diff options
author | andresantoso@chromium.org <andresantoso@chromium.org> | 2014-09-15 22:48:18 +0000 |
---|---|---|
committer | andresantoso@chromium.org <andresantoso@chromium.org> | 2014-09-15 22:48:18 +0000 |
commit | def0b7a7b0c4ad3c2f27ddddffcbba7892594da6 (patch) | |
tree | b7af14b1b86942c590c0ae074eda01e72a404e4c /src/client/mac/crash_generation | |
parent | This CL initialize NSData in HTTPMultipartUpload.m to nil. (diff) | |
download | breakpad-def0b7a7b0c4ad3c2f27ddddffcbba7892594da6.tar.xz |
Mac: Add support for in-process crash reporting to Breakpad.
Add new option BREAKPAD_IN_PROCESS.
If YES, Breakpad will write the dump file in-process and then launch the reporter
executable as a child process.
Originally reviewed at https://codereview.chromium.org/571523004/
BUG=chromium:414239
R=mark@chromium.org
Review URL: https://breakpad.appspot.com/1714002
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1375 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/mac/crash_generation')
-rw-r--r-- | src/client/mac/crash_generation/ConfigFile.mm | 2 | ||||
-rw-r--r-- | src/client/mac/crash_generation/Inspector.h | 1 | ||||
-rw-r--r-- | src/client/mac/crash_generation/Inspector.mm | 51 |
3 files changed, 5 insertions, 49 deletions
diff --git a/src/client/mac/crash_generation/ConfigFile.mm b/src/client/mac/crash_generation/ConfigFile.mm index dbb0f24d..acab7de8 100644 --- a/src/client/mac/crash_generation/ConfigFile.mm +++ b/src/client/mac/crash_generation/ConfigFile.mm @@ -36,7 +36,7 @@ #include <sys/time.h> #import "client/apple/Framework/BreakpadDefines.h" -#import "GTMDefines.h" +#import "common/mac/GTMDefines.h" namespace google_breakpad { diff --git a/src/client/mac/crash_generation/Inspector.h b/src/client/mac/crash_generation/Inspector.h index 7e2eec80..67123551 100644 --- a/src/client/mac/crash_generation/Inspector.h +++ b/src/client/mac/crash_generation/Inspector.h @@ -138,7 +138,6 @@ class Inspector { bool InspectTask(); kern_return_t SendAcknowledgement(); - void LaunchReporter(const char *inConfigFilePath); // The bootstrap port in which the inspector is registered and into which it // must check in. diff --git a/src/client/mac/crash_generation/Inspector.mm b/src/client/mac/crash_generation/Inspector.mm index d226ca38..dc6f4808 100644 --- a/src/client/mac/crash_generation/Inspector.mm +++ b/src/client/mac/crash_generation/Inspector.mm @@ -43,6 +43,7 @@ #import "common/mac/MachIPC.h" #include "common/mac/bootstrap_compat.h" +#include "common/mac/launch_reporter.h" #import "GTMDefines.h" @@ -76,7 +77,9 @@ void Inspector::Inspect(const char *receive_port_name) { if (wrote_minidump) { // Ask the user if he wants to upload the crash report to a server, // and do so if he agrees. - LaunchReporter(config_file_.GetFilePath()); + LaunchReporter( + config_params_.GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION), + config_file_.GetFilePath()); } else { fprintf(stderr, "Inspection of crashed process failed\n"); } @@ -355,51 +358,5 @@ kern_return_t Inspector::SendAcknowledgement() { return KERN_INVALID_NAME; } -//============================================================================= -void Inspector::LaunchReporter(const char *inConfigFilePath) { - // Extract the path to the reporter executable. - const char *reporterExecutablePath = - config_params_.GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION); - - // Setup and launch the crash dump sender. - const char *argv[3]; - argv[0] = reporterExecutablePath; - argv[1] = inConfigFilePath; - argv[2] = NULL; - - // Launch the reporter - pid_t pid = fork(); - - // If we're in the child, load in our new executable and run. - // The parent will not wait for the child to complete. - if (pid == 0) { - execv(argv[0], (char * const *)argv); - config_file_.Unlink(); // launch failed - get rid of config file - _exit(1); - } - - // Wait until the Reporter child process exits. - // - - // We'll use a timeout of one minute. - int timeoutCount = 60; // 60 seconds - - while (timeoutCount-- > 0) { - int status; - pid_t result = waitpid(pid, &status, WNOHANG); - - if (result == 0) { - // The child has not yet finished. - sleep(1); - } else if (result == -1) { - // error occurred. - break; - } else { - // child has finished - break; - } - } -} - } // namespace google_breakpad |