mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-06 14:57:41 +00:00
Expose install_fatal_error_handler() through the C API.
I expose the API with some caveats: - The C++ API involves a traditional void* opaque pointer for the fatal error callback. The C API doesn’t do this. I don’t think that the void* opaque pointer makes any sense since this is a global callback - there will only be one of them. So if you need to pass some data to your callback, just put it in a global variable. - The bindings will ignore the gen_crash_diag boolean. I ignore it because (1) I don’t know what it does, (2) it’s not documented AFAIK, and (3) I couldn’t imagine any use for it. I made the gut call that it probably wasn’t important enough to expose through the C API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192864 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
adbd3ae1df
commit
0739140b05
@ -416,6 +416,22 @@ void LLVMShutdown();
|
|||||||
char *LLVMCreateMessage(const char *Message);
|
char *LLVMCreateMessage(const char *Message);
|
||||||
void LLVMDisposeMessage(char *Message);
|
void LLVMDisposeMessage(char *Message);
|
||||||
|
|
||||||
|
typedef void (*LLVMFatalErrorHandler)(const char *Reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install a fatal error handler. By default, if LLVM detects a fatal error, it
|
||||||
|
* will call exit(1). This may not be appropriate in many contexts. For example,
|
||||||
|
* doing exit(1) will bypass many crash reporting/tracing system tools. This
|
||||||
|
* function allows you to install a callback that will be invoked prior to the
|
||||||
|
* call to exit(1).
|
||||||
|
*/
|
||||||
|
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the fatal error handler. This resets LLVM's fatal error handling
|
||||||
|
* behavior to the default.
|
||||||
|
*/
|
||||||
|
void LLVMResetFatalErrorHandler(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup LLVMCCoreContext Contexts
|
* @defgroup LLVMCCoreContext Contexts
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "llvm/Support/Signals.h"
|
#include "llvm/Support/Signals.h"
|
||||||
#include "llvm/Support/Threading.h"
|
#include "llvm/Support/Threading.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm-c/Core.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
@ -102,3 +103,19 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
|
|||||||
LLVM_BUILTIN_UNREACHABLE;
|
LLVM_BUILTIN_UNREACHABLE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void bindingsErrorHandler(void *user_data, const std::string& reason,
|
||||||
|
bool gen_crash_diag) {
|
||||||
|
LLVMFatalErrorHandler handler =
|
||||||
|
reinterpret_cast<LLVMFatalErrorHandler>(user_data);
|
||||||
|
handler(reason.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) {
|
||||||
|
install_fatal_error_handler(
|
||||||
|
bindingsErrorHandler, reinterpret_cast<void*>(Handler));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LLVMResetFatalErrorHandler() {
|
||||||
|
remove_fatal_error_handler();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user