public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Fix lookup of separate debug file on MS-Windows
@ 2019-04-18 13:49 Eli Zaretskii
  2019-04-18 16:19 ` LRN
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2019-04-18 13:49 UTC (permalink / raw)
  To: gdb-patches

If you put the separate debug file in a global debug directory, GDB on
MS-Windows will currently 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

The patch below fixes that:

--- gdb/symfile.c~0	2019-03-27 00:52:05.000000000 +0200
+++ gdb/symfile.c	2019-04-18 13:19:05.231697600 +0300
@@ -1443,6 +1443,18 @@ find_separate_debug_file (const char *di
     = 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 strip
+     the drive letter, so that the file name resulting from splicing
+     below will be valid.  */
+  if (HAS_DRIVE_SPEC (dir_notarget))
+    {
+      dir_notarget = STRIP_DRIVE_SPEC (dir_notarget);
+      /* We will append a slash to debugdir, so remove the leading
+	 slash as well.  */
+      if (IS_DIR_SEPARATOR (dir_notarget[0]))
+	dir_notarget++;
+    }
+
   for (const gdb::unique_xmalloc_ptr<char> &debugdir : debugdir_vec)
     {
       debugfile = target_prefix ? "target:" : "";


OK to commit to both branches (with the necessary ChangeLog entries)?

Btw, the removal of the leading slash of dir_notarget could
potentially benefit Posix systems as well.  Or maybe we should not
append the literal slash in this snippet from
find_separate_debug_file:

      debugfile = target_prefix ? "target:" : "";
      debugfile += debugdir.get ();
      debugfile += "/";  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      debugfile += dir_notarget;
      debugfile += debuglink;

since AFAICT dir_notarget will always begin with a slash (I added a
test for that because I wasn't sure that is indeed so).

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-05-03  7:36 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 13:49 Fix lookup of separate debug file on MS-Windows Eli Zaretskii
2019-04-18 16:19 ` LRN
2019-04-18 18:41   ` Eli Zaretskii
2019-04-18 21:42     ` LRN
2019-04-19  6:48       ` Eli Zaretskii
2019-04-19 10:06         ` LRN
2019-04-21 12:06     ` Eli Zaretskii
2019-04-21 12:55       ` Simon Marchi
2019-04-22  9:19         ` Eli Zaretskii
2019-04-27 10:56           ` Eli Zaretskii
2019-04-27 16:16           ` Simon Marchi
2019-04-27 16:39             ` Eli Zaretskii
2019-04-27 18:56               ` Simon Marchi
2019-04-27 19:05                 ` Eli Zaretskii
2019-05-03  7:36                   ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).