From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ExeyD1e8tmhEEhIAWB0awg (envelope-from ) for ; Tue, 02 Sep 2025 05:43:51 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qAOAV7bL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5jbIpnrN; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qAOAV7bL; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5jbIpnrN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 25A841E04C; Tue, 02 Sep 2025 05:43:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0090C1E043 for ; Tue, 02 Sep 2025 05:43:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 790D93858C41 for ; Tue, 2 Sep 2025 09:43:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 790D93858C41 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qAOAV7bL; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5jbIpnrN; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qAOAV7bL; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5jbIpnrN Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id B90DC3858D21 for ; Tue, 2 Sep 2025 09:18:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B90DC3858D21 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B90DC3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756804738; cv=none; b=L7y7N1A5VDci8tfMJKFMklS2atiNOdqKb1ZKoaxbDPMhmXjPmX3OIV9PhPGzMthQzPBEkQjSOcOyXtDuOZ2bm9XJncKxxi/+MDQ2BnryRUUhRo+Eue16f7GTJBMj0HVhqWc7Fy6S93DMrfNyMx0HRqQqluQcScJc9r4jYWP9iQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756804738; c=relaxed/simple; bh=tTWlmO5LtyY/Y3H3ihIBqQlA530bH5zEKR3K7lQ+Dr4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=WPYy6XlwFu3f7FnxdEcxcDCzAudFnJfI6QYd5KTL/0mwIGpoejd68SB99kyNCPIUM8hYL3UXXJ6C35AaMO5TjLSpVc6ABuhYmy8PZxXy3EI3cLi1pSZeUU/KEreyockdmyqCBvrNPA0+XINH7sr1EEsgfrIWFEBpxAnRsrdKBE4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B90DC3858D21 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AB2751F452; Tue, 2 Sep 2025 09:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756804737; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0L3hy9dw1Ay0nHnr/axLsv7oqu+OiDnM5DG2q7mMTI=; b=qAOAV7bLVAQym91ZEImjky2H/NLHNm1olTcIz02gSuKjFTr8b29uGT/tRAj+vk+mxx8WKT kkJwR+VTdPBWLmV3mXMXiu3Fkukhv5gonFpvQpkB0rHYqAlaE4Mv1LXqJ6iDHraQbz88FT mjCr8LziNJfMVrkU9dV45lzs0YpsaWw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756804737; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0L3hy9dw1Ay0nHnr/axLsv7oqu+OiDnM5DG2q7mMTI=; b=5jbIpnrNaZt15nEi9ipqD0pJmysal+kiZKuEuABKA20kUal3Je06vVBXE1kFVay7n9+gme /hB+3okUbICmIZAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qAOAV7bL; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=5jbIpnrN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1756804737; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0L3hy9dw1Ay0nHnr/axLsv7oqu+OiDnM5DG2q7mMTI=; b=qAOAV7bLVAQym91ZEImjky2H/NLHNm1olTcIz02gSuKjFTr8b29uGT/tRAj+vk+mxx8WKT kkJwR+VTdPBWLmV3mXMXiu3Fkukhv5gonFpvQpkB0rHYqAlaE4Mv1LXqJ6iDHraQbz88FT mjCr8LziNJfMVrkU9dV45lzs0YpsaWw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1756804737; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i0L3hy9dw1Ay0nHnr/axLsv7oqu+OiDnM5DG2q7mMTI=; b=5jbIpnrNaZt15nEi9ipqD0pJmysal+kiZKuEuABKA20kUal3Je06vVBXE1kFVay7n9+gme /hB+3okUbICmIZAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 93ECB13882; Tue, 2 Sep 2025 09:18:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id K2eiIoG2tmg0CQAAD6G6ig (envelope-from ); Tue, 02 Sep 2025 09:18:57 +0000 Message-ID: Date: Tue, 2 Sep 2025 11:18:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] [gdb/testsuite] Fix host_file_normalize_mingw To: Pedro Alves , gdb-patches@sourceware.org References: <20250827131439.27473-1-tdevries@suse.de> <20250827131439.27473-3-tdevries@suse.de> <64decff4-3ff0-4033-812e-df98f7fb6912@palves.net> Content-Language: en-US From: Tom de Vries In-Reply-To: <64decff4-3ff0-4033-812e-df98f7fb6912@palves.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; URIBL_BLOCKED(0.00)[suse.de:mid,suse.de:dkim,palves.net:email,gdb.base:url,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Queue-Id: AB2751F452 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 8/29/25 21:47, Pedro Alves wrote: > Hi Tom, > > On 2025-08-27 14:14, Tom de Vries wrote: > >> 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" >> } >> } >> } > > > Unfortunately, this breaks things for me. > I test on a directory under c:/, and the testsuite broke very visibly. :-) > > For example, the patch makes us mishandle this: > > set f3 "/c/foo/bar" > set f4 "C:/foo/bar" > gdb_assert { [host_file_normalize_mingw $f3 $unix_to_win] == $f4 } > > Instead of turning $f3 into: > C:/foo/bar > it turns it into: > C:/msys64/c/foo/bar > > Notice that the "/" mount point is the only one that ends in "/". This > is even if you try to create one explicitly with a trailing /. On MSYS2: > > $ mount c:/foo /foo/ > mount: warning - /foo/ does not exist. > $ mount > C:/foo on /foo type ntfs (binary,user) > ... > > So I think we need to instead special case the "/" mount point. > > And then... while playing with this, I noticed I had done something strange with this case: > > if {[string length $filename] == $mount_len} { > return "$win_filename/" > > The intent was to append the slash when the mount is a drive letter, like 'cygpath -ma' does: > > $ cygpath -ma /c > C:/ > > Other cases do not get a trailing slash: > > $ cygpath -ma /c/foo > C:/foo > > I think this is because on Windows, every drive letter has a current directory, and really "C:" means > "current directory of drive letter C:", not "root of C:". Resolving it to "C:/" makes it unambiguous. > > However, I mishandled that, and made the code append the slash whenever the input filename matches > a mount exactly, any mount. > > And then I noticed that TCL's "file normalize" on Linux always removes the trailing slash, and since > host_file_normalize is an abstraction for it, I thought host_file_normalize_mingw should do the same. > Likewise for duplicate slashes, "file normalize" gets rid of them. > > I was going to give you a suggestion for the root mount fix, and handle the slashes things in a follow > up patch to yours, but fixing the slashes details changes how to address the issue with handling the > root dir, so I ended up doing it all in one patch. See below. > > I changed how one adds tests to your new testcase to a way that I think is much easier to write, read, > and makes gdb.sum results also have some sense. It also prints some info to gdb.log that helped me > understand what went wrong when a test FAILs. > > The "/foo" test I added has the same effect as yours, just with a shorter and simpler filename, that > fits better with the other new tests I added. What matters is that this case is a file/directory under > a mount point, and I made the testcase test that for every mount point (root, drive letter, other). > > I absolutely love the idea of a testcase for this. It helps so much! Thanks a lot for starting that. > > WDYT? Does this version work for you? I smoke tested it here with a few of the testcases that required > tweaking in the patch that added host_file_normalize like gdb.base/source-dir.exp and gdb.base/fullname.exp > and they still passed. > Hi Pedro, I ran the test-case on both x86_64-linux and msys2-ucrt64, and it passed in both cases, so I think it should be fine. Feel free to commit this together with the first patch, or perhaps to combined into one patch. Given that the second patch now changes the setup of the test-case, I think squashing makes more sense. Thanks, - Tom > From de4e47323d9e7df1b09cd635bfce902b00b3371b Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Fri, 29 Aug 2025 20:05:48 +0100 > Subject: [PATCH] Fix host_file_normalize_mingw > > Change-Id: I852a8662f0cb8b0ee4e683e9b157618cf6955477 > --- > .../gdb.testsuite/mount-point-map.exp | 33 ++++++++++++++++--- > gdb/testsuite/lib/gdb.exp | 26 +++++++++++++-- > 2 files changed, 52 insertions(+), 7 deletions(-) > > diff --git a/gdb/testsuite/gdb.testsuite/mount-point-map.exp b/gdb/testsuite/gdb.testsuite/mount-point-map.exp > index d4c8bfdeff6..9e462bb63e9 100644 > --- a/gdb/testsuite/gdb.testsuite/mount-point-map.exp > +++ b/gdb/testsuite/gdb.testsuite/mount-point-map.exp > @@ -18,9 +18,32 @@ set unix_to_win { > / C:/msys64 > } > > -set d1 "/" > -set d2 "C:/msys64/" > -gdb_assert { [host_file_normalize_mingw $d1 $unix_to_win] == $d2 } > +# Test that FROM is normalized to TO. > > -set d3 "C:/msys64" > -gdb_assert { [host_file_normalize_mingw $d3 $unix_to_win] == $d3 } > +proc test {from to} { > + set got [host_file_normalize_mingw $from $::unix_to_win] > + verbose -log "input: $from" > + verbose -log "expected: $to" > + verbose -log "got: $got" > + gdb_assert {$got == $to} $from > +} > + > +# Drive letters always get a '/' suffix, other Windows file names do > +# not. > +test "/" "C:/msys64" > +test "/c" "C:/" > +test "/bin" "C:/msys64/usr/bin" > + > +# A file name that already starts with a drive letter. > +test "C:/msys64" "C:/msys64" > + > +# A subdir/subfile under each mount. > +test "/foo" "C:/msys64/foo" > +test "/c/foo" "C:/foo" > +test "/bin/foo" "C:/msys64/usr/bin/foo" > + > +# Test slash normalization. > +test "//" "C:/msys64" > +test "/c///foo//bar//" "C:/foo/bar" > +# We don't currently handle UNC paths. > +test "//server///" "C:/msys64/server" > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 18e449ad8a0..17eb00a10f3 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -2374,12 +2374,34 @@ proc host_file_normalize_mingw {filename unix_to_win} { > return $filename > } > > + # Collapse all repeated forward slashes. > + set filename [regsub -all {//+} $filename {/}] > + > + # Strip trailing slash, except for root. > + if {$filename ne "/" && [string match */ $filename]} { > + set filename [string range $filename 0 end-1] > + } > + > foreach {unix_filename win_filename} $unix_to_win { > set mount_len [string length $unix_filename] > if {[string equal -length $mount_len $unix_filename $filename]} { > - if {[string length $filename] == $mount_len} { > - return "$win_filename/" > + if {$unix_filename eq "/"} { > + if {$filename eq "/"} { > + return "$win_filename" > + } else { > + return "$win_filename$filename" > + } > + } elseif {[string length $filename] == $mount_len} { > + # Like "cygpath -ma" if the file name resolves to a > + # drive letter, append a slash, to make it unambiguous > + # that we resolved to the root of the drive and not > + # the drive's current directory. > + if {[string match {[A-Za-z]:} $win_filename]} { > + return "$win_filename/" > + } else { > + return "$win_filename" > + } > } elseif {[string index $filename $mount_len] eq "/"} { > set rest [string range $filename $mount_len end] > return "$win_filename$rest" >