From: Eli Zaretskii <eliz@gnu.org>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA 2/4] Implement | (pipe) command.
Date: Sun, 21 Apr 2019 10:18:00 -0000 [thread overview]
Message-ID: <838sw3acgz.fsf@gnu.org> (raw)
In-Reply-To: <1555839622.6208.17.camel@skynet.be> (message from Philippe Waroquiers on Sun, 21 Apr 2019 11:40:22 +0200)
> From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
> Cc: gdb-patches@sourceware.org
> Date: Sun, 21 Apr 2019 11:40:22 +0200
>
> > > + if (shell_command_status > 0)
> > > + {
> > > + if (WIFEXITED (shell_command_status))
> > > + warning (_("shell command \"%s\" exit status %d"), shell_command,
> > > + WEXITSTATUS (shell_command_status));
> > > + else if (WIFSIGNALED (shell_command_status))
> > > + warning (_("shell command \"%s\" exit with signal %d"), shell_command,
> > > + WTERMSIG (shell_command_status));
> >
> > These macros will need to be ported to MinGW, since the current
> > definitions in gdb_wait.h are for Posix systems (and never used on
> > anything other than that). Gnulib has replacements, but they are less
> > functional on Windows than I'd like them to be, in particular when the
> > shell program exited due to a signal. I can provide better
> > replacements if you want.
> It would be nice to have better replacement for Windows,
> as I do not have the knowledge and needed setup to test
> for this platform.
Here's my proposal:
#define WIFEXITED(stat_val) (((stat_val) & 0xC0000000) == 0)
#define WIFSIGNALED(stat_val) (((stat_val) & 0xC0000000) == 0xC0000000)
#define WEXITSTATUS(stat_val) ((stat_val) & 255)
#define WTERMSIG(stat_val) windows_status_to_termsig (stat_val)
where windows_status_to_termsig should use the xlate[] array defined
in windows-nat.c, like the (ifdef'ed away) code in
windows_nat_target::resume does.
The underlying idea is that when a Windows program is terminated by a
fatal exception, its exit code is the value of that exception, as
defined by the various STATUS_* symbols in the Windows API headers.
The above is not perfect, because a program could legitimately exit
normally with a status whose value happens to have the high bits set,
but that's extremely rare, to say the least, and I think such a
negligibly small probability of false positives is justified by the
utility of reporting the terminating signal in the "normal" cases.
next prev parent reply other threads:[~2019-04-21 10:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-20 21:22 [RFA 0/4] " Philippe Waroquiers
2019-04-20 21:22 ` [RFA 1/4] Add previous_saved_command_line to allow a command to repeat a previous command Philippe Waroquiers
2019-04-24 20:51 ` Tom Tromey
2019-04-20 21:22 ` [RFA 2/4] Implement | (pipe) command Philippe Waroquiers
2019-04-21 5:19 ` Eli Zaretskii
2019-04-21 9:40 ` Philippe Waroquiers
2019-04-21 10:18 ` Eli Zaretskii [this message]
2019-04-22 10:30 ` Philippe Waroquiers
2019-04-22 11:08 ` Eli Zaretskii
2019-04-22 13:15 ` Philippe Waroquiers
2019-04-22 13:21 ` Eli Zaretskii
2019-04-24 20:50 ` Tom Tromey
2019-04-25 5:58 ` Eli Zaretskii
2019-04-20 21:22 ` [RFA 3/4] Test the " Philippe Waroquiers
2019-04-24 20:52 ` Tom Tromey
2019-04-20 21:22 ` [RFA 4/4] NEWS and documentation for " Philippe Waroquiers
2019-04-21 5:22 ` Eli Zaretskii
2019-04-22 20:45 ` [RFA 0/4] Implement " Abhijit Halder
2019-04-22 21:14 ` Philippe Waroquiers
2019-04-24 20:53 ` 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=838sw3acgz.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=philippe.waroquiers@skynet.be \
/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