public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Use strwinerror in gdb/windows-nat.c
Date: Sun, 13 Nov 2022 15:14:14 +0000	[thread overview]
Message-ID: <e441c700-38dd-b333-4cd0-69467bf6a385@dronecode.org.uk> (raw)
In-Reply-To: <87k045484t.fsf@tromey.com>

On 08/11/2022 18:24, Tom Tromey via Gdb-patches wrote:
>>>>>> "Jon" == Jon Turney <jon.turney@dronecode.org.uk> writes:
> 
> Jon> I'd suggest the attached to fix this, but I don't think this qualifies
> Jon> as obvious, since it's not obvious what USE_WIN32API is supposed to
> Jon> mean, so a review would be useful.
> 
> I don't fully know either, but this is what gdbsupport/common.m4 says:
> 
>    case ${host} in
>      *mingw32*)
>        AC_DEFINE(USE_WIN32API, 1,
> 		[Define if we should use the Windows API, instead of the
> 		 POSIX API.  On Windows, we use the Windows API when
> 		 building for MinGW, but the POSIX API when building
> 		 for Cygwin.])
>        WIN32APILIBS="-lws2_32"

Well, yes.  But this seems to mash up a few different things, e.g.:

- using the Windows API for interfacing with the debuggee
- not using any POSIX API
- target is MinGW

> Jon> Commit 02d04eac "Use strwinerror in gdb/windows-nat.c" also moves
> Jon> strwinerror() under the USE_WIN32API conditional, which is not defined
> Jon> for Cygwin (and looks like it shouldn't be, as appears to imply
> Jon> non-POSIX and MiNGW and WinSock...)
> 
> Jon> Also enable the declaration and definition of strwinerror() when
> Jon> __CYGWIN__ is defined.
> 
> I'm not sure how this area ought to work on Cygwin.  The goal here is to
> get a better error message when some Windows API fails.  If Cygwin can
> use strwinerror, then this seems fine.  If not, I could write a patch to

Thanks for reviewing this change.

Cygwin currently uses the Windows Debug API to control the inferior, so 
it's getting Windows error codes back, so turning those into text like 
this is indeed useful.

I'm going to take this as an approval and apply.

(There is a locale issue, in that the Windows idea of the current 
locale, which FormatMessage() uses, is not necessary the same, or even 
in a 1:1 mapping with Cygwin's POSIX-like idea of it, but I think I'll 
ignore that for the moment...)

> stub this out for Cygwin, which would be the status quo ante.

I think the status quo includes that these function would be used in 
gdbserver, if anyone built it for Cygwin, because there weren't under 
USE_WIN32API before.


      reply	other threads:[~2022-11-13 15:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 17:05 Tom Tromey
2022-08-16 13:57 ` Tom Tromey
2022-11-04 14:21   ` Jon Turney
2022-11-08 18:24     ` Tom Tromey
2022-11-13 15:14       ` Jon Turney [this message]

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=e441c700-38dd-b333-4cd0-69467bf6a385@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /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).