Commit 2a068f41 authored by Tristan Rice's avatar Tristan Rice Committed by Facebook Github Bot

ExceptionTracerLib: allow overriding the deleter method for thrown exceptions

Summary:
This allows us to use a custom deleter to track the lifetime of exceptions in
the case of smart pointers which may be persisted outside catch blocks.

Reviewed By: yfeldblum

Differential Revision: D16572937

fbshipit-source-id: ad2f0a981a2b31ef4b17a902719b684f538c29c7
parent dd239cec
...@@ -103,7 +103,7 @@ namespace { ...@@ -103,7 +103,7 @@ namespace {
* This handler gathers statistics on all exceptions thrown by the program * This handler gathers statistics on all exceptions thrown by the program
* Information is being stored in thread local storage. * Information is being stored in thread local storage.
*/ */
void throwHandler(void*, std::type_info* exType, void (*)(void*)) noexcept { void throwHandler(void*, std::type_info* exType, void (**)(void*)) noexcept {
// This array contains the exception type and the stack frame // This array contains the exception type and the stack frame
// pointers so they get all hashed together. // pointers so they get all hashed together.
uintptr_t frames[kMaxFrames + 1]; uintptr_t frames[kMaxFrames + 1];
......
...@@ -67,7 +67,7 @@ void moveTopException(StackTraceStack& from, StackTraceStack& to) { ...@@ -67,7 +67,7 @@ void moveTopException(StackTraceStack& from, StackTraceStack& to) {
struct Initializer { struct Initializer {
Initializer() { Initializer() {
registerCxaThrowCallback( registerCxaThrowCallback(
[](void*, std::type_info*, void (*)(void*)) noexcept { [](void*, std::type_info*, void (**)(void*)) noexcept {
addActiveException(); addActiveException();
}); });
......
...@@ -103,7 +103,7 @@ void __cxa_throw( ...@@ -103,7 +103,7 @@ void __cxa_throw(
void (*destructor)(void*)) { void (*destructor)(void*)) {
static auto orig_cxa_throw = static auto orig_cxa_throw =
reinterpret_cast<decltype(&__cxa_throw)>(dlsym(RTLD_NEXT, "__cxa_throw")); reinterpret_cast<decltype(&__cxa_throw)>(dlsym(RTLD_NEXT, "__cxa_throw"));
getCxaThrowCallbacks().invoke(thrownException, type, destructor); getCxaThrowCallbacks().invoke(thrownException, type, &destructor);
orig_cxa_throw(thrownException, type, destructor); orig_cxa_throw(thrownException, type, destructor);
__builtin_unreachable(); // orig_cxa_throw never returns __builtin_unreachable(); // orig_cxa_throw never returns
} }
......
...@@ -29,7 +29,7 @@ namespace detail { ...@@ -29,7 +29,7 @@ namespace detail {
* We, however, want callbacks to be exception safe. * We, however, want callbacks to be exception safe.
* This dummies are an ugly workaround that problem. * This dummies are an ugly workaround that problem.
*/ */
void dummyCxaThrow(void*, std::type_info*, void (*)(void*)) noexcept; void dummyCxaThrow(void*, std::type_info*, void (**)(void*)) noexcept;
void dummyCxaBeginCatch(void*) noexcept; void dummyCxaBeginCatch(void*) noexcept;
void dummyCxaRethrow() noexcept; void dummyCxaRethrow() noexcept;
void dummyCxaEndCatch() noexcept; void dummyCxaEndCatch() noexcept;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment