2024-01-12 23:30:44 +08:00
|
|
|
/* Copyright (C) 2008-2024 Free Software Foundation, Inc.
|
2009-01-11 21:10:44 +08:00
|
|
|
|
|
|
|
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/>. */
|
|
|
|
|
2009-01-12 09:10:28 +08:00
|
|
|
#include "windows-tdep.h"
|
2024-04-23 04:10:14 +08:00
|
|
|
#include "extract-store-integer.h"
|
2021-12-22 07:38:32 +08:00
|
|
|
#include "gdbsupport/gdb_obstack.h"
|
2009-01-11 21:10:44 +08:00
|
|
|
#include "xml-support.h"
|
2010-04-16 15:49:37 +08:00
|
|
|
#include "gdbarch.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "command.h"
|
2024-04-24 03:22:44 +08:00
|
|
|
#include "cli/cli-cmds.h"
|
2010-04-16 15:49:37 +08:00
|
|
|
#include "gdbthread.h"
|
2012-06-05 21:50:57 +08:00
|
|
|
#include "objfiles.h"
|
2012-12-13 18:44:45 +08:00
|
|
|
#include "symfile.h"
|
|
|
|
#include "coff-pe-read.h"
|
|
|
|
#include "gdb_bfd.h"
|
2013-10-01 21:17:57 +08:00
|
|
|
#include "solib.h"
|
|
|
|
#include "solib-target.h"
|
Teach gdb how to unwind cygwin _sigbe and sigdelayed frames
The majority of functions in the cygwin DLL are wrapped by routines
which use an an alternate stack to return via a signal handler if a
signal occured while inside the function. (See [1],[2])
At present, these frames cannot be correctly unwound by gdb. There
doesn't seem to currently be a way to correctly describe these frames
using DWARF CFI.
So instead, write a custom unwinder for _sigbe and sigdelayed frames,
which gets the return address from the alternate stack.
The offset of tls::stackptr from TIB.stacktop is determined by analyzing
the code in _sigbe or sigdelayed.
This can backtrace from _sigbe and from a sighandler through sigdelayed.
Implemented for amd64 and i386
Issues:
1. We should detect if we are in the wrapper after the return address
has been popped off the alternate stack, and if so, fetch the return
address from the register it's been popped into.
2. If there are multiple _sigbe or sigdelayed stack frames to be
unwound, this only unwinds the first one correctly, because we don't
unwind the value of the alternate stack pointer itself.
This is no worse than currently, when we can't even unwind one of
these frame correctly, but isn't quite correct.
I guess this could be handled by defining a pseudo-register to track
its value as we unwind the stack.
[1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/gendef
[2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/how-signals-work.txt
Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: I4a0d02c1b85d0aadaab2de3abd584eb4bda5b5cc
2016-01-13 06:49:09 +08:00
|
|
|
#include "frame-unwind.h"
|
2015-04-02 20:38:29 +08:00
|
|
|
#include "gdbcore.h"
|
2020-02-13 00:53:32 +08:00
|
|
|
#include "coff/internal.h"
|
|
|
|
#include "libcoff.h"
|
|
|
|
#include "solist.h"
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2020-03-17 04:56:36 +08:00
|
|
|
#define CYGWIN_DLL_NAME "cygwin1.dll"
|
|
|
|
|
2020-01-06 19:51:54 +08:00
|
|
|
/* Windows signal numbers differ between MinGW flavors and between
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
those and Cygwin. The below enumerations were gleaned from the
|
|
|
|
respective headers. */
|
|
|
|
|
|
|
|
/* Signal numbers for the various MinGW flavors. The ones marked with
|
|
|
|
MinGW-w64 are defined by MinGW-w64, not by mingw.org's MinGW. */
|
2020-01-06 19:51:54 +08:00
|
|
|
|
|
|
|
enum
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
{
|
|
|
|
WINDOWS_SIGHUP = 1, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGINT = 2,
|
|
|
|
WINDOWS_SIGQUIT = 3, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGILL = 4,
|
|
|
|
WINDOWS_SIGTRAP = 5, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGIOT = 6, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGEMT = 7, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGFPE = 8,
|
|
|
|
WINDOWS_SIGKILL = 9, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGBUS = 10, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGSEGV = 11,
|
|
|
|
WINDOWS_SIGSYS = 12, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGPIPE = 13, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGALRM = 14, /* MinGW-w64 */
|
|
|
|
WINDOWS_SIGTERM = 15,
|
|
|
|
WINDOWS_SIGBREAK = 21,
|
|
|
|
WINDOWS_SIGABRT = 22,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Signal numbers for Cygwin. */
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CYGWIN_SIGHUP = 1,
|
|
|
|
CYGWIN_SIGINT = 2,
|
|
|
|
CYGWIN_SIGQUIT = 3,
|
|
|
|
CYGWIN_SIGILL = 4,
|
|
|
|
CYGWIN_SIGTRAP = 5,
|
|
|
|
CYGWIN_SIGABRT = 6,
|
|
|
|
CYGWIN_SIGEMT = 7,
|
|
|
|
CYGWIN_SIGFPE = 8,
|
|
|
|
CYGWIN_SIGKILL = 9,
|
|
|
|
CYGWIN_SIGBUS = 10,
|
|
|
|
CYGWIN_SIGSEGV = 11,
|
|
|
|
CYGWIN_SIGSYS = 12,
|
|
|
|
CYGWIN_SIGPIPE = 13,
|
|
|
|
CYGWIN_SIGALRM = 14,
|
|
|
|
CYGWIN_SIGTERM = 15,
|
|
|
|
CYGWIN_SIGURG = 16,
|
|
|
|
CYGWIN_SIGSTOP = 17,
|
|
|
|
CYGWIN_SIGTSTP = 18,
|
|
|
|
CYGWIN_SIGCONT = 19,
|
|
|
|
CYGWIN_SIGCHLD = 20,
|
|
|
|
CYGWIN_SIGTTIN = 21,
|
|
|
|
CYGWIN_SIGTTOU = 22,
|
|
|
|
CYGWIN_SIGIO = 23,
|
|
|
|
CYGWIN_SIGXCPU = 24,
|
|
|
|
CYGWIN_SIGXFSZ = 25,
|
|
|
|
CYGWIN_SIGVTALRM = 26,
|
|
|
|
CYGWIN_SIGPROF = 27,
|
|
|
|
CYGWIN_SIGWINCH = 28,
|
|
|
|
CYGWIN_SIGLOST = 29,
|
|
|
|
CYGWIN_SIGUSR1 = 30,
|
|
|
|
CYGWIN_SIGUSR2 = 31,
|
|
|
|
};
|
2020-01-06 19:51:54 +08:00
|
|
|
|
2020-06-30 00:11:51 +08:00
|
|
|
/* These constants are defined by Cygwin's core_dump.h */
|
|
|
|
static constexpr unsigned int NOTE_INFO_MODULE = 3;
|
|
|
|
static constexpr unsigned int NOTE_INFO_MODULE64 = 4;
|
|
|
|
|
2010-04-16 15:49:37 +08:00
|
|
|
struct cmd_list_element *info_w32_cmdlist;
|
|
|
|
|
|
|
|
typedef struct thread_information_block_32
|
|
|
|
{
|
|
|
|
uint32_t current_seh; /* %fs:0x0000 */
|
|
|
|
uint32_t current_top_of_stack; /* %fs:0x0004 */
|
|
|
|
uint32_t current_bottom_of_stack; /* %fs:0x0008 */
|
|
|
|
uint32_t sub_system_tib; /* %fs:0x000c */
|
|
|
|
uint32_t fiber_data; /* %fs:0x0010 */
|
|
|
|
uint32_t arbitrary_data_slot; /* %fs:0x0014 */
|
|
|
|
uint32_t linear_address_tib; /* %fs:0x0018 */
|
|
|
|
uint32_t environment_pointer; /* %fs:0x001c */
|
|
|
|
uint32_t process_id; /* %fs:0x0020 */
|
|
|
|
uint32_t current_thread_id; /* %fs:0x0024 */
|
|
|
|
uint32_t active_rpc_handle; /* %fs:0x0028 */
|
|
|
|
uint32_t thread_local_storage; /* %fs:0x002c */
|
|
|
|
uint32_t process_environment_block; /* %fs:0x0030 */
|
|
|
|
uint32_t last_error_number; /* %fs:0x0034 */
|
|
|
|
}
|
|
|
|
thread_information_32;
|
|
|
|
|
|
|
|
typedef struct thread_information_block_64
|
|
|
|
{
|
|
|
|
uint64_t current_seh; /* %gs:0x0000 */
|
|
|
|
uint64_t current_top_of_stack; /* %gs:0x0008 */
|
|
|
|
uint64_t current_bottom_of_stack; /* %gs:0x0010 */
|
|
|
|
uint64_t sub_system_tib; /* %gs:0x0018 */
|
|
|
|
uint64_t fiber_data; /* %gs:0x0020 */
|
|
|
|
uint64_t arbitrary_data_slot; /* %gs:0x0028 */
|
|
|
|
uint64_t linear_address_tib; /* %gs:0x0030 */
|
|
|
|
uint64_t environment_pointer; /* %gs:0x0038 */
|
|
|
|
uint64_t process_id; /* %gs:0x0040 */
|
|
|
|
uint64_t current_thread_id; /* %gs:0x0048 */
|
|
|
|
uint64_t active_rpc_handle; /* %gs:0x0050 */
|
|
|
|
uint64_t thread_local_storage; /* %gs:0x0058 */
|
|
|
|
uint64_t process_environment_block; /* %gs:0x0060 */
|
|
|
|
uint64_t last_error_number; /* %gs:0x0068 */
|
|
|
|
}
|
|
|
|
thread_information_64;
|
|
|
|
|
|
|
|
|
|
|
|
static const char* TIB_NAME[] =
|
|
|
|
{
|
|
|
|
" current_seh ", /* %fs:0x0000 */
|
|
|
|
" current_top_of_stack ", /* %fs:0x0004 */
|
|
|
|
" current_bottom_of_stack ", /* %fs:0x0008 */
|
|
|
|
" sub_system_tib ", /* %fs:0x000c */
|
|
|
|
" fiber_data ", /* %fs:0x0010 */
|
|
|
|
" arbitrary_data_slot ", /* %fs:0x0014 */
|
|
|
|
" linear_address_tib ", /* %fs:0x0018 */
|
|
|
|
" environment_pointer ", /* %fs:0x001c */
|
|
|
|
" process_id ", /* %fs:0x0020 */
|
|
|
|
" current_thread_id ", /* %fs:0x0024 */
|
|
|
|
" active_rpc_handle ", /* %fs:0x0028 */
|
|
|
|
" thread_local_storage ", /* %fs:0x002c */
|
|
|
|
" process_environment_block ", /* %fs:0x0030 */
|
|
|
|
" last_error_number " /* %fs:0x0034 */
|
|
|
|
};
|
|
|
|
|
2011-01-12 09:23:29 +08:00
|
|
|
static const int MAX_TIB32 =
|
|
|
|
sizeof (thread_information_32) / sizeof (uint32_t);
|
|
|
|
static const int MAX_TIB64 =
|
|
|
|
sizeof (thread_information_64) / sizeof (uint64_t);
|
2010-04-16 15:49:37 +08:00
|
|
|
static const int FULL_TIB_SIZE = 0x1000;
|
|
|
|
|
Change boolean options to bool instead of int
This is for add_setshow_boolean_cmd as well as the gdb::option interface.
gdb/ChangeLog:
2019-09-17 Christian Biesinger <cbiesinger@google.com>
* ada-lang.c (ada_ignore_descriptive_types_p): Change to bool.
(print_signatures): Likewise.
(trust_pad_over_xvs): Likewise.
* arch/aarch64-insn.c (aarch64_debug): Likewise.
* arch/aarch64-insn.h (aarch64_debug): Likewise.
* arm-linux-nat.c (arm_apcs_32): Likewise.
* arm-linux-tdep.c (arm_apcs_32): Likewise.
* arm-nbsd-nat.c (arm_apcs_32): Likewise.
* arm-tdep.c (arm_debug): Likewise.
(arm_apcs_32): Likewise.
* auto-load.c (debug_auto_load): Likewise.
(auto_load_gdb_scripts): Likewise.
(global_auto_load): Likewise.
(auto_load_local_gdbinit): Likewise.
(auto_load_local_gdbinit_loaded): Likewise.
* auto-load.h (global_auto_load): Likewise.
(auto_load_local_gdbinit): Likewise.
(auto_load_local_gdbinit_loaded): Likewise.
* breakpoint.c (disconnected_dprintf): Likewise.
(breakpoint_proceeded): Likewise.
(automatic_hardware_breakpoints): Likewise.
(always_inserted_mode): Likewise.
(target_exact_watchpoints): Likewise.
(_initialize_breakpoint): Update.
* breakpoint.h (target_exact_watchpoints): Change to bool.
* btrace.c (maint_btrace_pt_skip_pad): Likewise.
* cli/cli-cmds.c (trace_commands): Likewise.
* cli/cli-cmds.h (trace_commands): Likewise.
* cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument
to bool*.
* cli/cli-logging.c (logging_overwrite): Change to bool.
(logging_redirect): Likewise.
(debug_redirect): Likewise.
* cli/cli-option.h (option_def) <boolean>: Change return type to bool*.
(struct boolean_option_def) <get_var_address_cb_>: Change return type
to bool.
<boolean_option_def>: Update.
(struct flag_option_def): Change default type of Context to bool
from int.
<flag_option_def>: Change return type of var_address_cb_ to bool*.
* cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*.
(get_setshow_command_value_string): Likewise.
* cli/cli-style.c (cli_styling): Change to bool.
(source_styling): Likewise.
* cli/cli-style.h (source_styling): Likewise.
(cli_styling): Likewise.
* cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change
to bool.
* command.h (var_types): Update comment.
(add_setshow_boolean_cmd): Change int* var argument to bool*.
* compile/compile-cplus-types.c (debug_compile_cplus_types): Change to
bool.
(debug_compile_cplus_scopes): Likewise.
* compile/compile-internal.h (compile_debug): Likewise.
* compile/compile.c (compile_debug): Likewise.
(struct compile_options) <raw>: Likewise.
* cp-support.c (catch_demangler_crashes): Likewise.
* cris-tdep.c (usr_cmd_cris_version_valid): Likewise.
(usr_cmd_cris_dwarf2_cfi): Likewise.
* csky-tdep.c (csky_debug): Likewise.
* darwin-nat.c (enable_mach_exceptions): Likewise.
* dcache.c (dcache_enabled_p): Likewise.
* defs.h (info_verbose): Likewise.
* demangle.c (demangle): Likewise.
(asm_demangle): Likewise.
* dwarf-index-cache.c (debug_index_cache): Likewise.
* dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise.
* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise.
* dwarf2read.c (check_physname): Likewise.
(use_deprecated_index_sections): Likewise.
(dwarf_always_disassemble): Likewise.
* eval.c (overload_resolution): Likewise.
* event-top.c (set_editing_cmd_var): Likewise.
(exec_done_display_p): Likewise.
* event-top.h (set_editing_cmd_var): Likewise.
(exec_done_display_p): Likewise.
* exec.c (write_files): Likewise.
* fbsd-nat.c (debug_fbsd_lwp): Likewise
(debug_fbsd_nat): Likewise.
* frame.h (struct frame_print_options) <print_raw_frame_arguments>:
Likewise.
(struct set_backtrace_options) <backtrace_past_main>: Likewise.
<backtrace_past_entry> Likewise.
* gdb-demangle.h (demangle): Likewise.
(asm_demangle): Likewise.
* gdb_bfd.c (bfd_sharing): Likewise.
* gdbcore.h (write_files): Likewise.
* gdbsupport/common-debug.c (show_debug_regs): Likewise.
* gdbsupport/common-debug.h (show_debug_regs): Likewise.
* gdbthread.h (print_thread_events): Likewise.
* gdbtypes.c (opaque_type_resolution): Likewise.
(strict_type_checking): Likewise.
* gnu-nat.c (gnu_debug_flag): Likewise.
* guile/scm-auto-load.c (auto_load_guile_scripts): Likewise.
* guile/scm-param.c (pascm_variable): Add boolval.
(add_setshow_generic): Update.
(pascm_param_value): Update.
(pascm_set_param_value_x): Update.
* hppa-tdep.c (hppa_debug): Change to bool..
* infcall.c (may_call_functions_p): Likewise.
(coerce_float_to_double_p): Likewise.
(unwind_on_signal_p): Likewise.
(unwind_on_terminating_exception_p): Likewise.
* infcmd.c (startup_with_shell): Likewise.
* inferior.c (print_inferior_events): Likewise.
* inferior.h (startup_with_shell): Likewise.
(print_inferior_events): Likewise.
* infrun.c (step_stop_if_no_debug): Likewise.
(detach_fork): Likewise.
(debug_displaced): Likewise.
(disable_randomization): Likewise.
(non_stop): Likewise.
(non_stop_1): Likewise.
(observer_mode): Likewise.
(observer_mode_1): Likewise.
(set_observer_mode): Update.
(sched_multi): Change to bool.
* infrun.h (debug_displaced): Likewise.
(sched_multi): Likewise.
(step_stop_if_no_debug): Likewise.
(non_stop): Likewise.
(disable_randomization): Likewise.
* linux-tdep.c (use_coredump_filter): Likewise.
(dump_excluded_mappings): Likewise.
* linux-thread-db.c (auto_load_thread_db): Likewise.
(check_thread_db_on_load): Likewise.
* main.c (captured_main_1): Update.
* maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt,
xx2_opt, boolean_opt>: Change to bool.
* maint-test-settings.c (maintenance_test_settings_boolean): Likewise.
* maint.c (maintenance_profile_p): Likewise.
(per_command_time): Likewise.
(per_command_space): Likewise.
(per_command_symtab): Likewise.
* memattr.c (inaccessible_by_default): Likewise.
* mi/mi-main.c (mi_async): Likewise.
(mi_async_1): Likewise.
* mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise.
* nat/fork-inferior.h (startup_with_shell): Likewise.
* nat/linux-namespaces.c (debug_linux_namespaces): Likewise.
* nat/linux-namespaces.h (debug_linux_namespaces): Likewise.
* nios2-tdep.c (nios2_debug): Likewise.
* or1k-tdep.c (or1k_debug): Likewise.
* parse.c (parser_debug): Likewise.
* parser-defs.h (parser_debug): Likewise.
* printcmd.c (print_symbol_filename): Likewise.
* proc-api.c (procfs_trace): Likewise.
* python/py-auto-load.c (auto_load_python_scripts): Likewise.
* python/py-param.c (union parmpy_variable): Add "bool boolval" field.
(set_parameter_value): Update.
(add_setshow_generic): Update.
* python/py-value.c (copy_py_bool_obj): Change argument from int*
to bool*.
* python/python.c (gdbpy_parameter_value): Cast to bool* instead of
int*.
* ravenscar-thread.c (ravenscar_task_support): Change to bool.
* record-btrace.c (record_btrace_target::store_registers): Update.
* record-full.c (record_full_memory_query): Change to bool.
(record_full_stop_at_limit): Likewise.
* record-full.h (record_full_memory_query): Likewise.
* remote-notif.c (notif_debug): Likewise.
* remote-notif.h (notif_debug): Likewise.
* remote.c (use_range_stepping): Likewise.
(interrupt_on_connect): Likewise.
(remote_break): Likewise.
* ser-tcp.c (tcp_auto_retry): Likewise.
* ser-unix.c (serial_hwflow): Likewise.
* skip.c (debug_skip): Likewise.
* solib-aix.c (solib_aix_debug): Likewise.
* spu-tdep.c (spu_stop_on_load_p): Likewise.
(spu_auto_flush_cache_p): Likewise.
* stack.c (struct backtrace_cmd_options) <full, no_filters, hide>:
Likewise.
(struct info_print_options) <quiet>: Likewise.
* symfile-debug.c (debug_symfile): Likewise.
* symfile.c (auto_solib_add): Likewise.
(separate_debug_file_debug): Likewise.
* symfile.h (auto_solib_add): Likewise.
(separate_debug_file_debug): Likewise.
* symtab.c (basenames_may_differ): Likewise.
(struct filename_partial_match_opts) <dirname, basename>: Likewise.
(struct info_print_options) <quiet, exclude_minsyms>: Likewise.
(struct info_types_options) <quiet>: Likewise.
* symtab.h (demangle): Likewise.
(basenames_may_differ): Likewise.
* target-dcache.c (stack_cache_enabled_1): Likewise.
(code_cache_enabled_1): Likewise.
* target.c (trust_readonly): Likewise.
(may_write_registers): Likewise.
(may_write_memory): Likewise.
(may_insert_breakpoints): Likewise.
(may_insert_tracepoints): Likewise.
(may_insert_fast_tracepoints): Likewise.
(may_stop): Likewise.
(auto_connect_native_target): Likewise.
(target_stop_and_wait): Update.
(target_async_permitted): Change to bool.
(target_async_permitted_1): Likewise.
(may_write_registers_1): Likewise.
(may_write_memory_1): Likewise.
(may_insert_breakpoints_1): Likewise.
(may_insert_tracepoints_1): Likewise.
(may_insert_fast_tracepoints_1): Likewise.
(may_stop_1): Likewise.
* target.h (target_async_permitted): Likewise.
(may_write_registers): Likewise.
(may_write_memory): Likewise.
(may_insert_breakpoints): Likewise.
(may_insert_tracepoints): Likewise.
(may_insert_fast_tracepoints): Likewise.
(may_stop): Likewise.
* thread.c (struct info_threads_opts) <show_global_ids>: Likewise.
(make_thread_apply_all_options_def_group): Change argument from int*
to bool*.
(thread_apply_all_command): Update.
(print_thread_events): Change to bool.
* top.c (confirm): Likewise.
(command_editing_p): Likewise.
(history_expansion_p): Likewise.
(write_history_p): Likewise.
(info_verbose): Likewise.
* top.h (confirm): Likewise.
(history_expansion_p): Likewise.
* tracepoint.c (disconnected_tracing): Likewise.
(circular_trace_buffer): Likewise.
* typeprint.c (print_methods): Likewise.
(print_typedefs): Likewise.
* utils.c (debug_timestamp): Likewise.
(sevenbit_strings): Likewise.
(pagination_enabled): Likewise.
* utils.h (sevenbit_strings): Likewise.
(pagination_enabled): Likewise.
* valops.c (overload_resolution): Likewise.
* valprint.h (struct value_print_options) <prettyformat_arrays,
prettyformat_structs, vtblprint, unionprint, addressprint, objectprint,
stop_print_at_null, print_array_indexes, deref_ref, static_field_print,
pascal_static_field_print, raw, summary, symbol_print, finish_print>:
Likewise.
* windows-nat.c (new_console): Likewise.
(cygwin_exceptions): Likewise.
(new_group): Likewise.
(debug_exec): Likewise.
(debug_events): Likewise.
(debug_memory): Likewise.
(debug_exceptions): Likewise.
(useshell): Likewise.
* windows-tdep.c (maint_display_all_tib): Likewise.
* xml-support.c (debug_xml): Likewise.
2019-09-15 03:36:58 +08:00
|
|
|
static bool maint_display_all_tib = false;
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2020-01-17 22:28:09 +08:00
|
|
|
struct windows_gdbarch_data
|
|
|
|
{
|
2022-06-02 05:31:15 +08:00
|
|
|
struct type *siginfo_type = nullptr;
|
|
|
|
/* Type of thread information block. */
|
|
|
|
struct type *tib_ptr_type = nullptr;
|
2020-01-17 22:28:09 +08:00
|
|
|
};
|
|
|
|
|
2022-06-02 05:31:15 +08:00
|
|
|
static const registry<gdbarch>::key<windows_gdbarch_data>
|
|
|
|
windows_gdbarch_data_handle;
|
2020-01-17 22:28:09 +08:00
|
|
|
|
|
|
|
/* Get windows_gdbarch_data of an arch. */
|
|
|
|
|
|
|
|
static struct windows_gdbarch_data *
|
|
|
|
get_windows_gdbarch_data (struct gdbarch *gdbarch)
|
|
|
|
{
|
2022-06-02 05:31:15 +08:00
|
|
|
windows_gdbarch_data *result = windows_gdbarch_data_handle.get (gdbarch);
|
|
|
|
if (result == nullptr)
|
|
|
|
result = windows_gdbarch_data_handle.emplace (gdbarch);
|
|
|
|
return result;
|
2020-01-17 22:28:09 +08:00
|
|
|
}
|
|
|
|
|
2010-04-16 15:49:37 +08:00
|
|
|
/* Define Thread Local Base pointer type. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
windows_get_tlb_type (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
struct type *dword_ptr_type, *dword32_type, *void_ptr_type;
|
|
|
|
struct type *peb_ldr_type, *peb_ldr_ptr_type;
|
2016-04-19 01:16:27 +08:00
|
|
|
struct type *peb_type, *peb_ptr_type, *list_type;
|
2010-04-16 15:49:37 +08:00
|
|
|
struct type *module_list_ptr_type;
|
|
|
|
struct type *tib_type, *seh_type, *tib_ptr_type, *seh_ptr_type;
|
2019-12-23 23:38:13 +08:00
|
|
|
struct type *word_type, *wchar_type, *wchar_ptr_type;
|
|
|
|
struct type *uni_str_type, *rupp_type, *rupp_ptr_type;
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2020-02-10 00:37:58 +08:00
|
|
|
windows_gdbarch_data *windows_gdbarch_data
|
|
|
|
= get_windows_gdbarch_data (gdbarch);
|
|
|
|
if (windows_gdbarch_data->tib_ptr_type != nullptr)
|
|
|
|
return windows_gdbarch_data->tib_ptr_type;
|
|
|
|
|
2023-03-13 23:53:35 +08:00
|
|
|
type_allocator alloc (gdbarch);
|
|
|
|
|
2023-03-14 00:31:06 +08:00
|
|
|
dword_ptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch),
|
2010-04-16 15:49:37 +08:00
|
|
|
1, "DWORD_PTR");
|
2023-03-14 00:31:06 +08:00
|
|
|
dword32_type = init_integer_type (alloc, 32,
|
2010-04-16 15:49:37 +08:00
|
|
|
1, "DWORD32");
|
2023-03-14 00:31:06 +08:00
|
|
|
word_type = init_integer_type (alloc, 16,
|
2019-12-23 23:38:13 +08:00
|
|
|
1, "WORD");
|
2023-03-14 00:31:06 +08:00
|
|
|
wchar_type = init_integer_type (alloc, 16,
|
2019-12-23 23:38:13 +08:00
|
|
|
1, "wchar_t");
|
2010-04-16 15:49:37 +08:00
|
|
|
void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
|
2023-03-14 02:25:27 +08:00
|
|
|
wchar_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
|
|
|
|
nullptr, wchar_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
/* list entry */
|
|
|
|
|
|
|
|
list_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
list_type->set_name (xstrdup ("list"));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
module_list_ptr_type = void_ptr_type;
|
|
|
|
|
2011-01-12 09:23:29 +08:00
|
|
|
append_composite_type_field (list_type, "forward_list",
|
|
|
|
module_list_ptr_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
append_composite_type_field (list_type, "backward_list",
|
|
|
|
module_list_ptr_type);
|
|
|
|
|
|
|
|
/* Structured Exception Handler */
|
|
|
|
|
|
|
|
seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
seh_type->set_name (xstrdup ("seh"));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2023-03-13 23:53:35 +08:00
|
|
|
seh_ptr_type = alloc.new_type (TYPE_CODE_PTR,
|
|
|
|
void_ptr_type->length () * TARGET_CHAR_BIT,
|
|
|
|
NULL);
|
2022-07-31 00:07:39 +08:00
|
|
|
seh_ptr_type->set_target_type (seh_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
append_composite_type_field (seh_type, "next_seh", seh_ptr_type);
|
2010-04-20 07:52:11 +08:00
|
|
|
append_composite_type_field (seh_type, "handler",
|
|
|
|
builtin_type (gdbarch)->builtin_func_ptr);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
/* struct _PEB_LDR_DATA */
|
|
|
|
peb_ldr_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
peb_ldr_type->set_name (xstrdup ("peb_ldr_data"));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
append_composite_type_field (peb_ldr_type, "length", dword32_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "initialized", dword32_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "ss_handle", void_ptr_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "in_load_order", list_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "in_memory_order", list_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "in_init_order", list_type);
|
|
|
|
append_composite_type_field (peb_ldr_type, "entry_in_progress",
|
|
|
|
void_ptr_type);
|
2023-03-13 23:53:35 +08:00
|
|
|
peb_ldr_ptr_type = alloc.new_type (TYPE_CODE_PTR,
|
|
|
|
void_ptr_type->length () * TARGET_CHAR_BIT,
|
|
|
|
NULL);
|
2022-07-31 00:07:39 +08:00
|
|
|
peb_ldr_ptr_type->set_target_type (peb_ldr_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2019-12-23 23:38:13 +08:00
|
|
|
/* struct UNICODE_STRING */
|
|
|
|
uni_str_type = arch_composite_type (gdbarch, "unicode_string",
|
|
|
|
TYPE_CODE_STRUCT);
|
|
|
|
|
|
|
|
append_composite_type_field (uni_str_type, "length", word_type);
|
|
|
|
append_composite_type_field (uni_str_type, "maximum_length", word_type);
|
|
|
|
append_composite_type_field_aligned (uni_str_type, "buffer",
|
|
|
|
wchar_ptr_type,
|
2022-09-21 23:05:21 +08:00
|
|
|
wchar_ptr_type->length ());
|
2019-12-23 23:38:13 +08:00
|
|
|
|
|
|
|
/* struct _RTL_USER_PROCESS_PARAMETERS */
|
|
|
|
rupp_type = arch_composite_type (gdbarch, "rtl_user_process_parameters",
|
|
|
|
TYPE_CODE_STRUCT);
|
|
|
|
|
|
|
|
append_composite_type_field (rupp_type, "maximum_length", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "length", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "flags", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "debug_flags", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "console_handle", void_ptr_type);
|
|
|
|
append_composite_type_field (rupp_type, "console_flags", dword32_type);
|
|
|
|
append_composite_type_field_aligned (rupp_type, "standard_input",
|
|
|
|
void_ptr_type,
|
2022-09-21 23:05:21 +08:00
|
|
|
void_ptr_type->length ());
|
2019-12-23 23:38:13 +08:00
|
|
|
append_composite_type_field (rupp_type, "standard_output", void_ptr_type);
|
|
|
|
append_composite_type_field (rupp_type, "standard_error", void_ptr_type);
|
|
|
|
append_composite_type_field (rupp_type, "current_directory", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "current_directory_handle",
|
|
|
|
void_ptr_type);
|
|
|
|
append_composite_type_field (rupp_type, "dll_path", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "image_path_name", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "command_line", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "environment", void_ptr_type);
|
|
|
|
append_composite_type_field (rupp_type, "starting_x", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "starting_y", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "count_x", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "count_y", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "count_chars_x", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "count_chars_y", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "fill_attribute", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "window_flags", dword32_type);
|
|
|
|
append_composite_type_field (rupp_type, "show_window_flags", dword32_type);
|
|
|
|
append_composite_type_field_aligned (rupp_type, "window_title",
|
|
|
|
uni_str_type,
|
2022-09-21 23:05:21 +08:00
|
|
|
void_ptr_type->length ());
|
2019-12-23 23:38:13 +08:00
|
|
|
append_composite_type_field (rupp_type, "desktop_info", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "shell_info", uni_str_type);
|
|
|
|
append_composite_type_field (rupp_type, "runtime_data", uni_str_type);
|
|
|
|
|
2023-03-14 02:25:27 +08:00
|
|
|
rupp_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
|
|
|
|
nullptr, rupp_type);
|
2019-12-23 23:38:13 +08:00
|
|
|
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
/* struct process environment block */
|
|
|
|
peb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
peb_type->set_name (xstrdup ("peb"));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
/* First bytes contain several flags. */
|
|
|
|
append_composite_type_field (peb_type, "flags", dword_ptr_type);
|
|
|
|
append_composite_type_field (peb_type, "mutant", void_ptr_type);
|
|
|
|
append_composite_type_field (peb_type, "image_base_address", void_ptr_type);
|
|
|
|
append_composite_type_field (peb_type, "ldr", peb_ldr_ptr_type);
|
2019-12-23 23:38:13 +08:00
|
|
|
append_composite_type_field (peb_type, "process_parameters", rupp_ptr_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
append_composite_type_field (peb_type, "sub_system_data", void_ptr_type);
|
|
|
|
append_composite_type_field (peb_type, "process_heap", void_ptr_type);
|
|
|
|
append_composite_type_field (peb_type, "fast_peb_lock", void_ptr_type);
|
2023-03-13 23:53:35 +08:00
|
|
|
peb_ptr_type = alloc.new_type (TYPE_CODE_PTR,
|
|
|
|
void_ptr_type->length () * TARGET_CHAR_BIT,
|
|
|
|
NULL);
|
2022-07-31 00:07:39 +08:00
|
|
|
peb_ptr_type->set_target_type (peb_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* struct thread information block */
|
|
|
|
tib_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
2020-05-17 00:15:54 +08:00
|
|
|
tib_type->set_name (xstrdup ("tib"));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
/* uint32_t current_seh; %fs:0x0000 */
|
|
|
|
append_composite_type_field (tib_type, "current_seh", seh_ptr_type);
|
|
|
|
/* uint32_t current_top_of_stack; %fs:0x0004 */
|
2011-01-12 09:23:29 +08:00
|
|
|
append_composite_type_field (tib_type, "current_top_of_stack",
|
|
|
|
void_ptr_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
/* uint32_t current_bottom_of_stack; %fs:0x0008 */
|
|
|
|
append_composite_type_field (tib_type, "current_bottom_of_stack",
|
|
|
|
void_ptr_type);
|
|
|
|
/* uint32_t sub_system_tib; %fs:0x000c */
|
|
|
|
append_composite_type_field (tib_type, "sub_system_tib", void_ptr_type);
|
|
|
|
|
|
|
|
/* uint32_t fiber_data; %fs:0x0010 */
|
|
|
|
append_composite_type_field (tib_type, "fiber_data", void_ptr_type);
|
|
|
|
/* uint32_t arbitrary_data_slot; %fs:0x0014 */
|
|
|
|
append_composite_type_field (tib_type, "arbitrary_data_slot", void_ptr_type);
|
|
|
|
/* uint32_t linear_address_tib; %fs:0x0018 */
|
|
|
|
append_composite_type_field (tib_type, "linear_address_tib", void_ptr_type);
|
|
|
|
/* uint32_t environment_pointer; %fs:0x001c */
|
|
|
|
append_composite_type_field (tib_type, "environment_pointer", void_ptr_type);
|
|
|
|
/* uint32_t process_id; %fs:0x0020 */
|
|
|
|
append_composite_type_field (tib_type, "process_id", dword_ptr_type);
|
|
|
|
/* uint32_t current_thread_id; %fs:0x0024 */
|
|
|
|
append_composite_type_field (tib_type, "thread_id", dword_ptr_type);
|
|
|
|
/* uint32_t active_rpc_handle; %fs:0x0028 */
|
|
|
|
append_composite_type_field (tib_type, "active_rpc_handle", dword_ptr_type);
|
|
|
|
/* uint32_t thread_local_storage; %fs:0x002c */
|
2011-01-12 09:23:29 +08:00
|
|
|
append_composite_type_field (tib_type, "thread_local_storage",
|
|
|
|
void_ptr_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
/* uint32_t process_environment_block; %fs:0x0030 */
|
|
|
|
append_composite_type_field (tib_type, "process_environment_block",
|
|
|
|
peb_ptr_type);
|
|
|
|
/* uint32_t last_error_number; %fs:0x0034 */
|
|
|
|
append_composite_type_field (tib_type, "last_error_number", dword_ptr_type);
|
|
|
|
|
2023-03-13 23:53:35 +08:00
|
|
|
tib_ptr_type = alloc.new_type (TYPE_CODE_PTR,
|
|
|
|
void_ptr_type->length () * TARGET_CHAR_BIT,
|
|
|
|
NULL);
|
2022-07-31 00:07:39 +08:00
|
|
|
tib_ptr_type->set_target_type (tib_type);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2020-02-10 00:37:58 +08:00
|
|
|
windows_gdbarch_data->tib_ptr_type = tib_ptr_type;
|
2010-04-30 23:38:42 +08:00
|
|
|
|
2010-04-16 15:49:37 +08:00
|
|
|
return tib_ptr_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The $_tlb convenience variable is a bit special. We don't know
|
|
|
|
for sure the type of the value until we actually have a chance to
|
|
|
|
fetch the data. The type can change depending on gdbarch, so it is
|
|
|
|
also dependent on which thread you have selected. */
|
|
|
|
|
|
|
|
/* This function implements the lval_computed support for reading a
|
|
|
|
$_tlb value. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tlb_value_read (struct value *val)
|
|
|
|
{
|
|
|
|
CORE_ADDR tlb;
|
2023-01-31 22:52:09 +08:00
|
|
|
struct type *type = check_typedef (val->type ());
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
if (!target_get_tib_address (inferior_ptid, &tlb))
|
|
|
|
error (_("Unable to read tlb"));
|
2023-02-01 04:45:40 +08:00
|
|
|
store_typed_address (val->contents_raw ().data (), type, tlb);
|
2010-04-16 15:49:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function implements the lval_computed support for writing a
|
|
|
|
$_tlb value. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tlb_value_write (struct value *v, struct value *fromval)
|
|
|
|
{
|
|
|
|
error (_("Impossible to change the Thread Local Base"));
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:00:20 +08:00
|
|
|
static const struct lval_funcs tlb_value_funcs =
|
2010-04-16 15:49:37 +08:00
|
|
|
{
|
|
|
|
tlb_value_read,
|
|
|
|
tlb_value_write
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Return a new value with the correct type for the tlb object of
|
|
|
|
the current thread using architecture GDBARCH. Return a void value
|
|
|
|
if there's no object available. */
|
|
|
|
|
|
|
|
static struct value *
|
2012-04-28 04:38:39 +08:00
|
|
|
tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
|
2010-04-16 15:49:37 +08:00
|
|
|
{
|
2020-09-29 09:38:25 +08:00
|
|
|
if (target_has_stack () && inferior_ptid != null_ptid)
|
2010-04-16 15:49:37 +08:00
|
|
|
{
|
|
|
|
struct type *type = windows_get_tlb_type (gdbarch);
|
2023-02-01 04:29:49 +08:00
|
|
|
return value::allocate_computed (type, &tlb_value_funcs, NULL);
|
2010-04-16 15:49:37 +08:00
|
|
|
}
|
|
|
|
|
2023-02-01 04:25:17 +08:00
|
|
|
return value::allocate (builtin_type (gdbarch)->builtin_void);
|
2010-04-16 15:49:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Display thread information block of a given thread. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
display_one_tib (ptid_t ptid)
|
|
|
|
{
|
|
|
|
gdb_byte *tib = NULL;
|
|
|
|
gdb_byte *index;
|
|
|
|
CORE_ADDR thread_local_base;
|
|
|
|
ULONGEST i, val, max, max_name, size, tib_size;
|
2023-09-30 02:24:38 +08:00
|
|
|
ULONGEST sizeof_ptr = gdbarch_ptr_bit (current_inferior ()->arch ());
|
|
|
|
bfd_endian byte_order = gdbarch_byte_order (current_inferior ()->arch ());
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
if (sizeof_ptr == 64)
|
|
|
|
{
|
|
|
|
size = sizeof (uint64_t);
|
|
|
|
tib_size = sizeof (thread_information_64);
|
|
|
|
max = MAX_TIB64;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = sizeof (uint32_t);
|
|
|
|
tib_size = sizeof (thread_information_32);
|
|
|
|
max = MAX_TIB32;
|
|
|
|
}
|
|
|
|
|
|
|
|
max_name = max;
|
|
|
|
|
|
|
|
if (maint_display_all_tib)
|
|
|
|
{
|
|
|
|
tib_size = FULL_TIB_SIZE;
|
|
|
|
max = tib_size / size;
|
|
|
|
}
|
|
|
|
|
2015-09-26 02:08:06 +08:00
|
|
|
tib = (gdb_byte *) alloca (tib_size);
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
if (target_get_tib_address (ptid, &thread_local_base) == 0)
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (_("Unable to get thread local base for %s\n"),
|
|
|
|
target_pid_to_str (ptid).c_str ());
|
2010-04-16 15:49:37 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-03-25 06:08:12 +08:00
|
|
|
if (target_read (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY,
|
2010-04-16 15:49:37 +08:00
|
|
|
NULL, tib, thread_local_base, tib_size) != tib_size)
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (_("Unable to read thread information "
|
|
|
|
"block for %s at address %s\n"),
|
|
|
|
target_pid_to_str (ptid).c_str (),
|
2023-09-30 02:24:38 +08:00
|
|
|
paddress (current_inferior ()->arch (), thread_local_base));
|
2010-04-16 15:49:37 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (_("Thread Information Block %s at %s\n"),
|
|
|
|
target_pid_to_str (ptid).c_str (),
|
2023-09-30 02:24:38 +08:00
|
|
|
paddress (current_inferior ()->arch (), thread_local_base));
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
index = (gdb_byte *) tib;
|
|
|
|
|
|
|
|
/* All fields have the size of a pointer, this allows to iterate
|
|
|
|
using the same for loop for both layouts. */
|
|
|
|
for (i = 0; i < max; i++)
|
|
|
|
{
|
|
|
|
val = extract_unsigned_integer (index, size, byte_order);
|
|
|
|
if (i < max_name)
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (_("%s is 0x%s\n"), TIB_NAME[i], phex (val, size));
|
2010-04-16 15:49:37 +08:00
|
|
|
else if (val != 0)
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (_("TIB[0x%s] is 0x%s\n"), phex (i * size, 2),
|
|
|
|
phex (val, size));
|
2010-04-16 15:49:37 +08:00
|
|
|
index += size;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Per-inferior/Inferior-qualified thread IDs
This commit changes GDB to track thread numbers per-inferior. Then,
if you're debugging multiple inferiors, GDB displays
"inferior-num.thread-num" instead of just "thread-num" whenever it
needs to display a thread:
(gdb) info inferiors
Num Description Executable
1 process 6022 /home/pedro/gdb/tests/threads
* 2 process 6037 /home/pedro/gdb/tests/threads
(gdb) info threads
Id Target Id Frame
1.1 Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
1.2 Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
1.3 Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
2.1 Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
2.2 Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
* 2.3 Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
(gdb)
...
(gdb) thread 1.1
[Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
(gdb)
...
etc.
You can still use "thread NUM", in which case GDB infers you're
referring to thread NUM of the current inferior.
The $_thread convenience var and Python's InferiorThread.num attribute
are remapped to the new per-inferior thread number. It's a backward
compatibility break, but since it only matters when debugging multiple
inferiors, I think it's worth doing.
Because MI thread IDs need to be a single integer, we keep giving
threads a global identifier, _in addition_ to the per-inferior number,
and make MI always refer to the global thread IDs. IOW, nothing
changes from a MI frontend's perspective.
Similarly, since Python's Breakpoint.thread and Guile's
breakpoint-thread/set-breakpoint-thread breakpoint methods need to
work with integers, those are adjusted to work with global thread IDs
too. Follow up patches will provide convenient means to access
threads' global IDs.
To avoid potencially confusing users (which also avoids updating much
of the testsuite), if there's only one inferior and its ID is "1",
IOW, the user hasn't done anything multi-process/inferior related,
then the "INF." part of thread IDs is not shown. E.g,.:
(gdb) info inferiors
Num Description Executable
* 1 process 15275 /home/pedro/gdb/tests/threads
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
(gdb) add-inferior
Added inferior 2
(gdb) info threads
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
(gdb)
No regressions on x86_64 Fedora 20.
gdb/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* NEWS: Mention that thread IDs are now per inferior and global
thread IDs.
* Makefile.in (SFILES): Add tid-parse.c.
(COMMON_OBS): Add tid-parse.o.
(HFILES_NO_SRCDIR): Add tid-parse.h.
* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
* breakpoint.c (insert_breakpoint_locations)
(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
(print_one_breakpoint_location, set_longjmp_breakpoint)
(check_longjmp_breakpoint_for_call_dummy)
(set_momentary_breakpoint): Adjust to use global IDs.
(find_condition_and_thread, watch_command_1): Use parse_thread_id.
(until_break_command, longjmp_bkpt_dtor)
(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
to use global IDs.
* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
ptid_to_global_thread_id.
* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
* gdbthread.h (struct thread_info): Rename field 'num' to
'global_num. Add new fields 'per_inf_num' and 'inf'.
(thread_id_to_pid): Rename thread_id_to_pid to
global_thread_id_to_ptid.
(pid_to_thread_id): Rename to ...
(ptid_to_global_thread_id): ... this.
(valid_thread_id): Rename to ...
(valid_global_thread_id): ... this.
(find_thread_id): Rename to ...
(find_thread_global_id): ... this.
(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
(print_thread_info): Add comment.
* tid-parse.h: New file.
* tid-parse.c: New file.
* infcmd.c (step_command_fsm_prepare)
(step_command_fsm_should_stop): Adjust to use the global thread
ID.
(until_next_command, until_next_command)
(finish_command_fsm_should_stop): Adjust to use the global thread
ID.
(attach_post_wait): Adjust to check the inferior number too.
* inferior.h (struct inferior) <highest_thread_num>: New field.
* infrun.c (handle_signal_stop)
(insert_exception_resume_breakpoint)
(insert_exception_resume_from_probe): Adjust to use the global
thread ID.
* record-btrace.c (record_btrace_open): Use global thread IDs.
* remote.c (process_initial_stop_replies): Also consider the
inferior number.
* target.c (target_pre_inferior): Clear the inferior's highest
thread num.
* thread.c (clear_thread_inferior_resources): Adjust to use the
global thread ID.
(new_thread): New inferior parameter. Adjust to use it. Set both
the thread's global ID and the thread's per-inferior ID.
(add_thread_silent): Adjust.
(find_thread_global_id): New.
(find_thread_id): Make static. Adjust to rename.
(valid_thread_id): Rename to ...
(valid_global_thread_id): ... this.
(pid_to_thread_id): Rename to ...
(ptid_to_global_thread_id): ... this.
(thread_id_to_pid): Rename to ...
(global_thread_id_to_ptid): ... this. Adjust.
(first_thread_of_process): Adjust.
(do_captured_list_thread_ids): Adjust to use global thread IDs.
(should_print_thread): New function.
(print_thread_info): Rename to ...
(print_thread_info_1): ... this, and add new show_global_ids
parameter. Handle it. Iterate over inferiors.
(print_thread_info): Reimplement as wrapper around
print_thread_info_1.
(show_inferior_qualified_tids): New function.
(print_thread_id): Use it.
(tp_array_compar): Compare inferior numbers too.
(thread_apply_command): Use tid_range_parser.
(do_captured_thread_select): Use parse_thread_id.
(thread_id_make_value): Adjust.
(_initialize_thread): Adjust "info threads" help string.
* varobj.c (struct varobj_root): Update comment.
(varobj_create): Adjust to use global thread IDs.
(value_of_root_1): Adjust to use global_thread_id_to_ptid.
* windows-tdep.c (display_tib): No longer accept an argument.
* cli/cli-utils.c (get_number_trailer): Make extern.
* cli/cli-utils.h (get_number_trailer): Declare.
(get_number_const): Adjust documentation.
* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
thread IDs.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
Likewise.
* python/py-breakpoint.c (bppy_set_thread): Likewise.
* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
* python/py-infthread.c (thpy_get_num): Add comment and return the
per-inferior thread ID.
(thread_object_getset): Update comment of "num".
gdb/testsuite/ChangeLog:
2016-01-07 Pedro Alves <palves@redhat.com>
* gdb.base/break.exp: Adjust to output changes.
* gdb.base/hbreak2.exp: Likewise.
* gdb.base/sepdebug.exp: Likewise.
* gdb.base/watch_thread_num.exp: Likewise.
* gdb.linespec/keywords.exp: Likewise.
* gdb.multi/info-threads.exp: Likewise.
* gdb.threads/thread-find.exp: Likewise.
* gdb.multi/tids.c: New file.
* gdb.multi/tids.exp: New file.
gdb/doc/ChangeLog:
2016-01-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads): Document per-inferior thread IDs,
qualified thread IDs, global thread IDs and thread ID lists.
(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
thread IDs.
(Convenience Vars): Document the $_thread convenience variable.
(Ada Tasks): Adjust to refer to thread IDs.
(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
Commands, GDB/MI Variable Objects): Update to mention global
thread IDs.
* guile.texi (Breakpoints In Guile)
<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
global thread IDs instead of thread IDs.
* python.texi (Threads In Python): Adjust documentation of
InferiorThread.num.
(Breakpoint.thread): Mention global thread IDs instead of thread
IDs.
2016-01-13 18:56:07 +08:00
|
|
|
/* Display thread information block of the current thread. */
|
2010-04-16 15:49:37 +08:00
|
|
|
|
|
|
|
static void
|
2017-09-10 11:22:05 +08:00
|
|
|
display_tib (const char * args, int from_tty)
|
2010-04-16 15:49:37 +08:00
|
|
|
{
|
2018-06-12 04:45:22 +08:00
|
|
|
if (inferior_ptid != null_ptid)
|
2010-04-16 15:49:37 +08:00
|
|
|
display_one_tib (inferior_ptid);
|
|
|
|
}
|
2009-01-11 21:10:44 +08:00
|
|
|
|
|
|
|
void
|
2009-01-13 12:14:07 +08:00
|
|
|
windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,
|
2019-12-22 00:08:14 +08:00
|
|
|
CORE_ADDR *text_offset_cached,
|
2023-04-13 04:27:01 +08:00
|
|
|
struct gdbarch *gdbarch, std::string &xml)
|
2009-01-11 21:10:44 +08:00
|
|
|
{
|
2019-12-22 00:08:14 +08:00
|
|
|
CORE_ADDR text_offset = text_offset_cached ? *text_offset_cached : 0;
|
2012-12-13 18:44:45 +08:00
|
|
|
|
2023-04-13 04:27:01 +08:00
|
|
|
xml += "<library name=\"";
|
|
|
|
xml_escape_text_append (xml, so_name);
|
|
|
|
xml += "\"><segment address=\"";
|
2019-12-22 00:08:14 +08:00
|
|
|
|
|
|
|
if (!text_offset)
|
|
|
|
{
|
2020-05-20 01:36:24 +08:00
|
|
|
gdb_bfd_ref_ptr dll (gdb_bfd_open (so_name, gnutarget));
|
2019-12-22 00:08:14 +08:00
|
|
|
/* The following calls are OK even if dll is NULL.
|
|
|
|
The default value 0x1000 is returned by pe_text_section_offset
|
|
|
|
in that case. */
|
|
|
|
text_offset = pe_text_section_offset (dll.get ());
|
|
|
|
if (text_offset_cached)
|
|
|
|
*text_offset_cached = text_offset;
|
|
|
|
}
|
|
|
|
|
2023-04-13 04:27:01 +08:00
|
|
|
xml += paddress (gdbarch, load_addr + text_offset);
|
|
|
|
xml += "\"/></library>";
|
2009-01-11 21:10:44 +08:00
|
|
|
}
|
2010-04-16 15:49:37 +08:00
|
|
|
|
2012-06-05 21:50:57 +08:00
|
|
|
/* Implement the "iterate_over_objfiles_in_search_order" gdbarch
|
|
|
|
method. It searches all objfiles, starting with CURRENT_OBJFILE
|
|
|
|
first (if not NULL).
|
|
|
|
|
|
|
|
On Windows, the system behaves a little differently when two
|
|
|
|
objfiles each define a global symbol using the same name, compared
|
|
|
|
to other platforms such as GNU/Linux for instance. On GNU/Linux,
|
|
|
|
all instances of the symbol effectively get merged into a single
|
|
|
|
one, but on Windows, they remain distinct.
|
|
|
|
|
|
|
|
As a result, it usually makes sense to start global symbol searches
|
|
|
|
with the current objfile before expanding it to all other objfiles.
|
|
|
|
This helps for instance when a user debugs some code in a DLL that
|
|
|
|
refers to a global variable defined inside that DLL. When trying
|
|
|
|
to print the value of that global variable, it would be unhelpful
|
|
|
|
to print the value of another global variable defined with the same
|
|
|
|
name, but in a different DLL. */
|
|
|
|
|
2013-10-01 21:17:57 +08:00
|
|
|
static void
|
2012-06-05 21:50:57 +08:00
|
|
|
windows_iterate_over_objfiles_in_search_order
|
2022-05-04 20:14:22 +08:00
|
|
|
(gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
|
|
|
|
objfile *current_objfile)
|
2012-06-05 21:50:57 +08:00
|
|
|
{
|
|
|
|
if (current_objfile)
|
|
|
|
{
|
2022-05-04 20:14:22 +08:00
|
|
|
if (cb (current_objfile))
|
2012-06-05 21:50:57 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Change all_objfiles adapter to be a method on program_space
This changes the all_objfiles range adapter to be a method on the
program space, and fixes up all the users.
gdb/ChangeLog
2019-01-17 Tom Tromey <tom@tromey.com>
* progspace.h (program_space) <objfiles_range>: New typedef.
<objfiles>: New method.
<objfiles_head>: Rename from objfiles.
(object_files): Update.
* guile/scm-progspace.c (gdbscm_progspace_objfiles): Update.
* guile/scm-pretty-print.c
(ppscm_find_pretty_printer_from_objfiles): Update.
* guile/scm-objfile.c (gdbscm_objfiles): Update.
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
Update.
* python/py-progspace.c (pspy_get_objfiles): Update.
* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
Update.
* python/py-objfile.c (objfpy_lookup_objfile_by_name)
(objfpy_lookup_objfile_by_build_id): Update.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Update.
* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
Update.
* symtab.c (iterate_over_symtabs, matching_obj_sections)
(expand_symtab_containing_pc, lookup_objfile_from_block)
(lookup_static_symbol, basic_lookup_transparent_type)
(find_pc_sect_compunit_symtab, find_symbol_at_address)
(find_line_symtab, info_sources_command)
(default_collect_symbol_completion_matches_break_on)
(make_source_files_completion_list, find_main_name): Update.
* symmisc.c (print_symbol_bcache_statistics)
(print_objfile_statistics, maintenance_print_symbols)
(maintenance_print_msymbols, maintenance_print_objfiles)
(maintenance_info_symtabs, maintenance_check_symtabs)
(maintenance_expand_symtabs, maintenance_info_line_tables):
Update.
* symfile.c (remove_symbol_file_command, overlay_invalidate_all)
(find_pc_overlay, find_pc_mapped_section, list_overlays_command)
(map_overlay_command, unmap_overlay_command)
(simple_overlay_update, expand_symtabs_matching)
(map_symbol_filenames): Update.
* symfile-debug.c (set_debug_symfile): Update.
* spu-tdep.c (spu_overlay_update, spu_objfile_from_frame):
Update.
* source.c (select_source_symtab, forget_cached_source_info):
Update.
* solib.c (solib_read_symbols): Update.
* solib-spu.c (append_ocl_sos): Update.
* psymtab.c (maintenance_print_psymbols)
(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
* probe.c (parse_probes_in_pspace, find_probe_by_pc): Update.
* printcmd.c (info_symbol_command): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created):
Update.
* objfiles.h (class all_objfiles): Remove.
* objfiles.c (have_partial_symbols, have_full_symbols)
(have_minimal_symbols, qsort_cmp, update_section_map)
(shared_objfile_contains_address_p)
(default_iterate_over_objfiles_in_search_order): Update.
* objc-lang.c (info_selectors_command, info_classes_command)
(find_methods): Update.
* minsyms.c (find_solib_trampoline_target): Update.
* maint.c (maintenance_info_sections)
(maintenance_translate_address, count_symtabs_and_blocks):
Update.
* main.c (captured_main_1): Update.
* linux-thread-db.c (try_thread_db_load_from_pdir)
(has_libpthread): Update.
* linespec.c (iterate_over_all_matching_symtabs)
(search_minsyms_for_name): Update.
* jit.c (jit_find_objf_with_entry_addr): Update.
* hppa-tdep.c (find_unwind_entry)
(hppa_lookup_stub_minimal_symbol): Update.
* gcore.c (gcore_create_callback, objfile_find_memory_regions):
Update.
* elfread.c (elf_gnu_ifunc_resolve_by_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* dwarf2-frame.c (dwarf2_frame_find_fde): Update.
* dwarf-index-write.c (save_gdb_index_command): Update.
* cp-support.c (add_symbol_overload_list_qualified): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* blockframe.c (find_pc_partial_function): Update.
* ada-lang.c (ada_lookup_simple_minsym, add_nonlocal_symbols)
(ada_collect_symbol_completion_matches)
(ada_add_global_exceptions): Update.
2019-01-16 07:55:05 +08:00
|
|
|
for (objfile *objfile : current_program_space->objfiles ())
|
2022-05-04 20:14:22 +08:00
|
|
|
if (objfile != current_objfile)
|
|
|
|
{
|
|
|
|
if (cb (objfile))
|
|
|
|
return;
|
|
|
|
}
|
2012-06-05 21:50:57 +08:00
|
|
|
}
|
|
|
|
|
2010-04-16 15:49:37 +08:00
|
|
|
static void
|
|
|
|
show_maint_show_all_tib (struct ui_file *file, int from_tty,
|
|
|
|
struct cmd_list_element *c, const char *value)
|
|
|
|
{
|
2022-01-03 02:46:15 +08:00
|
|
|
gdb_printf (file, _("Show all non-zero elements of "
|
|
|
|
"Thread Information Block is %s.\n"), value);
|
2010-04-16 15:49:37 +08:00
|
|
|
}
|
|
|
|
|
2020-04-19 09:28:13 +08:00
|
|
|
|
|
|
|
static int w32_prefix_command_valid = 0;
|
|
|
|
void
|
|
|
|
init_w32_command_list (void)
|
|
|
|
{
|
|
|
|
if (!w32_prefix_command_valid)
|
|
|
|
{
|
|
|
|
add_basic_prefix_cmd
|
|
|
|
("w32", class_info,
|
|
|
|
_("Print information specific to Win32 debugging."),
|
2021-05-12 18:19:22 +08:00
|
|
|
&info_w32_cmdlist, 0, &infolist);
|
2020-04-19 09:28:13 +08:00
|
|
|
w32_prefix_command_valid = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
/* Implementation of `gdbarch_gdb_signal_to_target' for Windows. */
|
2020-01-06 19:51:54 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
windows_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal signal)
|
|
|
|
{
|
|
|
|
switch (signal)
|
|
|
|
{
|
|
|
|
case GDB_SIGNAL_0:
|
|
|
|
return 0;
|
|
|
|
case GDB_SIGNAL_HUP:
|
|
|
|
return WINDOWS_SIGHUP;
|
|
|
|
case GDB_SIGNAL_INT:
|
|
|
|
return WINDOWS_SIGINT;
|
|
|
|
case GDB_SIGNAL_QUIT:
|
|
|
|
return WINDOWS_SIGQUIT;
|
|
|
|
case GDB_SIGNAL_ILL:
|
|
|
|
return WINDOWS_SIGILL;
|
|
|
|
case GDB_SIGNAL_TRAP:
|
|
|
|
return WINDOWS_SIGTRAP;
|
|
|
|
case GDB_SIGNAL_ABRT:
|
|
|
|
return WINDOWS_SIGABRT;
|
|
|
|
case GDB_SIGNAL_EMT:
|
|
|
|
return WINDOWS_SIGEMT;
|
|
|
|
case GDB_SIGNAL_FPE:
|
|
|
|
return WINDOWS_SIGFPE;
|
|
|
|
case GDB_SIGNAL_KILL:
|
|
|
|
return WINDOWS_SIGKILL;
|
|
|
|
case GDB_SIGNAL_BUS:
|
|
|
|
return WINDOWS_SIGBUS;
|
|
|
|
case GDB_SIGNAL_SEGV:
|
|
|
|
return WINDOWS_SIGSEGV;
|
|
|
|
case GDB_SIGNAL_SYS:
|
|
|
|
return WINDOWS_SIGSYS;
|
|
|
|
case GDB_SIGNAL_PIPE:
|
|
|
|
return WINDOWS_SIGPIPE;
|
|
|
|
case GDB_SIGNAL_ALRM:
|
|
|
|
return WINDOWS_SIGALRM;
|
|
|
|
case GDB_SIGNAL_TERM:
|
|
|
|
return WINDOWS_SIGTERM;
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implementation of `gdbarch_gdb_signal_to_target' for Cygwin. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
cygwin_gdb_signal_to_target (struct gdbarch *gdbarch, enum gdb_signal signal)
|
|
|
|
{
|
|
|
|
switch (signal)
|
|
|
|
{
|
|
|
|
case GDB_SIGNAL_0:
|
|
|
|
return 0;
|
|
|
|
case GDB_SIGNAL_HUP:
|
|
|
|
return CYGWIN_SIGHUP;
|
|
|
|
case GDB_SIGNAL_INT:
|
|
|
|
return CYGWIN_SIGINT;
|
|
|
|
case GDB_SIGNAL_QUIT:
|
|
|
|
return CYGWIN_SIGQUIT;
|
|
|
|
case GDB_SIGNAL_ILL:
|
|
|
|
return CYGWIN_SIGILL;
|
|
|
|
case GDB_SIGNAL_TRAP:
|
|
|
|
return CYGWIN_SIGTRAP;
|
|
|
|
case GDB_SIGNAL_ABRT:
|
|
|
|
return CYGWIN_SIGABRT;
|
|
|
|
case GDB_SIGNAL_EMT:
|
|
|
|
return CYGWIN_SIGEMT;
|
|
|
|
case GDB_SIGNAL_FPE:
|
|
|
|
return CYGWIN_SIGFPE;
|
|
|
|
case GDB_SIGNAL_KILL:
|
|
|
|
return CYGWIN_SIGKILL;
|
|
|
|
case GDB_SIGNAL_BUS:
|
|
|
|
return CYGWIN_SIGBUS;
|
|
|
|
case GDB_SIGNAL_SEGV:
|
|
|
|
return CYGWIN_SIGSEGV;
|
|
|
|
case GDB_SIGNAL_SYS:
|
|
|
|
return CYGWIN_SIGSYS;
|
|
|
|
case GDB_SIGNAL_PIPE:
|
|
|
|
return CYGWIN_SIGPIPE;
|
|
|
|
case GDB_SIGNAL_ALRM:
|
|
|
|
return CYGWIN_SIGALRM;
|
|
|
|
case GDB_SIGNAL_TERM:
|
|
|
|
return CYGWIN_SIGTERM;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_URG:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGURG;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_STOP:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGSTOP;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_TSTP:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGTSTP;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_CONT:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGCONT;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_CHLD:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGCHLD;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_TTIN:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGTTIN;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_TTOU:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGTTOU;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_IO:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGIO;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_XCPU:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGXCPU;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_XFSZ:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGXFSZ;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_VTALRM:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGVTALRM;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_PROF:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGPROF;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_WINCH:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGWINCH;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_PWR:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGLOST;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_USR1:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGUSR1;
|
2020-01-06 19:51:54 +08:00
|
|
|
case GDB_SIGNAL_USR2:
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
return CYGWIN_SIGUSR2;
|
2020-01-06 19:51:54 +08:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
struct enum_value_name
|
|
|
|
{
|
|
|
|
uint32_t value;
|
|
|
|
const char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Allocate a TYPE_CODE_ENUM type structure with its named values. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
create_enum (struct gdbarch *gdbarch, int bit, const char *name,
|
|
|
|
const struct enum_value_name *values, int count)
|
|
|
|
{
|
|
|
|
struct type *type;
|
|
|
|
int i;
|
|
|
|
|
2023-03-13 23:53:35 +08:00
|
|
|
type = type_allocator (gdbarch).new_type (TYPE_CODE_ENUM, bit, name);
|
[gdb/symtab] Factor out type::{alloc_fields,copy_fields}
After finding this code in buildsym_compunit::finish_block_internal:
...
ftype->set_fields
((struct field *)
TYPE_ALLOC (ftype, nparams * sizeof (struct field)));
...
and fixing PR30810 by using TYPE_ZALLOC, I wondered if there were more
locations that needed fixing.
I decided to make things easier to spot by factoring out a new function
alloc_fields:
...
/* Allocate the fields array of this type, with NFIELDS elements. If INIT,
zero-initialize the allocated memory. */
void
type::alloc_fields (unsigned int nfields, bool init = true);
...
where:
- a regular use would be "alloc_fields (nfields)", and
- an exceptional use that needed no initialization would be
"alloc_fields (nfields, false)".
Pretty soon I discovered that most of the latter cases are due to
initialization by memcpy, so I added two variants of copy_fields as well.
After this rewrite there are 8 uses of set_fields left:
...
gdb/coffread.c: type->set_fields (nullptr);
gdb/coffread.c: type->set_fields (nullptr);
gdb/coffread.c: type->set_fields (nullptr);
gdb/eval.c: type->set_fields
gdb/gdbtypes.c: type->set_fields (args);
gdb/gdbtypes.c: t->set_fields (XRESIZEVEC (struct field, t->fields (),
gdb/dwarf2/read.c: type->set_fields (new_fields);
gdb/dwarf2/read.c: sub_type->set_fields (sub_type->fields () + 1);
...
These fall into the following categories:
- set to nullptr (coffread.c),
- type not owned by objfile or gdbarch (eval.c), and
- modifying an existing fields array, like adding an element at the end or
dropping an element at the start (the rest).
Tested on x86_64-linux.
2023-08-31 15:37:44 +08:00
|
|
|
type->alloc_fields (count);
|
2020-09-14 23:07:56 +08:00
|
|
|
type->set_is_unsigned (true);
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
2021-05-28 03:01:28 +08:00
|
|
|
{
|
2021-08-30 23:49:48 +08:00
|
|
|
type->field (i).set_name (values[i].name);
|
gdb: add accessors for field (and call site) location
Add accessors for the various location values in struct field. This
lets us assert that when we get a location value of a certain kind (say,
bitpos), the field's location indeed contains a value of that kind.
Remove the SET_FIELD_* macros, instead use the new setters directly.
Update the FIELD_* macros used to access field locations to go through
the getters. They will be removed in a subsequent patch.
There are places where the FIELD_* macros are used on call_site_target
structures, because it contains members of the same name (loc_kind and
loc). For now, I have replicated the getters/setters in
call_site_target. But we could perhaps eventually factor them in a
"location" structure that can be used at both places.
Note that the field structure, being zero-initialized, defaults to a
bitpos location with value 0. While writing this patch, I tried to make
it default to an "unset" location, to catch places where we would miss
setting a field's location. However, I found that some places relied on
the default being "bitpos 0", so I left it as-is. This change could
always be done as follow-up work, making these places explicitly set the
"bitpos 0" location.
I found two issues to fix:
- I got some failures in the gdb.base/infcall-nested-structs-c++.exp
test. They were caused by two functions in amd64-tdep.c using
TYPE_FIELD_BITPOS before checking if the location is of the bitpos
kind, which they do indirectly through `field_is_static`. Simply
move getting the bitpos below the field_is_static call.
- I got a failure in gdb.xml/tdesc-regs.exp. It turns out that in
make_gdb_type_enum, we set enum field values using SET_FIELD_BITPOS,
and later access them through FIELD_ENUMVAL. Fix that by using
set_loc_enumval to set the value.
Change-Id: I53d3734916c46457576ba11dd77df4049d2fc1e8
2021-10-01 10:38:29 +08:00
|
|
|
type->field (i).set_loc_enumval (values[i].value);
|
2021-05-28 03:01:28 +08:00
|
|
|
}
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct enum_value_name exception_values[] =
|
|
|
|
{
|
|
|
|
{ 0x40000015, "FATAL_APP_EXIT" },
|
2020-04-24 23:12:48 +08:00
|
|
|
{ 0x4000001E, "WX86_SINGLE_STEP" },
|
|
|
|
{ 0x4000001F, "WX86_BREAKPOINT" },
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
{ 0x40010005, "DBG_CONTROL_C" },
|
|
|
|
{ 0x40010008, "DBG_CONTROL_BREAK" },
|
|
|
|
{ 0x80000002, "DATATYPE_MISALIGNMENT" },
|
|
|
|
{ 0x80000003, "BREAKPOINT" },
|
|
|
|
{ 0x80000004, "SINGLE_STEP" },
|
|
|
|
{ 0xC0000005, "ACCESS_VIOLATION" },
|
|
|
|
{ 0xC0000006, "IN_PAGE_ERROR" },
|
|
|
|
{ 0xC000001D, "ILLEGAL_INSTRUCTION" },
|
|
|
|
{ 0xC0000025, "NONCONTINUABLE_EXCEPTION" },
|
|
|
|
{ 0xC0000026, "INVALID_DISPOSITION" },
|
|
|
|
{ 0xC000008C, "ARRAY_BOUNDS_EXCEEDED" },
|
|
|
|
{ 0xC000008D, "FLOAT_DENORMAL_OPERAND" },
|
|
|
|
{ 0xC000008E, "FLOAT_DIVIDE_BY_ZERO" },
|
|
|
|
{ 0xC000008F, "FLOAT_INEXACT_RESULT" },
|
|
|
|
{ 0xC0000090, "FLOAT_INVALID_OPERATION" },
|
|
|
|
{ 0xC0000091, "FLOAT_OVERFLOW" },
|
|
|
|
{ 0xC0000092, "FLOAT_STACK_CHECK" },
|
|
|
|
{ 0xC0000093, "FLOAT_UNDERFLOW" },
|
|
|
|
{ 0xC0000094, "INTEGER_DIVIDE_BY_ZERO" },
|
|
|
|
{ 0xC0000095, "INTEGER_OVERFLOW" },
|
|
|
|
{ 0xC0000096, "PRIV_INSTRUCTION" },
|
|
|
|
{ 0xC00000FD, "STACK_OVERFLOW" },
|
|
|
|
{ 0xC0000409, "FAST_FAIL" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct enum_value_name violation_values[] =
|
|
|
|
{
|
|
|
|
{ 0, "READ_ACCESS_VIOLATION" },
|
|
|
|
{ 1, "WRITE_ACCESS_VIOLATION" },
|
|
|
|
{ 8, "DATA_EXECUTION_PREVENTION_VIOLATION" },
|
|
|
|
};
|
|
|
|
|
2020-01-17 22:28:09 +08:00
|
|
|
/* Implement the "get_siginfo_type" gdbarch method. */
|
|
|
|
|
|
|
|
static struct type *
|
|
|
|
windows_get_siginfo_type (struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
struct windows_gdbarch_data *windows_gdbarch_data;
|
|
|
|
struct type *dword_type, *pvoid_type, *ulongptr_type;
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
struct type *code_enum, *violation_enum;
|
|
|
|
struct type *violation_type, *para_type, *siginfo_ptr_type, *siginfo_type;
|
2020-01-17 22:28:09 +08:00
|
|
|
|
|
|
|
windows_gdbarch_data = get_windows_gdbarch_data (gdbarch);
|
|
|
|
if (windows_gdbarch_data->siginfo_type != NULL)
|
|
|
|
return windows_gdbarch_data->siginfo_type;
|
|
|
|
|
2023-03-14 00:31:06 +08:00
|
|
|
type_allocator alloc (gdbarch);
|
|
|
|
dword_type = init_integer_type (alloc, gdbarch_int_bit (gdbarch),
|
2020-01-17 22:28:09 +08:00
|
|
|
1, "DWORD");
|
2023-03-14 02:25:27 +08:00
|
|
|
pvoid_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch), "PVOID",
|
2020-01-17 22:28:09 +08:00
|
|
|
builtin_type (gdbarch)->builtin_void);
|
2023-03-14 00:31:06 +08:00
|
|
|
ulongptr_type = init_integer_type (alloc, gdbarch_ptr_bit (gdbarch),
|
2020-01-17 22:28:09 +08:00
|
|
|
1, "ULONG_PTR");
|
|
|
|
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
/* ExceptionCode value names */
|
|
|
|
code_enum = create_enum (gdbarch, gdbarch_int_bit (gdbarch),
|
|
|
|
"ExceptionCode", exception_values,
|
|
|
|
ARRAY_SIZE (exception_values));
|
|
|
|
|
|
|
|
/* ACCESS_VIOLATION type names */
|
|
|
|
violation_enum = create_enum (gdbarch, gdbarch_ptr_bit (gdbarch),
|
|
|
|
"ViolationType", violation_values,
|
|
|
|
ARRAY_SIZE (violation_values));
|
|
|
|
|
|
|
|
/* ACCESS_VIOLATION information */
|
|
|
|
violation_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
|
|
|
|
append_composite_type_field (violation_type, "Type", violation_enum);
|
|
|
|
append_composite_type_field (violation_type, "Address", pvoid_type);
|
|
|
|
|
|
|
|
/* Unnamed union of the documented field ExceptionInformation,
|
|
|
|
and the alternative AccessViolationInformation (which displays
|
|
|
|
human-readable values for ExceptionCode ACCESS_VIOLATION). */
|
|
|
|
para_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
|
|
|
|
append_composite_type_field (para_type, "ExceptionInformation",
|
|
|
|
lookup_array_range_type (ulongptr_type, 0, 14));
|
|
|
|
append_composite_type_field (para_type, "AccessViolationInformation",
|
|
|
|
violation_type);
|
|
|
|
|
2020-01-17 22:28:09 +08:00
|
|
|
siginfo_type = arch_composite_type (gdbarch, "EXCEPTION_RECORD",
|
|
|
|
TYPE_CODE_STRUCT);
|
2023-03-14 02:25:27 +08:00
|
|
|
siginfo_ptr_type = init_pointer_type (alloc, gdbarch_ptr_bit (gdbarch),
|
|
|
|
nullptr, siginfo_type);
|
2020-01-17 22:28:09 +08:00
|
|
|
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
/* ExceptionCode is documented as type DWORD, but here a helper
|
|
|
|
enum type is used instead to display a human-readable value. */
|
|
|
|
append_composite_type_field (siginfo_type, "ExceptionCode", code_enum);
|
2020-01-17 22:28:09 +08:00
|
|
|
append_composite_type_field (siginfo_type, "ExceptionFlags", dword_type);
|
|
|
|
append_composite_type_field (siginfo_type, "ExceptionRecord",
|
|
|
|
siginfo_ptr_type);
|
|
|
|
append_composite_type_field (siginfo_type, "ExceptionAddress",
|
|
|
|
pvoid_type);
|
|
|
|
append_composite_type_field (siginfo_type, "NumberParameters", dword_type);
|
|
|
|
/* The 64-bit variant needs some padding. */
|
Use enums for human-readable exception information.
Changes to $_siginfo type to this:
(gdb) pt $_siginfo
type = struct EXCEPTION_RECORD {
enum ExceptionCode ExceptionCode;
DWORD ExceptionFlags;
struct EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
union {
ULONG_PTR ExceptionInformation[15];
struct {...} AccessViolationInformation;
};
}
(gdb) pt $_siginfo.ExceptionCode
type = enum ExceptionCode {FATAL_APP_EXIT = 1073741845,
DBG_CONTROL_C = 1073807365, DBG_CONTROL_BREAK = 1073807368,
DATATYPE_MISALIGNMENT = 2147483650, BREAKPOINT, SINGLE_STEP,
ACCESS_VIOLATION = 3221225477, IN_PAGE_ERROR,
ILLEGAL_INSTRUCTION = 3221225501, NONCONTINUABLE_EXCEPTION = 3221225509,
INVALID_DISPOSITION, ARRAY_BOUNDS_EXCEEDED = 3221225612,
FLOAT_DENORMAL_OPERAND, FLOAT_DIVIDE_BY_ZERO, FLOAT_INEXACT_RESULT,
FLOAT_INVALID_OPERATION, FLOAT_OVERFLOW, FLOAT_STACK_CHECK,
FLOAT_UNDERFLOW, INTEGER_DIVIDE_BY_ZERO, INTEGER_OVERFLOW,
PRIV_INSTRUCTION, STACK_OVERFLOW = 3221225725, FAST_FAIL = 3221226505}
(gdb) pt $_siginfo.AccessViolationInformation
type = struct {
enum ViolationType Type;
PVOID Address;
}
(gdb) pt $_siginfo.AccessViolationInformation.Type
type = enum ViolationType {READ_ACCESS_VIOLATION, WRITE_ACCESS_VIOLATION,
DATA_EXECUTION_PREVENTION_VIOLATION = 8}
Which makes it easier to understand the reason of the exception:
(gdb) p $_siginfo
$1 = {
ExceptionCode = ACCESS_VIOLATION,
ExceptionFlags = 0,
ExceptionRecord = 0x0,
ExceptionAddress = 0x401632 <main+18>,
NumberParameters = 2,
{
ExceptionInformation = {1, 291, 0 <repeats 13 times>},
AccessViolationInformation = {
Type = WRITE_ACCESS_VIOLATION,
Address = 0x123
}
}
}
gdb/ChangeLog:
2020-02-09 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct enum_value_name): New struct.
(create_enum): New function.
(windows_get_siginfo_type): Create and use enum types.
2020-01-17 22:50:58 +08:00
|
|
|
append_composite_type_field_aligned (siginfo_type, "",
|
2022-09-21 23:05:21 +08:00
|
|
|
para_type, ulongptr_type->length ());
|
2020-01-17 22:28:09 +08:00
|
|
|
|
|
|
|
windows_gdbarch_data->siginfo_type = siginfo_type;
|
|
|
|
|
|
|
|
return siginfo_type;
|
|
|
|
}
|
|
|
|
|
2024-02-06 04:18:34 +08:00
|
|
|
/* Implement the "solib_create_inferior_hook" solib_ops method. */
|
2020-02-13 00:53:32 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
windows_solib_create_inferior_hook (int from_tty)
|
|
|
|
{
|
|
|
|
CORE_ADDR exec_base = 0;
|
|
|
|
|
|
|
|
/* Find base address of main executable in
|
|
|
|
TIB->process_environment_block->image_base_address. */
|
2023-09-30 02:24:38 +08:00
|
|
|
gdbarch *gdbarch = current_inferior ()->arch ();
|
2020-02-13 00:53:32 +08:00
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
int ptr_bytes;
|
|
|
|
int peb_offset; /* Offset of process_environment_block in TIB. */
|
|
|
|
int base_offset; /* Offset of image_base_address in PEB. */
|
|
|
|
if (gdbarch_ptr_bit (gdbarch) == 32)
|
|
|
|
{
|
|
|
|
ptr_bytes = 4;
|
|
|
|
peb_offset = 48;
|
|
|
|
base_offset = 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ptr_bytes = 8;
|
|
|
|
peb_offset = 96;
|
|
|
|
base_offset = 16;
|
|
|
|
}
|
|
|
|
CORE_ADDR tlb;
|
|
|
|
gdb_byte buf[8];
|
Remove target_has_execution macro
This removes the object-like macro target_has_execution, replacing it
with a function call. target_has_execution_current is also now
handled by this function.
gdb/ChangeLog
2020-09-28 Tom Tromey <tom@tromey.com>
* inferior.h (class inferior) <has_execution>: Update.
* windows-tdep.c (windows_solib_create_inferior_hook): Update.
* valops.c (find_function_in_inferior)
(value_allocate_space_in_inferior): Update.
* top.c (kill_or_detach): Update.
* target.c (target_preopen, set_target_permissions): Update.
(target_has_execution_current): Remove.
* sparc64-tdep.c (adi_examine_command, adi_assign_command):
Update.
* solib.c (update_solib_list, reload_shared_libraries): Update.
* solib-svr4.c (svr4_solib_create_inferior_hook): Update.
* solib-dsbt.c (enable_break): Update.
* score-tdep.c (score7_fetch_inst): Update.
* rs6000-nat.c (rs6000_nat_target::xfer_shared_libraries):
Update.
* remote.c (remote_target::start_remote)
(remote_target::remote_check_symbols, remote_target::open_1)
(remote_target::remote_detach_1, remote_target::verify_memory)
(remote_target::xfer_partial, remote_target::read_description)
(remote_target::get_min_fast_tracepoint_insn_len): Update.
* record-full.c (record_full_open_1): Update.
* record-btrace.c (record_btrace_target_open): Update.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring): Update.
* linux-thread-db.c (add_thread_db_info)
(thread_db_find_new_threads_silently, check_thread_db_callback)
(try_thread_db_load_1, record_thread): Update.
* linux-tdep.c (linux_info_proc, linux_vsyscall_range_raw):
Update.
* linux-fork.c (checkpoint_command): Update.
* infrun.c (set_non_stop, set_observer_mode)
(check_multi_target_resumption, for_each_just_stopped_thread)
(maybe_remove_breakpoints, normal_stop)
(class infcall_suspend_state): Update.
* infcmd.c (ERROR_NO_INFERIOR, kill_if_already_running)
(info_program_command, attach_command): Update.
* infcall.c (call_function_by_hand_dummy): Update.
* inf-loop.c (inferior_event_handler): Update.
* gcore.c (gcore_command, derive_heap_segment): Update.
* exec.c (exec_file_command): Update.
* eval.c (evaluate_subexp): Update.
* compile/compile.c (compile_to_object): Update.
* cli/cli-dump.c (restore_command): Update.
* breakpoint.c (update_watchpoint)
(update_inserted_breakpoint_locations)
(insert_breakpoint_locations, get_bpstat_thread): Update.
* target.h (target_has_execution): Remove macro.
(target_has_execution_current): Don't declare.
(target_has_execution): Rename from target_has_execution_1. Add
argument default.
2020-09-29 09:38:25 +08:00
|
|
|
if (target_has_execution ()
|
2020-03-05 04:20:31 +08:00
|
|
|
&& target_get_tib_address (inferior_ptid, &tlb)
|
2020-02-13 00:53:32 +08:00
|
|
|
&& !target_read_memory (tlb + peb_offset, buf, ptr_bytes))
|
|
|
|
{
|
|
|
|
CORE_ADDR peb = extract_unsigned_integer (buf, ptr_bytes, byte_order);
|
|
|
|
if (!target_read_memory (peb + base_offset, buf, ptr_bytes))
|
|
|
|
exec_base = extract_unsigned_integer (buf, ptr_bytes, byte_order);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Rebase executable if the base address changed because of ASLR. */
|
2020-10-30 05:04:33 +08:00
|
|
|
if (current_program_space->symfile_object_file != nullptr && exec_base != 0)
|
2020-02-13 00:53:32 +08:00
|
|
|
{
|
Remove the exec_bfd macro
This removes the exec_bfd macro, in favor of new accessors on
program_space. In one spot the accessor can't be used; but this is
still a big improvement over the macro, IMO.
gdb/ChangeLog
2020-10-29 Tom Tromey <tom@tromey.com>
* windows-tdep.c (windows_solib_create_inferior_hook): Update.
* symfile.c (reread_symbols): Update.
* symfile-mem.c (add_symbol_file_from_memory_command)
(add_vsyscall_page): Update.
* source-cache.c (source_cache::get_plain_source_lines): Update.
* solib-svr4.c (find_program_interpreter, elf_locate_base)
(svr4_current_sos_direct, svr4_exec_displacement)
(svr4_relocate_main_executable): Update.
(svr4_iterate_over_objfiles_in_search_order): Update.
* solib-frv.c (enable_break2, enable_break): Update.
* solib-dsbt.c (lm_base, enable_break): Update.
* solib-darwin.c (find_program_interpreter)
(darwin_solib_create_inferior_hook): Update.
* sol-thread.c (rw_common, ps_pdmodel): Update.
* rs6000-nat.c (rs6000_nat_target::create_inferior): Update.
* remote.c (compare_sections_command)
(remote_target::trace_set_readonly_regions): Update.
* remote-sim.c (get_sim_inferior_data)
(gdbsim_target::create_inferior, gdbsim_target::create_inferior): Update.
(gdbsim_target_open, gdbsim_target::files_info): Update.
* exec.h (exec_bfd): Remove macro.
* progspace.c (initialize_progspace): Update.
* proc-service.c (ps_addr_to_core_addr, core_addr_to_ps_addr):
Update.
* nto-procfs.c (nto_procfs_target::post_attach)
(nto_procfs_target::create_inferior): Update.
* maint.c (maintenance_info_sections): Update.
* linux-thread-db.c (thread_db_target::get_thread_local_address):
Update.
* infcmd.c (post_create_inferior): Update.
* gcore.c (default_gcore_arch, default_gcore_target): Update.
(objfile_find_memory_regions): Update.
* exec.c (validate_exec_file, exec_file_attach)
(exec_read_partial_read_only, print_section_info): Update.
* corelow.c (core_target_open): Update.
* corefile.c (reopen_exec_file, validate_files): Update.
* arm-tdep.c (gdb_print_insn_arm): Update.
* arch-utils.c (gdbarch_update_p, default_print_insn): Update.
* progspace.h (struct program_space) <exec_bfd, set_exec_bfd>: New
methods.
2020-10-30 05:04:33 +08:00
|
|
|
CORE_ADDR vmaddr
|
|
|
|
= pe_data (current_program_space->exec_bfd ())->pe_opthdr.ImageBase;
|
2020-02-13 00:53:32 +08:00
|
|
|
if (vmaddr != exec_base)
|
2020-10-30 05:04:33 +08:00
|
|
|
objfile_rebase (current_program_space->symfile_object_file,
|
|
|
|
exec_base - vmaddr);
|
2020-02-13 00:53:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-06 04:18:34 +08:00
|
|
|
static solib_ops windows_so_ops;
|
2020-02-13 00:53:32 +08:00
|
|
|
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
/* Common parts for gdbarch initialization for the Windows and Cygwin OS
|
|
|
|
ABIs. */
|
2013-10-01 21:17:57 +08:00
|
|
|
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
static void
|
|
|
|
windows_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch)
|
2013-10-01 21:17:57 +08:00
|
|
|
{
|
Teach GDB that wchar_t is a built-in type in C++ mode
GDB is currently not aware that wchar_t is a built-in type in C++
mode. This is usually not a problem because the debug info describes
the type, so when you have a program loaded, you don't notice this.
However, if you try expressions involving wchar_t before a program is
loaded, gdb errors out:
(gdb) p (wchar_t)-1
No symbol table is loaded. Use the "file" command.
(gdb) p L"hello"
No type named wchar_t.
(gdb) ptype L"hello"
No type named wchar_t.
This commit teaches gdb about the type. After:
(gdb) p (wchar_t)-1
$1 = -1 L'\xffffffff'
(gdb) p L"hello"
$2 = L"hello"
(gdb) ptype L"hello"
type = wchar_t [6]
Unlike char16_t/char32_t, unfortunately, the underlying type of
wchar_t is implementation dependent, both size and signness. So this
requires adding a couple new gdbarch hooks.
I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it
seems to me that the majority of the ABIs have a 4-byte signed
wchar_t, so that's what I made the default for GDB too. And then I
looked for which ports have a 16-bit and/or unsigned wchar_t, and made
GDB follow suit.
gdb/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>:
New enum value.
(cplus_language_arch_info): Register cplus_primitive_type_wchar_t.
* gdbtypes.h (struct builtin_type) <builtin_wchar>: New field.
* gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type.
* gdbarch.sh (wchar_bit, wchar_signed): New per-arch values.
* gdbarch.h, gdbarch.c: Regenerate.
* aarch64-tdep.c (aarch64_gdbarch_init): Override
gdbarch_wchar_bit and gdbarch_wchar_signed.
* alpha-tdep.c (alpha_gdbarch_init): Likewise.
* arm-tdep.c (arm_gdbarch_init): Likewise.
* avr-tdep.c (avr_gdbarch_init): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* i386-nto-tdep.c (i386nto_init_abi): Likewise.
* i386-tdep.c (i386_go32_init_abi): Likewise.
* m32r-tdep.c (m32r_gdbarch_init): Likewise.
* moxie-tdep.c (moxie_gdbarch_init): Likewise.
* nds32-tdep.c (nds32_gdbarch_init): Likewise.
* rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise.
* sh-tdep.c (sh_gdbarch_init): Likewise.
* sparc-tdep.c (sparc32_gdbarch_init): Likewise.
* sparc64-tdep.c (sparc64_init_abi): Likewise.
* windows-tdep.c (windows_init_abi): Likewise.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise.
gdb/testsuite/ChangeLog:
2017-04-12 Pedro Alves <palves@redhat.com>
PR gdb/21323
* gdb.cp/wide_char_types.c: Include <wchar.h>.
(wchar): New global.
* gdb.cp/wide_char_types.exp (wide_char_types_program)
(do_test_wide_char, wide_char_types_no_program, top level): Add
wchar_t testing.
2017-04-12 21:00:49 +08:00
|
|
|
set_gdbarch_wchar_bit (gdbarch, 16);
|
|
|
|
set_gdbarch_wchar_signed (gdbarch, 0);
|
|
|
|
|
2013-10-01 21:17:57 +08:00
|
|
|
/* Canonical paths on this target look like
|
|
|
|
`c:\Program Files\Foo App\mydll.dll', for example. */
|
|
|
|
set_gdbarch_has_dos_based_file_system (gdbarch, 1);
|
|
|
|
|
|
|
|
set_gdbarch_iterate_over_objfiles_in_search_order
|
|
|
|
(gdbarch, windows_iterate_over_objfiles_in_search_order);
|
|
|
|
|
2020-02-13 00:53:32 +08:00
|
|
|
windows_so_ops = solib_target_so_ops;
|
|
|
|
windows_so_ops.solib_create_inferior_hook
|
|
|
|
= windows_solib_create_inferior_hook;
|
2022-08-09 00:41:43 +08:00
|
|
|
set_gdbarch_so_ops (gdbarch, &windows_so_ops);
|
2020-01-17 22:28:09 +08:00
|
|
|
|
|
|
|
set_gdbarch_get_siginfo_type (gdbarch, windows_get_siginfo_type);
|
2013-10-01 21:17:57 +08:00
|
|
|
}
|
|
|
|
|
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.
2020-04-09 02:05:54 +08:00
|
|
|
/* See windows-tdep.h. */
|
|
|
|
void
|
|
|
|
windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
windows_init_abi_common (info, gdbarch);
|
|
|
|
set_gdbarch_gdb_signal_to_target (gdbarch, windows_gdb_signal_to_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See windows-tdep.h. */
|
|
|
|
|
|
|
|
void
|
|
|
|
cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
|
|
|
{
|
|
|
|
windows_init_abi_common (info, gdbarch);
|
|
|
|
set_gdbarch_gdb_signal_to_target (gdbarch, cygwin_gdb_signal_to_target);
|
|
|
|
}
|
|
|
|
|
2012-04-28 04:38:39 +08:00
|
|
|
/* Implementation of `tlb' variable. */
|
|
|
|
|
|
|
|
static const struct internalvar_funcs tlb_funcs =
|
|
|
|
{
|
|
|
|
tlb_make_value,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2020-03-17 04:56:36 +08:00
|
|
|
/* Layout of an element of a PE's Import Directory Table. Based on:
|
|
|
|
|
|
|
|
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-directory-table
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pe_import_directory_entry
|
|
|
|
{
|
|
|
|
uint32_t import_lookup_table_rva;
|
|
|
|
uint32_t timestamp;
|
|
|
|
uint32_t forwarder_chain;
|
|
|
|
uint32_t name_rva;
|
|
|
|
uint32_t import_address_table_rva;
|
|
|
|
};
|
|
|
|
|
2023-10-19 10:44:11 +08:00
|
|
|
static_assert (sizeof (pe_import_directory_entry) == 20);
|
2020-03-17 04:56:36 +08:00
|
|
|
|
|
|
|
/* See windows-tdep.h. */
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_linked_with_cygwin_dll (bfd *abfd)
|
|
|
|
{
|
|
|
|
/* The list of DLLs a PE is linked to is in the .idata section. See:
|
|
|
|
|
|
|
|
https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section
|
|
|
|
*/
|
|
|
|
asection *idata_section = bfd_get_section_by_name (abfd, ".idata");
|
|
|
|
if (idata_section == nullptr)
|
|
|
|
return false;
|
|
|
|
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
bfd_size_type idata_section_size = bfd_section_size (idata_section);
|
|
|
|
internal_extra_pe_aouthdr *pe_extra = &pe_data (abfd)->pe_opthdr;
|
|
|
|
bfd_vma import_table_va = pe_extra->DataDirectory[PE_IMPORT_TABLE].VirtualAddress;
|
|
|
|
bfd_vma idata_section_va = bfd_section_vma (idata_section);
|
|
|
|
|
|
|
|
/* The section's virtual address as reported by BFD has the image base applied,
|
|
|
|
remove it. */
|
|
|
|
gdb_assert (idata_section_va >= pe_extra->ImageBase);
|
|
|
|
idata_section_va -= pe_extra->ImageBase;
|
|
|
|
|
|
|
|
bfd_vma idata_section_end_va = idata_section_va + idata_section_size;
|
|
|
|
|
|
|
|
/* Make sure that the import table is indeed within the .idata section's range. */
|
|
|
|
if (import_table_va < idata_section_va
|
|
|
|
|| import_table_va >= idata_section_end_va)
|
|
|
|
{
|
|
|
|
warning (_("\
|
2022-08-04 11:18:05 +08:00
|
|
|
%s: import table's virtual address (%s) is outside .idata \
|
|
|
|
section's range [%s, %s]."),
|
|
|
|
bfd_get_filename (abfd), hex_string (import_table_va),
|
|
|
|
hex_string (idata_section_va),
|
|
|
|
hex_string (idata_section_end_va));
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The import table starts at this offset into the .idata section. */
|
|
|
|
bfd_vma import_table_offset_in_sect = import_table_va - idata_section_va;
|
2020-03-17 04:56:36 +08:00
|
|
|
|
2020-04-03 03:49:06 +08:00
|
|
|
/* Get the section's data. */
|
|
|
|
gdb::byte_vector idata_contents;
|
|
|
|
if (!gdb_bfd_get_full_section_contents (abfd, idata_section, &idata_contents))
|
2020-03-17 04:56:36 +08:00
|
|
|
{
|
2020-04-17 03:46:16 +08:00
|
|
|
warning (_("%s: failed to get contents of .idata section."),
|
|
|
|
bfd_get_filename (abfd));
|
2020-03-17 04:56:36 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
gdb_assert (idata_contents.size () == idata_section_size);
|
|
|
|
|
|
|
|
const gdb_byte *iter = idata_contents.data () + import_table_offset_in_sect;
|
|
|
|
const gdb_byte *end = idata_contents.data () + idata_section_size;
|
2020-03-17 04:56:36 +08:00
|
|
|
const pe_import_directory_entry null_dir_entry = { 0 };
|
|
|
|
|
|
|
|
/* Iterate through all directory entries. */
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
/* Is there enough space left in the section for another entry? */
|
|
|
|
if (iter + sizeof (pe_import_directory_entry) > end)
|
|
|
|
{
|
2020-04-17 03:46:16 +08:00
|
|
|
warning (_("%s: unexpected end of .idata section."),
|
|
|
|
bfd_get_filename (abfd));
|
2020-03-17 04:56:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pe_import_directory_entry *dir_entry = (pe_import_directory_entry *) iter;
|
|
|
|
|
|
|
|
/* Is it the end of list marker? */
|
|
|
|
if (memcmp (dir_entry, &null_dir_entry,
|
|
|
|
sizeof (pe_import_directory_entry)) == 0)
|
|
|
|
break;
|
|
|
|
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
bfd_vma name_va = dir_entry->name_rva;
|
2020-03-17 04:56:36 +08:00
|
|
|
|
|
|
|
/* If the name's virtual address is smaller than the section's virtual
|
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c). I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it? What if the lines around it are also
wrong, do I fix them too? I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.
So I propose to fix as much as possible once and for all (hopefully).
One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines. My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for. So you
already need a somewhat efficient way to do this.
Using some interactive tool, rather than plain git-blame, makes this
trivial. For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too. My point is that it won't
really make archeology more difficult.
The other typical counter argument is that it will cause conflicts with
existing patches. That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve. I have also tried "git
rebase --ignore-whitespace", it seems to work well. Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).
gdb/ChangeLog:
* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.
gdbserver/ChangeLog:
* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.
gdbsupport/ChangeLog:
* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.
Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695
2020-11-02 23:26:14 +08:00
|
|
|
address, there's a problem. */
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
if (name_va < idata_section_va || name_va >= idata_section_end_va)
|
2020-03-17 04:56:36 +08:00
|
|
|
{
|
|
|
|
warning (_("\
|
2022-08-04 11:18:05 +08:00
|
|
|
%s: name's virtual address (%s) is outside .idata section's \
|
|
|
|
range [%s, %s]."),
|
|
|
|
bfd_get_filename (abfd), hex_string (name_va),
|
|
|
|
hex_string (idata_section_va),
|
|
|
|
hex_string (idata_section_end_va));
|
2020-03-17 04:56:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:
warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.
This uncovers an issue with how we parse the import table, part of the
.idata section. Right now, we assume that the import table is located
at the beginning of the section. That was the case in everything I had
tried so far, but this file is an example where that's not true.
We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section. Using the file mentioned above, this is the values we have to
work with:
A) bfd_section_vma (idata_section) 101b8000
B) Import table's virtual address b82b8
C) Image base 10100000
The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first. The offset of the table
in the section is therefore:
B - (A - C)
This patch implements that.
gdb/ChangeLog:
* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.
2020-04-17 03:46:03 +08:00
|
|
|
const gdb_byte *name = &idata_contents[name_va - idata_section_va];
|
2020-03-17 04:56:36 +08:00
|
|
|
|
2020-04-24 02:15:28 +08:00
|
|
|
/* Make sure we don't overshoot the end of the section with the
|
|
|
|
streq. */
|
|
|
|
if (name + sizeof (CYGWIN_DLL_NAME) <= end)
|
|
|
|
{
|
|
|
|
/* Finally, check if this is the dll name we are looking for. */
|
|
|
|
if (streq ((const char *) name, CYGWIN_DLL_NAME))
|
|
|
|
return true;
|
|
|
|
}
|
2020-03-17 04:56:36 +08:00
|
|
|
|
2020-04-02 05:41:31 +08:00
|
|
|
iter += sizeof (pe_import_directory_entry);
|
2020-03-17 04:56:36 +08:00
|
|
|
}
|
|
|
|
|
2020-04-24 02:15:28 +08:00
|
|
|
return false;
|
2020-03-17 04:56:36 +08:00
|
|
|
}
|
|
|
|
|
2020-06-30 23:52:41 +08:00
|
|
|
struct cpms_data
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch;
|
2023-04-13 04:27:01 +08:00
|
|
|
std::string xml;
|
2020-06-30 23:52:41 +08:00
|
|
|
int module_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
core_process_module_section (bfd *abfd, asection *sect, void *obj)
|
|
|
|
{
|
|
|
|
struct cpms_data *data = (struct cpms_data *) obj;
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
|
|
|
|
|
2020-06-30 00:11:51 +08:00
|
|
|
unsigned int data_type;
|
2020-06-30 23:52:41 +08:00
|
|
|
char *module_name;
|
|
|
|
size_t module_name_size;
|
2020-06-30 00:11:51 +08:00
|
|
|
size_t module_name_offset;
|
2020-06-30 23:52:41 +08:00
|
|
|
CORE_ADDR base_addr;
|
|
|
|
|
|
|
|
if (!startswith (sect->name, ".module"))
|
|
|
|
return;
|
|
|
|
|
2021-12-27 04:49:22 +08:00
|
|
|
gdb::byte_vector buf (bfd_section_size (sect) + 1);
|
2020-06-30 23:52:41 +08:00
|
|
|
if (!bfd_get_section_contents (abfd, sect,
|
2021-12-27 04:49:22 +08:00
|
|
|
buf.data (), 0, bfd_section_size (sect)))
|
|
|
|
return;
|
|
|
|
/* We're going to treat part of the buffer as a string, so make sure
|
|
|
|
it is NUL-terminated. */
|
|
|
|
buf.back () = 0;
|
2020-06-30 23:52:41 +08:00
|
|
|
|
|
|
|
/* A DWORD (data_type) followed by struct windows_core_module_info. */
|
2021-12-27 04:49:22 +08:00
|
|
|
if (bfd_section_size (sect) < 4)
|
|
|
|
return;
|
|
|
|
data_type = extract_unsigned_integer (buf.data (), 4, byte_order);
|
2020-06-30 23:52:41 +08:00
|
|
|
|
2020-06-30 00:11:51 +08:00
|
|
|
if (data_type == NOTE_INFO_MODULE)
|
|
|
|
{
|
|
|
|
module_name_offset = 12;
|
2021-12-27 04:49:22 +08:00
|
|
|
if (bfd_section_size (sect) < module_name_offset)
|
|
|
|
return;
|
|
|
|
base_addr = extract_unsigned_integer (&buf[4], 4, byte_order);
|
|
|
|
module_name_size = extract_unsigned_integer (&buf[8], 4, byte_order);
|
2020-06-30 00:11:51 +08:00
|
|
|
}
|
|
|
|
else if (data_type == NOTE_INFO_MODULE64)
|
|
|
|
{
|
|
|
|
module_name_offset = 16;
|
2021-12-27 04:49:22 +08:00
|
|
|
if (bfd_section_size (sect) < module_name_offset)
|
|
|
|
return;
|
|
|
|
base_addr = extract_unsigned_integer (&buf[4], 8, byte_order);
|
|
|
|
module_name_size = extract_unsigned_integer (&buf[12], 4, byte_order);
|
2020-06-30 00:11:51 +08:00
|
|
|
}
|
|
|
|
else
|
2021-12-27 04:49:22 +08:00
|
|
|
return;
|
2020-06-30 23:52:41 +08:00
|
|
|
|
2020-06-30 00:11:51 +08:00
|
|
|
if (module_name_offset + module_name_size > bfd_section_size (sect))
|
2021-12-27 04:49:22 +08:00
|
|
|
return;
|
|
|
|
module_name = (char *) buf.data () + module_name_offset;
|
2020-06-30 23:52:41 +08:00
|
|
|
|
|
|
|
/* The first module is the .exe itself. */
|
|
|
|
if (data->module_count != 0)
|
|
|
|
windows_xfer_shared_library (module_name, base_addr,
|
2023-04-13 04:27:01 +08:00
|
|
|
NULL, data->gdbarch, data->xml);
|
2020-06-30 23:52:41 +08:00
|
|
|
data->module_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONGEST
|
|
|
|
windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
|
2023-04-13 04:27:01 +08:00
|
|
|
gdb_byte *readbuf,
|
|
|
|
ULONGEST offset, ULONGEST len)
|
2020-06-30 23:52:41 +08:00
|
|
|
{
|
2023-04-13 04:27:01 +08:00
|
|
|
cpms_data data { gdbarch, "<library-list>\n", 0 };
|
2024-02-06 05:13:58 +08:00
|
|
|
bfd_map_over_sections (current_program_space->core_bfd (),
|
2020-06-30 23:52:41 +08:00
|
|
|
core_process_module_section,
|
|
|
|
&data);
|
2023-04-13 04:27:01 +08:00
|
|
|
data.xml += "</library-list>\n";
|
2020-06-30 23:52:41 +08:00
|
|
|
|
2023-04-13 04:27:01 +08:00
|
|
|
ULONGEST len_avail = data.xml.length ();
|
2020-06-30 23:52:41 +08:00
|
|
|
if (offset >= len_avail)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (len > len_avail - offset)
|
|
|
|
len = len_avail - offset;
|
|
|
|
|
2023-04-13 04:27:01 +08:00
|
|
|
memcpy (readbuf, data.xml.data () + offset, len);
|
|
|
|
|
2020-06-30 23:52:41 +08:00
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is how we want PTIDs from core files to be printed. */
|
|
|
|
|
|
|
|
std::string
|
|
|
|
windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
|
|
|
|
{
|
|
|
|
if (ptid.lwp () != 0)
|
|
|
|
return string_printf ("Thread 0x%lx", ptid.lwp ());
|
|
|
|
|
|
|
|
return normal_pid_to_str (ptid);
|
|
|
|
}
|
|
|
|
|
2020-01-14 03:01:38 +08:00
|
|
|
void _initialize_windows_tdep ();
|
2010-04-16 15:49:37 +08:00
|
|
|
void
|
2020-01-14 03:01:38 +08:00
|
|
|
_initialize_windows_tdep ()
|
2010-04-16 15:49:37 +08:00
|
|
|
{
|
2020-04-19 09:28:13 +08:00
|
|
|
init_w32_command_list ();
|
2021-05-28 01:59:01 +08:00
|
|
|
cmd_list_element *info_w32_thread_information_block_cmd
|
|
|
|
= add_cmd ("thread-information-block", class_info, display_tib,
|
|
|
|
_("Display thread information block."),
|
|
|
|
&info_w32_cmdlist);
|
|
|
|
add_alias_cmd ("tib", info_w32_thread_information_block_cmd, class_info, 1,
|
2010-04-16 15:49:37 +08:00
|
|
|
&info_w32_cmdlist);
|
|
|
|
|
|
|
|
add_setshow_boolean_cmd ("show-all-tib", class_maintenance,
|
|
|
|
&maint_display_all_tib, _("\
|
|
|
|
Set whether to display all non-zero fields of thread information block."), _("\
|
|
|
|
Show whether to display all non-zero fields of thread information block."), _("\
|
|
|
|
Use \"on\" to enable, \"off\" to disable.\n\
|
|
|
|
If enabled, all non-zero fields of thread information block are displayed,\n\
|
|
|
|
even if their meaning is unknown."),
|
|
|
|
NULL,
|
|
|
|
show_maint_show_all_tib,
|
|
|
|
&maintenance_set_cmdlist,
|
|
|
|
&maintenance_show_cmdlist);
|
|
|
|
|
|
|
|
/* Explicitly create without lookup, since that tries to create a
|
|
|
|
value with a void typed value, and when we get here, gdbarch
|
|
|
|
isn't initialized yet. At this point, we're quite sure there
|
|
|
|
isn't another convenience variable of the same name. */
|
2012-04-28 04:38:39 +08:00
|
|
|
create_internalvar_type_lazy ("_tlb", &tlb_funcs, NULL);
|
2010-04-16 15:49:37 +08:00
|
|
|
}
|
Teach gdb how to unwind cygwin _sigbe and sigdelayed frames
The majority of functions in the cygwin DLL are wrapped by routines
which use an an alternate stack to return via a signal handler if a
signal occured while inside the function. (See [1],[2])
At present, these frames cannot be correctly unwound by gdb. There
doesn't seem to currently be a way to correctly describe these frames
using DWARF CFI.
So instead, write a custom unwinder for _sigbe and sigdelayed frames,
which gets the return address from the alternate stack.
The offset of tls::stackptr from TIB.stacktop is determined by analyzing
the code in _sigbe or sigdelayed.
This can backtrace from _sigbe and from a sighandler through sigdelayed.
Implemented for amd64 and i386
Issues:
1. We should detect if we are in the wrapper after the return address
has been popped off the alternate stack, and if so, fetch the return
address from the register it's been popped into.
2. If there are multiple _sigbe or sigdelayed stack frames to be
unwound, this only unwinds the first one correctly, because we don't
unwind the value of the alternate stack pointer itself.
This is no worse than currently, when we can't even unwind one of
these frame correctly, but isn't quite correct.
I guess this could be handled by defining a pseudo-register to track
its value as we unwind the stack.
[1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/gendef
[2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/how-signals-work.txt
Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: I4a0d02c1b85d0aadaab2de3abd584eb4bda5b5cc
2016-01-13 06:49:09 +08:00
|
|
|
|
|
|
|
/* Frame cache data for the cygwin sigwrapper unwinder. */
|
|
|
|
|
|
|
|
struct cygwin_sigwrapper_frame_cache
|
|
|
|
{
|
|
|
|
CORE_ADDR prev_pc;
|
|
|
|
int tlsoffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Return true if the instructions at PC match the instructions bytes
|
|
|
|
in PATTERN. Returns false otherwise. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
insns_match_pattern (CORE_ADDR pc,
|
|
|
|
const gdb::array_view<const gdb_byte> pattern)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < pattern.size (); i++)
|
|
|
|
{
|
|
|
|
gdb_byte buf;
|
|
|
|
if (target_read_code (pc + i, &buf, 1) != 0)
|
|
|
|
return false;
|
|
|
|
if (buf != pattern[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper for cygwin_sigwrapper_frame_cache. Search for one of the
|
|
|
|
patterns in PATTERNS_LIST within [START, END). If found, record
|
|
|
|
the tls offset found after the matched pattern in the instruction
|
|
|
|
stream, in *TLSOFFSET. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
cygwin_sigwrapper_frame_analyze
|
|
|
|
(struct gdbarch *gdbarch,
|
|
|
|
CORE_ADDR start, CORE_ADDR end,
|
|
|
|
gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list,
|
|
|
|
int *tlsoffset)
|
|
|
|
{
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
|
|
|
|
*tlsoffset = 0;
|
|
|
|
|
|
|
|
for (CORE_ADDR addr = start; addr < end; addr++)
|
|
|
|
{
|
|
|
|
for (auto patterns : patterns_list)
|
|
|
|
{
|
|
|
|
if (insns_match_pattern (addr, patterns))
|
|
|
|
{
|
|
|
|
/* The instruction sequence is followed by 4 bytes for
|
|
|
|
tls::stackptr. */
|
|
|
|
gdb_byte tls_stackptr[4];
|
|
|
|
if (target_read_code (addr + patterns.size (), tls_stackptr, 4) == 0)
|
|
|
|
{
|
|
|
|
*tlsoffset = extract_signed_integer (tls_stackptr, 4, byte_order);
|
|
|
|
|
|
|
|
frame_debug_printf ("matched pattern at %s, sigstackptroffset=%x",
|
|
|
|
paddress (gdbarch, addr),
|
|
|
|
*tlsoffset);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: Perhaps we should also note the address of the xaddq
|
|
|
|
instruction which pops the RA from the sigstack. If PC is after
|
|
|
|
that, we should look in the appropriate register to get the RA,
|
|
|
|
not on the sigstack. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill THIS_CACHE using the cygwin sigwrapper unwinding data for
|
|
|
|
THIS_FRAME. */
|
|
|
|
|
|
|
|
static cygwin_sigwrapper_frame_cache *
|
|
|
|
cygwin_sigwrapper_frame_cache (frame_info_ptr this_frame, void **this_cache)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
|
|
|
auto *cache = (struct cygwin_sigwrapper_frame_cache *) *this_cache;
|
|
|
|
const int len = gdbarch_addr_bit (gdbarch) / 8;
|
|
|
|
|
|
|
|
/* Get address of top of stack from thread information block. */
|
|
|
|
CORE_ADDR thread_local_base;
|
|
|
|
target_get_tib_address (inferior_ptid, &thread_local_base);
|
|
|
|
|
|
|
|
CORE_ADDR stacktop
|
|
|
|
= read_memory_unsigned_integer (thread_local_base + len, len, byte_order);
|
|
|
|
|
|
|
|
frame_debug_printf ("TEB.stacktop=%s", paddress (gdbarch, stacktop));
|
|
|
|
|
|
|
|
/* Find cygtls, relative to stacktop, and read signalstackptr from
|
|
|
|
cygtls. */
|
|
|
|
CORE_ADDR signalstackptr
|
|
|
|
= read_memory_unsigned_integer (stacktop + cache->tlsoffset,
|
|
|
|
len, byte_order);
|
|
|
|
|
|
|
|
frame_debug_printf ("sigsp=%s", paddress (gdbarch, signalstackptr));
|
|
|
|
|
|
|
|
/* Read return address from signal stack. */
|
|
|
|
cache->prev_pc
|
|
|
|
= read_memory_unsigned_integer (signalstackptr - len, len, byte_order);
|
|
|
|
|
|
|
|
frame_debug_printf ("ra=%s", paddress (gdbarch, cache->prev_pc));
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
cygwin_sigwrapper_frame_prev_register (const frame_info_ptr &this_frame,
|
|
|
|
void **this_cache,
|
|
|
|
int regnum)
|
|
|
|
{
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
struct cygwin_sigwrapper_frame_cache *cache
|
|
|
|
= cygwin_sigwrapper_frame_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
frame_debug_printf ("%s for pc=%s",
|
|
|
|
gdbarch_register_name (gdbarch, regnum),
|
|
|
|
paddress (gdbarch, cache->prev_pc));
|
|
|
|
|
|
|
|
if (regnum == gdbarch_pc_regnum (gdbarch))
|
|
|
|
return frame_unwind_got_address (this_frame, regnum, cache->prev_pc);
|
|
|
|
|
|
|
|
return frame_unwind_got_register (this_frame, regnum, regnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cygwin_sigwrapper_frame_this_id (const frame_info_ptr &this_frame,
|
|
|
|
void **this_cache,
|
|
|
|
struct frame_id *this_id)
|
|
|
|
{
|
|
|
|
*this_id = frame_id_build_unavailable_stack (get_frame_func (this_frame));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cygwin_sigwrapper_frame_sniffer (const struct frame_unwind *self_,
|
|
|
|
const frame_info_ptr &this_frame,
|
|
|
|
void **this_cache)
|
|
|
|
{
|
|
|
|
const auto *self = (const struct cygwin_sigwrapper_frame_unwind *) self_;
|
|
|
|
struct gdbarch *gdbarch = get_frame_arch (this_frame);
|
|
|
|
|
|
|
|
CORE_ADDR pc = get_frame_pc (this_frame);
|
|
|
|
const char *name;
|
|
|
|
CORE_ADDR start, end;
|
|
|
|
find_pc_partial_function (pc, &name, &start, &end);
|
|
|
|
|
|
|
|
if (name == nullptr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (strcmp (name, "_sigbe") != 0
|
|
|
|
&& strcmp (name, "__sigbe") != 0
|
|
|
|
&& strcmp (name, "sigdelayed") != 0
|
|
|
|
&& strcmp (name, "_sigdelayed") != 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
frame_debug_printf ("name=%s, start=%s, end=%s",
|
|
|
|
name,
|
|
|
|
paddress (gdbarch, start),
|
|
|
|
paddress (gdbarch, end));
|
|
|
|
|
|
|
|
int tlsoffset;
|
|
|
|
cygwin_sigwrapper_frame_analyze (gdbarch, start, end, self->patterns_list,
|
|
|
|
&tlsoffset);
|
|
|
|
if (tlsoffset == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
frame_debug_printf ("sigstackptroffset=%x", tlsoffset);
|
|
|
|
|
|
|
|
auto *cache = FRAME_OBSTACK_ZALLOC (struct cygwin_sigwrapper_frame_cache);
|
|
|
|
cache->tlsoffset = tlsoffset;
|
|
|
|
|
|
|
|
*this_cache = cache;
|
|
|
|
cygwin_sigwrapper_frame_cache (this_frame, this_cache);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cygwin sigwapper unwinder. */
|
|
|
|
|
|
|
|
cygwin_sigwrapper_frame_unwind::cygwin_sigwrapper_frame_unwind
|
|
|
|
(gdb::array_view<const gdb::array_view<const gdb_byte>> patterns_list)
|
|
|
|
: frame_unwind (),
|
|
|
|
patterns_list (patterns_list)
|
|
|
|
{
|
|
|
|
name = "cygwin sigwrapper";
|
|
|
|
type = NORMAL_FRAME;
|
|
|
|
stop_reason = default_frame_unwind_stop_reason;
|
|
|
|
this_id = cygwin_sigwrapper_frame_this_id;
|
|
|
|
prev_register = cygwin_sigwrapper_frame_prev_register;
|
|
|
|
sniffer = cygwin_sigwrapper_frame_sniffer;
|
|
|
|
}
|