Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Debug info detection.
@ 2003-03-06 23:06 Michal Ludvig
  2003-03-07 15:25 ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Ludvig @ 2003-03-06 23:06 UTC (permalink / raw)
  To: GDB Patches

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

Hi all,
The attached patch adds new function cfi_have_unwind_info() that I'll 
use for detection, whether a given function has a dwarf2 unwind info 
(from .eh_frame or .debug_frame) or not. I'll use it in the upcomming 
x86_64_frame_p() to detect which set of unwind functions should be 
returned for a given frame.

OK to commit?

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz

[-- Attachment #2: cfi-haveinfo-1.diff --]
[-- Type: text/plain, Size: 1451 bytes --]

2003-03-06  Michal Ludvig  <mludvig@suse.cz>

	* dwarf2cfi.c (cfi_have_unwind_info): New function.
	* dwarf2cfi.h (cfi_have_unwind_info): New prototype.

Index: dwarf2cfi.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
retrieving revision 1.31
diff -u -p -r1.31 dwarf2cfi.c
--- dwarf2cfi.c	10 Feb 2003 11:50:20 -0000	1.31
+++ dwarf2cfi.c	6 Mar 2003 22:57:56 -0000
@@ -835,6 +835,12 @@ frame_state_for (struct context *context
 		       fde->data + fde->data_length, context, fs);
 }
 
+struct fde_unit *
+cfi_have_unwind_info (CORE_ADDR pc)
+{
+  return get_fde_for_addr (pc);
+}
+
 static void
 get_reg (char *reg, struct context *context, int regnum)
 {
Index: dwarf2cfi.h
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.h,v
retrieving revision 1.4
diff -u -p -r1.4 dwarf2cfi.h
--- dwarf2cfi.h	9 Dec 2002 02:04:16 -0000	1.4
+++ dwarf2cfi.h	6 Mar 2003 22:57:56 -0000
@@ -75,6 +75,9 @@ void cfi_init_extra_frame_info (int from
 /* Obtain return address of the frame.  */
 CORE_ADDR cfi_get_ra (struct frame_info *fi);
 
+/* Check if there is an unwind info for a given PC.  */
+struct fde_unit *cfi_have_unwind_info (CORE_ADDR pc);
+
 /* Find register number REGNUM relative to FRAME and put its
    (raw) contents in *RAW_BUFFER.  Set *OPTIMIZED if the variable
    was optimized out (and thus can't be fetched).  If the variable

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

* Re: [RFA] Debug info detection.
  2003-03-06 23:06 [RFA] Debug info detection Michal Ludvig
@ 2003-03-07 15:25 ` Andrew Cagney
  2003-03-07 15:48   ` Michal Ludvig
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2003-03-07 15:25 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: GDB Patches

> Hi all,
> The attached patch adds new function cfi_have_unwind_info() that I'll use for detection, whether a given function has a dwarf2 unwind info (from .eh_frame or .debug_frame) or not. I'll use it in the upcomming x86_64_frame_p() to detect which set of unwind functions should be returned for a given frame.

Your comment about x86_64_frame_p() makes me wonder if you're going in 
the right direction.

Looking at the d10v, you'll see:

   frame_unwind_append_predicate (gdbarch, d10v_frame_p);

For the x86-64, since it wants to also use dwarf2cfi and dwarf2eh, I'd 
expect to see something like:

   /* Try for a true CFI frame first.  If that fails, fall back to
      a .eh_frame info.  */
   frame_unwind_append_predicate (gdbarch, dwarf2cfi_frame_p);
   frame_unwind_append_predicate (gdbarch, dwarf2eh_frame_p);

   /* Finally, and as a last resort, use a prologue based unwinder.  */
   frame_unwind_append_predicate (gdbarch, x86_64_frame_p);

While I'm sure that splitting dwarf2cfi and dwarf2eh is logical, having 
separate x86_64_frame_p() that only implements traditional prologe based 
unwind is correct.

Can I suggest starting from the other end - a new file 
dwarf2cfi-frame.[hc] and then moving in from there?  The dwarf2expr.[hc] 
code was recently added and that was ment to superseed much of dwarf2cfi.c.

I'd also have a copy of cagney_offbyone-20030303-branch handy (you could 
even prototype the changes on it or a successor).  That contains a key 
fix that hasn't yet been committed to the mainline.

Andrew



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

* Re: [RFA] Debug info detection.
  2003-03-07 15:25 ` Andrew Cagney
@ 2003-03-07 15:48   ` Michal Ludvig
  2003-03-07 16:32     ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Ludvig @ 2003-03-07 15:48 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: GDB Patches

Andrew Cagney wrote:
>> Hi all,
>> The attached patch adds new function cfi_have_unwind_info() that I'll 
>> use for detection, whether a given function has a dwarf2 unwind info 
>> (from .eh_frame or .debug_frame) or not. I'll use it in the upcomming 
>> x86_64_frame_p() to detect which set of unwind functions should be 
>> returned for a given frame.
> 
> Your comment about x86_64_frame_p() makes me wonder if you're going in 
> the right direction.
> 
> Looking at the d10v, you'll see:
> 
>   frame_unwind_append_predicate (gdbarch, d10v_frame_p);
> 
> For the x86-64, since it wants to also use dwarf2cfi and dwarf2eh, I'd 
> expect to see something like:
> 
>   /* Try for a true CFI frame first.  If that fails, fall back to
>      a .eh_frame info.  */
>   frame_unwind_append_predicate (gdbarch, dwarf2cfi_frame_p);
>   frame_unwind_append_predicate (gdbarch, dwarf2eh_frame_p);
> 
>   /* Finally, and as a last resort, use a prologue based unwinder.  */
>   frame_unwind_append_predicate (gdbarch, x86_64_frame_p);

For now I have...

const struct frame_unwind *
x86_64_frame_p (CORE_ADDR pc)
{
   struct frame_unwind *unwind_cfi = NULL;
   struct frame_unwind *unwind_asm = &x86_64_asm_frame_unwind;
   struct frame_unwind *unwind_sigtramp = &x86_64_sigtramp_frame_unwind;
   char *name;

   find_pc_partial_function (pc, &name, NULL, NULL);
   if (gdbarch_pc_in_sigtramp (current_gdbarch, pc, name))
     return unwind_sigtramp;
   else if (cfi_have_unwind_info (pc))
     return unwind_cfi;   /* Returns NULL here...  */
   else
     return unwind_asm;
}

I.e. I'll handle sigtramps and non-CFI functions via the new way and 
fall back to old methods for CFI functions. That's because the CFI 
unwinder works quite well and I don't need to change it now, but 
backtrace through sigtramps doesn't work almost at all, and backtrace 
from non-cfi functions works only with my uncommitted hack. Both of 
these cases must be solved.

> While I'm sure that splitting dwarf2cfi and dwarf2eh is logical, having 

Why should we have different ways for unwinding with information taken 
from .debug_frame (is that what dwarf2cfi should be for?) and from 
.eh_frame (dwarf2eh)? Both of these sections provide the same data and 
the only different bits are in their parsing...

> separate x86_64_frame_p() that only implements traditional prologe based 
> unwind is correct.
> 
> Can I suggest starting from the other end - a new file 
> dwarf2cfi-frame.[hc] and then moving in from there?  The dwarf2expr.[hc] 
> code was recently added and that was ment to superseed much of dwarf2cfi.c.

As I said higher - I'm doing this to solve backtrace for non-cfi frames. 
   Rewriting the CFI engine is not my priority right now.

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz


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

* Re: [RFA] Debug info detection.
  2003-03-07 15:48   ` Michal Ludvig
@ 2003-03-07 16:32     ` Andrew Cagney
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2003-03-07 16:32 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: GDB Patches

> For now I have...
> 
> const struct frame_unwind *
> x86_64_frame_p (CORE_ADDR pc)
> {
>   struct frame_unwind *unwind_cfi = NULL;
>   struct frame_unwind *unwind_asm = &x86_64_asm_frame_unwind;
>   struct frame_unwind *unwind_sigtramp = &x86_64_sigtramp_frame_unwind;
>   char *name;
> 
>   find_pc_partial_function (pc, &name, NULL, NULL);
>   if (gdbarch_pc_in_sigtramp (current_gdbarch, pc, name))
>     return unwind_sigtramp;
>   else if (cfi_have_unwind_info (pc))
>     return unwind_cfi;   /* Returns NULL here...  */
>   else
>     return unwind_asm;
> }

The function x86-64-tdep.c:x86_64_frame_p() should contain:
	return x86_64_unwind;

The file/function dwarf2cfi-frame.c:dwarf2cfi_frame_p() should contain:
	if (cfi_have_unwind_info (pc))
	     return dwarf2cfi_unwind;

(Assuming sigtramps are os specific) The file/function 
x86-64-linux-tdep.c:x86_64_linux_sigtramp_frame_p() should contain:
 >   if (gdbarch_pc_in_sigtramp (current_gdbarch, pc, name))
 >     return x86_64_linux_sigtramp_unwind;

Andrew



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

end of thread, other threads:[~2003-03-07 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 23:06 [RFA] Debug info detection Michal Ludvig
2003-03-07 15:25 ` Andrew Cagney
2003-03-07 15:48   ` Michal Ludvig
2003-03-07 16:32     ` Andrew Cagney

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