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

Side by Side Diff: snapshot/win/capture_context_memory.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
(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/capture_context_memory.h"
16
17 #include "snapshot/win/memory_snapshot_win.h"
18 #include "snapshot/win/process_reader_win.h"
19
20 namespace crashpad {
21 namespace internal {
22
23 namespace {
24
25 void MaybeCaptureMemoryAround(ProcessReaderWin* process_reader,
26 WinVMAddress address,
27 PointerVector<MemorySnapshotWin>* into) {
28 if (address > 0x10000) {
29 const WinVMSize kRegisterByteOffset = 32;
30 const WinVMAddress target = address - kRegisterByteOffset;
31 const WinVMSize size = 128;
32 if (process_reader->GetProcessInfo().LoggingRangeIsFullyReadable(
Mark Mentovai 2016/01/08 19:20:52 If the address is readable at all, we should do as
scottmg 2016/01/08 19:52:02 Done.
33 CheckedRange<WinVMAddress, WinVMSize>(target, size))) {
34 internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin();
35 snapshot->Initialize(process_reader, target, size);
36 into->push_back(snapshot);
37 }
38 }
39 }
40
41 } // namespace
42
43 void CaptureMemoryPointedToByContext(const CPUContext& context,
44 ProcessReaderWin* process_reader,
45 PointerVector<MemorySnapshotWin>* into) {
46 #if defined(ARCH_CPU_X86_64)
47 if (context.architecture == kCPUArchitectureX86_64) {
48 MaybeCaptureMemoryAround(process_reader, context.x86_64->rax, into);
49 MaybeCaptureMemoryAround(process_reader, context.x86_64->rbx, into);
50 MaybeCaptureMemoryAround(process_reader, context.x86_64->rcx, into);
51 MaybeCaptureMemoryAround(process_reader, context.x86_64->rdx, into);
52 MaybeCaptureMemoryAround(process_reader, context.x86_64->rdi, into);
53 MaybeCaptureMemoryAround(process_reader, context.x86_64->rsi, into);
Mark Mentovai 2016/01/08 19:20:52 If bp doesn’t point to the thread’s stack, you sho
scottmg 2016/01/08 19:52:02 Done.
54 MaybeCaptureMemoryAround(process_reader, context.x86_64->r8, into);
55 MaybeCaptureMemoryAround(process_reader, context.x86_64->r9, into);
56 MaybeCaptureMemoryAround(process_reader, context.x86_64->r10, into);
57 MaybeCaptureMemoryAround(process_reader, context.x86_64->r11, into);
58 MaybeCaptureMemoryAround(process_reader, context.x86_64->r12, into);
59 MaybeCaptureMemoryAround(process_reader, context.x86_64->r13, into);
60 MaybeCaptureMemoryAround(process_reader, context.x86_64->r14, into);
61 MaybeCaptureMemoryAround(process_reader, context.x86_64->r15, into);
62 MaybeCaptureMemoryAround(process_reader, context.x86_64->rip, into);
63 } else {
64 #endif
65 MaybeCaptureMemoryAround(process_reader, context.x86->eax, into);
66 MaybeCaptureMemoryAround(process_reader, context.x86->ebx, into);
67 MaybeCaptureMemoryAround(process_reader, context.x86->ecx, into);
68 MaybeCaptureMemoryAround(process_reader, context.x86->edx, into);
69 MaybeCaptureMemoryAround(process_reader, context.x86->edi, into);
70 MaybeCaptureMemoryAround(process_reader, context.x86->esi, into);
71 MaybeCaptureMemoryAround(process_reader, context.x86->eip, into);
72 #if defined(ARCH_CPU_X86_64)
73 }
74 #endif
75 }
76
77 } // namespace internal
78 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698