From 8c7f7542ea10f9d113176b4ea87913795c2433c6 Mon Sep 17 00:00:00 2001 From: Hannes Domani Date: Thu, 31 Jan 2019 01:48:57 +0100 Subject: [PATCH 5/6] Add $_siginfo for minidump. --- bfd/coffgen.c | 8 ++++++++ gdb/windows-tdep.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 5b5c53c7ba..856bcf5544 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -3593,6 +3593,14 @@ coff_core_file_p (bfd *abfd) if (!sec) goto fail; + sec = make_bfd_asection (abfd, ".coreexception", + SEC_HAS_CONTENTS, + exceptionRva + 8, + sizeof exception.record, + 0); + if (!sec) + goto fail; + exceptionThreadId = exception.threadId; /* some exception codes are bigger than INT_MAX, so this makes sure diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 03755a1244..dc583cb2c0 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -983,6 +983,49 @@ windows_gdb_signal_from_target (struct gdbarch *gdbarch, return GDB_SIGNAL_UNKNOWN; } +static LONGEST +windows_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, + ULONGEST offset, ULONGEST len) +{ + asection *section = bfd_get_section_by_name (core_bfd, ".coreexception"); + if (section == NULL) + return -1; + + /* The exception record of the minidump file is always in 64bit format. */ + if (gdbarch_ptr_bit (gdbarch) == 32) + { + uint32_t rec[38]; + int r; + +#define EXC_SIZE_32 80 +#define EXC_SIZE_64 152 + + if (offset > EXC_SIZE_32) + return -1; + + if (bfd_section_size (section) != EXC_SIZE_64) + return -1; + + if (!bfd_get_section_contents (core_bfd, section, rec, 0, EXC_SIZE_64)) + return -1; + + for (r = 2; r < 19; r++) + rec[r + 1] = rec[r * 2]; + + if (len > EXC_SIZE_32 - offset) + len = EXC_SIZE_32 - offset; + + memcpy (readbuf, (char *) rec + offset, len); + + return len; + } + + if (!bfd_get_section_contents (core_bfd, section, readbuf, offset, len)) + return -1; + + return len; +} + /* To be called from the various GDB_OSABI_CYGWIN handlers for the various Windows architectures and machine types. */ @@ -1011,6 +1054,7 @@ windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str); set_gdbarch_gdb_signal_from_target (gdbarch, windows_gdb_signal_from_target); + set_gdbarch_core_xfer_siginfo (gdbarch, windows_core_xfer_siginfo); } /* Implementation of `tlb' variable. */ -- 2.15.1.windows.2