mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-28 20:43:45 +08:00
0f2265e246
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.
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
/* Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef WINDOWS_TDEP_H
|
|
#define WINDOWS_TDEP_H
|
|
|
|
struct obstack;
|
|
struct gdbarch;
|
|
|
|
extern struct cmd_list_element *info_w32_cmdlist;
|
|
|
|
extern void init_w32_command_list (void);
|
|
|
|
extern void windows_xfer_shared_library (const char* so_name,
|
|
CORE_ADDR load_addr,
|
|
CORE_ADDR *text_offset_cached,
|
|
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). */
|
|
|
|
extern bool is_linked_with_cygwin_dll (bfd *abfd);
|
|
|
|
#endif
|