Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Re: [patch/rfa/hppa] Use frame pointer for unwinding
@ 2004-05-17 17:14 John David Anglin
  2004-05-17 17:28 ` Randolph Chung
  0 siblings, 1 reply; 17+ messages in thread
From: John David Anglin @ 2004-05-17 17:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: tausq, cagney

> ok. there is no gcc bug yet, but i will file one.

Bug?

> the fp != 0 is there probably because i don't understand correctly how
> the unwinder is working. if you have three frames:

> frame 3 - unwind from here
> frame 2 - doesn't save fp; fp should be constant in this function
> frame 1 - saves fp

Note that the the previous SP (frame pointer) is saved in the frame
marker of frame 1.  This value is accessible from frame 2 (i.e.,
effectively the frame pointer is always saved under hpux when Save_SP
is true -- it's just done by the caller).  However, I think gdb
should avoid using the saved SP value in the frame marker as not
all versions of GCC support this.  It's also not supported under
linux.

There are basically three situations generated by GCC:

1) The previous SP is saved at the start of the frame, the frame has
   a frame pointer (all alloca frames have a frame pointer) and Save_SP
   is set in the callinfo data.  Under hpux, the previous SP value
   is also saved at SP - 4 (8 on hppa64) in the frame marker.  This
   value is copied when a stack adjustment is done (i.e., the frame
   marker moves).

2) The frame uses register %r3 but doesn't have a frame pointer.  In
   this case, %r3 is saved along with the other general registers.

3) The frame does have a frame pointer or use %r3.  %r3 is not saved
   in the frame.

> frame 3 gets frame 2 as next_frame, will it be able to get the value of
> fp (from what is saved in frame 1)? it seems to work in my tests, but 
> i haven't yet figured out how it works in the code. if frame 2 doesn't
> save a register in its cache, is there some code that by default 
> propagates the values from the next frame?

If frame doesn't save %r3 either using method 1 or 2, then frame 2
leaves %r3 unchanged.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [patch/rfa/hppa] Use frame pointer for unwinding
@ 2004-05-17 16:13 John David Anglin
  0 siblings, 0 replies; 17+ messages in thread
From: John David Anglin @ 2004-05-17 16:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: cagney, randolph

> > Anyway, I spoke with Dave Anglin (hppa gcc maintainer) about this. The
> > problem is that currently gcc/binutils does not correctly implement the
> > alloca_frame bit. The frame pointer is maintained in the case of a
> > variable-sized frame, but there is no flag set in the unwind record, and
> > the frame layout is slightly different compared to the HP compiler. It's
> > one of the things that should be fixed in gcc eventually. Also Dave has
> > observed that the Save_SP bit is set only for gcc; with the HP compiler
> > this is not set. Finally, with the HP compiler the frame pointer can be
> > maintained either in r3 or r4. It's not clear yet how this works. Some
> > more experimentation/disassembling HP code is required :-( I will add
> > some comments to the code about this situation. 
> 
> Is there a GCC bug report for this?

No.  GCC has always used a different frame layout than HP and set
Save_SP to indicate that the frame has a frame pointer.  Whether it
is a bug to not set the alloca_frame bit is an open question given
the different layout.

Ada uses the HP unwind library to a limited extent for backtraces.  I
believe that the frame marker support that GCC provides for the saved
SP value is sufficient for the library to unwind an alloca frame
without the alloca_frame bit being set.  We only do this under hpux
for compatibility with the HP library.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)


^ permalink raw reply	[flat|nested] 17+ messages in thread
* [patch/rfa/hppa] Use frame pointer for unwinding
@ 2004-05-16  2:07 Randolph Chung
  2004-05-16 10:36 ` Mark Kettenis
  2004-05-16 16:32 ` Andrew Cagney
  0 siblings, 2 replies; 17+ messages in thread
From: Randolph Chung @ 2004-05-16  2:07 UTC (permalink / raw)
  To: gdb-patches

One more patch --

Currently we don't use the frame pointer to unwind the stack, we rely
only on unwinding records. However, this doesn't work for functions that
call alloca() because the unwinding record does not account for the
variable-sized stack frame. In this case, the ABI requires that the
compiler always maintain a frame pointer.

Fixes these two FAILs from the testsuite, no new regressions.
+PASS: gdb.base/funcargs.exp: backtrace from call_after_alloca_subr
+PASS: gdb.base/selftest.exp: backtrace through signal handler

ok to apply?
randolph


2004-05-15  Randolph Chung  <tausq@debian.org>

	* hppa-tdep.c (hppa_frame_cache): If a frame pointer is available, use
	it for unwinding the stack.

Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.156
diff -u -p -r1.156 hppa-tdep.c
--- hppa-tdep.c	8 May 2004 03:59:34 -0000	1.156
+++ hppa-tdep.c	16 May 2004 01:42:56 -0000
@@ -1761,15 +1798,26 @@ hppa_frame_cache (struct frame_info *nex
        the current function (and is thus equivalent to the "saved"
        stack pointer.  */
     CORE_ADDR this_sp = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
+    CORE_ADDR fp;
 
    if (hppa_debug)
       fprintf_unfiltered (gdb_stdlog, " (this_sp=0x%s, pc=0x%s, "
 		          "prologue_end=0x%s) ",
 		          paddr_nz (this_sp),
 			  paddr_nz (frame_pc_unwind (next_frame)),
 			  paddr_nz (prologue_end));
 
-    if (frame_pc_unwind (next_frame) >= prologue_end)
+    if (get_frame_type (next_frame) == NORMAL_FRAME
+        && u->Save_SP 
+	&& (fp = frame_unwind_register_unsigned (next_frame, HPPA_FP_REGNUM)))
+      {
+	cache->base = fp;
+
+	if (hppa_debug)
+	  fprintf_unfiltered (gdb_stdlog, " (base=0x%s) [frame pointer] }",
+			      paddr_nz (cache->base));
+      }
+    else if (frame_pc_unwind (next_frame) >= prologue_end)
       {
         if (u->Save_SP && trad_frame_addr_p (cache->saved_regs, HPPA_SP_REGNUM))
           {

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-05-17 17:54 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-17 17:14 [patch/rfa/hppa] Use frame pointer for unwinding John David Anglin
2004-05-17 17:28 ` Randolph Chung
2004-05-17 17:54   ` John David Anglin
  -- strict thread matches above, loose matches on Subject: below --
2004-05-17 16:13 John David Anglin
2004-05-16  2:07 Randolph Chung
2004-05-16 10:36 ` Mark Kettenis
2004-05-16 15:36   ` Randolph Chung
2004-05-16 16:22     ` Mark Kettenis
2004-05-16 16:42       ` Randolph Chung
2004-05-16 16:32 ` Andrew Cagney
2004-05-16 17:03   ` Randolph Chung
2004-05-17  0:13     ` Randolph Chung
2004-05-17  2:34       ` Randolph Chung
2004-05-17 15:23         ` Andrew Cagney
2004-05-17 16:01           ` Randolph Chung
2004-05-17 17:27             ` Andrew Cagney
2004-05-17 15:13     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox