OLD | NEW |
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 "snapshot/process_snapshot.h" |
19 #include "util/file/file_writer.h" | 20 #include "util/file/file_writer.h" |
20 | 21 |
21 namespace crashpad { | 22 namespace crashpad { |
22 | 23 |
23 MinidumpCrashpadInfoWriter::MinidumpCrashpadInfoWriter() | 24 MinidumpCrashpadInfoWriter::MinidumpCrashpadInfoWriter() |
24 : MinidumpStreamWriter(), crashpad_info_(), module_list_(nullptr) { | 25 : MinidumpStreamWriter(), crashpad_info_(), module_list_(nullptr) { |
25 crashpad_info_.version = MinidumpCrashpadInfo::kVersion; | 26 crashpad_info_.version = MinidumpCrashpadInfo::kVersion; |
26 } | 27 } |
27 | 28 |
28 MinidumpCrashpadInfoWriter::~MinidumpCrashpadInfoWriter() { | 29 MinidumpCrashpadInfoWriter::~MinidumpCrashpadInfoWriter() { |
29 } | 30 } |
30 | 31 |
| 32 void MinidumpCrashpadInfoWriter::InitializeFromSnapshot( |
| 33 const ProcessSnapshot* process_snapshot) { |
| 34 DCHECK_EQ(state(), kStateMutable); |
| 35 DCHECK(!module_list_); |
| 36 |
| 37 auto modules = make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); |
| 38 modules->InitializeFromSnapshot(process_snapshot->Modules()); |
| 39 |
| 40 if (modules->IsUseful()) { |
| 41 SetModuleList(modules.Pass()); |
| 42 } |
| 43 } |
| 44 |
31 void MinidumpCrashpadInfoWriter::SetModuleList( | 45 void MinidumpCrashpadInfoWriter::SetModuleList( |
32 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list) { | 46 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list) { |
33 DCHECK_EQ(state(), kStateMutable); | 47 DCHECK_EQ(state(), kStateMutable); |
34 | 48 |
35 module_list_ = module_list.Pass(); | 49 module_list_ = module_list.Pass(); |
36 } | 50 } |
37 | 51 |
38 bool MinidumpCrashpadInfoWriter::Freeze() { | 52 bool MinidumpCrashpadInfoWriter::Freeze() { |
39 DCHECK_EQ(state(), kStateMutable); | 53 DCHECK_EQ(state(), kStateMutable); |
40 | 54 |
(...skipping 29 matching lines...) Expand all Loading... |
70 bool MinidumpCrashpadInfoWriter::WriteObject(FileWriterInterface* file_writer) { | 84 bool MinidumpCrashpadInfoWriter::WriteObject(FileWriterInterface* file_writer) { |
71 DCHECK_EQ(state(), kStateWritable); | 85 DCHECK_EQ(state(), kStateWritable); |
72 | 86 |
73 return file_writer->Write(&crashpad_info_, sizeof(crashpad_info_)); | 87 return file_writer->Write(&crashpad_info_, sizeof(crashpad_info_)); |
74 } | 88 } |
75 | 89 |
76 MinidumpStreamType MinidumpCrashpadInfoWriter::StreamType() const { | 90 MinidumpStreamType MinidumpCrashpadInfoWriter::StreamType() const { |
77 return kMinidumpStreamTypeCrashpadInfo; | 91 return kMinidumpStreamTypeCrashpadInfo; |
78 } | 92 } |
79 | 93 |
| 94 bool MinidumpCrashpadInfoWriter::IsUseful() const { |
| 95 return module_list_; |
| 96 } |
| 97 |
80 } // namespace crashpad | 98 } // namespace crashpad |
OLD | NEW |