From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12153 invoked by alias); 5 Apr 2006 03:30:21 -0000 Received: (qmail 12145 invoked by uid 22791); 5 Apr 2006 03:30:20 -0000 X-Spam-Check-By: sourceware.org Received: from dsl027-180-168.sfo1.dsl.speakeasy.net (HELO sunset.davemloft.net) (216.27.180.168) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Apr 2006 03:30:19 +0000 Received: from localhost ([127.0.0.1] ident=davem) by sunset.davemloft.net with esmtp (Exim 4.60) (envelope-from ) id 1FQyiP-0004Cn-S4 for gdb-patches@sources.redhat.com; Tue, 04 Apr 2006 20:29:53 -0700 Date: Wed, 05 Apr 2006 03:30:00 -0000 Message-Id: <20060404.202940.38078716.davem@davemloft.net> To: gdb-patches@sources.redhat.com Subject: [PATCH]: Setup sparc32 to support dwarf2 unwind sniffer From: "David S. Miller" Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00049.txt.bz2 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 * 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; + } +} + /* 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) \