From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28404 invoked by alias); 29 Sep 2009 22:20:34 -0000 Received: (qmail 28384 invoked by uid 22791); 29 Sep 2009 22:20:33 -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; Tue, 29 Sep 2009 22:20:29 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 843042BAB49; Tue, 29 Sep 2009 18:20:27 -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 9NQdtRGo0HC4; Tue, 29 Sep 2009 18:20:27 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 4B60B2BAB45; Tue, 29 Sep 2009 18:20:27 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 7FBB3F593D; Tue, 29 Sep 2009 15:20:24 -0700 (PDT) Date: Tue, 29 Sep 2009 22:20:00 -0000 From: Joel Brobecker To: S?bastien Granjoux Cc: gdb-patches@sourceware.org Subject: Re: Fix breakpoints when several source files have the same name Message-ID: <20090929222024.GH6362@adacore.com> References: <4A1926A2.1000806@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A1926A2.1000806@free.fr> 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-09/txt/msg00938.txt.bz2 Sebastien, Really really sorry for taking so long before reviewing this patch. Please don't hesitate to send pings on the list to remind us of a patch that is sitting unreviewed for more than a week or two. > There is in gdb 6.8 a new bug that makes breakpoints inserted at the > wrong place when a program has several files with the same base name (in > different directories). [...] > I have found it using the mi interface but it appears in the same way > with the other commands. For the record, here is how I reproduced the issue on my side: I have two small files a/foo.c and b/foo.c, each containing an empty function called foo_a and foo_b (resp). Then a file main.c: extern void foo_a (void); extern void foo_b (void); int main (void) { foo_a (); foo_b (); return 0; } To build, I did: % (cd a && gcc -c -g foo.c) % (cd b && gcc -c -g foo.c) % gcc -o main main.c a/foo.o b/foo.o The important part here, is to compile both foo.c files from within the directory where these files are located, at least with GCC. Trying to break on either location, using the filename's fullname, results in 2 breakpoints being inserted instead of just one: (gdb) b /t.a/brobecke/ex/break/a/foo.c:3 Breakpoint 1 at 0x400480: file foo.c, line 4. (2 locations) (gdb) b /t.a/brobecke/ex/break/b/foo.c:3 Note: breakpoint 1 also set at pc 0x400480. Note: breakpoint 1 also set at pc 0x400478. Breakpoint 2 at 0x400480: file foo.c, line 4. (2 locations) > 2009-05-24 Sebastien Granjoux > > PR mi/9583: > * symtab.c (find_line_symtab): Use full filename if available My concern with your approach is with performance: symtab_to_fullname and psymtab_to_fullname are actually a bit expensive to call, as they involve locating the file on the local host disk, taking into account debugging info as well as the source path (see the "dir" command) and then opening/closing that file if found. How about changing the patch to only do the fullname matching iff (if and only iff) the simple filename matches first. In other words, compute the symtab/psymtab fullname only if the filename matches. -- Joel