This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 2/4] Implement | (pipe) command.


On Sun, 2019-04-21 at 13:18 +0300, Eli Zaretskii wrote:
> 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.
Thanks for the above.

To confirm what to do, I will try to explain my current understanding:

Currently, on MingW, the above macros (WIFEXITED, WIFSIGNALED, ...)
are not defined.

So, the idea is to have gdb_wait.h defining them on MingW,
with something like:

#ifndef	WIFEXITED
#if defined (__MINGW32__)
#define WIFEXITED(stat_val)   (((stat_val) & 0xC0000000) == 0)
#else
#define WIFEXITED(w)	(((w)&0377) == 0)
#endif
#endif

Then in windows-nat.c, implement windows_status_to_termsig
that searches in xlate for stat_val & ~0xC0000000 to give
the equivalent signal.

Does the above look reasonable ?

Thanks

Philippe




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]