Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: tracepoints: abstract frame base finding in dwarf2loc.c
@ 2007-10-26 23:42 Jim Blandy
  2007-10-27  8:19 ` Michael Snyder
  2007-11-04 17:22 ` Ulrich Weigand
  0 siblings, 2 replies; 4+ messages in thread
From: Jim Blandy @ 2007-10-26 23:42 UTC (permalink / raw)
  To: gdb-patches


Here's a change to dwarf2loc.c that pulls out the guts of the code to
find a function symbol's frame base expression into its own function.
We'll also use this function to find frame bases for variables we're
collecting at a tracepoint, in a later patch.  There should be no
change in behavior.  Tested on i386 Linux with no regressions.

Okay to commit?

gdb/ChangeLog:
2007-10-25  Jim Blandy  <jimb@codesourcery.com>

	* dwarf2loc.c (symbol_frame_base): New function.
	(dwarf_expr_frame_base): Use it.

diff -r c9d900af6ded -r 3e791181e789 gdb/dwarf2loc.c
--- a/gdb/dwarf2loc.c	Thu Oct 25 12:48:34 2007 -0700
+++ b/gdb/dwarf2loc.c	Thu Oct 25 14:08:00 2007 -0700
@@ -132,6 +132,32 @@ dwarf_expr_read_mem (void *baton, gdb_by
   read_memory (addr, buf, len);
 }
 
+/* Find the frame base expression for PC, within FUNCTION.
+   Set *START to a pointer to it; set *LENGTH to its length.  */
+static void
+symbol_frame_base (struct symbol *function, CORE_ADDR pc,
+                   gdb_byte **start, size_t *length)
+{
+  if (SYMBOL_OPS (function) == &dwarf2_loclist_funcs)
+    {
+      struct dwarf2_loclist_baton *symbaton;
+
+      symbaton = SYMBOL_LOCATION_BATON (function);
+      *start = find_location_expression (symbaton, length, pc);
+    }
+  else
+    {
+      struct dwarf2_locexpr_baton *symbaton;
+      symbaton = SYMBOL_LOCATION_BATON (function);
+      *length = symbaton->size;
+      *start = symbaton->data;
+    }
+
+  if (*start == NULL)
+    error (_("Could not find the frame base for \"%s\"."),
+	   SYMBOL_NATURAL_NAME (function));
+}
+
 /* Using the frame specified in BATON, find the location expression
    describing the frame base.  Return a pointer to it in START and
    its length in LENGTH.  */
