This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Parent dirs of non-existing CU current dirs


> Date: Sat, 26 Apr 2008 15:15:56 +0200
> From: "Jan Kratochvil" <jan.kratochvil@redhat.com>

Jan I have trouble reading your mail, because it uses Quoted-Printable
encoding.  Can you please teach your mailer not to do this?

Anyway it may be that all those superfluous = signs have made me
misinterpret the problem.  However, I don't think this diff is right.
The path

/usr/src/debug/nspr-4.7.0.99.2/pr/src/../.././mozilla/nsprpub/pr/src/prvrsion.c

is not neccessarily the same as

/usr/src/debug/nspr-4.7.0.99.2/mozilla/nsprpub/pr/src/prvrsion.c

This really is an end-user problem here, for deleting the compilation
directory.

> Hi,
> 
> (gdb) up
> #1  0x00007f79042e1ee4 in PR_WaitCondVar (cvar=3D0x14196f0, timeout=3D42949=
> 67295)
>     at ../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c:405
> 405=09../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c: No such file or =
> directory.
> =09in ../../../mozilla/nsprpub/pr/src/pthreads/ptsynch.c
> 
> /usr/lib/debug/lib64/libnspr4.so.debug
>  <0><b>: 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/nsp=
> rpub/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
> 
> --=_-_TWVzc2FnZS1Cb3VuZGFyeS0tNzMzMTU4LTQ3ODA1NDA5LTgyMTg0OA-b_
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: Quoted-Printable
> 
> 2008-04-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> =09Find sources in parent dirs of non-existing CU current dirs.
> =09* defs.h (gdb_trim_dir_parents): New prototype.
> =09* utils.c (gdb_trim_dir_parents): New function.
> =09* source.c (openp): Call GDB_TRIM_DIR_PARENTS.
> 
> 2008-04-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> =09* gdb.base/nodir.exp, gdb.base/nodir.c: New files.
> 
> --- ./gdb/defs.h=0924 Apr 2008 11:13:44 -0000=091.221
> +++ ./gdb/defs.h=0926 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=0917 Apr 2008 17:43:58 -0000=091.87
> +++ ./gdb/source.c=0926 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))
>  =09{
>  =09  fd =3D open (filename, mode);
> --- ./gdb/utils.c=0924 Apr 2008 11:13:44 -0000=091.187
> +++ ./gdb/utils.c=0926 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 =3D path;
> +  char *dest =3D path;
> +
> +  do
> +    {
> +      if ((dest =3D=3D path || IS_DIR_SEPARATOR (src[-1]))
> +          && src[0] =3D=3D '.' && src[1] =3D=3D '.'
> +             && (IS_DIR_SEPARATOR (src[2]) || src[2] =3D=3D 0))
> +        {
> +          while (dest > path && IS_DIR_SEPARATOR (dest[-1]))
> +            dest--;
> +          while (dest > path && !IS_DIR_SEPARATOR (dest[-1]))
> +            dest--;
> +          src =3D &src[2];
> +          while (IS_DIR_SEPARATOR (*src))
> +            src++;
> +          continue;
> +        }
> +      *dest++ =3D *src++;
> +    }
> +  while (src[-1] !=3D 0);
> +}
> +
>  
>  /* This is the 32-bit CRC function used by the GNU separate debug
>     facility.  An executable may contain a section named
> --- /dev/null=091 Jan 1970 00:00:00 -0000
> +++ ./gdb/testsuite/gdb.base/nodir.c=0926 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 <http://www.gnu.org/licenses/>.
> +
> +   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=091 Jan 1970 00:00:00 -0000
> +++ ./gdb/testsuite/gdb.base/nodir.exp=0926 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 <http://www.gnu.org/licenses/>.
> +
> +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 !=3D "" } {
> +    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"
> 
> --=_-_TWVzc2FnZS1Cb3VuZGFyeS0tNzMzMTU4LTQ3ODA1NDA5LTgyMTg0OA-b_--
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]