From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12530 invoked by alias); 27 Oct 2007 08:17:36 -0000 Received: (qmail 12518 invoked by uid 22791); 27 Oct 2007 08:17:35 -0000 X-Spam-Check-By: sourceware.org Received: from 216-129-118-140.cust.layer42.net (HELO bluesmobile.specifix.com) (216.129.118.140) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 27 Oct 2007 08:17:33 +0000 Received: from [127.0.0.1] (bluesmobile.specifix.com [216.129.118.140]) by bluesmobile.specifix.com (Postfix) with ESMTP id DAEC83B748; Sat, 27 Oct 2007 01:03:01 -0700 (PDT) Subject: Re: RFC: tracepoints: abstract frame base finding in dwarf2loc.c From: Michael Snyder To: Jim Blandy Cc: gdb-patches@sourceware.org In-Reply-To: References: Content-Type: text/plain Date: Sat, 27 Oct 2007 08:19:00 -0000 Message-Id: <1193472739.16917.104.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-4.fc7) Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00738.txt.bz2 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 > > * 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