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

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: . 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
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 HANDLE thread,
58 EXCEPTION_POINTERS* exception_pointers) {
59 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
60 DCHECK(!exception_);
61
62 exception_.reset(new internal::ExceptionSnapshotWin());
63 if (!exception_->Initialize(&process_reader_, thread, exception_pointers)) {
64 exception_.reset();
65 return false;
66 }
67
68 return true;
69 }
70
56 void ProcessSnapshotWin::GetCrashpadOptions( 71 void ProcessSnapshotWin::GetCrashpadOptions(
57 CrashpadInfoClientOptions* options) { 72 CrashpadInfoClientOptions* options) {
58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 73 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
59 74
60 CrashpadInfoClientOptions local_options; 75 CrashpadInfoClientOptions local_options;
61 76
62 for (internal::ModuleSnapshotWin* module : modules_) { 77 for (internal::ModuleSnapshotWin* module : modules_) {
63 CrashpadInfoClientOptions module_options; 78 CrashpadInfoClientOptions module_options;
64 module->GetCrashpadOptions(&module_options); 79 module->GetCrashpadOptions(&module_options);
65 80
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { 157 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const {
143 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 158 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
144 std::vector<const ModuleSnapshot*> modules; 159 std::vector<const ModuleSnapshot*> modules;
145 for (internal::ModuleSnapshotWin* module : modules_) { 160 for (internal::ModuleSnapshotWin* module : modules_) {
146 modules.push_back(module); 161 modules.push_back(module);
147 } 162 }
148 return modules; 163 return modules;
149 } 164 }
150 165
151 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { 166 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const {
152 CHECK(false) << "TODO(scottmg): Exception()"; 167 return exception_.get();
153 return nullptr;
154 } 168 }
155 169
156 void ProcessSnapshotWin::InitializeThreads() { 170 void ProcessSnapshotWin::InitializeThreads() {
157 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = 171 const std::vector<ProcessReaderWin::Thread>& process_reader_threads =
158 process_reader_.Threads(); 172 process_reader_.Threads();
159 for (const ProcessReaderWin::Thread& process_reader_thread : 173 for (const ProcessReaderWin::Thread& process_reader_thread :
160 process_reader_threads) { 174 process_reader_threads) {
161 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); 175 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin());
162 if (thread->Initialize(&process_reader_, process_reader_thread)) { 176 if (thread->Initialize(&process_reader_, process_reader_thread)) {
163 threads_.push_back(thread.release()); 177 threads_.push_back(thread.release());
164 } 178 }
165 } 179 }
166 } 180 }
167 181
168 void ProcessSnapshotWin::InitializeModules() { 182 void ProcessSnapshotWin::InitializeModules() {
169 const std::vector<ProcessInfo::Module>& process_reader_modules = 183 const std::vector<ProcessInfo::Module>& process_reader_modules =
170 process_reader_.Modules(); 184 process_reader_.Modules();
171 for (const ProcessInfo::Module& process_reader_module : 185 for (const ProcessInfo::Module& process_reader_module :
172 process_reader_modules) { 186 process_reader_modules) {
173 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); 187 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin());
174 if (module->Initialize(&process_reader_, process_reader_module)) { 188 if (module->Initialize(&process_reader_, process_reader_module)) {
175 modules_.push_back(module.release()); 189 modules_.push_back(module.release());
176 } 190 }
177 } 191 }
178 } 192 }
179 193
180 } // namespace crashpad 194 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698