Determine address of calling routine

Started by live2play, March 17, 2010, 06:10:59 PM

Previous topic - Next topic

live2play

I know that the CTR register holds the address of the instruction to execute on a bctrl, but how do you find the address of the instruction that called the routine you're currently in.  For instance, if I set an execute breakpoint at an address and it triggers, how do I determine the address of the instruction that executed the instruction at my breakpoint?

dcx2

Look at the Link Register.  It connects you back to the caller.  Be careful if the Link Register was pushed onto the stack.

http://wiird.l0nk.org/forum/index.php/topic,5080.0.html

live2play

Thanks for the link to the tutorial.  So, LR holds the address?

dcx2

I go into great detail in the tutorial.  LR usually holds the address, but at the beginning and end of functions it can be pushed on the stack, because another function might over-write the LR.  Sometimes you need to find the beginning or end of the function you want to find the caller of, so you can see the LR before it goes on or after it comes off the stack.