Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Parent dirs of non-existing CU current dirs
@ 2008-04-26 13:42 Jan Kratochvil
  2008-04-26 15:24 ` Mark Kettenis
  2008-04-26 16:05 ` [cancel] Re: [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kratochvil @ 2008-04-26 13:42 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

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><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/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

[-- Attachment #2: gdb-nodir.patch --]
[-- Type: text/plain, Size: 4974 bytes --]

2008-04-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	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  <jan.kratochvil@redhat.com>

	* 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 <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	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 <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 != "" } {
+    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"

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Parent dirs of non-existing CU current dirs
  2008-04-26 13:42 [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil
@ 2008-04-26 15:24 ` Mark Kettenis
  2008-04-26 16:20   ` [ot] Content-Transfer-Encoding here [Re: [patch] Parent dirs of non-existing CU current dirs] Jan Kratochvil
  2008-04-26 16:05 ` [cancel] Re: [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2008-04-26 15:24 UTC (permalink / raw)
  To: jan.kratochvil; +Cc: gdb-patches

> 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_--
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [cancel] Re: [patch] Parent dirs of non-existing CU current dirs
  2008-04-26 13:42 [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil
  2008-04-26 15:24 ` Mark Kettenis
@ 2008-04-26 16:05 ` Jan Kratochvil
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2008-04-26 16:05 UTC (permalink / raw)
  To: gdb-patches

Hi,

please disregard the previous letter.

One cannot easily trim `..'s as besides of forgotten `.' one cannot expect
where the parent directory points as the previous directory may have been
a symlink to a directory.

There really should exist the empty directories referencing their parents.


Sorry,
Jan


On Sat, 26 Apr 2008 15:15:56 +0200, Jan Kratochvil wrote:
> 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><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/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

> 2008-04-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	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  <jan.kratochvil@redhat.com>
> 
> 	* gdb.base/nodir.exp, gdb.base/nodir.c: New files.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ot] Content-Transfer-Encoding here  [Re: [patch] Parent dirs of  non-existing CU current dirs]
  2008-04-26 15:24 ` Mark Kettenis
@ 2008-04-26 16:20   ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2008-04-26 16:20 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Sat, 26 Apr 2008 15:41:20 +0200, Mark Kettenis wrote:
> > 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?

My MUA does not specify any Content-Transfer-Encoding encoding and according to
the RFC 2045 section 6.1 it should be correct:
   An encoding type of 7BIT requires that the body
   is already in a 7bit mail-ready representation.  This is the default
   value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the
   Content-Transfer-Encoding header field is not present.


You quoted:
> > --=_-_TWVzc2FnZS1Cb3VuZGFyeS0tNzMzMTU4LTQ3ODA1NDA5LTgyMTg0OA-b_
> > Content-Type: text/plain; charset=us-ascii
> > Content-Transfer-Encoding: Quoted-Printable

but even the web mail archive does not contain the `Content-Transfer-Encoding'
header (and MHonArc also correctly interprets the patch there):
  http://sourceware.org/cgi-bin/get-raw-msg?listname=gdb-patches&date=2008-04&msgid=20080426131556.GA15844%40host0.dyn.jankratochvil.net
You must have some local mail filtering there, please check it.


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

Thanks for the notice, found it unfortunately too late.


Regards,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-26 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-26 13:42 [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil
2008-04-26 15:24 ` Mark Kettenis
2008-04-26 16:20   ` [ot] Content-Transfer-Encoding here [Re: [patch] Parent dirs of non-existing CU current dirs] Jan Kratochvil
2008-04-26 16:05 ` [cancel] Re: [patch] Parent dirs of non-existing CU current dirs Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox