Index: minidump/minidump_module_crashpad_info_writer.cc |
diff --git a/minidump/minidump_module_crashpad_info_writer.cc b/minidump/minidump_module_crashpad_info_writer.cc |
index a7afbda90b53005992508671e16d6837e17987a1..e1a2a231c103f71d1ca9a4ed3ec35cd1b7cbb1eb 100644 |
--- a/minidump/minidump_module_crashpad_info_writer.cc |
+++ b/minidump/minidump_module_crashpad_info_writer.cc |
@@ -18,6 +18,7 @@ |
#include "base/logging.h" |
#include "minidump/minidump_simple_string_dictionary_writer.h" |
+#include "snapshot/module_snapshot.h" |
#include "util/file/file_writer.h" |
#include "util/numeric/safe_assignment.h" |
@@ -31,6 +32,27 @@ MinidumpModuleCrashpadInfoWriter::MinidumpModuleCrashpadInfoWriter() |
MinidumpModuleCrashpadInfoWriter::~MinidumpModuleCrashpadInfoWriter() { |
} |
+void MinidumpModuleCrashpadInfoWriter::InitializeFromSnapshot( |
+ const ModuleSnapshot* module_snapshot, size_t module_list_index) { |
+ DCHECK_EQ(state(), kStateMutable); |
+ DCHECK(!simple_annotations_); |
+ |
+ uint32_t module_list_index_u32; |
+ if (!AssignIfInRange(&module_list_index_u32, module_list_index)) { |
+ LOG(ERROR) << "module_list_index " << module_list_index << " out of range"; |
+ return; |
+ } |
+ SetMinidumpModuleListIndex(module_list_index_u32); |
+ |
+ auto simple_annotations = |
+ make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); |
+ simple_annotations->InitializeFromMap( |
+ module_snapshot->AnnotationsSimpleMap()); |
+ if (simple_annotations->IsUseful()) { |
+ SetSimpleAnnotations(simple_annotations.Pass()); |
+ } |
+} |
+ |
void MinidumpModuleCrashpadInfoWriter::SetSimpleAnnotations( |
scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations) { |
DCHECK_EQ(state(), kStateMutable); |
@@ -38,6 +60,10 @@ void MinidumpModuleCrashpadInfoWriter::SetSimpleAnnotations( |
simple_annotations_ = simple_annotations.Pass(); |
} |
+bool MinidumpModuleCrashpadInfoWriter::IsUseful() const { |
+ return simple_annotations_; |
+} |
+ |
bool MinidumpModuleCrashpadInfoWriter::Freeze() { |
DCHECK_EQ(state(), kStateMutable); |
@@ -88,6 +114,24 @@ MinidumpModuleCrashpadInfoListWriter::MinidumpModuleCrashpadInfoListWriter() |
MinidumpModuleCrashpadInfoListWriter::~MinidumpModuleCrashpadInfoListWriter() { |
} |
+void MinidumpModuleCrashpadInfoListWriter::InitializeFromSnapshot( |
+ const std::vector<const ModuleSnapshot*>& module_snapshots) { |
+ DCHECK_EQ(state(), kStateMutable); |
+ DCHECK(modules_.empty()); |
+ DCHECK(module_location_descriptors_.empty()); |
+ |
+ size_t count = module_snapshots.size(); |
+ for (size_t index = 0; index < count; ++index) { |
+ const ModuleSnapshot* module_snapshot = module_snapshots[index]; |
+ |
+ auto module = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); |
+ module->InitializeFromSnapshot(module_snapshot, index); |
+ if (module->IsUseful()) { |
+ AddModule(module.Pass()); |
+ } |
+ } |
+} |
+ |
void MinidumpModuleCrashpadInfoListWriter::AddModule( |
scoped_ptr<MinidumpModuleCrashpadInfoWriter> module) { |
DCHECK_EQ(state(), kStateMutable); |