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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: snapshot/win/capture_context_memory.cc
diff --git a/snapshot/win/capture_context_memory.cc b/snapshot/win/capture_context_memory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c69cc36674c159369045e790a9e58d4f05bf49a
--- /dev/null
+++ b/snapshot/win/capture_context_memory.cc
@@ -0,0 +1,78 @@
+// Copyright 2015 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "snapshot/win/capture_context_memory.h"
+
+#include "snapshot/win/memory_snapshot_win.h"
+#include "snapshot/win/process_reader_win.h"
+
+namespace crashpad {
+namespace internal {
+
+namespace {
+
+void MaybeCaptureMemoryAround(ProcessReaderWin* process_reader,
+ WinVMAddress address,
+ PointerVector<MemorySnapshotWin>* into) {
+ if (address > 0x10000) {
+ const WinVMSize kRegisterByteOffset = 32;
+ const WinVMAddress target = address - kRegisterByteOffset;
+ const WinVMSize size = 128;
+ 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.
+ CheckedRange<WinVMAddress, WinVMSize>(target, size))) {
+ internal::MemorySnapshotWin* snapshot = new internal::MemorySnapshotWin();
+ snapshot->Initialize(process_reader, target, size);
+ into->push_back(snapshot);
+ }
+ }
+}
+
+} // namespace
+
+void CaptureMemoryPointedToByContext(const CPUContext& context,
+ ProcessReaderWin* process_reader,
+ PointerVector<MemorySnapshotWin>* into) {
+#if defined(ARCH_CPU_X86_64)
+ if (context.architecture == kCPUArchitectureX86_64) {
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rax, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rbx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rcx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rdx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rdi, into);
+ 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.
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r8, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r9, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r10, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r11, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r12, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r13, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r14, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->r15, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86_64->rip, into);
+ } else {
+#endif
+ MaybeCaptureMemoryAround(process_reader, context.x86->eax, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->ebx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->ecx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->edx, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->edi, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->esi, into);
+ MaybeCaptureMemoryAround(process_reader, context.x86->eip, into);
+#if defined(ARCH_CPU_X86_64)
+ }
+#endif
+}
+
+} // namespace internal
+} // namespace crashpad

Powered by Google App Engine
This is Rietveld 408576698