mac: Add --use-system-default-handler option to crashpad_handler

This is a weird option that causes crashpad_handler to discard the crash
handler it inherited and replace it with the system default. Its use is
not recommended.

BUG=chromium:538373
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1391463002 .
This commit is contained in:
Mark Mentovai 2015-10-06 14:15:18 -04:00
parent c95b30464a
commit 08e5e10167
2 changed files with 27 additions and 0 deletions

View File

@ -82,6 +82,13 @@ Listen on the given pipe name for connections from clients. 'PIPE' must be of
the form +\\.\pipe\<somename>+. This option is required. This option is only
valid on Windows.
*--reset-own-crash-exception-port-to-system-default*::
Causes the exception handler server to set its own crash handler to the system
default before beginning operation. This is only expected to be useful in cases
where the server inherits an inappropriate crash handler from its parent
process. This option is only valid on OS X. Use of this option is discouraged.
It should not be used absent extraordinary circumstances.
*--url*='URL'::
If uploads are enabled, sends crash reports to the Breakpad-type crash report
collection server at 'URL'. Uploads are disabled by default, and can only be

View File

@ -24,6 +24,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "client/crash_report_database.h"
#include "client/crashpad_client.h"
#include "tools/tool_support.h"
#include "handler/crash_report_upload_thread.h"
#include "util/stdlib/map_insert.h"
@ -55,6 +56,8 @@ void Usage(const base::FilePath& me) {
" --database=PATH store the crash report database at PATH\n"
#if defined(OS_MACOSX)
" --handshake-fd=FD establish communication with the client over FD\n"
" --reset-own-crash-exception-port-to-system-default\n"
" reset the server's exception handler to default\n"
#elif defined(OS_WIN)
" --pipe-name=PIPE communicate with the client over PIPE\n"
#endif // OS_MACOSX
@ -78,6 +81,7 @@ int HandlerMain(int argc, char* argv[]) {
kOptionDatabase,
#if defined(OS_MACOSX)
kOptionHandshakeFD,
kOptionResetOwnCrashExceptionPortToSystemDefault,
#elif defined(OS_WIN)
kOptionPipeName,
#endif // OS_MACOSX
@ -94,12 +98,14 @@ int HandlerMain(int argc, char* argv[]) {
const char* database;
#if defined(OS_MACOSX)
int handshake_fd;
bool reset_own_crash_exception_port_to_system_default;
#elif defined(OS_WIN)
std::string pipe_name;
#endif
} options = {};
#if defined(OS_MACOSX)
options.handshake_fd = -1;
options.reset_own_crash_exception_port_to_system_default = false;
#endif
const option long_options[] = {
@ -107,6 +113,10 @@ int HandlerMain(int argc, char* argv[]) {
{"database", required_argument, nullptr, kOptionDatabase},
#if defined(OS_MACOSX)
{"handshake-fd", required_argument, nullptr, kOptionHandshakeFD},
{"reset-own-crash-exception-port-to-system-default",
no_argument,
nullptr,
kOptionResetOwnCrashExceptionPortToSystemDefault},
#elif defined(OS_WIN)
{"pipe-name", required_argument, nullptr, kOptionPipeName},
#endif
@ -147,6 +157,10 @@ int HandlerMain(int argc, char* argv[]) {
}
break;
}
case kOptionResetOwnCrashExceptionPortToSystemDefault: {
options.reset_own_crash_exception_port_to_system_default = true;
break;
}
#elif defined(OS_WIN)
case kOptionPipeName: {
options.pipe_name = optarg;
@ -196,6 +210,12 @@ int HandlerMain(int argc, char* argv[]) {
return EXIT_FAILURE;
}
#if defined(OS_MACOSX)
if (options.reset_own_crash_exception_port_to_system_default) {
CrashpadClient::UseSystemDefaultHandler();
}
#endif
ExceptionHandlerServer exception_handler_server;
#if defined(OS_MACOSX)