This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: gdb_realpath: dealing with ./ and ../
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: ARistovski at qnx dot com
- Cc: brobecker at adacore dot com, dje at google dot com, gdb at sourceware dot org, RMansfield at qnx dot com
- Date: Tue, 8 Jan 2008 17:39:35 +0100 (CET)
- Subject: Re: gdb_realpath: dealing with ./ and ../
- References: <2F6320727174C448A52CEB63D85D11F40A5F@nova.ott.qnx.com>
> From: Aleksandar Ristovski <ARistovski@qnx.com>
> Date: Tue, 8 Jan 2008 11:11:33 -0500
Dropping in late, so excuse me if I'm saying things that already have
been said. But I really want to make sure that any changes are no
going to hurt people that develop free software on POSIX systems where
they do have all source files available.
> If we can confirm for sure that "normalize_path" is safe, I think the idea
> is good (please read my comment about normalize_path here:
> http://sourceware.org/ml/gdb-patches/2008-01/msg00138.html)
>
> Example
> DW_AT_name=../main.cc
> DW_AT_comp_dir=/foo/bar/obj
> The Directory Table:
> ..
> The File Name Table:$
> Entry>Dir>~~~~Time>~~~Size>~~~Name$
> 1>~~~~1>~~~~~~0>~~~~~~0>~~~~~~main.cc$
>
> Now we get rid of the comp_dir information (this is what effectively
> happens):
>
> NAME=main.cc
> DIR=/foo/bar
>
> And there is no info about /foo/bar/obj.
>
>
> I would think that this is safe.
Unfortunately it isn't. If /foo/bar/obj is a symlink to /bar/foo/obj,
then ../main.cc actually refers to /bar/foo/main.cc, and not
/foo/bar/main.cc. So just "normalizing" names is defenitely unsafe.
The big question here is, whether a compiler will actually set
DW_AT_comp_dir to /foo/bar/obj in that case. One can argue that the
compilation directory really is /bar/foo/obj in that case and that
DW_AT_comp_dir should be set to /bar/foo/obj.