This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[hpux] Improve handling of unwind records for hp compiler
- From: Randolph Chung <randolph at tausq dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 15 Dec 2005 22:48:12 +0800
- Subject: [hpux] Improve handling of unwind records for hp compiler
As discussed recently on the gdb mailing list, current gdb has problems
unwinding code generated by the HP compiler. The attached patch teaches
the hppa unwinder about two additional flags in the unwind record
generated by the HP toolchain.
For some reason in the gdb code, the "alloca_frame" bit is called
Pseudo_SP_Set; most HP docs refer to it as alloca_frame. I'll submit a
separate change to improve the "maint print unwind" command to print out
all the unwind record flags and change the name of the alloca_frame flag
to match the documentation.
This patch was tested with no regressions against GNU tools on
hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. I only tested it against
one HP compiled program I have on hand (wdb).
I'll commit this in a couple of days if there are no additional comments.
thanks
randolph
P.S. wdb doesn't handle this case correctly either.
2005-12-15 Randolph Chung <tausq@debian.org>
* hppa-tdep.c (hppa_frame_cache): Handle Region_Description and
Pseudo_SP_Set in unwind record.
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.216
diff -u -p -r1.216 hppa-tdep.c
--- hppa-tdep.c 9 Dec 2005 11:13:34 -0000 1.216
+++ hppa-tdep.c 15 Dec 2005 14:41:17 -0000
@@ -1857,7 +1857,7 @@ hppa_frame_cache (struct frame_info *nex
GCC code. */
{
int final_iteration = 0;
- CORE_ADDR pc, end_pc;
+ CORE_ADDR pc, start_pc, end_pc;
int looking_for_sp = u->Save_SP;
int looking_for_rp = u->Save_RP;
int fp_loc = -1;
@@ -1877,9 +1877,19 @@ hppa_frame_cache (struct frame_info *nex
/* We used to use frame_func_unwind () to locate the beginning of the
function to pass to skip_prologue (). However, when objects are
compiled without debug symbols, frame_func_unwind can return the wrong
- function (or 0). We can do better than that by using unwind records. */
+ function (or 0). We can do better than that by using unwind records.
+ This only works if the Region_description of the unwind record
+ indicates that it includes the entry point of the function.
+ HP compilers sometimes generate unwind records for regions that
+ do not include the entry or exit point of a function. GNU tools
+ do not do this. */
- prologue_end = skip_prologue_hard_way (u->region_start, 0);
+ if ((u->Region_description & 0x2) == 0)
+ start_pc = u->region_start;
+ else
+ start_pc = frame_func_unwind (next_frame);
+
+ prologue_end = skip_prologue_hard_way (start_pc, 0);
end_pc = frame_pc_unwind (next_frame);
if (prologue_end != 0 && end_pc > prologue_end)
@@ -1887,7 +1897,7 @@ hppa_frame_cache (struct frame_info *nex
frame_size = 0;
- for (pc = u->region_start;
+ for (pc = start_pc;
((saved_gr_mask || saved_fr_mask
|| looking_for_sp || looking_for_rp
|| frame_size < (u->Total_frame_size << 3))
@@ -2054,9 +2064,12 @@ hppa_frame_cache (struct frame_info *nex
instead of Save_SP. */
fp = frame_unwind_register_unsigned (next_frame, HPPA_FP_REGNUM);
+
+ if (u->Pseudo_SP_Set)
+ fp -= u->Total_frame_size << 3;
if (frame_pc_unwind (next_frame) >= prologue_end
- && u->Save_SP && fp != 0)
+ && (u->Save_SP || u->Pseudo_SP_Set) && fp != 0)
{
cache->base = fp;