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

Side by Side Diff: snapshot/win/module_snapshot_win.cc

Issue 1052813002: win: make CrashpadInfo retrievable (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 7 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
(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 if (!pe_image_reader_->Initialize(process_reader_,
48 process_reader_module.dll_base,
49 process_reader_module.size,
50 name_)) {
51 LOG(WARNING) << "pe reader initialization failed";
Mark Mentovai 2015/04/30 20:58:35 PEImageReader is documented as logging something i
scottmg 2015/04/30 22:09:43 Done.
52 return false;
53 }
54
55 INITIALIZATION_STATE_SET_VALID(initialized_);
56 return true;
57 }
58
59 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) {
60 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
61
62 process_types::CrashpadInfo crashpad_info;
63 if (!pe_image_reader_->GetCrashpadInfo(&crashpad_info)) {
64 options->crashpad_handler_behavior = TriState::kUnset;
65 options->system_crash_reporter_forwarding = TriState::kUnset;
66 return;
67 }
68
69 options->crashpad_handler_behavior =
70 CrashpadInfoClientOptions::TriStateFromCrashpadInfo(
71 crashpad_info.crashpad_handler_behavior);
72
73 options->system_crash_reporter_forwarding =
74 CrashpadInfoClientOptions::TriStateFromCrashpadInfo(
75 crashpad_info.system_crash_reporter_forwarding);
76 }
77
78 std::string ModuleSnapshotWin::Name() const {
79 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
80 return name_;
81 }
82
83 uint64_t ModuleSnapshotWin::Address() const {
84 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
85 CHECK(false) << "TODO(scottmg)";
Mark Mentovai 2015/04/30 20:58:35 Like Timestamp(), you can implement Address() and
scottmg 2015/04/30 22:09:43 Done.
86 return 0;
87 }
88
89 uint64_t ModuleSnapshotWin::Size() const {
90 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
91 CHECK(false) << "TODO(scottmg)";
92 return 0;
93 }
94
95 time_t ModuleSnapshotWin::Timestamp() const {
96 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
97 return timestamp_;
98 }
99
100 void ModuleSnapshotWin::FileVersion(uint16_t* version_0,
101 uint16_t* version_1,
102 uint16_t* version_2,
103 uint16_t* version_3) const {
104 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
105 CHECK(false) << "TODO(scottmg)";
106 }
107
108 void ModuleSnapshotWin::SourceVersion(uint16_t* version_0,
109 uint16_t* version_1,
110 uint16_t* version_2,
111 uint16_t* version_3) const {
112 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
113 CHECK(false) << "TODO(scottmg)";
114 }
115
116 ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const {
117 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
118 CHECK(false) << "TODO(scottmg)";
119 return ModuleSnapshot::ModuleType();
120 }
121
122 void ModuleSnapshotWin::UUID(crashpad::UUID* uuid) const {
123 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
124 CHECK(false) << "TODO(scottmg)";
125 }
126
127 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const {
128 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
129 CHECK(false) << "TODO(scottmg)";
130 return std::vector<std::string>();
131 }
132
133 std::map<std::string, std::string> ModuleSnapshotWin::AnnotationsSimpleMap()
134 const {
135 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
136 CHECK(false) << "TODO(scottmg)";
137 return std::map<std::string, std::string>();
138 }
139
140 } // namespace internal
141 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698