aboutsummaryrefslogtreecommitdiff
path: root/gdb/windows-tdep.h
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/windows-tdep.h
parent3810f182ee3b14d36b37938e897ea871f1175b46 (diff)
downloadbinutils-0f2265e2461babf685ff14f4ec9a9c60898453fe.zip
binutils-0f2265e2461babf685ff14f4ec9a9c60898453fe.tar.gz
binutils-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/windows-tdep.h')
-rw-r--r--gdb/windows-tdep.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index f2dc426..cd7717b 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -31,9 +31,18 @@ extern void windows_xfer_shared_library (const char* so_name,
struct gdbarch *gdbarch,
struct obstack *obstack);
+/* To be called from the various GDB_OSABI_WINDOWS handlers for the
+ various Windows architectures and machine types. */
+
extern void windows_init_abi (struct gdbarch_info info,
struct gdbarch *gdbarch);
+/* To be called from the various GDB_OSABI_CYGWIN handlers for the
+ various Windows architectures and machine types. */
+
+extern void cygwin_init_abi (struct gdbarch_info info,
+ struct gdbarch *gdbarch);
+
/* Return true if the Portable Executable behind ABFD uses the Cygwin dll
(cygwin1.dll). */