[hppa] FYI: confusion in unwind descriptor field meaning

Randolph Chung randolph@tausq.org
Sat Nov 12 13:21:00 GMT 2005


> Hmm.  Is it possible to find a function's entry point from a PC within
> that function's code given only the unwind records?  If the detailed

There is one unwind record for each function. The unwind record contains
the start and end address of the function. So yes, given a pc, we can
find the unwind record and recover the starting address of the function.

> contents of the unwind records are difficult to interpret accurately,
> but we can accurately recover entry points from them, and prologue
> analysis works, then we could use the unwind records *only* to
> discover entry points, and then use prologue analysis to actually get
> the unwind information.

Well....
If we have an unwind record (and we should for any ABI-conforming
function), and the pc is after the prologue, then theoretically we don't
need to do prologue analysis.

Now, there is a trick to this -- how do we know we are after the
prologue? Currently, we look at the unwind record which tells us what
information is stored in the frame, and we do code analysis to determine
the pc where all the information that the unwind record says should be
in the frame has been stored in the frame.

We used to not do this, and in fact hppa-tdep.c has a few variations of
ways to "skip the prologue" :-(

The more efficient way to determine the end of the prologue is to use
debug info (i.e. we do what most backends do with
find_pc_partial_function and find_pc_line). Sometime last year I changed
this to always do code walking to better work with optimized functions.
Note that in this case we are only counting instructions and not really
"remembering" where things are.

Then we check to see if the pc is after the prologue. If it is not, we
do more prologue analysis and code walking to figure out what to do.

You might think this is all rather circular, and it is. I agree with
what you said below, that is:

> I'm sounding like some kind of prologue analysis fanatic here, but
> really I'm not.   We should make the best use of the techniques and
> information available, and it sounds to me like prologue analysis is
> comparable with the alternatives here, if we can find the information
> it needs.

I'm all for cleaning up the code; I just think we need to be careful
because of all the "twists" in the hppa ABI... especially on HPUX :(
Just take a look at hppa_hpux_push_dummy_code sometime. <sigh>

randolph
-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/



More information about the Gdb-patches mailing list