Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Dwarf-2 unwinding vs. manual prologue analysis
@ 2005-05-26 15:24 Orjan Friberg
  2005-05-26 20:40 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Orjan Friberg @ 2005-05-26 15:24 UTC (permalink / raw)
  To: gdb-patches

When adding the CRISv32 support, it seemed like a good idea to avoid having to 
do manual prologue analysis to determine where registers are saved, figuring out 
the return address etc.  For some reason I imagined I wouldn't have to do this 
if I could use the Dwarf-2 frame sniffer (because all code would have Dwarf-2 
CFI).  I hooked in the Dwarf-2 frame sniffer and everything ran fine, and it 
wasn't until just recently that I discovered (to my horror) that the prologue 
scanner (meant for CRISv10 only; the ISAs are not compatible) was not only 
called when debugging CRISv32, but simple things like 'next' broke in various 
places in the testsuite when I didn't do it.

I do feel a bit embarrased asking this, as one would think I'd know this 
already.  Since I obviously don't, here we go:

Do I need to able to do manual prologue analysis when there's Dwarf-2 CFI 
available?  If so, is there a set of minimum requirements for what that analysis 
must be able figure out?


For the record: I created a minimal prologue scanner for CRISv32 by using the 
time-honoured method of gradually stripping away stuff from the CRISv10 version 
until things stopped working.  This is what I ended up with:

   frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base);
   info->base = this_base;
   info->prev_sp = this_base;

   /* The PC is found in SRP (the actual register or located on the stack).  */
   info->saved_regs[PC_REGNUM] = info->saved_regs[SRP_REGNUM];


-- 
Orjan Friberg
Axis Communications


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

* Re: Dwarf-2 unwinding vs. manual prologue analysis
  2005-05-26 15:24 Dwarf-2 unwinding vs. manual prologue analysis Orjan Friberg
@ 2005-05-26 20:40 ` Daniel Jacobowitz
       [not found]   ` <4296F9B6.10500@axis.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-05-26 20:40 UTC (permalink / raw)
  To: Orjan Friberg; +Cc: gdb-patches

Please use gdb@ for questions; I expect most messages to gdb-patches to
be in need of review :-)

On Thu, May 26, 2005 at 04:59:05PM +0200, Orjan Friberg wrote:
> When adding the CRISv32 support, it seemed like a good idea to avoid having 
> to do manual prologue analysis to determine where registers are saved, 
> figuring out the return address etc.  For some reason I imagined I wouldn't 
> have to do this if I could use the Dwarf-2 frame sniffer (because all code 
> would have Dwarf-2 CFI).  I hooked in the Dwarf-2 frame sniffer and 
> everything ran fine, and it wasn't until just recently that I discovered 
> (to my horror) that the prologue scanner (meant for CRISv10 only; the ISAs 
> are not compatible) was not only called when debugging CRISv32, but simple 
> things like 'next' broke in various places in the testsuite when I didn't 
> do it.
> 
> I do feel a bit embarrased asking this, as one would think I'd know this 
> already.  Since I obviously don't, here we go:
> 
> Do I need to able to do manual prologue analysis when there's Dwarf-2 CFI 
> available?  If so, is there a set of minimum requirements for what that 
> analysis must be able figure out?

No.  If enabling the DWARF-2 CFI support causes things to break, then
you need to inspect your CFI; it is probably broken.  You need to do
prologue analysis if there's anything without CFI that you need to
handle, which there usually is - for instance PLT stubs.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: Dwarf-2 unwinding vs. manual prologue analysis
       [not found]   ` <4296F9B6.10500@axis.com>
@ 2005-05-28  8:58     ` Orjan Friberg
  0 siblings, 0 replies; 3+ messages in thread
From: Orjan Friberg @ 2005-05-28  8:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Daniel Jacobowitz

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]

(Back to gdb-patches@ for patch submission.)

Orjan Friberg wrote:
> 
> Ah, now I see.  The things that broke without any prologue scanning were 
> indeed things like 'next' over library calls (PLT stubs) and things 
> related to call dummys (callfuncs.exp).

