[RFC] : append dwarf2 unwinder on sparc

Message ID 7E528836-0667-4A7E-B902-5F17D88F9221@adacore.com
State New, archived
Headers

Commit Message

Tristan Gingold July 1, 2014, 3:17 p.m. UTC
  Hello,

as gcc 4.9 has switched to dwarf-4 by default, it now emits DW_OP_call_frame_cfa.
But gdb is able to handle it only if the frame was unwinded by dwarf2
(See dwarf2-frame.c:dwarf2_frame_cfa)

Is there any reason not to append the dwarf2 unwinder on sparc ?

Tristan.

	* sparc-tdep.c (sparc32_gdbarch_init): Call dwarf2_append_unwinders.
  

Comments

Mark Kettenis July 1, 2014, 4 p.m. UTC | #1
> From: Tristan Gingold <gingold@adacore.com>
> Date: Tue, 1 Jul 2014 17:17:34 +0200
> 
> Hello,
> 
> as gcc 4.9 has switched to dwarf-4 by default, it now emits DW_OP_call_frame_cfa.
> But gdb is able to handle it only if the frame was unwinded by dwarf2
> (See dwarf2-frame.c:dwarf2_frame_cfa)
> 
> Is there any reason not to append the dwarf2 unwinder on sparc ?

Yes.  The dwarf2 unwinder doesn't work properly with StackGhost.  For
Linux we append the dwarf2 unwinder in the OS/ABI-specific
initialization function.

On SPARC there is not much ambiuity about the call frame address.
Perhaps it is time to lift the restriction in dwarf2_frame_cfa()?

> 	* sparc-tdep.c (sparc32_gdbarch_init): Call dwarf2_append_unwinders.
> 
> diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
> index e7b3090..5b8ad38 100644
> --- a/gdb/sparc-tdep.c
> +++ b/gdb/sparc-tdep.c
> @@ -1739,6 +1739,11 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>    /* Hook in ABI-specific overrides, if they have been registered.  */
>    gdbarch_init_osabi (info, gdbarch);
>  
> +  /* Hook in the DWARF CFI frame unwinder.  This unwinder is appended
> +     to the list before the prologue-based unwinders, so that DWARF
> +     CFI info will be used if it is available.  */
> +  dwarf2_append_unwinders (gdbarch);
> +
>    frame_unwind_append_unwinder (gdbarch, &sparc32_frame_unwind);
>  
>    /* If we have register sets, enable the generic core file support.  */
>
  
Tristan Gingold July 2, 2014, 7:51 a.m. UTC | #2
On 01 Jul 2014, at 18:00, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:

>> From: Tristan Gingold <gingold@adacore.com>
>> Date: Tue, 1 Jul 2014 17:17:34 +0200
>> 
>> Hello,
>> 
>> as gcc 4.9 has switched to dwarf-4 by default, it now emits DW_OP_call_frame_cfa.
>> But gdb is able to handle it only if the frame was unwinded by dwarf2
>> (See dwarf2-frame.c:dwarf2_frame_cfa)
>> 
>> Is there any reason not to append the dwarf2 unwinder on sparc ?
> 
> Yes.  The dwarf2 unwinder doesn't work properly with StackGhost.  For
> Linux we append the dwarf2 unwinder in the OS/ABI-specific
> initialization function.

I see.  My target was bareboard.

> On SPARC there is not much ambiuity about the call frame address.
> Perhaps it is time to lift the restriction in dwarf2_frame_cfa()?

I suppose this means adding a new method to struct frame_unwind ?
Not very exciting :-(

Thanks,
Tristan.
  

Patch

diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index e7b3090..5b8ad38 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1739,6 +1739,11 @@  sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
+  /* Hook in the DWARF CFI frame unwinder.  This unwinder is appended
+     to the list before the prologue-based unwinders, so that DWARF
+     CFI info will be used if it is available.  */
+  dwarf2_append_unwinders (gdbarch);
+
   frame_unwind_append_unwinder (gdbarch, &sparc32_frame_unwind);
 
   /* If we have register sets, enable the generic core file support.  */