The pns() function in debug.cpp is provided for use when running in a debugger so you can dump the mixed java and native stacks. However, it requires passing in $fp, $sp, and $pc registers. This makes it hard to use if you want to add a call to it from within hotspot source. I propose the following alternate psn2() function to be used for this purpose.
//
// This version of pns() is not useful when called from the debugger, but is
// useful when called from within hotspot code. The advantages over pns()
// are not having to pass in any arguments, and it will work on Windows/x64.
//
extern "C" void pns2() { // print native stack
Command c("pns2");
static char buf[O_BUFLEN];
if (os::platform_print_native_stack(tty, NULL, buf, sizeof(buf))) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
Thread* t = Thread::current_or_null();
frame fr = os::current_frame();
VMError::print_native_stack(tty, fr, t, buf, sizeof(buf));
}
}
//
// This version of pns() is not useful when called from the debugger, but is
// useful when called from within hotspot code. The advantages over pns()
// are not having to pass in any arguments, and it will work on Windows/x64.
//
extern "C" void pns2() { // print native stack
Command c("pns2");
static char buf[O_BUFLEN];
if (os::platform_print_native_stack(tty, NULL, buf, sizeof(buf))) {
// We have printed the native stack in platform-specific code,
// so nothing else to do in this case.
} else {
Thread* t = Thread::current_or_null();
frame fr = os::current_frame();
VMError::print_native_stack(tty, fr, t, buf, sizeof(buf));
}
}