public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: use cygpath to convert from Unix to Windows paths
@ 2020-03-11 18:32 Simon Marchi
  2020-03-11 18:40 ` Christian Biesinger
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2020-03-11 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

When on a MinGW host, standard_output_file uses a regular expression to
convert Unix-style paths of the form "/c/foo" to "c:/foo".  This is
needed because the paths we pass to GDB (for example, with the "file"
command) need to be in the Windows form.

However, the regexp only works if your binutils-gdb repo is under a
`/[a-z]/...` path (the Unix paths mapping to Windows drives).
Presumably, that works if you clone the repo in Windows, then access it
through `/c/...`.

In my case, I've cloned the repository directly inside my MinGW shell,
so in /home/smarchi.  The regexp therefore doesn't work for me.  The
path doesn't get transformed, and the file command fails when running
any test:

    (gdb) file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.arch/i386-bp_permanent/i386-bp_permanent
    /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.arch/i386-bp_permanent/i386-bp_permanent: No such file or directory.

A safer way to do this conversion would be to use the cygpath utility.
It can be used to convert any MinGW path into its Windows equivalent.

Note that despite originally coming from Cygwin, the cygpath utility is
distributed by mingw-w64 and can be used in that environment.

With this, the file command in the test succeeds:

    (gdb) file C:/msys64/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.arch/i386-bp_permanent/i386-bp_permanent
    Reading symbols from C:/msys64/home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.arch/i386-bp_permanent/i386-bp_permanent...

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (standard_output_file): Use cygpath to convert
	from Unix to Windows path.
---
 gdb/testsuite/lib/gdb.exp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9614e8dc87cd..ac16e0e85c99 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4899,8 +4899,10 @@ proc standard_output_file {basename} {
     file mkdir $dir
     # If running on MinGW, replace /c/foo with c:/foo
     if { [ishost *-*-mingw*] } {
-        set dir [regsub {^/([a-z])/} $dir {\1:/}]
+       set dir [exec cygpath --mixed "${dir}"]
+
     }
+
     return [file join $dir $basename]
 }
 
-- 
2.25.1


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

end of thread, other threads:[~2020-05-12 22:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 18:32 [PATCH] testsuite: use cygpath to convert from Unix to Windows paths Simon Marchi
2020-03-11 18:40 ` Christian Biesinger
2020-03-11 19:09   ` Simon Marchi
2020-03-11 19:14     ` Eli Zaretskii
2020-03-11 19:26       ` Simon Marchi
2020-03-13 17:57         ` Tom Tromey
2020-03-13 18:14           ` Christian Biesinger
2020-03-13 19:11           ` Tom Tromey
2020-05-12 22:44             ` Simon Marchi

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).