OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (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 | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #include "snapshot/win/module_snapshot_win.h" | |
16 | |
17 #include "base/strings/stringprintf.h" | |
18 #include "base/strings/utf_string_conversions.h" | |
19 #include "snapshot/win/pe_image_reader.h" | |
20 #include "util/misc/tri_state.h" | |
21 #include "util/misc/uuid.h" | |
22 #include "util/stdlib/strnlen.h" | |
23 | |
24 namespace crashpad { | |
25 namespace internal { | |
26 | |
27 ModuleSnapshotWin::ModuleSnapshotWin() | |
28 : ModuleSnapshot(), | |
29 name_(), | |
30 timestamp_(0), | |
31 process_reader_(nullptr), | |
32 initialized_() { | |
33 } | |
34 | |
35 ModuleSnapshotWin::~ModuleSnapshotWin() { | |
36 } | |
37 | |
38 bool ModuleSnapshotWin::Initialize( | |
39 ProcessReaderWin* process_reader, | |
40 const ProcessInfo::Module& process_reader_module) { | |
41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | |
42 | |
43 process_reader_ = process_reader; | |
44 name_ = base::UTF16ToUTF8(process_reader_module.name); | |
45 timestamp_ = process_reader_module.timestamp; | |
46 pe_image_reader_.reset(new PEImageReader()); | |
47 pe_image_reader_->Initialize( | |
Mark Mentovai
2015/04/29 19:37:14
Check return value? The callee can’t fail as curre
scottmg
2015/04/30 03:31:31
Done.
| |
48 process_reader_, process_reader_module.dll_base, name_); | |
49 | |
50 INITIALIZATION_STATE_SET_VALID(initialized_); | |
51 return true; | |
52 } | |
53 | |
54 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { | |
55 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
56 | |
57 process_types::CrashpadInfo crashpad_info; | |
58 if (!pe_image_reader_->GetCrashpadInfo(&crashpad_info)) { | |
59 options->crashpad_handler_behavior = TriState::kUnset; | |
60 options->system_crash_reporter_forwarding = TriState::kUnset; | |
Mark Mentovai
2015/04/29 19:37:14
Does this make sense on Windows at all? I wasn’t s
scottmg
2015/04/30 03:31:31
I'm not sure if it's a good idea (I haven't actual
Mark Mentovai
2015/04/30 20:58:35
That’s reasonable. If we find that this doesn’t ma
| |
61 return; | |
62 } | |
63 | |
64 options->crashpad_handler_behavior = | |
65 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | |
66 crashpad_info.crashpad_handler_behavior); | |
67 | |
68 options->system_crash_reporter_forwarding = | |
69 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | |
70 crashpad_info.system_crash_reporter_forwarding); | |
71 } | |
72 | |
73 std::string ModuleSnapshotWin::Name() const { | |
74 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
75 return name_; | |
76 } | |
77 | |
78 uint64_t ModuleSnapshotWin::Address() const { | |
79 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
80 CHECK(false) << "TODO(scottmg)"; | |
Mark Mentovai
2015/04/29 19:37:14
Makes it easier to review, too. :)
scottmg
2015/04/30 03:31:31
Hopefully future reviews will be a bit "harder". :
Mark Mentovai
2015/04/30 20:58:35
scottmg wrote:
| |
81 return 0; | |
82 } | |
83 | |
84 uint64_t ModuleSnapshotWin::Size() const { | |
85 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
86 CHECK(false) << "TODO(scottmg)"; | |
87 return 0; | |
88 } | |
89 | |
90 time_t ModuleSnapshotWin::Timestamp() const { | |
91 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
92 return timestamp_; | |
93 } | |
94 | |
95 void ModuleSnapshotWin::FileVersion(uint16_t* version_0, | |
96 uint16_t* version_1, | |
97 uint16_t* version_2, | |
98 uint16_t* version_3) const { | |
99 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
100 CHECK(false) << "TODO(scottmg)"; | |
101 } | |
102 | |
103 void ModuleSnapshotWin::SourceVersion(uint16_t* version_0, | |
104 uint16_t* version_1, | |
105 uint16_t* version_2, | |
106 uint16_t* version_3) const { | |
107 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
108 CHECK(false) << "TODO(scottmg)"; | |
109 } | |
110 | |
111 ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const { | |
112 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
113 CHECK(false) << "TODO(scottmg)"; | |
114 return ModuleSnapshot::ModuleType(); | |
115 } | |
116 | |
117 void ModuleSnapshotWin::UUID(crashpad::UUID* uuid) const { | |
118 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
119 CHECK(false) << "TODO(scottmg)"; | |
120 } | |
121 | |
122 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { | |
123 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
124 CHECK(false) << "TODO(scottmg)"; | |
125 return std::vector<std::string>(); | |
126 } | |
127 | |
128 std::map<std::string, std::string> ModuleSnapshotWin::AnnotationsSimpleMap() | |
129 const { | |
130 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
131 CHECK(false) << "TODO(scottmg)"; | |
132 return std::map<std::string, std::string>(); | |
133 } | |
134 | |
135 } // namespace internal | |
136 } // namespace crashpad | |
OLD | NEW |