8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well

Also fix stack trace on x86 to enable walking of runtime stubs and native wrappers

Reviewed-by: kvn
This commit is contained in:
Volker Simonis 2014-09-24 12:19:07 -07:00
parent f85f7d2832
commit a1628426d3
12 changed files with 117 additions and 41 deletions

View file

@ -577,7 +577,7 @@ void VMError::report(outputStream* st) {
STEP(120, "(printing native stack)" )
if (_verbose) {
if (_verbose) {
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.
@ -585,43 +585,7 @@ void VMError::report(outputStream* st) {
frame fr = _context ? os::fetch_frame_from_context(_context)
: os::current_frame();
// see if it's a valid frame
if (fr.pc()) {
st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
int count = 0;
while (count++ < StackPrintLimit) {
fr.print_on_error(st, buf, sizeof(buf));
st->cr();
// Compiled code may use EBP register on x86 so it looks like
// non-walkable C frame. Use frame.sender() for java frames.
if (_thread && _thread->is_Java_thread()) {
// Catch very first native frame by using stack address.
// For JavaThread stack_base and stack_size should be set.
if (!_thread->on_local_stack((address)(fr.sender_sp() + 1))) {
break;
}
if (fr.is_java_frame()) {
RegisterMap map((JavaThread*)_thread, false); // No update
fr = fr.sender(&map);
} else {
fr = os::get_sender_for_C_frame(&fr);
}
} else {
// is_first_C_frame() does only simple checks for frame pointer,
// it will pass if java compiled code has a pointer in EBP.
if (os::is_first_C_frame(&fr)) break;
fr = os::get_sender_for_C_frame(&fr);
}
}
if (count > StackPrintLimit) {
st->print_cr("...<more frames>...");
}
st->cr();
}
print_native_stack(st, fr, _thread, buf, sizeof(buf));
}
}