How do I get at the current stack pointer?

Johan Walles d92-jwa@nada.kth.se
Fri Sep 6 01:54:00 GMT 2002


Hi!

We are developing a virtual machine for Java.  On Linux/IA64, the stack 
lay out for the methods we have generated is different from that of 
compiled C code.  Thus, when walking the stack, in a back trace for 
example, GDB can step into one of our stack frames, but on the way out 
it gets confused.

We are trying to solve this problem by adding some code to 
get_prev_frame() in blockframe.c, that:

* Checks the inferior for a stack walking helper function.
* If it exists, calls the function with the current pc and the current 
stack pointer (bsp).  It returns the stack pointer (bsp) and pc for the 
previous frame.

I have two questions about this.  First, does this seem like a 
reasonable solution, or do you think there is an easier way for us to do 
this?

Second, if I have a struct frame_info *, how do I get a stack pointer 
out of it?  I get the pc using gdbarch_frame_saved_pc() but I can't seem 
to find a similar function for accessing the stack pointer.

   Cheers //Johan



More information about the Gdb mailing list