Re: [RFA] patch for DW_AT_comp_dir/DW_AT_name vs .debug_line inco nsistencies

Doug Evans
2008-01-08T17:33:07Z

On Jan 8, 2008 8:09 AM, Aleksandar Ristovski <ARistovski@qnx.com> wrote:
> About normalize_path: I am really missing how would symlink spoil anything.

As a data point, here is an example that doesn't use #line, uses
present day gcc, and would cause bad behaviour in gdb if
normalize_path was indescriminately used. To what extent the example
is contrived and wouldn't occur in practice I don't know.

[The use of an obj directory here isn't important, it's just a turd
from various experiments.]

rm -rf /tmp/foo
mkdir -p /tmp/foo
cd /tmp/foo
mkdir -p a/b
ln -s a/b t
mkdir obj
cat >a/foo.c <<EOF
int x;
EOF
cat >a/b/foo.c <<EOF
#include "../foo.c"
int foo(){return x;}
EOF
cat >foo.c <<EOF
#include "t/foo.c"
int main (){return foo();}
EOF
cat foo.c
(cd obj && gcc -g /tmp/foo/foo.c -o ../foo.x)
readelf -w foo.x >foo.w

From foo.w:

DW_AT_name : /tmp/foo/foo.c

The Directory Table:
/tmp/foo/t
/tmp/foo
/tmp/foo/t/..

The File Name Table:
Entry Dir Time Size Name
1 1 0 0 foo.c
2 2 0 0 foo.c
3 3 0 0 foo.c