This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Invalid registers


On Wed, Jul 13, 2005 at 05:14:02PM +0100, Andrew STUBBS wrote:
> The SH ABI lists the PR register (in which the PC is saved by a branch to  
> subroutine) as caller save. This is true because a function has to save it  
> before calling a subroutine. However, in practice it can be viewed as a  
> callee save register because all non-leaf functions save it in the  
> function prologue. GCC appears to be emitting CFI information for PR as if  
> it was callee save.
> 
> You say that there should be no CFI for caller saved registers, so I'll  
> take that as answering my question.

Sorry, at some point you got me turned around with my own terminology. 
Let me try again, more coherently.

CFI describes saved registers.  It can describe any saved register;
typically, however, it only describes enough state to unwind to the
state as-of any call instruction, i.e. to describe any frame on the
stack.  At a call instruction there is still code in the caller to be
executed which will reload the caller saved registers; that code can be
freely scheduled, it is not part of the call sequence.  So typically it
is not described.  Those registers are dead at the call site and given
interesting values again later.

While the registers may be conceptually unavailable, the variables in
them are not - if your compiler emits good location lists, they'll
reflect the stack slots used.

So the value for PR we want to recover while unwinding is the value it
had "at the call site" - generally unavailable.  But we can figure out
what it was just after the call site, where the prologue will often
have saved it, and use that to determine where to unwind to.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]