linux: Collect Crashpad options from CrashpadInfos

Bug: crashpad:30
Change-Id: I233780e97a4b23238995af409c5f40d2e809906b
Reviewed-on: https://chromium-review.googlesource.com/848248
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Joshua Peraza 2018-01-10 11:53:15 -08:00 committed by Commit Bot
parent 94d65e0e9c
commit fa197c267c
2 changed files with 47 additions and 0 deletions

View File

@ -79,6 +79,45 @@ bool ProcessSnapshotLinux::InitializeException(
return true;
}
void ProcessSnapshotLinux::GetCrashpadOptions(
CrashpadInfoClientOptions* options) {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
CrashpadInfoClientOptions local_options;
for (const auto& module : modules_) {
CrashpadInfoClientOptions module_options;
if (!module->GetCrashpadOptions(&module_options)) {
continue;
}
if (local_options.crashpad_handler_behavior == TriState::kUnset) {
local_options.crashpad_handler_behavior =
module_options.crashpad_handler_behavior;
}
if (local_options.system_crash_reporter_forwarding == TriState::kUnset) {
local_options.system_crash_reporter_forwarding =
module_options.system_crash_reporter_forwarding;
}
if (local_options.gather_indirectly_referenced_memory == TriState::kUnset) {
local_options.gather_indirectly_referenced_memory =
module_options.gather_indirectly_referenced_memory;
local_options.indirectly_referenced_memory_cap =
module_options.indirectly_referenced_memory_cap;
}
// If non-default values have been found for all options, the loop can end
// early.
if (local_options.crashpad_handler_behavior != TriState::kUnset &&
local_options.system_crash_reporter_forwarding != TriState::kUnset &&
local_options.gather_indirectly_referenced_memory != TriState::kUnset) {
break;
}
}
*options = local_options;
}
pid_t ProcessSnapshotLinux::ProcessID() const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
return process_reader_.ProcessID();

View File

@ -24,6 +24,7 @@
#include <vector>
#include "base/macros.h"
#include "snapshot/crashpad_info_client_options.h"
#include "snapshot/linux/exception_snapshot_linux.h"
#include "snapshot/linux/module_snapshot_linux.h"
#include "snapshot/linux/process_reader.h"
@ -87,6 +88,13 @@ class ProcessSnapshotLinux final : public ProcessSnapshot {
annotations_simple_map_ = annotations_simple_map;
}
//! \brief Returns options from CrashpadInfo structures found in modules in
//! the process.
//!
//! \param[out] options Options set in CrashpadInfo structures in modules in
//! the process.
void GetCrashpadOptions(CrashpadInfoClientOptions* options);
// ProcessSnapshot:
pid_t ProcessID() const override;