From timurrrr.com on August 26, 2011 10:23:09
As of r481 :
include
include
pragma comment(lib, "dbghelp.lib")
include
include
long WINAPI SDEF(EXCEPTION_POINTERS *ep) { STACKFRAME64 stack_frame; memset(&stack_frame, 0, sizeof(stack_frame)); stack_frame.AddrPC.Offset = ep->ContextRecord->Eip; stack_frame.AddrFrame.Offset = ep->ContextRecord->Ebp; stack_frame.AddrStack.Offset = ep->ContextRecord->Esp; stack_frame.AddrPC.Mode = AddrModeFlat; stack_frame.AddrFrame.Mode = AddrModeFlat; stack_frame.AddrStack.Mode = AddrModeFlat; while (StackWalk64(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(), &stack_frame, ep->ContextRecord, NULL, &SymFunctionTableAccess64, &SymGetModuleBase64, NULL)) { printf("Frame: 0x%08X\n", stack_frame.AddrPC.Offset); } return 1; }
int main() { SetUnhandledExceptionFilter(&SDEF); throw std::exception("Woo"); }
Error #1: UNINITIALIZED READ: reading 0x0018ea2c-0x0018ea2d 1 byte(s)
:00:02.162 in thread 4972
Note: instruction: test 0xffffffb4(%ebp) $0x01
0x73f94c40 dbghelp.dll!SymFromAddrW
0x73f94916 dbghelp.dll!SymFromAddrW
0x73f94f0f dbghelp.dll!SymFromAddrW
0x73f965b1 dbghelp.dll!StackWalk64
0x73f964c8 dbghelp.dll!StackWalk64
0x004010e4 test.exe!SDEF
c:\sandbox\stackwalk\test.cpp:20
Original issue: http://code.google.com/p/drmemory/issues/detail?id=567
该提问来源于开源项目:DynamoRIO/drmemory