From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24625 invoked by alias); 11 May 2009 18:21:08 -0000 Received: (qmail 24615 invoked by uid 22791); 11 May 2009 18:21:07 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_JMF_BL,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout4.012.net.il (HELO mtaout3.012.net.il) (84.95.2.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 May 2009 18:20:58 +0000 Received: from conversion-daemon.i_mtaout3.012.net.il by i_mtaout3.012.net.il (HyperSendmail v2004.12) id <0KJH00E00RB8T400@i_mtaout3.012.net.il> for gdb-patches@sourceware.org; Mon, 11 May 2009 21:20:54 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.228.73.80]) by i_mtaout3.012.net.il (HyperSendmail v2004.12) with ESMTPA id <0KJH00GYTSATVUP0@i_mtaout3.012.net.il>; Mon, 11 May 2009 21:20:54 +0300 (IDT) Date: Mon, 11 May 2009 18:21:00 -0000 From: Eli Zaretskii Subject: Re: [RFA] Fix "break foo" when `foo's prologue ends before line table In-reply-to: <20090511125644.GD14773@adacore.com> To: Joel Brobecker Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83zldjxzzr.fsf@gnu.org> References: <83skjebbef.fsf@gnu.org> <20090511125644.GD14773@adacore.com> 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: 2009-05/txt/msg00222.txt.bz2 > Date: Mon, 11 May 2009 14:56:44 +0200 > From: Joel Brobecker > Cc: gdb-patches@sourceware.org > > Regardless of that, however, we should really look at what > "break FUNCTION" is supposed to be doing. And looking at the doc, > it says: ``Specifies the line that begins the body of the function'' > (this matches what I thought it should be doing intuitively). > So, regardless of what GDB should be doing in terms of prologue > analysis, I think we should still try to find the first line > as you're doing in your patch. Thanks for the feedback. That's two in favor, none against. ;-) > > + ALL_PSYMTABS (objfile, p) > > + { > > + if (FILENAME_CMP (symtab->filename, p->filename) != 0) > > + continue; > > + PSYMTAB_TO_SYMTAB (p); > > + } > > + > > + /* Loop over all symtabs for the function's file, looking for an > > + entry in a lineinfo table whose PC is in the range > > + [FUNC_START..FUNC_END] and whose line number is the smallest. */ > > + ALL_SYMTABS (objfile, s) > > 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. > 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". > 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?