From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Aub1BYNqRWo/jyEAWB0awg (envelope-from ) for ; Wed, 01 Jul 2026 15:29:07 -0400 Received: by simark.ca (Postfix, from userid 112) id 05BFE1E024; Wed, 01 Jul 2026 15:29:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 347521E024 for ; Wed, 01 Jul 2026 15:29:06 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B39814BA2E22 for ; Wed, 1 Jul 2026 19:29:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B39814BA2E22 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by sourceware.org (Postfix) with ESMTPS id 7C05C4BA5439 for ; Wed, 1 Jul 2026 19:28:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7C05C4BA5439 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7C05C4BA5439 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782934115; cv=none; b=Cg2acjXw0RwQvFEy8tCdEgGLI6JGOGMW1Riu+HCdBbvAWc7HG/hLfpzkfUymwY4DHSwmwmADuGTkEfx0XMo93sHF6P/6mvSvevZFubdy5xdYWHATVkHxhdWNOt4vZlTkJRnM7qKMHDcs+VrvJEgNb13V+NwBW9oNGwtcIFHxGRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782934115; c=relaxed/simple; bh=MYlfEs69LouGWAcyskKwlrwH4SVwhJazIjk+GsRSLRM=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=Cy3AvPBchqFfIReV13SqQ1kRswJzAxAvYXNAEeWjyiVTll6M6RC3ZYjMZw7NBGRqsq4XewjpybZphSZzcD9C0rHAIF+sf5fm7yjkN3p6XWeSphanD6qzDs9s7A59xrr4I5p7XgbD2ZE9a7BepWwyM/iymb5O8NkI05KmW12WWTE= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C05C4BA5439 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso5635725e9.1 for ; Wed, 01 Jul 2026 12:28:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782934114; x=1783538914; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qL2b6wQoxwy5F1Zzi3MMhiPoTChKJ2iC7RsNjjwLq8c=; b=qtEUyQd/DOJ2xQ2j7jzkuupMFEDg43WcPKAcA2U4uL8f6OUXZLkgTQ6n81CjQEuXWS bNa0Pwo6IJL1Rt+JFJRe9unpsIEAv4d080JXqeYdJSlWl2pzJVt0fYDntSAmGstiWawT DTHQJjjqdXzP8NhtPjVS+nxPKecOqAXGRLz7rhL1DET4/r/m/RQa4ObWunplnooTypGO Y7k0ko57gr99+9an3CwRN/Kxj8GyilqNRaLgKRy0yhHT6ibmDBC7gfOSkCPgR7hu0mz+ id0a0qpYk2K5fbYVWwZHOzHogSbD0KNNIdaVGk2e1S/XGt5choORogqzGV4Vv3bN5yNl 8VNA== X-Gm-Message-State: AOJu0YzTn2C8fy1c4JIJmzpXdbP9RiPnDzeLFrXVQsbzQtIt3dmCWW8Z FbZiSrMJqffEXNVnq9UafXICU+ZwUAeoILmQcWymo6IyExqH9Qxra88KuwBiEA== X-Gm-Gg: AfdE7cmLWYFP1MgaP8WSWm+rVm49jV/XcOTj8O2Lnmx6IglwPPDxGyT9n+zk299lVrz 7h6Sf+4tJstBWvwNXMTnjxohEE29ftxVJhzzNbCyfmJKNzvjr6G3HJN/5Lp4mPS+aiu2GsPR06+ OE0j4BoHjCKy1nfXJZnVMquNQlx37AURICCzJid5IaxC19/Dz+FuWJc/CjmHIs2b5ahTKJJOEFo bkFjld1W7rNEbyUqq2jEiRddVPdyW2b/Wba75X0kCVoipB26wn1JTIgHJpyD8IC2/5CwKSMkJ0k 68u9y55XHSBClrSqToO2X8ClgJUCWpGY+dK7E30cQ+NqoK2Ts9sryUZdEf7Ia7j+LdCHClthRxd ZhEwmQKohk2NaRShGxYUB0dyqsjHSq5LetTP2kH0kujEcaRhy5IfTwFhHiLkGYMyHxQydSiyiV+ xt9lpolL4a9A31uN4R32GG8HfF6zs6PrJShN/BZQ6IVaBIoX+MWxvO8oFDF587uyeH2w== X-Received: by 2002:a05:600c:6592:b0:493:c389:d43c with SMTP id 5b1f17b1804b1-493c389d4e4mr38328625e9.34.1782934114292; Wed, 01 Jul 2026 12:28:34 -0700 (PDT) Received: from ?IPV6:2001:8a0:fac2:7700:16f0:8919:779f:a439? ([2001:8a0:fac2:7700:16f0:8919:779f:a439]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-477db3dbc75sm2302516f8f.5.2026.07.01.12.28.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jul 2026 12:28:33 -0700 (PDT) Message-ID: Date: Wed, 1 Jul 2026 20:28:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Windows: Normalize backward slashes to forward slashes To: Eli Zaretskii Cc: gdb-patches@sourceware.org References: <20260629212430.340516-1-pedro@palves.net> <867bnge0bc.fsf@gnu.org> <86qzlocbb4.fsf@gnu.org> <86fr22diax.fsf@gnu.org> From: Pedro Alves Content-Language: en-US In-Reply-To: <86fr22diax.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 2026-07-01 13:07, Eli Zaretskii wrote: >> Date: Wed, 1 Jul 2026 12:28:41 +0100 >> Cc: gdb-patches@sourceware.org >> From: Pedro Alves >> >> Still, I think the conversion is worth doing. What the slash direction does >> for sure affect is the argv[0] the inferior sees. The command line we hand >> CreateProcess is also what the child's CRT splits into argv, so without converting, >> the inferior sees forward slashes in its own program name. Giving the inferior >> native separators in argv[0] seems like enough reason to convert -- i.e., not >> framing it about what CreateProcess parses, but what the inferior itself sees >> and parses. > > I agree. > >> I've made gdb and gdbserver do that, and added a comment about this. In gdb/windows-nat.c: >> >> /* Convert the executable path to backslash separators, so the >> inferior observes native backslashes in its own program name. */ >> std::string toexec_native = exec_file; >> std::replace (toexec_native.begin (), toexec_native.end (), '/', '\\'); >> toexec = toexec_native.c_str (); >> >> and in gdbserver/win32-low.cc: >> >> /* Convert the executable path to backslash separators, so the >> inferior observes native backslashes in its own program name. */ >> std::string program_native = program; >> std::replace (program_native.begin (), program_native.end (), '/', '\\'); >> program = program_native.c_str (); >> >> >> (Note: these are both on !Cygwin paths, as the Cygwin paths already do the path >> conversion via cygwin_conv_path. And BTW, Cygwin GDB already presented forward >> slashes to users already everywhere, including in "info shared", etc.) >> >> >> Having this reason written down also avoids having to try to come up with some >> speculative comment about some old Windows behavior we're not exactly sure what it was. >> >> >>> >>>> 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. >>> >>> Yes, I think it's safer to convert to all backslashes in the argument >>> we pass to CreateProcess. And it will not show outside of that place, >>> so the (very positive and welcome) effects of your changes will not be >>> affected. >>> >> >> Here's the updated patch. Other than the tweaks mentioned above, and an updated >> commit log, nothing else changed. >> >> Let me know what you think. > > LGTM, thanks. I have a couple of minor comments below. > >> --- a/gdb/NEWS >> +++ b/gdb/NEWS >> @@ -83,6 +83,21 @@ >> >> * Support for native Thread Local Storage (TLS) variables on Windows. >> >> +* GDB now normalizes backslashes to forward slashes on Windows. >> + >> + E.g., depending on compiler and build system used by your project, >> + previously GDB could show a mix of slash styles, like for example: >> + >> + C:/proj/src\main.c >> + >> + GDB will now consistently show forward slashes: >> + >> + C:/proj/src/main.c >> + >> + This affects everywhere GDB shows a filename/dirname: source >> + filenames, executable filename, shared libraries, the cd/pwd >> + commands, etc. > > Should this mention GDB/MI output? Someone might not guess that it's > covered by "etc.", given that the other examples are from quite > different use cases. How about this? This impacts all interpreters, including the CLI, the TUI, the GDB/MI interface, and the Debug Adapter Protocol, and affects everywhere GDB shows a filename/dirname: source filenames, executable filename, shared libraries, the cd/pwd commands, etc. > >> +char * >> +normalize_slashes (char *path) >> +{ >> + for (char *p = path; *p != '\0'; ++p) >> + if (*p == '\\') >> + *p = '/'; >> + return path; >> +} > > Ehm... GNU Coding Standards frown on using "path" for anything but > PATH-style directory lists. So maybe we should use "filename" or > somesuch, here and elsewhere. Yeah, I had made an effort to avoid it in the NEWS entry for that reason. For the code itself, I think that's a losing battle, the file itself is called pathstuff.c, described at the top as: /* Path manipulation routines for GDB and gdbserver. It's full of functions using "path" as I was using, and then used throughout GDB, like: $ grep path ../gdbsupport/pathstuff.h | grep extern extern char *normalize_slashes (char *path); extern gdb::unique_xmalloc_ptr gdb_realpath (const char *filename); extern std::string gdb_realpath_keepfile (const char *filename); extern std::string gdb_abspath (const char *path, extern const char *child_path (const char *parent, const char *child); extern std::string path_join (gdb::array_view paths); extern bool contains_dir_separator (const char *path); Then you have standard functions/symbols like realpath, GetFullPathName, PATH_MAX, etc (used by that file). So "path" is pretty well established, including in POSIX and Windows APIs, and I don't think GDB developers end up confused. Honestly, I think using the GNU terminology confuses more people than helps. Recently in the DWARF committee I pointed out the GNU terminology to people, and everyone seemed surprised and confused, and I think thought I was being weird. :-P If I were to have say in this aspect of the GNU coding standards, I would rather come up with a more precise name for the PATH-style directory lists case than fight about what does "path" mean. > > Reviewed-By: Eli Zaretskii >