This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c
- From: Michael Snyder <msnyder at specifix dot com>
- To: Jim Blandy <jimb at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sat, 27 Oct 2007 01:12:19 -0700
- Subject: Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c
- References: <m3ir4tbgxz.fsf@codesourcery.com>
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