Commit 2a3cfb82 authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

linux: add a first chance handler helper

Change-Id: I504212d4ad0a51edf6aad8df9f5bde79f84b782d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849267Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704289}
parent 8dbdb8de
...@@ -23,6 +23,32 @@ ...@@ -23,6 +23,32 @@
namespace crash_reporter { namespace crash_reporter {
namespace {
// TODO(jperaza): This is the first chance handler type used by Breakpad and v8.
// The Crashpad FirstChanceHandler type explicitly declares the third parameter
// to be a ucontext_t* instead of a void*. Using a reinterpret cast to convert
// one function type to another causes calling the handler to fail with SIGILL
// when CFI is enabled. Use a helper with Crashpad's FirstChanceHandler type
// to delegate to the real first chance handler instead of re-interpreting the
// handler itself. This can be removed if the two function types converge.
bool (*g_first_chance_handler)(int, siginfo_t*, void*);
bool FirstChanceHandlerHelper(int signo,
siginfo_t* siginfo,
ucontext_t* context) {
return g_first_chance_handler(signo, siginfo, context);
}
} // namespace
void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*)) {
DCHECK(!g_first_chance_handler);
g_first_chance_handler = handler;
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(
FirstChanceHandlerHelper);
}
// TODO(jperaza): Remove kEnableCrashpad and IsCrashpadEnabled() when Crashpad // TODO(jperaza): Remove kEnableCrashpad and IsCrashpadEnabled() when Crashpad
// is fully enabled on Linux. // is fully enabled on Linux.
const char kEnableCrashpad[] = "enable-crashpad"; const char kEnableCrashpad[] = "enable-crashpad";
...@@ -31,11 +57,6 @@ bool IsCrashpadEnabled() { ...@@ -31,11 +57,6 @@ bool IsCrashpadEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableCrashpad); return base::CommandLine::ForCurrentProcess()->HasSwitch(kEnableCrashpad);
} }
void SetFirstChanceExceptionHandler(bool (*handler)(int, siginfo_t*, void*)) {
crashpad::CrashpadClient::SetFirstChanceExceptionHandler(
reinterpret_cast<crashpad::CrashpadClient::FirstChanceHandler>(handler));
}
bool GetHandlerSocket(int* fd, pid_t* pid) { bool GetHandlerSocket(int* fd, pid_t* pid) {
return crashpad::CrashpadClient::GetHandlerSocket(fd, pid); return crashpad::CrashpadClient::GetHandlerSocket(fd, pid);
} }
......
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