aboutsummaryrefslogtreecommitdiff
path: root/gdb/amd64-windows-tdep.c
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2020-06-29 16:20:13 +0100
committerJon Turney <jon.turney@dronecode.org.uk>2020-09-18 17:12:08 +0100
commit7d155da3d945350fb40e12c64511e0d719df3137 (patch)
tree0a3a48d364c32d4d3bbd0de6875c648fdd0f65d7 /gdb/amd64-windows-tdep.c
parente8ef12b99666ef6f84f4c7601dc76ae351e453f2 (diff)
downloadgdb-7d155da3d945350fb40e12c64511e0d719df3137.zip
gdb-7d155da3d945350fb40e12c64511e0d719df3137.tar.gz
gdb-7d155da3d945350fb40e12c64511e0d719df3137.tar.bz2
Add sniffer for Cygwin x86_64 core dumps
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.
Diffstat (limited to 'gdb/amd64-windows-tdep.c')
-rw-r--r--gdb/amd64-windows-tdep.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 487dfd4..e55d021 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);
+
}