cros: Pass a dir for minidumps to crash_reporter

This change add function to pass a file directory to Chrome OS's
crash_reporter to write minidumps to. This is used for tests.

BUG=chromium:944123

Change-Id: Ia61955d5ec671c61adde14e61dc72e4be32e389f
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1775290
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Tim Zheng 2019-09-09 14:55:20 -07:00 committed by Commit Bot
parent 9a62344612
commit 9b314d5fa8
3 changed files with 25 additions and 0 deletions

View File

@ -163,6 +163,8 @@ void Usage(const base::FilePath& me) {
" only if uploads are enabled for the database\n"
#if defined(OS_CHROMEOS)
" --use-cros-crash-reporter\n"
" --minidump-dir-for-tests=TEST_MINIDUMP_DIR\n"
" the directory for testing minidumps\n"
#endif // OS_CHROMEOS
" --help display this help and exit\n"
" --version output version information and exit\n",
@ -197,6 +199,7 @@ struct Options {
bool upload_gzip;
#if defined(OS_CHROMEOS)
bool use_cros_crash_reporter;
base::FilePath minidump_dir_for_tests;
#endif // OS_CHROMEOS
};
@ -571,6 +574,7 @@ int HandlerMain(int argc,
kOptionURL,
#if defined(OS_CHROMEOS)
kOptionUseCrosCrashReporter,
kOptionMinidumpDirForTests,
#endif // OS_CHROMEOS
// Standard options.
@ -642,6 +646,10 @@ int HandlerMain(int argc,
no_argument,
nullptr,
kOptionUseCrosCrashReporter},
{"minidump_dir_for_tests",
required_argument,
nullptr,
kOptionMinidumpDirForTests},
#endif // OS_CHROMEOS
{"help", no_argument, nullptr, kOptionHelp},
{"version", no_argument, nullptr, kOptionVersion},
@ -789,6 +797,11 @@ int HandlerMain(int argc,
options.use_cros_crash_reporter = true;
break;
}
case kOptionMinidumpDirForTests: {
options.minidump_dir_for_tests = base::FilePath(
ToolSupport::CommandLineArgumentToFilePathStringType(optarg));
break;
}
#endif // OS_CHROMEOS
case kOptionHelp: {
Usage(me);
@ -946,6 +959,12 @@ int HandlerMain(int argc,
user_stream_sources);
#endif // OS_CHROMEOS
#if defined(OS_CHROMEOS)
if (!options.minidump_dir_for_tests.empty()) {
exception_handler->SetDumpDir(options.minidump_dir_for_tests);
}
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID)
if (options.exception_information_address) {
ExceptionHandlerProtocol::ClientInformation info;

View File

@ -255,6 +255,9 @@ bool CrosCrashReportExceptionHandler::HandleExceptionWithConnection(
argv.push_back("--crash_loop_before=" +
std::to_string(info.crash_loop_before_time));
}
if (!dump_dir_.empty()) {
argv.push_back("--chrome_dump_dir=" + dump_dir_.value());
}
if (!DoubleForkAndExec(argv,
nullptr /* envp */,
@ -270,6 +273,7 @@ bool CrosCrashReportExceptionHandler::HandleExceptionWithConnection(
if (local_report_id != nullptr) {
*local_report_id = uuid;
}
LOG(INFO) << "Successfully wrote report " << uuid.ToString();
Metrics::ExceptionCaptureResult(Metrics::CaptureResult::kSuccess);
return true;

View File

@ -76,6 +76,7 @@ class CrosCrashReportExceptionHandler
int broker_sock,
UUID* local_report_id = nullptr) override;
void SetDumpDir(const base::FilePath& dump_dir) { dump_dir_ = dump_dir; }
private:
bool HandleExceptionWithConnection(
PtraceConnection* connection,
@ -88,6 +89,7 @@ class CrosCrashReportExceptionHandler
CrashReportDatabase* database_; // weak
const std::map<std::string, std::string>* process_annotations_; // weak
const UserStreamDataSources* user_stream_data_sources_; // weak
base::FilePath dump_dir_;
DISALLOW_COPY_AND_ASSIGN(CrosCrashReportExceptionHandler);
};