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

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

Issue 1533183002: win: Capture some memory pointed at by context (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: typo Created 4 years, 11 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/exception_snapshot_win.h" 15 #include "snapshot/win/exception_snapshot_win.h"
16 16
17 #include "snapshot/memory_snapshot.h"
18 #include "snapshot/win/capture_context_memory.h"
17 #include "snapshot/win/cpu_context_win.h" 19 #include "snapshot/win/cpu_context_win.h"
20 #include "snapshot/win/memory_snapshot_win.h"
18 #include "snapshot/win/process_reader_win.h" 21 #include "snapshot/win/process_reader_win.h"
19 #include "util/win/nt_internals.h" 22 #include "util/win/nt_internals.h"
20 23
21 namespace crashpad { 24 namespace crashpad {
22 namespace internal { 25 namespace internal {
23 26
24 ExceptionSnapshotWin::ExceptionSnapshotWin() 27 ExceptionSnapshotWin::ExceptionSnapshotWin()
25 : ExceptionSnapshot(), 28 : ExceptionSnapshot(),
26 context_union_(), 29 context_union_(),
27 context_(), 30 context_(),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (!InitializeFromExceptionPointers<EXCEPTION_RECORD32, 82 if (!InitializeFromExceptionPointers<EXCEPTION_RECORD32,
80 process_types::EXCEPTION_POINTERS32>( 83 process_types::EXCEPTION_POINTERS32>(
81 *process_reader, exception_pointers_address, &context_record)) { 84 *process_reader, exception_pointers_address, &context_record)) {
82 return false; 85 return false;
83 } 86 }
84 context_.architecture = kCPUArchitectureX86; 87 context_.architecture = kCPUArchitectureX86;
85 context_.x86 = &context_union_.x86; 88 context_.x86 = &context_union_.x86;
86 InitializeX86Context(context_record, context_.x86); 89 InitializeX86Context(context_record, context_.x86);
87 } 90 }
88 91
92 CaptureMemoryPointedToByContext(context_, process_reader, &extra_memory_);
93
89 INITIALIZATION_STATE_SET_VALID(initialized_); 94 INITIALIZATION_STATE_SET_VALID(initialized_);
90 return true; 95 return true;
91 } 96 }
92 97
93 const CPUContext* ExceptionSnapshotWin::Context() const { 98 const CPUContext* ExceptionSnapshotWin::Context() const {
94 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 99 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
95 return &context_; 100 return &context_;
96 } 101 }
97 102
98 uint64_t ExceptionSnapshotWin::ThreadID() const { 103 uint64_t ExceptionSnapshotWin::ThreadID() const {
(...skipping 14 matching lines...) Expand all
113 uint64_t ExceptionSnapshotWin::ExceptionAddress() const { 118 uint64_t ExceptionSnapshotWin::ExceptionAddress() const {
114 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 119 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
115 return exception_address_; 120 return exception_address_;
116 } 121 }
117 122
118 const std::vector<uint64_t>& ExceptionSnapshotWin::Codes() const { 123 const std::vector<uint64_t>& ExceptionSnapshotWin::Codes() const {
119 INITIALIZATION_STATE_DCHECK_VALID(initialized_); 124 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
120 return codes_; 125 return codes_;
121 } 126 }
122 127
128 std::vector<const MemorySnapshot*> ExceptionSnapshotWin::ExtraMemory() const {
129 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
130 std::vector<const MemorySnapshot*> result;
131 result.reserve(extra_memory_.size());
132 for (const auto& em : extra_memory_)
133 result.push_back(em);
134 return result;
135 }
136
123 template <class ExceptionRecordType, 137 template <class ExceptionRecordType,
124 class ExceptionPointersType, 138 class ExceptionPointersType,
125 class ContextType> 139 class ContextType>
126 bool ExceptionSnapshotWin::InitializeFromExceptionPointers( 140 bool ExceptionSnapshotWin::InitializeFromExceptionPointers(
127 const ProcessReaderWin& process_reader, 141 const ProcessReaderWin& process_reader,
128 WinVMAddress exception_pointers_address, 142 WinVMAddress exception_pointers_address,
129 ContextType* context_record) { 143 ContextType* context_record) {
130 ExceptionPointersType exception_pointers; 144 ExceptionPointersType exception_pointers;
131 if (!process_reader.ReadMemory(exception_pointers_address, 145 if (!process_reader.ReadMemory(exception_pointers_address,
132 sizeof(exception_pointers), 146 sizeof(exception_pointers),
(...skipping 30 matching lines...) Expand all
163 context_record)) { 177 context_record)) {
164 LOG(ERROR) << "ContextRecord"; 178 LOG(ERROR) << "ContextRecord";
165 return false; 179 return false;
166 } 180 }
167 181
168 return true; 182 return true;
169 } 183 }
170 184
171 } // namespace internal 185 } // namespace internal
172 } // namespace crashpad 186 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698