[PATCH] expose install_fatal_error_handler() through the C API
Filip Pizlo
fpizlo at apple.com
Wed Oct 16 16:46:36 PDT 2013
Hi!
If LLVM encounters badness it may call report_fatal_error(). The default behavior of this function is to call exit(1). That doesn’t work out so great if LLVM is being used as a library in pretty much anything other than a command-line tool. For example, if LLVM is in a daemon or in a UI app, calling exit(1) will bypass any stack trace or error reporting that the system would normally do for “fatal” conditions.
Hence being able to override the behavior of report_fatal_error(), like what install_fatal_error_handler() does, is critical enough that it should be exposed via the C API.
This patch does that.
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.
-Filip
-------------- next part --------------
A non-text attachment was scrubbed...
Name: install-fatal-error-handler.diff
Type: application/octet-stream
Size: 2010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131016/16486f06/attachment.obj>
More information about the llvm-commits
mailing list