This is the mail archive of the gdb-prs@sources.redhat.com 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]

gdb/264: confusion between directory and filename in debugging information provided by Sun Workshop 5.3



>Number:         264
>Category:       gdb
>Synopsis:       confusion between directory and filename in debugging information provided by Sun Workshop 5.3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 20 00:58:02 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jean-Michel Rouet <JM.Rouet@noos.fr>
>Release:        gdb-5.1
>Organization:
>Environment:
SunOS neptune 5.8 Generic_108528-07 sun4u sparc
Sun WorkShop 6 update 2 C 5.3 2001/05/15
GNU gdb 5.1
>Description:
program compiled with cc/CC on workshop 5.3 contains

.stabs "/some/directory",100,0,0,0
.stabs "source.c",0,3,0,0

where the directory is not terminated by a trailing '/'.
This confuses gdb (buildsym.c comment around line 626)
because gdb tests whether a file is a directory only by 
searching for a trailing '/'.

Thus I propose to slightly modify this test, by making use
of a conventionnal 'stat()' call. (see buildsym.patch)
>How-To-Repeat:

>Fix:
Here is a proposed patch

diff -ru gdb-5.1.orig/gdb/buildsym.c gdb-5.1/gdb/buildsym.c
--- gdb-5.1.orig/gdb/buildsym.c Mon Apr 30 12:30:27 2001
+++ gdb-5.1/gdb/buildsym.c      Thu Dec 20 09:47:34 2001
@@ -26,6 +26,7 @@
    Routines to support specific debugging information formats (stabs,
    DWARF, etc) belong somewhere else. */
 
+#include <sys/stat.h>
 #include "defs.h"
 #include "bfd.h"
 #include "obstack.h"
@@ -622,13 +623,16 @@
    value to dirname and remembering the new name.  Some sanity
    checking is performed to ensure that the state of the subfile
    struct is reasonable and that the old name we are assuming to be a
-   directory name actually is (by checking for a trailing '/'). */
+   directory name actually is (by checking S_IFDIR flag in file 
+   status). */
 
 void
 patch_subfile_names (struct subfile *subfile, char *name)
 {
+  struct stat buf;
+  
   if (subfile != NULL && subfile->dirname == NULL && subfile->name != NULL
-      && subfile->name[strlen (subfile->name) - 1] == '/')
+      && (stat(subfile->name, &buf) == 0) && (buf.st_mode & S_IFDIR))
     {
       subfile->dirname = subfile->name;
       subfile->name = savestring (name, strlen (name));
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="buildsym.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="buildsym.patch"

ZGlmZiAtcnUgZ2RiLTUuMS5vcmlnL2dkYi9idWlsZHN5bS5jIGdkYi01LjEvZ2RiL2J1aWxkc3lt
LmMKLS0tIGdkYi01LjEub3JpZy9nZGIvYnVpbGRzeW0uYwlNb24gQXByIDMwIDEyOjMwOjI3IDIw
MDEKKysrIGdkYi01LjEvZ2RiL2J1aWxkc3ltLmMJVGh1IERlYyAyMCAwOTo0NzozNCAyMDAxCkBA
IC0yNiw2ICsyNiw3IEBACiAgICBSb3V0aW5lcyB0byBzdXBwb3J0IHNwZWNpZmljIGRlYnVnZ2lu
ZyBpbmZvcm1hdGlvbiBmb3JtYXRzIChzdGFicywKICAgIERXQVJGLCBldGMpIGJlbG9uZyBzb21l
d2hlcmUgZWxzZS4gKi8KIAorI2luY2x1ZGUgPHN5cy9zdGF0Lmg+CiAjaW5jbHVkZSAiZGVmcy5o
IgogI2luY2x1ZGUgImJmZC5oIgogI2luY2x1ZGUgIm9ic3RhY2suaCIKQEAgLTYyMiwxMyArNjIz
LDE2IEBACiAgICB2YWx1ZSB0byBkaXJuYW1lIGFuZCByZW1lbWJlcmluZyB0aGUgbmV3IG5hbWUu
ICBTb21lIHNhbml0eQogICAgY2hlY2tpbmcgaXMgcGVyZm9ybWVkIHRvIGVuc3VyZSB0aGF0IHRo
ZSBzdGF0ZSBvZiB0aGUgc3ViZmlsZQogICAgc3RydWN0IGlzIHJlYXNvbmFibGUgYW5kIHRoYXQg
dGhlIG9sZCBuYW1lIHdlIGFyZSBhc3N1bWluZyB0byBiZSBhCi0gICBkaXJlY3RvcnkgbmFtZSBh
Y3R1YWxseSBpcyAoYnkgY2hlY2tpbmcgZm9yIGEgdHJhaWxpbmcgJy8nKS4gKi8KKyAgIGRpcmVj
dG9yeSBuYW1lIGFjdHVhbGx5IGlzIChieSBjaGVja2luZyBTX0lGRElSIGZsYWcgaW4gZmlsZSAK
KyAgIHN0YXR1cykuICovCiAKIHZvaWQKIHBhdGNoX3N1YmZpbGVfbmFtZXMgKHN0cnVjdCBzdWJm
aWxlICpzdWJmaWxlLCBjaGFyICpuYW1lKQogeworICBzdHJ1Y3Qgc3RhdCBidWY7CisgIAogICBp
ZiAoc3ViZmlsZSAhPSBOVUxMICYmIHN1YmZpbGUtPmRpcm5hbWUgPT0gTlVMTCAmJiBzdWJmaWxl
LT5uYW1lICE9IE5VTEwKLSAgICAgICYmIHN1YmZpbGUtPm5hbWVbc3RybGVuIChzdWJmaWxlLT5u
YW1lKSAtIDFdID09ICcvJykKKyAgICAgICYmIChzdGF0KHN1YmZpbGUtPm5hbWUsICZidWYpID09
IDApICYmIChidWYuc3RfbW9kZSAmIFNfSUZESVIpKQogICAgIHsKICAgICAgIHN1YmZpbGUtPmRp
cm5hbWUgPSBzdWJmaWxlLT5uYW1lOwogICAgICAgc3ViZmlsZS0+bmFtZSA9IHNhdmVzdHJpbmcg
KG5hbWUsIHN0cmxlbiAobmFtZSkpOwo=


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