@@ -141,36 +167,17 @@ dwarf_expr_frame_base (void *baton, gdb_
   /* FIXME: cagney/2003-03-26: This code should be using
      get_frame_base_address(), and then implement a dwarf2 specific
      this_base method.  */
-  struct symbol *framefunc;
   struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
-
-  framefunc = get_frame_function (debaton->frame);
+  struct frame_info *frame = debaton->frame;
+  struct symbol *framefunc = get_frame_function (frame);
+  CORE_ADDR pc = get_frame_address_in_block (frame);
 
   /* If we found a frame-relative symbol then it was certainly within
      some function associated with a frame. If we can't find the frame,
      something has gone wrong.  */
   gdb_assert (framefunc != NULL);
 
-  if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs)
-    {
-      struct dwarf2_loclist_baton *symbaton;
-      struct frame_info *frame = debaton->frame;
-
-      symbaton = SYMBOL_LOCATION_BATON (framefunc);
-      *start = find_location_expression (symbaton, length,
-					 get_frame_address_in_block (frame));
-    }
-  else
-    {
-      struct dwarf2_locexpr_baton *symbaton;
-      symbaton = SYMBOL_LOCATION_BATON (framefunc);
-      *length = symbaton->size;
-      *start = symbaton->data;
-    }
-
-  if (*start == NULL)
-    error (_("Could not find the frame base for \"%s\"."),
-	   SYMBOL_NATURAL_NAME (framefunc));
+  symbol_frame_base (framefunc, pc, start, length);
 }
 
 /* Using the objfile specified in BATON, find the address for the


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

* Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c
  2007-10-26 23:42 RFC: tracepoints: abstract frame base finding in dwarf2loc.c Jim Blandy
@ 2007-10-27  8:19 ` Michael Snyder
  2007-11-04 17:22 ` Ulrich Weigand
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Snyder @ 2007-10-27  8:19 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

On Fri, 2007-10-26 at 16:21 -0700, Jim Blandy wrote:
> Here's a change to dwarf2loc.c that pulls out the guts of the code to
> find a function symbol's frame base expression into its own function.
> We'll also use this function to find frame bases for variables we're
> collecting at a tracepoint, in a later patch.  There should be no
> change in behavior.  Tested on i386 Linux with no regressions.
> 
> Okay to commit?

I'm no dwarf expert, but it looks ok to me...

> 
> gdb/ChangeLog:
> 2007-10-25  Jim Blandy  <jimb@codesourcery.com>
> 
> 	* dwarf2loc.c (symbol_frame_base): New function.
> 	(dwarf_expr_frame_base): Use it.
> 
> diff -r c9d900af6ded -r 3e791181e789 gdb/dwarf2loc.c
> --- a/gdb/dwarf2loc.c	Thu Oct 25 12:48:34 2007 -0700
> +++ b/gdb/dwarf2loc.c	Thu Oct 25 14:08:00 2007 -0700
> @@ -132,6 +132,32 @@ dwarf_expr_read_mem (void *baton, gdb_by
>    read_memory (addr, buf, len);
>  }
>  
> +/* Find the frame base expression for PC, within FUNCTION.
> +   Set *START to a pointer to it; set *LENGTH to its length.  */
> +static void
> +symbol_frame_base (struct symbol *function, CORE_ADDR pc,
> +                   gdb_byte **start, size_t *length)
> +{
> +  if (SYMBOL_OPS (function) == &dwarf2_loclist_funcs)
> +    {
> +      struct dwarf2_loclist_baton *symbaton;
> +
> +      symbaton = SYMBOL_LOCATION_BATON (function);
> +      *start = find_location_expression (symbaton, length, pc);
> +    }
> +  else
> +    {
> +      struct dwarf2_locexpr_baton *symbaton;
> +      symbaton = SYMBOL_LOCATION_BATON (function);
> +      *length = symbaton->size;
> +      *start = symbaton->data;
> +    }
> +
> +  if (*start == NULL)
> +    error (_("Could not find the frame base for \"%s\"."),
> +	   SYMBOL_NATURAL_NAME (function));
> +}
> +
>  /* Using the frame specified in BATON, find the location expression
>     describing the frame base.  Return a pointer to it in START and
>     its length in LENGTH.  */
> @@ -141,36 +167,17 @@ dwarf_expr_frame_base (void *baton, gdb_
>    /* FIXME: cagney/2003-03-26: This code should be using
>       get_frame_base_address(), and then implement a dwarf2 specific
>       this_base method.  */
> -  struct symbol *framefunc;
>    struct dwarf_expr_baton *debaton = (struct dwarf_expr_baton *) baton;
> -
> -  framefunc = get_frame_function (debaton->frame);
> +  struct frame_info *frame = debaton->frame;
> +  struct symbol *framefunc = get_frame_function (frame);
> +  CORE_ADDR pc = get_frame_address_in_block (frame);
>  
>    /* If we found a frame-relative symbol then it was certainly within
>       some function associated with a frame. If we can't find the frame,
>       something has gone wrong.  */
>    gdb_assert (framefunc != NULL);
>  
> -  if (SYMBOL_OPS (framefunc) == &dwarf2_loclist_funcs)
> -    {
> -      struct dwarf2_loclist_baton *symbaton;
> -      struct frame_info *frame = debaton->frame;
> -
> -      symbaton = SYMBOL_LOCATION_BATON (framefunc);
> -      *start = find_location_expression (symbaton, length,
> -					 get_frame_address_in_block (frame));
> -    }
> -  else
> -    {
> -      struct dwarf2_locexpr_baton *symbaton;
> -      symbaton = SYMBOL_LOCATION_BATON (framefunc);
> -      *length = symbaton->size;
> -      *start = symbaton->data;
> -    }
> -
> -  if (*start == NULL)
> -    error (_("Could not find the frame base for \"%s\"."),
> -	   SYMBOL_NATURAL_NAME (framefunc));
> +  symbol_frame_base (framefunc, pc, start, length);
>  }
>  
>  /* Using the objfile specified in BATON, find the address for the


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

* Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c
  2007-10-26 23:42 RFC: tracepoints: abstract frame base finding in dwarf2loc.c Jim Blandy
  2007-10-27  8:19 ` Michael Snyder
@ 2007-11-04 17:22 ` Ulrich Weigand
  2007-11-05 16:41   ` Jim Blandy
  1 sibling, 1 reply; 4+ messages in thread
From: Ulrich Weigand @ 2007-11-04 17:22 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

Jim Blandy wrote:

> Here's a change to dwarf2loc.c that pulls out the guts of the code to
> find a function symbol's frame base expression into its own function.
> We'll also use this function to find frame bases for variables we're
> collecting at a tracepoint, in a later patch.  There should be no
> change in behavior.  Tested on i386 Linux with no regressions.

Nice; I assume you'll be using that to handle DW_OP_fbreg properly and
get rid of the gdbarch_virtual_frame_pointer call in tracepoint_var_ref?

> +/* Find the frame base expression for PC, within FUNCTION.
> +   Set *START to a pointer to it; set *LENGTH to its length.  */
> +static void
> +symbol_frame_base (struct symbol *function, CORE_ADDR pc,
> +                   gdb_byte **start, size_t *length)

