33 #include "jvm_windows.h"
34 #include "memory/allocation.inline.hpp"
35 #include "memory/resourceArea.hpp"
36 #include "nativeInst_x86.hpp"
37 #include "os_share_windows.hpp"
38 #include "prims/jniFastGetField.hpp"
39 #include "prims/jvm.h"
40 #include "prims/jvm_misc.hpp"
41 #include "runtime/arguments.hpp"
42 #include "runtime/extendedPC.hpp"
43 #include "runtime/frame.inline.hpp"
44 #include "runtime/interfaceSupport.hpp"
45 #include "runtime/java.hpp"
46 #include "runtime/javaCalls.hpp"
47 #include "runtime/mutexLocker.hpp"
48 #include "runtime/osThread.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/stubRoutines.hpp"
51 #include "runtime/thread.inline.hpp"
52 #include "runtime/timer.hpp"
53 #include "unwind_windows_x86.hpp"
54 #include "utilities/events.hpp"
55 #include "utilities/vmError.hpp"
56 #include "windbghelp.hpp"
57
58
59 #undef REG_SP
60 #undef REG_FP
61 #undef REG_PC
62 #ifdef AMD64
63 #define REG_SP Rsp
64 #define REG_FP Rbp
65 #define REG_PC Rip
66 #else
67 #define REG_SP Esp
68 #define REG_FP Ebp
69 #define REG_PC Eip
70 #endif // AMD64
71
72 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
380 stk.AddrFrame.Mode = AddrModeFlat;
381 stk.AddrPC.Offset = ctx.Rip;
382 stk.AddrPC.Mode = AddrModeFlat;
383
384 int count = 0;
385 address lastpc = 0;
386 while (count++ < StackPrintLimit) {
387 intptr_t* sp = (intptr_t*)stk.AddrStack.Offset;
388 intptr_t* fp = (intptr_t*)stk.AddrFrame.Offset; // NOT necessarily the same as ctx.Rbp!
389 address pc = (address)stk.AddrPC.Offset;
390
391 if (pc != NULL) {
392 if (count == 2 && lastpc == pc) {
393 // Skip it -- StackWalk64() may return the same PC
394 // (but different SP) on the first try.
395 } else {
396 // Don't try to create a frame(sp, fp, pc) -- on WinX64, stk.AddrFrame
397 // may not contain what Java expects, and may cause the frame() constructor
398 // to crash. Let's just print out the symbolic address.
399 frame::print_C_frame(st, buf, buf_size, pc);
400 st->cr();
401 }
402 lastpc = pc;
403 }
404
405 PVOID p = WindowsDbgHelp::symFunctionTableAccess64(GetCurrentProcess(), stk.AddrPC.Offset);
406 if (!p) {
407 // StackWalk64() can't handle this PC. Calling StackWalk64 again may cause crash.
408 break;
409 }
410
411 BOOL result = WindowsDbgHelp::stackWalk64(
412 IMAGE_FILE_MACHINE_AMD64, // __in DWORD MachineType,
413 GetCurrentProcess(), // __in HANDLE hProcess,
414 GetCurrentThread(), // __in HANDLE hThread,
415 &stk, // __inout LP STACKFRAME64 StackFrame,
416 &ctx); // __inout PVOID ContextRecord,
417
418 if (!result) {
419 break;
|
33 #include "jvm_windows.h"
34 #include "memory/allocation.inline.hpp"
35 #include "memory/resourceArea.hpp"
36 #include "nativeInst_x86.hpp"
37 #include "os_share_windows.hpp"
38 #include "prims/jniFastGetField.hpp"
39 #include "prims/jvm.h"
40 #include "prims/jvm_misc.hpp"
41 #include "runtime/arguments.hpp"
42 #include "runtime/extendedPC.hpp"
43 #include "runtime/frame.inline.hpp"
44 #include "runtime/interfaceSupport.hpp"
45 #include "runtime/java.hpp"
46 #include "runtime/javaCalls.hpp"
47 #include "runtime/mutexLocker.hpp"
48 #include "runtime/osThread.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/stubRoutines.hpp"
51 #include "runtime/thread.inline.hpp"
52 #include "runtime/timer.hpp"
53 #include "symbolengine.hpp"
54 #include "unwind_windows_x86.hpp"
55 #include "utilities/events.hpp"
56 #include "utilities/vmError.hpp"
57 #include "windbghelp.hpp"
58
59
60 #undef REG_SP
61 #undef REG_FP
62 #undef REG_PC
63 #ifdef AMD64
64 #define REG_SP Rsp
65 #define REG_FP Rbp
66 #define REG_PC Rip
67 #else
68 #define REG_SP Esp
69 #define REG_FP Ebp
70 #define REG_PC Eip
71 #endif // AMD64
72
73 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
381 stk.AddrFrame.Mode = AddrModeFlat;
382 stk.AddrPC.Offset = ctx.Rip;
383 stk.AddrPC.Mode = AddrModeFlat;
384
385 int count = 0;
386 address lastpc = 0;
387 while (count++ < StackPrintLimit) {
388 intptr_t* sp = (intptr_t*)stk.AddrStack.Offset;
389 intptr_t* fp = (intptr_t*)stk.AddrFrame.Offset; // NOT necessarily the same as ctx.Rbp!
390 address pc = (address)stk.AddrPC.Offset;
391
392 if (pc != NULL) {
393 if (count == 2 && lastpc == pc) {
394 // Skip it -- StackWalk64() may return the same PC
395 // (but different SP) on the first try.
396 } else {
397 // Don't try to create a frame(sp, fp, pc) -- on WinX64, stk.AddrFrame
398 // may not contain what Java expects, and may cause the frame() constructor
399 // to crash. Let's just print out the symbolic address.
400 frame::print_C_frame(st, buf, buf_size, pc);
401 // print source file and line, if available
402 char buf[128];
403 int line_no;
404 if (SymbolEngine::get_source_info(pc, buf, sizeof(buf), &line_no)) {
405 st->print(" (%s:%d)", buf, line_no);
406 }
407 st->cr();
408 }
409 lastpc = pc;
410 }
411
412 PVOID p = WindowsDbgHelp::symFunctionTableAccess64(GetCurrentProcess(), stk.AddrPC.Offset);
413 if (!p) {
414 // StackWalk64() can't handle this PC. Calling StackWalk64 again may cause crash.
415 break;
416 }
417
418 BOOL result = WindowsDbgHelp::stackWalk64(
419 IMAGE_FILE_MACHINE_AMD64, // __in DWORD MachineType,
420 GetCurrentProcess(), // __in HANDLE hProcess,
421 GetCurrentThread(), // __in HANDLE hThread,
422 &stk, // __inout LP STACKFRAME64 StackFrame,
423 &ctx); // __inout PVOID ContextRecord,
424
425 if (!result) {
426 break;
|