From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4556 invoked by alias); 11 Jul 2002 18:42:56 -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 4547 invoked from network); 11 Jul 2002 18:42:53 -0000 Received: from unknown (HELO crack.them.org) (65.125.64.184) by sources.redhat.com with SMTP; 11 Jul 2002 18:42:53 -0000 Received: from dsl254-114-096.nyc1.dsl.speakeasy.net ([216.254.114.96] helo=nevyn.them.org) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 17Situ-0005VQ-00; Thu, 11 Jul 2002 13:42:50 -0500 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 17Sitw-00043X-00; Thu, 11 Jul 2002 14:42:52 -0400 Date: Thu, 11 Jul 2002 11:52:00 -0000 From: Daniel Jacobowitz To: Jim Ingham Cc: gdb-patches@sources.redhat.com Subject: Re: [patch] Fix to processing end of function stab in dbxread.c Message-ID: <20020711184252.GA29207@nevyn.them.org> Mail-Followup-To: Jim Ingham , gdb-patches@sources.redhat.com References: <20020711034619.GA22631@nevyn.them.org> <7B09F01E-94F9-11D6-AD3A-00039379E320@apple.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7B09F01E-94F9-11D6-AD3A-00039379E320@apple.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2002-07/txt/msg00236.txt.bz2 On Thu, Jul 11, 2002 at 11:10:28AM -0700, Jim Ingham wrote: > Daniel, > > We are talking about two different things here - I am talking about > converting the value in the blank FUN stab that marks the end of a > function to a read address, NOT correcting an SLINE stab. That may > seem confusing given that I was talking about linetables, so I will > give my previous explanation in a little more detail. Thanks for the excellent explanation. > Fred's fix was to emit a fake linetable entry - with linenumber 0, when > he sees the end of function stab. That way, in the linetable there is > just a region with no associated linenumbers from the end of the > function to 00031fd4. The problem was getting "the end of the > function" from the data in the null FUN stab. The value of the stab is > the offset from the beginning of the function. He was adding that to > function_start_offset which according to the comment in the file is NOT > the address of the last function on any system but Solaris. It is the > offset to the text section on other platforms, (which is clever, > because then it is the correct thing to use to relocate the addresses > in the SLINE entries on all platforms). But it is not an appropriate > thing to add to the offset from the end function stab. > > Note also that in the one other place where we get the real address > from the end fun stab (dbxread.c around 1726), we do: > > /* See if this is an end of function stab. */ > if (pst && nlist.n_type == N_FUN && *namestring == '\000') > { > CORE_ADDR valu; > > /* It's value is the size (in bytes) of the function for > function relative stabs, or the address of the function's > end for old style stabs. */ > valu = nlist.n_value + last_function_start; > if (TEXTHIGH (pst) == 0 || valu > TEXTHIGH (pst)) > TEXTHIGH (pst) = valu; > break; > } > > again using last_function_start, not function_start_offset. You've switched functions. That code is in read_dbx_symtab. There was no variable in process_one_symbol by that name until quite recently. They do have the same meaning however. That's what I meant about your archeology being wrong. The comment that function_start_offset is only correct for Solaris is also wrong; I can verify that it is correct on GNU/Linux. That's not your fault, though, the comments in dbxread.c range from mediocre to misleading. What comments referencing Solaris 2 (rather than referencing something about Sun's lame tools) often mean is "on SVR4-ish systems". I judge from your example that MacOSX has resolved addresses attached to N_SLINE stabs, but not in ending N_FUN stabs? GDB assumes that function_start_offset applies to both of them equally (and it will be zero if we expect both to be resolved). On GNU/Linux both N_SLINE and final N_FUN have offsets within the function. I suspect that on some Solaris variant N_SLINE and final N_FUN will both have resolved values. In that case using last_function_start + valu will put us well outside of the actual function, causing mayhem. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer