From 6e2469ff7afa5134cb55154212e10f25b9e7b2dd Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Wed, 13 May 2020 12:35:51 +0200 Subject: [PATCH] Handle Windows drives in auto-load script paths Fixes this testsuite fail on Windows: FAIL: gdb.base/auto-load.exp: print $script_loaded Converts the debugfile path from c:/dir/file to /c/dir/file, so it can be appended to the auto-load path. gdb/ChangeLog: 2020-07-08 Hannes Domani * auto-load.c (auto_load_objfile_script_1): Convert drive part of debugfile path on Windows. gdb/doc/ChangeLog: 2020-07-08 Hannes Domani * gdb.texinfo: Document Windows drive conversion of 'set auto-load scripts-directory'. --- gdb/ChangeLog | 5 +++++ gdb/auto-load.c | 7 +++++++ gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4014fe4405e..df9bc04c874 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-07-08 Hannes Domani + + * auto-load.c (auto_load_objfile_script_1): Convert drive part + of debugfile path on Windows. + 2020-07-08 John Baldwin * fbsd-nat.c (fbsd_nat_target::find_memory_regions): Rename 'obfd' diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 99bd96b971a..c967261925a 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -784,6 +784,13 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname, "scripts-directory' path \"%s\".\n"), auto_load_dir); + /* Convert Windows file name from c:/dir/file to /c/dir/file. */ + if (HAS_DRIVE_SPEC (debugfile)) + { + debugfile_holder = STRIP_DRIVE_SPEC (debugfile); + filename = std::string("\\") + debugfile[0] + debugfile_holder; + } + for (const gdb::unique_xmalloc_ptr &dir : vec) { /* FILENAME is absolute, so we don't need a "/" here. */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index ee6a866258d..0538115b1bf 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2020-07-08 Hannes Domani + + * gdb.texinfo: Document Windows drive conversion of + 'set auto-load scripts-directory'. + 2020-07-06 Andrew Burgess * gdb.texi (Registers): Add @anchor for 'info registers diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fb6fd9eb870..1514ff10e8d 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -27340,6 +27340,10 @@ script in the specified extension language. If this file does not exist, then @value{GDBN} will look for @var{script-name} file in all of the directories as specified below. +(On MS-Windows/MS-DOS, the drive letter of the executable's leading +directories is converted to a one-letter subdirectory, i.e.@: +@file{d:/usr/bin/} is converted to @file{/d/usr/bin/}, because Windows +filesystems disallow colons in file names.) Note that loading of these files requires an accordingly configured @code{auto-load safe-path} (@pxref{Auto-loading safe path}). -- 2.30.2