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, |
(...skipping 11 matching lines...) Expand all Loading... | |
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 timestamp_(0), | 30 timestamp_(0), |
31 process_reader_(nullptr), | 31 process_reader_(nullptr), |
32 uuid_(), | |
33 age_(0), | |
34 pdb_name_(), | |
32 initialized_() { | 35 initialized_() { |
33 } | 36 } |
34 | 37 |
35 ModuleSnapshotWin::~ModuleSnapshotWin() { | 38 ModuleSnapshotWin::~ModuleSnapshotWin() { |
36 } | 39 } |
37 | 40 |
38 bool ModuleSnapshotWin::Initialize( | 41 bool ModuleSnapshotWin::Initialize( |
39 ProcessReaderWin* process_reader, | 42 ProcessReaderWin* process_reader, |
40 const ProcessInfo::Module& process_reader_module) { | 43 const ProcessInfo::Module& process_reader_module) { |
41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 44 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
42 | 45 |
43 process_reader_ = process_reader; | 46 process_reader_ = process_reader; |
44 name_ = process_reader_module.name; | 47 name_ = process_reader_module.name; |
45 timestamp_ = process_reader_module.timestamp; | 48 timestamp_ = process_reader_module.timestamp; |
46 pe_image_reader_.reset(new PEImageReader()); | 49 pe_image_reader_.reset(new PEImageReader()); |
47 if (!pe_image_reader_->Initialize(process_reader_, | 50 if (!pe_image_reader_->Initialize(process_reader_, |
48 process_reader_module.dll_base, | 51 process_reader_module.dll_base, |
49 process_reader_module.size, | 52 process_reader_module.size, |
50 base::UTF16ToUTF8(name_))) { | 53 base::UTF16ToUTF8(name_))) { |
51 return false; | 54 return false; |
52 } | 55 } |
53 | 56 |
57 DWORD age_dword; | |
58 std::string full_pdb_name; | |
59 if (pe_image_reader_->DebugDirectoryInformation( | |
60 &uuid_, &age_dword, &full_pdb_name)) { | |
61 static_assert(sizeof(DWORD) == sizeof(uint32_t), "unexpected age size"); | |
62 age_ = age_dword; | |
63 | |
64 size_t last_slash = full_pdb_name.find_last_of("/\\"); | |
Mark Mentovai
2015/10/28 20:01:11
I guess this can’t be a BaseName() because this is
scottmg
2015/10/28 20:59:25
Right on both counts. A quick check against MiniDu
| |
65 if (last_slash != std::string::npos) | |
66 pdb_name_ = full_pdb_name.substr(last_slash + 1); | |
67 else | |
68 pdb_name_ = full_pdb_name; | |
69 } | |
70 | |
54 INITIALIZATION_STATE_SET_VALID(initialized_); | 71 INITIALIZATION_STATE_SET_VALID(initialized_); |
55 return true; | 72 return true; |
56 } | 73 } |
57 | 74 |
58 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { | 75 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { |
59 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 76 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
60 if (process_reader_->Is64Bit()) | 77 if (process_reader_->Is64Bit()) |
61 GetCrashpadOptionsInternal<process_types::internal::Traits64>(options); | 78 GetCrashpadOptionsInternal<process_types::internal::Traits64>(options); |
62 else | 79 else |
63 GetCrashpadOptionsInternal<process_types::internal::Traits32>(options); | 80 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) | 147 if (ffi.dwFileType == VFT_DLL) |
131 return ModuleSnapshot::kModuleTypeSharedLibrary; | 148 return ModuleSnapshot::kModuleTypeSharedLibrary; |
132 if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD) | 149 if (ffi.dwFileType == VFT_DRV || ffi.dwFileType == VFT_VXD) |
133 return ModuleSnapshot::kModuleTypeLoadableModule; | 150 return ModuleSnapshot::kModuleTypeLoadableModule; |
134 } | 151 } |
135 return ModuleSnapshot::kModuleTypeUnknown; | 152 return ModuleSnapshot::kModuleTypeUnknown; |
136 } | 153 } |
137 | 154 |
138 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { | 155 void ModuleSnapshotWin::UUIDAndAge(crashpad::UUID* uuid, uint32_t* age) const { |
139 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 156 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
140 // TODO(scottmg): Consider passing pdbname through to snapshot. | 157 *uuid = uuid_; |
141 std::string pdbname; | 158 *age = age_; |
142 DWORD age_dword; | 159 } |
143 if (!pe_image_reader_->DebugDirectoryInformation( | 160 |
144 uuid, &age_dword, &pdbname)) { | 161 std::string ModuleSnapshotWin::PDBName() const { |
145 *uuid = crashpad::UUID(); | 162 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
146 *age = 0; | 163 return pdb_name_; |
147 } | |
148 static_assert(sizeof(DWORD) == sizeof(uint32_t), "unexpected age size"); | |
149 *age = age_dword; | |
150 } | 164 } |
151 | 165 |
152 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { | 166 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { |
153 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 167 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
154 // These correspond to system-logged things on Mac. We don't currently track | 168 // These correspond to system-logged things on Mac. We don't currently track |
155 // any of these on Windows, but could in the future. | 169 // any of these on Windows, but could in the future. |
156 // See https://code.google.com/p/crashpad/issues/detail?id=38. | 170 // See https://code.google.com/p/crashpad/issues/detail?id=38. |
157 return std::vector<std::string>(); | 171 return std::vector<std::string>(); |
158 } | 172 } |
159 | 173 |
(...skipping 19 matching lines...) Expand all Loading... | |
179 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 193 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
180 crashpad_info.crashpad_handler_behavior); | 194 crashpad_info.crashpad_handler_behavior); |
181 | 195 |
182 options->system_crash_reporter_forwarding = | 196 options->system_crash_reporter_forwarding = |
183 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | 197 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( |
184 crashpad_info.system_crash_reporter_forwarding); | 198 crashpad_info.system_crash_reporter_forwarding); |
185 } | 199 } |
186 | 200 |
187 } // namespace internal | 201 } // namespace internal |
188 } // namespace crashpad | 202 } // namespace crashpad |
OLD | NEW |