From: Pedro Alves <pedro@palves.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Windows: Normalize backward slashes to forward slashes
Date: Tue, 30 Jun 2026 15:47:54 +0100 [thread overview]
Message-ID: <dec1a9e0-3f94-4b04-a016-0992627729dd@palves.net> (raw)
In-Reply-To: <867bnge0bc.fsf@gnu.org>
On 2026-06-30 12:26, Eli Zaretskii wrote:
>> From: Pedro Alves <pedro@palves.net>
>> Date: Mon, 29 Jun 2026 22:24:30 +0100
>>
>> Starting program: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple
>
> Are forward slashes only shown to the user, or does the code pas the
> file name with forward slashes to CreateProcess? (I'm not familiar
> with thecode enough to determine which one myself, sorry.) If we pass
> forward slashes to CreateProcess, it could cause problems, IME; it is
> much safer to use backslashes there.
We now pass forward slashes down to CreateProcess. It just works on my Windows 11 machine, though. I forgot to
mention, but I (painfully) ran the whole testsuite before and after this patch (that's how I discovered the need
to tweak the gdb.base/set-cwd.exp testcase).
Searching online, I found this:
https://stackoverflow.com/questions/5652834/c-createprocess-wont-work-with-app-and-args-with-forward-slash-worked
... where someone said:
"CreateProcess does work with forward-slashes on Windows 7. I'm guessing this is a version-specific feature (or bug)."
And here:
https://www.reddit.com/r/programmingmemes/comments/1k8ctk2/comment/mp8lvsr/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
Someone said:
"At least since Windows 2000, probably since always."
I asked an LLM, and got this:
"That normalization is original to NT -- Windows NT 3.1 (1993). The kernel's RtlDosPathNameToNtPathName has always treated / as an alternate separator. CreateProcess
itself never "added" the feature -- it just calls through to the kernel, which handles it transparently."
So I wonder whether what you're recalling is something from the Windows 9x days, which we no longer support (we support WinXP and up). Do you happen to recall?
If it's really a problem on supported Windows versions, it should be a matter of converting back to forward slashes before we
call CreateProcess. We already do that in gdb/windows-nat.c:windows_nat_target::create_inferior, for "set cwd":
/* Mirror slashes on inferior's cwd. */
std::replace (expanded_infcwd.begin (), expanded_infcwd.end (),
'/', '\\');
we'd just need to do the same for exec_file.
Pedro Alves
next prev parent reply other threads:[~2026-06-30 14:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 21:24 Pedro Alves
2026-06-30 11:26 ` Eli Zaretskii
2026-06-30 14:47 ` Pedro Alves [this message]
2026-06-30 15:11 ` Eli Zaretskii
2026-07-01 11:28 ` [PATCH v2] " Pedro Alves
2026-07-01 12:07 ` Eli Zaretskii
2026-07-01 19:28 ` Pedro Alves
2026-07-02 5:28 ` Eli Zaretskii
2026-07-06 12:07 ` Andrew Burgess
2026-07-06 22:35 ` 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=dec1a9e0-3f94-4b04-a016-0992627729dd@palves.net \
--to=pedro@palves.net \
--cc=eliz@gnu.org \
--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