Re: [RFAv3 2/6] Improve process exit status macros on MinGW

Pedro Alves
2020-01-03T20:08:15Z

On 1/3/20 7:59 PM, Pedro Alves wrote:

> #define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
> #define DebugActiveProcessStop dyn_DebugActiveProcessStop
> @@ -1627,8 +1628,23 @@ get_windows_debug_event (struct target_ops *ops,
> windows_delete_thread (ptid_t (current_event.dwProcessId, 0,
> current_event.dwThreadId),
> 0, true /* main_thread_p */);
> - ourstatus->kind = TARGET_WAITKIND_EXITED;
> - ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode;
> + DWORD exit_status = current_event.u.ExitProcess.dwExitCode;
> + /* If the exit status looks like a fatal exception, but we
> + don't recognize the exception's code, make the original
> + exit status value available, to avoid losing
> + information. */
> + int exit_signal
> + = WIFSIGNALED (exit_status) ? WTERMSIG (exit_status) : -1;
> + if (exit_signal == -1)
> + {
> + ourstatus->kind = TARGET_WAITKIND_EXITED;
> + ourstatus->value.integer = exit_status;
> + }
> + else
> + {
> + ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
> + ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));

I notice now that this should be:

ourstatus->value.sig = gdb_signal_from_host (exit_signal);

I had fixed that on gdbserver, but not on windows-nat.c. And the reason
I didn't notice is that the build tree I was using is only building
gdbserver, not the whole of gdb + gdbserver, and I failed to notice it.
Hopefully the rest of the code will build cleanly without requiring
much more fixing.

Thanks,
Pedro Alves