OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 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 "snapshot/win/module_snapshot_win.h" | 15 #include "snapshot/win/module_snapshot_win.h" |
16 | 16 |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "snapshot/win/pe_image_annotations_reader.h" | 18 #include "snapshot/win/pe_image_annotations_reader.h" |
19 #include "snapshot/win/pe_image_reader.h" | 19 #include "snapshot/win/pe_image_reader.h" |
20 #include "util/misc/tri_state.h" | 20 #include "util/misc/tri_state.h" |
21 #include "util/misc/uuid.h" | 21 #include "util/misc/uuid.h" |
22 #include "util/win/module_version.h" | 22 #include "util/win/module_version.h" |
23 | 23 |
24 namespace crashpad { | 24 namespace crashpad { |
25 namespace internal { | 25 namespace internal { |
26 | 26 |
27 ModuleSnapshotWin::ModuleSnapshotWin() | 27 ModuleSnapshotWin::ModuleSnapshotWin() |
28 : ModuleSnapshot(), | 28 : ModuleSnapshot(), |
29 name_(), | 29 name_(), |
| 30 pdb_name_(), |
| 31 uuid_(), |
| 32 pe_image_reader_(), |
| 33 process_reader_(nullptr), |
30 timestamp_(0), | 34 timestamp_(0), |
31 process_reader_(nullptr), | 35 age_(0), |
32 initialized_() { | 36 initialized_() { |
33 } | 37 } |
34 | 38 |
35 ModuleSnapshotWin::~ModuleSnapshotWin() { | 39 ModuleSnapshotWin::~ModuleSnapshotWin() { |
36 } | 40 } |
37 | 41 |
38 bool ModuleSnapshotWin::Initialize( | 42 bool ModuleSnapshotWin::Initialize( |
39 ProcessReaderWin* process_reader, | 43 ProcessReaderWin* process_reader, |
40 const ProcessInfo::Module& process_reader_module) { | 44 const ProcessInfo::Module& process_reader_module) { |
41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 45 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
42 | 46 |
43 process_reader_ = process_reader; | 47 process_reader_ = process_reader; |
44 name_ = process_reader_module.name; | 48 name_ = process_reader_module.name; |
45 timestamp_ = process_reader_module.timestamp; | 49 timestamp_ = process_reader_module.timestamp; |
46 pe_image_reader_.reset(new PEImageReader()); | 50 pe_image_reader_.reset(new PEImageReader()); |
47 if (!pe_image_reader_->Initialize(process_reader_, | 51 if (!pe_image_reader_->Initialize(process_reader_, |
48 process_reader_module.dll_base, | 52 process_reader_module.dll_base, |
49 process_reader_module.size, | 53 process_reader_module.size, |
50 base::UTF16ToUTF8(name_))) { | 54 base::UTF16ToUTF8(name_))) { |
51 return false; | 55 return false; |
52 } | 56 } |
53 | 57 |
| 58 DWORD age_dword; |
| 59 if (pe_image_reader_->DebugDirectoryInformation( |
| 60 &uuid_, &age_dword, &pdb_name_)) { |
| 61 static_assert(sizeof(DWORD) == sizeof(uint32_t), "unexpected age size"); |
| 62 age_ = age_dword; |
| 63 } |
| 64 |
54 INITIALIZATION_STATE_SET_VALID(initialized_); | 65 INITIALIZATION_STATE_SET_VALID(initialized_); |
55 return true; | 66 return true; |
56 } | 67 } |
57 | 68 |
58 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { | 69 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { |
59 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 70 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
60 if (process_reader_->Is64Bit()) | 71 if (process_reader_->Is64Bit()) |
61 GetCrashpadOptionsInternal<process_types::internal::Traits64>(options); | 72 GetCrashpadOptionsInternal<process_types::internal::Traits64>(options); |
62 else | 73 else |
63 GetCrashpadOptionsInternal<process_types::internal::Traits32>(options); | 74 GetCrashpadOptionsInternal<process_types::internal::Traits32>(options); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 if (ffi.dwFileType == VFT_DLL) | 141 if (ffi.dwFileType == VFT_DLL) |
131 return ModuleSnapshot::kModuleTypeSharedLibrary; | 142 return ModuleSnapshot::kModuleTypeSharedLibrary; |
132 if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD) | 143 if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD) |
133 return ModuleSnapshot::kModuleTypeLoadableModule; | 144 return ModuleSnapshot::kModuleTypeLoadableModule; |
134 } | 145 } |
135 return ModuleSnapshot::kModuleTypeUnknown; | 146 return ModuleSnapshot::kModuleTypeUnknown; |
136 } | 147 } |
137 | 148 |
138 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { | 149 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { |
139 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 150 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
140 // TODO(scottmg): Consider passing pdbname through to snapshot. | 151 *uuid = uuid_; |
141 std::string pdbname; | 152 *age = age_; |
142 DWORD age_dword; | 153 } |
143 if (!pe_image_reader_->DebugDirectoryInformation( | 154 |
144 uuid, &age_dword, &pdbname)) { | 155 std::string ModuleSnapshotWin::DebugFileName() const { |
145 *uuid = crashpad::UUID(); | 156 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
146 *age = 0; | 157 return pdb_name_; |
147 } | |
148 static_assert(sizeof(DWORD) == sizeof(uint32_t), "unexpected age size"); | |
149 *age = age_dword; | |
150 } | 158 } |
151 | 159 |
152 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { | 160 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { |
153 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 161 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
154 // These correspond to system-logged things on Mac. We don't currently track | 162 // These correspond to system-logged things on Mac. We don't currently track |
155 // any of these on Windows, but could in the future. | 163 // any of these on Windows, but could in the future. |
156 // See https://code.google.com/p/crashpad/issues/detail?id=38. | 164 // See https://code.google.com/p/crashpad/issues/detail?id=38. |
157 return std::vector<std::string>(); | 165 return std::vector<std::string>(); |
158 } | 166 } |
159 | 167 |
(...skipping 19 matching lines...) Expand all Loading... |
179 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 187 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
180 crashpad_info.crashpad_handler_behavior); | 188 crashpad_info.crashpad_handler_behavior); |
181 | 189 |
182 options->system_crash_reporter_forwarding = | 190 options->system_crash_reporter_forwarding = |
183 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 191 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
184 crashpad_info.system_crash_reporter_forwarding); | 192 crashpad_info.system_crash_reporter_forwarding); |
185 } | 193 } |
186 | 194 |
187 } // namespace internal | 195 } // namespace internal |
188 } // namespace crashpad | 196 } // namespace crashpad |
OLD | NEW |