Where does VMError::print_native_stack and os::get_sender_for_C_frame load/use the frame pointer?
Julian Waters
tanksherman27 at gmail.com
Thu Jul 11 05:52:43 UTC 2024
Hi Dean,
I eventually did find frame::link(), but ultimately it didn't seem to help as VMError::print_native_stack still doesn't work properly on Windows. It seems as though frame::link() calls addr_at on x86, which in turn calls frame::fp(), which returns _fp. I think whatever sets _fp for VMError::print_native_stack is the missing link here, but unfortunately I don't know where it's set
The code that I tried on Windows x64 is attached below
best regards,
Julian
// VC++ does not save frame pointer on stack in optimized build. It
// can be turned off by -Oy-. If we really want to walk C frames,
// we can use the StackWalk() API.
frame os::get_sender_for_C_frame(frame* fr) {
#ifdef __GNUC__
return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
#elif defined(_MSC_VER)
ShouldNotReachHere();
return frame();
#endif
}
frame os::current_frame() {
#ifdef __GNUC__
frame f(reinterpret_cast<intptr_t*>(os::current_stack_pointer()),
reinterpret_cast<intptr_t*>(__builtin_frame_address(1)),
CAST_FROM_FN_PTR(address, &os::current_frame));
if (os::is_first_C_frame(&f)) {
// stack is not walkable
return frame();
} else {
return os::get_sender_for_C_frame(&f);
}
#elif defined(_MSC_VER)
return frame(); // cannot walk Windows frames this way. See os::get_native_stack
// and os::platform_print_native_stack
#endif
}
More information about the hotspot-dev
mailing list