alternate pns() debug function
Ioi Lam
ioi.lam at oracle.com
Tue Nov 7 07:20:31 UTC 2017
On 11/6/17 9:05 PM, Chris Plummer wrote:
> Hi,
>
> I'd like to add an alternate version of pns() to debug.cpp, and would
> like some initial comments first before filing a bug and sending out
> an RFR. pns() is used to print out the native stack:
>
> extern "C" void pns(void* sp, void* fp, void* pc) { // print native stack
> Command c("pns");
> static char buf[O_BUFLEN];
> Thread* t = Thread::current_or_null();
> // Call generic frame constructor (certain arguments may be ignored)
> frame fr(sp, fp, pc);
> VMError::print_native_stack(tty, fr, t, buf, sizeof(buf));
> }
>
> And here's the help output for it:
>
> pns(void* sp, void* fp, void* pc) - print native (i.e. mixed) stack
> trace. E.g.");
> pns($sp, $rbp, $pc) on Linux/amd64 and
> Solaris/amd64 or");
> pns($sp, $ebp, $pc) on Linux/x86 or");
> pns($sp, 0, $pc) on Linux/ppc64 or");
> pns($sp + 0x7ff, 0, $pc) on Solaris/SPARC");
> - in gdb do 'set overload-resolution off' before
> calling pns()");
> - in dbx do 'frame 1' before calling pns()");
>
> The intent is to call it from gdb, but it is potentially useful to
> call it from within hotspot when debugging. I'd like to propose the
> following alternative, since it does away with needing to pass in
> register values (not easy to do from C):
>
> extern "C" void pns2() { // print native stack
> Command c("pns2");
> static char buf[O_BUFLEN];
> Thread* t = Thread::current_or_null();
> frame fr = os::current_frame();
> VMError::print_native_stack(tty, fr, t, buf, sizeof(buf));
> }
>
> I actually used this quite a bit with some recent debugging. There
> were places in hotspot where I wanted to know what the native stack
> looked like when called, and it was a lot easier to just add a call to
> pns2() than to setup the test to run in gdb. This seems to work on
> Linux/x64, macosx/64, and solaris/sparc. For some reason it crashes on
> Windows/x64, but I don't see any indication from the above help for
> pns() that it works on Windows/x64 anyway.
>
> #
> # A fatal error has been detected by the Java Runtime Environment:
> #
> # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000003bcfae1466,
> pid=9872, tid=12212
> #
> # JRE version: Java(TM) SE Runtime Environment (10.0) (fastdebug build
> 10-internal+0-2017-11-07-0256309.chris.plummer.jdk10-hs)
> # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug
> 10-internal+0-2017-11-07-0256309.chris.plummer.jdk10-hs, mixed mode,
> tiered, compressed oops, g1 gc, windows-amd64)
> # Problematic frame:
> # v ~StubRoutines::get_previous_fp
> #
>
> I'm starting to suspect that os::current_frame() normally is never
> even called on Windows (there are calls to it in the VmError code, but
> I suspect they are never triggered on Windows) and that
> StubRoutines::get_previous_fp() is not working on Windows, but I could
> be wrong.
>
Hi Chris,
I like this new pns2() function.
To make this work on Windows, you probably need to follow this pattern
in vmError.cpp.
if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
// We have printed the native stack in platform-specific code
// Windows/x64 needs special handling.
} else {
frame fr = _context ? os::fetch_frame_from_context(_context)
: os::current_frame();
print_native_stack(st, fr, _thread, buf, sizeof(buf));
}
Thanks
- Ioi
> Let me know what you think.
>
> thanks,
>
> Chris
>
More information about the hotspot-runtime-dev
mailing list