Use RtlCaptureContext instead of inline assembly to capture execution context on Windows

Inline assembly is not available in Visual C++ 64-bit version so use RtlCaptureContext to capture execution context. RtlCaptureContext is not available on Windows 2000 so this change removes Windows 2000 support. If this turns up causing trouble we can revert to only use RtlCaptureContext in 64-bit and inline assembly in 32-bit.
Review URL: http://codereview.chromium.org/335008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3122 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
sgjesse@chromium.org 2009-10-23 12:47:44 +00:00
parent 7a509f2101
commit b0dfb371d6

View File

@ -48,10 +48,10 @@
#ifndef NOMCX #ifndef NOMCX
#define NOMCX #define NOMCX
#endif #endif
// Require Windows 2000 or higher (this is required for the IsDebuggerPresent // Require Windows XP or higher (this is required for the RtlCaptureContext
// function to be present). // function to be present).
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x500 #define _WIN32_WINNT 0x501
#endif #endif
#include <windows.h> #include <windows.h>
@ -1208,22 +1208,7 @@ int OS::StackWalk(Vector<OS::StackFrame> frames) {
// Capture current context. // Capture current context.
CONTEXT context; CONTEXT context;
memset(&context, 0, sizeof(context)); RtlCaptureContext(&context);
context.ContextFlags = CONTEXT_CONTROL;
context.ContextFlags = CONTEXT_CONTROL;
#ifdef _WIN64
// TODO(X64): Implement context capture.
#else
__asm call x
__asm x: pop eax
__asm mov context.Eip, eax
__asm mov context.Ebp, ebp
__asm mov context.Esp, esp
// NOTE: At some point, we could use RtlCaptureContext(&context) to
// capture the context instead of inline assembler. However it is
// only available on XP, Vista, Server 2003 and Server 2008 which
// might not be sufficient.
#endif
// Initialize the stack walking // Initialize the stack walking
STACKFRAME64 stack_frame; STACKFRAME64 stack_frame;