diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-06 01:54:42 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-06 01:54:42 +0000 |
commit | 54543699023a921731fad3aa6fb5a1702e955ddd (patch) | |
tree | 07bbff310be1c10a292f22c89f9609d93af76843 /chrome/tools | |
parent | 3c85f77376d7c6df2c356f2bb5905bc25a9cbc71 (diff) | |
download | chromium_src-54543699023a921731fad3aa6fb5a1702e955ddd.zip chromium_src-54543699023a921731fad3aa6fb5a1702e955ddd.tar.gz chromium_src-54543699023a921731fad3aa6fb5a1702e955ddd.tar.bz2 |
Windows Breakpad: Allow the crash dump dir and pipe name to be overridden
Change crash_service.exe so that the named pipe it listens on
(normally global) and the directory it writes to (normally per-user)
can both be overridden via command line options.
Similarly, add an environment variable to Chromium for connecting to
crash_service.exe via a non-default named pipe.
This will allow automated tests of Chromium's Breakpad crash reporting
to be more robust. A test runner can use a temp dir for crashes and a
temporary named pipe, so that it does not have to worry about
pre-existing instances of crash_service.exe or pre-existing dump
files.
BUG=http://code.google.com/p/nativeclient/issues/detail?id=2006
TEST=inbrowser_crash_test in the NaCl tree, with the change http://codereview.chromium.org/7569002
Review URL: http://codereview.chromium.org/7538036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95714 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rw-r--r-- | chrome/tools/crash_service/crash_service.cc | 24 | ||||
-rw-r--r-- | chrome/tools/crash_service/crash_service.h | 9 |
2 files changed, 25 insertions, 8 deletions
diff --git a/chrome/tools/crash_service/crash_service.cc b/chrome/tools/crash_service/crash_service.cc index ed31107..5872935 100644 --- a/chrome/tools/crash_service/crash_service.cc +++ b/chrome/tools/crash_service/crash_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -149,6 +149,8 @@ struct DumpJobInfo { const char CrashService::kMaxReports[] = "max-reports"; const char CrashService::kNoWindow[] = "no-window"; const char CrashService::kReporterTag[] = "reporter"; +const char CrashService::kDumpsDir[] = "dumps-dir"; +const char CrashService::kPipeName[] = "pipe-name"; CrashService::CrashService(const std::wstring& report_dir) : report_path_(report_dir), @@ -172,7 +174,7 @@ bool CrashService::Initialize(const std::wstring& command_line) { using google_breakpad::CrashReportSender; using google_breakpad::CrashGenerationServer; - const wchar_t* pipe_name = kTestPipeName; + std::wstring pipe_name = kTestPipeName; int max_reports = -1; // The checkpoint file allows CrashReportSender to enforce the the maximum @@ -189,18 +191,26 @@ bool CrashService::Initialize(const std::wstring& command_line) { } report_path_ = user_data_dir.Append(chrome::kCrashReportLog); + CommandLine cmd_line = CommandLine::FromString(command_line); + FilePath dumps_path; - if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) { - LOG(ERROR) << "could not get DIR_CRASH_DUMPS"; - return false; + if (cmd_line.HasSwitch(kDumpsDir)) { + dumps_path = FilePath(cmd_line.GetSwitchValueNative(kDumpsDir)); + } else { + if (!PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path)) { + LOG(ERROR) << "could not get DIR_CRASH_DUMPS"; + return false; + } } - CommandLine cmd_line = CommandLine::FromString(command_line); - // We can override the send reports quota with a command line switch. if (cmd_line.HasSwitch(kMaxReports)) max_reports = _wtoi(cmd_line.GetSwitchValueNative(kMaxReports).c_str()); + // Allow the global pipe name to be overridden for better testability. + if (cmd_line.HasSwitch(kPipeName)) + pipe_name = cmd_line.GetSwitchValueNative(kPipeName); + if (max_reports > 0) { // Create the http sender object. sender_ = new CrashReportSender(checkpoint_path.value()); diff --git a/chrome/tools/crash_service/crash_service.h b/chrome/tools/crash_service/crash_service.h index 82bc4be..9cb45d1 100644 --- a/chrome/tools/crash_service/crash_service.h +++ b/chrome/tools/crash_service/crash_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -56,6 +56,13 @@ class CrashService { // page in the crash server. This should be a 25 chars or less string. // The default tag if not specified is 'crash svc'. static const char kReporterTag[]; + // --dumps-dir=<directory-path> + // Override the directory to which crash dump files will be written. + static const char kDumpsDir[]; + // --pipe-name=<string> + // Override the name of the Windows named pipe on which we will + // listen for crash dump request messages. + static const char kPipeName[]; // Returns number of crash dumps handled. int requests_handled() const { |