aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-05-03 10:29:59 +0300
committerEli Zaretskii <eliz@gnu.org>2019-05-03 10:29:59 +0300
commit5f2459c233faebe8f882e556b2f4a86594a51292 (patch)
tree5af48662e4786e65e149b61ae9f2df9ef06b01f0 /gdb/symfile.c
parent41f61c65a2e1cfdb4aca3bccf6e11025495ba02e (diff)
downloadgdb-5f2459c233faebe8f882e556b2f4a86594a51292.zip
gdb-5f2459c233faebe8f882e556b2f4a86594a51292.tar.gz
gdb-5f2459c233faebe8f882e556b2f4a86594a51292.tar.bz2
Fix lookup of separate debug file on MS-Windows.
If you put the separate debug file in a global debug directory, GDB on MS-Windows would fail to find it. This happens because we obtain the directory to look up the debug file by concatenating the debug directory name with the leading directories of the executable, and the latter includes the drive letter on MS-Windows. So we get an invalid file name like d:/usr/lib/debug/d:/usr/bin/foo.debug This commit fixes that by removing the colon of the drive letter, thus producing d:/usr/lib/debug/d/usr/bin/foo.debug gdb/ChangeLog: 2019-05-03 Eli Zaretskii <eliz@gnu.org> * symfile.c (find_separate_debug_file): Remove colon from the drive spec of DOS/Windows file names of the target, so that the file name produced from DEBUGDIR and the target's directory will be valid on DOS/Windows systems. gdb/doc/ChangeLog: 2019-05-03 Eli Zaretskii <eliz@gnu.org> * gdb.texinfo (Separate Debug Files): Document how the subdirectory of the global debug directory is computed on MS-Windows/MS-DOS.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 5736666..af99da1 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1443,11 +1443,33 @@ find_separate_debug_file (const char *dir,
= dirnames_to_char_ptr_vec (debug_file_directory);
gdb::unique_xmalloc_ptr<char> canon_sysroot = gdb_realpath (gdb_sysroot);
+ /* MS-Windows/MS-DOS don't allow colons in file names; we must
+ convert the drive letter into a one-letter directory, so that the
+ file name resulting from splicing below will be valid.
+
+ FIXME: The below only works when GDB runs on MS-Windows/MS-DOS.
+ There are various remote-debugging scenarios where such a
+ transformation of the drive letter might be required when GDB runs
+ on a Posix host, see
+
+ https://sourceware.org/ml/gdb-patches/2019-04/msg00605.html
+
+ If some of those scenarions need to be supported, we will need to
+ use a different condition for HAS_DRIVE_SPEC and a different macro
+ instead of STRIP_DRIVE_SPEC, which work on Posix systems as well. */
+ std::string drive;
+ if (HAS_DRIVE_SPEC (dir_notarget))
+ {
+ drive = dir_notarget[0];
+ dir_notarget = STRIP_DRIVE_SPEC (dir_notarget);
+ }
+
for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
{
debugfile = target_prefix ? "target:" : "";
debugfile += debugdir.get ();
debugfile += "/";
+ debugfile += drive;
debugfile += dir_notarget;
debugfile += debuglink;