From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29633 invoked by alias); 11 May 2009 19:27:28 -0000 Received: (qmail 29580 invoked by uid 22791); 11 May 2009 19:27:27 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 May 2009 19:27:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 834802BAC22; Mon, 11 May 2009 15:27:20 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Y0Ti+mQrZzbH; Mon, 11 May 2009 15:27:20 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 1944C2BAAF2; Mon, 11 May 2009 15:27:20 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 637AFF5901; Mon, 11 May 2009 12:27:09 -0700 (PDT) Date: Mon, 11 May 2009 19:27:00 -0000 From: Joel Brobecker To: Eli Zaretskii Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Fix "break foo" when `foo's prologue ends before line table Message-ID: <20090511192709.GG14773@adacore.com> References: <83skjebbef.fsf@gnu.org> <20090511125644.GD14773@adacore.com> <83zldjxzzr.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83zldjxzzr.fsf@gnu.org> User-Agent: Mutt/1.5.18 (2008-05-17) 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: 2009-05/txt/msg00224.txt.bz2 > > I am wondering if this looping over all PSYMTAB and SYMTABs is really > > necessary. Is the symtab associated to your symbol not sufficient? > > I must admit that I have only a very basic knowledge of symbol tables. > In particular, I'm only vaguely familiar with the possible intricacies > of symtabs in the presence of included files and such likes. I simply > saw that find_line_symtab, which does a similar job, loops like that, > so I used the same paradigm. I think that the situation in this case is a little bit different, since we're using the symtab coming from the symbol itself. You'd expect that the associated linetable would be in that symtab... I'm always reluctant to introduce code I don't understand, and usually leave it out until I see a bug - that's why I was asking. Have you tried without this part? > > Also, instead of returning the line whose number is the smallest, > > I would return the smallest PC, as we're trying to skip the minimum > > before inserting the breakpoint. > > But the smallest PC could come from some source line that is further > down in the function's body, source-wise, if the compiler rearranged > code, couldn't it? What I'm trying to do is find the first source > line of the body of the function, not the first PC of the body. I > think the former is more in line with the semantics of "break FOO". I would disagree with that. Imagine that you have function like this: foo () { a (); b (); } If for some reason the optimizer rearanged the code like this: foo () { b (); a (); } Do you really want "break foo" to break on the line where a () is called? The problem with that is that, by the time we reach the breakpoint, b would have already been called. My expection is that the debugger should find the first line of code, not the line whose number is the smallest. In other words, when I break on a function, I expect that by the time I reach that function breakpoint, none of the real code has been executed yet - I want to debug the function :-). > > This means that your iteration on the line table can stop as soon as > > you've found a non-zero line that's inside your function address > > range. > > Is it guaranteed that the line table is always sorted by PC? Yep: /* The order of entries in the linetable is significant. They should be sorted by increasing values of the pc field. -- Joel