aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2020-01-06 11:51:54 +0000
committerPedro Alves <palves@redhat.com>2020-01-06 11:51:54 +0000
commit559e7e5056e0671f2f248e1f9c2af849bfe3e64b (patch)
tree72cbb9abc638d724015998beb33c2341e31ebff8 /gdb/gdbserver
parent49078ece048d0871508218203744f95e68ba5b4a (diff)
downloadfsf-binutils-gdb-559e7e5056e0671f2f248e1f9c2af849bfe3e64b.zip
fsf-binutils-gdb-559e7e5056e0671f2f248e1f9c2af849bfe3e64b.tar.gz
fsf-binutils-gdb-559e7e5056e0671f2f248e1f9c2af849bfe3e64b.tar.bz2
Improve process exit status macros on MinGW
When a Windows program is terminated by a fatal exception, its exit code is the value of that exception, as defined by the various EXCEPTION_* symbols in the Windows API headers. This commit emulates WTERMSIG etc. by translating the fatal exception codes to more-or-less equivalent Posix signals. gdb/ChangeLog: 2020-01-06 Eli Zaretskii <eliz@gnu.org> Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add gdbsupport/gdb_wait.c. * windows-tdep.c: New enumeration of WINDOWS_SIG* signals. (windows_gdb_signal_to_target): New function, uses the above enumeration to convert GDB internal signal codes to equivalent Windows codes. (windows_init_abi): Call set_gdbarch_gdb_signal_to_target. * windows-nat.c: Include "gdb_wait.h". (get_windows_debug_event): Extract the fatal exception from the exit status and convert to the equivalent Posix signal number. * cli/cli-cmds.c (exit_status_set_internal_vars): Account for the possibility that WTERMSIG returns GDB_SIGNAL_UNKNOWN. * gdbsupport/gdb_wait.c: New file, implements windows_status_to_termsig. * gdbsupport/gdb_wait.h (WIFEXITED, WIFSIGNALED, WEXITSTATUS) (WTERMSIG) [__MINGW32__]: Separate definitions for MinGW. gdb/gdbserver/ChangeLog: 2020-01-06 Eli Zaretskii <eliz@gnu.org> Pedro Alves <palves@redhat.com> * win32-low.c (get_child_debug_event): Extract the fatal exception from the exit status and convert to the equivalent Posix signal number. (win32_wait): Allow TARGET_WAITKIND_SIGNALLED status as well. * Makefile.in (OBS, SFILES): Add gdb_wait.[co].
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog9
-rw-r--r--gdb/gdbserver/Makefile.in2
-rw-r--r--gdb/gdbserver/win32-low.c22
3 files changed, 31 insertions, 2 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 4d16083..63778e2 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,12 @@
+2020-01-06 Eli Zaretskii <eliz@gnu.org>
+ Pedro Alves <palves@redhat.com>
+
+ * win32-low.c (get_child_debug_event): Extract the fatal exception
+ from the exit status and convert to the equivalent Posix signal
+ number.
+ (win32_wait): Allow TARGET_WAITKIND_SIGNALLED status as well.
+ * Makefile.in (OBS, SFILES): Add gdb_wait.[co].
+
2020-01-01 Hannes Domani <ssbssa@yahoo.de>
* Makefile.in: Use INSTALL_PROGRAM_ENV.
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index d39c065..1125426 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -217,6 +217,7 @@ SFILES = \
$(srcdir)/gdbsupport/gdb-dlfcn.c \
$(srcdir)/gdbsupport/gdb_tilde_expand.c \
$(srcdir)/gdbsupport/gdb_vecs.c \
+ $(srcdir)/gdbsupport/gdb_wait.c \
$(srcdir)/gdbsupport/netstuff.c \
$(srcdir)/gdbsupport/new-op.c \
$(srcdir)/gdbsupport/pathstuff.c \
@@ -264,6 +265,7 @@ OBS = \
gdbsupport/gdb-dlfcn.o \
gdbsupport/gdb_tilde_expand.o \
gdbsupport/gdb_vecs.o \
+ gdbsupport/gdb_wait.o \
gdbsupport/netstuff.o \
gdbsupport/new-op.o \
gdbsupport/pathstuff.o \
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index b4ee0f4..340f65b 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -34,6 +34,7 @@
#include <process.h>
#include "gdbsupport/gdb_tilde_expand.h"
#include "gdbsupport/common-inferior.h"
+#include "gdbsupport/gdb_wait.h"
#ifndef USE_WIN32API
#include <sys/cygwin.h>
@@ -1511,8 +1512,24 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
"for pid=%u tid=%x\n",
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId));
- 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 (exit_signal);
+ }
+ }
child_continue (DBG_CONTINUE, -1);
CloseHandle (current_process_handle);
current_process_handle = NULL;
@@ -1607,6 +1624,7 @@ win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
win32_clear_inferiors ();
return ptid_t (current_event.dwProcessId);
case TARGET_WAITKIND_STOPPED:
+ case TARGET_WAITKIND_SIGNALLED:
case TARGET_WAITKIND_LOADED:
OUTMSG2 (("Child Stopped with signal = %d \n",
ourstatus->value.sig));