win: Setup crash service according to command line parameters.
This commit is contained in:
parent
edd2bd74c9
commit
dce7e50636
3 changed files with 46 additions and 14 deletions
|
@ -24,7 +24,7 @@ namespace {
|
||||||
|
|
||||||
const wchar_t kTestPipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
|
const wchar_t kTestPipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
|
||||||
|
|
||||||
const wchar_t kCrashReportURL[] = L"https://clients2.google.com/cr/report";
|
const wchar_t kGoogleReportURL[] = L"https://clients2.google.com/cr/report";
|
||||||
const wchar_t kCheckPointFile[] = L"crash_checkpoint.txt";
|
const wchar_t kCheckPointFile[] = L"crash_checkpoint.txt";
|
||||||
|
|
||||||
typedef std::map<std::wstring, std::wstring> CrashMap;
|
typedef std::map<std::wstring, std::wstring> CrashMap;
|
||||||
|
@ -150,6 +150,7 @@ const char CrashService::kNoWindow[] = "no-window";
|
||||||
const char CrashService::kReporterTag[] = "reporter";
|
const char CrashService::kReporterTag[] = "reporter";
|
||||||
const char CrashService::kDumpsDir[] = "dumps-dir";
|
const char CrashService::kDumpsDir[] = "dumps-dir";
|
||||||
const char CrashService::kPipeName[] = "pipe-name";
|
const char CrashService::kPipeName[] = "pipe-name";
|
||||||
|
const char CrashService::kReporterURL[] = "reporter-url";
|
||||||
|
|
||||||
CrashService::CrashService()
|
CrashService::CrashService()
|
||||||
: sender_(NULL),
|
: sender_(NULL),
|
||||||
|
@ -195,10 +196,6 @@ bool CrashService::Initialize(const base::FilePath& operating_dir,
|
||||||
if (cmd_line.HasSwitch(kPipeName))
|
if (cmd_line.HasSwitch(kPipeName))
|
||||||
pipe_name = cmd_line.GetSwitchValueNative(kPipeName);
|
pipe_name = cmd_line.GetSwitchValueNative(kPipeName);
|
||||||
|
|
||||||
#ifdef _WIN64
|
|
||||||
pipe_name += L"-x64";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (max_reports > 0) {
|
if (max_reports > 0) {
|
||||||
// Create the http sender object.
|
// Create the http sender object.
|
||||||
sender_ = new CrashReportSender(checkpoint_path.value());
|
sender_ = new CrashReportSender(checkpoint_path.value());
|
||||||
|
@ -248,13 +245,17 @@ bool CrashService::Initialize(const base::FilePath& operating_dir,
|
||||||
if (cmd_line.HasSwitch(kReporterTag))
|
if (cmd_line.HasSwitch(kReporterTag))
|
||||||
reporter_tag_ = cmd_line.GetSwitchValueNative(kReporterTag);
|
reporter_tag_ = cmd_line.GetSwitchValueNative(kReporterTag);
|
||||||
|
|
||||||
|
reporter_url_ = kGoogleReportURL;
|
||||||
|
if (cmd_line.HasSwitch(kReporterURL))
|
||||||
|
reporter_url_ = cmd_line.GetSwitchValueNative(kReporterURL);
|
||||||
|
|
||||||
// Log basic information.
|
// Log basic information.
|
||||||
VLOG(1) << "pipe name is " << pipe_name
|
VLOG(1) << "pipe name is " << pipe_name
|
||||||
<< "\ndumps at " << dumps_path_to_use.value();
|
<< "\ndumps at " << dumps_path_to_use.value();
|
||||||
|
|
||||||
if (sender_) {
|
if (sender_) {
|
||||||
VLOG(1) << "checkpoint is " << checkpoint_path.value()
|
VLOG(1) << "checkpoint is " << checkpoint_path.value()
|
||||||
<< "\nserver is " << kCrashReportURL
|
<< "\nserver is " << reporter_url_
|
||||||
<< "\nmaximum " << sender_->max_reports_per_day() << " reports/day"
|
<< "\nmaximum " << sender_->max_reports_per_day() << " reports/day"
|
||||||
<< "\nreporter is " << reporter_tag_;
|
<< "\nreporter is " << reporter_tag_;
|
||||||
}
|
}
|
||||||
|
@ -406,8 +407,10 @@ DWORD CrashService::AsyncSendDump(void* context) {
|
||||||
base::AutoLock lock(info->self->sending_);
|
base::AutoLock lock(info->self->sending_);
|
||||||
VLOG(1) << "trying to send report for pid = " << info->pid;
|
VLOG(1) << "trying to send report for pid = " << info->pid;
|
||||||
google_breakpad::ReportResult send_result
|
google_breakpad::ReportResult send_result
|
||||||
= info->self->sender_->SendCrashReport(kCrashReportURL, info->map,
|
= info->self->sender_->SendCrashReport(info->self->reporter_url_,
|
||||||
info->dump_path, &report_id);
|
info->map,
|
||||||
|
info->dump_path,
|
||||||
|
&report_id);
|
||||||
switch (send_result) {
|
switch (send_result) {
|
||||||
case google_breakpad::RESULT_FAILED:
|
case google_breakpad::RESULT_FAILED:
|
||||||
report_id = L"<network issue>";
|
report_id = L"<network issue>";
|
||||||
|
|
|
@ -64,6 +64,9 @@ class CrashService {
|
||||||
// Override the name of the Windows named pipe on which we will
|
// Override the name of the Windows named pipe on which we will
|
||||||
// listen for crash dump request messages.
|
// listen for crash dump request messages.
|
||||||
static const char kPipeName[];
|
static const char kPipeName[];
|
||||||
|
// --reporter-url=<string>
|
||||||
|
// Override the URL to which crash reports will be sent to.
|
||||||
|
static const char kReporterURL[];
|
||||||
|
|
||||||
// Returns number of crash dumps handled.
|
// Returns number of crash dumps handled.
|
||||||
int requests_handled() const {
|
int requests_handled() const {
|
||||||
|
@ -110,6 +113,9 @@ class CrashService {
|
||||||
// the extra tag sent to the server with each dump.
|
// the extra tag sent to the server with each dump.
|
||||||
std::wstring reporter_tag_;
|
std::wstring reporter_tag_;
|
||||||
|
|
||||||
|
// receiver URL of crash reports.
|
||||||
|
std::wstring reporter_url_;
|
||||||
|
|
||||||
// clients serviced statistics:
|
// clients serviced statistics:
|
||||||
int requests_handled_;
|
int requests_handled_;
|
||||||
int requests_sent_;
|
int requests_sent_;
|
||||||
|
|
|
@ -10,19 +10,23 @@
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/string_util.h"
|
||||||
#include "common/crash_reporter/win/crash_service.h"
|
#include "common/crash_reporter/win/crash_service.h"
|
||||||
|
|
||||||
namespace crash_service {
|
namespace crash_service {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
const char kApplicationName[] = "application-name";
|
||||||
|
const wchar_t kPipeNameFormat[] = L"\\\\.\\pipe\\$1CrashService";
|
||||||
const wchar_t kStandardLogFile[] = L"operation_log.txt";
|
const wchar_t kStandardLogFile[] = L"operation_log.txt";
|
||||||
|
|
||||||
bool GetCrashServiceDirectory(base::FilePath* dir) {
|
bool GetCrashServiceDirectory(const std::wstring& application_name,
|
||||||
|
base::FilePath* dir) {
|
||||||
base::FilePath temp_dir;
|
base::FilePath temp_dir;
|
||||||
if (!file_util::GetTempDir(&temp_dir))
|
if (!file_util::GetTempDir(&temp_dir))
|
||||||
return false;
|
return false;
|
||||||
temp_dir = temp_dir.Append(L"atom_crashes");
|
temp_dir = temp_dir.Append(application_name + L" Crashes");
|
||||||
if (!file_util::PathExists(temp_dir)) {
|
if (!file_util::PathExists(temp_dir)) {
|
||||||
if (!file_util::CreateDirectory(temp_dir))
|
if (!file_util::CreateDirectory(temp_dir))
|
||||||
return false;
|
return false;
|
||||||
|
@ -33,14 +37,24 @@ bool GetCrashServiceDirectory(base::FilePath* dir) {
|
||||||
|
|
||||||
} // namespace.
|
} // namespace.
|
||||||
|
|
||||||
int Main(const wchar_t* cmd_line) {
|
int Main(const wchar_t* cmd) {
|
||||||
// Initialize all Chromium things.
|
// Initialize all Chromium things.
|
||||||
base::AtExitManager exit_manager;
|
base::AtExitManager exit_manager;
|
||||||
CommandLine::Init(0, NULL);
|
CommandLine::Init(0, NULL);
|
||||||
|
CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
|
// Use the application's name as pipe name and output directory.
|
||||||
|
if (!cmd_line.HasSwitch(kApplicationName)) {
|
||||||
|
LOG(ERROR) << "Application's name must be specified with --"
|
||||||
|
<< kApplicationName;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
std::wstring application_name = cmd_line.GetSwitchValueNative(
|
||||||
|
kApplicationName);
|
||||||
|
|
||||||
// We use/create a directory under the user's temp folder, for logging.
|
// We use/create a directory under the user's temp folder, for logging.
|
||||||
base::FilePath operating_dir;
|
base::FilePath operating_dir;
|
||||||
GetCrashServiceDirectory(&operating_dir);
|
GetCrashServiceDirectory(application_name, &operating_dir);
|
||||||
base::FilePath log_file = operating_dir.Append(kStandardLogFile);
|
base::FilePath log_file = operating_dir.Append(kStandardLogFile);
|
||||||
|
|
||||||
// Logging out to a file.
|
// Logging out to a file.
|
||||||
|
@ -52,11 +66,20 @@ int Main(const wchar_t* cmd_line) {
|
||||||
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
|
logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
|
||||||
logging::SetLogItems(true, false, true, false);
|
logging::SetLogItems(true, false, true, false);
|
||||||
|
|
||||||
VLOG(1) << "Session start. cmdline is [" << cmd_line << "]";
|
VLOG(1) << "Session start. cmdline is [" << cmd << "]";
|
||||||
|
|
||||||
|
// Setting the crash reporter.
|
||||||
|
string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat,
|
||||||
|
application_name,
|
||||||
|
NULL);
|
||||||
|
cmd_line.AppendSwitch("no-window");
|
||||||
|
cmd_line.AppendSwitchASCII("max-reports", "128");
|
||||||
|
cmd_line.AppendSwitchASCII("reporter", "atom-shell-crash-service");
|
||||||
|
cmd_line.AppendSwitchNative("pipe-name", pipe_name);
|
||||||
|
|
||||||
breakpad::CrashService crash_service;
|
breakpad::CrashService crash_service;
|
||||||
if (!crash_service.Initialize(operating_dir, operating_dir))
|
if (!crash_service.Initialize(operating_dir, operating_dir))
|
||||||
return 1;
|
return 2;
|
||||||
|
|
||||||
VLOG(1) << "Ready to process crash requests";
|
VLOG(1) << "Ready to process crash requests";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue