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

Unified Diff: base/debug/stack_trace_win.cc

Issue 896533003: Support creation of StackTrace directly from CONTEXT struct (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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
« no previous file with comments | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/stack_trace_win.cc
diff --git a/base/debug/stack_trace_win.cc b/base/debug/stack_trace_win.cc
index 8df6fc6e3e6cb21931540d46c6f6d162314c153c..27661edccd6c44716267ec344a6cfcef5280efe7 100644
--- a/base/debug/stack_trace_win.cc
+++ b/base/debug/stack_trace_win.cc
@@ -214,24 +214,35 @@ StackTrace::StackTrace() {
#endif
StackTrace::StackTrace(const EXCEPTION_POINTERS* exception_pointers) {
- // When walking an exception stack, we need to use StackWalk64().
- count_ = 0;
// StackWalk64() may modify context record passed to it, so we will
// use a copy.
CONTEXT context_record = *exception_pointers->ContextRecord;
+ InitTrace(&context_record);
+}
+
+StackTrace::StackTrace(const CONTEXT* context) {
+ // StackWalk64() may modify context record passed to it, so we will
+ // use a copy.
+ CONTEXT context_record = *context;
+ InitTrace(&context_record);
+}
+
+void StackTrace::InitTrace(CONTEXT* context_record) {
+ // When walking an exception stack, we need to use StackWalk64().
+ count_ = 0;
// Initialize stack walking.
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
#if defined(_WIN64)
int machine_type = IMAGE_FILE_MACHINE_AMD64;
- stack_frame.AddrPC.Offset = context_record.Rip;
- stack_frame.AddrFrame.Offset = context_record.Rbp;
- stack_frame.AddrStack.Offset = context_record.Rsp;
+ stack_frame.AddrPC.Offset = context_record->Rip;
+ stack_frame.AddrFrame.Offset = context_record->Rbp;
+ stack_frame.AddrStack.Offset = context_record->Rsp;
#else
int machine_type = IMAGE_FILE_MACHINE_I386;
- stack_frame.AddrPC.Offset = context_record.Eip;
- stack_frame.AddrFrame.Offset = context_record.Ebp;
- stack_frame.AddrStack.Offset = context_record.Esp;
+ stack_frame.AddrPC.Offset = context_record->Eip;
+ stack_frame.AddrFrame.Offset = context_record->Ebp;
+ stack_frame.AddrStack.Offset = context_record->Esp;
#endif
stack_frame.AddrPC.Mode = AddrModeFlat;
stack_frame.AddrFrame.Mode = AddrModeFlat;
@@ -240,7 +251,7 @@ StackTrace::StackTrace(const EXCEPTION_POINTERS* exception_pointers) {
GetCurrentProcess(),
GetCurrentThread(),
&stack_frame,
- &context_record,
+ context_record,
NULL,
&SymFunctionTableAccess64,
&SymGetModuleBase64,
« no previous file with comments | « base/debug/stack_trace.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698