[PATCH 1/4] Add sniffer for Cygwin x86_64 core dumps
Jon Turney
jon.turney@dronecode.org.uk
Wed Aug 12 19:18:13 GMT 2020
Similarly to existing i386_cygwin_core_osabi_sniffer()
gdb/ChangeLog:
2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
* amd64-windows-tdep.c (amd64_cygwin_core_osabi_sniffer): New.
(_initialize_amd64_windows_tdep): Register amd64_cygwin_core_osabi_sniffer.
---
gdb/ChangeLog | 5 +++++
gdb/amd64-windows-tdep.c | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 487dfd45fc7..e55d021b6c0 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -42,6 +42,8 @@ static int amd64_windows_dummy_call_integer_regs[] =
AMD64_R9_REGNUM /* %r9 */
};
+#define AMD64_WINDOWS_SIZEOF_GREGSET 1232
+
/* Return nonzero if an argument of type TYPE should be passed
via one of the integer registers. */
@@ -1276,6 +1278,24 @@ amd64_windows_osabi_sniffer (bfd *abfd)
return GDB_OSABI_WINDOWS;
}
+static enum gdb_osabi
+amd64_cygwin_core_osabi_sniffer (bfd *abfd)
+{
+ const char *target_name = bfd_get_target (abfd);
+
+ /* Cygwin uses elf core dumps. Do not claim all ELF executables,
+ check whether there is a .reg section of proper size. */
+ if (strcmp (target_name, "elf64-x86-64") == 0)
+ {
+ asection *section = bfd_get_section_by_name (abfd, ".reg");
+ if (section != nullptr
+ && bfd_section_size (section) == AMD64_WINDOWS_SIZEOF_GREGSET)
+ return GDB_OSABI_CYGWIN;
+ }
+
+ return GDB_OSABI_UNKNOWN;
+}
+
void _initialize_amd64_windows_tdep ();
void
_initialize_amd64_windows_tdep ()
@@ -1287,4 +1307,9 @@ _initialize_amd64_windows_tdep ()
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour,
amd64_windows_osabi_sniffer);
+
+ /* Cygwin uses elf core dumps. */
+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+ amd64_cygwin_core_osabi_sniffer);
+
}
--
2.28.0
More information about the Gdb-patches
mailing list