Commit ab2d3d24 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Fix --crash-me.

This change moves the initializing of the crash reporter sooner, before
the command line modes are being handled.

There is still some code that executes outside of the crash handler, such
as command line parsing and logging initialization.

Bug: 1060326
Change-Id: I2631d7ba1be18a33ca4984a127dd3b4f56f47003
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2096902Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748856}
parent fae7e292
......@@ -13,10 +13,6 @@
#include "base/task/single_thread_task_executor.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/updater/crash_client.h"
#include "chrome/updater/crash_reporter.h"
#include "chrome/updater/updater_version.h"
#include "components/crash/core/common/crash_key.h"
namespace updater {
......@@ -24,16 +20,6 @@ App::App() = default;
App::~App() = default;
int App::Run() {
crash_reporter::InitializeCrashKeys();
static crash_reporter::CrashKeyString<16> crash_key_process_type(
"process_type");
crash_key_process_type.Set("updater");
if (CrashClient::GetInstance()->InitializeCrashReporting())
VLOG(1) << "Crash reporting initialized.";
else
VLOG(1) << "Crash reporting is not available.";
StartCrashReporter(UPDATER_VERSION_STRING);
base::ThreadPoolInstance::CreateAndStartWithDefaultParams("Updater");
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
Initialize();
......
......@@ -16,7 +16,9 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/crash_client.h"
#include "chrome/updater/crash_reporter.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util.h"
#include "components/crash/core/common/crash_key.h"
#if defined(OS_WIN)
#include "chrome/updater/server/win/server.h"
......@@ -55,7 +57,20 @@ void InitLogging(const base::CommandLine& command_line) {
true, // enable_thread_id
true, // enable_timestamp
false); // enable_tickcount
VLOG(1) << "Log file " << settings.log_file_path;
VLOG(1) << "Version " << UPDATER_VERSION_STRING << ", log file "
<< settings.log_file_path;
}
void InitializeCrashReporting() {
crash_reporter::InitializeCrashKeys();
static crash_reporter::CrashKeyString<16> crash_key_process_type(
"process_type");
crash_key_process_type.Set("updater");
if (CrashClient::GetInstance()->InitializeCrashReporting())
VLOG(1) << "Crash reporting initialized.";
else
VLOG(1) << "Crash reporting is not available.";
StartCrashReporter(UPDATER_VERSION_STRING);
}
} // namespace
......@@ -64,8 +79,9 @@ int HandleUpdaterCommands(const base::CommandLine* command_line) {
DCHECK(!command_line->HasSwitch(kCrashHandlerSwitch));
if (command_line->HasSwitch(kCrashMeSwitch)) {
int* ptr = nullptr;
return *ptr;
// Records a backtrace in the log, crashes the program, saves a crash dump,
// and reports the crash.
CHECK(false) << "--crash-me was used.";
}
if (command_line->HasSwitch(kServerSwitch)) {
......@@ -105,6 +121,8 @@ int UpdaterMain(int argc, const char* const* argv) {
if (command_line->HasSwitch(kCrashHandlerSwitch))
return CrashReporterMain();
InitializeCrashReporting();
return HandleUpdaterCommands(command_line);
}
......
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