Commit 54543699 authored by mseaborn@chromium.org's avatar mseaborn@chromium.org

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
parent 3c85f773
......@@ -519,7 +519,15 @@ static DWORD __stdcall InitCrashReporterThread(void* param) {
std::wstring pipe_name;
if (use_crash_service) {
// Crash reporting is done by crash_service.exe.
pipe_name = kChromePipeName;
const wchar_t* var_name = L"CHROME_BREAKPAD_PIPE_NAME";
DWORD value_length = ::GetEnvironmentVariableW(var_name, NULL, 0);
if (value_length == 0) {
pipe_name = kChromePipeName;
} else {
scoped_array<wchar_t> value(new wchar_t[value_length]);
::GetEnvironmentVariableW(var_name, value.get(), value_length);
pipe_name = value.get();
}
} else {
// We want to use the Google Update crash reporting. We need to check if the
// user allows it first (in case the administrator didn't already decide
......
// 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());
......
// 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 {
......
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