Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]: Setup sparc32 to support dwarf2 unwind sniffer
@ 2006-04-05  3:30 David S. Miller
  2006-04-05  9:11 ` Mark Kettenis
  0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2006-04-05  3:30 UTC (permalink / raw)
  To: gdb-patches


This doesn't actually enable the sniffer, it just adds the
necessary dwarf2_frame_set_init_reg() handler, similar to what
sparc64 already has implemented in sparc64-tdep.c

We can't unilaterally make use of the dwarf2 unwinder on all
sparc targets yet, because of the mentioned StackGhost issues
mentioned in the comment.

But after this patch, we can decide to enable dwarf2 unwinding on a
per-target basis.  And we can do so right now on targets that do not
support StackGhost.  Later if the StackGhost issue is resolved, we
can do this for all Sparc targets.

This is very desirable because many current Sparc bugs are due to
the fact that sparc_analyze_prologue() cannot deal at all with clever
assembler sequences, for example in cases where the save is deferred
to somewhere past the beginning of the function which is also a
valid compiler optimization.

Ok to apply?

2006-04-04  David S. Miller  <davem@sunset.davemloft.net>

	* sparc-tdep.c (sparc32_dwarf2_frame_init_reg): New.
	(sparc32_gdbarch_init): Pass it to dwarf2_frame_set_init_reg.
	* Makefile.in (sparc-tdep.o): Update dependencies.
	
--- sparc-tdep.c.~1~	2006-02-25 15:05:03.000000000 -0800
+++ sparc-tdep.c	2006-04-04 20:19:46.000000000 -0700
@@ -22,6 +22,7 @@
 #include "defs.h"
 #include "arch-utils.h"
 #include "dis-asm.h"
+#include "dwarf2-frame.h"
 #include "floatformat.h"
 #include "frame.h"
 #include "frame-base.h"
@@ -994,6 +995,32 @@
 	  || (sparc_floating_p (type) && TYPE_LENGTH (type) == 16));
 }
 
+static void
+sparc32_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
+			       struct dwarf2_frame_state_reg *reg)
+{
+  switch (regnum)
+    {
+    case SPARC_G0_REGNUM:
+      /* Since %g0 is always zero, there is no point in saving it, and
+	 people will be inclined omit it from the CFI.  Make sure we
+	 don't warn about that.  */
+      reg->how = DWARF2_FRAME_REG_SAME_VALUE;
+      break;
+    case SPARC_SP_REGNUM:
+      reg->how = DWARF2_FRAME_REG_CFA;
+      break;
+    case SPARC32_PC_REGNUM:
+      reg->how = DWARF2_FRAME_REG_RA_OFFSET;
+      reg->loc.offset = 8;
+      break;
+    case SPARC32_NPC_REGNUM:
+      reg->how = DWARF2_FRAME_REG_RA_OFFSET;
+      reg->loc.offset = 12;
+      break;
+    }
+}
+
 \f
 /* The SPARC Architecture doesn't have hardware single-step support,
    and most operating systems don't implement it either, so we provide
@@ -1248,6 +1275,11 @@
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
+  /* Hook in the DWARF CFI frame unwinder.  */
+  dwarf2_frame_set_init_reg (gdbarch, sparc32_dwarf2_frame_init_reg);
+  /* FIXME: kettenis/20050423: Don't enable the unwinder until the
+     StackGhost issues have been resolved.  */
+
   frame_unwind_append_sniffer (gdbarch, sparc32_frame_sniffer);
 
   /* If we have register sets, enable the generic core file support.  */
--- Makefile.in.~1~	2006-04-04 15:12:20.000000000 -0700
+++ Makefile.in	2006-04-04 20:23:16.000000000 -0700
@@ -2666,10 +2666,10 @@
 	$(sparc_tdep_h) $(solib_svr4_h)
 sparc-stub.o: sparc-stub.c
 sparc-tdep.o: sparc-tdep.c $(defs_h) $(arch_utils_h) $(dis_asm_h) \
-	$(floatformat_h) $(frame_h) $(frame_base_h) $(frame_unwind_h) \
-	$(gdbcore_h) $(gdbtypes_h) $(inferior_h) $(symtab_h) $(objfiles_h) \
-	$(osabi_h) $(regcache_h) $(target_h) $(value_h) $(gdb_assert_h) \
-	$(gdb_string_h) $(sparc_tdep_h)
+	$(dwarf2_frame_h) $(floatformat_h) $(frame_h) $(frame_base_h) \
+	$(frame_unwind_h) $(gdbcore_h) $(gdbtypes_h) $(inferior_h) \
+	$(symtab_h) $(objfiles_h) $(osabi_h) $(regcache_h) $(target_h) \
+	$(value_h) $(gdb_assert_h) $(gdb_string_h) $(sparc_tdep_h)
 stabsread.o: stabsread.c $(defs_h) $(gdb_string_h) $(bfd_h) $(gdb_obstack_h) \
 	$(symtab_h) $(gdbtypes_h) $(expression_h) $(symfile_h) $(objfiles_h) \
 	$(aout_stab_gnu_h) $(libaout_h) $(aout_aout64_h) $(gdb_stabs_h) \


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

end of thread, other threads:[~2006-04-05 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-05  3:30 [PATCH]: Setup sparc32 to support dwarf2 unwind sniffer David S. Miller
2006-04-05  9:11 ` Mark Kettenis
2006-04-05 13:38   ` Daniel Jacobowitz
2006-04-05 18:54   ` David S. Miller

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