Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: minidump/minidump_crashpad_info_writer.cc

Issue 924673003: Add MinidumpCrashpadInfo::simple_annotations (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/minidump_crashpad_info_writer.h" 15 #include "minidump/minidump_crashpad_info_writer.h"
16 16
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "minidump/minidump_module_crashpad_info_writer.h" 18 #include "minidump/minidump_module_crashpad_info_writer.h"
19 #include "minidump/minidump_simple_string_dictionary_writer.h"
19 #include "snapshot/process_snapshot.h" 20 #include "snapshot/process_snapshot.h"
20 #include "util/file/file_writer.h" 21 #include "util/file/file_writer.h"
21 22
22 namespace crashpad { 23 namespace crashpad {
23 24
24 MinidumpCrashpadInfoWriter::MinidumpCrashpadInfoWriter() 25 MinidumpCrashpadInfoWriter::MinidumpCrashpadInfoWriter()
25 : MinidumpStreamWriter(), crashpad_info_(), module_list_(nullptr) { 26 : MinidumpStreamWriter(),
27 crashpad_info_(),
28 simple_annotations_(nullptr),
29 module_list_(nullptr) {
26 crashpad_info_.version = MinidumpCrashpadInfo::kVersion; 30 crashpad_info_.version = MinidumpCrashpadInfo::kVersion;
27 } 31 }
28 32
29 MinidumpCrashpadInfoWriter::~MinidumpCrashpadInfoWriter() { 33 MinidumpCrashpadInfoWriter::~MinidumpCrashpadInfoWriter() {
30 } 34 }
31 35
32 void MinidumpCrashpadInfoWriter::InitializeFromSnapshot( 36 void MinidumpCrashpadInfoWriter::InitializeFromSnapshot(
33 const ProcessSnapshot* process_snapshot) { 37 const ProcessSnapshot* process_snapshot) {
34 DCHECK_EQ(state(), kStateMutable); 38 DCHECK_EQ(state(), kStateMutable);
35 DCHECK(!module_list_); 39 DCHECK(!module_list_);
36 40
41 auto simple_annotations =
42 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
43 simple_annotations->InitializeFromMap(
44 process_snapshot->AnnotationsSimpleMap());
45 if (simple_annotations->IsUseful()) {
46 SetSimpleAnnotations(simple_annotations.Pass());
47 }
48
37 auto modules = make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 49 auto modules = make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
38 modules->InitializeFromSnapshot(process_snapshot->Modules()); 50 modules->InitializeFromSnapshot(process_snapshot->Modules());
39 51
40 if (modules->IsUseful()) { 52 if (modules->IsUseful()) {
41 SetModuleList(modules.Pass()); 53 SetModuleList(modules.Pass());
42 } 54 }
43 } 55 }
44 56
57 void MinidumpCrashpadInfoWriter::SetSimpleAnnotations(
58 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations) {
59 DCHECK_EQ(state(), kStateMutable);
60
61 simple_annotations_ = simple_annotations.Pass();
62 }
63
45 void MinidumpCrashpadInfoWriter::SetModuleList( 64 void MinidumpCrashpadInfoWriter::SetModuleList(
46 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list) { 65 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list) {
47 DCHECK_EQ(state(), kStateMutable); 66 DCHECK_EQ(state(), kStateMutable);
48 67
49 module_list_ = module_list.Pass(); 68 module_list_ = module_list.Pass();
50 } 69 }
51 70
52 bool MinidumpCrashpadInfoWriter::Freeze() { 71 bool MinidumpCrashpadInfoWriter::Freeze() {
53 DCHECK_EQ(state(), kStateMutable); 72 DCHECK_EQ(state(), kStateMutable);
54 73
55 if (!MinidumpStreamWriter::Freeze()) { 74 if (!MinidumpStreamWriter::Freeze()) {
56 return false; 75 return false;
57 } 76 }
58 77
78 if (simple_annotations_) {
79 simple_annotations_->RegisterLocationDescriptor(
80 &crashpad_info_.simple_annotations);
81 }
59 if (module_list_) { 82 if (module_list_) {
60 module_list_->RegisterLocationDescriptor(&crashpad_info_.module_list); 83 module_list_->RegisterLocationDescriptor(&crashpad_info_.module_list);
61 } 84 }
62 85
63 return true; 86 return true;
64 } 87 }
65 88
66 size_t MinidumpCrashpadInfoWriter::SizeOfObject() { 89 size_t MinidumpCrashpadInfoWriter::SizeOfObject() {
67 DCHECK_GE(state(), kStateFrozen); 90 DCHECK_GE(state(), kStateFrozen);
68 91
69 return sizeof(crashpad_info_); 92 return sizeof(crashpad_info_);
70 } 93 }
71 94
72 std::vector<internal::MinidumpWritable*> 95 std::vector<internal::MinidumpWritable*>
73 MinidumpCrashpadInfoWriter::Children() { 96 MinidumpCrashpadInfoWriter::Children() {
74 DCHECK_GE(state(), kStateFrozen); 97 DCHECK_GE(state(), kStateFrozen);
75 98
76 std::vector<MinidumpWritable*> children; 99 std::vector<MinidumpWritable*> children;
100 if (simple_annotations_) {
101 children.push_back(simple_annotations_.get());
102 }
77 if (module_list_) { 103 if (module_list_) {
78 children.push_back(module_list_.get()); 104 children.push_back(module_list_.get());
79 } 105 }
80 106
81 return children; 107 return children;
82 } 108 }
83 109
84 bool MinidumpCrashpadInfoWriter::WriteObject(FileWriterInterface* file_writer) { 110 bool MinidumpCrashpadInfoWriter::WriteObject(FileWriterInterface* file_writer) {
85 DCHECK_EQ(state(), kStateWritable); 111 DCHECK_EQ(state(), kStateWritable);
86 112
87 return file_writer->Write(&crashpad_info_, sizeof(crashpad_info_)); 113 return file_writer->Write(&crashpad_info_, sizeof(crashpad_info_));
88 } 114 }
89 115
90 MinidumpStreamType MinidumpCrashpadInfoWriter::StreamType() const { 116 MinidumpStreamType MinidumpCrashpadInfoWriter::StreamType() const {
91 return kMinidumpStreamTypeCrashpadInfo; 117 return kMinidumpStreamTypeCrashpadInfo;
92 } 118 }
93 119
94 bool MinidumpCrashpadInfoWriter::IsUseful() const { 120 bool MinidumpCrashpadInfoWriter::IsUseful() const {
95 return module_list_; 121 return simple_annotations_ || module_list_;
96 } 122 }
97 123
98 } // namespace crashpad 124 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_crashpad_info_writer.h ('k') | minidump/minidump_crashpad_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698