From: Jon Turney <jon.turney@dronecode.org.uk>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/9] Fix possible Cygwin build problem
Date: Thu, 2 Jun 2022 15:12:48 +0100 [thread overview]
Message-ID: <a3e4dfab-d458-920e-f59e-e1fe7bca33bf@dronecode.org.uk> (raw)
In-Reply-To: <83mtf4nmij.fsf@gnu.org>
On 26/05/2022 20:04, Eli Zaretskii wrote:
>> From: Tom Tromey <tromey@adacore.com>
>> Cc: Jon Turney <jon.turney@dronecode.org.uk>, Eli Zaretskii <eliz@gnu.org>,
>> tromey@adacore.com
>> Date: Thu, 26 May 2022 11:00:45 -0600
>>
>>>>>>> "Eli" == Eli Zaretskii via Gdb-patches <gdb-patches@sourceware.org> writes:
>>
>> Eli> __USEWIDE in native Windows programming assumes the use of wchar_t for
>> Eli> character and character strings, something that GDB sources aren't
>> Eli> equipped for doing, at least not easily. AFAIK, Cygwin alleviates
>> Eli> that by using UTF-8 encoded strings, but native Windows programming
>> Eli> cannot (yet) do that safely enough on all supported Windows versions.
>>
>> It looks like windows-nat.c defines __USEWIDE only for Cygwin, and then
>> is careful to use the *W forms of various Windows APIs. So maybe it
>> works ok in practice?
>
> I doubt it, in general, because GDB uses 'char *' for strings, and
> those won't work in *W APIs without an explicit conversion to wchar_t.
>
> However, I see only 2 calls to *W APIs in windows-nat.c, and they are
> both under the __CYGWIN__ condition. So I think we are good.
>
>> Eli> As long as MinGW builds of GDB support only the so-called "ANSI"
>> Eli> encoding (i.e. the current system codepage), there's no reason to use
>> Eli> __USEWIDE in the MinGW build of GDB, and every reason not to use it.
>>
>> Yeah, I think __USEWIDE is not used for mingw. However I wonder if we
>> could remove it for Cygwin as well... that would clean up some code.
>> Not a huge amount, but every Cygwin divergence is a bit of a pain.
>
> This will need a Cygwin expert, which I'm not.
I think that would be a step backwards.
The reasons for this code seem to have been discussed, back when it was
added [1].
I think we must use the *W() API variants on cygwin, so that the paths
can be losslessly converted char * encoded in cygwin's conception of the
locale (which is not the Windows codepage, and may not be representable
as one).
The only way I can think of this to be unified is to always use the *W()
API variants, keep that data which is internal to windows-nat in WCHAR,
and convert to a displayable name for the rest of gdb using wcstombs()
(on cygwin) or WideCharToMultiByte() on Windows.
[1] https://sourceware.org/pipermail/gdb-patches/2010-February/072173.html
next prev parent reply other threads:[~2022-06-02 14:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 19:17 [PATCH 0/9] Windows thread names Tom Tromey
2022-04-13 19:17 ` [PATCH 1/9] Fix possible Cygwin build problem Tom Tromey
2022-05-21 11:18 ` Jon Turney
2022-05-21 12:31 ` Eli Zaretskii
2022-05-26 17:00 ` Tom Tromey
2022-05-26 19:04 ` Eli Zaretskii
2022-06-02 14:12 ` Jon Turney [this message]
2022-06-02 16:04 ` Eli Zaretskii
2022-04-13 19:17 ` [PATCH 2/9] Don't call QUIT in read_string Tom Tromey
2022-04-13 19:17 ` [PATCH 3/9] Rename read_string Tom Tromey
2022-04-13 19:17 ` [PATCH 4/9] Remove the byte order parameter to target_read_string Tom Tromey
2022-04-13 19:17 ` [PATCH 5/9] Move target_read_string to target/target.c Tom Tromey
2022-04-13 19:17 ` [PATCH 6/9] Share handle_ms_vc_exception with gdbserver Tom Tromey
2022-04-13 19:17 ` [PATCH 7/9] Implement thread_name for gdbserver Tom Tromey
2022-04-13 19:17 ` [PATCH 8/9] Set the worker thread name on Windows Tom Tromey
2022-04-13 19:17 ` [PATCH 9/9] Use GetThreadDescription " Tom Tromey
2022-04-13 19:33 ` Eli Zaretskii
2022-04-14 5:26 ` Eli Zaretskii
2022-04-14 13:17 ` Tom Tromey
2022-04-14 13:51 ` Eli Zaretskii
2022-04-14 18:20 ` Tom Tromey
2022-04-14 18:18 ` Tom Tromey
2022-04-14 13:58 ` [PATCH 0/9] Windows thread names 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=a3e4dfab-d458-920e-f59e-e1fe7bca33bf@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).