Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: tromey@redhat.com, gdb-patches@sourceware.org
Subject: Re: [10/10] RFC: remove gdb_wait.h
Date: Fri, 16 Nov 2012 08:18:00 -0000	[thread overview]
Message-ID: <83txsqrmfu.fsf@gnu.org> (raw)
In-Reply-To: <20121115210828.GG3790@adacore.com>

> Date: Thu, 15 Nov 2012 13:08:28 -0800
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
> 
> > This could break the MinGW build some day, or maybe even today: its
> > definition of WIFSIGNALED and WIFEXITED is inaccurate for Windows.
> > 
> > I say "some day" because it looks like we don't actually use
> > WIFSIGNALED in any file that is compiled on Windows (not sure about
> > WIFEXITED, though).
> 
> In that case, let's be proactive and contribute a patch to gnulib?
> You seem to know what the problem is, so you'd be the best candidate.

With my previous Windows-related contribution to gnulib collecting
dust since January, without any reason (the RM agreed that the code
was correct and should be admitted), why would I bother to submit
another one?

The problem is that the definition of WIFSIGNALED is naive and
incorrect for most Windows programs.  It will cause any program that
does "exit(3);" be considered as exited due to a signal SIGTERM.  And
WIFEXITED, being defined as everything but WIFSIGNALED, is
consequently also incorrect.

The truth is described in the MSDN documentation of
GetExitCodeProcess:

  If the process has terminated and the function succeeds, the status
  returned is one of the following values:

    . The exit value specified in the ExitProcess or TerminateProcess
      function.
    . The return value from the main or WinMain function of the process.
    . The exception value for an unhandled exception that caused the
      process to terminate.

This is how I translated this documentation in my port of GNU
Findutils:

  #define WEXITSTATUS(w)  ((w) & ~0xC0000000)
  #define WIFEXITED(w)    (((w) & 0xC0000000) == 0)
  #define WTERMSIG(w)     (w)
  #define WIFSIGNALED(w)  (((w) & 0xC0000000) != 0)
  #define WIFSTOPPED(w)   (0)

To produce a human-readable description of WTERMSIG, one then needs to
compare its value with the EXCEPTION_* macros defined on winbase.h
header in the w32 API headers, or convert them to Posix signals like
what handle_exception in windows-nat.c and in win32-low.c do.  E.g.,
the value 0xc0000005 means Access Violation, a.k.a. "SIGSEGV".


  reply	other threads:[~2012-11-16  8:18 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 19:09 [0/10] RFC: use gnulib more heavily + more configure fixes Tom Tromey
2012-11-15 19:11 ` Tom Tromey
2012-11-15 19:14 ` [1/10] RFC: update gnulib Tom Tromey
2012-11-15 19:19   ` Joel Brobecker
2012-11-15 19:15 ` [0/10] RFC: use gnulib more heavily + more configure fixes Eli Zaretskii
2012-11-15 19:22 ` [3/10] RFC: remove gdb_dirent.h Tom Tromey
2012-11-16  2:46   ` Joel Brobecker
2012-11-27 20:11     ` Tom Tromey
2012-11-15 19:25 ` [4/10] RFC: unconditionally include signal.h Tom Tromey
2012-11-16 17:18   ` Pedro Alves
2012-11-17  1:25     ` Joel Brobecker
2012-11-17  8:15       ` Eli Zaretskii
2012-11-19 15:05         ` Pedro Alves
2012-11-27 20:14     ` Tom Tromey
2012-11-15 19:26 ` [5/10] RFC: don't check for stddef.h Tom Tromey
2012-11-15 19:28 ` [6/10] RFC: don't check for stdlib.h Tom Tromey
2012-11-15 19:29 ` [7/10] RFC: don't check for unistd.h Tom Tromey
2012-11-15 19:31 ` [8/10] RFC: don't check for sys/types.h Tom Tromey
2012-11-15 19:33 ` [9/10] RFC: remove gdb_stat.h Tom Tromey
2012-11-15 19:33 ` [2/10] RFC: remove gdb_string.h Tom Tromey
2012-11-15 20:08   ` Eli Zaretskii
2012-11-15 20:22     ` Tom Tromey
2012-11-15 20:34       ` Eli Zaretskii
2012-11-16  2:42   ` Joel Brobecker
2012-11-15 20:32 ` [10/10] RFC: remove gdb_wait.h Tom Tromey
2012-11-15 20:54   ` Eli Zaretskii
2012-11-15 21:08     ` Joel Brobecker
2012-11-16  8:18       ` Eli Zaretskii [this message]
2012-11-16 14:45         ` Joel Brobecker
2012-11-16 15:39           ` Eli Zaretskii
2012-11-16 17:28   ` Pedro Alves
2012-11-16 17:52     ` Eli Zaretskii
2012-11-16 18:10       ` Pedro Alves
2012-11-16 18:26         ` Eli Zaretskii
2012-11-17  2:30     ` Joel Brobecker
2012-11-19 15:09       ` Pedro Alves
2012-11-16 17:55 ` [0/10] RFC: use gnulib more heavily + more configure fixes Pedro Alves
2012-11-27 21:24   ` Tom Tromey
2012-12-10 20:41     ` Tom Tromey
2012-12-11  3:11       ` Joel Brobecker
2012-12-11 10:53       ` Pedro Alves
2012-12-17 19:39         ` Tom Tromey
2013-01-03 18:25       ` Tom Tromey
2013-01-03 18:42         ` Tom Tromey

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=83txsqrmfu.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.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