diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2020-01-17 15:28:09 +0100 |
---|---|---|
committer | Hannes Domani <ssbssa@yahoo.de> | 2020-02-09 12:14:51 +0100 |
commit | 7928d571c5f742a10d98b0de0ef85284c5959845 (patch) | |
tree | 3a728942f516e96dc543fc73b17b848f7aa9849d /gdb/windows-nat.c | |
parent | 98d3eb9390ef5eca14200c424f22812982c06b19 (diff) | |
download | gdb-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 'gdb/windows-nat.c')
-rw-r--r-- | gdb/windows-nat.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 366c98f..76fcdd6 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -236,6 +236,7 @@ static DEBUG_EVENT current_event; /* The current debug event from WaitForDebugEvent */ static HANDLE current_process_handle; /* Currently executing process */ static windows_thread_info *current_thread; /* Info on currently selected thread */ +static EXCEPTION_RECORD siginfo_er; /* Contents of $_siginfo */ /* Counts of things. */ static int exception_count = 0; @@ -1167,6 +1168,8 @@ handle_exception (struct target_waitstatus *ourstatus) DWORD code = rec->ExceptionCode; handle_exception_result result = HANDLE_EXCEPTION_HANDLED; + memcpy (&siginfo_er, rec, sizeof siginfo_er); + ourstatus->kind = TARGET_WAITKIND_STOPPED; /* Record the context of the current thread. */ @@ -2863,6 +2866,7 @@ windows_nat_target::mourn_inferior () CHECK (CloseHandle (current_process_handle)); open_process_used = 0; } + siginfo_er.ExceptionCode = 0; inf_child_target::mourn_inferior (); } @@ -2996,6 +3000,30 @@ windows_xfer_shared_libraries (struct target_ops *ops, return len != 0 ? TARGET_XFER_OK : TARGET_XFER_EOF; } +/* Helper for windows_nat_target::xfer_partial that handles signal info. */ + +static enum target_xfer_status +windows_xfer_siginfo (gdb_byte *readbuf, ULONGEST offset, ULONGEST len, + ULONGEST *xfered_len) +{ + if (siginfo_er.ExceptionCode == 0) + return TARGET_XFER_E_IO; + + if (readbuf == nullptr) + return TARGET_XFER_E_IO; + + if (offset > sizeof (siginfo_er)) + return TARGET_XFER_E_IO; + + if (offset + len > sizeof (siginfo_er)) + len = sizeof (siginfo_er) - offset; + + memcpy (readbuf, (char *) &siginfo_er + offset, len); + *xfered_len = len; + + return TARGET_XFER_OK; +} + enum target_xfer_status windows_nat_target::xfer_partial (enum target_object object, const char *annex, gdb_byte *readbuf, @@ -3011,6 +3039,9 @@ windows_nat_target::xfer_partial (enum target_object object, return windows_xfer_shared_libraries (this, object, annex, readbuf, writebuf, offset, len, xfered_len); + case TARGET_OBJECT_SIGNAL_INFO: + return windows_xfer_siginfo (readbuf, offset, len, xfered_len); + default: if (beneath () == NULL) { |