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

Unified Diff: snapshot/win/exception_snapshot_win.cc

Issue 1336823002: win x86: Grab bag of restructuring to get tests working on x86-on-x86 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes2 Created 5 years, 3 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/exception_snapshot_win.cc
diff --git a/snapshot/win/exception_snapshot_win.cc b/snapshot/win/exception_snapshot_win.cc
index a32c929487a51548521d9b505b8f32ff27bd7671..1156baf35d4b37852d20521a6ea91fb87d2b30d0 100644
--- a/snapshot/win/exception_snapshot_win.cc
+++ b/snapshot/win/exception_snapshot_win.cc
@@ -69,42 +69,30 @@ bool ExceptionSnapshotWin::Initialize(ProcessReaderWin* process_reader,
return false;
}
+#if defined(ARCH_CPU_64_BITS)
if (process_reader->Is64Bit()) {
- EXCEPTION_RECORD64 first_record;
- if (!process_reader->ReadMemory(
- reinterpret_cast<WinVMAddress>(exception_pointers.ExceptionRecord),
- sizeof(first_record),
- &first_record)) {
- LOG(ERROR) << "ExceptionRecord";
+ CONTEXT context_record;
+ if (!InitializeFromExceptionPointers<EXCEPTION_RECORD64>(
+ *process_reader, exception_pointers, &context_record)) {
return false;
}
- exception_code_ = first_record.ExceptionCode;
- exception_flags_ = first_record.ExceptionFlags;
- exception_address_ = first_record.ExceptionAddress;
- for (DWORD i = 0; i < first_record.NumberParameters; ++i)
- codes_.push_back(first_record.ExceptionInformation[i]);
- if (first_record.ExceptionRecord) {
- // https://code.google.com/p/crashpad/issues/detail?id=43
- LOG(WARNING) << "dropping chained ExceptionRecord";
- }
-
context_.architecture = kCPUArchitectureX86_64;
context_.x86_64 = &context_union_.x86_64;
- // We assume 64-on-64 here in that we're relying on the CONTEXT definition
- // to be the x64 one.
- CONTEXT context_record;
- if (!process_reader->ReadMemory(
- reinterpret_cast<WinVMAddress>(exception_pointers.ContextRecord),
- sizeof(context_record),
- &context_record)) {
- LOG(ERROR) << "ContextRecord";
- return false;
- }
InitializeX64Context(context_record, context_.x86_64);
} else {
- CHECK(false) << "TODO(scottmg) x86";
+ CHECK(false) << "TODO(scottmg) WOW64";
+ return false;
+ }
+#else
+ CONTEXT context_record;
+ if (!InitializeFromExceptionPointers<EXCEPTION_RECORD32>(
+ *process_reader, exception_pointers, &context_record)) {
return false;
}
+ context_.architecture = kCPUArchitectureX86;
+ context_.x86 = &context_union_.x86;
+ InitializeX86Context(context_record, context_.x86);
+#endif // ARCH_CPU_64_BITS
INITIALIZATION_STATE_SET_VALID(initialized_);
return true;
@@ -140,5 +128,39 @@ const std::vector<uint64_t>& ExceptionSnapshotWin::Codes() const {
return codes_;
}
+template <class ExceptionRecordType, class ContextType>
+bool ExceptionSnapshotWin::InitializeFromExceptionPointers(
+ const ProcessReaderWin& process_reader,
+ const EXCEPTION_POINTERS& exception_pointers,
+ ContextType* context_record) {
+ ExceptionRecordType first_record;
+ if (!process_reader.ReadMemory(
+ reinterpret_cast<WinVMAddress>(exception_pointers.ExceptionRecord),
+ sizeof(first_record),
+ &first_record)) {
+ LOG(ERROR) << "ExceptionRecord";
+ return false;
+ }
+ exception_code_ = first_record.ExceptionCode;
+ exception_flags_ = first_record.ExceptionFlags;
+ exception_address_ = first_record.ExceptionAddress;
+ for (DWORD i = 0; i < first_record.NumberParameters; ++i)
+ codes_.push_back(first_record.ExceptionInformation[i]);
+ if (first_record.ExceptionRecord) {
+ // https://code.google.com/p/crashpad/issues/detail?id=43
+ LOG(WARNING) << "dropping chained ExceptionRecord";
+ }
+
+ if (!process_reader.ReadMemory(
+ reinterpret_cast<WinVMAddress>(exception_pointers.ContextRecord),
+ sizeof(*context_record),
+ context_record)) {
+ LOG(ERROR) << "ContextRecord";
+ return false;
+ }
+
+ return true;
+}
+
} // namespace internal
} // namespace crashpad

Powered by Google App Engine
This is Rietveld 408576698