From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12327 invoked by alias); 10 Aug 2009 18:09:55 -0000 Received: (qmail 12316 invoked by uid 22791); 10 Aug 2009 18:09:54 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Aug 2009 18:09:42 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MaZJQ-0005TN-SC for gdb-patches@sources.redhat.com; Mon, 10 Aug 2009 18:09:36 +0000 Received: from entropy.qnx.com ([209.226.137.107]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Aug 2009 18:09:36 +0000 Received: from aristovski by entropy.qnx.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 10 Aug 2009 18:09:36 +0000 To: gdb-patches@sources.redhat.com From: Aleksandar Ristovski Subject: [patch] symfile find_separate_debug_file Date: Mon, 10 Aug 2009 18:58:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060806060109040106080302" User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) 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-08/txt/msg00147.txt.bz2 This is a multi-part message in MIME format. --------------060806060109040106080302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 794 Hello, I run into this accidentally. When debugging a shared object with embedded symbol file name (.gnu_debuglink section), we made an assumption that objfile would always have full path. However, if shared object was opened using base name only, we will end up with an objfile with the same name. By looking at allocate_objfile which generates the name for an objfile, it is clear that there could be any kind of path including full path, relative path or file name only. The patch checks for such situation and instead of gdb_assert-ing, creates current directory prefix. Tested by running the case manually. Thanks, -- Aleksandar Ristovski QNX Software Systems ChangeLog: * symfile.c (find_separate_debug_file): Fix the case when objfile has only basename as its name. --------------060806060109040106080302 Content-Type: text/x-patch; name="symfile-20090810.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="symfile-20090810.diff" Content-length: 1126 Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.240 diff -u -p -r1.240 symfile.c --- gdb/symfile.c 3 Aug 2009 17:00:34 -0000 1.240 +++ gdb/symfile.c 10 Aug 2009 17:56:24 -0000 @@ -1379,13 +1373,21 @@ find_separate_debug_file (struct objfile /* Strip off the final filename part, leaving the directory name, followed by a slash. Objfile names should always be absolute and tilde-expanded, so there should always be a slash in there - somewhere. */ - for (i = strlen(dir) - 1; i >= 0; i--) + somewhere, unless there isn't. See allocate_objfile. */ + for (i = strlen (dir) - 1; i >= 0; i--) { if (IS_DIR_SEPARATOR (dir[i])) break; } - gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i])); + if (i < 0) + { + /* We are dealing with base name only. Make it current dir. */ + if (strlen (dir) < 2) + dir = xrealloc (dir, 3); + dir[0] = '.'; + dir[1] = '/'; + i = 1; + } dir[i+1] = '\0'; /* Set I to max (strlen (canon_name), strlen (dir)). */ --------------060806060109040106080302--