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

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

Issue 1126413008: win: Implement exception snapshot (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: tidy Created 5 years, 4 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
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/process_snapshot_win.h" 15 #include "snapshot/win/process_snapshot_win.h"
16 16
17 #include "snapshot/win/module_snapshot_win.h" 17 #include "snapshot/win/module_snapshot_win.h"
18 #include "util/win/time.h" 18 #include "util/win/time.h"
19 19
20 namespace crashpad { 20 namespace crashpad {
21 21
22 ProcessSnapshotWin::ProcessSnapshotWin() 22 ProcessSnapshotWin::ProcessSnapshotWin()
23 : ProcessSnapshot(), 23 : ProcessSnapshot(),
24 system_(), 24 system_(),
25 threads_(), 25 threads_(),
26 modules_(), 26 modules_(),
27 // TODO(scottmg): exception_(), 27 exception_(),
28 process_reader_(), 28 process_reader_(),
29 report_id_(), 29 report_id_(),
30 client_id_(), 30 client_id_(),
31 annotations_simple_map_(), 31 annotations_simple_map_(),
32 snapshot_time_(), 32 snapshot_time_(),
33 initialized_() { 33 initialized_() {
34 } 34 }
35 35
36 ProcessSnapshotWin::~ProcessSnapshotWin() { 36 ProcessSnapshotWin::~ProcessSnapshotWin() {
37 } 37 }
38 38
39 bool ProcessSnapshotWin::Initialize(HANDLE process) { 39 bool ProcessSnapshotWin::Initialize(HANDLE process) {
40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); 40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
41 41
42 GetTimeOfDay(&snapshot_time_); 42 GetTimeOfDay(&snapshot_time_);
43 43
44 if (!process_reader_.Initialize(process)) 44 if (!process_reader_.Initialize(process))
45 return false; 45 return false;
46 46
47 system_.Initialize(&process_reader_); 47 system_.Initialize(&process_reader_);
48 48
49 InitializeThreads(); 49 InitializeThreads();
50 InitializeModules(); 50 InitializeModules();
51 51
52 INITIALIZATION_STATE_SET_VALID(initialized_); 52 INITIALIZATION_STATE_SET_VALID(initialized_);
53 return true; 53 return true;
54 } 54 }
55 55
56 bool ProcessSnapshotWin::InitializeException(
57 DWORD thread_id,
58 WinVMAddress exception_pointers) {
59 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
60 DCHECK(!exception_);
Mark Mentovai 2015/08/18 16:17:20 Can you add a logging.h #include to the Mac equiva
scottmg 2015/08/18 16:56:00 Mac looks correct to me? I added it here though.
Mark Mentovai 2015/08/18 17:52:13 scottmg wrote:
scottmg 2015/08/18 18:18:20 Oh, I must have been looking at exception_snapshot
61
62 exception_.reset(new internal::ExceptionSnapshotWin());
63 if (!exception_->Initialize(
64 &process_reader_, thread_id, exception_pointers)) {
65 exception_.reset();
66 return false;
67 }
68
69 return true;
70 }
71
56 void ProcessSnapshotWin::GetCrashpadOptions( 72 void ProcessSnapshotWin::GetCrashpadOptions(
57 CrashpadInfoClientOptions* options) { 73 CrashpadInfoClientOptions* options) {
58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 74 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
59 75
60 CrashpadInfoClientOptions local_options; 76 CrashpadInfoClientOptions local_options;
61 77
62 for (internal::ModuleSnapshotWin* module : modules_) { 78 for (internal::ModuleSnapshotWin* module : modules_) {
63 CrashpadInfoClientOptions module_options; 79 CrashpadInfoClientOptions module_options;
64 module->GetCrashpadOptions(&module_options); 80 module->GetCrashpadOptions(&module_options);
65 81
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { 158 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const {
143 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 159 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
144 std::vector<const ModuleSnapshot*> modules; 160 std::vector<const ModuleSnapshot*> modules;
145 for (internal::ModuleSnapshotWin* module : modules_) { 161 for (internal::ModuleSnapshotWin* module : modules_) {
146 modules.push_back(module); 162 modules.push_back(module);
147 } 163 }
148 return modules; 164 return modules;
149 } 165 }
150 166
151 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { 167 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const {
152 CHECK(false) << "TODO(scottmg): Exception()"; 168 return exception_.get();
153 return nullptr;
154 } 169 }
155 170
156 void ProcessSnapshotWin::InitializeThreads() { 171 void ProcessSnapshotWin::InitializeThreads() {
157 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = 172 const std::vector<ProcessReaderWin::Thread>& process_reader_threads =
158 process_reader_.Threads(); 173 process_reader_.Threads();
159 for (const ProcessReaderWin::Thread& process_reader_thread : 174 for (const ProcessReaderWin::Thread& process_reader_thread :
160 process_reader_threads) { 175 process_reader_threads) {
161 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); 176 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin());
162 if (thread->Initialize(&process_reader_, process_reader_thread)) { 177 if (thread->Initialize(&process_reader_, process_reader_thread)) {
163 threads_.push_back(thread.release()); 178 threads_.push_back(thread.release());
164 } 179 }
165 } 180 }
166 } 181 }
167 182
168 void ProcessSnapshotWin::InitializeModules() { 183 void ProcessSnapshotWin::InitializeModules() {
169 const std::vector<ProcessInfo::Module>& process_reader_modules = 184 const std::vector<ProcessInfo::Module>& process_reader_modules =
170 process_reader_.Modules(); 185 process_reader_.Modules();
171 for (const ProcessInfo::Module& process_reader_module : 186 for (const ProcessInfo::Module& process_reader_module :
172 process_reader_modules) { 187 process_reader_modules) {
173 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); 188 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin());
174 if (module->Initialize(&process_reader_, process_reader_module)) { 189 if (module->Initialize(&process_reader_, process_reader_module)) {
175 modules_.push_back(module.release()); 190 modules_.push_back(module.release());
176 } 191 }
177 } 192 }
178 } 193 }
179 194
180 } // namespace crashpad 195 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698