From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11855 invoked by alias); 3 Nov 2004 22:24:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11827 invoked from network); 3 Nov 2004 22:24:19 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 3 Nov 2004 22:24:19 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iA3MO9C0030033 for ; Wed, 3 Nov 2004 17:24:14 -0500 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iA3MO9r31868; Wed, 3 Nov 2004 17:24:09 -0500 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 316A5129D8C; Wed, 3 Nov 2004 17:24:04 -0500 (EST) Message-ID: <41895A80.1090500@gnu.org> Date: Wed, 03 Nov 2004 22:24:00 -0000 From: Andrew Cagney User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) MIME-Version: 1.0 To: Randolph Chung Cc: gdb-patches@sources.redhat.com Subject: Re: [patch/hppa/rfa] unwind fix for functions with no debug info References: <20041103174449.GD4249@tausq.org> In-Reply-To: <20041103174449.GD4249@tausq.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-11/txt/msg00049.txt.bz2 Randolph Chung wrote: > The attached patch fixes a problem reported by Dave Anglin and others. > When compiled without debug information, static functions have no symbol > table entry in gdb. In this case, frame_func_unwind returns the starting > address of the previously visible function. Using that to do unwinding > causes all sorts of brokeness.... (frame_func_unwind can also return zero.) > On hppa, each properly defined function has an unwind record which gives > the starting and ending address of the function. We can use that to > do unwinding more properly. > > Tested on hppa-linux with no regressions. > > Ok to apply? > > randolph > > 2004-11-03 Randolph Chung > > * hppa-tdep.c (hppa_frame_cache): Avoid using frame_func_unwind () to > locate the beginning of the function. When objects are compiled without > debug symbols, frame_func_unwind can return the wrong function. We > can do better than that by using unwind records. > (hppa_frame_this_id): Likewise. Ok for 6.3 and mainline with a comment/change log tweak: The convention is for the ChangeLog to record what was changed while the code records why it was changed. Consequently, the ChangeLog should read something like: hppa-tdep.c (hppa_frame_cache): Use frame_pc_unwind instead of frame_func_unwind () to locate the unwind entry. and the the corresponding code gets the rationale for doing things the current way: /* Avoid using frame_func_unwind () to locate the beginning of the function. When objects are compiled without debug symbols, frame_func_unwind can return the wrong function. We can do better than that by using unwind records. */ (the GNU coding standard discusses this further) Andrew > Index: hppa-tdep.c > =================================================================== > RCS file: /cvs/src/src/gdb/hppa-tdep.c,v > retrieving revision 1.175 > diff -u -p -r1.175 hppa-tdep.c > --- hppa-tdep.c 31 Oct 2004 21:09:28 -0000 1.175 > +++ hppa-tdep.c 3 Nov 2004 16:18:40 -0000 > @@ -1580,7 +1580,7 @@ hppa_frame_cache (struct frame_info *nex > cache->saved_regs = trad_frame_alloc_saved_regs (next_frame); > > /* Yow! */ > - u = find_unwind_entry (frame_func_unwind (next_frame)); > + u = find_unwind_entry (frame_pc_unwind (next_frame)); > if (!u) > { > if (hppa_debug) > @@ -1630,7 +1630,7 @@ hppa_frame_cache (struct frame_info *nex > symbol information. hppa_skip_prologue also bounds the returned > pc by the passed in pc, so it will not return a pc in the next > function. */ > - prologue_end = hppa_skip_prologue (frame_func_unwind (next_frame)); > + prologue_end = hppa_skip_prologue (u->region_start); > end_pc = frame_pc_unwind (next_frame); > > if (prologue_end != 0 && end_pc > prologue_end) > @@ -1638,7 +1638,7 @@ hppa_frame_cache (struct frame_info *nex > > frame_size = 0; > > - for (pc = frame_func_unwind (next_frame); > + for (pc = u->region_start; > ((saved_gr_mask || saved_fr_mask > || looking_for_sp || looking_for_rp > || frame_size < (u->Total_frame_size << 3)) > @@ -1881,8 +1881,14 @@ static void > hppa_frame_this_id (struct frame_info *next_frame, void **this_cache, > struct frame_id *this_id) > { > - struct hppa_frame_cache *info = hppa_frame_cache (next_frame, this_cache); > - (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame)); > + struct hppa_frame_cache *info; > + CORE_ADDR pc = frame_pc_unwind (next_frame); > + struct unwind_table_entry *u; > + > + info = hppa_frame_cache (next_frame, this_cache); > + u = find_unwind_entry (pc); > + > + (*this_id) = frame_id_build (info->base, u->region_start); > } > > static void