Add signal trampolines to that list too.

The change below (committed) doesn't make anything better or worse; it just 
clarifies the situation in which it's assumed that the new CRISv32-specific 
prologue scanner will be used and what conditions are assumed to hold true.

2005-05-27  Orjan Friberg  <orjanf@axis.com>

	* cris-tdep.c (crisv32_scan_prologue): Add.
	(cris_frame_unwind_cache, cris_skip_prologue): Call
	crisv32_scan_prologue when debugging CRISv32.

-- 
Orjan Friberg
Axis Communications


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2818 bytes --]

Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.131
diff -u -p -r1.131 cris-tdep.c
--- cris-tdep.c	27 May 2005 13:47:59 -0000	1.131
+++ cris-tdep.c	27 May 2005 14:14:24 -0000
@@ -724,6 +724,10 @@ static CORE_ADDR cris_scan_prologue (COR
 				     struct frame_info *next_frame,
 				     struct cris_unwind_cache *info);
 
+static CORE_ADDR crisv32_scan_prologue (CORE_ADDR pc, 
+					struct frame_info *next_frame,
+					struct cris_unwind_cache *info);
+
 static CORE_ADDR cris_unwind_pc (struct gdbarch *gdbarch, 
 				 struct frame_info *next_frame);
 
@@ -795,7 +799,10 @@ cris_frame_unwind_cache (struct frame_in
   info->leaf_function = 0;
 
   /* Prologue analysis does the rest...  */
-  cris_scan_prologue (frame_func_unwind (next_frame), next_frame, info);
+  if (cris_version () == 32)
+    crisv32_scan_prologue (frame_func_unwind (next_frame), next_frame, info);
+  else
+    cris_scan_prologue (frame_func_unwind (next_frame), next_frame, info);
 
   return info;
 }
@@ -1375,6 +1382,42 @@ cris_scan_prologue (CORE_ADDR pc, struct
   return pc;
 }
 
+static CORE_ADDR 
+crisv32_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame,
+		    struct cris_unwind_cache *info)
+{
+  ULONGEST this_base;
+
+  /* Unlike the CRISv10 prologue scanner (cris_scan_prologue), this is not
+     meant to be a full-fledged prologue scanner.  It is only needed for 
+     the cases where we end up in code always lacking DWARF-2 CFI, notably:
+
+       * PLT stubs (library calls)
+       * call dummys
+       * signal trampolines
+
+     For those cases, it is assumed that there is no actual prologue; that 
+     the stack pointer is not adjusted, and (as a consequence) the return
+     address is not pushed onto the stack.  */
+
+  /* We only want to know the end of the prologue when next_frame and info
+     are NULL (called from cris_skip_prologue i.e.).  */
+  if (next_frame == NULL && info == NULL)
+    {
+      return pc;
+    }
+
+  /* The SP is assumed to be unaltered.  */
+  frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base);
+  info->base = this_base;
+  info->prev_sp = this_base;
+      
+  /* The PC is assumed to be found in SRP.  */
+  info->saved_regs[PC_REGNUM] = info->saved_regs[SRP_REGNUM];
+
+  return pc;
+}
+
 /* Advance pc beyond any function entry prologue instructions at pc
    to reach some "real" code.  */
 
@@ -1397,7 +1440,11 @@ cris_skip_prologue (CORE_ADDR pc)
 	return sal.end;
     }
 
-  pc_after_prologue = cris_scan_prologue (pc, NULL, NULL);
+  if (cris_version () == 32)
+    pc_after_prologue = crisv32_scan_prologue (pc, NULL, NULL);
+  else
+    pc_after_prologue = cris_scan_prologue (pc, NULL, NULL);
+
   return pc_after_prologue;
 }
 

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

end of thread, other threads:[~2005-05-27 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-26 15:24 Dwarf-2 unwinding vs. manual prologue analysis Orjan Friberg
2005-05-26 20:40 ` Daniel Jacobowitz
     [not found]   ` <4296F9B6.10500@axis.com>
2005-05-28  8:58     ` Orjan Friberg

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