Where does VMError::print_native_stack and os::get_sender_for_C_frame load/use the frame pointer?

Julian Waters tanksherman27 at gmail.com
Mon Jul 8 06:04:11 UTC 2024


Hi all,

I have a question with regards to os::get_sender_for_C_frame and
VMError::print_native_stack. In Windows specific code comments allude
to both needing the rbp register to be saved, which is why
VMError::print_native_stack
doesn't work on Windows since Microsoft Visual C doesn't save the frame
pointer, as stated:

/*
* Windows/x64 does not use stack frames the way expected by Java:
* [1] in most cases, there is no frame pointer. All locals are addressed via RSP
* [2] in rare cases, when alloca() is used, a frame pointer is used,
but this may
* not be RBP.
* See http://msdn.microsoft.com/en-us/library/ew5tede7.aspx
*
* So it's not possible to print the native stack using the
* while (...) {... fr = os::get_sender_for_C_frame(&fr); }
* loop in vmError.cpp. We need to roll our own loop.
*/

// 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.

I can't seem to find where rbp is loaded and used on platforms and
compilers that do save the frame pointer though. Eclipse cannot find
it through the vast collection of member methods inside the frame
class and related code. Do anyone by any chance know where the code that
loads and uses the frame pointer for os::get_sender_for_C_frame and
VMError::print_native_stack is located on such platforms?

best regards,
Julian


More information about the hotspot-dev mailing list