Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] [gdb/testsuite] Fix host_file_normalize_mingw
Date: Wed, 27 Aug 2025 15:14:39 +0200	[thread overview]
Message-ID: <20250827131439.27473-3-tdevries@suse.de> (raw)
In-Reply-To: <20250827131439.27473-1-tdevries@suse.de>

I ran the testsuite on msys2-ucrt64 with mount point map:
...
  /bin C:/msys64/usr/bin
  /c   C:
  /    C:/msys64
...
and ran into the problem that host_file_normalize didn't translate:
...
/home/user/gdb/build/gdb/testsuite/temp/n/x
...
into:
...
C:/msys64/home/user/gdb/build/gdb/testsuite/temp/n/x
...

Fix this in host_file_normalize_mingw and add a corresponding test in
test-case gdb.testsuite/mount-point-map.exp.

Tested on aarch64-linux and msys2-ucrt64.
---
 gdb/testsuite/gdb.testsuite/mount-point-map.exp | 4 ++++
 gdb/testsuite/lib/gdb.exp                       | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.testsuite/mount-point-map.exp b/gdb/testsuite/gdb.testsuite/mount-point-map.exp
index d4c8bfdeff6..cc070622b13 100644
--- a/gdb/testsuite/gdb.testsuite/mount-point-map.exp
+++ b/gdb/testsuite/gdb.testsuite/mount-point-map.exp
@@ -24,3 +24,7 @@ gdb_assert { [host_file_normalize_mingw $d1 $unix_to_win] == $d2 }
 
 set d3 "C:/msys64"
 gdb_assert { [host_file_normalize_mingw $d3 $unix_to_win] == $d3 }
+
+set f1 "/home/user/gdb/build/gdb/testsuite/temp/n/x"
+set f2 "C:/msys64/home/user/gdb/build/gdb/testsuite/temp/n/x"
+gdb_assert { [host_file_normalize_mingw $f1 $unix_to_win] == $f2 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b7961eb30dc..4b0249db70b 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2381,9 +2381,9 @@ proc host_file_normalize_mingw {filename unix_to_win} {
 	if {[string equal -length $mount_len $unix_filename $filename]} {
 	    if {[string length $filename] == $mount_len} {
 		return "$win_filename/"
-	    } elseif {[string index $filename $mount_len] eq "/"} {
+	    } elseif {[string index $filename [expr $mount_len - 1]] eq "/"} {
 		set rest [string range $filename $mount_len end]
-		return "$win_filename$rest"
+		return "$win_filename/$rest"
 	    }
 	}
     }
-- 
2.43.0


  parent reply	other threads:[~2025-08-27 13:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 13:14 [PATCH 0/2] [gdb/testsuite] Fix host_file_normalize with host mingw Tom de Vries
2025-08-27 13:14 ` [PATCH 1/2] [gdb/testsuite] Add gdb.testsuite/mount-point-map.exp Tom de Vries
2025-08-27 13:14 ` Tom de Vries [this message]
2025-08-29 19:47   ` [PATCH 2/2] [gdb/testsuite] Fix host_file_normalize_mingw Pedro Alves
2025-09-02  9:18     ` Tom de Vries
2025-09-02 11:34       ` Pedro Alves
2025-09-02 11:44         ` Tom de Vries
2025-09-02 12:06           ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250827131439.27473-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox