From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15192 invoked by alias); 5 Apr 2006 09:11:42 -0000 Received: (qmail 15183 invoked by uid 22791); 5 Apr 2006 09:11:41 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-vbr9.xs4all.nl (HELO smtp-vbr9.xs4all.nl) (194.109.24.29) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Apr 2006 09:11:38 +0000 Received: from webmail.xs4all.nl (dovemail5.xs4all.nl [194.109.26.7]) by smtp-vbr9.xs4all.nl (8.13.6/8.13.6) with ESMTP id k359B5Um007220; Wed, 5 Apr 2006 11:11:05 +0200 (CEST) (envelope-from mark.kettenis@xs4all.nl) Received: from 192.87.1.22 (SquirrelMail authenticated user sibelius) by webmail.xs4all.nl with HTTP; Wed, 5 Apr 2006 11:11:05 +0200 (CEST) Message-ID: <11768.192.87.1.22.1144228265.squirrel@webmail.xs4all.nl> In-Reply-To: <20060404.202940.38078716.davem@davemloft.net> References: <20060404.202940.38078716.davem@davemloft.net> Date: Wed, 05 Apr 2006 09:11:00 -0000 Subject: Re: [PATCH]: Setup sparc32 to support dwarf2 unwind sniffer From: "Mark Kettenis" To: "David S. Miller" Cc: gdb-patches@sources.redhat.com User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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/msg00052.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. Perhaps we should try to address those issues. I never went through the trouble of making the sparc and sparc64 prologue analyzers any smarter, because I never encountered any code that made it fail. This is probably because OpenBSD/sparc64 uses GCC 3.3.5 (and OpenBSD/sparc uses an even older compiler). If you can post some disaambly of (real-life) prologues that the current unwinder doesn't handle, I'll happiliy turn them into testcases and try to improve the analyzer. > Ok to apply? Yes, thanks! I didn't do this before, because OpenBSD/sparc still uses stabs, so I had no way to test this. Don't hesitate to enable the dwarf2 unwinder on Linux. Marl > > 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) \ >