From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10802 invoked by alias); 26 Apr 2008 13:16:33 -0000 Received: (qmail 10789 invoked by uid 22791); 26 Apr 2008 13:16:32 -0000 X-Spam-Check-By: sourceware.org Received: from host0.dyn.jankratochvil.net (HELO host0.dyn.jankratochvil.net) (89.250.240.59) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 26 Apr 2008 13:16:02 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.2/8.14.1) with ESMTP id m3QDFuG1016010 for ; Sat, 26 Apr 2008 15:15:57 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.2/8.14.2/Submit) id m3QDFuuh016008 for gdb-patches@sourceware.org; Sat, 26 Apr 2008 15:15:56 +0200 Date: Sat, 26 Apr 2008 13:42:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Parent dirs of non-existing CU current dirs Message-ID: <20080426131556.GA15844@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1yeeQ81UyVL57Vl7" Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) 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: 2008-04/txt/msg00589.txt.bz2 --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1362 Hi, (gdb) up #1 0x00007f79042e1ee4 in PR_WaitCondVar (cvar=0x14196f0, timeout=4294967295) at ../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c:405 405 ../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c: No such file or directory. in ../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c /usr/lib/debug/lib64/libnspr4.so.debug <0>: Abbrev Number: 1 (DW_TAG_compile_unit) <11> DW_AT_name : (indirect string, offset: 0x7d): ../.././mozilla/nsprpub/pr/src/prvrsion.c <15> DW_AT_comp_dir : (indirect string, offset: 0x14c): /usr/src/debug/nspr-4.7.0.99.2/pr/src ls: cannot access /usr/src/debug/nspr-4.7.0.99.2/pr/src/../.././mozilla/nsprpub/pr/src/prvrsion.c: No such file or directory ls: cannot access /usr/src/debug/nspr-4.7.0.99.2/pr/src: No such file or directory -rw-r--r-- 1 root root 4715 2004-04-25 11:00 /usr/src/debug/nspr-4.7.0.99.2/./mozilla/nsprpub/pr/src/prvrsion.c -rw-r--r-- 1 root root 4715 2004-04-25 11:00 /usr/src/debug/nspr-4.7.0.99.2/mozilla/nsprpub/pr/src/prvrsion.c We should not insist the current directory of CU exists as it may be omitted if it would be empty. The other opinion may be there is a bug in the debuginfo generator and the empty directories should still exist there. One may also normalize the directories listed in the debuginfo files. No regressions on x86_64-fedora-9. Regards, Jan --1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="gdb-nodir.patch" Content-length: 4974 2008-04-26 Jan Kratochvil Find sources in parent dirs of non-existing CU current dirs. * defs.h (gdb_trim_dir_parents): New prototype. * utils.c (gdb_trim_dir_parents): New function. * source.c (openp): Call GDB_TRIM_DIR_PARENTS. 2008-04-26 Jan Kratochvil * gdb.base/nodir.exp, gdb.base/nodir.c: New files. --- ./gdb/defs.h 24 Apr 2008 11:13:44 -0000 1.221 +++ ./gdb/defs.h 26 Apr 2008 12:56:19 -0000 @@ -372,6 +372,7 @@ extern void init_page_info (void); extern char *gdb_realpath (const char *); extern char *xfullpath (const char *); +extern void gdb_trim_dir_parents (char *path); extern unsigned long gnu_debuglink_crc32 (unsigned long crc, unsigned char *buf, size_t len); --- ./gdb/source.c 17 Apr 2008 17:43:58 -0000 1.87 +++ ./gdb/source.c 26 Apr 2008 12:56:21 -0000 @@ -773,6 +773,8 @@ openp (const char *path, int opts, const strcat (filename + len, SLASH_STRING); strcat (filename, string); + gdb_trim_dir_parents (filename); + if (is_regular_file (filename)) { fd = open (filename, mode); --- ./gdb/utils.c 24 Apr 2008 11:13:44 -0000 1.187 +++ ./gdb/utils.c 26 Apr 2008 12:56:24 -0000 @@ -2987,6 +2987,35 @@ xfullpath (const char *filename) return result; } +/* Remove any `dir/../' parts as DIR from the CU current directory may not + exist and we still should find the source file in its parent directory. */ + +void +gdb_trim_dir_parents (char *path) +{ + char *src = path; + char *dest = path; + + do + { + if ((dest == path || IS_DIR_SEPARATOR (src[-1])) + && src[0] == '.' && src[1] == '.' + && (IS_DIR_SEPARATOR (src[2]) || src[2] == 0)) + { + while (dest > path && IS_DIR_SEPARATOR (dest[-1])) + dest--; + while (dest > path && !IS_DIR_SEPARATOR (dest[-1])) + dest--; + src = &src[2]; + while (IS_DIR_SEPARATOR (*src)) + src++; + continue; + } + *dest++ = *src++; + } + while (src[-1] != 0); +} + /* This is the 32-bit CRC function used by the GNU separate debug facility. An executable may contain a section named --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.base/nodir.c 26 Apr 2008 12:56:24 -0000 @@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +void +foo () +{ +} + +int +main () +{ + foo (); /* EXPECTED-STRING */ + return 0; +} --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ./gdb/testsuite/gdb.base/nodir.exp 26 Apr 2008 12:56:24 -0000 @@ -0,0 +1,49 @@ +# Copyright 2005, 2007, 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set srcfile nodir.c +set binfile ${objdir}/${subdir}/nodir +set binfiledir ${objdir}/${subdir}/nodir.d + +file copy -force ${srcdir}/${subdir}/${srcfile} ${objdir}/${subdir}/nodir-tmp.c +file mkdir $binfiledir +set origdir [pwd] +cd ${binfiledir} +set result [gdb_compile "../nodir-tmp.c" "../nodir" executable {debug}] +cd ${origdir} +file delete -force ${binfiledir} + +if { $result != "" } { + untested "Couldn't compile test program" + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +# Intentionally a bogus directory. +gdb_reinitialize_dir /dir-doEs-nOt-exIst +gdb_load ${binfile} + +# For C programs, "start" should stop in main(). +if { [gdb_start_cmd] < 0 } { + untested start + return -1 +} + +gdb_test "" \ + "main \\(\\) at .*nodir-tmp.c.*EXPECTED-STRING.*" \ + "start" --1yeeQ81UyVL57Vl7--