This is the mail archive of the gdb@sourceware.org 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: fail to get ra and bp


> I am porting GDB to a new target.

Would you mind telling us what this new target is? I believe this will
greatly help us provide more accurate answers. In the meantime...

> The prologue has two insns ---- push ra and push bp.
> When back tracing and printing variables, gdb will look for return address 
> of this frame and frame pointer on stack.
> Unfortunately, If compiling with -O2, the two insns are probably deleted. 
> So, GDB will not get ra and bp value.

Typical problem. My recommendation, stay away from prologue analysis
as much as you can, because as you know, higher levels of optimization
will break the typical frame layout. What you want, is have this
information provided by the compiler itself and dumped into the
objects in some form.

One very popular form, at least in the GNU world, is DWARF CFI. There
is also another popular form, which I don't really know much about.
The information is stored in .eh_frame sections. But it essentially
does the same: It tells you how to unwind the call stack.

This is what you want because this information allows you to avoid
tricky prologue scanning and hairy heuristics to try to guess where
things are.

Now that I think of it, if you have no choice but do prologue scanning,
you might want to look at a framework that was recently contributed
which should make your task easier. I think it's prologue-value.[hc].

-- 
Joel


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