19 #include "llvm/Config/config.h"
32 #if defined(HAVE_UNISTD_H)
50 assert(!
ErrorHandler &&
"Error handler already registered!\n");
75 void* handlerData =
nullptr;
85 handler(handlerData, Reason.
str(), GenCrashDiag);
92 OS <<
"LLVM ERROR: " << Reason <<
"\n";
112 dbgs() << msg <<
"\n";
113 dbgs() <<
"UNREACHABLE executed";
115 dbgs() <<
" at " << file <<
":" << line;
118 #ifdef LLVM_BUILTIN_UNREACHABLE
121 LLVM_BUILTIN_UNREACHABLE;
126 bool gen_crash_diag) {
129 handler(reason.c_str());
143 #include <winerror.h>
146 #define MAP_ERR_TO_COND(x, y) \
148 return make_error_code(errc::y)
152 MAP_ERR_TO_COND(ERROR_ACCESS_DENIED, permission_denied);
153 MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS, file_exists);
154 MAP_ERR_TO_COND(ERROR_BAD_UNIT, no_such_device);
155 MAP_ERR_TO_COND(ERROR_BUFFER_OVERFLOW, filename_too_long);
156 MAP_ERR_TO_COND(ERROR_BUSY, device_or_resource_busy);
157 MAP_ERR_TO_COND(ERROR_BUSY_DRIVE, device_or_resource_busy);
158 MAP_ERR_TO_COND(ERROR_CANNOT_MAKE, permission_denied);
159 MAP_ERR_TO_COND(ERROR_CANTOPEN, io_error);
160 MAP_ERR_TO_COND(ERROR_CANTREAD, io_error);
161 MAP_ERR_TO_COND(ERROR_CANTWRITE, io_error);
162 MAP_ERR_TO_COND(ERROR_CURRENT_DIRECTORY, permission_denied);
163 MAP_ERR_TO_COND(ERROR_DEV_NOT_EXIST, no_such_device);
164 MAP_ERR_TO_COND(ERROR_DEVICE_IN_USE, device_or_resource_busy);
165 MAP_ERR_TO_COND(ERROR_DIR_NOT_EMPTY, directory_not_empty);
166 MAP_ERR_TO_COND(ERROR_DIRECTORY, invalid_argument);
167 MAP_ERR_TO_COND(ERROR_DISK_FULL, no_space_on_device);
168 MAP_ERR_TO_COND(ERROR_FILE_EXISTS, file_exists);
169 MAP_ERR_TO_COND(ERROR_FILE_NOT_FOUND, no_such_file_or_directory);
170 MAP_ERR_TO_COND(ERROR_HANDLE_DISK_FULL, no_space_on_device);
171 MAP_ERR_TO_COND(ERROR_INVALID_ACCESS, permission_denied);
172 MAP_ERR_TO_COND(ERROR_INVALID_DRIVE, no_such_device);
173 MAP_ERR_TO_COND(ERROR_INVALID_FUNCTION, function_not_supported);
174 MAP_ERR_TO_COND(ERROR_INVALID_HANDLE, invalid_argument);
175 MAP_ERR_TO_COND(ERROR_INVALID_NAME, invalid_argument);
176 MAP_ERR_TO_COND(ERROR_LOCK_VIOLATION, no_lock_available);
177 MAP_ERR_TO_COND(ERROR_LOCKED, no_lock_available);
178 MAP_ERR_TO_COND(ERROR_NEGATIVE_SEEK, invalid_argument);
179 MAP_ERR_TO_COND(ERROR_NOACCESS, permission_denied);
180 MAP_ERR_TO_COND(ERROR_NOT_ENOUGH_MEMORY, not_enough_memory);
181 MAP_ERR_TO_COND(ERROR_NOT_READY, resource_unavailable_try_again);
182 MAP_ERR_TO_COND(ERROR_OPEN_FAILED, io_error);
183 MAP_ERR_TO_COND(ERROR_OPEN_FILES, device_or_resource_busy);
184 MAP_ERR_TO_COND(ERROR_OUTOFMEMORY, not_enough_memory);
185 MAP_ERR_TO_COND(ERROR_PATH_NOT_FOUND, no_such_file_or_directory);
186 MAP_ERR_TO_COND(ERROR_BAD_NETPATH, no_such_file_or_directory);
187 MAP_ERR_TO_COND(ERROR_READ_FAULT, io_error);
188 MAP_ERR_TO_COND(ERROR_RETRY, resource_unavailable_try_again);
189 MAP_ERR_TO_COND(ERROR_SEEK, io_error);
190 MAP_ERR_TO_COND(ERROR_SHARING_VIOLATION, permission_denied);
191 MAP_ERR_TO_COND(ERROR_TOO_MANY_OPEN_FILES, too_many_files_open);
192 MAP_ERR_TO_COND(ERROR_WRITE_FAULT, io_error);
193 MAP_ERR_TO_COND(ERROR_WRITE_PROTECT, permission_denied);
194 MAP_ERR_TO_COND(WSAEACCES, permission_denied);
195 MAP_ERR_TO_COND(WSAEBADF, bad_file_descriptor);
196 MAP_ERR_TO_COND(WSAEFAULT, bad_address);
197 MAP_ERR_TO_COND(WSAEINTR, interrupted);
198 MAP_ERR_TO_COND(WSAEINVAL, invalid_argument);
199 MAP_ERR_TO_COND(WSAEMFILE, too_many_files_open);
200 MAP_ERR_TO_COND(WSAENAMETOOLONG, filename_too_long);
202 return std::error_code(EV, std::system_category());
size_t size() const
size - Get the string size.
static void bindingsErrorHandler(void *user_data, const std::string &reason, bool gen_crash_diag)
A raw_ostream that writes to an SmallVector or SmallString.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
static void * ErrorHandlerUserData
void LLVMResetFatalErrorHandler()
Reset the fatal error handler.
std::string str() const
Return the twine contents as a std::string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void(* fatal_error_handler_t)(void *user_data, const std::string &reason, bool gen_crash_diag)
An error handler callback.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If Reload the main corpus periodically to get new units discovered by other processes Read the given input file
static fatal_error_handler_t ErrorHandler
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void remove_fatal_error_handler()
Restores default error handling behaviour.
#define LLVM_EXTENSION
LLVM_EXTENSION - Support compilers where we have a keyword to suppress pedantic diagnostics.
void(* LLVMFatalErrorHandler)(const char *Reason)
Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruct...
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
std::error_code mapWindowsError(unsigned EV)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void write(void *memory, value_type value)
Write a value to memory with a particular endianness.
StringRef str()
Flushes the stream contents to the target vector and return a StringRef for the vector contents...
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler)
Install a fatal error handler.
LLVM_ATTRIBUTE_NORETURN void llvm_unreachable_internal(const char *msg=nullptr, const char *file=nullptr, unsigned line=0)
This function calls abort(), and prints the optional message to stderr.
static ManagedStatic< sys::Mutex > ErrorHandlerMutex
StringRef - Represent a constant reference to a string, i.e.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
void install_fatal_error_handler(fatal_error_handler_t handler, void *user_data=nullptr)
install_fatal_error_handler - Installs a new error handler to be used whenever a serious (non-recover...