aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2020-01-17 15:28:09 +0100
committerHannes Domani <ssbssa@yahoo.de>2020-02-09 12:14:51 +0100
commit7928d571c5f742a10d98b0de0ef85284c5959845 (patch)
tree3a728942f516e96dc543fc73b17b848f7aa9849d /gdbserver
parent98d3eb9390ef5eca14200c424f22812982c06b19 (diff)
downloadgdb-7928d571c5f742a10d98b0de0ef85284c5959845.zip
gdb-7928d571c5f742a10d98b0de0ef85284c5959845.tar.gz
gdb-7928d571c5f742a10d98b0de0ef85284c5959845.tar.bz2
Display ExceptionRecord for $_siginfo
Uses the $_siginfo convenience variable to show the last exception. The type looks like this: (gdb) pt $_siginfo type = struct EXCEPTION_RECORD { DWORD ExceptionCode; DWORD ExceptionFlags; struct EXCEPTION_RECORD *ExceptionRecord; PVOID ExceptionAddress; DWORD NumberParameters; ULONG_PTR ExceptionInformation[15]; } EXCEPTION_RECORD is documented at [1]. Example: Program received signal SIGSEGV, Segmentation fault. main () at crasher.c:4 4 *(int*)0x123 = 0; (gdb) p $_siginfo $1 = { ExceptionCode = 3221225477, ExceptionFlags = 0, ExceptionRecord = 0x0, ExceptionAddress = 0x401632 <main+18>, NumberParameters = 2, ExceptionInformation = {1, 291, 0 <repeats 13 times>} } (gdb) p/x $_siginfo.ExceptionCode $2 = 0xc0000005 (gdb) p/x $_siginfo.ExceptionInformation[1] $3 = 0x123 And 0xc0000005 is the value of EXCEPTION_ACCESS_VIOLATION. [1] https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-exception_record gdb/ChangeLog: 2020-02-09 Hannes Domani <ssbssa@yahoo.de> * NEWS: Mention $_siginfo support for Windows. * windows-nat.c (handle_exception): Set siginfo_er. (windows_nat_target::mourn_inferior): Reset siginfo_er. (windows_xfer_siginfo): New function. (windows_nat_target::xfer_partial): Call windows_xfer_siginfo. * windows-tdep.c (struct windows_gdbarch_data): New struct. (init_windows_gdbarch_data): New function. (get_windows_gdbarch_data): New function. (windows_get_siginfo_type): New function. (windows_init_abi): Register windows_get_siginfo_type. (_initialize_windows_tdep): Register init_windows_gdbarch_data. gdbserver/ChangeLog: 2020-02-09 Hannes Domani <ssbssa@yahoo.de> * win32-low.c (win32_clear_inferiors): Reset siginfo_er. (handle_exception): Set siginfo_er. (win32_xfer_siginfo): New function.
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/ChangeLog6
-rw-r--r--gdbserver/win32-low.c30
2 files changed, 35 insertions, 1 deletions
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index a1d6e2a..4f3e8cb 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-09 Hannes Domani <ssbssa@yahoo.de>
+
+ * win32-low.c (win32_clear_inferiors): Reset siginfo_er.
+ (handle_exception): Set siginfo_er.
+ (win32_xfer_siginfo): New function.
+
2020-02-07 Tom Tromey <tom@tromey.com>
Pedro Alves <palves@redhat.com>
diff --git a/gdbserver/win32-low.c b/gdbserver/win32-low.c
index 2c4a9b1..9d03437 100644
--- a/gdbserver/win32-low.c
+++ b/gdbserver/win32-low.c
@@ -75,6 +75,7 @@ static int attaching = 0;
static HANDLE current_process_handle = NULL;
static DWORD current_process_id = 0;
static DWORD main_thread_id = 0;
+static EXCEPTION_RECORD siginfo_er; /* Contents of $_siginfo */
static enum gdb_signal last_sig = GDB_SIGNAL_0;
/* The current debug event from WaitForDebugEvent. */
@@ -801,6 +802,7 @@ win32_clear_inferiors (void)
CloseHandle (current_process_handle);
for_each_thread (delete_thread_info);
+ siginfo_er.ExceptionCode = 0;
clear_inferiors ();
}
@@ -1230,6 +1232,9 @@ handle_exception (struct target_waitstatus *ourstatus)
{
DWORD code = current_event.u.Exception.ExceptionRecord.ExceptionCode;
+ memcpy (&siginfo_er, &current_event.u.Exception.ExceptionRecord,
+ sizeof siginfo_er);
+
ourstatus->kind = TARGET_WAITKIND_STOPPED;
switch (code)
@@ -1772,6 +1777,29 @@ wince_hostio_last_error (char *buf)
}
#endif
+/* Write Windows signal info. */
+
+static int
+win32_xfer_siginfo (const char *annex, unsigned char *readbuf,
+ unsigned const char *writebuf, CORE_ADDR offset, int len)
+{
+ if (siginfo_er.ExceptionCode == 0)
+ return -1;
+
+ if (readbuf == nullptr)
+ return -1;
+
+ if (offset > sizeof (siginfo_er))
+ return -1;
+
+ if (offset + len > sizeof (siginfo_er))
+ len = sizeof (siginfo_er) - offset;
+
+ memcpy (readbuf, (char *) &siginfo_er + offset, len);
+
+ return len;
+}
+
/* Write Windows OS Thread Information Block address. */
static int
@@ -1833,7 +1861,7 @@ static process_stratum_target win32_target_ops = {
hostio_last_error_from_errno,
#endif
NULL, /* qxfer_osdata */
- NULL, /* qxfer_siginfo */
+ win32_xfer_siginfo,
NULL, /* supports_non_stop */
NULL, /* async */
NULL, /* start_non_stop */