From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22620 invoked by alias); 26 Oct 2007 23:21:34 -0000 Received: (qmail 22610 invoked by uid 22791); 26 Oct 2007 23:21:33 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 26 Oct 2007 23:21:31 +0000 Received: (qmail 29068 invoked from network); 26 Oct 2007 23:21:29 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Oct 2007 23:21:29 -0000 To: gdb-patches@sourceware.org Subject: RFC: tracepoints: abstract frame base finding in dwarf2loc.c From: Jim Blandy Date: Fri, 26 Oct 2007 23:42:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00729.txt.bz2 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 * 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