From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3702 invoked by alias); 14 Aug 2009 13:15:56 -0000 Received: (qmail 3610 invoked by uid 22791); 14 Aug 2009 13:15:54 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO qnxmail.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Aug 2009 13:15:44 +0000 Received: from Nebula.ott.qnx.com (nebula.ott.qnx.com [10.42.3.30]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id JAA03556; Fri, 14 Aug 2009 09:15:22 -0400 Received: from [127.0.0.1] ([10.42.100.129]) by Nebula.ott.qnx.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 14 Aug 2009 09:15:25 -0400 Message-ID: <4A85635D.7060508@qnx.com> Date: Fri, 14 Aug 2009 14:44:00 -0000 From: Aleksandar Ristovski User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Tom Tromey CC: Doug Evans , gdb-patches@sources.redhat.com Subject: Re: [patch] symfile find_separate_debug_file References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------000901040006060107080405" 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/msg00192.txt.bz2 This is a multi-part message in MIME format. --------------000901040006060107080405 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1076 Tom Tromey wrote: >>>>>> "Doug" == Doug Evans writes: > > Doug> fwiw, I wouldn't mind an elaboration of the comment, e.g. provide an > Doug> example when "unless there isn't" happens. Otherwise I have to go > Doug> looking and assume what I find is what the comment is referring to. > > Sounds reasonable to me. My initial idea was to remove that comment altogether since it describes an assumption that may have been good at the time, but doesn't stand any longer. But then went with "minimal change" approach. The code itself is clear and I don't think it needs explanation: if file does not contain any directory separators, use current directory. It happens when gdb opens a shared library from its current directory (e.g. libc.so.3). So how about I remove portion of that comment, and leave only generic part that makes no assumptions about presence of dir. separators? (new patch attached). -- Aleksandar Ristovski QNX Software Systems * symfile.c (find_separate_debug_file): Fix the case when objfile has only basename as its name. --------------000901040006060107080405 Content-Type: text/x-patch; name="symfile-20090814.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="symfile-20090814.diff" Content-length: 1005 Index: gdb/symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.240 @@ -1377,15 +1371,21 @@ find_separate_debug_file (struct objfile dir = xstrdup (objfile->name); /* 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--) + followed by a slash. */ + 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)). */ --------------000901040006060107080405--