I think the FUNCTION is redundant here, it can be recovered
via find_pc_function (pc).  This should in all cases have the
same result as the get_frame_function (frame) call below.

> +  struct symbol *framefunc = get_frame_function (frame);
> +  CORE_ADDR pc = get_frame_address_in_block (frame);

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

* Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c
  2007-11-04 17:22 ` Ulrich Weigand
@ 2007-11-05 16:41   ` Jim Blandy
  0 siblings, 0 replies; 4+ messages in thread
From: Jim Blandy @ 2007-11-05 16:41 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches


"Ulrich Weigand" <uweigand at de.ibm.com> writes:
> Jim Blandy wrote:
>
>> Here's a change to dwarf2loc.c that pulls out the guts of the code to
>> find a function symbol's frame base expression into its own function.
>> We'll also use this function to find frame bases for variables we're
>> collecting at a tracepoint, in a later patch.  There should be no
>> change in behavior.  Tested on i386 Linux with no regressions.
>
> Nice; I assume you'll be using that to handle DW_OP_fbreg properly and
> get rid of the gdbarch_virtual_frame_pointer call in tracepoint_var_ref?

Yes, exactly!

>> +/* Find the frame base expression for PC, within FUNCTION.
>> +   Set *START to a pointer to it; set *LENGTH to its length.  */
>> +static void
>> +symbol_frame_base (struct symbol *function, CORE_ADDR pc,
>> +                   gdb_byte **start, size_t *length)
>
> I think the FUNCTION is redundant here, it can be recovered
> via find_pc_function (pc).  This should in all cases have the
> same result as the get_frame_function (frame) call below.
>
>> +  struct symbol *framefunc = get_frame_function (frame);
>> +  CORE_ADDR pc = get_frame_address_in_block (frame);

Yes, I think you're right.  I had been confused about whether the
pc-decrementing magic necessary for find_pc_function to get the right
answer would always happen correctly, but:
- in the dwarf_expr_frame_base case, the PC we'd supply comes from
  get_frame_address_in_block, which does the magic, and
- in the tracepoint case, the address is supplied directly by the
  user, so the magic isn't required.

Thanks!


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

end of thread, other threads:[~2007-11-05 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 23:42 RFC: tracepoints: abstract frame base finding in dwarf2loc.c Jim Blandy
2007-10-27  8:19 ` Michael Snyder
2007-11-04 17:22 ` Ulrich Weigand
2007-11-05 16:41   ` Jim Blandy

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