aboutsummaryrefslogtreecommitdiff
path: root/gdb/amd64-windows-tdep.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-04-08 14:05:54 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2020-04-08 14:05:54 -0400
commit0f2265e2461babf685ff14f4ec9a9c60898453fe (patch)
tree9a305d08647704c5c4cba68dcbd000e9f35b95df /gdb/amd64-windows-tdep.c
parent3810f182ee3b14d36b37938e897ea871f1175b46 (diff)
downloadgdb-0f2265e2461babf685ff14f4ec9a9c60898453fe.zip
gdb-0f2265e2461babf685ff14f4ec9a9c60898453fe.tar.gz
gdb-0f2265e2461babf685ff14f4ec9a9c60898453fe.tar.bz2
gdb: stop using host-dependent signal numbers in windows-tdep.c
The signal enumeration in windows-tdep.c is defined differently whether it is compiled on Cygwin or not. This is problematic, since the code in tdep files is not supposed to be influenced by the host platform (the platform GDB itself runs on). This makes a difference in windows_gdb_signal_to_target. An obvious example of clash is SIGABRT. Let's pretend we are cross-debugging a Cygwin process from a MinGW (non-Cygwin Windows) GDB. If GDB needs to translate the gdb signal number GDB_SIGNAL_ABRT into a target equivalent, it would obtain the MinGW number (22), despite the target being a Cygwin process. Conversely, if debugging a MinGW process from a Cygwin-hosted GDB, GDB_SIGNAL_ABRT would be converted to a Cygwin signal number (6) despite the target being a MinGW process. This is wrong, since we want the result to depend on the target's platform, not GDB's platform. This known flaw was accepted because at the time we had a single OS ABI (called Cygwin) for all Windows binaries (Cygwin ones and non-Cygwin ones). This limitation is now lifted, as we now have separate Windows and Cygwin OS ABIs. This means we are able to detect at runtime whether the binary we are debugging is a Cygwin one or non-Cygwin one. This patch splits the signal enum in two, one for the MinGW flavors and one for Cygwin, removing all the ifdefs that made it depend on the host platform. It then makes two separate gdb_signal_to_target gdbarch methods, that are used according to the OS ABI selected at runtime. There is a bit of re-shuffling needed in how the gdbarch'es are initialized, but nothing major. gdb/ChangeLog: * windows-tdep.h (windows_init_abi): Add comment. (cygwin_init_abi): New declaration. * windows-tdep.c: Split signal enumeration in two, one for Windows and one for Cygwin. (windows_gdb_signal_to_target): Only deal with signal of the Windows OS ABI. (cygwin_gdb_signal_to_target): New function. (windows_init_abi): Rename to windows_init_abi_common, don't set gdb_signal_to_target gdbarch method. Add new new function with this name. (cygwin_init_abi): New function. * amd64-windows-tdep.c (amd64_windows_init_abi_common): Add comment. Don't call windows_init_abi. (amd64_windows_init_abi): Add comment, call windows_init_abi. (amd64_cygwin_init_abi): Add comment, call cygwin_init_abi. * i386-windows-tdep.c (i386_windows_init_abi): Rename to i386_windows_init_abi_common, don't call windows_init_abi. Add a new function of this name. (i386_cygwin_init_abi): New function. (_initialize_i386_windows_tdep): Bind i386_cygwin_init_abi to OS ABI Cygwin.
Diffstat (limited to 'gdb/amd64-windows-tdep.c')
-rw-r--r--gdb/amd64-windows-tdep.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 6d5076d..740152b 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -1208,6 +1208,8 @@ amd64_windows_auto_wide_charset (void)
return "UTF-16";
}
+/* Common parts for gdbarch initialization for Windows and Cygwin on AMD64. */
+
static void
amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch)
{
@@ -1227,8 +1229,6 @@ amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch)
amd64_init_abi (info, gdbarch,
amd64_target_description (X86_XSTATE_SSE_MASK, false));
- windows_init_abi (info, gdbarch);
-
/* Function calls. */
set_gdbarch_push_dummy_call (gdbarch, amd64_windows_push_dummy_call);
set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
@@ -1241,19 +1241,25 @@ amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_auto_wide_charset (gdbarch, amd64_windows_auto_wide_charset);
}
+/* gdbarch initialization for Windows on AMD64. */
+
static void
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
amd64_windows_init_abi_common (info, gdbarch);
+ windows_init_abi (info, gdbarch);
/* On Windows, "long"s are only 32bit. */
set_gdbarch_long_bit (gdbarch, 32);
}
+/* gdbarch initialization for Cygwin on AMD64. */
+
static void
amd64_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
amd64_windows_init_abi_common (info, gdbarch);
+ cygwin_init_abi (info, gdbarch);
}
static gdb_osabi