Re: Fix lookup of separate debug file on MS-Windows

Eli Zaretskii
2019-04-18T18:41:30Z

> From: LRN <lrn1986@gmail.com>
> Date: Thu, 18 Apr 2019 19:19:39 +0300
>
> While this is *a* fix, the result, AFAIU is:
>
> d:/usr/lib/debug/usr/bin/foo.debug
>
> This is a functional filename, but is it correct?

It fits the documentation, so yes.

> 1) Drive letters are lost (meaning that you can't have two paths with equal
> names on two different drives be mapped to different debug tree paths - they
> only differ in the drive letter, and you make that letter disappear)
>
> A more correct way to fix this is to replace 'X:/' with 'X/'.

We could do that, but it will need a documentation change. I think
it's overkill, as the chances of the binaries and the debug directory
to be on different drives are nil, but if others prefer to convert X:/
to X/, I'm fine with that.

> 2) This doesn't take runtime tree location into account. Your debug tree has to
> reflect the absolute, Windows path to the binary (since you're not doing any
> other adjustments, and since gdb gives you an asbolute, Windows path to begin
> with), otherwise gdb won't find the debug files.
> I.e. in the 'c:/some/directory/mingw/lib/debug/some/directory/mingw/bin/foo'
> example above the second '/some/directory' is clearly incidental, as the user
> just used that as a root of an installation.

It is as "incidental" as the same situation of Posix platforms, where
we simply splice the two directories.

> The package maintainer can't know where the binaries will end up,
> and can only predict the '/mingw/bin/foo' part.

Package maintainers shouldn't use global debug directories, because
for starters such directories might not exist at all, and even if they
do, their location cannot be predicted in advance. Package
maintainers should instead use the .debug subdirectory of where they
put the binaries, that arrangement already works, and is predictable.

> I.e. the path that gdb should look for should be:
>
> c:/some/directory/mingw/lib/debug/mingw/bin/foo
>
> or
>
> c:/some/directory/mingw/lib/debug/bin/foo

This would deviate from what we do on Unix, so I'm opposed to it.
Unless we also change the Unix behavior, of course.