binutils-gdb/gdb/ravenscar-thread.c

609 lines
18 KiB
C
Raw Permalink Normal View History

/* Ada Ravenscar thread support.
Copyright (C) 2004-2020 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdbcore.h"
#include "gdbthread.h"
#include "ada-lang.h"
#include "target.h"
#include "inferior.h"
#include "command.h"
#include "ravenscar-thread.h"
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
#include "observable.h"
#include "gdbcmd.h"
#include "top.h"
#include "regcache.h"
start change to progspace independence This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) <find_pc_sect_symtab>: Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update.
2013-08-15 16:46:35 +02:00
#include "objfiles.h"
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
/* This module provides support for "Ravenscar" tasks (Ada) when
debugging on bare-metal targets.
The typical situation is when debugging a bare-metal target over
the remote protocol. In that situation, the system does not know
about high-level concepts such as threads, only about some code
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
running on one or more CPUs. And since the remote protocol does not
provide any handling for CPUs, the de facto standard for handling
them is to have one thread per CPU, where the thread's ptid has
its lwp field set to the CPU number (eg: 1 for the first CPU,
2 for the second one, etc). This module will make that assumption.
This module then creates and maintains the list of threads based
on the list of Ada tasks, with one thread per Ada task. The convention
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
is that threads corresponding to the CPUs (see assumption above)
have a ptid_t of the form (PID, LWP, 0), while threads corresponding
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
to our Ada tasks have a ptid_t of the form (PID, 0, TID) where TID
is the Ada task's ID as extracted from Ada runtime information.
Switching to a given Ada task (or its underlying thread) is performed
by fetching the registers of that task from the memory area where
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
the registers were saved. For any of the other operations, the
operation is performed by first finding the CPU on which the task
is running, switching to its corresponding ptid, and then performing
the operation on that ptid using the target beneath us. */
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-14 21:36:58 +02:00
/* If true, ravenscar task support is enabled. */
static bool ravenscar_task_support = true;
static const char running_thread_name[] = "__gnat_running_thread_table";
static const char known_tasks_name[] = "system__tasking__debug__known_tasks";
static const char first_task_name[] = "system__tasking__debug__first_task";
static const char ravenscar_runtime_initializer[]
= "system__bb__threads__initialize";
target factories, target open and multiple instances of targets Currently, to open a target, with "target TARGET_NAME", GDB finds the target_ops instance with "TARGET_NAME" as short name, and then calls its target_ops::open virtual method. In reality, there's no actual target/name lookup, a pointer to the target_ops object was associated with the "target TARGET_NAME" command at add_target time (when GDB is initialized), as the command's context. This creates a chicken and egg situation. Consider the case of wanting to open multiple remote connections. We want to be able to have one remote target_ops instance per connection, but, if we're not connected yet, so we don't yet have an instance to call target->open() on... This patch fixes this by separating out common info about a target_ops to a separate structure (shortname, longname, doc), and changing the add_target routine to take a reference to such an object instead of a pointer to a target_ops, and a pointer to a factory function that is responsible to open an instance of the corresponding target when the user types "target TARGET_NAME". -extern void add_target (struct target_ops *); +extern void add_target (const target_info &info, target_open_ftype *func); I.e. this factory function replaces the target_ops::open virtual method. For static/singleton targets, nothing changes, the target_open_ftype function pushes the global target_ops instance on the target stack. At target_close time, the connection is tor down, but the global target_ops object remains live. However, targets that support being open multiple times will make their target_open_ftype routine allocate a new target_ops instance on the heap [e.g., new remote_target()], and push that on the stack. At target_close time, the new object is destroyed (by the target_ops::close virtual method). Both the core target and the remote targets will support being open multiple times (others could/should too, but those were my stopping point), but not in this patch yet. We need to get rid of more globals first before that'd be useful. Native targets are somewhat special, given find_default_run_target & friends. Those routines also expect to return a target_ops pointer, even before we've open the target. However, we'll never need more than one instance of the native target, so we can assume/require that native targets are global/simpletons, and have the backends register a pointer to the native target_ops. Since all native targets inherit inf_child_target, we can centralize that registration. See add_inf_child_target, get_native_target/set_native_target and find_default_run_target. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Use add_inf_child_target. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Use add_inf_child_target. * aix-thread.c (aix_thread_target_info): New. (aix_thread_target) <shortname, longname, doc>: Delete. <info>: New. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Use add_inf_child_target. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Use add_inf_child_target. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Use add_inf_child_target. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Use add_inf_child_target. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Use add_inf_child_target. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Use add_inf_child_target. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Use add_inf_child_target. * arm-linux-nat.c (_initialize_arm_linux_nat): Use add_inf_child_target. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Use add_inf_child_target. * bfd-target.c (target_bfd_target_info): New. (target_bfd) <shortname, longname, doc>: Delete. <info>: New. * bsd-kvm.c (bsd_kvm_target_info): New. (bsd_kvm_target) <shortname, longname, doc>: Delete. <info>: New. (bsd_kvm_target::open): Rename to ... (bsd_kvm_target_open): ... this. Adjust. * bsd-uthread.c (bsd_uthread_target_info): New. (bsd_uthread_target) <shortname, longname, doc>: Delete. <info>: New. * corefile.c (core_file_command): Adjust. * corelow.c (core_target_info): New. (core_target) <shortname, longname, doc>: Delete. <info>: New. (core_target::open): Rename to ... (core_target_open): ... this. Adjust. * ctf.c (ctf_target_info): New. (ctf_target) <shortname, longname, doc>: Delete. <info>: New. (ctf_target::open): Rename to ... (ctf_target_open): ... this. (_initialize_ctf): Adjust. * exec.c (exec_target_info): New. (exec_target) <shortname, longname, doc>: Delete. <info>: New. (exec_target::open): Rename to ... (exec_target_open): ... this. * gdbcore.h (core_target_open): Declare. * go32-nat.c (_initialize_go32_nat): Use add_inf_child_target. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Use add_inf_child_target. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Use add_inf_child_target. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Use add_inf_child_target. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Use add_inf_child_target. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Use add_inf_child_target. * i386-gnu-nat.c (_initialize_i386gnu_nat): Use add_inf_child_target. * i386-linux-nat.c (_initialize_i386_linux_nat): Use add_inf_child_target. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Use add_inf_child_target. * i386-obsd-nat.c (_initialize_i386obsd_nat): Use add_inf_child_target. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Use add_inf_child_target. * inf-child.c (inf_child_target_info): New. (inf_child_target::info): New. (inf_child_open_target): Remove 'target' parameter. Use get_native_target instead. (inf_child_target::open): Delete. (add_inf_child_target): New. * inf-child.h (inf_child_target) <shortname, longname, doc, open>: Delete. <info>: New. (add_inf_child_target): Declare. (inf_child_open_target): Declare. * linux-thread-db.c (thread_db_target_info): New. (thread_db_target) <shortname, longname, doc>: Delete. <info>: New. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Use add_inf_child_target. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Use add_inf_child_target. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Use add_inf_child_target. * m88k-bsd-nat.c (_initialize_m88kbsd_nat): Use add_inf_child_target. * make-target-delegates (print_class): Adjust. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Use add_inf_child_target. * mips-linux-nat.c (_initialize_mips_linux_nat): Use add_inf_child_target. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Use add_inf_child_target. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Use add_inf_child_target. * nto-procfs.c (nto_native_target_info): New. (nto_procfs_target_native) <shortname, longname, doc>: Delete. <info>: New. (nto_procfs_target_info): New. (nto_procfs_target_procfs) <shortname, longname, doc>: Delete. <info>: New. (init_procfs_targets): Adjust. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Use add_inf_child_target. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Use add_inf_child_target. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Use add_inf_child_target. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Use add_inf_child_target. * ravenscar-thread.c (ravenscar_target_info): New. (ravenscar_thread_target) <shortname, longname, doc>: Delete. <info>: New. * record-btrace.c (record_btrace_target_info): (record_btrace_target) <shortname, longname, doc>: Delete. <info>: New. (record_btrace_target::open): Rename to ... (record_btrace_target_open): ... this. Adjust. * record-full.c (record_longname, record_doc): New. (record_full_base_target) <shortname, longname, doc>: Delete. <info>: New. (record_full_target_info): New. (record_full_target): <shortname>: Delete. <info>: New. (record_full_core_open_1, record_full_open_1): Update comments. (record_full_base_target::open): Rename to ... (record_full_open): ... this. (cmd_record_full_restore): Update. (_initialize_record_full): Update. * remote-sim.c (remote_sim_target_info): New. (gdbsim_target) <shortname, longname, doc>: Delete. <info>: New. (gdbsim_target::open): Rename to ... (gdbsim_target_open): ... this. (_initialize_remote_sim): Adjust. * remote.c (remote_doc): New. (remote_target_info): New. (remote_target) <shortname, longname, doc>: Delete. <info>: New. (extended_remote_target_info): New. (extended_remote_target) <shortname, longname, doc>: Delete. <info>: New. (remote_target::open_1): Make static. Adjust. * rs6000-nat.c (_initialize_rs6000_nat): Use add_inf_child_target. * s390-linux-nat.c (_initialize_s390_nat): Use add_inf_child_target. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Use add_inf_child_target. * sol-thread.c (thread_db_target_info): New. (sol_thread_target) <shortname, longname, doc>: Delete. <info>: New. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Use add_inf_child_target. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Use add_inf_child_target. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Use add_inf_child_target. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use add_inf_child_target. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Use add_inf_child_target. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Use add_inf_child_target. * spu-linux-nat.c (_initialize_spu_nat): Use add_inf_child_target. * spu-multiarch.c (spu_multiarch_target_info): New. (spu_multiarch_target) <shortname, longname, doc>: Delete. <info>: New. * target-delegates.c: Regenerate. * target.c: Include <unordered_map>. (target_ops_p): Delete. (DEF_VEC_P(target_ops_p)): Delete. (target_factories): New. (test_target_info): New. (test_target_ops::info): New. (open_target): Adjust to use target_factories. (add_target_with_completer): Rename to ... (add_target): ... this. Change prototype. Register target_info and open callback in target_factories. Register target_info in command context instead of target_ops. (add_target): Delete old implementation. (add_deprecated_target_alias): Change prototype. Adjust. (the_native_target): New. (set_native_target, get_native_target): New. (find_default_run_target): Use the_native_target. (find_attach_target, find_run_target): Simplify. (target_ops::open): Delete. (dummy_target_info): New. (dummy_target::shortname, dummy_target::longname) (dummy_target::doc): Delete. (dummy_target::info): New. (debug_target::shortname, debug_target::longname) (debug_target::doc): Delete. (debug_target::info): New. * target.h (struct target_info): New. (target_ops::~target_ops): Add comment. (target_ops::info): New. (target_ops::shortname, target_ops::longname, target_ops::doc): No longer virtual. Implement in terms of target_info. (set_native_target, get_native_target): Declare. (target_open_ftype): New. (add_target, add_target_with_completer) (add_deprecated_target_alias): Change prototype. (test_target) <shortname, longname, doc>: Delete. <info>: New. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Use add_inf_child_target. * tracefile-tfile.c (tfile_target_info): New. (tfile_target) <shortname, longname, doc>: Delete. <info>: New. (tfile_target::open): Rename to ... (tfile_target_open): ... this. (_initialize_tracefile_tfile): Adjust. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Use add_inf_child_target. * windows-nat.c (_initialize_windows_nat): Use add_inf_child_target. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Use add_inf_child_target.
2018-05-03 01:37:32 +02:00
static const target_info ravenscar_target_info = {
"ravenscar",
N_("Ravenscar tasks."),
N_("Ravenscar tasks support.")
};
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
struct ravenscar_thread_target final : public target_ops
{
ravenscar_thread_target ()
: m_base_ptid (inferior_ptid)
{
thread_info *thr = add_active_thread ();
if (thr != nullptr)
switch_to_thread (thr);
}
target factories, target open and multiple instances of targets Currently, to open a target, with "target TARGET_NAME", GDB finds the target_ops instance with "TARGET_NAME" as short name, and then calls its target_ops::open virtual method. In reality, there's no actual target/name lookup, a pointer to the target_ops object was associated with the "target TARGET_NAME" command at add_target time (when GDB is initialized), as the command's context. This creates a chicken and egg situation. Consider the case of wanting to open multiple remote connections. We want to be able to have one remote target_ops instance per connection, but, if we're not connected yet, so we don't yet have an instance to call target->open() on... This patch fixes this by separating out common info about a target_ops to a separate structure (shortname, longname, doc), and changing the add_target routine to take a reference to such an object instead of a pointer to a target_ops, and a pointer to a factory function that is responsible to open an instance of the corresponding target when the user types "target TARGET_NAME". -extern void add_target (struct target_ops *); +extern void add_target (const target_info &info, target_open_ftype *func); I.e. this factory function replaces the target_ops::open virtual method. For static/singleton targets, nothing changes, the target_open_ftype function pushes the global target_ops instance on the target stack. At target_close time, the connection is tor down, but the global target_ops object remains live. However, targets that support being open multiple times will make their target_open_ftype routine allocate a new target_ops instance on the heap [e.g., new remote_target()], and push that on the stack. At target_close time, the new object is destroyed (by the target_ops::close virtual method). Both the core target and the remote targets will support being open multiple times (others could/should too, but those were my stopping point), but not in this patch yet. We need to get rid of more globals first before that'd be useful. Native targets are somewhat special, given find_default_run_target & friends. Those routines also expect to return a target_ops pointer, even before we've open the target. However, we'll never need more than one instance of the native target, so we can assume/require that native targets are global/simpletons, and have the backends register a pointer to the native target_ops. Since all native targets inherit inf_child_target, we can centralize that registration. See add_inf_child_target, get_native_target/set_native_target and find_default_run_target. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Use add_inf_child_target. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Use add_inf_child_target. * aix-thread.c (aix_thread_target_info): New. (aix_thread_target) <shortname, longname, doc>: Delete. <info>: New. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Use add_inf_child_target. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Use add_inf_child_target. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Use add_inf_child_target. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Use add_inf_child_target. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Use add_inf_child_target. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Use add_inf_child_target. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Use add_inf_child_target. * arm-linux-nat.c (_initialize_arm_linux_nat): Use add_inf_child_target. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Use add_inf_child_target. * bfd-target.c (target_bfd_target_info): New. (target_bfd) <shortname, longname, doc>: Delete. <info>: New. * bsd-kvm.c (bsd_kvm_target_info): New. (bsd_kvm_target) <shortname, longname, doc>: Delete. <info>: New. (bsd_kvm_target::open): Rename to ... (bsd_kvm_target_open): ... this. Adjust. * bsd-uthread.c (bsd_uthread_target_info): New. (bsd_uthread_target) <shortname, longname, doc>: Delete. <info>: New. * corefile.c (core_file_command): Adjust. * corelow.c (core_target_info): New. (core_target) <shortname, longname, doc>: Delete. <info>: New. (core_target::open): Rename to ... (core_target_open): ... this. Adjust. * ctf.c (ctf_target_info): New. (ctf_target) <shortname, longname, doc>: Delete. <info>: New. (ctf_target::open): Rename to ... (ctf_target_open): ... this. (_initialize_ctf): Adjust. * exec.c (exec_target_info): New. (exec_target) <shortname, longname, doc>: Delete. <info>: New. (exec_target::open): Rename to ... (exec_target_open): ... this. * gdbcore.h (core_target_open): Declare. * go32-nat.c (_initialize_go32_nat): Use add_inf_child_target. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Use add_inf_child_target. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Use add_inf_child_target. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Use add_inf_child_target. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Use add_inf_child_target. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Use add_inf_child_target. * i386-gnu-nat.c (_initialize_i386gnu_nat): Use add_inf_child_target. * i386-linux-nat.c (_initialize_i386_linux_nat): Use add_inf_child_target. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Use add_inf_child_target. * i386-obsd-nat.c (_initialize_i386obsd_nat): Use add_inf_child_target. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Use add_inf_child_target. * inf-child.c (inf_child_target_info): New. (inf_child_target::info): New. (inf_child_open_target): Remove 'target' parameter. Use get_native_target instead. (inf_child_target::open): Delete. (add_inf_child_target): New. * inf-child.h (inf_child_target) <shortname, longname, doc, open>: Delete. <info>: New. (add_inf_child_target): Declare. (inf_child_open_target): Declare. * linux-thread-db.c (thread_db_target_info): New. (thread_db_target) <shortname, longname, doc>: Delete. <info>: New. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Use add_inf_child_target. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Use add_inf_child_target. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Use add_inf_child_target. * m88k-bsd-nat.c (_initialize_m88kbsd_nat): Use add_inf_child_target. * make-target-delegates (print_class): Adjust. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Use add_inf_child_target. * mips-linux-nat.c (_initialize_mips_linux_nat): Use add_inf_child_target. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Use add_inf_child_target. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Use add_inf_child_target. * nto-procfs.c (nto_native_target_info): New. (nto_procfs_target_native) <shortname, longname, doc>: Delete. <info>: New. (nto_procfs_target_info): New. (nto_procfs_target_procfs) <shortname, longname, doc>: Delete. <info>: New. (init_procfs_targets): Adjust. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Use add_inf_child_target. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Use add_inf_child_target. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Use add_inf_child_target. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Use add_inf_child_target. * ravenscar-thread.c (ravenscar_target_info): New. (ravenscar_thread_target) <shortname, longname, doc>: Delete. <info>: New. * record-btrace.c (record_btrace_target_info): (record_btrace_target) <shortname, longname, doc>: Delete. <info>: New. (record_btrace_target::open): Rename to ... (record_btrace_target_open): ... this. Adjust. * record-full.c (record_longname, record_doc): New. (record_full_base_target) <shortname, longname, doc>: Delete. <info>: New. (record_full_target_info): New. (record_full_target): <shortname>: Delete. <info>: New. (record_full_core_open_1, record_full_open_1): Update comments. (record_full_base_target::open): Rename to ... (record_full_open): ... this. (cmd_record_full_restore): Update. (_initialize_record_full): Update. * remote-sim.c (remote_sim_target_info): New. (gdbsim_target) <shortname, longname, doc>: Delete. <info>: New. (gdbsim_target::open): Rename to ... (gdbsim_target_open): ... this. (_initialize_remote_sim): Adjust. * remote.c (remote_doc): New. (remote_target_info): New. (remote_target) <shortname, longname, doc>: Delete. <info>: New. (extended_remote_target_info): New. (extended_remote_target) <shortname, longname, doc>: Delete. <info>: New. (remote_target::open_1): Make static. Adjust. * rs6000-nat.c (_initialize_rs6000_nat): Use add_inf_child_target. * s390-linux-nat.c (_initialize_s390_nat): Use add_inf_child_target. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Use add_inf_child_target. * sol-thread.c (thread_db_target_info): New. (sol_thread_target) <shortname, longname, doc>: Delete. <info>: New. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Use add_inf_child_target. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Use add_inf_child_target. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Use add_inf_child_target. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use add_inf_child_target. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Use add_inf_child_target. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Use add_inf_child_target. * spu-linux-nat.c (_initialize_spu_nat): Use add_inf_child_target. * spu-multiarch.c (spu_multiarch_target_info): New. (spu_multiarch_target) <shortname, longname, doc>: Delete. <info>: New. * target-delegates.c: Regenerate. * target.c: Include <unordered_map>. (target_ops_p): Delete. (DEF_VEC_P(target_ops_p)): Delete. (target_factories): New. (test_target_info): New. (test_target_ops::info): New. (open_target): Adjust to use target_factories. (add_target_with_completer): Rename to ... (add_target): ... this. Change prototype. Register target_info and open callback in target_factories. Register target_info in command context instead of target_ops. (add_target): Delete old implementation. (add_deprecated_target_alias): Change prototype. Adjust. (the_native_target): New. (set_native_target, get_native_target): New. (find_default_run_target): Use the_native_target. (find_attach_target, find_run_target): Simplify. (target_ops::open): Delete. (dummy_target_info): New. (dummy_target::shortname, dummy_target::longname) (dummy_target::doc): Delete. (dummy_target::info): New. (debug_target::shortname, debug_target::longname) (debug_target::doc): Delete. (debug_target::info): New. * target.h (struct target_info): New. (target_ops::~target_ops): Add comment. (target_ops::info): New. (target_ops::shortname, target_ops::longname, target_ops::doc): No longer virtual. Implement in terms of target_info. (set_native_target, get_native_target): Declare. (target_open_ftype): New. (add_target, add_target_with_completer) (add_deprecated_target_alias): Change prototype. (test_target) <shortname, longname, doc>: Delete. <info>: New. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Use add_inf_child_target. * tracefile-tfile.c (tfile_target_info): New. (tfile_target) <shortname, longname, doc>: Delete. <info>: New. (tfile_target::open): Rename to ... (tfile_target_open): ... this. (_initialize_tracefile_tfile): Adjust. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Use add_inf_child_target. * windows-nat.c (_initialize_windows_nat): Use add_inf_child_target. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Use add_inf_child_target.
2018-05-03 01:37:32 +02:00
const target_info &info () const override
{ return ravenscar_target_info; }
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
target_ops::to_stratum -> target_ops::stratum() virtual method Given that a target's stratum is a property of the type, and not of an instance of the type, get rid of to_stratum data field and replace it with a virtual method. I.e., when we have e.g., 10 target remote instances active, there's no need for each of the instances to have their own to_stratum copy. gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * aix-thread.c (aix_thread_target) <aix_thread_target>: Delete. <stratum>: New override. * bfd-target.c (aix_thread_target) <aix_thread_target>: Delete. <stratum>: New override. * bsd-uthread.c (bsd_uthread_target) <bsd_uthread_target>: Delete. <stratum>: New override. * exec.c (exec_target) <exec_target>: Delete. <stratum>: New override. * gdbarch-selftests.c (register_to_value_test): Adjust to use the stratum method instead of the to_stratum field. * linux-thread-db.c (thread_db_target) <thread_db_target>: Delete. <stratum>: New override. (thread_db_target::thread_db_target): Delete. * make-target-delegates (print_class): Don't print a ctor declaration. Print a stratum method override declaration. * process-stratum-target.h (process_stratum_target) <process_stratum_target>: Delete. <stratum>: New override. * ravenscar-thread.c (ravenscar_thread_target) <ravenscar_thread_target>: Delete. <stratum>: New override. * record-btrace.c (record_btrace_target) <record_btrace_target>: Delete. <stratum>: New override. * record-full.c (record_full_base_target) <record_full_base_target>: Delete. <stratum>: New override. * record.c (record_disconnect, record_detach) (record_mourn_inferior, record_kill): Adjust to use the stratum method instead of the to_stratum field. * regcache.c (cooked_read_test, cooked_write_test): Likewise. * sol-thread.c (sol_thread_target) <sol_thread_target>: Delete. <stratum>: New override. * spu-multiarch.c (spu_multiarch_target) <spu_multiarch_target>: Delete. <stratum>: New override. * target-delegates.c: Regenerate. * target.c (target_stack::push, target_stack::unpush) (pop_all_targets_above, pop_all_targets_at_and_above) (info_target_command, target_require_runnable) (target_stack::find_beneath): Adjust to use the stratum method instead of the to_stratum field. (dummy_target::dummy_target): Delete. (dummy_target::stratum): New. (debug_target::debug_target): Delete. (debug_target::stratum): New. (maintenance_print_target_stack): Adjust to use the stratum method instead of the to_stratum field. * target.h (struct target_ops) <stratum>: New method. <to_stratum>: Delete. <is_pushed>: Adjust to use the stratum method instead of the to_stratum field.
2018-11-30 18:49:49 +01:00
strata stratum () const override { return thread_stratum; }
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
void fetch_registers (struct regcache *, int) override;
void store_registers (struct regcache *, int) override;
void prepare_to_store (struct regcache *) override;
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool stopped_by_sw_breakpoint () override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool stopped_by_hw_breakpoint () override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool stopped_by_watchpoint () override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool stopped_data_address (CORE_ADDR *) override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool thread_alive (ptid_t ptid) override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
int core_of_thread (ptid_t ptid) override;
void update_thread_list () override;
const char *extra_thread_info (struct thread_info *) override;
Change pid_to_str to return std::string Currently the target pid_to_str method returns a const char *, so many implementations have a static buffer that they update. This patch changes these methods to return a std::string instead. I think this is cleaner and avoids possible gotchas when calling pid_to_str on different ptids in a single statement. (Though no such calls exist currently.) This also updates various helper functions, and the gdbarch pid_to_str methods. I also made a best effort to fix all the callers, but I can't build some of the *-nat.c files. Tested by the buildbot. gdb/ChangeLog 2019-03-13 Tom Tromey <tromey@adacore.com> * i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers) (i386_gnu_nat_target::store_registers): Update. * target-debug.h (target_debug_print_std_string): New macro. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * windows-tdep.c (display_one_tib): Update. * tui/tui-stack.c (tui_make_status_line): Update. * top.c (print_inferior_quit_action): Update. * thread.c (thr_try_catch_cmd): Update. (add_thread_with_info): Update. (thread_target_id_str): Update. (thr_try_catch_cmd): Update. (thread_command): Update. (thread_find_command): Update. * record-btrace.c (record_btrace_target::info_record) (record_btrace_resume_thread, record_btrace_target::resume) (record_btrace_cancel_resume, record_btrace_step_thread) (record_btrace_target::wait, record_btrace_target::wait) (record_btrace_target::wait, record_btrace_target::stop): Update. * progspace.c (print_program_space): Update. * process-stratum-target.c (process_stratum_target::thread_address_space): Update. * linux-fork.c (linux_fork_mourn_inferior) (detach_checkpoint_command, info_checkpoints_command) (linux_fork_context): Update. (linux_fork_detach): Update. (class scoped_switch_fork_info): Update. (delete_checkpoint_command): Update. * infrun.c (follow_fork_inferior): Update. (follow_fork_inferior): Update. (proceed_after_vfork_done): Update. (handle_vfork_child_exec_or_exit): Update. (follow_exec): Update. (displaced_step_prepare_throw): Update. (displaced_step_restore): Update. (start_step_over): Update. (resume_1): Update. (clear_proceed_status_thread): Update. (proceed): Update. (print_target_wait_results): Update. (do_target_wait): Update. (context_switch): Update. (stop_all_threads): Update. (restart_threads): Update. (finish_step_over): Update. (handle_signal_stop): Update. (switch_back_to_stepped_thread): Update. (keep_going_pass_signal): Update. (print_exited_reason): Update. (normal_stop): Update. * inferior.c (inferior_pid_to_str): Change return type. (print_selected_inferior): Update. (add_inferior): Update. (detach_inferior): Update. * dummy-frame.c (fprint_dummy_frames): Update. * dcache.c (dcache_info_1): Update. * btrace.c (btrace_enable, btrace_disable, btrace_teardown) (btrace_fetch, btrace_clear): Update. * linux-tdep.c (linux_core_pid_to_str): Change return type. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return type. * fbsd-tdep.c (fbsd_core_pid_to_str): Change return type. * sol2-tdep.h (sol2_core_pid_to_str): Change return type. * sol2-tdep.c (sol2_core_pid_to_str): Change return type. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (core_pid_to_str): Change return type. * windows-nat.c (struct windows_nat_target) <pid_to_str>: Change return type. (windows_nat_target::pid_to_str): Change return type. (windows_delete_thread): Update. (windows_nat_target::attach): Update. (windows_nat_target::files_info): Update. * target-delegates.c: Rebuild. * sol-thread.c (class sol_thread_target) <pid_to_str>: Change return type. (sol_thread_target::pid_to_str): Change return type. * remote.c (class remote_target) <pid_to_str>: Change return type. (remote_target::pid_to_str): Change return type. (extended_remote_target::attach, remote_target::remote_stop_ns) (remote_target::remote_notif_remove_queued_reply) (remote_target::push_stop_reply, remote_target::disable_btrace): Update. (extended_remote_target::attach): Update. * remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return type. (gdbsim_target::pid_to_str): Change return type. * ravenscar-thread.c (struct ravenscar_thread_target) <pid_to_str>: Change return type. (ravenscar_thread_target::pid_to_str): Change return type. * procfs.c (class procfs_target) <pid_to_str>: Change return type. (procfs_target::pid_to_str): Change return type. (procfs_target::attach): Update. (procfs_target::detach): Update. (procfs_target::fetch_registers): Update. (procfs_target::store_registers): Update. (procfs_target::wait): Update. (procfs_target::files_info): Update. * obsd-nat.c (obsd_nat_target::pid_to_str): Change return type. * nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change return type. (nto_procfs_target::pid_to_str): Change return type. (nto_procfs_target::files_info, nto_procfs_target::attach): Update. * linux-thread-db.c (class thread_db_target) <pid_to_str>: Change return type. * linux-nat.c (linux_nat_target::pid_to_str): Change return type. (exit_lwp): Update. (attach_proc_task_lwp_callback, get_detach_signal) (detach_one_lwp, resume_lwp, linux_nat_target::resume) (linux_nat_target::resume, wait_lwp, stop_callback) (maybe_clear_ignore_sigint, stop_wait_callback, status_callback) (save_stop_reason, select_event_lwp, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps) (linux_nat_target::wait, linux_nat_stop_lwp): Update. * inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return type. (inf_ptrace_target::attach): Update. (inf_ptrace_target::files_info): Update. * go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return type. (go32_nat_target::pid_to_str): Change return type. * gnu-nat.c (gnu_nat_target::pid_to_str): Change return type. (gnu_nat_target::wait): Update. (gnu_nat_target::wait): Update. (gnu_nat_target::resume): Update. * fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type. (fbsd_nat_target::wait): Update. * darwin-nat.c (darwin_nat_target::pid_to_str): Change return type. (darwin_nat_target::attach): Update. * corelow.c (class core_target) <pid_to_str>: Change return type. (core_target::pid_to_str): Change return type. * target.c (normal_pid_to_str): Change return type. (default_pid_to_str): Likewise. (target_pid_to_str): Change return type. (target_translate_tls_address): Update. (target_announce_detach): Update. * bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change return type. (bsd_uthread_target::pid_to_str): Change return type. * bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return type. (bsd_kvm_target::pid_to_str): Change return type. * aix-thread.c (class aix_thread_target) <pid_to_str>: Change return type. (aix_thread_target::pid_to_str): Change return type. * target.h (struct target_ops) <pid_to_str>: Change return type. (target_pid_to_str, normal_pid_to_str): Likewise. * obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return type. * linux-nat.h (class linux_nat_target) <pid_to_str>: Change return type. * inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change return type. * gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return type. * fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return type. * darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change return type.
2019-02-28 17:09:55 +01:00
std::string pid_to_str (ptid_t) override;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ptid_t get_ada_task_ptid (long lwp, long thread) override;
void mourn_inferior () override;
void close () override
{
delete this;
}
private:
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
/* PTID of the last thread that received an event.
This can be useful to determine the associated task that received
the event, to make it the current task. */
ptid_t m_base_ptid;
thread_info *add_active_thread ();
ptid_t active_task (int cpu);
bool task_is_currently_active (ptid_t ptid);
bool runtime_initialized ();
};
/* Return true iff PTID corresponds to a ravenscar task. */
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
static bool
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
is_ravenscar_task (ptid_t ptid)
{
/* By construction, ravenscar tasks have their LWP set to zero.
Also make sure that the TID is nonzero, as some remotes, when
asked for the list of threads, will return the first thread
as having its TID set to zero. For instance, TSIM version
2.0.48 for LEON3 sends 'm0' as a reply to the 'qfThreadInfo'
query, which the remote protocol layer then treats as a thread
whose TID is 0. This is obviously not a ravenscar task. */
return ptid.lwp () == 0 && ptid.tid () != 0;
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
}
/* Given PTID, which can be either a ravenscar task or a CPU thread,
return which CPU that ptid is running on.
This assume that PTID is a valid ptid_t. Otherwise, a gdb_assert
will be triggered. */
static int
ravenscar_get_thread_base_cpu (ptid_t ptid)
{
int base_cpu;
if (is_ravenscar_task (ptid))
{
struct ada_task_info *task_info = ada_get_task_info_from_ptid (ptid);
gdb_assert (task_info != NULL);
base_cpu = task_info->base_cpu;
}
else
{
/* We assume that the LWP of the PTID is equal to the CPU number. */
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
base_cpu = ptid.lwp ();
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
}
return base_cpu;
}
/* Given a ravenscar task (identified by its ptid_t PTID), return true
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
if this task is the currently active task on the cpu that task is
running on.
In other words, this function determine which CPU this task is
currently running on, and then return nonzero if the CPU in question
is executing the code for that task. If that's the case, then
that task's registers are in the CPU bank. Otherwise, the task
is currently suspended, and its registers have been saved in memory. */
bool
ravenscar_thread_target::task_is_currently_active (ptid_t ptid)
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
{
ptid_t active_task_ptid
= active_task (ravenscar_get_thread_base_cpu (ptid));
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
2018-06-11 22:45:22 +02:00
return ptid == active_task_ptid;
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
}
/* Return the CPU thread (as a ptid_t) on which the given ravenscar
task is running.
This is the thread that corresponds to the CPU on which the task
is running. */
static ptid_t
get_base_thread_from_ravenscar_task (ptid_t ptid)
{
int base_cpu;
if (!is_ravenscar_task (ptid))
return ptid;
base_cpu = ravenscar_get_thread_base_cpu (ptid);
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
return ptid_t (ptid.pid (), base_cpu, 0);
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
}
/* Fetch the ravenscar running thread from target memory, make sure
there's a corresponding thread in the thread list, and return it.
If the runtime is not initialized, return NULL. */
thread_info *
ravenscar_thread_target::add_active_thread ()
{
Multi-target support This commit adds multi-target support to GDB. What this means is that with this commit, GDB can now be connected to different targets at the same time. E.g., you can debug a live native process and a core dump at the same time, connect to multiple gdbservers, etc. Actually, the word "target" is overloaded in gdb. We already have a target stack, with pushes several target_ops instances on top of one another. We also have "info target" already, which means something completely different to what this patch does. So from here on, I'll be using the "target connections" term, to mean an open process_stratum target, pushed on a target stack. This patch makes gdb have multiple target stacks, and multiple process_stratum targets open simultaneously. The user-visible changes / commands will also use this terminology, but of course it's all open to debate. User-interface-wise, not that much changes. The main difference is that each inferior may have its own target connection. A target connection (e.g., a target extended-remote connection) may support debugging multiple processes, just as before. Say you're debugging against gdbserver in extended-remote mode, and you do "add-inferior" to prepare to spawn a new process, like: (gdb) target extended-remote :9999 ... (gdb) start ... (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) file a.out ... (gdb) start ... At this point, you have two inferiors connected to the same gdbserver. With this commit, GDB will maintain a target stack per inferior, instead of a global target stack. To preserve the behavior above, by default, "add-inferior" makes the new inferior inherit a copy of the target stack of the current inferior. Same across a fork - the child inherits a copy of the target stack of the parent. While the target stacks are copied, the targets themselves are not. Instead, target_ops is made a refcounted_object, which means that target_ops instances are refcounted, which each inferior counting for a reference. What if you want to create an inferior and connect it to some _other_ target? For that, this commit introduces a new "add-inferior -no-connection" option that makes the new inferior not share the current inferior's target. So you could do: (gdb) target extended-remote :9999 Remote debugging using :9999 ... (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 <null> (gdb) tar extended-remote :10000 Remote debugging using :10000 ... (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 process 18450 target:/home/pedro/tmp/main (gdb) A following patch will extended "info inferiors" to include a column indicating which connection an inferior is bound to, along with a couple other UI tweaks. Other than that, debugging is the same as before. Users interact with inferiors and threads as before. The only difference is that inferiors may be bound to processes running in different machines. That's pretty much all there is to it in terms of noticeable UI changes. On to implementation. Since we can be connected to different systems at the same time, a ptid_t is no longer a unique identifier. Instead a thread can be identified by a pair of ptid_t and 'process_stratum_target *', the later being the instance of the process_stratum target that owns the process/thread. Note that process_stratum_target inherits from target_ops, and all process_stratum targets inherit from process_stratum_target. In earlier patches, many places in gdb were converted to refer to threads by thread_info pointer instead of ptid_t, but there are still places in gdb where we start with a pid/tid and need to find the corresponding inferior or thread_info objects. So you'll see in the patch many places adding a process_stratum_target parameter to functions that used to take only a ptid_t. Since each inferior has its own target stack now, we can always find the process_stratum target for an inferior. That is done via a inf->process_target() convenience method. Since each inferior has its own target stack, we need to handle the "beneath" calls when servicing target calls. The solution I settled with is just to make sure to switch the current inferior to the inferior you want before making a target call. Not relying on global context is just not feasible in current GDB. Fortunately, there aren't that many places that need to do that, because generally most code that calls target methods already has the current context pointing to the right inferior/thread. Note, to emphasize -- there's no method to "switch to this target stack". Instead, you switch the current inferior, and that implicitly switches the target stack. In some spots, we need to iterate over all inferiors so that we reach all target stacks. Native targets are still singletons. There's always only a single instance of such targets. Remote targets however, we'll have one instance per remote connection. The exec target is still a singleton. There's only one instance. I did not see the point of instanciating more than one exec_target object. After vfork, we need to make sure to push the exec target on the new inferior. See exec_on_vfork. For type safety, functions that need a {target, ptid} pair to identify a thread, take a process_stratum_target pointer for target parameter instead of target_ops *. Some shared code in gdb/nat/ also need to gain a target pointer parameter. This poses an issue, since gdbserver doesn't have process_stratum_target, only target_ops. To fix this, this commit renames gdbserver's target_ops to process_stratum_target. I think this makes sense. There's no concept of target stack in gdbserver, and gdbserver's target_ops really implements a process_stratum-like target. The thread and inferior iterator functions also gain process_stratum_target parameters. These are used to be able to iterate over threads and inferiors of a given target. Following usual conventions, if the target pointer is null, then we iterate over threads and inferiors of all targets. I tried converting "add-inferior" to the gdb::option framework, as a preparatory patch, but that stumbled on the fact that gdb::option does not support file options yet, for "add-inferior -exec". I have a WIP patchset that adds that, but it's not a trivial patch, mainly due to need to integrate readline's filename completion, so I deferred that to some other time. In infrun.c/infcmd.c, the main change is that we need to poll events out of all targets. See do_target_wait. Right after collecting an event, we switch the current inferior to an inferior bound to the target that reported the event, so that target methods can be used while handling the event. This makes most of the code transparent to multi-targets. See fetch_inferior_event. infrun.c:stop_all_threads is interesting -- in this function we need to stop all threads of all targets. What the function does is send an asynchronous stop request to all threads, and then synchronously waits for events, with target_wait, rinse repeat, until all it finds are stopped threads. Now that we have multiple targets, it's not efficient to synchronously block in target_wait waiting for events out of one target. Instead, we implement a mini event loop, with interruptible_select, select'ing on one file descriptor per target. For this to work, we need to be able to ask the target for a waitable file descriptor. Such file descriptors already exist, they are the descriptors registered in the main event loop with add_file_handler, inside the target_async implementations. This commit adds a new target_async_wait_fd target method that just returns the file descriptor in question. See wait_one / stop_all_threads in infrun.c. The 'threads_executing' global is made a per-target variable. Since it is only relevant to process_stratum_target targets, this is where it is put, instead of in target_ops. You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress. Current limitations: - You can only resume more that one target at the same time if all targets support asynchronous debugging, and support non-stop mode. It should be possible to support mixed all-stop + non-stop backends, but that is left for another time. This means that currently in order to do multi-target with gdbserver you need to issue "maint set target-non-stop on". I would like to make that mode be the default, but we're not there yet. Note that I'm talking about how the target backend works, only. User-visible all-stop mode works just fine. - As explained above, connecting to different remote servers at the same time is likely to produce bad results if they don't support the exact set of RSP features. FreeBSD updates courtesy of John Baldwin. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> John Baldwin <jhb@FreeBSD.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::thread_architecture): Adjust. * ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call. (task_command_1): Likewise. * aix-thread.c (sync_threadlists, aix_thread_target::resume) (aix_thread_target::wait, aix_thread_target::fetch_registers) (aix_thread_target::store_registers) (aix_thread_target::thread_alive): Adjust. * amd64-fbsd-tdep.c: Include "inferior.h". (amd64fbsd_get_thread_local_address): Pass down target. * amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle thread's gdbarch instead of target_gdbarch. * break-catch-sig.c (signal_catchpoint_print_it): Adjust call to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Likewise. * breakpoint.c (breakpoints_should_be_inserted_now): Consider all inferiors. (update_inserted_breakpoint_locations): Skip if inferiors with no execution. (update_global_location_list): When handling moribund locations, find representative inferior for location's pspace, and use thread count of its process_stratum target. * bsd-kvm.c (bsd_kvm_target_open): Pass target down. * bsd-uthread.c (bsd_uthread_target::wait): Use as_process_stratum_target and adjust thread_change_ptid and add_thread calls. (bsd_uthread_target::update_thread_list): Use as_process_stratum_target and adjust find_thread_ptid, thread_change_ptid and add_thread calls. * btrace.c (maint_btrace_packet_history_cmd): Adjust find_thread_ptid call. * corelow.c (add_to_thread_list): Adjust add_thread call. (core_target_open): Adjust add_thread_silent and thread_count calls. (core_target::pid_to_str): Adjust find_inferior_ptid call. * ctf.c (ctf_target_open): Adjust add_thread_silent call. * event-top.c (async_disconnect): Pop targets from all inferiors. * exec.c (add_target_sections): Push exec target on all inferiors sharing the program space. (remove_target_sections): Remove the exec target from all inferiors sharing the program space. (exec_on_vfork): New. * exec.h (exec_on_vfork): Declare. * fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::update_thread_list): Adjust. (fbsd_nat_target::resume): Adjust. (fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust. * fbsd-tdep.c (fbsd_corefile_thread): Adjust get_thread_arch_regcache call. * fork-child.c (gdb_startup_inferior): Pass target down to startup_inferior and set_executing. * gdbthread.h (struct process_stratum_target): Forward declare. (add_thread, add_thread_silent, add_thread_with_info) (in_thread_list): Add process_stratum_target parameter. (find_thread_ptid(inferior*, ptid_t)): New overload. (find_thread_ptid, thread_change_ptid): Add process_stratum_target parameter. (all_threads()): Delete overload. (all_threads, all_non_exited_threads): Add process_stratum_target parameter. (all_threads_safe): Use brace initialization. (thread_count): Add process_stratum_target parameter. (set_resumed, set_running, set_stop_requested, set_executing) (threads_are_executing, finish_thread_state): Add process_stratum_target parameter. (switch_to_thread): Use is_current_thread. * i386-fbsd-tdep.c: Include "inferior.h". (i386fbsd_get_thread_local_address): Pass down target. * i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust. * inf-child.c (inf_child_target::maybe_unpush_target): Remove have_inferiors check. * inf-ptrace.c (inf_ptrace_target::create_inferior) (inf_ptrace_target::attach): Adjust. * infcall.c (run_inferior_call): Adjust. * infcmd.c (run_command_1): Pass target to scoped_finish_thread_state. (proceed_thread_callback): Skip inferiors with no execution. (continue_command): Rename 'all_threads' local to avoid hiding 'all_threads' function. Adjust get_last_target_status call. (prepare_one_step): Adjust set_running call. (signal_command): Use user_visible_resume_target. Compare thread pointers instead of inferior_ptid. (info_program_command): Adjust to pass down target. (attach_command): Mark target's 'thread_executing' flag. (stop_current_target_threads_ns): New, factored out from ... (interrupt_target_1): ... this. Switch inferior before making target calls. * inferior-iter.h (struct all_inferiors_iterator, struct all_inferiors_range) (struct all_inferiors_safe_range) (struct all_non_exited_inferiors_range): Filter on process_stratum_target too. Remove explicit. * inferior.c (inferior::inferior): Push dummy target on target stack. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors): Add process_stratum_target parameter, and pass it down. (have_live_inferiors): Adjust. (switch_to_inferior_and_push_target): New. (add_inferior_command, clone_inferior_command): Handle "-no-connection" parameter. Use switch_to_inferior_and_push_target. (_initialize_inferior): Mention "-no-connection" option in the help of "add-inferior" and "clone-inferior" commands. * inferior.h: Include "process-stratum-target.h". (interrupt_target_1): Use bool. (struct inferior) <push_target, unpush_target, target_is_pushed, find_target_beneath, top_target, process_target, target_at, m_stack>: New. (discard_all_inferiors): Delete. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors) (all_inferiors, all_non_exited_inferiors): Add process_stratum_target parameter. * infrun.c: Include "gdb_select.h" and <unordered_map>. (target_last_proc_target): New global. (follow_fork_inferior): Push target on new inferior. Pass target to add_thread_silent. Call exec_on_vfork. Handle target's reference count. (follow_fork): Adjust get_last_target_status call. Also consider target. (follow_exec): Push target on new inferior. (struct execution_control_state) <target>: New field. (user_visible_resume_target): New. (do_target_resume): Call target_async. (resume_1): Set target's threads_executing flag. Consider resume target. (commit_resume_all_targets): New. (proceed): Also consider resume target. Skip threads of inferiors with no execution. Commit resumtion in all targets. (start_remote): Pass current inferior to wait_for_inferior. (infrun_thread_stop_requested): Consider target as well. Pass thread_info pointer to clear_inline_frame_state instead of ptid. (infrun_thread_thread_exit): Consider target as well. (random_pending_event_thread): New inferior parameter. Use it. (do_target_wait): Rename to ... (do_target_wait_1): ... this. Add inferior parameter, and pass it down. (threads_are_resumed_pending_p, do_target_wait): New. (prepare_for_detach): Adjust calls. (wait_for_inferior): New inferior parameter. Handle it. Use do_target_wait_1 instead of do_target_wait. (fetch_inferior_event): Adjust. Switch to representative inferior. Pass target down. (set_last_target_status): Add process_stratum_target parameter. Save target in global. (get_last_target_status): Add process_stratum_target parameter and handle it. (nullify_last_target_wait_ptid): Clear 'target_last_proc_target'. (context_switch): Check inferior_ptid == null_ptid before calling inferior_thread(). (get_inferior_stop_soon): Pass down target. (wait_one): Rename to ... (poll_one_curr_target): ... this. (struct wait_one_event): New. (wait_one): New. (stop_all_threads): Adjust. (handle_no_resumed, handle_inferior_event): Adjust to consider the event's target. (switch_back_to_stepped_thread): Also consider target. (print_stop_event): Update. (normal_stop): Update. Also consider the resume target. * infrun.h (wait_for_inferior): Remove declaration. (user_visible_resume_target): New declaration. (get_last_target_status, set_last_target_status): New process_stratum_target parameter. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter, and use it. (clear_inline_frame_state (thread_info*)): New. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter. (clear_inline_frame_state (thread_info*)): Declare. * linux-fork.c (delete_checkpoint_command): Pass target down to find_thread_ptid. (checkpoint_command): Adjust. * linux-nat.c (linux_nat_target::follow_fork): Switch to thread instead of just tweaking inferior_ptid. (linux_nat_switch_fork): Pass target down to thread_change_ptid. (exit_lwp): Pass target down to find_thread_ptid. (attach_proc_task_lwp_callback): Pass target down to add_thread/set_running/set_executing. (linux_nat_target::attach): Pass target down to thread_change_ptid. (get_detach_signal): Pass target down to find_thread_ptid. Consider last target status's target. (linux_resume_one_lwp_throw, resume_lwp) (linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp) (stop_wait_callback, save_stop_reason, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down. (linux_nat_target::async_wait_fd): New. (linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass target down. * linux-nat.h (linux_nat_target::async_wait_fd): Declare. * linux-tdep.c (get_thread_arch_regcache): Pass target down. * linux-thread-db.c (struct thread_db_info::process_target): New field. (add_thread_db_info): Save target. (get_thread_db_info): New process_stratum_target parameter. Also match target. (delete_thread_db_info): New process_stratum_target parameter. Also match target. (thread_from_lwp): Adjust to pass down target. (thread_db_notice_clone): Pass down target. (check_thread_db_callback): Pass down target. (try_thread_db_load_1): Always push the thread_db target. (try_thread_db_load, record_thread): Pass target down. (thread_db_target::detach): Pass target down. Always unpush the thread_db target. (thread_db_target::wait, thread_db_target::mourn_inferior): Pass target down. Always unpush the thread_db target. (find_new_threads_callback, thread_db_find_new_threads_2) (thread_db_target::update_thread_list): Pass target down. (thread_db_target::pid_to_str): Pass current inferior down. (thread_db_target::get_thread_local_address): Pass target down. (thread_db_target::resume, maintenance_check_libthread_db): Pass target down. * nto-procfs.c (nto_procfs_target::update_thread_list): Adjust. * procfs.c (procfs_target::procfs_init_inferior): Declare. (proc_set_current_signal, do_attach, procfs_target::wait): Adjust. (procfs_init_inferior): Rename to ... (procfs_target::procfs_init_inferior): ... this and adjust. (procfs_target::create_inferior, procfs_notice_thread) (procfs_do_thread_registers): Adjust. * ppc-fbsd-tdep.c: Include "inferior.h". (ppcfbsd_get_thread_local_address): Pass down target. * proc-service.c (ps_xfer_memory): Switch current inferior and program space as well. (get_ps_regcache): Pass target down. * process-stratum-target.c (process_stratum_target::thread_address_space) (process_stratum_target::thread_architecture): Pass target down. * process-stratum-target.h (process_stratum_target::threads_executing): New field. (as_process_stratum_target): New. * ravenscar-thread.c (ravenscar_thread_target::update_inferior_ptid): Pass target down. (ravenscar_thread_target::wait, ravenscar_add_thread): Pass target down. * record-btrace.c (record_btrace_target::info_record): Adjust. (record_btrace_target::record_method) (record_btrace_target::record_is_replaying) (record_btrace_target::fetch_registers) (get_thread_current_frame_id, record_btrace_target::resume) (record_btrace_target::wait, record_btrace_target::stop): Pass target down. * record-full.c (record_full_wait_1): Switch to event thread. Pass target down. * regcache.c (regcache::regcache) (get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add process_stratum_target parameter and handle it. (current_thread_target): New global. (get_thread_regcache): Add process_stratum_target parameter and handle it. Switch inferior before calling target method. (get_thread_regcache): Pass target down. (get_thread_regcache_for_ptid): Pass target down. (registers_changed_ptid): Add process_stratum_target parameter and handle it. (registers_changed_thread, registers_changed): Pass target down. (test_get_thread_arch_aspace_regcache): New. (current_regcache_test): Define a couple local test_target_ops instances and use them for testing. (readwrite_regcache): Pass process_stratum_target parameter. (cooked_read_test, cooked_write_test): Pass mock_target down. * regcache.h (get_thread_regcache, get_thread_arch_regcache) (get_thread_arch_aspace_regcache): Add process_stratum_target parameter. (regcache::target): New method. (regcache::regcache, regcache::get_thread_arch_aspace_regcache) (regcache::registers_changed_ptid): Add process_stratum_target parameter. (regcache::m_target): New field. (registers_changed_ptid): Add process_stratum_target parameter. * remote.c (remote_state::supports_vCont_probed): New field. (remote_target::async_wait_fd): New method. (remote_unpush_and_throw): Add remote_target parameter. (get_current_remote_target): Adjust. (remote_target::remote_add_inferior): Push target. (remote_target::remote_add_thread) (remote_target::remote_notice_new_inferior) (get_remote_thread_info): Pass target down. (remote_target::update_thread_list): Skip threads of inferiors bound to other targets. (remote_target::close): Don't discard inferiors. (remote_target::add_current_inferior_and_thread) (remote_target::process_initial_stop_replies) (remote_target::start_remote) (remote_target::remote_serial_quit_handler): Pass down target. (remote_target::remote_unpush_target): New remote_target parameter. Unpush the target from all inferiors. (remote_target::remote_unpush_and_throw): New remote_target parameter. Pass it down. (remote_target::open_1): Check whether the current inferior has execution instead of checking whether any inferior is live. Pass target down. (remote_target::remote_detach_1): Pass down target. Use remote_unpush_target. (extended_remote_target::attach): Pass down target. (remote_target::remote_vcont_probe): Set supports_vCont_probed. (remote_target::append_resumption): Pass down target. (remote_target::append_pending_thread_resumptions) (remote_target::remote_resume_with_hc, remote_target::resume) (remote_target::commit_resume): Pass down target. (remote_target::remote_stop_ns): Check supports_vCont_probed. (remote_target::interrupt_query) (remote_target::remove_new_fork_children) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::remote_parse_stop_reply) (remote_target::process_stop_reply): Pass down target. (first_remote_resumed_thread): New remote_target parameter. Pass it down. (remote_target::wait_as): Pass down target. (unpush_and_perror): New remote_target parameter. Pass it down. (remote_target::readchar, remote_target::remote_serial_write) (remote_target::getpkt_or_notif_sane_1) (remote_target::kill_new_fork_children, remote_target::kill): Pass down target. (remote_target::mourn_inferior): Pass down target. Use remote_unpush_target. (remote_target::core_of_thread) (remote_target::remote_btrace_maybe_reopen): Pass down target. (remote_target::pid_to_exec_file) (remote_target::thread_handle_to_thread_info): Pass down target. (remote_target::async_wait_fd): New. * riscv-fbsd-tdep.c: Include "inferior.h". (riscv_fbsd_get_thread_local_address): Pass down target. * sol2-tdep.c (sol2_core_pid_to_str): Pass down target. * sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs) (ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback): Adjust. * solib-spu.c (spu_skip_standalone_loader): Pass down target. * solib-svr4.c (enable_break): Pass down target. * spu-multiarch.c (parse_spufs_run): Pass down target. * spu-tdep.c (spu2ppu_sniffer): Pass down target. * target-delegates.c: Regenerate. * target.c (g_target_stack): Delete. (current_top_target): Return the current inferior's top target. (target_has_execution_1): Refer to the passed-in inferior's top target. (target_supports_terminal_ours): Check whether the initial inferior was already created. (decref_target): New. (target_stack::push): Incref/decref the target. (push_target, push_target, unpush_target): Adjust. (target_stack::unpush): Defref target. (target_is_pushed): Return bool. Adjust to refer to the current inferior's target stack. (dispose_inferior): Delete, and inline parts ... (target_preopen): ... here. Only dispose of the current inferior. (target_detach): Hold strong target reference while detaching. Pass target down. (target_thread_name): Add assertion. (target_resume): Pass down target. (target_ops::beneath, find_target_at): Adjust to refer to the current inferior's target stack. (get_dummy_target): New. (target_pass_ctrlc): Pass the Ctrl-C to the first inferior that has a thread running. (initialize_targets): Rename to ... (_initialize_target): ... this. * target.h: Include "gdbsupport/refcounted-object.h". (struct target_ops): Inherit refcounted_object. (target_ops::shortname, target_ops::longname): Make const. (target_ops::async_wait_fd): New method. (decref_target): Declare. (struct target_ops_ref_policy): New. (target_ops_ref): New typedef. (get_dummy_target): Declare function. (target_is_pushed): Return bool. * thread-iter.c (all_matching_threads_iterator::m_inf_matches) (all_matching_threads_iterator::all_matching_threads_iterator): Handle filter target. * thread-iter.h (struct all_matching_threads_iterator, struct all_matching_threads_range, class all_non_exited_threads_range): Filter by target too. Remove explicit. * thread.c (threads_executing): Delete. (inferior_thread): Pass down current inferior. (clear_thread_inferior_resources): Pass down thread pointer instead of ptid_t. (add_thread_silent, add_thread_with_info, add_thread): Add process_stratum_target parameter. Use it for thread and inferior searches. (is_current_thread): New. (thread_info::deletable): Use it. (find_thread_ptid, thread_count, in_thread_list) (thread_change_ptid, set_resumed, set_running): New process_stratum_target parameter. Pass it down. (set_executing): New process_stratum_target parameter. Pass it down. Adjust reference to 'threads_executing'. (threads_are_executing): New process_stratum_target parameter. Adjust reference to 'threads_executing'. (set_stop_requested, finish_thread_state): New process_stratum_target parameter. Pass it down. (switch_to_thread): Also match inferior. (switch_to_thread): New process_stratum_target parameter. Pass it down. (update_threads_executing): Reimplement. * top.c (quit_force): Pop targets from all inferior. (gdb_init): Don't call initialize_targets. * windows-nat.c (windows_nat_target) <get_windows_debug_event>: Declare. (windows_add_thread, windows_delete_thread): Adjust. (get_windows_debug_event): Rename to ... (windows_nat_target::get_windows_debug_event): ... this. Adjust. * tracefile-tfile.c (tfile_target_open): Pass down target. * gdbsupport/common-gdbthread.h (struct process_stratum_target): Forward declare. (switch_to_thread): Add process_stratum_target parameter. * mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target parameter. Use it. (mi_on_resume): Pass target down. * nat/fork-inferior.c (startup_inferior): Add process_stratum_target parameter. Pass it down. * nat/fork-inferior.h (startup_inferior): Add process_stratum_target parameter. * python/py-threadevent.c (py_get_event_thread): Pass target down. gdb/gdbserver/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * fork-child.c (post_fork_inferior): Pass target down to startup_inferior. * inferiors.c (switch_to_thread): Add process_stratum_target parameter. * lynx-low.c (lynx_target_ops): Now a process_stratum_target. * nto-low.c (nto_target_ops): Now a process_stratum_target. * linux-low.c (linux_target_ops): Now a process_stratum_target. * remote-utils.c (prepare_resume_reply): Pass the target to switch_to_thread. * target.c (the_target): Now a process_stratum_target. (done_accessing_memory): Pass the target to switch_to_thread. (set_target_ops): Ajust to use process_stratum_target. * target.h (struct target_ops): Rename to ... (struct process_stratum_target): ... this. (the_target, set_target_ops): Adjust. (prepare_to_access_memory): Adjust comment. * win32-low.c (child_xfer_memory): Adjust to use process_stratum_target. (win32_target_ops): Now a process_stratum_target.
2020-01-10 21:06:08 +01:00
process_stratum_target *proc_target
= as_process_stratum_target (this->beneath ());
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
int base_cpu;
gdb_assert (!is_ravenscar_task (m_base_ptid));
base_cpu = ravenscar_get_thread_base_cpu (m_base_ptid);
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
if (!runtime_initialized ())
return nullptr;
/* Make sure we set m_base_ptid before calling active_task
as the latter relies on it. */
ptid_t active_ptid = active_task (base_cpu);
gdb_assert (active_ptid != null_ptid);
/* The running thread may not have been added to
Push pruning old threads down to the target When GDB wants to sync the thread list with the target's (e.g., due to "info threads"), it calls update_thread_list: update_thread_list (void) { prune_threads (); target_find_new_threads (); update_threads_executing (); } And then prune_threads does: prune_threads (void) { struct thread_info *tp, *next; for (tp = thread_list; tp; tp = next) { next = tp->next; if (!thread_alive (tp)) delete_thread (tp->ptid); } } Calling thread_live on each thread one by one is expensive. E.g., on Linux, it ends up doing kill(SIG0) once for each thread. Not a big deal, but still a bunch of syscalls... With the remote target, it's cumbersome. That thread_alive call ends up generating one T packet per thread: Sending packet: $Tp2141.2150#82...Packet received: OK Sending packet: $Tp2141.214f#b7...Packet received: OK Sending packet: $Tp2141.2141#82...Packet received: OK Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n That seems a bit silly when target_find_new_threads method implementations will always fetch the whole current set of target threads, and then add those that are not in GDB's thread list, to GDB's thread list. This patch thus pushes down the responsibility of pruning dead threads to the target_find_new_threads method instead, so a target may implement pruning dead threads however it wants. Once we do that, target_find_new_threads becomes a misnomer, so the patch renames it to target_update_thread_list. The patch doesn't attempt to do any optimization to any target yet. It simply exports prune_threads, and makes all implementations of target_update_thread_list call that. It's meant to be a no-op. gdb/ 2014-10-15 Pedro Alves <palves@redhat.com> * ada-tasks.c (print_ada_task_info, task_command_1): Adjust. * bsd-uthread.c (bsd_uthread_find_new_threads): Rename to ... (bsd_uthread_update_thread_list): ... this. Call prune_threads. (bsd_uthread_target): Adjust. * corelow.c (core_open): Adjust. * dec-thread.c (dec_thread_find_new_threads): Update comment. (dec_thread_update_thread_list): New function. (init_dec_thread_ops): Adjust. * gdbthread.h (prune_threads): New declaration. * linux-thread-db.c (thread_db_find_new_threads): Rename to ... (thread_db_update_thread_list): ... this. Call prune_threads. (init_thread_db_ops): Adjust. * nto-procfs.c (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. (procfs_attach, procfs_create_inferior, init_procfs_targets): Adjust. * obsd-nat.c (obsd_find_new_threads): Rename to ... (obsd_update_thread_list): ... this. Call prune_threads. (obsd_add_target): Adjust. * procfs.c (procfs_target): Adjust. (procfs_notice_thread): Update comment. (procfs_find_new_threads): Rename to ... (procfs_update_thread_list): ... this. Call prune_threads. * ravenscar-thread.c (ravenscar_update_inferior_ptid): Update comment. (ravenscar_wait): Adjust. (ravenscar_find_new_threads): Rename to ... (ravenscar_update_thread_list): ... this. Call prune_threads. (init_ravenscar_thread_ops): Adjust. * record-btrace.c (record_btrace_find_new_threads): Rename to ... (record_btrace_update_thread_list): ... this. Adjust comment. (init_record_btrace_ops): Adjust. * remote.c (remote_threads_info): Rename to ... (remote_update_thread_list): ... this. Call prune_threads. (remote_start_remote, extended_remote_attach_1, init_remote_ops): Adjust. * sol-thread.c (check_for_thread_db): Adjust. (sol_find_new_threads_callback): Rename to ... (sol_update_thread_list_callback): ... this. (sol_find_new_threads): Rename to ... (sol_update_thread_list): ... this. Call prune_threads. Adjust. (sol_get_ada_task_ptid, init_sol_thread_ops): Adjust. * target-delegates.c: Regenerate. * target.c (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * target.h (struct target_ops): Rename to_find_new_threads field to to_update_thread_list. (target_find_new_threads): Rename to ... (target_update_thread_list): ... this. * thread.c (prune_threads): Make extern. (update_thread_list): Adjust.
2014-10-15 23:44:00 +02:00
system.tasking.debug's list yet; so ravenscar_update_thread_list
may not always add it to the thread list. Add it here. */
thread_info *active_thr = find_thread_ptid (proc_target, active_ptid);
if (active_thr == nullptr)
active_thr = add_thread (proc_target, active_ptid);
return active_thr;
}
/* The Ravenscar Runtime exports a symbol which contains the ID of
the thread that is currently running. Try to locate that symbol
and return its associated minimal symbol.
Return NULL if not found. */
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
static struct bound_minimal_symbol
get_running_thread_msymbol ()
{
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol msym;
msym = lookup_minimal_symbol (running_thread_name, NULL, NULL);
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
if (!msym.minsym)
/* Older versions of the GNAT runtime were using a different
(less ideal) name for the symbol where the active thread ID
is stored. If we couldn't find the symbol using the latest
name, then try the old one. */
msym = lookup_minimal_symbol ("running_thread", NULL, NULL);
return msym;
}
/* Return True if the Ada Ravenscar run-time can be found in the
application. */
static bool
has_ravenscar_runtime ()
{
struct bound_minimal_symbol msym_ravenscar_runtime_initializer
= lookup_minimal_symbol (ravenscar_runtime_initializer, NULL, NULL);
struct bound_minimal_symbol msym_known_tasks
= lookup_minimal_symbol (known_tasks_name, NULL, NULL);
struct bound_minimal_symbol msym_first_task
= lookup_minimal_symbol (first_task_name, NULL, NULL);
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol msym_running_thread
= get_running_thread_msymbol ();
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
return (msym_ravenscar_runtime_initializer.minsym
&& (msym_known_tasks.minsym || msym_first_task.minsym)
&& msym_running_thread.minsym);
}
/* Return True if the Ada Ravenscar run-time can be found in the
application, and if it has been initialized on target. */
bool
ravenscar_thread_target::runtime_initialized ()
{
return active_task (1) != null_ptid;
}
/* Return the ID of the thread that is currently running.
Return 0 if the ID could not be determined. */
static CORE_ADDR
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
get_running_thread_id (int cpu)
{
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
struct bound_minimal_symbol object_msym = get_running_thread_msymbol ();
int object_size;
int buf_size;
-Wpointer-sign: char -> gdb_byte. -Wpointer-sign catches all these cases across the codebase that should be using gdb_byte for raw target bytes. I think these are all obvious, hence I've collapsed into a single patch. gdb/ 2013-04-19 Pedro Alves <palves@redhat.com> * aarch64-tdep.c (aarch64_default_breakpoint): Change type to gdb_byte[]. (aarch64_breakpoint_from_pc): Change return type to gdb_byte *. * ada-lang.c (ada_value_assign): Use gdb_byte. * alphanbsd-tdep.c (sigtramp_retcode): Change type to gdb_byte[]. (alphanbsd_sigtramp_offset): Use gdb_byte. * arm-linux-tdep.c (arm_linux_arm_le_breakpoint) (arm_linux_arm_be_breakpoint, eabi_linux_arm_le_breakpoint) (eabi_linux_arm_be_breakpoint, arm_linux_thumb_be_breakpoint) (arm_linux_thumb_le_breakpoint, arm_linux_thumb2_be_breakpoint) (arm_linux_thumb2_le_breakpoint): Change type to gdb_byte[]. * arm-tdep.c (arm_stub_unwind_sniffer) (arm_displaced_init_closure): Use gdb_byte. (arm_default_arm_le_breakpoint, arm_default_arm_be_breakpoint) (arm_default_thumb_le_breakpoint) (arm_default_thumb_be_breakpoint): Change type to gdb_byte[]. * arm-tdep.h (struct gdbarch_tdep) <arm_breakpoint, thumb_breakpoint, thumb2_breakpoint>: Change type to gdb_byte *. * arm-wince-tdep.c (arm_wince_le_breakpoint) (arm_wince_thumb_le_breakpoint): Change type to gdb_byte[]. * armnbsd-tdep.c (arm_nbsd_arm_le_breakpoint) (arm_nbsd_arm_be_breakpoint, arm_nbsd_thumb_le_breakpoint) (arm_nbsd_thumb_be_breakpoint): Change type to gdb_byte[]. * armobsd-tdep.c (arm_obsd_thumb_le_breakpoint) (arm_obsd_thumb_be_breakpoint): Change type to gdb_byte[]. * cris-tdep.c (push_stack_item, cris_push_dummy_call) (cris_store_return_value, cris_extract_return_value): Use gdb_byte. (constraint): Change type of parameter to char * from signed char*. Use gdb_byte. * dwarf2loc.c (read_pieced_value, write_pieced_value): Change type of local buffer to gdb_byte *. * dwarf2read.c (read_index_from_section): Use gdb_byte. (create_dwp_hash_table): Change type of locals to gdb_byte *. (add_address_entry): Change type of local buffer to gdb_byte[]. * frv-tdep.c (frv_adjust_breakpoint_address, find_func_descr) (frv_push_dummy_call): Use gdb_byte. * hppa-hpux-tdep.c (hppa_hpux_push_dummy_code) (hppa_hpux_supply_ss_fpblock, hppa_hpux_supply_ss_wide) (hppa_hpux_supply_save_state): Use gdb_byte. * hppa-tdep.c (hppa32_push_dummy_call) (hppa64_convert_code_addr_to_fptr): Use gdb_byte. * ia64-tdep.c (extract_bit_field, replace_bit_field) (slotN_contents, replace_slotN_contents): Change type of parameter to gdb_byte *. (fetch_instruction, ia64_pseudo_register_write) (ia64_register_to_value, ia64_value_to_register) (ia64_extract_return_value, ia64_store_return_value) (ia64_push_dummy_call): Use gdb_byte. * m32c-tdep.c (m32c_return_value): Remove cast. * m68hc11-tdep.c (m68hc11_pseudo_register_write) (m68hc11_push_dummy_call, m68hc11_store_return_value): Use gdb_byte. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Use gdb_byte. * mn10300-tdep.c (mn10300_store_return_value) (mn10300_breakpoint_from_pc, mn10300_push_dummy_call): Use gdb_byte. * moxie-tdep.c (moxie_process_readu): Use gdb_byte. (moxie_process_record): Remove casts. * ppc-ravenscar-thread.c (supply_register_at_address) (ppc_ravenscar_generic_store_registers): Use gdb_byte. * ravenscar-thread.c (get_running_thread_id): Use gdb_byte. * remote-m32r-sdi.c (m32r_fetch_register): Use gdb_byte. * remote-mips.c (mips_xfer_memory): Use gdb_byte. * remote.c (compare_sections_command): Use gdb_byte. * score-tdep.c (score7_free_memblock): Change type of parameter to gdb_byte *. * sh-tdep.c (sh_justify_value_in_reg): Change return type to gdb_byte *. Use gdb_byte. (sh_push_dummy_call_fpu): Use gdb_byte. (sh_extract_return_value_nofpu, sh_extract_return_value_fpu) (sh_store_return_value_nofpu, sh_store_return_value_fpu) (sh_register_convert_to_virtual, sh_register_convert_to_raw): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh_pseudo_register_read, sh_pseudo_register_write): Use gdb_byte. * sh64-tdep.c (sh64_push_dummy_call): Use gdb_byte. (sh64_store_return_value, sh64_register_convert_to_virtual): Change parameter type to 'gdb_byte *'. Use gdb_byte. (sh64_pseudo_register_write): Use gdb_byte. * solib-darwin.c (darwin_current_sos): Add casts to 'gdb_byte *'. * solib-irix.c (fetch_lm_info): Likewise. Use gdb_byte for byte buffer. (irix_current_sos): Use gdb_byte. * solib-som.c (som_current_sos): Use gdb_byte. * sparc-ravenscar-thread.c (supply_register_at_address) (sparc_ravenscar_generic_store_registers): Use gdb_byte. * spu-multiarch.c (spu_xfer_partial): Add cast to 'char *'. * spu-tdep.c (spu_get_overlay_table): Use gdb_byte. * tic6x-tdep.c (tic6x_breakpoint_from_pc): Change return type to 'gdb_byte *'. * tic6x-tdep.h (struct gdbarch_tdep) <breakpoint>: Change type to 'gdb_byte *'. * tracepoint.c (tfile_fetch_registers): Use gdb_byte. * xstormy16-tdep.c (xstormy16_extract_return_value) (xstormy16_store_return_value): Change parameter type to 'gdb_byte *'. Adjust. (xstormy16_push_dummy_call): Use gdb_byte. * xtensa-tdep.c (xtensa_scan_prologue, call0_ret) (call0_analyze_prologue, execute_code): Use gdb_byte.
2013-04-19 17:09:46 +02:00
gdb_byte *buf;
CORE_ADDR object_addr;
struct type *builtin_type_void_data_ptr
= builtin_type (target_gdbarch ())->builtin_data_ptr;
use bound_minsym as result for lookup_minimal_symbol et al This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2013-10-15 03:53:29 +02:00
if (!object_msym.minsym)
return 0;
object_size = TYPE_LENGTH (builtin_type_void_data_ptr);
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
object_addr = (BMSYMBOL_VALUE_ADDRESS (object_msym)
+ (cpu - 1) * object_size);
buf_size = object_size;
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
buf = (gdb_byte *) alloca (buf_size);
read_memory (object_addr, buf, buf_size);
return extract_typed_address (buf, builtin_type_void_data_ptr);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::resume (ptid_t ptid, int step,
enum gdb_signal siggnal)
{
/* If we see a wildcard resume, we simply pass that on. Otherwise,
arrange to resume the base ptid. */
inferior_ptid = m_base_ptid;
if (ptid != minus_one_ptid)
ptid = m_base_ptid;
beneath ()->resume (ptid, step, siggnal);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ptid_t
ravenscar_thread_target::wait (ptid_t ptid,
struct target_waitstatus *status,
int options)
{
Multi-target support This commit adds multi-target support to GDB. What this means is that with this commit, GDB can now be connected to different targets at the same time. E.g., you can debug a live native process and a core dump at the same time, connect to multiple gdbservers, etc. Actually, the word "target" is overloaded in gdb. We already have a target stack, with pushes several target_ops instances on top of one another. We also have "info target" already, which means something completely different to what this patch does. So from here on, I'll be using the "target connections" term, to mean an open process_stratum target, pushed on a target stack. This patch makes gdb have multiple target stacks, and multiple process_stratum targets open simultaneously. The user-visible changes / commands will also use this terminology, but of course it's all open to debate. User-interface-wise, not that much changes. The main difference is that each inferior may have its own target connection. A target connection (e.g., a target extended-remote connection) may support debugging multiple processes, just as before. Say you're debugging against gdbserver in extended-remote mode, and you do "add-inferior" to prepare to spawn a new process, like: (gdb) target extended-remote :9999 ... (gdb) start ... (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) file a.out ... (gdb) start ... At this point, you have two inferiors connected to the same gdbserver. With this commit, GDB will maintain a target stack per inferior, instead of a global target stack. To preserve the behavior above, by default, "add-inferior" makes the new inferior inherit a copy of the target stack of the current inferior. Same across a fork - the child inherits a copy of the target stack of the parent. While the target stacks are copied, the targets themselves are not. Instead, target_ops is made a refcounted_object, which means that target_ops instances are refcounted, which each inferior counting for a reference. What if you want to create an inferior and connect it to some _other_ target? For that, this commit introduces a new "add-inferior -no-connection" option that makes the new inferior not share the current inferior's target. So you could do: (gdb) target extended-remote :9999 Remote debugging using :9999 ... (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 <null> (gdb) tar extended-remote :10000 Remote debugging using :10000 ... (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 process 18450 target:/home/pedro/tmp/main (gdb) A following patch will extended "info inferiors" to include a column indicating which connection an inferior is bound to, along with a couple other UI tweaks. Other than that, debugging is the same as before. Users interact with inferiors and threads as before. The only difference is that inferiors may be bound to processes running in different machines. That's pretty much all there is to it in terms of noticeable UI changes. On to implementation. Since we can be connected to different systems at the same time, a ptid_t is no longer a unique identifier. Instead a thread can be identified by a pair of ptid_t and 'process_stratum_target *', the later being the instance of the process_stratum target that owns the process/thread. Note that process_stratum_target inherits from target_ops, and all process_stratum targets inherit from process_stratum_target. In earlier patches, many places in gdb were converted to refer to threads by thread_info pointer instead of ptid_t, but there are still places in gdb where we start with a pid/tid and need to find the corresponding inferior or thread_info objects. So you'll see in the patch many places adding a process_stratum_target parameter to functions that used to take only a ptid_t. Since each inferior has its own target stack now, we can always find the process_stratum target for an inferior. That is done via a inf->process_target() convenience method. Since each inferior has its own target stack, we need to handle the "beneath" calls when servicing target calls. The solution I settled with is just to make sure to switch the current inferior to the inferior you want before making a target call. Not relying on global context is just not feasible in current GDB. Fortunately, there aren't that many places that need to do that, because generally most code that calls target methods already has the current context pointing to the right inferior/thread. Note, to emphasize -- there's no method to "switch to this target stack". Instead, you switch the current inferior, and that implicitly switches the target stack. In some spots, we need to iterate over all inferiors so that we reach all target stacks. Native targets are still singletons. There's always only a single instance of such targets. Remote targets however, we'll have one instance per remote connection. The exec target is still a singleton. There's only one instance. I did not see the point of instanciating more than one exec_target object. After vfork, we need to make sure to push the exec target on the new inferior. See exec_on_vfork. For type safety, functions that need a {target, ptid} pair to identify a thread, take a process_stratum_target pointer for target parameter instead of target_ops *. Some shared code in gdb/nat/ also need to gain a target pointer parameter. This poses an issue, since gdbserver doesn't have process_stratum_target, only target_ops. To fix this, this commit renames gdbserver's target_ops to process_stratum_target. I think this makes sense. There's no concept of target stack in gdbserver, and gdbserver's target_ops really implements a process_stratum-like target. The thread and inferior iterator functions also gain process_stratum_target parameters. These are used to be able to iterate over threads and inferiors of a given target. Following usual conventions, if the target pointer is null, then we iterate over threads and inferiors of all targets. I tried converting "add-inferior" to the gdb::option framework, as a preparatory patch, but that stumbled on the fact that gdb::option does not support file options yet, for "add-inferior -exec". I have a WIP patchset that adds that, but it's not a trivial patch, mainly due to need to integrate readline's filename completion, so I deferred that to some other time. In infrun.c/infcmd.c, the main change is that we need to poll events out of all targets. See do_target_wait. Right after collecting an event, we switch the current inferior to an inferior bound to the target that reported the event, so that target methods can be used while handling the event. This makes most of the code transparent to multi-targets. See fetch_inferior_event. infrun.c:stop_all_threads is interesting -- in this function we need to stop all threads of all targets. What the function does is send an asynchronous stop request to all threads, and then synchronously waits for events, with target_wait, rinse repeat, until all it finds are stopped threads. Now that we have multiple targets, it's not efficient to synchronously block in target_wait waiting for events out of one target. Instead, we implement a mini event loop, with interruptible_select, select'ing on one file descriptor per target. For this to work, we need to be able to ask the target for a waitable file descriptor. Such file descriptors already exist, they are the descriptors registered in the main event loop with add_file_handler, inside the target_async implementations. This commit adds a new target_async_wait_fd target method that just returns the file descriptor in question. See wait_one / stop_all_threads in infrun.c. The 'threads_executing' global is made a per-target variable. Since it is only relevant to process_stratum_target targets, this is where it is put, instead of in target_ops. You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress. Current limitations: - You can only resume more that one target at the same time if all targets support asynchronous debugging, and support non-stop mode. It should be possible to support mixed all-stop + non-stop backends, but that is left for another time. This means that currently in order to do multi-target with gdbserver you need to issue "maint set target-non-stop on". I would like to make that mode be the default, but we're not there yet. Note that I'm talking about how the target backend works, only. User-visible all-stop mode works just fine. - As explained above, connecting to different remote servers at the same time is likely to produce bad results if they don't support the exact set of RSP features. FreeBSD updates courtesy of John Baldwin. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> John Baldwin <jhb@FreeBSD.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::thread_architecture): Adjust. * ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call. (task_command_1): Likewise. * aix-thread.c (sync_threadlists, aix_thread_target::resume) (aix_thread_target::wait, aix_thread_target::fetch_registers) (aix_thread_target::store_registers) (aix_thread_target::thread_alive): Adjust. * amd64-fbsd-tdep.c: Include "inferior.h". (amd64fbsd_get_thread_local_address): Pass down target. * amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle thread's gdbarch instead of target_gdbarch. * break-catch-sig.c (signal_catchpoint_print_it): Adjust call to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Likewise. * breakpoint.c (breakpoints_should_be_inserted_now): Consider all inferiors. (update_inserted_breakpoint_locations): Skip if inferiors with no execution. (update_global_location_list): When handling moribund locations, find representative inferior for location's pspace, and use thread count of its process_stratum target. * bsd-kvm.c (bsd_kvm_target_open): Pass target down. * bsd-uthread.c (bsd_uthread_target::wait): Use as_process_stratum_target and adjust thread_change_ptid and add_thread calls. (bsd_uthread_target::update_thread_list): Use as_process_stratum_target and adjust find_thread_ptid, thread_change_ptid and add_thread calls. * btrace.c (maint_btrace_packet_history_cmd): Adjust find_thread_ptid call. * corelow.c (add_to_thread_list): Adjust add_thread call. (core_target_open): Adjust add_thread_silent and thread_count calls. (core_target::pid_to_str): Adjust find_inferior_ptid call. * ctf.c (ctf_target_open): Adjust add_thread_silent call. * event-top.c (async_disconnect): Pop targets from all inferiors. * exec.c (add_target_sections): Push exec target on all inferiors sharing the program space. (remove_target_sections): Remove the exec target from all inferiors sharing the program space. (exec_on_vfork): New. * exec.h (exec_on_vfork): Declare. * fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::update_thread_list): Adjust. (fbsd_nat_target::resume): Adjust. (fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust. * fbsd-tdep.c (fbsd_corefile_thread): Adjust get_thread_arch_regcache call. * fork-child.c (gdb_startup_inferior): Pass target down to startup_inferior and set_executing. * gdbthread.h (struct process_stratum_target): Forward declare. (add_thread, add_thread_silent, add_thread_with_info) (in_thread_list): Add process_stratum_target parameter. (find_thread_ptid(inferior*, ptid_t)): New overload. (find_thread_ptid, thread_change_ptid): Add process_stratum_target parameter. (all_threads()): Delete overload. (all_threads, all_non_exited_threads): Add process_stratum_target parameter. (all_threads_safe): Use brace initialization. (thread_count): Add process_stratum_target parameter. (set_resumed, set_running, set_stop_requested, set_executing) (threads_are_executing, finish_thread_state): Add process_stratum_target parameter. (switch_to_thread): Use is_current_thread. * i386-fbsd-tdep.c: Include "inferior.h". (i386fbsd_get_thread_local_address): Pass down target. * i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust. * inf-child.c (inf_child_target::maybe_unpush_target): Remove have_inferiors check. * inf-ptrace.c (inf_ptrace_target::create_inferior) (inf_ptrace_target::attach): Adjust. * infcall.c (run_inferior_call): Adjust. * infcmd.c (run_command_1): Pass target to scoped_finish_thread_state. (proceed_thread_callback): Skip inferiors with no execution. (continue_command): Rename 'all_threads' local to avoid hiding 'all_threads' function. Adjust get_last_target_status call. (prepare_one_step): Adjust set_running call. (signal_command): Use user_visible_resume_target. Compare thread pointers instead of inferior_ptid. (info_program_command): Adjust to pass down target. (attach_command): Mark target's 'thread_executing' flag. (stop_current_target_threads_ns): New, factored out from ... (interrupt_target_1): ... this. Switch inferior before making target calls. * inferior-iter.h (struct all_inferiors_iterator, struct all_inferiors_range) (struct all_inferiors_safe_range) (struct all_non_exited_inferiors_range): Filter on process_stratum_target too. Remove explicit. * inferior.c (inferior::inferior): Push dummy target on target stack. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors): Add process_stratum_target parameter, and pass it down. (have_live_inferiors): Adjust. (switch_to_inferior_and_push_target): New. (add_inferior_command, clone_inferior_command): Handle "-no-connection" parameter. Use switch_to_inferior_and_push_target. (_initialize_inferior): Mention "-no-connection" option in the help of "add-inferior" and "clone-inferior" commands. * inferior.h: Include "process-stratum-target.h". (interrupt_target_1): Use bool. (struct inferior) <push_target, unpush_target, target_is_pushed, find_target_beneath, top_target, process_target, target_at, m_stack>: New. (discard_all_inferiors): Delete. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors) (all_inferiors, all_non_exited_inferiors): Add process_stratum_target parameter. * infrun.c: Include "gdb_select.h" and <unordered_map>. (target_last_proc_target): New global. (follow_fork_inferior): Push target on new inferior. Pass target to add_thread_silent. Call exec_on_vfork. Handle target's reference count. (follow_fork): Adjust get_last_target_status call. Also consider target. (follow_exec): Push target on new inferior. (struct execution_control_state) <target>: New field. (user_visible_resume_target): New. (do_target_resume): Call target_async. (resume_1): Set target's threads_executing flag. Consider resume target. (commit_resume_all_targets): New. (proceed): Also consider resume target. Skip threads of inferiors with no execution. Commit resumtion in all targets. (start_remote): Pass current inferior to wait_for_inferior. (infrun_thread_stop_requested): Consider target as well. Pass thread_info pointer to clear_inline_frame_state instead of ptid. (infrun_thread_thread_exit): Consider target as well. (random_pending_event_thread): New inferior parameter. Use it. (do_target_wait): Rename to ... (do_target_wait_1): ... this. Add inferior parameter, and pass it down. (threads_are_resumed_pending_p, do_target_wait): New. (prepare_for_detach): Adjust calls. (wait_for_inferior): New inferior parameter. Handle it. Use do_target_wait_1 instead of do_target_wait. (fetch_inferior_event): Adjust. Switch to representative inferior. Pass target down. (set_last_target_status): Add process_stratum_target parameter. Save target in global. (get_last_target_status): Add process_stratum_target parameter and handle it. (nullify_last_target_wait_ptid): Clear 'target_last_proc_target'. (context_switch): Check inferior_ptid == null_ptid before calling inferior_thread(). (get_inferior_stop_soon): Pass down target. (wait_one): Rename to ... (poll_one_curr_target): ... this. (struct wait_one_event): New. (wait_one): New. (stop_all_threads): Adjust. (handle_no_resumed, handle_inferior_event): Adjust to consider the event's target. (switch_back_to_stepped_thread): Also consider target. (print_stop_event): Update. (normal_stop): Update. Also consider the resume target. * infrun.h (wait_for_inferior): Remove declaration. (user_visible_resume_target): New declaration. (get_last_target_status, set_last_target_status): New process_stratum_target parameter. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter, and use it. (clear_inline_frame_state (thread_info*)): New. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter. (clear_inline_frame_state (thread_info*)): Declare. * linux-fork.c (delete_checkpoint_command): Pass target down to find_thread_ptid. (checkpoint_command): Adjust. * linux-nat.c (linux_nat_target::follow_fork): Switch to thread instead of just tweaking inferior_ptid. (linux_nat_switch_fork): Pass target down to thread_change_ptid. (exit_lwp): Pass target down to find_thread_ptid. (attach_proc_task_lwp_callback): Pass target down to add_thread/set_running/set_executing. (linux_nat_target::attach): Pass target down to thread_change_ptid. (get_detach_signal): Pass target down to find_thread_ptid. Consider last target status's target. (linux_resume_one_lwp_throw, resume_lwp) (linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp) (stop_wait_callback, save_stop_reason, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down. (linux_nat_target::async_wait_fd): New. (linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass target down. * linux-nat.h (linux_nat_target::async_wait_fd): Declare. * linux-tdep.c (get_thread_arch_regcache): Pass target down. * linux-thread-db.c (struct thread_db_info::process_target): New field. (add_thread_db_info): Save target. (get_thread_db_info): New process_stratum_target parameter. Also match target. (delete_thread_db_info): New process_stratum_target parameter. Also match target. (thread_from_lwp): Adjust to pass down target. (thread_db_notice_clone): Pass down target. (check_thread_db_callback): Pass down target. (try_thread_db_load_1): Always push the thread_db target. (try_thread_db_load, record_thread): Pass target down. (thread_db_target::detach): Pass target down. Always unpush the thread_db target. (thread_db_target::wait, thread_db_target::mourn_inferior): Pass target down. Always unpush the thread_db target. (find_new_threads_callback, thread_db_find_new_threads_2) (thread_db_target::update_thread_list): Pass target down. (thread_db_target::pid_to_str): Pass current inferior down. (thread_db_target::get_thread_local_address): Pass target down. (thread_db_target::resume, maintenance_check_libthread_db): Pass target down. * nto-procfs.c (nto_procfs_target::update_thread_list): Adjust. * procfs.c (procfs_target::procfs_init_inferior): Declare. (proc_set_current_signal, do_attach, procfs_target::wait): Adjust. (procfs_init_inferior): Rename to ... (procfs_target::procfs_init_inferior): ... this and adjust. (procfs_target::create_inferior, procfs_notice_thread) (procfs_do_thread_registers): Adjust. * ppc-fbsd-tdep.c: Include "inferior.h". (ppcfbsd_get_thread_local_address): Pass down target. * proc-service.c (ps_xfer_memory): Switch current inferior and program space as well. (get_ps_regcache): Pass target down. * process-stratum-target.c (process_stratum_target::thread_address_space) (process_stratum_target::thread_architecture): Pass target down. * process-stratum-target.h (process_stratum_target::threads_executing): New field. (as_process_stratum_target): New. * ravenscar-thread.c (ravenscar_thread_target::update_inferior_ptid): Pass target down. (ravenscar_thread_target::wait, ravenscar_add_thread): Pass target down. * record-btrace.c (record_btrace_target::info_record): Adjust. (record_btrace_target::record_method) (record_btrace_target::record_is_replaying) (record_btrace_target::fetch_registers) (get_thread_current_frame_id, record_btrace_target::resume) (record_btrace_target::wait, record_btrace_target::stop): Pass target down. * record-full.c (record_full_wait_1): Switch to event thread. Pass target down. * regcache.c (regcache::regcache) (get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add process_stratum_target parameter and handle it. (current_thread_target): New global. (get_thread_regcache): Add process_stratum_target parameter and handle it. Switch inferior before calling target method. (get_thread_regcache): Pass target down. (get_thread_regcache_for_ptid): Pass target down. (registers_changed_ptid): Add process_stratum_target parameter and handle it. (registers_changed_thread, registers_changed): Pass target down. (test_get_thread_arch_aspace_regcache): New. (current_regcache_test): Define a couple local test_target_ops instances and use them for testing. (readwrite_regcache): Pass process_stratum_target parameter. (cooked_read_test, cooked_write_test): Pass mock_target down. * regcache.h (get_thread_regcache, get_thread_arch_regcache) (get_thread_arch_aspace_regcache): Add process_stratum_target parameter. (regcache::target): New method. (regcache::regcache, regcache::get_thread_arch_aspace_regcache) (regcache::registers_changed_ptid): Add process_stratum_target parameter. (regcache::m_target): New field. (registers_changed_ptid): Add process_stratum_target parameter. * remote.c (remote_state::supports_vCont_probed): New field. (remote_target::async_wait_fd): New method. (remote_unpush_and_throw): Add remote_target parameter. (get_current_remote_target): Adjust. (remote_target::remote_add_inferior): Push target. (remote_target::remote_add_thread) (remote_target::remote_notice_new_inferior) (get_remote_thread_info): Pass target down. (remote_target::update_thread_list): Skip threads of inferiors bound to other targets. (remote_target::close): Don't discard inferiors. (remote_target::add_current_inferior_and_thread) (remote_target::process_initial_stop_replies) (remote_target::start_remote) (remote_target::remote_serial_quit_handler): Pass down target. (remote_target::remote_unpush_target): New remote_target parameter. Unpush the target from all inferiors. (remote_target::remote_unpush_and_throw): New remote_target parameter. Pass it down. (remote_target::open_1): Check whether the current inferior has execution instead of checking whether any inferior is live. Pass target down. (remote_target::remote_detach_1): Pass down target. Use remote_unpush_target. (extended_remote_target::attach): Pass down target. (remote_target::remote_vcont_probe): Set supports_vCont_probed. (remote_target::append_resumption): Pass down target. (remote_target::append_pending_thread_resumptions) (remote_target::remote_resume_with_hc, remote_target::resume) (remote_target::commit_resume): Pass down target. (remote_target::remote_stop_ns): Check supports_vCont_probed. (remote_target::interrupt_query) (remote_target::remove_new_fork_children) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::remote_parse_stop_reply) (remote_target::process_stop_reply): Pass down target. (first_remote_resumed_thread): New remote_target parameter. Pass it down. (remote_target::wait_as): Pass down target. (unpush_and_perror): New remote_target parameter. Pass it down. (remote_target::readchar, remote_target::remote_serial_write) (remote_target::getpkt_or_notif_sane_1) (remote_target::kill_new_fork_children, remote_target::kill): Pass down target. (remote_target::mourn_inferior): Pass down target. Use remote_unpush_target. (remote_target::core_of_thread) (remote_target::remote_btrace_maybe_reopen): Pass down target. (remote_target::pid_to_exec_file) (remote_target::thread_handle_to_thread_info): Pass down target. (remote_target::async_wait_fd): New. * riscv-fbsd-tdep.c: Include "inferior.h". (riscv_fbsd_get_thread_local_address): Pass down target. * sol2-tdep.c (sol2_core_pid_to_str): Pass down target. * sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs) (ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback): Adjust. * solib-spu.c (spu_skip_standalone_loader): Pass down target. * solib-svr4.c (enable_break): Pass down target. * spu-multiarch.c (parse_spufs_run): Pass down target. * spu-tdep.c (spu2ppu_sniffer): Pass down target. * target-delegates.c: Regenerate. * target.c (g_target_stack): Delete. (current_top_target): Return the current inferior's top target. (target_has_execution_1): Refer to the passed-in inferior's top target. (target_supports_terminal_ours): Check whether the initial inferior was already created. (decref_target): New. (target_stack::push): Incref/decref the target. (push_target, push_target, unpush_target): Adjust. (target_stack::unpush): Defref target. (target_is_pushed): Return bool. Adjust to refer to the current inferior's target stack. (dispose_inferior): Delete, and inline parts ... (target_preopen): ... here. Only dispose of the current inferior. (target_detach): Hold strong target reference while detaching. Pass target down. (target_thread_name): Add assertion. (target_resume): Pass down target. (target_ops::beneath, find_target_at): Adjust to refer to the current inferior's target stack. (get_dummy_target): New. (target_pass_ctrlc): Pass the Ctrl-C to the first inferior that has a thread running. (initialize_targets): Rename to ... (_initialize_target): ... this. * target.h: Include "gdbsupport/refcounted-object.h". (struct target_ops): Inherit refcounted_object. (target_ops::shortname, target_ops::longname): Make const. (target_ops::async_wait_fd): New method. (decref_target): Declare. (struct target_ops_ref_policy): New. (target_ops_ref): New typedef. (get_dummy_target): Declare function. (target_is_pushed): Return bool. * thread-iter.c (all_matching_threads_iterator::m_inf_matches) (all_matching_threads_iterator::all_matching_threads_iterator): Handle filter target. * thread-iter.h (struct all_matching_threads_iterator, struct all_matching_threads_range, class all_non_exited_threads_range): Filter by target too. Remove explicit. * thread.c (threads_executing): Delete. (inferior_thread): Pass down current inferior. (clear_thread_inferior_resources): Pass down thread pointer instead of ptid_t. (add_thread_silent, add_thread_with_info, add_thread): Add process_stratum_target parameter. Use it for thread and inferior searches. (is_current_thread): New. (thread_info::deletable): Use it. (find_thread_ptid, thread_count, in_thread_list) (thread_change_ptid, set_resumed, set_running): New process_stratum_target parameter. Pass it down. (set_executing): New process_stratum_target parameter. Pass it down. Adjust reference to 'threads_executing'. (threads_are_executing): New process_stratum_target parameter. Adjust reference to 'threads_executing'. (set_stop_requested, finish_thread_state): New process_stratum_target parameter. Pass it down. (switch_to_thread): Also match inferior. (switch_to_thread): New process_stratum_target parameter. Pass it down. (update_threads_executing): Reimplement. * top.c (quit_force): Pop targets from all inferior. (gdb_init): Don't call initialize_targets. * windows-nat.c (windows_nat_target) <get_windows_debug_event>: Declare. (windows_add_thread, windows_delete_thread): Adjust. (get_windows_debug_event): Rename to ... (windows_nat_target::get_windows_debug_event): ... this. Adjust. * tracefile-tfile.c (tfile_target_open): Pass down target. * gdbsupport/common-gdbthread.h (struct process_stratum_target): Forward declare. (switch_to_thread): Add process_stratum_target parameter. * mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target parameter. Use it. (mi_on_resume): Pass target down. * nat/fork-inferior.c (startup_inferior): Add process_stratum_target parameter. Pass it down. * nat/fork-inferior.h (startup_inferior): Add process_stratum_target parameter. * python/py-threadevent.c (py_get_event_thread): Pass target down. gdb/gdbserver/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * fork-child.c (post_fork_inferior): Pass target down to startup_inferior. * inferiors.c (switch_to_thread): Add process_stratum_target parameter. * lynx-low.c (lynx_target_ops): Now a process_stratum_target. * nto-low.c (nto_target_ops): Now a process_stratum_target. * linux-low.c (linux_target_ops): Now a process_stratum_target. * remote-utils.c (prepare_resume_reply): Pass the target to switch_to_thread. * target.c (the_target): Now a process_stratum_target. (done_accessing_memory): Pass the target to switch_to_thread. (set_target_ops): Ajust to use process_stratum_target. * target.h (struct target_ops): Rename to ... (struct process_stratum_target): ... this. (the_target, set_target_ops): Adjust. (prepare_to_access_memory): Adjust comment. * win32-low.c (child_xfer_memory): Adjust to use process_stratum_target. (win32_target_ops): Now a process_stratum_target.
2020-01-10 21:06:08 +01:00
process_stratum_target *beneath
= as_process_stratum_target (this->beneath ());
ptid_t event_ptid;
if (ptid != minus_one_ptid)
ptid = m_base_ptid;
Multi-target support This commit adds multi-target support to GDB. What this means is that with this commit, GDB can now be connected to different targets at the same time. E.g., you can debug a live native process and a core dump at the same time, connect to multiple gdbservers, etc. Actually, the word "target" is overloaded in gdb. We already have a target stack, with pushes several target_ops instances on top of one another. We also have "info target" already, which means something completely different to what this patch does. So from here on, I'll be using the "target connections" term, to mean an open process_stratum target, pushed on a target stack. This patch makes gdb have multiple target stacks, and multiple process_stratum targets open simultaneously. The user-visible changes / commands will also use this terminology, but of course it's all open to debate. User-interface-wise, not that much changes. The main difference is that each inferior may have its own target connection. A target connection (e.g., a target extended-remote connection) may support debugging multiple processes, just as before. Say you're debugging against gdbserver in extended-remote mode, and you do "add-inferior" to prepare to spawn a new process, like: (gdb) target extended-remote :9999 ... (gdb) start ... (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) file a.out ... (gdb) start ... At this point, you have two inferiors connected to the same gdbserver. With this commit, GDB will maintain a target stack per inferior, instead of a global target stack. To preserve the behavior above, by default, "add-inferior" makes the new inferior inherit a copy of the target stack of the current inferior. Same across a fork - the child inherits a copy of the target stack of the parent. While the target stacks are copied, the targets themselves are not. Instead, target_ops is made a refcounted_object, which means that target_ops instances are refcounted, which each inferior counting for a reference. What if you want to create an inferior and connect it to some _other_ target? For that, this commit introduces a new "add-inferior -no-connection" option that makes the new inferior not share the current inferior's target. So you could do: (gdb) target extended-remote :9999 Remote debugging using :9999 ... (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 <null> (gdb) tar extended-remote :10000 Remote debugging using :10000 ... (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 process 18450 target:/home/pedro/tmp/main (gdb) A following patch will extended "info inferiors" to include a column indicating which connection an inferior is bound to, along with a couple other UI tweaks. Other than that, debugging is the same as before. Users interact with inferiors and threads as before. The only difference is that inferiors may be bound to processes running in different machines. That's pretty much all there is to it in terms of noticeable UI changes. On to implementation. Since we can be connected to different systems at the same time, a ptid_t is no longer a unique identifier. Instead a thread can be identified by a pair of ptid_t and 'process_stratum_target *', the later being the instance of the process_stratum target that owns the process/thread. Note that process_stratum_target inherits from target_ops, and all process_stratum targets inherit from process_stratum_target. In earlier patches, many places in gdb were converted to refer to threads by thread_info pointer instead of ptid_t, but there are still places in gdb where we start with a pid/tid and need to find the corresponding inferior or thread_info objects. So you'll see in the patch many places adding a process_stratum_target parameter to functions that used to take only a ptid_t. Since each inferior has its own target stack now, we can always find the process_stratum target for an inferior. That is done via a inf->process_target() convenience method. Since each inferior has its own target stack, we need to handle the "beneath" calls when servicing target calls. The solution I settled with is just to make sure to switch the current inferior to the inferior you want before making a target call. Not relying on global context is just not feasible in current GDB. Fortunately, there aren't that many places that need to do that, because generally most code that calls target methods already has the current context pointing to the right inferior/thread. Note, to emphasize -- there's no method to "switch to this target stack". Instead, you switch the current inferior, and that implicitly switches the target stack. In some spots, we need to iterate over all inferiors so that we reach all target stacks. Native targets are still singletons. There's always only a single instance of such targets. Remote targets however, we'll have one instance per remote connection. The exec target is still a singleton. There's only one instance. I did not see the point of instanciating more than one exec_target object. After vfork, we need to make sure to push the exec target on the new inferior. See exec_on_vfork. For type safety, functions that need a {target, ptid} pair to identify a thread, take a process_stratum_target pointer for target parameter instead of target_ops *. Some shared code in gdb/nat/ also need to gain a target pointer parameter. This poses an issue, since gdbserver doesn't have process_stratum_target, only target_ops. To fix this, this commit renames gdbserver's target_ops to process_stratum_target. I think this makes sense. There's no concept of target stack in gdbserver, and gdbserver's target_ops really implements a process_stratum-like target. The thread and inferior iterator functions also gain process_stratum_target parameters. These are used to be able to iterate over threads and inferiors of a given target. Following usual conventions, if the target pointer is null, then we iterate over threads and inferiors of all targets. I tried converting "add-inferior" to the gdb::option framework, as a preparatory patch, but that stumbled on the fact that gdb::option does not support file options yet, for "add-inferior -exec". I have a WIP patchset that adds that, but it's not a trivial patch, mainly due to need to integrate readline's filename completion, so I deferred that to some other time. In infrun.c/infcmd.c, the main change is that we need to poll events out of all targets. See do_target_wait. Right after collecting an event, we switch the current inferior to an inferior bound to the target that reported the event, so that target methods can be used while handling the event. This makes most of the code transparent to multi-targets. See fetch_inferior_event. infrun.c:stop_all_threads is interesting -- in this function we need to stop all threads of all targets. What the function does is send an asynchronous stop request to all threads, and then synchronously waits for events, with target_wait, rinse repeat, until all it finds are stopped threads. Now that we have multiple targets, it's not efficient to synchronously block in target_wait waiting for events out of one target. Instead, we implement a mini event loop, with interruptible_select, select'ing on one file descriptor per target. For this to work, we need to be able to ask the target for a waitable file descriptor. Such file descriptors already exist, they are the descriptors registered in the main event loop with add_file_handler, inside the target_async implementations. This commit adds a new target_async_wait_fd target method that just returns the file descriptor in question. See wait_one / stop_all_threads in infrun.c. The 'threads_executing' global is made a per-target variable. Since it is only relevant to process_stratum_target targets, this is where it is put, instead of in target_ops. You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress. Current limitations: - You can only resume more that one target at the same time if all targets support asynchronous debugging, and support non-stop mode. It should be possible to support mixed all-stop + non-stop backends, but that is left for another time. This means that currently in order to do multi-target with gdbserver you need to issue "maint set target-non-stop on". I would like to make that mode be the default, but we're not there yet. Note that I'm talking about how the target backend works, only. User-visible all-stop mode works just fine. - As explained above, connecting to different remote servers at the same time is likely to produce bad results if they don't support the exact set of RSP features. FreeBSD updates courtesy of John Baldwin. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> John Baldwin <jhb@FreeBSD.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::thread_architecture): Adjust. * ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call. (task_command_1): Likewise. * aix-thread.c (sync_threadlists, aix_thread_target::resume) (aix_thread_target::wait, aix_thread_target::fetch_registers) (aix_thread_target::store_registers) (aix_thread_target::thread_alive): Adjust. * amd64-fbsd-tdep.c: Include "inferior.h". (amd64fbsd_get_thread_local_address): Pass down target. * amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle thread's gdbarch instead of target_gdbarch. * break-catch-sig.c (signal_catchpoint_print_it): Adjust call to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Likewise. * breakpoint.c (breakpoints_should_be_inserted_now): Consider all inferiors. (update_inserted_breakpoint_locations): Skip if inferiors with no execution. (update_global_location_list): When handling moribund locations, find representative inferior for location's pspace, and use thread count of its process_stratum target. * bsd-kvm.c (bsd_kvm_target_open): Pass target down. * bsd-uthread.c (bsd_uthread_target::wait): Use as_process_stratum_target and adjust thread_change_ptid and add_thread calls. (bsd_uthread_target::update_thread_list): Use as_process_stratum_target and adjust find_thread_ptid, thread_change_ptid and add_thread calls. * btrace.c (maint_btrace_packet_history_cmd): Adjust find_thread_ptid call. * corelow.c (add_to_thread_list): Adjust add_thread call. (core_target_open): Adjust add_thread_silent and thread_count calls. (core_target::pid_to_str): Adjust find_inferior_ptid call. * ctf.c (ctf_target_open): Adjust add_thread_silent call. * event-top.c (async_disconnect): Pop targets from all inferiors. * exec.c (add_target_sections): Push exec target on all inferiors sharing the program space. (remove_target_sections): Remove the exec target from all inferiors sharing the program space. (exec_on_vfork): New. * exec.h (exec_on_vfork): Declare. * fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::update_thread_list): Adjust. (fbsd_nat_target::resume): Adjust. (fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust. * fbsd-tdep.c (fbsd_corefile_thread): Adjust get_thread_arch_regcache call. * fork-child.c (gdb_startup_inferior): Pass target down to startup_inferior and set_executing. * gdbthread.h (struct process_stratum_target): Forward declare. (add_thread, add_thread_silent, add_thread_with_info) (in_thread_list): Add process_stratum_target parameter. (find_thread_ptid(inferior*, ptid_t)): New overload. (find_thread_ptid, thread_change_ptid): Add process_stratum_target parameter. (all_threads()): Delete overload. (all_threads, all_non_exited_threads): Add process_stratum_target parameter. (all_threads_safe): Use brace initialization. (thread_count): Add process_stratum_target parameter. (set_resumed, set_running, set_stop_requested, set_executing) (threads_are_executing, finish_thread_state): Add process_stratum_target parameter. (switch_to_thread): Use is_current_thread. * i386-fbsd-tdep.c: Include "inferior.h". (i386fbsd_get_thread_local_address): Pass down target. * i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust. * inf-child.c (inf_child_target::maybe_unpush_target): Remove have_inferiors check. * inf-ptrace.c (inf_ptrace_target::create_inferior) (inf_ptrace_target::attach): Adjust. * infcall.c (run_inferior_call): Adjust. * infcmd.c (run_command_1): Pass target to scoped_finish_thread_state. (proceed_thread_callback): Skip inferiors with no execution. (continue_command): Rename 'all_threads' local to avoid hiding 'all_threads' function. Adjust get_last_target_status call. (prepare_one_step): Adjust set_running call. (signal_command): Use user_visible_resume_target. Compare thread pointers instead of inferior_ptid. (info_program_command): Adjust to pass down target. (attach_command): Mark target's 'thread_executing' flag. (stop_current_target_threads_ns): New, factored out from ... (interrupt_target_1): ... this. Switch inferior before making target calls. * inferior-iter.h (struct all_inferiors_iterator, struct all_inferiors_range) (struct all_inferiors_safe_range) (struct all_non_exited_inferiors_range): Filter on process_stratum_target too. Remove explicit. * inferior.c (inferior::inferior): Push dummy target on target stack. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors): Add process_stratum_target parameter, and pass it down. (have_live_inferiors): Adjust. (switch_to_inferior_and_push_target): New. (add_inferior_command, clone_inferior_command): Handle "-no-connection" parameter. Use switch_to_inferior_and_push_target. (_initialize_inferior): Mention "-no-connection" option in the help of "add-inferior" and "clone-inferior" commands. * inferior.h: Include "process-stratum-target.h". (interrupt_target_1): Use bool. (struct inferior) <push_target, unpush_target, target_is_pushed, find_target_beneath, top_target, process_target, target_at, m_stack>: New. (discard_all_inferiors): Delete. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors) (all_inferiors, all_non_exited_inferiors): Add process_stratum_target parameter. * infrun.c: Include "gdb_select.h" and <unordered_map>. (target_last_proc_target): New global. (follow_fork_inferior): Push target on new inferior. Pass target to add_thread_silent. Call exec_on_vfork. Handle target's reference count. (follow_fork): Adjust get_last_target_status call. Also consider target. (follow_exec): Push target on new inferior. (struct execution_control_state) <target>: New field. (user_visible_resume_target): New. (do_target_resume): Call target_async. (resume_1): Set target's threads_executing flag. Consider resume target. (commit_resume_all_targets): New. (proceed): Also consider resume target. Skip threads of inferiors with no execution. Commit resumtion in all targets. (start_remote): Pass current inferior to wait_for_inferior. (infrun_thread_stop_requested): Consider target as well. Pass thread_info pointer to clear_inline_frame_state instead of ptid. (infrun_thread_thread_exit): Consider target as well. (random_pending_event_thread): New inferior parameter. Use it. (do_target_wait): Rename to ... (do_target_wait_1): ... this. Add inferior parameter, and pass it down. (threads_are_resumed_pending_p, do_target_wait): New. (prepare_for_detach): Adjust calls. (wait_for_inferior): New inferior parameter. Handle it. Use do_target_wait_1 instead of do_target_wait. (fetch_inferior_event): Adjust. Switch to representative inferior. Pass target down. (set_last_target_status): Add process_stratum_target parameter. Save target in global. (get_last_target_status): Add process_stratum_target parameter and handle it. (nullify_last_target_wait_ptid): Clear 'target_last_proc_target'. (context_switch): Check inferior_ptid == null_ptid before calling inferior_thread(). (get_inferior_stop_soon): Pass down target. (wait_one): Rename to ... (poll_one_curr_target): ... this. (struct wait_one_event): New. (wait_one): New. (stop_all_threads): Adjust. (handle_no_resumed, handle_inferior_event): Adjust to consider the event's target. (switch_back_to_stepped_thread): Also consider target. (print_stop_event): Update. (normal_stop): Update. Also consider the resume target. * infrun.h (wait_for_inferior): Remove declaration. (user_visible_resume_target): New declaration. (get_last_target_status, set_last_target_status): New process_stratum_target parameter. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter, and use it. (clear_inline_frame_state (thread_info*)): New. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter. (clear_inline_frame_state (thread_info*)): Declare. * linux-fork.c (delete_checkpoint_command): Pass target down to find_thread_ptid. (checkpoint_command): Adjust. * linux-nat.c (linux_nat_target::follow_fork): Switch to thread instead of just tweaking inferior_ptid. (linux_nat_switch_fork): Pass target down to thread_change_ptid. (exit_lwp): Pass target down to find_thread_ptid. (attach_proc_task_lwp_callback): Pass target down to add_thread/set_running/set_executing. (linux_nat_target::attach): Pass target down to thread_change_ptid. (get_detach_signal): Pass target down to find_thread_ptid. Consider last target status's target. (linux_resume_one_lwp_throw, resume_lwp) (linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp) (stop_wait_callback, save_stop_reason, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down. (linux_nat_target::async_wait_fd): New. (linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass target down. * linux-nat.h (linux_nat_target::async_wait_fd): Declare. * linux-tdep.c (get_thread_arch_regcache): Pass target down. * linux-thread-db.c (struct thread_db_info::process_target): New field. (add_thread_db_info): Save target. (get_thread_db_info): New process_stratum_target parameter. Also match target. (delete_thread_db_info): New process_stratum_target parameter. Also match target. (thread_from_lwp): Adjust to pass down target. (thread_db_notice_clone): Pass down target. (check_thread_db_callback): Pass down target. (try_thread_db_load_1): Always push the thread_db target. (try_thread_db_load, record_thread): Pass target down. (thread_db_target::detach): Pass target down. Always unpush the thread_db target. (thread_db_target::wait, thread_db_target::mourn_inferior): Pass target down. Always unpush the thread_db target. (find_new_threads_callback, thread_db_find_new_threads_2) (thread_db_target::update_thread_list): Pass target down. (thread_db_target::pid_to_str): Pass current inferior down. (thread_db_target::get_thread_local_address): Pass target down. (thread_db_target::resume, maintenance_check_libthread_db): Pass target down. * nto-procfs.c (nto_procfs_target::update_thread_list): Adjust. * procfs.c (procfs_target::procfs_init_inferior): Declare. (proc_set_current_signal, do_attach, procfs_target::wait): Adjust. (procfs_init_inferior): Rename to ... (procfs_target::procfs_init_inferior): ... this and adjust. (procfs_target::create_inferior, procfs_notice_thread) (procfs_do_thread_registers): Adjust. * ppc-fbsd-tdep.c: Include "inferior.h". (ppcfbsd_get_thread_local_address): Pass down target. * proc-service.c (ps_xfer_memory): Switch current inferior and program space as well. (get_ps_regcache): Pass target down. * process-stratum-target.c (process_stratum_target::thread_address_space) (process_stratum_target::thread_architecture): Pass target down. * process-stratum-target.h (process_stratum_target::threads_executing): New field. (as_process_stratum_target): New. * ravenscar-thread.c (ravenscar_thread_target::update_inferior_ptid): Pass target down. (ravenscar_thread_target::wait, ravenscar_add_thread): Pass target down. * record-btrace.c (record_btrace_target::info_record): Adjust. (record_btrace_target::record_method) (record_btrace_target::record_is_replaying) (record_btrace_target::fetch_registers) (get_thread_current_frame_id, record_btrace_target::resume) (record_btrace_target::wait, record_btrace_target::stop): Pass target down. * record-full.c (record_full_wait_1): Switch to event thread. Pass target down. * regcache.c (regcache::regcache) (get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add process_stratum_target parameter and handle it. (current_thread_target): New global. (get_thread_regcache): Add process_stratum_target parameter and handle it. Switch inferior before calling target method. (get_thread_regcache): Pass target down. (get_thread_regcache_for_ptid): Pass target down. (registers_changed_ptid): Add process_stratum_target parameter and handle it. (registers_changed_thread, registers_changed): Pass target down. (test_get_thread_arch_aspace_regcache): New. (current_regcache_test): Define a couple local test_target_ops instances and use them for testing. (readwrite_regcache): Pass process_stratum_target parameter. (cooked_read_test, cooked_write_test): Pass mock_target down. * regcache.h (get_thread_regcache, get_thread_arch_regcache) (get_thread_arch_aspace_regcache): Add process_stratum_target parameter. (regcache::target): New method. (regcache::regcache, regcache::get_thread_arch_aspace_regcache) (regcache::registers_changed_ptid): Add process_stratum_target parameter. (regcache::m_target): New field. (registers_changed_ptid): Add process_stratum_target parameter. * remote.c (remote_state::supports_vCont_probed): New field. (remote_target::async_wait_fd): New method. (remote_unpush_and_throw): Add remote_target parameter. (get_current_remote_target): Adjust. (remote_target::remote_add_inferior): Push target. (remote_target::remote_add_thread) (remote_target::remote_notice_new_inferior) (get_remote_thread_info): Pass target down. (remote_target::update_thread_list): Skip threads of inferiors bound to other targets. (remote_target::close): Don't discard inferiors. (remote_target::add_current_inferior_and_thread) (remote_target::process_initial_stop_replies) (remote_target::start_remote) (remote_target::remote_serial_quit_handler): Pass down target. (remote_target::remote_unpush_target): New remote_target parameter. Unpush the target from all inferiors. (remote_target::remote_unpush_and_throw): New remote_target parameter. Pass it down. (remote_target::open_1): Check whether the current inferior has execution instead of checking whether any inferior is live. Pass target down. (remote_target::remote_detach_1): Pass down target. Use remote_unpush_target. (extended_remote_target::attach): Pass down target. (remote_target::remote_vcont_probe): Set supports_vCont_probed. (remote_target::append_resumption): Pass down target. (remote_target::append_pending_thread_resumptions) (remote_target::remote_resume_with_hc, remote_target::resume) (remote_target::commit_resume): Pass down target. (remote_target::remote_stop_ns): Check supports_vCont_probed. (remote_target::interrupt_query) (remote_target::remove_new_fork_children) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::remote_parse_stop_reply) (remote_target::process_stop_reply): Pass down target. (first_remote_resumed_thread): New remote_target parameter. Pass it down. (remote_target::wait_as): Pass down target. (unpush_and_perror): New remote_target parameter. Pass it down. (remote_target::readchar, remote_target::remote_serial_write) (remote_target::getpkt_or_notif_sane_1) (remote_target::kill_new_fork_children, remote_target::kill): Pass down target. (remote_target::mourn_inferior): Pass down target. Use remote_unpush_target. (remote_target::core_of_thread) (remote_target::remote_btrace_maybe_reopen): Pass down target. (remote_target::pid_to_exec_file) (remote_target::thread_handle_to_thread_info): Pass down target. (remote_target::async_wait_fd): New. * riscv-fbsd-tdep.c: Include "inferior.h". (riscv_fbsd_get_thread_local_address): Pass down target. * sol2-tdep.c (sol2_core_pid_to_str): Pass down target. * sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs) (ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback): Adjust. * solib-spu.c (spu_skip_standalone_loader): Pass down target. * solib-svr4.c (enable_break): Pass down target. * spu-multiarch.c (parse_spufs_run): Pass down target. * spu-tdep.c (spu2ppu_sniffer): Pass down target. * target-delegates.c: Regenerate. * target.c (g_target_stack): Delete. (current_top_target): Return the current inferior's top target. (target_has_execution_1): Refer to the passed-in inferior's top target. (target_supports_terminal_ours): Check whether the initial inferior was already created. (decref_target): New. (target_stack::push): Incref/decref the target. (push_target, push_target, unpush_target): Adjust. (target_stack::unpush): Defref target. (target_is_pushed): Return bool. Adjust to refer to the current inferior's target stack. (dispose_inferior): Delete, and inline parts ... (target_preopen): ... here. Only dispose of the current inferior. (target_detach): Hold strong target reference while detaching. Pass target down. (target_thread_name): Add assertion. (target_resume): Pass down target. (target_ops::beneath, find_target_at): Adjust to refer to the current inferior's target stack. (get_dummy_target): New. (target_pass_ctrlc): Pass the Ctrl-C to the first inferior that has a thread running. (initialize_targets): Rename to ... (_initialize_target): ... this. * target.h: Include "gdbsupport/refcounted-object.h". (struct target_ops): Inherit refcounted_object. (target_ops::shortname, target_ops::longname): Make const. (target_ops::async_wait_fd): New method. (decref_target): Declare. (struct target_ops_ref_policy): New. (target_ops_ref): New typedef. (get_dummy_target): Declare function. (target_is_pushed): Return bool. * thread-iter.c (all_matching_threads_iterator::m_inf_matches) (all_matching_threads_iterator::all_matching_threads_iterator): Handle filter target. * thread-iter.h (struct all_matching_threads_iterator, struct all_matching_threads_range, class all_non_exited_threads_range): Filter by target too. Remove explicit. * thread.c (threads_executing): Delete. (inferior_thread): Pass down current inferior. (clear_thread_inferior_resources): Pass down thread pointer instead of ptid_t. (add_thread_silent, add_thread_with_info, add_thread): Add process_stratum_target parameter. Use it for thread and inferior searches. (is_current_thread): New. (thread_info::deletable): Use it. (find_thread_ptid, thread_count, in_thread_list) (thread_change_ptid, set_resumed, set_running): New process_stratum_target parameter. Pass it down. (set_executing): New process_stratum_target parameter. Pass it down. Adjust reference to 'threads_executing'. (threads_are_executing): New process_stratum_target parameter. Adjust reference to 'threads_executing'. (set_stop_requested, finish_thread_state): New process_stratum_target parameter. Pass it down. (switch_to_thread): Also match inferior. (switch_to_thread): New process_stratum_target parameter. Pass it down. (update_threads_executing): Reimplement. * top.c (quit_force): Pop targets from all inferior. (gdb_init): Don't call initialize_targets. * windows-nat.c (windows_nat_target) <get_windows_debug_event>: Declare. (windows_add_thread, windows_delete_thread): Adjust. (get_windows_debug_event): Rename to ... (windows_nat_target::get_windows_debug_event): ... this. Adjust. * tracefile-tfile.c (tfile_target_open): Pass down target. * gdbsupport/common-gdbthread.h (struct process_stratum_target): Forward declare. (switch_to_thread): Add process_stratum_target parameter. * mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target parameter. Use it. (mi_on_resume): Pass target down. * nat/fork-inferior.c (startup_inferior): Add process_stratum_target parameter. Pass it down. * nat/fork-inferior.h (startup_inferior): Add process_stratum_target parameter. * python/py-threadevent.c (py_get_event_thread): Pass target down. gdb/gdbserver/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * fork-child.c (post_fork_inferior): Pass target down to startup_inferior. * inferiors.c (switch_to_thread): Add process_stratum_target parameter. * lynx-low.c (lynx_target_ops): Now a process_stratum_target. * nto-low.c (nto_target_ops): Now a process_stratum_target. * linux-low.c (linux_target_ops): Now a process_stratum_target. * remote-utils.c (prepare_resume_reply): Pass the target to switch_to_thread. * target.c (the_target): Now a process_stratum_target. (done_accessing_memory): Pass the target to switch_to_thread. (set_target_ops): Ajust to use process_stratum_target. * target.h (struct target_ops): Rename to ... (struct process_stratum_target): ... this. (the_target, set_target_ops): Adjust. (prepare_to_access_memory): Adjust comment. * win32-low.c (child_xfer_memory): Adjust to use process_stratum_target. (win32_target_ops): Now a process_stratum_target.
2020-01-10 21:06:08 +01:00
event_ptid = beneath->wait (ptid, status, 0);
/* Find any new threads that might have been created, and return the
active thread.
Only do it if the program is still alive, though. Otherwise,
this causes problems when debugging through the remote protocol,
because we might try switching threads (and thus sending packets)
after the remote has disconnected. */
if (status->kind != TARGET_WAITKIND_EXITED
&& status->kind != TARGET_WAITKIND_SIGNALLED)
{
m_base_ptid = event_ptid;
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
this->update_thread_list ();
return this->add_active_thread ()->ptid;
}
return m_base_ptid;
}
/* Add the thread associated to the given TASK to the thread list
(if the thread has already been added, this is a no-op). */
static void
ravenscar_add_thread (struct ada_task_info *task)
{
Multi-target support This commit adds multi-target support to GDB. What this means is that with this commit, GDB can now be connected to different targets at the same time. E.g., you can debug a live native process and a core dump at the same time, connect to multiple gdbservers, etc. Actually, the word "target" is overloaded in gdb. We already have a target stack, with pushes several target_ops instances on top of one another. We also have "info target" already, which means something completely different to what this patch does. So from here on, I'll be using the "target connections" term, to mean an open process_stratum target, pushed on a target stack. This patch makes gdb have multiple target stacks, and multiple process_stratum targets open simultaneously. The user-visible changes / commands will also use this terminology, but of course it's all open to debate. User-interface-wise, not that much changes. The main difference is that each inferior may have its own target connection. A target connection (e.g., a target extended-remote connection) may support debugging multiple processes, just as before. Say you're debugging against gdbserver in extended-remote mode, and you do "add-inferior" to prepare to spawn a new process, like: (gdb) target extended-remote :9999 ... (gdb) start ... (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) file a.out ... (gdb) start ... At this point, you have two inferiors connected to the same gdbserver. With this commit, GDB will maintain a target stack per inferior, instead of a global target stack. To preserve the behavior above, by default, "add-inferior" makes the new inferior inherit a copy of the target stack of the current inferior. Same across a fork - the child inherits a copy of the target stack of the parent. While the target stacks are copied, the targets themselves are not. Instead, target_ops is made a refcounted_object, which means that target_ops instances are refcounted, which each inferior counting for a reference. What if you want to create an inferior and connect it to some _other_ target? For that, this commit introduces a new "add-inferior -no-connection" option that makes the new inferior not share the current inferior's target. So you could do: (gdb) target extended-remote :9999 Remote debugging using :9999 ... (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 <null> (gdb) tar extended-remote :10000 Remote debugging using :10000 ... (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 process 18450 target:/home/pedro/tmp/main (gdb) A following patch will extended "info inferiors" to include a column indicating which connection an inferior is bound to, along with a couple other UI tweaks. Other than that, debugging is the same as before. Users interact with inferiors and threads as before. The only difference is that inferiors may be bound to processes running in different machines. That's pretty much all there is to it in terms of noticeable UI changes. On to implementation. Since we can be connected to different systems at the same time, a ptid_t is no longer a unique identifier. Instead a thread can be identified by a pair of ptid_t and 'process_stratum_target *', the later being the instance of the process_stratum target that owns the process/thread. Note that process_stratum_target inherits from target_ops, and all process_stratum targets inherit from process_stratum_target. In earlier patches, many places in gdb were converted to refer to threads by thread_info pointer instead of ptid_t, but there are still places in gdb where we start with a pid/tid and need to find the corresponding inferior or thread_info objects. So you'll see in the patch many places adding a process_stratum_target parameter to functions that used to take only a ptid_t. Since each inferior has its own target stack now, we can always find the process_stratum target for an inferior. That is done via a inf->process_target() convenience method. Since each inferior has its own target stack, we need to handle the "beneath" calls when servicing target calls. The solution I settled with is just to make sure to switch the current inferior to the inferior you want before making a target call. Not relying on global context is just not feasible in current GDB. Fortunately, there aren't that many places that need to do that, because generally most code that calls target methods already has the current context pointing to the right inferior/thread. Note, to emphasize -- there's no method to "switch to this target stack". Instead, you switch the current inferior, and that implicitly switches the target stack. In some spots, we need to iterate over all inferiors so that we reach all target stacks. Native targets are still singletons. There's always only a single instance of such targets. Remote targets however, we'll have one instance per remote connection. The exec target is still a singleton. There's only one instance. I did not see the point of instanciating more than one exec_target object. After vfork, we need to make sure to push the exec target on the new inferior. See exec_on_vfork. For type safety, functions that need a {target, ptid} pair to identify a thread, take a process_stratum_target pointer for target parameter instead of target_ops *. Some shared code in gdb/nat/ also need to gain a target pointer parameter. This poses an issue, since gdbserver doesn't have process_stratum_target, only target_ops. To fix this, this commit renames gdbserver's target_ops to process_stratum_target. I think this makes sense. There's no concept of target stack in gdbserver, and gdbserver's target_ops really implements a process_stratum-like target. The thread and inferior iterator functions also gain process_stratum_target parameters. These are used to be able to iterate over threads and inferiors of a given target. Following usual conventions, if the target pointer is null, then we iterate over threads and inferiors of all targets. I tried converting "add-inferior" to the gdb::option framework, as a preparatory patch, but that stumbled on the fact that gdb::option does not support file options yet, for "add-inferior -exec". I have a WIP patchset that adds that, but it's not a trivial patch, mainly due to need to integrate readline's filename completion, so I deferred that to some other time. In infrun.c/infcmd.c, the main change is that we need to poll events out of all targets. See do_target_wait. Right after collecting an event, we switch the current inferior to an inferior bound to the target that reported the event, so that target methods can be used while handling the event. This makes most of the code transparent to multi-targets. See fetch_inferior_event. infrun.c:stop_all_threads is interesting -- in this function we need to stop all threads of all targets. What the function does is send an asynchronous stop request to all threads, and then synchronously waits for events, with target_wait, rinse repeat, until all it finds are stopped threads. Now that we have multiple targets, it's not efficient to synchronously block in target_wait waiting for events out of one target. Instead, we implement a mini event loop, with interruptible_select, select'ing on one file descriptor per target. For this to work, we need to be able to ask the target for a waitable file descriptor. Such file descriptors already exist, they are the descriptors registered in the main event loop with add_file_handler, inside the target_async implementations. This commit adds a new target_async_wait_fd target method that just returns the file descriptor in question. See wait_one / stop_all_threads in infrun.c. The 'threads_executing' global is made a per-target variable. Since it is only relevant to process_stratum_target targets, this is where it is put, instead of in target_ops. You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress. Current limitations: - You can only resume more that one target at the same time if all targets support asynchronous debugging, and support non-stop mode. It should be possible to support mixed all-stop + non-stop backends, but that is left for another time. This means that currently in order to do multi-target with gdbserver you need to issue "maint set target-non-stop on". I would like to make that mode be the default, but we're not there yet. Note that I'm talking about how the target backend works, only. User-visible all-stop mode works just fine. - As explained above, connecting to different remote servers at the same time is likely to produce bad results if they don't support the exact set of RSP features. FreeBSD updates courtesy of John Baldwin. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> John Baldwin <jhb@FreeBSD.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::thread_architecture): Adjust. * ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call. (task_command_1): Likewise. * aix-thread.c (sync_threadlists, aix_thread_target::resume) (aix_thread_target::wait, aix_thread_target::fetch_registers) (aix_thread_target::store_registers) (aix_thread_target::thread_alive): Adjust. * amd64-fbsd-tdep.c: Include "inferior.h". (amd64fbsd_get_thread_local_address): Pass down target. * amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle thread's gdbarch instead of target_gdbarch. * break-catch-sig.c (signal_catchpoint_print_it): Adjust call to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Likewise. * breakpoint.c (breakpoints_should_be_inserted_now): Consider all inferiors. (update_inserted_breakpoint_locations): Skip if inferiors with no execution. (update_global_location_list): When handling moribund locations, find representative inferior for location's pspace, and use thread count of its process_stratum target. * bsd-kvm.c (bsd_kvm_target_open): Pass target down. * bsd-uthread.c (bsd_uthread_target::wait): Use as_process_stratum_target and adjust thread_change_ptid and add_thread calls. (bsd_uthread_target::update_thread_list): Use as_process_stratum_target and adjust find_thread_ptid, thread_change_ptid and add_thread calls. * btrace.c (maint_btrace_packet_history_cmd): Adjust find_thread_ptid call. * corelow.c (add_to_thread_list): Adjust add_thread call. (core_target_open): Adjust add_thread_silent and thread_count calls. (core_target::pid_to_str): Adjust find_inferior_ptid call. * ctf.c (ctf_target_open): Adjust add_thread_silent call. * event-top.c (async_disconnect): Pop targets from all inferiors. * exec.c (add_target_sections): Push exec target on all inferiors sharing the program space. (remove_target_sections): Remove the exec target from all inferiors sharing the program space. (exec_on_vfork): New. * exec.h (exec_on_vfork): Declare. * fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::update_thread_list): Adjust. (fbsd_nat_target::resume): Adjust. (fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust. * fbsd-tdep.c (fbsd_corefile_thread): Adjust get_thread_arch_regcache call. * fork-child.c (gdb_startup_inferior): Pass target down to startup_inferior and set_executing. * gdbthread.h (struct process_stratum_target): Forward declare. (add_thread, add_thread_silent, add_thread_with_info) (in_thread_list): Add process_stratum_target parameter. (find_thread_ptid(inferior*, ptid_t)): New overload. (find_thread_ptid, thread_change_ptid): Add process_stratum_target parameter. (all_threads()): Delete overload. (all_threads, all_non_exited_threads): Add process_stratum_target parameter. (all_threads_safe): Use brace initialization. (thread_count): Add process_stratum_target parameter. (set_resumed, set_running, set_stop_requested, set_executing) (threads_are_executing, finish_thread_state): Add process_stratum_target parameter. (switch_to_thread): Use is_current_thread. * i386-fbsd-tdep.c: Include "inferior.h". (i386fbsd_get_thread_local_address): Pass down target. * i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust. * inf-child.c (inf_child_target::maybe_unpush_target): Remove have_inferiors check. * inf-ptrace.c (inf_ptrace_target::create_inferior) (inf_ptrace_target::attach): Adjust. * infcall.c (run_inferior_call): Adjust. * infcmd.c (run_command_1): Pass target to scoped_finish_thread_state. (proceed_thread_callback): Skip inferiors with no execution. (continue_command): Rename 'all_threads' local to avoid hiding 'all_threads' function. Adjust get_last_target_status call. (prepare_one_step): Adjust set_running call. (signal_command): Use user_visible_resume_target. Compare thread pointers instead of inferior_ptid. (info_program_command): Adjust to pass down target. (attach_command): Mark target's 'thread_executing' flag. (stop_current_target_threads_ns): New, factored out from ... (interrupt_target_1): ... this. Switch inferior before making target calls. * inferior-iter.h (struct all_inferiors_iterator, struct all_inferiors_range) (struct all_inferiors_safe_range) (struct all_non_exited_inferiors_range): Filter on process_stratum_target too. Remove explicit. * inferior.c (inferior::inferior): Push dummy target on target stack. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors): Add process_stratum_target parameter, and pass it down. (have_live_inferiors): Adjust. (switch_to_inferior_and_push_target): New. (add_inferior_command, clone_inferior_command): Handle "-no-connection" parameter. Use switch_to_inferior_and_push_target. (_initialize_inferior): Mention "-no-connection" option in the help of "add-inferior" and "clone-inferior" commands. * inferior.h: Include "process-stratum-target.h". (interrupt_target_1): Use bool. (struct inferior) <push_target, unpush_target, target_is_pushed, find_target_beneath, top_target, process_target, target_at, m_stack>: New. (discard_all_inferiors): Delete. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors) (all_inferiors, all_non_exited_inferiors): Add process_stratum_target parameter. * infrun.c: Include "gdb_select.h" and <unordered_map>. (target_last_proc_target): New global. (follow_fork_inferior): Push target on new inferior. Pass target to add_thread_silent. Call exec_on_vfork. Handle target's reference count. (follow_fork): Adjust get_last_target_status call. Also consider target. (follow_exec): Push target on new inferior. (struct execution_control_state) <target>: New field. (user_visible_resume_target): New. (do_target_resume): Call target_async. (resume_1): Set target's threads_executing flag. Consider resume target. (commit_resume_all_targets): New. (proceed): Also consider resume target. Skip threads of inferiors with no execution. Commit resumtion in all targets. (start_remote): Pass current inferior to wait_for_inferior. (infrun_thread_stop_requested): Consider target as well. Pass thread_info pointer to clear_inline_frame_state instead of ptid. (infrun_thread_thread_exit): Consider target as well. (random_pending_event_thread): New inferior parameter. Use it. (do_target_wait): Rename to ... (do_target_wait_1): ... this. Add inferior parameter, and pass it down. (threads_are_resumed_pending_p, do_target_wait): New. (prepare_for_detach): Adjust calls. (wait_for_inferior): New inferior parameter. Handle it. Use do_target_wait_1 instead of do_target_wait. (fetch_inferior_event): Adjust. Switch to representative inferior. Pass target down. (set_last_target_status): Add process_stratum_target parameter. Save target in global. (get_last_target_status): Add process_stratum_target parameter and handle it. (nullify_last_target_wait_ptid): Clear 'target_last_proc_target'. (context_switch): Check inferior_ptid == null_ptid before calling inferior_thread(). (get_inferior_stop_soon): Pass down target. (wait_one): Rename to ... (poll_one_curr_target): ... this. (struct wait_one_event): New. (wait_one): New. (stop_all_threads): Adjust. (handle_no_resumed, handle_inferior_event): Adjust to consider the event's target. (switch_back_to_stepped_thread): Also consider target. (print_stop_event): Update. (normal_stop): Update. Also consider the resume target. * infrun.h (wait_for_inferior): Remove declaration. (user_visible_resume_target): New declaration. (get_last_target_status, set_last_target_status): New process_stratum_target parameter. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter, and use it. (clear_inline_frame_state (thread_info*)): New. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter. (clear_inline_frame_state (thread_info*)): Declare. * linux-fork.c (delete_checkpoint_command): Pass target down to find_thread_ptid. (checkpoint_command): Adjust. * linux-nat.c (linux_nat_target::follow_fork): Switch to thread instead of just tweaking inferior_ptid. (linux_nat_switch_fork): Pass target down to thread_change_ptid. (exit_lwp): Pass target down to find_thread_ptid. (attach_proc_task_lwp_callback): Pass target down to add_thread/set_running/set_executing. (linux_nat_target::attach): Pass target down to thread_change_ptid. (get_detach_signal): Pass target down to find_thread_ptid. Consider last target status's target. (linux_resume_one_lwp_throw, resume_lwp) (linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp) (stop_wait_callback, save_stop_reason, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down. (linux_nat_target::async_wait_fd): New. (linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass target down. * linux-nat.h (linux_nat_target::async_wait_fd): Declare. * linux-tdep.c (get_thread_arch_regcache): Pass target down. * linux-thread-db.c (struct thread_db_info::process_target): New field. (add_thread_db_info): Save target. (get_thread_db_info): New process_stratum_target parameter. Also match target. (delete_thread_db_info): New process_stratum_target parameter. Also match target. (thread_from_lwp): Adjust to pass down target. (thread_db_notice_clone): Pass down target. (check_thread_db_callback): Pass down target. (try_thread_db_load_1): Always push the thread_db target. (try_thread_db_load, record_thread): Pass target down. (thread_db_target::detach): Pass target down. Always unpush the thread_db target. (thread_db_target::wait, thread_db_target::mourn_inferior): Pass target down. Always unpush the thread_db target. (find_new_threads_callback, thread_db_find_new_threads_2) (thread_db_target::update_thread_list): Pass target down. (thread_db_target::pid_to_str): Pass current inferior down. (thread_db_target::get_thread_local_address): Pass target down. (thread_db_target::resume, maintenance_check_libthread_db): Pass target down. * nto-procfs.c (nto_procfs_target::update_thread_list): Adjust. * procfs.c (procfs_target::procfs_init_inferior): Declare. (proc_set_current_signal, do_attach, procfs_target::wait): Adjust. (procfs_init_inferior): Rename to ... (procfs_target::procfs_init_inferior): ... this and adjust. (procfs_target::create_inferior, procfs_notice_thread) (procfs_do_thread_registers): Adjust. * ppc-fbsd-tdep.c: Include "inferior.h". (ppcfbsd_get_thread_local_address): Pass down target. * proc-service.c (ps_xfer_memory): Switch current inferior and program space as well. (get_ps_regcache): Pass target down. * process-stratum-target.c (process_stratum_target::thread_address_space) (process_stratum_target::thread_architecture): Pass target down. * process-stratum-target.h (process_stratum_target::threads_executing): New field. (as_process_stratum_target): New. * ravenscar-thread.c (ravenscar_thread_target::update_inferior_ptid): Pass target down. (ravenscar_thread_target::wait, ravenscar_add_thread): Pass target down. * record-btrace.c (record_btrace_target::info_record): Adjust. (record_btrace_target::record_method) (record_btrace_target::record_is_replaying) (record_btrace_target::fetch_registers) (get_thread_current_frame_id, record_btrace_target::resume) (record_btrace_target::wait, record_btrace_target::stop): Pass target down. * record-full.c (record_full_wait_1): Switch to event thread. Pass target down. * regcache.c (regcache::regcache) (get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add process_stratum_target parameter and handle it. (current_thread_target): New global. (get_thread_regcache): Add process_stratum_target parameter and handle it. Switch inferior before calling target method. (get_thread_regcache): Pass target down. (get_thread_regcache_for_ptid): Pass target down. (registers_changed_ptid): Add process_stratum_target parameter and handle it. (registers_changed_thread, registers_changed): Pass target down. (test_get_thread_arch_aspace_regcache): New. (current_regcache_test): Define a couple local test_target_ops instances and use them for testing. (readwrite_regcache): Pass process_stratum_target parameter. (cooked_read_test, cooked_write_test): Pass mock_target down. * regcache.h (get_thread_regcache, get_thread_arch_regcache) (get_thread_arch_aspace_regcache): Add process_stratum_target parameter. (regcache::target): New method. (regcache::regcache, regcache::get_thread_arch_aspace_regcache) (regcache::registers_changed_ptid): Add process_stratum_target parameter. (regcache::m_target): New field. (registers_changed_ptid): Add process_stratum_target parameter. * remote.c (remote_state::supports_vCont_probed): New field. (remote_target::async_wait_fd): New method. (remote_unpush_and_throw): Add remote_target parameter. (get_current_remote_target): Adjust. (remote_target::remote_add_inferior): Push target. (remote_target::remote_add_thread) (remote_target::remote_notice_new_inferior) (get_remote_thread_info): Pass target down. (remote_target::update_thread_list): Skip threads of inferiors bound to other targets. (remote_target::close): Don't discard inferiors. (remote_target::add_current_inferior_and_thread) (remote_target::process_initial_stop_replies) (remote_target::start_remote) (remote_target::remote_serial_quit_handler): Pass down target. (remote_target::remote_unpush_target): New remote_target parameter. Unpush the target from all inferiors. (remote_target::remote_unpush_and_throw): New remote_target parameter. Pass it down. (remote_target::open_1): Check whether the current inferior has execution instead of checking whether any inferior is live. Pass target down. (remote_target::remote_detach_1): Pass down target. Use remote_unpush_target. (extended_remote_target::attach): Pass down target. (remote_target::remote_vcont_probe): Set supports_vCont_probed. (remote_target::append_resumption): Pass down target. (remote_target::append_pending_thread_resumptions) (remote_target::remote_resume_with_hc, remote_target::resume) (remote_target::commit_resume): Pass down target. (remote_target::remote_stop_ns): Check supports_vCont_probed. (remote_target::interrupt_query) (remote_target::remove_new_fork_children) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::remote_parse_stop_reply) (remote_target::process_stop_reply): Pass down target. (first_remote_resumed_thread): New remote_target parameter. Pass it down. (remote_target::wait_as): Pass down target. (unpush_and_perror): New remote_target parameter. Pass it down. (remote_target::readchar, remote_target::remote_serial_write) (remote_target::getpkt_or_notif_sane_1) (remote_target::kill_new_fork_children, remote_target::kill): Pass down target. (remote_target::mourn_inferior): Pass down target. Use remote_unpush_target. (remote_target::core_of_thread) (remote_target::remote_btrace_maybe_reopen): Pass down target. (remote_target::pid_to_exec_file) (remote_target::thread_handle_to_thread_info): Pass down target. (remote_target::async_wait_fd): New. * riscv-fbsd-tdep.c: Include "inferior.h". (riscv_fbsd_get_thread_local_address): Pass down target. * sol2-tdep.c (sol2_core_pid_to_str): Pass down target. * sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs) (ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback): Adjust. * solib-spu.c (spu_skip_standalone_loader): Pass down target. * solib-svr4.c (enable_break): Pass down target. * spu-multiarch.c (parse_spufs_run): Pass down target. * spu-tdep.c (spu2ppu_sniffer): Pass down target. * target-delegates.c: Regenerate. * target.c (g_target_stack): Delete. (current_top_target): Return the current inferior's top target. (target_has_execution_1): Refer to the passed-in inferior's top target. (target_supports_terminal_ours): Check whether the initial inferior was already created. (decref_target): New. (target_stack::push): Incref/decref the target. (push_target, push_target, unpush_target): Adjust. (target_stack::unpush): Defref target. (target_is_pushed): Return bool. Adjust to refer to the current inferior's target stack. (dispose_inferior): Delete, and inline parts ... (target_preopen): ... here. Only dispose of the current inferior. (target_detach): Hold strong target reference while detaching. Pass target down. (target_thread_name): Add assertion. (target_resume): Pass down target. (target_ops::beneath, find_target_at): Adjust to refer to the current inferior's target stack. (get_dummy_target): New. (target_pass_ctrlc): Pass the Ctrl-C to the first inferior that has a thread running. (initialize_targets): Rename to ... (_initialize_target): ... this. * target.h: Include "gdbsupport/refcounted-object.h". (struct target_ops): Inherit refcounted_object. (target_ops::shortname, target_ops::longname): Make const. (target_ops::async_wait_fd): New method. (decref_target): Declare. (struct target_ops_ref_policy): New. (target_ops_ref): New typedef. (get_dummy_target): Declare function. (target_is_pushed): Return bool. * thread-iter.c (all_matching_threads_iterator::m_inf_matches) (all_matching_threads_iterator::all_matching_threads_iterator): Handle filter target. * thread-iter.h (struct all_matching_threads_iterator, struct all_matching_threads_range, class all_non_exited_threads_range): Filter by target too. Remove explicit. * thread.c (threads_executing): Delete. (inferior_thread): Pass down current inferior. (clear_thread_inferior_resources): Pass down thread pointer instead of ptid_t. (add_thread_silent, add_thread_with_info, add_thread): Add process_stratum_target parameter. Use it for thread and inferior searches. (is_current_thread): New. (thread_info::deletable): Use it. (find_thread_ptid, thread_count, in_thread_list) (thread_change_ptid, set_resumed, set_running): New process_stratum_target parameter. Pass it down. (set_executing): New process_stratum_target parameter. Pass it down. Adjust reference to 'threads_executing'. (threads_are_executing): New process_stratum_target parameter. Adjust reference to 'threads_executing'. (set_stop_requested, finish_thread_state): New process_stratum_target parameter. Pass it down. (switch_to_thread): Also match inferior. (switch_to_thread): New process_stratum_target parameter. Pass it down. (update_threads_executing): Reimplement. * top.c (quit_force): Pop targets from all inferior. (gdb_init): Don't call initialize_targets. * windows-nat.c (windows_nat_target) <get_windows_debug_event>: Declare. (windows_add_thread, windows_delete_thread): Adjust. (get_windows_debug_event): Rename to ... (windows_nat_target::get_windows_debug_event): ... this. Adjust. * tracefile-tfile.c (tfile_target_open): Pass down target. * gdbsupport/common-gdbthread.h (struct process_stratum_target): Forward declare. (switch_to_thread): Add process_stratum_target parameter. * mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target parameter. Use it. (mi_on_resume): Pass target down. * nat/fork-inferior.c (startup_inferior): Add process_stratum_target parameter. Pass it down. * nat/fork-inferior.h (startup_inferior): Add process_stratum_target parameter. * python/py-threadevent.c (py_get_event_thread): Pass target down. gdb/gdbserver/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * fork-child.c (post_fork_inferior): Pass target down to startup_inferior. * inferiors.c (switch_to_thread): Add process_stratum_target parameter. * lynx-low.c (lynx_target_ops): Now a process_stratum_target. * nto-low.c (nto_target_ops): Now a process_stratum_target. * linux-low.c (linux_target_ops): Now a process_stratum_target. * remote-utils.c (prepare_resume_reply): Pass the target to switch_to_thread. * target.c (the_target): Now a process_stratum_target. (done_accessing_memory): Pass the target to switch_to_thread. (set_target_ops): Ajust to use process_stratum_target. * target.h (struct target_ops): Rename to ... (struct process_stratum_target): ... this. (the_target, set_target_ops): Adjust. (prepare_to_access_memory): Adjust comment. * win32-low.c (child_xfer_memory): Adjust to use process_stratum_target. (win32_target_ops): Now a process_stratum_target.
2020-01-10 21:06:08 +01:00
if (find_thread_ptid (current_inferior (), task->ptid) == NULL)
add_thread (current_inferior ()->process_target (), task->ptid);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::update_thread_list ()
{
/* Do not clear the thread list before adding the Ada task, to keep
the thread that the process stratum has included into it
(m_base_ptid) and the running thread, that may not have been included
to system.tasking.debug's list yet. */
iterate_over_live_ada_tasks (ravenscar_add_thread);
}
ptid_t
ravenscar_thread_target::active_task (int cpu)
{
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
CORE_ADDR tid = get_running_thread_id (cpu);
if (tid == 0)
return null_ptid;
else
return ptid_t (m_base_ptid.pid (), 0, tid);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
const char *
ravenscar_thread_target::extra_thread_info (thread_info *tp)
{
return "Ravenscar task";
}
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::thread_alive (ptid_t ptid)
{
/* Ravenscar tasks are non-terminating. */
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
return true;
}
Change pid_to_str to return std::string Currently the target pid_to_str method returns a const char *, so many implementations have a static buffer that they update. This patch changes these methods to return a std::string instead. I think this is cleaner and avoids possible gotchas when calling pid_to_str on different ptids in a single statement. (Though no such calls exist currently.) This also updates various helper functions, and the gdbarch pid_to_str methods. I also made a best effort to fix all the callers, but I can't build some of the *-nat.c files. Tested by the buildbot. gdb/ChangeLog 2019-03-13 Tom Tromey <tromey@adacore.com> * i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers) (i386_gnu_nat_target::store_registers): Update. * target-debug.h (target_debug_print_std_string): New macro. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * windows-tdep.c (display_one_tib): Update. * tui/tui-stack.c (tui_make_status_line): Update. * top.c (print_inferior_quit_action): Update. * thread.c (thr_try_catch_cmd): Update. (add_thread_with_info): Update. (thread_target_id_str): Update. (thr_try_catch_cmd): Update. (thread_command): Update. (thread_find_command): Update. * record-btrace.c (record_btrace_target::info_record) (record_btrace_resume_thread, record_btrace_target::resume) (record_btrace_cancel_resume, record_btrace_step_thread) (record_btrace_target::wait, record_btrace_target::wait) (record_btrace_target::wait, record_btrace_target::stop): Update. * progspace.c (print_program_space): Update. * process-stratum-target.c (process_stratum_target::thread_address_space): Update. * linux-fork.c (linux_fork_mourn_inferior) (detach_checkpoint_command, info_checkpoints_command) (linux_fork_context): Update. (linux_fork_detach): Update. (class scoped_switch_fork_info): Update. (delete_checkpoint_command): Update. * infrun.c (follow_fork_inferior): Update. (follow_fork_inferior): Update. (proceed_after_vfork_done): Update. (handle_vfork_child_exec_or_exit): Update. (follow_exec): Update. (displaced_step_prepare_throw): Update. (displaced_step_restore): Update. (start_step_over): Update. (resume_1): Update. (clear_proceed_status_thread): Update. (proceed): Update. (print_target_wait_results): Update. (do_target_wait): Update. (context_switch): Update. (stop_all_threads): Update. (restart_threads): Update. (finish_step_over): Update. (handle_signal_stop): Update. (switch_back_to_stepped_thread): Update. (keep_going_pass_signal): Update. (print_exited_reason): Update. (normal_stop): Update. * inferior.c (inferior_pid_to_str): Change return type. (print_selected_inferior): Update. (add_inferior): Update. (detach_inferior): Update. * dummy-frame.c (fprint_dummy_frames): Update. * dcache.c (dcache_info_1): Update. * btrace.c (btrace_enable, btrace_disable, btrace_teardown) (btrace_fetch, btrace_clear): Update. * linux-tdep.c (linux_core_pid_to_str): Change return type. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return type. * fbsd-tdep.c (fbsd_core_pid_to_str): Change return type. * sol2-tdep.h (sol2_core_pid_to_str): Change return type. * sol2-tdep.c (sol2_core_pid_to_str): Change return type. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (core_pid_to_str): Change return type. * windows-nat.c (struct windows_nat_target) <pid_to_str>: Change return type. (windows_nat_target::pid_to_str): Change return type. (windows_delete_thread): Update. (windows_nat_target::attach): Update. (windows_nat_target::files_info): Update. * target-delegates.c: Rebuild. * sol-thread.c (class sol_thread_target) <pid_to_str>: Change return type. (sol_thread_target::pid_to_str): Change return type. * remote.c (class remote_target) <pid_to_str>: Change return type. (remote_target::pid_to_str): Change return type. (extended_remote_target::attach, remote_target::remote_stop_ns) (remote_target::remote_notif_remove_queued_reply) (remote_target::push_stop_reply, remote_target::disable_btrace): Update. (extended_remote_target::attach): Update. * remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return type. (gdbsim_target::pid_to_str): Change return type. * ravenscar-thread.c (struct ravenscar_thread_target) <pid_to_str>: Change return type. (ravenscar_thread_target::pid_to_str): Change return type. * procfs.c (class procfs_target) <pid_to_str>: Change return type. (procfs_target::pid_to_str): Change return type. (procfs_target::attach): Update. (procfs_target::detach): Update. (procfs_target::fetch_registers): Update. (procfs_target::store_registers): Update. (procfs_target::wait): Update. (procfs_target::files_info): Update. * obsd-nat.c (obsd_nat_target::pid_to_str): Change return type. * nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change return type. (nto_procfs_target::pid_to_str): Change return type. (nto_procfs_target::files_info, nto_procfs_target::attach): Update. * linux-thread-db.c (class thread_db_target) <pid_to_str>: Change return type. * linux-nat.c (linux_nat_target::pid_to_str): Change return type. (exit_lwp): Update. (attach_proc_task_lwp_callback, get_detach_signal) (detach_one_lwp, resume_lwp, linux_nat_target::resume) (linux_nat_target::resume, wait_lwp, stop_callback) (maybe_clear_ignore_sigint, stop_wait_callback, status_callback) (save_stop_reason, select_event_lwp, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps) (linux_nat_target::wait, linux_nat_stop_lwp): Update. * inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return type. (inf_ptrace_target::attach): Update. (inf_ptrace_target::files_info): Update. * go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return type. (go32_nat_target::pid_to_str): Change return type. * gnu-nat.c (gnu_nat_target::pid_to_str): Change return type. (gnu_nat_target::wait): Update. (gnu_nat_target::wait): Update. (gnu_nat_target::resume): Update. * fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type. (fbsd_nat_target::wait): Update. * darwin-nat.c (darwin_nat_target::pid_to_str): Change return type. (darwin_nat_target::attach): Update. * corelow.c (class core_target) <pid_to_str>: Change return type. (core_target::pid_to_str): Change return type. * target.c (normal_pid_to_str): Change return type. (default_pid_to_str): Likewise. (target_pid_to_str): Change return type. (target_translate_tls_address): Update. (target_announce_detach): Update. * bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change return type. (bsd_uthread_target::pid_to_str): Change return type. * bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return type. (bsd_kvm_target::pid_to_str): Change return type. * aix-thread.c (class aix_thread_target) <pid_to_str>: Change return type. (aix_thread_target::pid_to_str): Change return type. * target.h (struct target_ops) <pid_to_str>: Change return type. (target_pid_to_str, normal_pid_to_str): Likewise. * obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return type. * linux-nat.h (class linux_nat_target) <pid_to_str>: Change return type. * inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change return type. * gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return type. * fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return type. * darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change return type.
2019-02-28 17:09:55 +01:00
std::string
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::pid_to_str (ptid_t ptid)
{
Change pid_to_str to return std::string Currently the target pid_to_str method returns a const char *, so many implementations have a static buffer that they update. This patch changes these methods to return a std::string instead. I think this is cleaner and avoids possible gotchas when calling pid_to_str on different ptids in a single statement. (Though no such calls exist currently.) This also updates various helper functions, and the gdbarch pid_to_str methods. I also made a best effort to fix all the callers, but I can't build some of the *-nat.c files. Tested by the buildbot. gdb/ChangeLog 2019-03-13 Tom Tromey <tromey@adacore.com> * i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers) (i386_gnu_nat_target::store_registers): Update. * target-debug.h (target_debug_print_std_string): New macro. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * windows-tdep.c (display_one_tib): Update. * tui/tui-stack.c (tui_make_status_line): Update. * top.c (print_inferior_quit_action): Update. * thread.c (thr_try_catch_cmd): Update. (add_thread_with_info): Update. (thread_target_id_str): Update. (thr_try_catch_cmd): Update. (thread_command): Update. (thread_find_command): Update. * record-btrace.c (record_btrace_target::info_record) (record_btrace_resume_thread, record_btrace_target::resume) (record_btrace_cancel_resume, record_btrace_step_thread) (record_btrace_target::wait, record_btrace_target::wait) (record_btrace_target::wait, record_btrace_target::stop): Update. * progspace.c (print_program_space): Update. * process-stratum-target.c (process_stratum_target::thread_address_space): Update. * linux-fork.c (linux_fork_mourn_inferior) (detach_checkpoint_command, info_checkpoints_command) (linux_fork_context): Update. (linux_fork_detach): Update. (class scoped_switch_fork_info): Update. (delete_checkpoint_command): Update. * infrun.c (follow_fork_inferior): Update. (follow_fork_inferior): Update. (proceed_after_vfork_done): Update. (handle_vfork_child_exec_or_exit): Update. (follow_exec): Update. (displaced_step_prepare_throw): Update. (displaced_step_restore): Update. (start_step_over): Update. (resume_1): Update. (clear_proceed_status_thread): Update. (proceed): Update. (print_target_wait_results): Update. (do_target_wait): Update. (context_switch): Update. (stop_all_threads): Update. (restart_threads): Update. (finish_step_over): Update. (handle_signal_stop): Update. (switch_back_to_stepped_thread): Update. (keep_going_pass_signal): Update. (print_exited_reason): Update. (normal_stop): Update. * inferior.c (inferior_pid_to_str): Change return type. (print_selected_inferior): Update. (add_inferior): Update. (detach_inferior): Update. * dummy-frame.c (fprint_dummy_frames): Update. * dcache.c (dcache_info_1): Update. * btrace.c (btrace_enable, btrace_disable, btrace_teardown) (btrace_fetch, btrace_clear): Update. * linux-tdep.c (linux_core_pid_to_str): Change return type. * i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return type. * fbsd-tdep.c (fbsd_core_pid_to_str): Change return type. * sol2-tdep.h (sol2_core_pid_to_str): Change return type. * sol2-tdep.c (sol2_core_pid_to_str): Change return type. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (core_pid_to_str): Change return type. * windows-nat.c (struct windows_nat_target) <pid_to_str>: Change return type. (windows_nat_target::pid_to_str): Change return type. (windows_delete_thread): Update. (windows_nat_target::attach): Update. (windows_nat_target::files_info): Update. * target-delegates.c: Rebuild. * sol-thread.c (class sol_thread_target) <pid_to_str>: Change return type. (sol_thread_target::pid_to_str): Change return type. * remote.c (class remote_target) <pid_to_str>: Change return type. (remote_target::pid_to_str): Change return type. (extended_remote_target::attach, remote_target::remote_stop_ns) (remote_target::remote_notif_remove_queued_reply) (remote_target::push_stop_reply, remote_target::disable_btrace): Update. (extended_remote_target::attach): Update. * remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return type. (gdbsim_target::pid_to_str): Change return type. * ravenscar-thread.c (struct ravenscar_thread_target) <pid_to_str>: Change return type. (ravenscar_thread_target::pid_to_str): Change return type. * procfs.c (class procfs_target) <pid_to_str>: Change return type. (procfs_target::pid_to_str): Change return type. (procfs_target::attach): Update. (procfs_target::detach): Update. (procfs_target::fetch_registers): Update. (procfs_target::store_registers): Update. (procfs_target::wait): Update. (procfs_target::files_info): Update. * obsd-nat.c (obsd_nat_target::pid_to_str): Change return type. * nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change return type. (nto_procfs_target::pid_to_str): Change return type. (nto_procfs_target::files_info, nto_procfs_target::attach): Update. * linux-thread-db.c (class thread_db_target) <pid_to_str>: Change return type. * linux-nat.c (linux_nat_target::pid_to_str): Change return type. (exit_lwp): Update. (attach_proc_task_lwp_callback, get_detach_signal) (detach_one_lwp, resume_lwp, linux_nat_target::resume) (linux_nat_target::resume, wait_lwp, stop_callback) (maybe_clear_ignore_sigint, stop_wait_callback, status_callback) (save_stop_reason, select_event_lwp, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps) (linux_nat_target::wait, linux_nat_stop_lwp): Update. * inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return type. (inf_ptrace_target::attach): Update. (inf_ptrace_target::files_info): Update. * go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return type. (go32_nat_target::pid_to_str): Change return type. * gnu-nat.c (gnu_nat_target::pid_to_str): Change return type. (gnu_nat_target::wait): Update. (gnu_nat_target::wait): Update. (gnu_nat_target::resume): Update. * fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type. (fbsd_nat_target::wait): Update. * darwin-nat.c (darwin_nat_target::pid_to_str): Change return type. (darwin_nat_target::attach): Update. * corelow.c (class core_target) <pid_to_str>: Change return type. (core_target::pid_to_str): Change return type. * target.c (normal_pid_to_str): Change return type. (default_pid_to_str): Likewise. (target_pid_to_str): Change return type. (target_translate_tls_address): Update. (target_announce_detach): Update. * bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change return type. (bsd_uthread_target::pid_to_str): Change return type. * bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return type. (bsd_kvm_target::pid_to_str): Change return type. * aix-thread.c (class aix_thread_target) <pid_to_str>: Change return type. (aix_thread_target::pid_to_str): Change return type. * target.h (struct target_ops) <pid_to_str>: Change return type. (target_pid_to_str, normal_pid_to_str): Likewise. * obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return type. * linux-nat.h (class linux_nat_target) <pid_to_str>: Change return type. * inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change return type. * gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return type. * fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return type. * darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change return type.
2019-02-28 17:09:55 +01:00
return string_printf ("Thread %#x", (int) ptid.tid ());
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::fetch_registers (struct regcache *regcache, int regnum)
{
ptid_t ptid = regcache->ptid ();
if (runtime_initialized ()
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
&& is_ravenscar_task (ptid)
&& !task_is_currently_active (ptid))
{
s/get_regcache_arch (regcache)/regcache->arch ()/g This patches removes get_regcache_arch, and use regache->arch () instead. The motivation of this change is that I am going to move some basic stuff into a base class of regcache. I don't need to update "client" code regcache->arch (). On the other hand, this patch shortens the code a little bit. gdb: 2017-10-25 Yao Qi <yao.qi@linaro.org> * aarch32-linux-nat.c (aarch32_gp_regcache_supply): Use regcache->arch () instead get_regcache_arch. * aarch64-fbsd-nat.c (aarch64_fbsd_fetch_inferior_registers): Likewise. (aarch64_fbsd_store_inferior_registers): Likewise. * aarch64-linux-nat.c (fetch_gregs_from_thread): Likewise. (store_gregs_to_thread): Likewise. (fetch_fpregs_from_thread): Likewise. (store_fpregs_to_thread): Likewise. * aarch64-tdep.c (aarch64_extract_return_value): Likewise. (aarch64_store_return_value): Likewise. (aarch64_software_single_step): Likewise. * aix-thread.c (aix_thread_wait): Likewise. (supply_reg32): Likewise. (supply_sprs64): Likewise. (supply_sprs32): Likewise. (fill_gprs64): Likewise. (fill_gprs32): Likewise. (fill_sprs64): Likewise. (fill_sprs32): Likewise. (store_regs_user_thread): Likewise. (store_regs_kernel_thread): Likewise. * alpha-bsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * alpha-tdep.c (alpha_extract_return_value): Likewise. (alpha_store_return_value): Likewise. (alpha_deal_with_atomic_sequence): Likewise. (alpha_next_pc): Likewise. (alpha_software_single_step): Likewise. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * amd64-nat.c (amd64_supply_native_gregset): Likewise. (amd64_collect_native_gregset): Likewise. * amd64-obsd-tdep.c (amd64obsd_supply_uthread): Likewise. (amd64obsd_collect_uthread): Likewise. * amd64-tdep.c (amd64_supply_fpregset): Likewise. (amd64_collect_fpregset): Likewise. (amd64_supply_fxsave): Likewise. (amd64_supply_xsave): Likewise. (amd64_collect_fxsave): Likewise. (amd64_collect_xsave): Likewise. * arc-tdep.c (arc_write_pc): Likewise. * arch-utils.c (default_skip_permanent_breakpoint): Likewise. * arm-fbsd-nat.c (arm_fbsd_fetch_inferior_registers): Likewise. (arm_fbsd_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_vfp_regs): Likewise. (store_vfp_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * arm-linux-tdep.c (arm_linux_supply_gregset): Likewise. (arm_linux_sigreturn_next_pc): Likewise. (arm_linux_get_next_pcs_syscall_next_pc): Likewise. * arm-nbsd-nat.c (arm_supply_gregset): Likewise. (fetch_register): Likewise. (store_register): Likewise. * arm-tdep.c (arm_is_thumb): Likewise. (displaced_in_arm_mode): Likewise. (bx_write_pc): Likewise. (arm_get_next_pcs_addr_bits_remove): Likewise. (arm_software_single_step): Likewise. (arm_extract_return_value): Likewise. (arm_store_return_value): Likewise. (arm_write_pc): Likewise. * bfin-tdep.c (bfin_extract_return_value): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * core-regset.c (fetch_core_registers): Likewise. * corelow.c (get_core_registers): Likewise. * cris-tdep.c (cris_store_return_value): Likewise. (cris_extract_return_value): Likewise. (find_step_target): Likewise. (find_step_target): Likewise. (cris_software_single_step): Likewise. * ctf.c (ctf_fetch_registers): Likewise. * darwin-nat.c (cancel_breakpoint): Likewise. * fbsd-tdep.c (fbsd_collect_thread_registers): Likewise. * frv-tdep.c (frv_extract_return_value): Likewise. * ft32-tdep.c (ft32_store_return_value): Likewise. (ft32_extract_return_value): Likewise. * go32-nat.c (fetch_register): Likewise. (go32_fetch_registers): Likewise. (go32_store_registers): Likewise. (store_register): Likewise. * h8300-tdep.c (h8300_extract_return_value): Likewise. (h8300_store_return_value): Likewise. * hppa-linux-nat.c (fetch_register): Likewise. (store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * i386-darwin-nat.c (i386_darwin_fetch_inferior_registers): Likewise. (i386_darwin_store_inferior_registers): Likewise. * i386-gnu-nat.c (gnu_fetch_registers): Likewise. (gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register): Likewise. (store_register): Likewise. (supply_gregset): Likewise. (fill_gregset): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. (i386_linux_resume): Likewise. * i386-linux-tdep.c (i386_linux_get_syscall_number_from_regcache): Likewise. * i386-nto-tdep.c (i386nto_supply_gregset): Likewise. * i386-obsd-nat.c (i386obsd_supply_pcb): Likewise. * i386-obsd-tdep.c (i386obsd_supply_uthread): Likewise. (i386obsd_collect_uthread): Likewise. * i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise. (i386_supply_gregset): Likewise. (i386_collect_gregset): Likewise. (i386_supply_fpregset): Likewise. (i386_collect_fpregset): Likewise. (i386_mpx_bd_base): Likewise. * i386-v4-nat.c (supply_fpregset): Likewise. (fill_fpregset): Likewise. * i387-tdep.c (i387_supply_fsave): Likewise. (i387_collect_fsave): Likewise. (i387_supply_fxsave): Likewise. (i387_collect_fxsave): Likewise. (i387_supply_xsave): Likewise. (i387_collect_xsave): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_registers): Likewise. * ia64-tdep.c (ia64_access_rse_reg): Likewise. (ia64_extract_return_value): Likewise. (ia64_store_return_value): Likewise. (find_func_descr): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_registers): Likewise. * infrun.c (use_displaced_stepping): Likewise. (displaced_step_prepare_throw): Likewise. (resume): Likewise. (proceed): Likewise. (do_target_wait): Likewise. (adjust_pc_after_break): Likewise. (handle_inferior_event_1): Likewise. (handle_signal_stop): Likewise. (save_infcall_suspend_state): Likewise. (restore_infcall_suspend_state): Likewise. * iq2000-tdep.c (iq2000_extract_return_value): Likewise. * jit.c (jit_frame_prev_register): Likewise. * linux-nat.c (save_stop_reason): Likewise. (linux_nat_wait_1): Likewise. (resume_stopped_resumed_lwps): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (record_linux_system_call): Likewise. * linux-tdep.c (linux_collect_thread_registers): Likewise. * lm32-tdep.c (lm32_extract_return_value): Likewise. (lm32_store_return_value): Likewise. * m32c-tdep.c (m32c_read_flg): Likewise. (m32c_pseudo_register_read): Likewise. (m32c_pseudo_register_write): Likewise. * m32r-linux-tdep.c (m32r_linux_supply_gregset): Likewise. (m32r_linux_collect_gregset): Likewise. * m32r-tdep.c (m32r_store_return_value): Likewise. (m32r_extract_return_value): Likewise. * m68k-bsd-nat.c (m68kbsd_supply_fpregset): Likewise. (m68kbsd_collect_fpregset): Likewise. * m68k-bsd-tdep.c (m68kbsd_supply_fpregset): Likewise. * m68k-linux-nat.c (fetch_register): Likewise. (old_fetch_inferior_registers): Likewise. (old_store_inferior_registers): Likewise. (store_regs): Likewise. * m68k-tdep.c (m68k_svr4_extract_return_value): Likewise. (m68k_svr4_store_return_value): Likewise. * m88k-tdep.c (m88k_store_arguments): Likewise. * mi/mi-main.c (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_write_register_values): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers): Likewise. (mips_fbsd_store_inferior_registers): Likewise. * mips-fbsd-tdep.c (mips_fbsd_supply_fpregs): Likewise. (mips_fbsd_supply_gregs): Likewise. (mips_fbsd_collect_fpregs): Likewise. (mips_fbsd_collect_gregs): Likewise. (mips_fbsd_supply_fpregset): Likewise. (mips_fbsd_collect_fpregset): Likewise. (mips_fbsd_supply_gregset): Likewise. (mips_fbsd_collect_gregset): Likewise. * mips-linux-nat.c (supply_gregset): Likewise. (fill_gregset): Likewise. (supply_fpregset): Likewise. (fill_fpregset): Likewise. * mips-linux-tdep.c (mips_supply_gregset): Likewise. (mips_fill_gregset): Likewise. (mips_supply_fpregset): Likewise. (mips_fill_fpregset): Likewise. (mips64_supply_gregset): Likewise. (micromips_linux_sigframe_validate): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * mips-nbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise. (mipsnbsd_supply_gregset): Likewise. (mipsnbsd_iterate_over_regset_sections): Likewise. (mipsnbsd_supply_reg): Likewise. (mipsnbsd_supply_fpreg): Likewise. * mips-tdep.c (mips_in_frame_stub): Likewise. (mips_dummy_id): Likewise. (is_octeon_bbit_op): Likewise. (micromips_bc1_pc): Likewise. (extended_mips16_next_pc): Likewise. (mips16_next_pc): Likewise. (deal_with_atomic_sequence): Likewise. * moxie-tdep.c (moxie_process_readu): Likewise. * nios2-tdep.c (nios2_get_next_pc): Likewise. * nto-procfs.c (procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers): Likewise. (ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (fetch_vsx_register): Likewise. (fetch_altivec_register): Likewise. (get_spe_registers): Likewise. (fetch_spe_register): Likewise. (fetch_altivec_registers): Likewise. (fetch_all_gp_regs): Likewise. (fetch_all_fp_regs): Likewise. (store_vsx_register): Likewise. (store_altivec_register): Likewise. (set_spe_registers): Likewise. (store_spe_register): Likewise. (store_altivec_registers): Likewise. (store_all_gp_regs): Likewise. (store_all_fp_regs): Likewise. * ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise. (ppc_linux_collect_gregset): Likewise. (ppc_canonicalize_syscall): Likewise. (ppc_linux_record_signal): Likewise. (ppu2spu_prev_register): Likewise. * ppc-nbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * ppc-ravenscar-thread.c (ppc_ravenscar_generic_fetch_registers): Likewise. (ppc_ravenscar_generic_store_registers): Likewise. * procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers): Likewise. (ravenscar_store_registers): Likewise. (ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers): Likewise. * record-full.c (record_full_wait_1): Likewise. (record_full_registers_change): Likewise. (record_full_store_registers): Likewise. (record_full_core_fetch_registers): Likewise. (record_full_save): Likewise. (record_full_goto_insn): Likewise. * regcache.c (regcache_register_size): Likewise. (get_regcache_arch): Remove. (regcache_read_pc): Likewise. * regcache.h (get_regcache_arch): Remove. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * remote.c (fetch_register_using_p): Likewise. (send_g_packet): Likewise. (remote_prepare_to_store): Likewise. (store_registers_using_G): Likewise. * reverse.c (save_bookmark_command): Likewise. (goto_bookmark_command): Likewise. * rs6000-aix-tdep.c (branch_dest): Likewise. * rs6000-nat.c (rs6000_ptrace64): Likewise. (fetch_register): Likewise. * rs6000-tdep.c (ppc_supply_reg): Likewise. (ppc_collect_reg): Likewise. (ppc_collect_gregset): Likewise. (ppc_collect_fpregset): Likewise. (ppc_collect_vsxregset): Likewise. (ppc_collect_vrregset): Likewise. (ppc_displaced_step_hw_singlestep): Likewise. (rs6000_pseudo_register_read): Likewise. (rs6000_pseudo_register_write): Likewise. * s390-linux-nat.c (supply_gregset): Likewise. (fill_gregset): Likewise. (s390_linux_fetch_inferior_registers): Likewise. * s390-linux-tdep.c (s390_write_pc): Likewise. (s390_software_single_step): Likewise. (s390_all_but_pc_registers_record): Likewise. (s390_linux_syscall_record): Likewise. * sentinel-frame.c (sentinel_frame_prev_arch): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sh-tdep.c (sh_extract_return_value_nofpu): Likewise. (sh_extract_return_value_fpu): Likewise. (sh_store_return_value_nofpu): Likewise. (sh_corefile_supply_regset): Likewise. (sh_corefile_collect_regset): Likewise. * sh64-tdep.c (sh64_extract_return_value): Likewise. (sh64_store_return_value): Likewise. * sparc-linux-tdep.c (sparc32_linux_collect_core_fpregset): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers): Likewise. (sparc_store_inferior_registers): Likewise. * sparc-ravenscar-thread.c (register_in_thread_descriptor_p): Likewise. (sparc_ravenscar_prepare_to_store): Likewise. * sparc-tdep.c (sparc32_store_arguments): Likewise. (sparc_analyze_control_transfer): Likewise. (sparc_step_trap): Likewise. (sparc_software_single_step): Likewise. (sparc32_gdbarch_init): Likewise. (sparc_supply_rwindow): Likewise. (sparc_collect_rwindow): Likewise. * sparc64-linux-tdep.c (sparc64_linux_collect_core_fpregset): Likewise. * sparc64-nbsd-nat.c (sparc64nbsd_supply_gregset): Likewise. (sparc64nbsd_collect_gregset): Likewise. (sparc64nbsd_supply_fpregset): Likewise. (sparc64nbsd_collect_fpregset): Likewise. * sparc64-tdep.c (sparc64_store_arguments): Likewise. (sparc64_supply_gregset): Likewise. (sparc64_collect_gregset): Likewise. (sparc64_supply_fpregset): Likewise. (sparc64_collect_fpregset): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. * spu-tdep.c (spu_unwind_sp): Likewise. (spu2ppu_prev_register): Likewise. (spu_memory_remove_breakpoint): Likewise. * stack.c (return_command): Likewise. * tic6x-tdep.c (tic6x_extract_signed_field): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (trace_save_ctf): Likewise. * windows-nat.c (do_windows_fetch_inferior_registers): Likewise. (do_windows_store_inferior_registers): Likewise. (windows_resume): Likewise. * xtensa-linux-nat.c (fill_gregset): Likewise. (supply_gregset_reg): Likewise. * xtensa-tdep.c (xtensa_register_write_masked): Likewise. (xtensa_register_read_masked): Likewise. (xtensa_supply_gregset): Likewise. (xtensa_extract_return_value): Likewise. (xtensa_store_return_value): Likewise.
2017-10-25 17:37:03 +02:00
struct gdbarch *gdbarch = regcache->arch ();
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
C++-ify ravenscar_arch_ops This turns ravenscar_arch_ops into an abstract base class and updates all the places where it is used. This is an improvement because it avoids any possibility of forgetting to set one of the function pointers. It also makes clear that these functions aren't intended to be changed dynamically. This version of the patch removes the prepare_to_store method, as it is unused, and it is easy enough to add if it is ever needed. gdb/ChangeLog 2019-02-15 Tom Tromey <tromey@adacore.com> * sparc-ravenscar-thread.c (struct sparc_ravenscar_ops): Derive from ravenscar_arch_ops. (sparc_ravenscar_ops::fetch_registers) (sparc_ravenscar_ops::store_registers): Now methods. (sparc_ravenscar_prepare_to_store): Remove. (sparc_ravenscar_ops): Redefine. * ravenscar-thread.h (struct ravenscar_arch_ops): Add virtual methods and destructor. Remove members. * ravenscar-thread.c (ravenscar_thread_target::fetch_registers) (ravenscar_thread_target::store_registers) (ravenscar_thread_target::prepare_to_store): Update. * ppc-ravenscar-thread.c (ppc_ravenscar_generic_prepare_to_store): Remove. (struct ppc_ravenscar_powerpc_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_powerpc_ops::fetch_registers) (ppc_ravenscar_powerpc_ops::store_registers): Now methods. (ppc_ravenscar_powerpc_ops): Redefine. (struct ppc_ravenscar_e500_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_e500_ops::fetch_registers) (ppc_ravenscar_e500_ops::store_registers): Now methods. (ppc_ravenscar_e500_ops): Redefine. * aarch64-ravenscar-thread.c (aarch64_ravenscar_generic_prepare_to_store): Remove. (struct aarch64_ravenscar_ops): Derive from ravenscar_arch_ops. (aarch64_ravenscar_fetch_registers) (aarch64_ravenscar_store_registers): Now methods. (aarch64_ravenscar_ops): Redefine.
2019-02-05 11:08:02 +01:00
arch_ops->fetch_registers (regcache, regnum);
}
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
else
beneath ()->fetch_registers (regcache, regnum);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::store_registers (struct regcache *regcache,
int regnum)
{
ptid_t ptid = regcache->ptid ();
if (runtime_initialized ()
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
&& is_ravenscar_task (ptid)
&& !task_is_currently_active (ptid))
{
s/get_regcache_arch (regcache)/regcache->arch ()/g This patches removes get_regcache_arch, and use regache->arch () instead. The motivation of this change is that I am going to move some basic stuff into a base class of regcache. I don't need to update "client" code regcache->arch (). On the other hand, this patch shortens the code a little bit. gdb: 2017-10-25 Yao Qi <yao.qi@linaro.org> * aarch32-linux-nat.c (aarch32_gp_regcache_supply): Use regcache->arch () instead get_regcache_arch. * aarch64-fbsd-nat.c (aarch64_fbsd_fetch_inferior_registers): Likewise. (aarch64_fbsd_store_inferior_registers): Likewise. * aarch64-linux-nat.c (fetch_gregs_from_thread): Likewise. (store_gregs_to_thread): Likewise. (fetch_fpregs_from_thread): Likewise. (store_fpregs_to_thread): Likewise. * aarch64-tdep.c (aarch64_extract_return_value): Likewise. (aarch64_store_return_value): Likewise. (aarch64_software_single_step): Likewise. * aix-thread.c (aix_thread_wait): Likewise. (supply_reg32): Likewise. (supply_sprs64): Likewise. (supply_sprs32): Likewise. (fill_gprs64): Likewise. (fill_gprs32): Likewise. (fill_sprs64): Likewise. (fill_sprs32): Likewise. (store_regs_user_thread): Likewise. (store_regs_kernel_thread): Likewise. * alpha-bsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. (alphabsd_store_inferior_registers): Likewise. * alpha-tdep.c (alpha_extract_return_value): Likewise. (alpha_store_return_value): Likewise. (alpha_deal_with_atomic_sequence): Likewise. (alpha_next_pc): Likewise. (alpha_software_single_step): Likewise. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. (amd64bsd_store_inferior_registers): Likewise. * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. (amd64_linux_store_inferior_registers): Likewise. * amd64-nat.c (amd64_supply_native_gregset): Likewise. (amd64_collect_native_gregset): Likewise. * amd64-obsd-tdep.c (amd64obsd_supply_uthread): Likewise. (amd64obsd_collect_uthread): Likewise. * amd64-tdep.c (amd64_supply_fpregset): Likewise. (amd64_collect_fpregset): Likewise. (amd64_supply_fxsave): Likewise. (amd64_supply_xsave): Likewise. (amd64_collect_fxsave): Likewise. (amd64_collect_xsave): Likewise. * arc-tdep.c (arc_write_pc): Likewise. * arch-utils.c (default_skip_permanent_breakpoint): Likewise. * arm-fbsd-nat.c (arm_fbsd_fetch_inferior_registers): Likewise. (arm_fbsd_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_vfp_regs): Likewise. (store_vfp_regs): Likewise. (arm_linux_fetch_inferior_registers): Likewise. (arm_linux_store_inferior_registers): Likewise. * arm-linux-tdep.c (arm_linux_supply_gregset): Likewise. (arm_linux_sigreturn_next_pc): Likewise. (arm_linux_get_next_pcs_syscall_next_pc): Likewise. * arm-nbsd-nat.c (arm_supply_gregset): Likewise. (fetch_register): Likewise. (store_register): Likewise. * arm-tdep.c (arm_is_thumb): Likewise. (displaced_in_arm_mode): Likewise. (bx_write_pc): Likewise. (arm_get_next_pcs_addr_bits_remove): Likewise. (arm_software_single_step): Likewise. (arm_extract_return_value): Likewise. (arm_store_return_value): Likewise. (arm_write_pc): Likewise. * bfin-tdep.c (bfin_extract_return_value): Likewise. * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. (bsd_uthread_store_registers): Likewise. * core-regset.c (fetch_core_registers): Likewise. * corelow.c (get_core_registers): Likewise. * cris-tdep.c (cris_store_return_value): Likewise. (cris_extract_return_value): Likewise. (find_step_target): Likewise. (find_step_target): Likewise. (cris_software_single_step): Likewise. * ctf.c (ctf_fetch_registers): Likewise. * darwin-nat.c (cancel_breakpoint): Likewise. * fbsd-tdep.c (fbsd_collect_thread_registers): Likewise. * frv-tdep.c (frv_extract_return_value): Likewise. * ft32-tdep.c (ft32_store_return_value): Likewise. (ft32_extract_return_value): Likewise. * go32-nat.c (fetch_register): Likewise. (go32_fetch_registers): Likewise. (go32_store_registers): Likewise. (store_register): Likewise. * h8300-tdep.c (h8300_extract_return_value): Likewise. (h8300_store_return_value): Likewise. * hppa-linux-nat.c (fetch_register): Likewise. (store_register): Likewise. (hppa_linux_fetch_inferior_registers): Likewise. (hppa_linux_store_inferior_registers): Likewise. * i386-darwin-nat.c (i386_darwin_fetch_inferior_registers): Likewise. (i386_darwin_store_inferior_registers): Likewise. * i386-gnu-nat.c (gnu_fetch_registers): Likewise. (gnu_store_registers): Likewise. * i386-linux-nat.c (fetch_register): Likewise. (store_register): Likewise. (supply_gregset): Likewise. (fill_gregset): Likewise. (i386_linux_fetch_inferior_registers): Likewise. (i386_linux_store_inferior_registers): Likewise. (i386_linux_resume): Likewise. * i386-linux-tdep.c (i386_linux_get_syscall_number_from_regcache): Likewise. * i386-nto-tdep.c (i386nto_supply_gregset): Likewise. * i386-obsd-nat.c (i386obsd_supply_pcb): Likewise. * i386-obsd-tdep.c (i386obsd_supply_uthread): Likewise. (i386obsd_collect_uthread): Likewise. * i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise. (i386_supply_gregset): Likewise. (i386_collect_gregset): Likewise. (i386_supply_fpregset): Likewise. (i386_collect_fpregset): Likewise. (i386_mpx_bd_base): Likewise. * i386-v4-nat.c (supply_fpregset): Likewise. (fill_fpregset): Likewise. * i387-tdep.c (i387_supply_fsave): Likewise. (i387_collect_fsave): Likewise. (i387_supply_fxsave): Likewise. (i387_collect_fxsave): Likewise. (i387_supply_xsave): Likewise. (i387_collect_xsave): Likewise. * ia64-linux-nat.c (ia64_linux_fetch_registers): Likewise. (ia64_linux_store_registers): Likewise. * ia64-tdep.c (ia64_access_rse_reg): Likewise. (ia64_extract_return_value): Likewise. (ia64_store_return_value): Likewise. (find_func_descr): Likewise. * inf-child.c (inf_child_fetch_inferior_registers): Likewise. * inf-ptrace.c (inf_ptrace_fetch_registers): Likewise. (inf_ptrace_store_registers): Likewise. * infrun.c (use_displaced_stepping): Likewise. (displaced_step_prepare_throw): Likewise. (resume): Likewise. (proceed): Likewise. (do_target_wait): Likewise. (adjust_pc_after_break): Likewise. (handle_inferior_event_1): Likewise. (handle_signal_stop): Likewise. (save_infcall_suspend_state): Likewise. (restore_infcall_suspend_state): Likewise. * iq2000-tdep.c (iq2000_extract_return_value): Likewise. * jit.c (jit_frame_prev_register): Likewise. * linux-nat.c (save_stop_reason): Likewise. (linux_nat_wait_1): Likewise. (resume_stopped_resumed_lwps): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (record_linux_system_call): Likewise. * linux-tdep.c (linux_collect_thread_registers): Likewise. * lm32-tdep.c (lm32_extract_return_value): Likewise. (lm32_store_return_value): Likewise. * m32c-tdep.c (m32c_read_flg): Likewise. (m32c_pseudo_register_read): Likewise. (m32c_pseudo_register_write): Likewise. * m32r-linux-tdep.c (m32r_linux_supply_gregset): Likewise. (m32r_linux_collect_gregset): Likewise. * m32r-tdep.c (m32r_store_return_value): Likewise. (m32r_extract_return_value): Likewise. * m68k-bsd-nat.c (m68kbsd_supply_fpregset): Likewise. (m68kbsd_collect_fpregset): Likewise. * m68k-bsd-tdep.c (m68kbsd_supply_fpregset): Likewise. * m68k-linux-nat.c (fetch_register): Likewise. (old_fetch_inferior_registers): Likewise. (old_store_inferior_registers): Likewise. (store_regs): Likewise. * m68k-tdep.c (m68k_svr4_extract_return_value): Likewise. (m68k_svr4_store_return_value): Likewise. * m88k-tdep.c (m88k_store_arguments): Likewise. * mi/mi-main.c (mi_cmd_data_list_changed_registers): Likewise. (mi_cmd_data_write_register_values): Likewise. * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers): Likewise. (mips_fbsd_store_inferior_registers): Likewise. * mips-fbsd-tdep.c (mips_fbsd_supply_fpregs): Likewise. (mips_fbsd_supply_gregs): Likewise. (mips_fbsd_collect_fpregs): Likewise. (mips_fbsd_collect_gregs): Likewise. (mips_fbsd_supply_fpregset): Likewise. (mips_fbsd_collect_fpregset): Likewise. (mips_fbsd_supply_gregset): Likewise. (mips_fbsd_collect_gregset): Likewise. * mips-linux-nat.c (supply_gregset): Likewise. (fill_gregset): Likewise. (supply_fpregset): Likewise. (fill_fpregset): Likewise. * mips-linux-tdep.c (mips_supply_gregset): Likewise. (mips_fill_gregset): Likewise. (mips_supply_fpregset): Likewise. (mips_fill_fpregset): Likewise. (mips64_supply_gregset): Likewise. (micromips_linux_sigframe_validate): Likewise. * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_fetch_inferior_registers): Likewise. (mipsnbsd_store_inferior_registers): Likewise. * mips-nbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise. (mipsnbsd_supply_gregset): Likewise. (mipsnbsd_iterate_over_regset_sections): Likewise. (mipsnbsd_supply_reg): Likewise. (mipsnbsd_supply_fpreg): Likewise. * mips-tdep.c (mips_in_frame_stub): Likewise. (mips_dummy_id): Likewise. (is_octeon_bbit_op): Likewise. (micromips_bc1_pc): Likewise. (extended_mips16_next_pc): Likewise. (mips16_next_pc): Likewise. (deal_with_atomic_sequence): Likewise. * moxie-tdep.c (moxie_process_readu): Likewise. * nios2-tdep.c (nios2_get_next_pc): Likewise. * nto-procfs.c (procfs_store_registers): Likewise. * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers): Likewise. (ppcfbsd_store_inferior_registers): Likewise. * ppc-linux-nat.c (fetch_vsx_register): Likewise. (fetch_altivec_register): Likewise. (get_spe_registers): Likewise. (fetch_spe_register): Likewise. (fetch_altivec_registers): Likewise. (fetch_all_gp_regs): Likewise. (fetch_all_fp_regs): Likewise. (store_vsx_register): Likewise. (store_altivec_register): Likewise. (set_spe_registers): Likewise. (store_spe_register): Likewise. (store_altivec_registers): Likewise. (store_all_gp_regs): Likewise. (store_all_fp_regs): Likewise. * ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise. (ppc_linux_collect_gregset): Likewise. (ppc_canonicalize_syscall): Likewise. (ppc_linux_record_signal): Likewise. (ppu2spu_prev_register): Likewise. * ppc-nbsd-nat.c (ppcnbsd_supply_pcb): Likewise. * ppc-obsd-nat.c (ppcobsd_fetch_registers): Likewise. (ppcobsd_store_registers): Likewise. * ppc-ravenscar-thread.c (ppc_ravenscar_generic_fetch_registers): Likewise. (ppc_ravenscar_generic_store_registers): Likewise. * procfs.c (procfs_fetch_registers): Likewise. (procfs_store_registers): Likewise. * ravenscar-thread.c (ravenscar_fetch_registers): Likewise. (ravenscar_store_registers): Likewise. (ravenscar_prepare_to_store): Likewise. * record-btrace.c (record_btrace_fetch_registers): Likewise. * record-full.c (record_full_wait_1): Likewise. (record_full_registers_change): Likewise. (record_full_store_registers): Likewise. (record_full_core_fetch_registers): Likewise. (record_full_save): Likewise. (record_full_goto_insn): Likewise. * regcache.c (regcache_register_size): Likewise. (get_regcache_arch): Remove. (regcache_read_pc): Likewise. * regcache.h (get_regcache_arch): Remove. * remote-sim.c (gdbsim_fetch_register): Likewise. (gdbsim_store_register): Likewise. * remote.c (fetch_register_using_p): Likewise. (send_g_packet): Likewise. (remote_prepare_to_store): Likewise. (store_registers_using_G): Likewise. * reverse.c (save_bookmark_command): Likewise. (goto_bookmark_command): Likewise. * rs6000-aix-tdep.c (branch_dest): Likewise. * rs6000-nat.c (rs6000_ptrace64): Likewise. (fetch_register): Likewise. * rs6000-tdep.c (ppc_supply_reg): Likewise. (ppc_collect_reg): Likewise. (ppc_collect_gregset): Likewise. (ppc_collect_fpregset): Likewise. (ppc_collect_vsxregset): Likewise. (ppc_collect_vrregset): Likewise. (ppc_displaced_step_hw_singlestep): Likewise. (rs6000_pseudo_register_read): Likewise. (rs6000_pseudo_register_write): Likewise. * s390-linux-nat.c (supply_gregset): Likewise. (fill_gregset): Likewise. (s390_linux_fetch_inferior_registers): Likewise. * s390-linux-tdep.c (s390_write_pc): Likewise. (s390_software_single_step): Likewise. (s390_all_but_pc_registers_record): Likewise. (s390_linux_syscall_record): Likewise. * sentinel-frame.c (sentinel_frame_prev_arch): Likewise. * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. (shnbsd_store_inferior_registers): Likewise. * sh-tdep.c (sh_extract_return_value_nofpu): Likewise. (sh_extract_return_value_fpu): Likewise. (sh_store_return_value_nofpu): Likewise. (sh_corefile_supply_regset): Likewise. (sh_corefile_collect_regset): Likewise. * sh64-tdep.c (sh64_extract_return_value): Likewise. (sh64_store_return_value): Likewise. * sparc-linux-tdep.c (sparc32_linux_collect_core_fpregset): Likewise. * sparc-nat.c (sparc_fetch_inferior_registers): Likewise. (sparc_store_inferior_registers): Likewise. * sparc-ravenscar-thread.c (register_in_thread_descriptor_p): Likewise. (sparc_ravenscar_prepare_to_store): Likewise. * sparc-tdep.c (sparc32_store_arguments): Likewise. (sparc_analyze_control_transfer): Likewise. (sparc_step_trap): Likewise. (sparc_software_single_step): Likewise. (sparc32_gdbarch_init): Likewise. (sparc_supply_rwindow): Likewise. (sparc_collect_rwindow): Likewise. * sparc64-linux-tdep.c (sparc64_linux_collect_core_fpregset): Likewise. * sparc64-nbsd-nat.c (sparc64nbsd_supply_gregset): Likewise. (sparc64nbsd_collect_gregset): Likewise. (sparc64nbsd_supply_fpregset): Likewise. (sparc64nbsd_collect_fpregset): Likewise. * sparc64-tdep.c (sparc64_store_arguments): Likewise. (sparc64_supply_gregset): Likewise. (sparc64_collect_gregset): Likewise. (sparc64_supply_fpregset): Likewise. (sparc64_collect_fpregset): Likewise. * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. * spu-tdep.c (spu_unwind_sp): Likewise. (spu2ppu_prev_register): Likewise. (spu_memory_remove_breakpoint): Likewise. * stack.c (return_command): Likewise. * tic6x-tdep.c (tic6x_extract_signed_field): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (trace_save_ctf): Likewise. * windows-nat.c (do_windows_fetch_inferior_registers): Likewise. (do_windows_store_inferior_registers): Likewise. (windows_resume): Likewise. * xtensa-linux-nat.c (fill_gregset): Likewise. (supply_gregset_reg): Likewise. * xtensa-tdep.c (xtensa_register_write_masked): Likewise. (xtensa_register_read_masked): Likewise. (xtensa_supply_gregset): Likewise. (xtensa_extract_return_value): Likewise. (xtensa_store_return_value): Likewise.
2017-10-25 17:37:03 +02:00
struct gdbarch *gdbarch = regcache->arch ();
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
C++-ify ravenscar_arch_ops This turns ravenscar_arch_ops into an abstract base class and updates all the places where it is used. This is an improvement because it avoids any possibility of forgetting to set one of the function pointers. It also makes clear that these functions aren't intended to be changed dynamically. This version of the patch removes the prepare_to_store method, as it is unused, and it is easy enough to add if it is ever needed. gdb/ChangeLog 2019-02-15 Tom Tromey <tromey@adacore.com> * sparc-ravenscar-thread.c (struct sparc_ravenscar_ops): Derive from ravenscar_arch_ops. (sparc_ravenscar_ops::fetch_registers) (sparc_ravenscar_ops::store_registers): Now methods. (sparc_ravenscar_prepare_to_store): Remove. (sparc_ravenscar_ops): Redefine. * ravenscar-thread.h (struct ravenscar_arch_ops): Add virtual methods and destructor. Remove members. * ravenscar-thread.c (ravenscar_thread_target::fetch_registers) (ravenscar_thread_target::store_registers) (ravenscar_thread_target::prepare_to_store): Update. * ppc-ravenscar-thread.c (ppc_ravenscar_generic_prepare_to_store): Remove. (struct ppc_ravenscar_powerpc_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_powerpc_ops::fetch_registers) (ppc_ravenscar_powerpc_ops::store_registers): Now methods. (ppc_ravenscar_powerpc_ops): Redefine. (struct ppc_ravenscar_e500_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_e500_ops::fetch_registers) (ppc_ravenscar_e500_ops::store_registers): Now methods. (ppc_ravenscar_e500_ops): Redefine. * aarch64-ravenscar-thread.c (aarch64_ravenscar_generic_prepare_to_store): Remove. (struct aarch64_ravenscar_ops): Derive from ravenscar_arch_ops. (aarch64_ravenscar_fetch_registers) (aarch64_ravenscar_store_registers): Now methods. (aarch64_ravenscar_ops): Redefine.
2019-02-05 11:08:02 +01:00
arch_ops->store_registers (regcache, regnum);
}
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
else
beneath ()->store_registers (regcache, regnum);
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::prepare_to_store (struct regcache *regcache)
{
ptid_t ptid = regcache->ptid ();
if (runtime_initialized ()
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
&& is_ravenscar_task (ptid)
&& !task_is_currently_active (ptid))
{
C++-ify ravenscar_arch_ops This turns ravenscar_arch_ops into an abstract base class and updates all the places where it is used. This is an improvement because it avoids any possibility of forgetting to set one of the function pointers. It also makes clear that these functions aren't intended to be changed dynamically. This version of the patch removes the prepare_to_store method, as it is unused, and it is easy enough to add if it is ever needed. gdb/ChangeLog 2019-02-15 Tom Tromey <tromey@adacore.com> * sparc-ravenscar-thread.c (struct sparc_ravenscar_ops): Derive from ravenscar_arch_ops. (sparc_ravenscar_ops::fetch_registers) (sparc_ravenscar_ops::store_registers): Now methods. (sparc_ravenscar_prepare_to_store): Remove. (sparc_ravenscar_ops): Redefine. * ravenscar-thread.h (struct ravenscar_arch_ops): Add virtual methods and destructor. Remove members. * ravenscar-thread.c (ravenscar_thread_target::fetch_registers) (ravenscar_thread_target::store_registers) (ravenscar_thread_target::prepare_to_store): Update. * ppc-ravenscar-thread.c (ppc_ravenscar_generic_prepare_to_store): Remove. (struct ppc_ravenscar_powerpc_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_powerpc_ops::fetch_registers) (ppc_ravenscar_powerpc_ops::store_registers): Now methods. (ppc_ravenscar_powerpc_ops): Redefine. (struct ppc_ravenscar_e500_ops): Derive from ravenscar_arch_ops. (ppc_ravenscar_e500_ops::fetch_registers) (ppc_ravenscar_e500_ops::store_registers): Now methods. (ppc_ravenscar_e500_ops): Redefine. * aarch64-ravenscar-thread.c (aarch64_ravenscar_generic_prepare_to_store): Remove. (struct aarch64_ravenscar_ops): Derive from ravenscar_arch_ops. (aarch64_ravenscar_fetch_registers) (aarch64_ravenscar_store_registers): Now methods. (aarch64_ravenscar_ops): Redefine.
2019-02-05 11:08:02 +01:00
/* Nothing. */
}
Add multiple-CPU support in ravenscar-thread.c This patch reworks the ravenscar-thread layer to remove the assumption that the target only has 1 CPU. In particular, when connected to a QEMU target over the remote protocol, QEMU reports each CPU as one thread. This patch adapts the ravenscar-thread layer to this, and adds a large comment explaining the general design of this unit. gdb/ChangeLog: * ada-lang.h (ada_get_task_info_from_ptid): Add declaration. * ada-tasks.c (ada_get_task_info_from_ptid): New function. * ravenscar-thread.c: Add into comment. (base_magic_null_ptid): Delete. (base_ptid): Change documentation. (ravenscar_active_task): Renames ravenscar_running_thread. All callers updated throughout. (is_ravenscar_task, ravenscar_get_thread_base_cpu): New function. (ravenscar_task_is_currently_active): Likewise. (get_base_thread_from_ravenscar_task): Ditto. (ravenscar_update_inferior_ptid): Adjust to handle multiple CPUs. (ravenscar_runtime_initialized): Likewise. (get_running_thread_id): Add new parameter "cpu". Adjust implementation to handle this new parameter. (ravenscar_fetch_registers): Small adjustment to use is_ravenscar_task and ravenscar_task_is_currently_active in order to decide whether to use the target beneath or this module's arch_ops. (ravenscar_store_registers, ravenscar_prepare_to_store): Likewise. (ravenscar_stopped_by_sw_breakpoint): Use get_base_thread_from_ravenscar_task to get the underlying thread, rather than using base_ptid. (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): Likewise. (ravenscar_inferior_created): Do not set base_magic_null_ptid.
2017-11-21 23:00:30 +01:00
else
beneath ()->prepare_to_store (regcache);
}
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
/* Implement the to_stopped_by_sw_breakpoint target_ops "method". */
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::stopped_by_sw_breakpoint ()
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
{
scoped_restore save_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid);
return beneath ()->stopped_by_sw_breakpoint ();
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
}
/* Implement the to_stopped_by_hw_breakpoint target_ops "method". */
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::stopped_by_hw_breakpoint ()
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
{
scoped_restore save_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid);
return beneath ()->stopped_by_hw_breakpoint ();
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
}
/* Implement the to_stopped_by_watchpoint target_ops "method". */
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::stopped_by_watchpoint ()
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
{
scoped_restore save_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid);
return beneath ()->stopped_by_watchpoint ();
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
}
/* Implement the to_stopped_data_address target_ops "method". */
target_ops: Use bool throughout After the previous target_ops/C++ patches are all squashed and merged, this one can go in separately. This patch adjusts all the target methods to return bool instead of int when they're returning a boolean. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * target.h (target_ops) <stopped_by_sw_breakpoint, supports_stopped_by_sw_breakpoint, stopped_by_hw_breakpoint, supports_stopped_by_hw_breakpoint, stopped_by_watchpoint, have_continuable_watchpoint, stopped_data_address, watchpoint_addr_within_range, can_accel_watchpoint_condition, can_run, thread_alive, has_all_memory, has_memory, has_stack, has_registers, has_execution, can_async_p, is_async_p, supports_non_stop, always_non_stop_p, can_execute_reverse, supports_multi_process, supports_enable_disable_tracepoint, supports_disable_randomization, supports_string_tracing, supports_evaluation_of_breakpoint_conditions, can_run_breakpoint_commands, filesystem_is_local, can_download_tracepoint, get_trace_state_variable_value, set_trace_notes, get_tib_address, use_agent, can_use_agent, record_is_replaying, record_will_replay, augmented_libraries_svr4_read>: Adjust to return bool. * aarch64-linux-nat.c: All implementations adjusted. * aix-thread.c: All implementations adjusted. * arm-linux-nat.c: All implementations adjusted. * breakpoint.c: All implementations adjusted. * bsd-kvm.c: All implementations adjusted. * bsd-uthread.c: All implementations adjusted. * corelow.c: All implementations adjusted. * ctf.c: All implementations adjusted. * darwin-nat.c: All implementations adjusted. * darwin-nat.h: All implementations adjusted. * exec.c: All implementations adjusted. * fbsd-nat.c: All implementations adjusted. * fbsd-nat.h: All implementations adjusted. * gnu-nat.c: All implementations adjusted. * gnu-nat.h: All implementations adjusted. * go32-nat.c: All implementations adjusted. * ia64-linux-nat.c: All implementations adjusted. * inf-child.c: All implementations adjusted. * inf-child.h: All implementations adjusted. * inf-ptrace.c: All implementations adjusted. * inf-ptrace.h: All implementations adjusted. * linux-nat.c: All implementations adjusted. * linux-nat.h: All implementations adjusted. * mips-linux-nat.c: All implementations adjusted. * nto-procfs.c: All implementations adjusted. * ppc-linux-nat.c: All implementations adjusted. * procfs.c: All implementations adjusted. * ravenscar-thread.c: All implementations adjusted. * record-btrace.c: All implementations adjusted. * record-full.c: All implementations adjusted. * remote-sim.c: All implementations adjusted. * remote.c: All implementations adjusted. * s390-linux-nat.c: All implementations adjusted. * sol-thread.c: All implementations adjusted. * spu-multiarch.c: All implementations adjusted. * target-delegates.c: All implementations adjusted. * target.c: All implementations adjusted. * target.h: All implementations adjusted. * tracefile-tfile.c: All implementations adjusted. * tracefile.c: All implementations adjusted. * tracefile.h: All implementations adjusted. * windows-nat.c: All implementations adjusted. * x86-linux-nat.h: All implementations adjusted. * x86-nat.h: All implementations adjusted.
2018-05-03 01:37:26 +02:00
bool
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ravenscar_thread_target::stopped_data_address (CORE_ADDR *addr_p)
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
{
scoped_restore save_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid);
return beneath ()->stopped_data_address (addr_p);
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
void
ravenscar_thread_target::mourn_inferior ()
{
m_base_ptid = null_ptid;
target_ops *beneath = this->beneath ();
unpush_target (this);
beneath->mourn_inferior ();
}
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
/* Implement the to_core_of_thread target_ops "method". */
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
int
ravenscar_thread_target::core_of_thread (ptid_t ptid)
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
{
scoped_restore save_ptid = make_scoped_restore (&inferior_ptid);
inferior_ptid = get_base_thread_from_ravenscar_task (inferior_ptid);
return beneath ()->core_of_thread (inferior_ptid);
watchpoint regression debugging with remote protocol (bare metal) We have noticed a regression in our watchpoint support when debugging through the remote protocol a program running on a bare metal platform, when the program uses what we call the Ravenscar Runtime. This runtime is a subset of the Ada runtime defined by the Ravenscar Profile. One of the nice things about this runtime is that it provides tasking, which is equivalent to the concept of threads in C (it is actually often mapped to threads, when available). For bare metal targets, however, there is no OS, and therefore no thread layer. What we did, then, was add a ravenscar-thread layer, which has insider knowledge of the runtime to get the list of threads, but also all necessary info to perform thread switching. For the record, the commit which caused the regression is: commit 799a2abe613be0645b84f5aaa050f2f91e6ae3f7 Date: Mon Nov 30 16:05:16 2015 +0000 Subject: remote: stop reason and watchpoint data address per thread Running local-watch-wrong-thread.exp with "maint set target-non-stop on" exposes that gdb/remote.c only records whether the target stopped for a breakpoint/watchpoint plus the watchpoint data address *for the last reported remote event*. But in non-stop mode, we need to keep that info per-thread, as each thread can end up with its own last-status pending. Our testcase is very simple. We have a package defining a global variable named "Watch"... package Pck is Watch : Integer := 1974; end Pck; ... and a main subprogram which changes its value procedure Foo is begin Pck.Watch := Pck.Watch + 1; end Foo; To reproduce, we built our program as usual, started it in QEMU, and then connected GDB to QEMU... (gdb) target remote :4444 (gdb) break _ada_foo (gdb) cont <--- this is to make sure the program is started and the variable we want to watch is initialized ... at which point we try to use a watchpoint on our global variable: (gdb) watch watch ... but, upon resuming the execution with a "cont", we expected to get a watchpoint-hit notification, such as... (gdb) cont Hardware watchpoint 2: watch Old value = 1974 New value = 1975 0xfff00258 in foo () at /[...]/foo.adb:6 6 end Foo; ... but unfortunately, we get a SIGTRAP instead: (gdb) cont Program received signal SIGTRAP, Trace/breakpoint trap. foo () at /[...]/foo.adb:6 6 end Foo; What happens is that, on the one hand, the change in remote.c now stores the watchpoint-hit notification info in the thread that received it; and on the other hand, we have a ravenscar-thread layer which manages the thread list on top of the remote protocol layer. The two of them get disconnected, and this eventually results in GDB not realizing that we hit a watchpoint. Below is how: First, once connected and just before inserting our watchpoint, we have the ravenscar-thread layer which built the list of threads by extracting some info from inferior memory, giving us the following two threads: (gdb) info threads Id Target Id Frame 1 Thread 0 "0Q@" (Ravenscar task) foo () at /[...]/foo.adb:5 * 2 Thread 0x24618 (Ravenscar task) foo () at /[...]/foo.adb:5 The first thread is the only thread QEMU told GDB about. The second one is a thread that the ravenscar-thread added. QEMU has now way to know about those threads, since they are really embedded inside the program; that's why we have the ravenscar layer, which uses inside-knowledge to extract the list of threads. Next, we insert a watchpoint, which applies to all threads. No problem so far. Then, we continue; meaning that GDB sends a Z2 packet to QEMU to get the watchpoint inserted, then a vCont to resume the program's execution. The program hits the watchpoints, and thererfore QEMU reports it back: Packet received: T05thread:01;watch:000022c4; Since QEMU knows about one thread and one thread only, it stands to reason that it would say that the event applies to thread:01, which is our first thread in the "info threads" listing. That thread has a ptid of {42000, lwp=1, tid=0}. This is where Pedro's change kicks in: Seeing this event, and having determined that the event was reported for thread 01, and therefore ptid {42000, lwp=1, tid=0}, it saves the watchpoint-hit event info in the private area of that thread/ptid. Once this is done, remote.c's event-wait layer returns. Enter the ravenscar-thread layer of the event-wait, which does a little dance to delegate the wait to underlying layers with ptids that those layers know about, and then when the target_beneath's to_wait is done, tries to figure out which thread is now the active thread. The code looks like this: 1. inferior_ptid = base_ptid; 2. beneath->to_wait (beneath, base_ptid, status, 0); 3. [...] 4. ravenscar_update_inferior_ptid (); 5. 6. return inferior_ptid; Line 1 is where we reset inferior_ptid to the ptid that the target_beneath layer knows about, allowing us to then call its to_wait implementation (line 2). And then, upon return, we call ravenscar_update_inferior_ptid, which reads inferior memory to determine which thread is actually active, setting inferior_ptid accordingly. Then we return that inferior_ptid (which, again, neither QEMU and therefore nor the remote.c layer knows about). Upon return, we eventually arrive to the part where we try to handle the inferior event: we discover that we got a SIGTRAP and, as part of its handling, we call watchpoints_triggered, which calls target_stopped_by_watchpoint, which eventually remote_stopped_by_watchpoint, where Pedro's change kicks in again: struct thread_info *thread = inferior_thread (); return (thread->priv != NULL && thread->priv->stop_reason == TARGET_STOPPED_BY_WATCHPOINT); Because the ravenscar-thread layer changed the inferior_ptid to the ptid of the active thread, inferior_thread now returns the private data of that thread. This is not the thread that QEMU reported the watchpoint-hit on, and thus, the function returns "no watchpoint hit, mister". Hence GDB not understanding the SIGTRAP, thus reporting it verbatim. The way we chose to fix the issue is by making sure that the ravenscar-thread layer doesn't let the remote layer be called with inferior_ptid being set to a thread that the remote layer does not know about. gdb/ChangeLog: * ravenscar-thread.c (ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint, ravenscar_stopped_by_watchpoint) (ravenscar_stopped_data_address, ravenscar_core_of_thread): New functions. (init_ravenscar_thread_ops): Set the to_stopped_by_sw_breakpoint, to_stopped_by_hw_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address and to_core_of_thread fields of ravenscar_ops.
2017-11-21 22:42:48 +01:00
}
/* Observer on inferior_created: push ravenscar thread stratum if needed. */
static void
ravenscar_inferior_created (struct target_ops *target, int from_tty)
{
problem debugging ravenscar programs if runtime is stripped Trying to debug a program using a stripped version of the ravenscar runtime, we can get the following error: (gdb) cont Continuing. Cannot find Ada_Task_Control_Block type. Aborting This is because the ravenscar-thread layer makes the assumption that the runtime is built the way we expect it, meaning that the Ada tasking units we rely on for Ada tasking debugging, are built with debugging information, and that this debug information has not been stripped from the runtime. When this assumption is not true, resuming such a program can trigger the error above, which then leads GDB a little confused. For instance, we can see things like: (gdb) bt Target is executing. This patch fixes the issue by disabling the ravenscar thread layer if we detect that the runtime is missing some of the debugging info we need in order to support Ada task debugging. This is the best we can do, as the ravenscar-thread layer actually depends on the ada-tasks layer to implement thread debugging. gdb/ChangeLog: * ada-lang.h (ada_get_tcb_types_info): Add declaration. * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info. Make non-static. Change return type to char *. Adjust code accordingly. Rewrite the function's documentation. (read_atcb): Adjust call to get_tcb_types_info accordingly. * ravenscar-thread.c (ravenscar_inferior_created): Check that we have enough debugging information in the runtime to support Ada task debugging before we enable the ravenscar-thread layer.
2017-11-21 23:03:06 +01:00
const char *err_msg;
if (!ravenscar_task_support
|| gdbarch_ravenscar_ops (target_gdbarch ()) == NULL
|| !has_ravenscar_runtime ())
return;
problem debugging ravenscar programs if runtime is stripped Trying to debug a program using a stripped version of the ravenscar runtime, we can get the following error: (gdb) cont Continuing. Cannot find Ada_Task_Control_Block type. Aborting This is because the ravenscar-thread layer makes the assumption that the runtime is built the way we expect it, meaning that the Ada tasking units we rely on for Ada tasking debugging, are built with debugging information, and that this debug information has not been stripped from the runtime. When this assumption is not true, resuming such a program can trigger the error above, which then leads GDB a little confused. For instance, we can see things like: (gdb) bt Target is executing. This patch fixes the issue by disabling the ravenscar thread layer if we detect that the runtime is missing some of the debugging info we need in order to support Ada task debugging. This is the best we can do, as the ravenscar-thread layer actually depends on the ada-tasks layer to implement thread debugging. gdb/ChangeLog: * ada-lang.h (ada_get_tcb_types_info): Add declaration. * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info. Make non-static. Change return type to char *. Adjust code accordingly. Rewrite the function's documentation. (read_atcb): Adjust call to get_tcb_types_info accordingly. * ravenscar-thread.c (ravenscar_inferior_created): Check that we have enough debugging information in the runtime to support Ada task debugging before we enable the ravenscar-thread layer.
2017-11-21 23:03:06 +01:00
err_msg = ada_get_tcb_types_info ();
if (err_msg != NULL)
{
warning (_("%s. Task/thread support disabled."), err_msg);
problem debugging ravenscar programs if runtime is stripped Trying to debug a program using a stripped version of the ravenscar runtime, we can get the following error: (gdb) cont Continuing. Cannot find Ada_Task_Control_Block type. Aborting This is because the ravenscar-thread layer makes the assumption that the runtime is built the way we expect it, meaning that the Ada tasking units we rely on for Ada tasking debugging, are built with debugging information, and that this debug information has not been stripped from the runtime. When this assumption is not true, resuming such a program can trigger the error above, which then leads GDB a little confused. For instance, we can see things like: (gdb) bt Target is executing. This patch fixes the issue by disabling the ravenscar thread layer if we detect that the runtime is missing some of the debugging info we need in order to support Ada task debugging. This is the best we can do, as the ravenscar-thread layer actually depends on the ada-tasks layer to implement thread debugging. gdb/ChangeLog: * ada-lang.h (ada_get_tcb_types_info): Add declaration. * ada-tasks.c (ada_get_tcb_types_info): Renames get_tcb_types_info. Make non-static. Change return type to char *. Adjust code accordingly. Rewrite the function's documentation. (read_atcb): Adjust call to get_tcb_types_info accordingly. * ravenscar-thread.c (ravenscar_inferior_created): Check that we have enough debugging information in the runtime to support Ada task debugging before we enable the ravenscar-thread layer.
2017-11-21 23:03:06 +01:00
return;
}
target_ops_up target_holder (new ravenscar_thread_target ());
push_target (std::move (target_holder));
}
Convert struct target_ops to C++ I.e., use C++ virtual methods and inheritance instead of tables of function pointers. Unfortunately, there's no way to do a smooth transition. ALL native targets in the tree must be converted at the same time. I've tested all I could with cross compilers and with help from GCC compile farm, but naturally I haven't been able to test many of the ports. Still, I made a best effort to port everything over, and while I expect some build problems due to typos and such, which should be trivial to fix, I don't expect any design problems. * Implementation notes: - The flattened current_target is gone. References to current_target or current_target.beneath are replaced with references to target_stack (the top of the stack) directly. - To keep "set debug target" working, this adds a new debug_stratum layer that sits on top of the stack, prints the debug, and delegates to the target beneath. In addition, this makes the shortname and longname properties of target_ops be virtual methods instead of data fields, and makes the debug target defer those to the target beneath. This is so that debug code sprinkled around that does "if (debugtarget) ..." can transparently print the name of the target beneath. A patch later in the series actually splits out the shortname/longname methods to a separate structure, but I preferred to keep that chance separate as it is associated with changing a bit the design of how targets are registered and open. - Since you can't check whether a C++ virtual method is overridden, the old method of checking whether a target_ops implements a method by comparing the function pointer must be replaced with something else. Some cases are fixed by adding a parallel "can_do_foo" target_ops methods. E.g.,: + for (t = target_stack; t != NULL; t = t->beneath) { - if (t->to_create_inferior != NULL) + if (t->can_create_inferior ()) break; } Others are fixed by changing void return type to bool or int return type, and have the default implementation return false or -1, to indicate lack of support. - make-target-delegates was adjusted to generate C++ classes and methods. It needed tweaks to grok "virtual" in front of the target method name, and for the fact that methods are no longer function pointers. (In particular, the current code parsing the return type was simple because it could simply parse up until the '(' in '(*to_foo)'. It now generates a couple C++ classes that inherit target_ops: dummy_target and debug_target. Since we need to generate the class declarations as well, i.e., we need to emit methods twice, we now generate the code in two passes. - The core_target global is renamed to avoid conflict with the "core_target" class. - ctf/tfile targets init_tracefile_ops is replaced by a base class that is inherited by both ctf and tfile. - bsd-uthread The bsd_uthread_ops_hack hack is gone. It's not needed because nothing was extending a target created by bsd_uthread_target. - remote/extended-remote targets This is a first pass, just enough to C++ify target_ops. A later pass will convert more free functions to methods, and make remote_state be truly per remote instance, allowing multiple simultaneous instances of remote targets. - inf-child/"native" is converted to an actual base class (inf_child_target), that is inherited by all native targets. - GNU/Linux The old weird double-target linux_ops mechanism in linux-nat.c, is gone, replaced by adding a few virtual methods to linux-nat.h's target_ops, called low_XXX, that the concrete linux-nat implementations override. Sort of like gdbserver's linux_target_ops, but simpler, for requiring only one target_ops-like hierarchy, which spares implementing the same method twice when we need to forward the method to a low implementation. The low target simply reimplements the target_ops method directly in that case. There are a few remaining linux-nat.c hooks that would be better converted to low_ methods like above too. E.g.: linux_nat_set_new_thread (t, x86_linux_new_thread); linux_nat_set_new_fork (t, x86_linux_new_fork); linux_nat_set_forget_process That'll be done in a follow up patch. - We can no longer use functions like x86_use_watchpoints to install custom methods on an arbitrary base target. The patch replaces instances of such a pattern with template mixins. For example memory_breakpoint_target defined in target.h, or x86_nat_target in x86-nat.h. - linux_trad_target, MIPS and Alpha GNU/Linux The code in the new linux-nat-trad.h/c files which was split off of inf-ptrace.h/c recently, is converted to a C++ base class, and used by the MIPS and Alpha GNU/Linux ports. - BSD targets The $architecture x NetBSD/OpenBSD/FreeBSD support matrix complicates things a bit. There's common BSD target code, and there's common architecture-specific code shared between the different BSDs. Currently, all that is stiched together to form a final target, via the i386bsd_target, x86bsd_target, fbsd_nat_add_target functions etc. This introduces new fbsd_nat_target, obsd_nat_target and nbsd_nat_target classes that serve as base/prototype target for the corresponding BSD variant. And introduces generic i386/AMD64 BSD targets, to be used as template mixin to build a final target. Similarly, a generic SPARC target is added, used by both BSD and Linux ports. - bsd_kvm_add_target, BSD libkvm target I considered making bsd_kvm_supply_pcb a virtual method, and then have each port inherit bsd_kvm_target and override that method, but that was resulting in lots of unjustified churn, so I left the function pointer mechanism alone. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> John Baldwin <jhb@freebsd.org> * target.h (enum strata) <debug_stratum>: New. (struct target_ops) <all delegation methods>: Replace by C++ virtual methods, and drop "to_" prefix. All references updated throughout. <to_shortname, to_longname, to_doc, to_data, to_have_steppable_watchpoint, to_have_continuable_watchpoint, to_has_thread_control, to_attach_no_wait>: Delete, replaced by virtual methods. All references updated throughout. <can_attach, supports_terminal_ours, can_create_inferior, get_thread_control_capabilities, attach_no_wait>: New virtual methods. <insert_breakpoint, remove_breakpoint>: Now TARGET_DEFAULT_NORETURN methods. <info_proc>: Now returns bool. <to_magic>: Delete. (OPS_MAGIC): Delete. (current_target): Delete. All references replaced by references to ... (target_stack): ... this. New. (target_shortname, target_longname): Adjust. (target_can_run): Now a function declaration. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (memory_breakpoint_target): New template class. (test_target_ops): Refactor as a C++ class with virtual methods. * make-target-delegates (NAME_PART): Tighten. (POINTER_PART, CP_SYMBOL): New. (SIMPLE_RETURN_PART): Reimplement. (VEC_RETURN_PART): Expect less. (RETURN_PART, VIRTUAL_PART): New. (METHOD): Adjust to C++ virtual methods. (scan_target_h): Remove reference to C99. (dname): Output "target_ops::" prefix. (write_function_header): Adjust to output a C++ class method. (write_declaration): New. (write_delegator): Adjust to output a C++ class method. (tdname): Output "dummy_target::" prefix. (write_tdefault, write_debugmethod): Adjust to output a C++ class method. (tdefault_names, debug_names): Delete. (return_types, tdefaults, styles, argtypes_array): New. (top level): All methods are delegators. (print_class): New. (top level): Print dummy_target and debug_target classes. * target-delegates.c: Regenerate. * target-debug.h (target_debug_print_enum_info_proc_what) (target_debug_print_thread_control_capabilities) (target_debug_print_thread_info_p): New. * target.c (dummy_target): Delete. (the_dummy_target, the_debug_target): New. (target_stack): Now extern. (set_targetdebug): Push/unpush debug target. (default_child_has_all_memory, default_child_has_memory) (default_child_has_stack, default_child_has_registers) (default_child_has_execution): Remove target_ops parameter. (complete_target_initialization): Delete. (add_target_with_completer): No longer call complete_target_initialization. (target_supports_terminal_ours): Use regular delegation. (update_current_target): Delete. (push_target): No longer check magic number. Don't call update_current_target. (unpush_target): Don't call update_current_target. (target_is_pushed): No longer check magic number. (target_require_runnable): Skip for all stratums over process_stratum. (target_ops::info_proc): New. (target_info_proc): Use find_target_at and find_default_run_target. (target_supports_disable_randomization): Use regular delegation. (target_get_osdata): Use find_target_at. (target_ops::open, target_ops::close, target_ops::can_attach) (target_ops::attach, target_ops::can_create_inferior) (target_ops::create_inferior, target_ops::can_run) (target_can_run): New. (default_fileio_target): Use regular delegation. (target_ops::fileio_open, target_ops::fileio_pwrite) (target_ops::fileio_pread, target_ops::fileio_fstat) (target_ops::fileio_close, target_ops::fileio_unlink) (target_ops::fileio_readlink): New. (target_fileio_open_1, target_fileio_unlink) (target_fileio_readlink): Always call the target method. Handle FILEIO_ENOSYS. (return_zero, return_zero_has_execution): Delete. (init_dummy_target): Delete. (dummy_target::dummy_target, dummy_target::shortname) (dummy_target::longname, dummy_target::doc) (debug_target::debug_target, debug_target::shortname) (debug_target::longname, debug_target::doc): New. (target_supports_delete_record): Use regular delegation. (setup_target_debug): Delete. (maintenance_print_target_stack): Skip debug_stratum. (initialize_targets): Instantiate the_dummy_target and the_debug_target. * auxv.c (target_auxv_parse): Remove 'ops' parameter. Adjust to use target_stack. (target_auxv_search, fprint_target_auxv): Adjust. (info_auxv_command): Adjust to use target_stack. * auxv.h (target_auxv_parse): Remove 'ops' parameter. * exceptions.c (print_flush): Handle a NULL target_stack. * regcache.c (target_ops_no_register): Refactor as class with virtual methods. * exec.c (exec_target): New class. (exec_ops): Now an exec_target. (exec_open, exec_close_1, exec_get_section_table) (exec_xfer_partial, exec_files_info, exec_has_memory) (exec_make_note_section): Refactor as exec_target methods. (exec_file_clear, ignore, exec_remove_breakpoint, init_exec_ops): Delete. (exec_target::find_memory_regions): New. (_initialize_exec): Don't call init_exec_ops. * gdbcore.h (exec_file_clear): Delete. * corefile.c (core_target): Delete. (core_file_command): Adjust. * corelow.c (core_target): New class. (the_core_target): New. (core_close): Remove target_ops parameter. (core_close_cleanup): Adjust. (core_target::close): New. (core_open, core_detach, get_core_registers, core_files_info) (core_xfer_partial, core_thread_alive, core_read_description) (core_pid_to_str, core_thread_name, core_has_memory) (core_has_stack, core_has_registers, core_info_proc): Rework as core_target methods. (ignore, core_remove_breakpoint, init_core_ops): Delete. (_initialize_corelow): Initialize the_core_target. * gdbcore.h (core_target): Delete. (the_core_target): New. * ctf.c: (ctf_target): New class. (ctf_ops): Now a ctf_target. (ctf_open, ctf_close, ctf_files_info, ctf_fetch_registers) (ctf_xfer_partial, ctf_get_trace_state_variable_value) (ctf_trace_find, ctf_traceframe_info): Refactor as ctf_target methods. (init_ctf_ops): Delete. (_initialize_ctf): Don't call it. * tracefile-tfile.c (tfile_target): New class. (tfile_ops): Now a tfile_target. (tfile_open, tfile_close, tfile_files_info) (tfile_get_tracepoint_status, tfile_trace_find) (tfile_fetch_registers, tfile_xfer_partial) (tfile_get_trace_state_variable_value, tfile_traceframe_info): Refactor as tfile_target methods. (tfile_xfer_partial_features): Remove target_ops parameter. (init_tfile_ops): Delete. (_initialize_tracefile_tfile): Don't call it. * tracefile.c (tracefile_has_all_memory, tracefile_has_memory) (tracefile_has_stack, tracefile_has_registers) (tracefile_thread_alive, tracefile_get_trace_status): Refactor as tracefile_target methods. (init_tracefile_ops): Delete. (tracefile_target::tracefile_target): New. * tracefile.h: Include "target.h". (tracefile_target): New class. (init_tracefile_ops): Delete. * spu-multiarch.c (spu_multiarch_target): New class. (spu_ops): Now a spu_multiarch_target. (spu_thread_architecture, spu_region_ok_for_hw_watchpoint) (spu_fetch_registers, spu_store_registers, spu_xfer_partial) (spu_search_memory, spu_mourn_inferior): Refactor as spu_multiarch_target methods. (init_spu_ops): Delete. (_initialize_spu_multiarch): Remove references to init_spu_ops, complete_target_initialization. * ravenscar-thread.c (ravenscar_thread_target): New class. (ravenscar_ops): Now a ravenscar_thread_target. (ravenscar_resume, ravenscar_wait, ravenscar_update_thread_list) (ravenscar_thread_alive, ravenscar_pid_to_str) (ravenscar_fetch_registers, ravenscar_store_registers) (ravenscar_prepare_to_store, ravenscar_stopped_by_sw_breakpoint) (ravenscar_stopped_by_hw_breakpoint) (ravenscar_stopped_by_watchpoint, ravenscar_stopped_data_address) (ravenscar_mourn_inferior, ravenscar_core_of_thread) (ravenscar_get_ada_task_ptid): Refactor as ravenscar_thread_target methods. (init_ravenscar_thread_ops): Delete. (_initialize_ravenscar): Remove references to init_ravenscar_thread_ops and complete_target_initialization. * bsd-uthread.c (bsd_uthread_ops_hack): Delete. (bsd_uthread_target): New class. (bsd_uthread_ops): Now a bsd_uthread_target. (bsd_uthread_activate): Adjust to refer to bsd_uthread_ops. (bsd_uthread_close, bsd_uthread_mourn_inferior) (bsd_uthread_fetch_registers, bsd_uthread_store_registers) (bsd_uthread_wait, bsd_uthread_resume, bsd_uthread_thread_alive) (bsd_uthread_update_thread_list, bsd_uthread_extra_thread_info) (bsd_uthread_pid_to_str): Refactor as bsd_uthread_target methods. (bsd_uthread_target): Delete function. (_initialize_bsd_uthread): Remove reference to complete_target_initialization. * bfd-target.c (target_bfd_data): Delete. Fields folded into ... (target_bfd): ... this new class. (target_bfd_xfer_partial, target_bfd_get_section_table) (target_bfd_close): Refactor as target_bfd methods. (target_bfd::~target_bfd): New. (target_bfd_reopen): Adjust. (target_bfd::close): New. * record-btrace.c (record_btrace_target): New class. (record_btrace_ops): Now a record_btrace_target. (record_btrace_open, record_btrace_stop_recording) (record_btrace_disconnect, record_btrace_close) (record_btrace_async, record_btrace_info) (record_btrace_insn_history, record_btrace_insn_history_range) (record_btrace_insn_history_from, record_btrace_call_history) (record_btrace_call_history_range) (record_btrace_call_history_from, record_btrace_record_method) (record_btrace_is_replaying, record_btrace_will_replay) (record_btrace_xfer_partial, record_btrace_insert_breakpoint) (record_btrace_remove_breakpoint, record_btrace_fetch_registers) (record_btrace_store_registers, record_btrace_prepare_to_store) (record_btrace_to_get_unwinder) (record_btrace_to_get_tailcall_unwinder, record_btrace_resume) (record_btrace_commit_resume, record_btrace_wait) (record_btrace_stop, record_btrace_can_execute_reverse) (record_btrace_stopped_by_sw_breakpoint) (record_btrace_supports_stopped_by_sw_breakpoint) (record_btrace_stopped_by_hw_breakpoint) (record_btrace_supports_stopped_by_hw_breakpoint) (record_btrace_update_thread_list, record_btrace_thread_alive) (record_btrace_goto_begin, record_btrace_goto_end) (record_btrace_goto, record_btrace_stop_replaying_all) (record_btrace_execution_direction) (record_btrace_prepare_to_generate_core) (record_btrace_done_generating_core): Refactor as record_btrace_target methods. (init_record_btrace_ops): Delete. (_initialize_record_btrace): Remove reference to init_record_btrace_ops. * record-full.c (RECORD_FULL_IS_REPLAY): Adjust to always refer to the execution_direction global. (record_full_base_target, record_full_target) (record_full_core_target): New classes. (record_full_ops): Now a record_full_target. (record_full_core_ops): Now a record_full_core_target. (record_full_target::detach, record_full_target::disconnect) (record_full_core_target::disconnect) (record_full_target::mourn_inferior, record_full_target::kill): New. (record_full_open, record_full_close, record_full_async): Refactor as methods of the record_full_base_target class. (record_full_resume, record_full_commit_resume): Refactor as methods of the record_full_target class. (record_full_wait, record_full_stopped_by_watchpoint) (record_full_stopped_data_address) (record_full_stopped_by_sw_breakpoint) (record_full_supports_stopped_by_sw_breakpoint) (record_full_stopped_by_hw_breakpoint) (record_full_supports_stopped_by_hw_breakpoint): Refactor as methods of the record_full_base_target class. (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint): Refactor as methods of the record_full_target class. (record_full_can_execute_reverse, record_full_get_bookmark) (record_full_goto_bookmark, record_full_execution_direction) (record_full_record_method, record_full_info, record_full_delete) (record_full_is_replaying, record_full_will_replay) (record_full_goto_begin, record_full_goto_end, record_full_goto) (record_full_stop_replaying): Refactor as methods of the record_full_base_target class. (record_full_core_resume, record_full_core_kill) (record_full_core_fetch_registers) (record_full_core_prepare_to_store) (record_full_core_store_registers, record_full_core_xfer_partial) (record_full_core_insert_breakpoint) (record_full_core_remove_breakpoint) (record_full_core_has_execution): Refactor as methods of the record_full_core_target class. (record_full_base_target::supports_delete_record): New. (init_record_full_ops): Delete. (init_record_full_core_ops): Delete. (record_full_save): Refactor as method of the record_full_base_target class. (_initialize_record_full): Remove references to init_record_full_ops and init_record_full_core_ops. * remote.c (remote_target, extended_remote_target): New classes. (remote_ops): Now a remote_target. (extended_remote_ops): Now an extended_remote_target. (remote_insert_fork_catchpoint, remote_remove_fork_catchpoint) (remote_insert_vfork_catchpoint, remote_remove_vfork_catchpoint) (remote_insert_exec_catchpoint, remote_remove_exec_catchpoint) (remote_pass_signals, remote_set_syscall_catchpoint) (remote_program_signals, ) (remote_thread_always_alive): Remove target_ops parameter. (remote_thread_alive, remote_thread_name) (remote_update_thread_list, remote_threads_extra_info) (remote_static_tracepoint_marker_at) (remote_static_tracepoint_markers_by_strid) (remote_get_ada_task_ptid, remote_close, remote_start_remote) (remote_open): Refactor as methods of remote_target. (extended_remote_open, extended_remote_detach) (extended_remote_attach, extended_remote_post_attach): (extended_remote_supports_disable_randomization) (extended_remote_create_inferior): : Refactor as method of extended_remote_target. (remote_set_permissions, remote_open_1, remote_detach) (remote_follow_fork, remote_follow_exec, remote_disconnect) (remote_resume, remote_commit_resume, remote_stop) (remote_interrupt, remote_pass_ctrlc, remote_terminal_inferior) (remote_terminal_ours, remote_wait, remote_fetch_registers) (remote_prepare_to_store, remote_store_registers) (remote_flash_erase, remote_flash_done, remote_files_info) (remote_kill, remote_mourn, remote_insert_breakpoint) (remote_remove_breakpoint, remote_insert_watchpoint) (remote_watchpoint_addr_within_range) (remote_remove_watchpoint, remote_region_ok_for_hw_watchpoint) (remote_check_watch_resources, remote_stopped_by_sw_breakpoint) (remote_supports_stopped_by_sw_breakpoint) (remote_stopped_by_hw_breakpoint) (remote_supports_stopped_by_hw_breakpoint) (remote_stopped_by_watchpoint, remote_stopped_data_address) (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint) (remote_verify_memory): Refactor as methods of remote_target. (remote_write_qxfer, remote_read_qxfer): Remove target_ops parameter. (remote_xfer_partial, remote_get_memory_xfer_limit) (remote_search_memory, remote_rcmd, remote_memory_map) (remote_pid_to_str, remote_get_thread_local_address) (remote_get_tib_address, remote_read_description): Refactor as methods of remote_target. (remote_target::fileio_open, remote_target::fileio_pwrite) (remote_target::fileio_pread, remote_target::fileio_close): New. (remote_hostio_readlink, remote_hostio_fstat) (remote_filesystem_is_local, remote_can_execute_reverse) (remote_supports_non_stop, remote_supports_disable_randomization) (remote_supports_multi_process, remote_supports_cond_breakpoints) (remote_supports_enable_disable_tracepoint) (remote_supports_string_tracing) (remote_can_run_breakpoint_commands, remote_trace_init) (remote_download_tracepoint, remote_can_download_tracepoint) (remote_download_trace_state_variable, remote_enable_tracepoint) (remote_disable_tracepoint, remote_trace_set_readonly_regions) (remote_trace_start, remote_get_trace_status) (remote_get_tracepoint_status, remote_trace_stop) (remote_trace_find, remote_get_trace_state_variable_value) (remote_save_trace_data, remote_get_raw_trace_data) (remote_set_disconnected_tracing, remote_core_of_thread) (remote_set_circular_trace_buffer, remote_traceframe_info) (remote_get_min_fast_tracepoint_insn_len) (remote_set_trace_buffer_size, remote_set_trace_notes) (remote_use_agent, remote_can_use_agent, remote_enable_btrace) (remote_disable_btrace, remote_teardown_btrace) (remote_read_btrace, remote_btrace_conf) (remote_augmented_libraries_svr4_read, remote_load) (remote_pid_to_exec_file, remote_can_do_single_step) (remote_execution_direction, remote_thread_handle_to_thread_info): Refactor as methods of remote_target. (init_remote_ops, init_extended_remote_ops): Delete. (remote_can_async_p, remote_is_async_p, remote_async) (remote_thread_events, remote_upload_tracepoints) (remote_upload_trace_state_variables): Refactor as methods of remote_target. (_initialize_remote): Remove references to init_remote_ops and init_extended_remote_ops. * remote-sim.c (gdbsim_target): New class. (gdbsim_fetch_register, gdbsim_store_register, gdbsim_kill) (gdbsim_load, gdbsim_create_inferior, gdbsim_open, gdbsim_close) (gdbsim_detach, gdbsim_resume, gdbsim_interrupt) (gdbsim_wait, gdbsim_prepare_to_store, gdbsim_xfer_partial) (gdbsim_files_info, gdbsim_mourn_inferior, gdbsim_thread_alive) (gdbsim_pid_to_str, gdbsim_has_all_memory, gdbsim_has_memory): Refactor as methods of gdbsim_target. (gdbsim_ops): Now a gdbsim_target. (init_gdbsim_ops): Delete. (gdbsim_cntrl_c): Adjust. (_initialize_remote_sim): Remove reference to init_gdbsim_ops. * amd64-linux-nat.c (amd64_linux_nat_target): New class. (the_amd64_linux_nat_target): New. (amd64_linux_fetch_inferior_registers) (amd64_linux_store_inferior_registers): Refactor as methods of amd64_linux_nat_target. (_initialize_amd64_linux_nat): Adjust. Set linux_target. * i386-linux-nat.c: Don't include "linux-nat.h". (i386_linux_nat_target): New class. (the_i386_linux_nat_target): New. (i386_linux_fetch_inferior_registers) (i386_linux_store_inferior_registers, i386_linux_resume): Refactor as methods of i386_linux_nat_target. (_initialize_i386_linux_nat): Adjust. Set linux_target. * inf-child.c (inf_child_ops): Delete. (inf_child_fetch_inferior_registers) (inf_child_store_inferior_registers): Delete. (inf_child_post_attach, inf_child_prepare_to_store): Refactor as methods of inf_child_target. (inf_child_target::supports_terminal_ours) (inf_child_target::terminal_init) (inf_child_target::terminal_inferior) (inf_child_target::terminal_ours_for_output) (inf_child_target::terminal_ours, inf_child_target::interrupt) (inf_child_target::pass_ctrlc, inf_child_target::terminal_info): New. (inf_child_open, inf_child_disconnect, inf_child_close) (inf_child_mourn_inferior, inf_child_maybe_unpush_target) (inf_child_post_startup_inferior, inf_child_can_run) (inf_child_pid_to_exec_file): Refactor as methods of inf_child_target. (inf_child_follow_fork): Delete. (inf_child_target::can_create_inferior) (inf_child_target::can_attach): New. (inf_child_target::has_all_memory, inf_child_target::has_memory) (inf_child_target::has_stack, inf_child_target::has_registers) (inf_child_target::has_execution): New. (inf_child_fileio_open, inf_child_fileio_pwrite) (inf_child_fileio_pread, inf_child_fileio_fstat) (inf_child_fileio_close, inf_child_fileio_unlink) (inf_child_fileio_readlink, inf_child_use_agent) (inf_child_can_use_agent): Refactor as methods of inf_child_target. (return_zero, inf_child_target): Delete. (inf_child_target::inf_child_target): New. * inf-child.h: Include "target.h". (inf_child_target): Delete function prototype. (inf_child_target): New class. (inf_child_open_target, inf_child_mourn_inferior) (inf_child_maybe_unpush_target): Delete. * inf-ptrace.c (inf_ptrace_target::~inf_ptrace_target): New. (inf_ptrace_follow_fork, inf_ptrace_insert_fork_catchpoint) (inf_ptrace_remove_fork_catchpoint, inf_ptrace_create_inferior) (inf_ptrace_post_startup_inferior, inf_ptrace_mourn_inferior) (inf_ptrace_attach, inf_ptrace_post_attach, inf_ptrace_detach) (inf_ptrace_detach_success, inf_ptrace_kill, inf_ptrace_resume) (inf_ptrace_wait, inf_ptrace_xfer_partial) (inf_ptrace_thread_alive, inf_ptrace_files_info) (inf_ptrace_pid_to_str, inf_ptrace_auxv_parse): Refactor as methods of inf_ptrace_target. (inf_ptrace_target): Delete function. * inf-ptrace.h: Include "inf-child.h". (inf_ptrace_target): Delete function declaration. (inf_ptrace_target): New class. (inf_ptrace_trad_target, inf_ptrace_detach_success): Delete. * linux-nat.c (linux_target): New. (linux_ops, linux_ops_saved, super_xfer_partial): Delete. (linux_nat_target::~linux_nat_target): New. (linux_child_post_attach, linux_child_post_startup_inferior) (linux_child_follow_fork, linux_child_insert_fork_catchpoint) (linux_child_remove_fork_catchpoint) (linux_child_insert_vfork_catchpoint) (linux_child_remove_vfork_catchpoint) (linux_child_insert_exec_catchpoint) (linux_child_remove_exec_catchpoint) (linux_child_set_syscall_catchpoint, linux_nat_pass_signals) (linux_nat_create_inferior, linux_nat_attach, linux_nat_detach) (linux_nat_resume, linux_nat_stopped_by_watchpoint) (linux_nat_stopped_data_address) (linux_nat_stopped_by_sw_breakpoint) (linux_nat_supports_stopped_by_sw_breakpoint) (linux_nat_stopped_by_hw_breakpoint) (linux_nat_supports_stopped_by_hw_breakpoint, linux_nat_wait) (linux_nat_kill, linux_nat_mourn_inferior) (linux_nat_xfer_partial, linux_nat_thread_alive) (linux_nat_update_thread_list, linux_nat_pid_to_str) (linux_nat_thread_name, linux_child_pid_to_exec_file) (linux_child_static_tracepoint_markers_by_strid) (linux_nat_is_async_p, linux_nat_can_async_p) (linux_nat_supports_non_stop, linux_nat_always_non_stop_p) (linux_nat_supports_multi_process) (linux_nat_supports_disable_randomization, linux_nat_async) (linux_nat_stop, linux_nat_close, linux_nat_thread_address_space) (linux_nat_core_of_thread, linux_nat_filesystem_is_local) (linux_nat_fileio_open, linux_nat_fileio_readlink) (linux_nat_fileio_unlink, linux_nat_thread_events): Refactor as methods of linux_nat_target. (linux_nat_wait_1, linux_xfer_siginfo, linux_proc_xfer_partial) (linux_proc_xfer_spu, linux_nat_xfer_osdata): Remove target_ops parameter. (check_stopped_by_watchpoint): Adjust. (linux_xfer_partial): Delete. (linux_target_install_ops, linux_target, linux_nat_add_target): Delete. (linux_nat_target::linux_nat_target): New. * linux-nat.h: Include "inf-ptrace.h". (linux_nat_target): New. (linux_target, linux_target_install_ops, linux_nat_add_target): Delete function declarations. (linux_target): Declare global. * linux-thread-db.c (thread_db_target): New. (thread_db_target::thread_db_target): New. (thread_db_ops): Delete. (the_thread_db_target): New. (thread_db_detach, thread_db_wait, thread_db_mourn_inferior) (thread_db_update_thread_list, thread_db_pid_to_str) (thread_db_extra_thread_info) (thread_db_thread_handle_to_thread_info) (thread_db_get_thread_local_address, thread_db_get_ada_task_ptid) (thread_db_resume): Refactor as methods of thread_db_target. (init_thread_db_ops): Delete. (_initialize_thread_db): Remove reference to init_thread_db_ops. * x86-linux-nat.c: Don't include "linux-nat.h". (super_post_startup_inferior): Delete. (x86_linux_nat_target::~x86_linux_nat_target): New. (x86_linux_child_post_startup_inferior) (x86_linux_read_description, x86_linux_enable_btrace) (x86_linux_disable_btrace, x86_linux_teardown_btrace) (x86_linux_read_btrace, x86_linux_btrace_conf): Refactor as methods of x86_linux_nat_target. (x86_linux_create_target): Delete. Bits folded ... (x86_linux_add_target): ... here. Now takes a linux_nat_target pointer. * x86-linux-nat.h: Include "linux-nat.h" and "x86-nat.h". (x86_linux_nat_target): New class. (x86_linux_create_target): Delete. (x86_linux_add_target): Now takes a linux_nat_target pointer. * x86-nat.c (x86_insert_watchpoint, x86_remove_watchpoint) (x86_region_ok_for_watchpoint, x86_stopped_data_address) (x86_stopped_by_watchpoint, x86_insert_hw_breakpoint) (x86_remove_hw_breakpoint, x86_can_use_hw_breakpoint) (x86_stopped_by_hw_breakpoint): Remove target_ops parameter and make extern. (x86_use_watchpoints): Delete. * x86-nat.h: Include "breakpoint.h" and "target.h". (x86_use_watchpoints): Delete. (x86_can_use_hw_breakpoint, x86_region_ok_for_hw_watchpoint) (x86_stopped_by_watchpoint, x86_stopped_data_address) (x86_insert_watchpoint, x86_remove_watchpoint) (x86_insert_hw_breakpoint, x86_remove_hw_breakpoint) (x86_stopped_by_hw_breakpoint): New declarations. (x86_nat_target): New template class. * ppc-linux-nat.c (ppc_linux_nat_target): New class. (the_ppc_linux_nat_target): New. (ppc_linux_fetch_inferior_registers) (ppc_linux_can_use_hw_breakpoint) (ppc_linux_region_ok_for_hw_watchpoint) (ppc_linux_ranged_break_num_registers) (ppc_linux_insert_hw_breakpoint, ppc_linux_remove_hw_breakpoint) (ppc_linux_insert_mask_watchpoint) (ppc_linux_remove_mask_watchpoint) (ppc_linux_can_accel_watchpoint_condition) (ppc_linux_insert_watchpoint, ppc_linux_remove_watchpoint) (ppc_linux_stopped_data_address, ppc_linux_stopped_by_watchpoint) (ppc_linux_watchpoint_addr_within_range) (ppc_linux_masked_watch_num_registers) (ppc_linux_store_inferior_registers, ppc_linux_auxv_parse) (ppc_linux_read_description): Refactor as methods of ppc_linux_nat_target. (_initialize_ppc_linux_nat): Adjust. Set linux_target. * procfs.c (procfs_xfer_partial): Delete forward declaration. (procfs_target): New class. (the_procfs_target): New. (procfs_target): Delete function. (procfs_auxv_parse, procfs_attach, procfs_detach) (procfs_fetch_registers, procfs_store_registers, procfs_wait) (procfs_xfer_partial, procfs_resume, procfs_pass_signals) (procfs_files_info, procfs_kill_inferior, procfs_mourn_inferior) (procfs_create_inferior, procfs_update_thread_list) (procfs_thread_alive, procfs_pid_to_str) (procfs_can_use_hw_breakpoint, procfs_stopped_by_watchpoint) (procfs_stopped_data_address, procfs_insert_watchpoint) (procfs_remove_watchpoint, procfs_region_ok_for_hw_watchpoint) (proc_find_memory_regions, procfs_info_proc) (procfs_make_note_section): Refactor as methods of procfs_target. (_initialize_procfs): Adjust. * sol-thread.c (sol_thread_target): New class. (sol_thread_ops): Now a sol_thread_target. (sol_thread_detach, sol_thread_resume, sol_thread_wait) (sol_thread_fetch_registers, sol_thread_store_registers) (sol_thread_xfer_partial, sol_thread_mourn_inferior) (sol_thread_alive, solaris_pid_to_str, sol_update_thread_list) (sol_get_ada_task_ptid): Refactor as methods of sol_thread_target. (init_sol_thread_ops): Delete. (_initialize_sol_thread): Adjust. Remove references to init_sol_thread_ops and complete_target_initialization. * windows-nat.c (windows_nat_target): New class. (windows_fetch_inferior_registers) (windows_store_inferior_registers, windows_resume, windows_wait) (windows_attach, windows_detach, windows_pid_to_exec_file) (windows_files_info, windows_create_inferior) (windows_mourn_inferior, windows_interrupt, windows_kill_inferior) (windows_close, windows_pid_to_str, windows_xfer_partial) (windows_get_tib_address, windows_get_ada_task_ptid) (windows_thread_name, windows_thread_alive): Refactor as windows_nat_target methods. (do_initial_windows_stuff): Adjust. (windows_target): Delete function. (_initialize_windows_nat): Adjust. * darwin-nat.c (darwin_resume, darwin_wait_to, darwin_interrupt) (darwin_mourn_inferior, darwin_kill_inferior) (darwin_create_inferior, darwin_attach, darwin_detach) (darwin_pid_to_str, darwin_thread_alive, darwin_xfer_partial) (darwin_pid_to_exec_file, darwin_get_ada_task_ptid) (darwin_supports_multi_process): Refactor as darwin_nat_target methods. (darwin_resume_to, darwin_files_info): Delete. (_initialize_darwin_inferior): Rename to ... (_initialize_darwin_nat): ... this. Adjust to C++ification. * darwin-nat.h: Include "inf-child.h". (darwin_nat_target): New class. (darwin_complete_target): Delete. * i386-darwin-nat.c (i386_darwin_nat_target): New class. (darwin_target): New. (i386_darwin_fetch_inferior_registers) (i386_darwin_store_inferior_registers): Refactor as methods of darwin_nat_target. (darwin_complete_target): Delete, with ... (_initialize_i386_darwin_nat): ... bits factored out here. * alpha-linux-nat.c (alpha_linux_nat_target): New class. (the_alpha_linux_nat_target): New. (alpha_linux_register_u_offset): Refactor as alpha_linux_nat_target method. (_initialize_alpha_linux_nat): Adjust. * linux-nat-trad.c (inf_ptrace_register_u_offset): Delete. (inf_ptrace_fetch_register, inf_ptrace_fetch_registers) (inf_ptrace_store_register, inf_ptrace_store_registers): Refact as methods of linux_nat_trad_target. (linux_trad_target): Delete. * linux-nat-trad.h (linux_trad_target): Delete function. (linux_nat_trad_target): New class. * mips-linux-nat.c (mips_linux_nat_target): New class. (super_fetch_registers, super_store_registers, super_close): Delete. (the_mips_linux_nat_target): New. (mips64_linux_regsets_fetch_registers) (mips64_linux_regsets_store_registers) (mips64_linux_fetch_registers, mips64_linux_store_registers) (mips_linux_register_u_offset, mips_linux_read_description) (mips_linux_can_use_hw_breakpoint) (mips_linux_stopped_by_watchpoint) (mips_linux_stopped_data_address) (mips_linux_region_ok_for_hw_watchpoint) (mips_linux_insert_watchpoint, mips_linux_remove_watchpoint) (mips_linux_close): Refactor as methods of mips_linux_nat. (_initialize_mips_linux_nat): Adjust to C++ification. * aix-thread.c (aix_thread_target): New class. (aix_thread_ops): Now an aix_thread_target. (aix_thread_detach, aix_thread_resume, aix_thread_wait) (aix_thread_fetch_registers, aix_thread_store_registers) (aix_thread_xfer_partial, aix_thread_mourn_inferior) (aix_thread_thread_alive, aix_thread_pid_to_str) (aix_thread_extra_thread_info, aix_thread_get_ada_task_ptid): Refactor as methods of aix_thread_target. (init_aix_thread_ops): Delete. (_initialize_aix_thread): Remove references to init_aix_thread_ops and complete_target_initialization. * rs6000-nat.c (rs6000_xfer_shared_libraries): Delete. (rs6000_nat_target): New class. (the_rs6000_nat_target): New. (rs6000_fetch_inferior_registers, rs6000_store_inferior_registers) (rs6000_xfer_partial, rs6000_wait, rs6000_create_inferior) (rs6000_xfer_shared_libraries): Refactor as rs6000_nat_target methods. (super_create_inferior): Delete. (_initialize_rs6000_nat): Adjust to C++ification. * arm-linux-nat.c (arm_linux_nat_target): New class. (the_arm_linux_nat_target): New. (arm_linux_fetch_inferior_registers) (arm_linux_store_inferior_registers, arm_linux_read_description) (arm_linux_can_use_hw_breakpoint, arm_linux_insert_hw_breakpoint) (arm_linux_remove_hw_breakpoint) (arm_linux_region_ok_for_hw_watchpoint) (arm_linux_insert_watchpoint, arm_linux_remove_watchpoint) (arm_linux_stopped_data_address, arm_linux_stopped_by_watchpoint) (arm_linux_watchpoint_addr_within_range): Refactor as methods of arm_linux_nat_target. (_initialize_arm_linux_nat): Adjust to C++ification. * aarch64-linux-nat.c (aarch64_linux_nat_target): New class. (the_aarch64_linux_nat_target): New. (aarch64_linux_fetch_inferior_registers) (aarch64_linux_store_inferior_registers) (aarch64_linux_child_post_startup_inferior) (aarch64_linux_read_description) (aarch64_linux_can_use_hw_breakpoint) (aarch64_linux_insert_hw_breakpoint) (aarch64_linux_remove_hw_breakpoint) (aarch64_linux_insert_watchpoint, aarch64_linux_remove_watchpoint) (aarch64_linux_region_ok_for_hw_watchpoint) (aarch64_linux_stopped_data_address) (aarch64_linux_stopped_by_watchpoint) (aarch64_linux_watchpoint_addr_within_range) (aarch64_linux_can_do_single_step): Refactor as methods of aarch64_linux_nat_target. (super_post_startup_inferior): Delete. (_initialize_aarch64_linux_nat): Adjust to C++ification. * hppa-linux-nat.c (hppa_linux_nat_target): New class. (the_hppa_linux_nat_target): New. (hppa_linux_fetch_inferior_registers) (hppa_linux_store_inferior_registers): Refactor as methods of hppa_linux_nat_target. (_initialize_hppa_linux_nat): Adjust to C++ification. * ia64-linux-nat.c (ia64_linux_nat_target): New class. (the_ia64_linux_nat_target): New. (ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint) (ia64_linux_stopped_data_address) (ia64_linux_stopped_by_watchpoint, ia64_linux_fetch_registers) (ia64_linux_store_registers, ia64_linux_xfer_partial): Refactor as ia64_linux_nat_target methods. (super_xfer_partial): Delete. (_initialize_ia64_linux_nat): Adjust to C++ification. * m32r-linux-nat.c (m32r_linux_nat_target): New class. (the_m32r_linux_nat_target): New. (m32r_linux_fetch_inferior_registers) (m32r_linux_store_inferior_registers): Refactor as m32r_linux_nat_target methods. (_initialize_m32r_linux_nat): Adjust to C++ification. * m68k-linux-nat.c (m68k_linux_nat_target): New class. (the_m68k_linux_nat_target): New. (m68k_linux_fetch_inferior_registers) (m68k_linux_store_inferior_registers): Refactor as m68k_linux_nat_target methods. (_initialize_m68k_linux_nat): Adjust to C++ification. * s390-linux-nat.c (s390_linux_nat_target): New class. (the_s390_linux_nat_target): New. (s390_linux_fetch_inferior_registers) (s390_linux_store_inferior_registers, s390_stopped_by_watchpoint) (s390_insert_watchpoint, s390_remove_watchpoint) (s390_can_use_hw_breakpoint, s390_insert_hw_breakpoint) (s390_remove_hw_breakpoint, s390_region_ok_for_hw_watchpoint) (s390_auxv_parse, s390_read_description): Refactor as methods of s390_linux_nat_target. (_initialize_s390_nat): Adjust to C++ification. * sparc-linux-nat.c (sparc_linux_nat_target): New class. (the_sparc_linux_nat_target): New. (_initialize_sparc_linux_nat): Adjust to C++ification. * sparc-nat.c (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers): Remove target_ops parameter. * sparc64-linux-nat.c (sparc64_linux_nat_target): New class. (the_sparc64_linux_nat_target): New. (_initialize_sparc64_linux_nat): Adjust to C++ification. * spu-linux-nat.c (spu_linux_nat_target): New class. (the_spu_linux_nat_target): New. (spu_child_post_startup_inferior, spu_child_post_attach) (spu_child_wait, spu_fetch_inferior_registers) (spu_store_inferior_registers, spu_xfer_partial) (spu_can_use_hw_breakpoint): Refactor as spu_linux_nat_target methods. (_initialize_spu_nat): Adjust to C++ification. * tilegx-linux-nat.c (tilegx_linux_nat_target): New class. (the_tilegx_linux_nat_target): New. (fetch_inferior_registers, store_inferior_registers): Refactor as methods. (_initialize_tile_linux_nat): Adjust to C++ification. * xtensa-linux-nat.c (xtensa_linux_nat_target): New class. (the_xtensa_linux_nat_target): New. (xtensa_linux_fetch_inferior_registers) (xtensa_linux_store_inferior_registers): Refactor as xtensa_linux_nat_target methods. (_initialize_xtensa_linux_nat): Adjust to C++ification. * fbsd-nat.c (USE_SIGTRAP_SIGINFO): Delete. (fbsd_pid_to_exec_file, fbsd_find_memory_regions) (fbsd_find_memory_regions, fbsd_info_proc, fbsd_xfer_partial) (fbsd_thread_alive, fbsd_pid_to_str, fbsd_thread_name) (fbsd_update_thread_list, fbsd_resume, fbsd_wait) (fbsd_stopped_by_sw_breakpoint) (fbsd_supports_stopped_by_sw_breakpoint, fbsd_follow_fork) (fbsd_insert_fork_catchpoint, fbsd_remove_fork_catchpoint) (fbsd_insert_vfork_catchpoint, fbsd_remove_vfork_catchpoint) (fbsd_post_startup_inferior, fbsd_post_attach) (fbsd_insert_exec_catchpoint, fbsd_remove_exec_catchpoint) (fbsd_set_syscall_catchpoint) (super_xfer_partial, super_resume, super_wait) (fbsd_supports_stopped_by_hw_breakpoint): Delete. (fbsd_handle_debug_trap): Remove target_ops parameter. (fbsd_nat_add_target): Delete. * fbsd-nat.h: Include "inf-ptrace.h". (fbsd_nat_add_target): Delete. (USE_SIGTRAP_SIGINFO): Define. (fbsd_nat_target): New class. * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers) (amd64bsd_store_inferior_registers): Remove target_ops parameter. (amd64bsd_target): Delete. * amd64-bsd-nat.h: New file. * amd64-fbsd-nat.c: Include "amd64-bsd-nat.h" instead of "x86-bsd-nat.h". (amd64_fbsd_nat_target): New class. (the_amd64_fbsd_nat_target): New. (amd64fbsd_read_description): Refactor as method of amd64_fbsd_nat_target. (amd64_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_amd64fbsd_nat): Adjust to C++ification. * amd64-nat.h (amd64bsd_target): Delete function declaration. * i386-bsd-nat.c (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Remove target_ops parameter. (i386bsd_target): Delete. * i386-bsd-nat.h (i386bsd_target): Delete function declaration. (i386bsd_fetch_inferior_registers) (i386bsd_store_inferior_registers): Declare. (i386_bsd_nat_target): New class. * i386-fbsd-nat.c (i386_fbsd_nat_target): New class. (the_i386_fbsd_nat_target): New. (i386fbsd_resume, i386fbsd_read_description): Refactor as i386_fbsd_nat_target methods. (i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint): New. (_initialize_i386fbsd_nat): Adjust to C++ification. * x86-bsd-nat.c (super_mourn_inferior): Delete. (x86bsd_mourn_inferior, x86bsd_target): Delete. (_initialize_x86_bsd_nat): Adjust to C++ification. * x86-bsd-nat.h: Include "x86-nat.h". (x86bsd_target): Delete declaration. (x86bsd_nat_target): New class. * aarch64-fbsd-nat.c (aarch64_fbsd_nat_target): New class. (the_aarch64_fbsd_nat_target): New. (aarch64_fbsd_fetch_inferior_registers) (aarch64_fbsd_store_inferior_registers): Refactor as methods of aarch64_fbsd_nat_target. (_initialize_aarch64_fbsd_nat): Adjust to C++ification. * alpha-bsd-nat.c (alpha_bsd_nat_target): New class. (the_alpha_bsd_nat_target): New. (alphabsd_fetch_inferior_registers) (alphabsd_store_inferior_registers): Refactor as alpha_bsd_nat_target methods. (_initialize_alphabsd_nat): Refactor as methods of alpha_bsd_nat_target. * amd64-nbsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_nbsd_nat_target): New. (_initialize_amd64nbsd_nat): Adjust to C++ification. * amd64-obsd-nat.c: Include "amd64-bsd-nat.h". (the_amd64_obsd_nat_target): New. (_initialize_amd64obsd_nat): Adjust to C++ification. * arm-fbsd-nat.c (arm_fbsd_nat_target): New. (the_arm_fbsd_nat_target): New. (arm_fbsd_fetch_inferior_registers) (arm_fbsd_store_inferior_registers, arm_fbsd_read_description): (_initialize_arm_fbsd_nat): Refactor as methods of arm_fbsd_nat_target. (_initialize_arm_fbsd_nat): Adjust to C++ification. * arm-nbsd-nat.c (arm_netbsd_nat_target): New class. (the_arm_netbsd_nat_target): New. (armnbsd_fetch_registers, armnbsd_store_registers): Refactor as arm_netbsd_nat_target. (_initialize_arm_netbsd_nat): Adjust to C++ification. * hppa-nbsd-nat.c (hppa_nbsd_nat_target): New class. (the_hppa_nbsd_nat_target): New. (hppanbsd_fetch_registers, hppanbsd_store_registers): Refactor as hppa_nbsd_nat_target methods. (_initialize_hppanbsd_nat): Adjust to C++ification. * hppa-obsd-nat.c (hppa_obsd_nat_target): New class. (the_hppa_obsd_nat_target): New. (hppaobsd_fetch_registers, hppaobsd_store_registers): Refactor as methods of hppa_obsd_nat_target. (_initialize_hppaobsd_nat): Adjust to C++ification. Use add_target. * i386-nbsd-nat.c (the_i386_nbsd_nat_target): New. (_initialize_i386nbsd_nat): Adjust to C++ification. Use add_target. * i386-obsd-nat.c (the_i386_obsd_nat_target): New. (_initialize_i386obsd_nat): Use add_target. * m68k-bsd-nat.c (m68k_bsd_nat_target): New class. (the_m68k_bsd_nat_target): New. (m68kbsd_fetch_inferior_registers) (m68kbsd_store_inferior_registers): Refactor as methods of m68k_bsd_nat_target. (_initialize_m68kbsd_nat): Adjust to C++ification. * mips-fbsd-nat.c (mips_fbsd_nat_target): New class. (the_mips_fbsd_nat_target): New. (mips_fbsd_fetch_inferior_registers) (mips_fbsd_store_inferior_registers): Refactor as methods of mips_fbsd_nat_target. (_initialize_mips_fbsd_nat): Adjust to C++ification. Use add_target. * mips-nbsd-nat.c (mips_nbsd_nat_target): New class. (the_mips_nbsd_nat_target): New. (mipsnbsd_fetch_inferior_registers) (mipsnbsd_store_inferior_registers): Refactor as methods of mips_nbsd_nat_target. (_initialize_mipsnbsd_nat): Adjust to C++ification. * mips64-obsd-nat.c (mips64_obsd_nat_target): New class. (the_mips64_obsd_nat_target): New. (mips64obsd_fetch_inferior_registers) (mips64obsd_store_inferior_registers): Refactor as methods of mips64_obsd_nat_target. (_initialize_mips64obsd_nat): Adjust to C++ification. Use add_target. * nbsd-nat.c (nbsd_pid_to_exec_file): Refactor as method of nbsd_nat_target. * nbsd-nat.h: Include "inf-ptrace.h". (nbsd_nat_target): New class. * obsd-nat.c (obsd_pid_to_str, obsd_update_thread_list) (obsd_wait): Refactor as methods of obsd_nat_target. (obsd_add_target): Delete. * obsd-nat.h: Include "inf-ptrace.h". (obsd_nat_target): New class. * ppc-fbsd-nat.c (ppc_fbsd_nat_target): New class. (the_ppc_fbsd_nat_target): New. (ppcfbsd_fetch_inferior_registers) (ppcfbsd_store_inferior_registers): Refactor as methods of ppc_fbsd_nat_target. (_initialize_ppcfbsd_nat): Adjust to C++ification. Use add_target. * ppc-nbsd-nat.c (ppc_nbsd_nat_target): New class. (the_ppc_nbsd_nat_target): New. (ppcnbsd_fetch_inferior_registers) (ppcnbsd_store_inferior_registers): Refactor as methods of ppc_nbsd_nat_target. (_initialize_ppcnbsd_nat): Adjust to C++ification. * ppc-obsd-nat.c (ppc_obsd_nat_target): New class. (the_ppc_obsd_nat_target): New. (ppcobsd_fetch_registers, ppcobsd_store_registers): Refactor as methods of ppc_obsd_nat_target. (_initialize_ppcobsd_nat): Adjust to C++ification. Use add_target. * sh-nbsd-nat.c (sh_nbsd_nat_target): New class. (the_sh_nbsd_nat_target): New. (shnbsd_fetch_inferior_registers) (shnbsd_store_inferior_registers): Refactor as methods of sh_nbsd_nat_target. (_initialize_shnbsd_nat): Adjust to C++ification. * sparc-nat.c (sparc_xfer_wcookie): Make extern. (inf_ptrace_xfer_partial): Delete. (sparc_xfer_partial, sparc_target): Delete. * sparc-nat.h (sparc_fetch_inferior_registers) (sparc_store_inferior_registers, sparc_xfer_wcookie): Declare. (sparc_target): Delete function declaration. (sparc_target): New template class. * sparc-nbsd-nat.c (the_sparc_nbsd_nat_target): New. (_initialize_sparcnbsd_nat): Adjust to C++ification. * sparc64-fbsd-nat.c (the_sparc64_fbsd_nat_target): New. (_initialize_sparc64fbsd_nat): Adjust to C++ification. Use add_target. * sparc64-nbsd-nat.c (the_sparc64_nbsd_nat_target): New. (_initialize_sparc64nbsd_nat): Adjust to C++ification. * sparc64-obsd-nat.c (the_sparc64_obsd_nat_target): New. (_initialize_sparc64obsd_nat): Adjust to C++ification. Use add_target. * vax-bsd-nat.c (vax_bsd_nat_target): New class. (the_vax_bsd_nat_target): New. (vaxbsd_fetch_inferior_registers) (vaxbsd_store_inferior_registers): Refactor as vax_bsd_nat_target methods. (_initialize_vaxbsd_nat): Adjust to C++ification. * bsd-kvm.c (bsd_kvm_target): New class. (bsd_kvm_ops): Now a bsd_kvm_target. (bsd_kvm_open, bsd_kvm_close, bsd_kvm_xfer_partial) (bsd_kvm_files_info, bsd_kvm_fetch_registers) (bsd_kvm_thread_alive, bsd_kvm_pid_to_str): Refactor as methods of bsd_kvm_target. (bsd_kvm_return_one): Delete. (bsd_kvm_add_target): Adjust to C++ification. * nto-procfs.c (nto_procfs_target, nto_procfs_target_native) (nto_procfs_target_procfs): New classes. (procfs_open_1, procfs_thread_alive, procfs_update_thread_list) (procfs_files_info, procfs_pid_to_exec_file, procfs_attach) (procfs_post_attach, procfs_wait, procfs_fetch_registers) (procfs_xfer_partial, procfs_detach, procfs_insert_breakpoint) (procfs_remove_breakpoint, procfs_insert_hw_breakpoint) (procfs_remove_hw_breakpoint, procfs_resume) (procfs_mourn_inferior, procfs_create_inferior, procfs_interrupt) (procfs_kill_inferior, procfs_store_registers) (procfs_pass_signals, procfs_pid_to_str, procfs_can_run): Refactor as methods of nto_procfs_target. (nto_procfs_ops): Now an nto_procfs_target_procfs. (nto_native_ops): Delete. (procfs_open, procfs_native_open): Delete. (nto_native_ops): Now an nto_procfs_target_native. (init_procfs_targets): Adjust to C++ification. (procfs_can_use_hw_breakpoint, procfs_remove_hw_watchpoint) (procfs_insert_hw_watchpoint, procfs_stopped_by_watchpoint): Refactor as methods of nto_procfs_target. * go32-nat.c (go32_nat_target): New class. (the_go32_nat_target): New. (go32_attach, go32_resume, go32_wait, go32_fetch_registers) (go32_store_registers, go32_xfer_partial, go32_files_info) (go32_kill_inferior, go32_create_inferior, go32_mourn_inferior) (go32_terminal_init, go32_terminal_info, go32_terminal_inferior) (go32_terminal_ours, go32_pass_ctrlc, go32_thread_alive) (go32_pid_to_str): Refactor as methods of go32_nat_target. (go32_target): Delete. (_initialize_go32_nat): Adjust to C++ification. * gnu-nat.c (gnu_wait, gnu_resume, gnu_kill_inferior) (gnu_mourn_inferior, gnu_create_inferior, gnu_attach, gnu_detach) (gnu_stop, gnu_thread_alive, gnu_xfer_partial) (gnu_find_memory_regions, gnu_pid_to_str): Refactor as methods of gnu_nat_target. (gnu_target): Delete. * gnu-nat.h (gnu_target): Delete. (gnu_nat_target): New class. * i386-gnu-nat.c (gnu_base_target): New. (i386_gnu_nat_target): New class. (the_i386_gnu_nat_target): New. (_initialize_i386gnu_nat): Adjust to C++ification. gdb/testsuite/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * gdb.base/breakpoint-in-ro-region.exp: Adjust to to_resume and to_log_command renames. * gdb.base/sss-bp-on-user-bp-2.exp: Likewise.
2018-05-03 01:37:22 +02:00
ptid_t
ravenscar_thread_target::get_ada_task_ptid (long lwp, long thread)
{
return ptid_t (m_base_ptid.pid (), 0, thread);
}
/* Command-list for the "set/show ravenscar" prefix command. */
static struct cmd_list_element *set_ravenscar_list;
static struct cmd_list_element *show_ravenscar_list;
/* Implement the "show ravenscar task-switching" command. */
static void
show_ravenscar_task_switching_command (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
const char *value)
{
if (ravenscar_task_support)
fprintf_filtered (file, _("\
Support for Ravenscar task/thread switching is enabled\n"));
else
fprintf_filtered (file, _("\
Support for Ravenscar task/thread switching is disabled\n"));
}
/* Module startup initialization function, automagically called by
init.c. */
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
void _initialize_ravenscar ();
void
_initialize_ravenscar ()
{
/* Notice when the inferior is created in order to push the
ravenscar ops if needed. */
Convert observers to C++ This converts observers from using a special source-generating script to be plain C++. This version of the patch takes advantage of C++11 by using std::function and variadic templates; incorporates Pedro's patches; and renames the header file to "observable.h" (this change eliminates the need for a clean rebuild). Note that Pedro's patches used a template lambda in tui-hooks.c, but this failed to compile on some buildbot instances (presumably due to differing C++ versions); I replaced this with an ordinary template function. Regression tested on the buildbot. gdb/ChangeLog 2018-03-19 Pedro Alves <palves@redhat.com> Tom Tromey <tom@tromey.com> * unittests/observable-selftests.c: New file. * common/observable.h: New file. * observable.h: New file. * ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c, arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c, breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c, corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c, extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c, infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c, linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c, mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c, ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c, python/py-breakpoint.c, python/py-finishbreakpoint.c, python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c, record-btrace.c, record-full.c, record.c, regcache.c, remote.c, riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c, spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c, symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c, tui/tui-interp.c, valops.c: Update all users. * tui/tui-hooks.c (tui_bp_created_observer) (tui_bp_deleted_observer, tui_bp_modified_observer) (tui_inferior_exit_observer, tui_before_prompt_observer) (tui_normal_stop_observer, tui_register_changed_observer): Remove. (tui_observers_token): New global. (attach_or_detach, tui_attach_detach_observers): New functions. (tui_install_hooks, tui_remove_hooks): Use tui_attach_detach_observers. * record-btrace.c (record_btrace_thread_observer): Remove. (record_btrace_thread_observer_token): New global. * observer.sh: Remove. * observer.c: Rename to observable.c. * observable.c (namespace gdb_observers): Define new objects. (observer_debug): Move into gdb_observers namespace. (struct observer, struct observer_list, xalloc_observer_list_node) (xfree_observer_list_node, generic_observer_attach) (generic_observer_detach, generic_observer_notify): Remove. (_initialize_observer): Update. Don't include observer.inc. * Makefile.in (generated_files): Remove observer.h, observer.inc. (clean mostlyclean): Likewise. (observer.h, observer.inc): Remove targets. (SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c. (COMMON_SFILES): Use observable.c, not observer.c. * .gitignore: Remove observer.h. gdb/doc/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * observer.texi: Remove. gdb/testsuite/ChangeLog 2018-03-19 Tom Tromey <tom@tromey.com> * gdb.gdb/observer.exp: Remove.
2016-10-02 18:50:20 +02:00
gdb::observers::inferior_created.attach (ravenscar_inferior_created);
Replace most calls to help_list and cmd_show_list Currently there are many prefix commands that do nothing but call either help_list or cmd_show_list. I happened to notice that one such call, for "set print type", used the wrong command list parameter, causing incorrect output. Rather than fix this bug in isolation, I decided to eliminate this possibility by adding two new ways to add prefix commands, which simply route the call to help_list or cmd_show_list, as appropriate. This makes it impossible for a mismatch to occur. In some cases, a bit of output was removed; however, I don't think this output in general was very useful. It seemed redundant with what's already printed by help_list. A representative example is this hunk, removed from ada-lang.c: - printf_unfiltered (_(\ -"\"set ada\" must be followed by the name of a setting.\n")); This simplified the CLI style set/show commands quite a bit, and allowed the deletion of a macro. This also cleans up some unusual code in windows-tdep.c. Tested on x86-64 Fedora 30. Note that I have no way to build the go32-nat.c change. gdb/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * auto-load.c (show_auto_load_cmd): Remove. (auto_load_show_cmdlist_get): Use add_show_prefix_cmd. * arc-tdep.c (_initialize_arc_tdep): Use add_show_prefix_cmd. (maintenance_print_arc_command): Remove. * tui/tui-win.c (tui_command): Remove. (tui_get_cmd_list): Use add_basic_prefix_cmd. * tui/tui-layout.c (tui_layout_command): Remove. (_initialize_tui_layout): Use add_basic_prefix_cmd. * python/python.c (user_set_python, user_show_python): Remove. (_initialize_python): Use add_basic_prefix_cmd, add_show_prefix_cmd. * guile/guile.c (set_guile_command, show_guile_command): Remove. (install_gdb_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_guile_command): Remove. * dwarf2/read.c (set_dwarf_cmd, show_dwarf_cmd): Remove. (_initialize_dwarf2_read): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-style.h (class cli_style_option) <add_setshow_commands>: Remove do_set and do_show parameters. * cli/cli-style.c (set_style, show_style): Remove. (_initialize_cli_style): Use add_basic_prefix_cmd, add_show_prefix_cmd. (cli_style_option::add_setshow_commands): Remove do_set and do_show parameters. (cli_style_option::add_setshow_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (STYLE_ADD_SETSHOW_COMMANDS): Remove macro. (set_style_name): Remove. * cli/cli-dump.c (dump_command, append_command): Remove. (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Remove. (_initialize_cli_dump): Use add_basic_prefix_cmd. * windows-tdep.c (w32_prefix_command_valid): Remove global. (init_w32_command_list): Remove; move into ... (_initialize_windows_tdep): ... here. Use add_basic_prefix_cmd. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Remove. (_initialize_valprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * typeprint.c (set_print_type, show_print_type): Remove. (_initialize_typeprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record.c (set_record_command, show_record_command): Remove. (_initialize_record): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-cmds.c (_initialize_cli_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_command, show_command, set_debug, show_debug): Remove. * top.h (set_history, show_history): Don't declare. * top.c (set_history, show_history): Remove. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Remove. (_initialize_target_descriptions): Use add_basic_prefix_cmd, add_show_prefix_cmd. * symtab.c (info_module_command): Remove. (_initialize_symtab): Use add_basic_prefix_cmd. * symfile.c (overlay_command): Remove. (_initialize_symfile): Use add_basic_prefix_cmd. * sparc64-tdep.c (info_adi_command): Remove. (_initialize_sparc64_adi_tdep): Use add_basic_prefix_cmd. * sh-tdep.c (show_sh_command, set_sh_command): Remove. (_initialize_sh_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * serial.c (serial_set_cmd, serial_show_cmd): Remove. (_initialize_serial): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Remove. (_initialize_ser_tcp): Use add_basic_prefix_cmd, add_show_prefix_cmd. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command) (_initialize_rs6000_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * riscv-tdep.c (show_riscv_command, set_riscv_command) (show_debug_riscv_command, set_debug_riscv_command): Remove. (_initialize_riscv_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * remote.c (remote_command, set_remote_cmd): Remove. (_initialize_remote): Use add_basic_prefix_cmd. * record-full.c (set_record_full_command) (show_record_full_command): Remove. (_initialize_record_full): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record-btrace.c (cmd_set_record_btrace) (cmd_show_record_btrace, cmd_set_record_btrace_bts) (cmd_show_record_btrace_bts, cmd_set_record_btrace_pt) (cmd_show_record_btrace_pt): Remove. (_initialize_record_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Remove. (_initialize_ravenscar): Use add_basic_prefix_cmd, add_show_prefix_cmd. * mips-tdep.c (show_mips_command, set_mips_command) (_initialize_mips_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint.c (maintenance_command, maintenance_info_command) (maintenance_check_command, maintenance_print_command) (maintenance_set_cmd, maintenance_show_cmd): Remove. (_initialize_maint_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (show_per_command_cmd): Remove. * maint-test-settings.c (maintenance_set_test_settings_cmd): Remove. (maintenance_show_test_settings_cmd): Remove. (_initialize_maint_test_settings): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint-test-options.c (maintenance_test_options_command): Remove. (_initialize_maint_test_options): Use add_basic_prefix_cmd. * macrocmd.c (macro_command): Remove (_initialize_macrocmd): Use add_basic_prefix_cmd. * language.c (set_check, show_check): Remove. (_initialize_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * infcmd.c (unset_command): Remove. (_initialize_infcmd): Use add_basic_prefix_cmd. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Remove. (_initialize_i386_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * go32-nat.c (go32_info_dos_command): Remove. (_initialize_go32_nat): Use add_basic_prefix_cmd. * cli/cli-decode.c (do_prefix_cmd, add_basic_prefix_cmd) (do_show_prefix_cmd, add_show_prefix_cmd): New functions. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Remove. (_initialize_frame): Use add_basic_prefix_cmd, add_show_prefix_cmd. * dcache.c (set_dcache_command, show_dcache_command): Remove. (_initialize_dcache): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cp-support.c (maint_cplus_command): Remove. (_initialize_cp_support): Use add_basic_prefix_cmd. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd, _initialize_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * breakpoint.c (save_command): Remove. (_initialize_breakpoint): Use add_basic_prefix_cmd. * arm-tdep.c (set_arm_command, show_arm_command): Remove. (_initialize_arm_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ada-lang.c (maint_set_ada_cmd, maint_show_ada_cmd) (set_ada_command, show_ada_command): Remove. (_initialize_ada_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * command.h (add_basic_prefix_cmd, add_show_prefix_cmd): Declare. gdb/testsuite/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * gdb.cp/maint.exp (test_help): Simplify multiple_help_body. Update tests. * gdb.btrace/cpu.exp: Update tests. * gdb.base/maint.exp: Update tests. * gdb.base/default.exp: Update tests. * gdb.base/completion.exp: Update tests.
2020-04-17 15:27:14 +02:00
add_basic_prefix_cmd ("ravenscar", no_class,
_("Prefix command for changing Ravenscar-specific settings."),
&set_ravenscar_list, "set ravenscar ", 0, &setlist);
Replace most calls to help_list and cmd_show_list Currently there are many prefix commands that do nothing but call either help_list or cmd_show_list. I happened to notice that one such call, for "set print type", used the wrong command list parameter, causing incorrect output. Rather than fix this bug in isolation, I decided to eliminate this possibility by adding two new ways to add prefix commands, which simply route the call to help_list or cmd_show_list, as appropriate. This makes it impossible for a mismatch to occur. In some cases, a bit of output was removed; however, I don't think this output in general was very useful. It seemed redundant with what's already printed by help_list. A representative example is this hunk, removed from ada-lang.c: - printf_unfiltered (_(\ -"\"set ada\" must be followed by the name of a setting.\n")); This simplified the CLI style set/show commands quite a bit, and allowed the deletion of a macro. This also cleans up some unusual code in windows-tdep.c. Tested on x86-64 Fedora 30. Note that I have no way to build the go32-nat.c change. gdb/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * auto-load.c (show_auto_load_cmd): Remove. (auto_load_show_cmdlist_get): Use add_show_prefix_cmd. * arc-tdep.c (_initialize_arc_tdep): Use add_show_prefix_cmd. (maintenance_print_arc_command): Remove. * tui/tui-win.c (tui_command): Remove. (tui_get_cmd_list): Use add_basic_prefix_cmd. * tui/tui-layout.c (tui_layout_command): Remove. (_initialize_tui_layout): Use add_basic_prefix_cmd. * python/python.c (user_set_python, user_show_python): Remove. (_initialize_python): Use add_basic_prefix_cmd, add_show_prefix_cmd. * guile/guile.c (set_guile_command, show_guile_command): Remove. (install_gdb_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_guile_command): Remove. * dwarf2/read.c (set_dwarf_cmd, show_dwarf_cmd): Remove. (_initialize_dwarf2_read): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-style.h (class cli_style_option) <add_setshow_commands>: Remove do_set and do_show parameters. * cli/cli-style.c (set_style, show_style): Remove. (_initialize_cli_style): Use add_basic_prefix_cmd, add_show_prefix_cmd. (cli_style_option::add_setshow_commands): Remove do_set and do_show parameters. (cli_style_option::add_setshow_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (STYLE_ADD_SETSHOW_COMMANDS): Remove macro. (set_style_name): Remove. * cli/cli-dump.c (dump_command, append_command): Remove. (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Remove. (_initialize_cli_dump): Use add_basic_prefix_cmd. * windows-tdep.c (w32_prefix_command_valid): Remove global. (init_w32_command_list): Remove; move into ... (_initialize_windows_tdep): ... here. Use add_basic_prefix_cmd. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Remove. (_initialize_valprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * typeprint.c (set_print_type, show_print_type): Remove. (_initialize_typeprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record.c (set_record_command, show_record_command): Remove. (_initialize_record): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-cmds.c (_initialize_cli_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_command, show_command, set_debug, show_debug): Remove. * top.h (set_history, show_history): Don't declare. * top.c (set_history, show_history): Remove. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Remove. (_initialize_target_descriptions): Use add_basic_prefix_cmd, add_show_prefix_cmd. * symtab.c (info_module_command): Remove. (_initialize_symtab): Use add_basic_prefix_cmd. * symfile.c (overlay_command): Remove. (_initialize_symfile): Use add_basic_prefix_cmd. * sparc64-tdep.c (info_adi_command): Remove. (_initialize_sparc64_adi_tdep): Use add_basic_prefix_cmd. * sh-tdep.c (show_sh_command, set_sh_command): Remove. (_initialize_sh_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * serial.c (serial_set_cmd, serial_show_cmd): Remove. (_initialize_serial): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Remove. (_initialize_ser_tcp): Use add_basic_prefix_cmd, add_show_prefix_cmd. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command) (_initialize_rs6000_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * riscv-tdep.c (show_riscv_command, set_riscv_command) (show_debug_riscv_command, set_debug_riscv_command): Remove. (_initialize_riscv_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * remote.c (remote_command, set_remote_cmd): Remove. (_initialize_remote): Use add_basic_prefix_cmd. * record-full.c (set_record_full_command) (show_record_full_command): Remove. (_initialize_record_full): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record-btrace.c (cmd_set_record_btrace) (cmd_show_record_btrace, cmd_set_record_btrace_bts) (cmd_show_record_btrace_bts, cmd_set_record_btrace_pt) (cmd_show_record_btrace_pt): Remove. (_initialize_record_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Remove. (_initialize_ravenscar): Use add_basic_prefix_cmd, add_show_prefix_cmd. * mips-tdep.c (show_mips_command, set_mips_command) (_initialize_mips_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint.c (maintenance_command, maintenance_info_command) (maintenance_check_command, maintenance_print_command) (maintenance_set_cmd, maintenance_show_cmd): Remove. (_initialize_maint_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (show_per_command_cmd): Remove. * maint-test-settings.c (maintenance_set_test_settings_cmd): Remove. (maintenance_show_test_settings_cmd): Remove. (_initialize_maint_test_settings): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint-test-options.c (maintenance_test_options_command): Remove. (_initialize_maint_test_options): Use add_basic_prefix_cmd. * macrocmd.c (macro_command): Remove (_initialize_macrocmd): Use add_basic_prefix_cmd. * language.c (set_check, show_check): Remove. (_initialize_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * infcmd.c (unset_command): Remove. (_initialize_infcmd): Use add_basic_prefix_cmd. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Remove. (_initialize_i386_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * go32-nat.c (go32_info_dos_command): Remove. (_initialize_go32_nat): Use add_basic_prefix_cmd. * cli/cli-decode.c (do_prefix_cmd, add_basic_prefix_cmd) (do_show_prefix_cmd, add_show_prefix_cmd): New functions. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Remove. (_initialize_frame): Use add_basic_prefix_cmd, add_show_prefix_cmd. * dcache.c (set_dcache_command, show_dcache_command): Remove. (_initialize_dcache): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cp-support.c (maint_cplus_command): Remove. (_initialize_cp_support): Use add_basic_prefix_cmd. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd, _initialize_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * breakpoint.c (save_command): Remove. (_initialize_breakpoint): Use add_basic_prefix_cmd. * arm-tdep.c (set_arm_command, show_arm_command): Remove. (_initialize_arm_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ada-lang.c (maint_set_ada_cmd, maint_show_ada_cmd) (set_ada_command, show_ada_command): Remove. (_initialize_ada_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * command.h (add_basic_prefix_cmd, add_show_prefix_cmd): Declare. gdb/testsuite/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * gdb.cp/maint.exp (test_help): Simplify multiple_help_body. Update tests. * gdb.btrace/cpu.exp: Update tests. * gdb.base/maint.exp: Update tests. * gdb.base/default.exp: Update tests. * gdb.base/completion.exp: Update tests.
2020-04-17 15:27:14 +02:00
add_show_prefix_cmd ("ravenscar", no_class,
_("Prefix command for showing Ravenscar-specific settings."),
&show_ravenscar_list, "show ravenscar ", 0, &showlist);
add_setshow_boolean_cmd ("task-switching", class_obscure,
&ravenscar_task_support, _("\
Make first and last lines of 'command help documentation' consistent. With this patch, the help docs now respect 2 invariants: * The first line of a command help is terminated by a '.' character. * The last character of a command help is not a newline character. Note that the changes for the last invariant were done by Tom, as part of : [PATCH] Remove trailing newlines from help text https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html but some occurrences have been re-introduced since then. Some help docs had to be rephrased/restructured to respect the above invariants. Before this patch, print_doc_line was printing the first line of a command help documentation, but stopping at the first '.' or ',' character. This was giving inconsistent results : * The first line of command helps was sometimes '.' terminated, sometimes not. * The first line of command helps was not always designed to be readable/understandable/unambiguous when stopping at the first '.' or ',' character. This e.g. created the following inconsistencies/problems: < catch exception -- Catch Ada exceptions < catch handlers -- Catch Ada exceptions < catch syscall -- Catch system calls by their names < down-silently -- Same as the `down' command while the new help is: > catch exception -- Catch Ada exceptions, when raised. > catch handlers -- Catch Ada exceptions, when handled. > catch syscall -- Catch system calls by their names, groups and/or numbers. > down-silently -- Same as the `down' command, but does not print anything. Also, the command help doc should not be terminated by a newline character, but this was not respected by all commands. The cli-option -OPT framework re-introduced some occurences. So, the -OPT build help framework was changed to not output newlines at the end of %OPTIONS% replacement. This patch changes the help documentations to ensure the 2 invariants given above. It implied to slightly rephrase or restructure some help docs. Based on the above invariants, print_doc_line (called by 'apropos' and 'help' commands to print the first line of a command help) now outputs the full first line of a command help. This all results in a lot of small changes in the produced help docs. There are less code changes than changes in the help docs, as a lot of docs are produced by some code (e.g. the remote packet usage settings). gdb/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.h (print_doc_line): Add for_value_prefix argument. * cli/cli-decode.c (print_doc_line): Likewise. It now prints the full first line, except when FOR_VALUE_PREFIX. In this case, the trailing '.' is not output, and the first character is uppercased. (print_help_for_command): Update call to print_doc_line. (print_doc_of_command): Likewise. * cli/cli-setshow.c (deprecated_show_value_hack): Likewise. * cli/cli-option.c (append_indented_doc): Do not append newline. (build_help_option): Append newline after first appended_indented_doc only if a second call is done. (build_help): Append 2 new lines before each option, except the first one. * compile/compile.c (_initialize_compile): Add new lines after %OPTIONS%, when not at the end of the help. Change help doc or code producing the help doc to respect the invariants. * maint-test-options.c (_initialize_maint_test_options): Likewise. Also removed the new line after 'Options:', as all other commands do not put an empty line between 'Options:' and the first option. * printcmd.c (_initialize_printcmd): Likewise. * stack.c (_initialize_stack): Likewise. * interps.c (interpreter_exec_cmd): Fix "Usage:" line that was incorrectly telling COMMAND is optional. * ada-lang.c (_initialize_ada_language): Change help doc or code producing the help doc to respect the invariants. * ada-tasks.c (_initialize_ada_tasks): Likewise. * breakpoint.c (_initialize_breakpoint): Likewise. * cli/cli-cmds.c (_initialize_cli_cmds): Likewise. * cli/cli-logging.c (_initialize_cli_logging): Likewise. * cli/cli-setshow.c (_initialize_cli_setshow): Likewise. * cli/cli-style.c (cli_style_option::add_setshow_commands, _initialize_cli_style): Likewise. * corelow.c (core_target_info): Likewise. * dwarf-index-cache.c (_initialize_index_cache): Likewise. * dwarf2read.c (_initialize_dwarf2_read): Likewise. * filesystem.c (_initialize_filesystem): Likewise. * frame.c (_initialize_frame): Likewise. * gnu-nat.c (add_task_commands): Likewise. * infcall.c (_initialize_infcall): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * interps.c (_initialize_interpreter): Likewise. * language.c (_initialize_language): Likewise. * linux-fork.c (_initialize_linux_fork): Likewise. * maint-test-settings.c (_initialize_maint_test_settings): Likewise. * maint.c (_initialize_maint_cmds): Likewise. * memattr.c (_initialize_mem): Likewise. * printcmd.c (_initialize_printcmd): Likewise. * python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq, _RegEx): Likewise. * ravenscar-thread.c (_initialize_ravenscar): Likewise. * record-btrace.c (_initialize_record_btrace): Likewise. * record-full.c (_initialize_record_full): Likewise. * record.c (_initialize_record): Likewise. * regcache-dump.c (_initialize_regcache_dump): Likewise. * regcache.c (_initialize_regcache): Likewise. * remote.c (add_packet_config_cmd, init_remote_threadtests, _initialize_remote): Likewise. * ser-tcp.c (_initialize_ser_tcp): Likewise. * serial.c (_initialize_serial): Likewise. * skip.c (_initialize_step_skip): Likewise. * source.c (_initialize_source): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * symtab.c (_initialize_symtab): Likewise. * target-descriptions.c (_initialize_target_descriptions): Likewise. * top.c (init_main): Likewise. * tracefile-tfile.c (tfile_target_info): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. * tui/tui-win.c (_initialize_tui_win): Likewise. * utils.c (add_internal_problem_command): Likewise. * valprint.c (value_print_option_defs): Likewise. gdb/testsuite/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Update tests for help doc new invariants. * gdb.base/help.exp: Likewise.
2019-06-09 11:16:20 +02:00
Enable or disable support for GNAT Ravenscar tasks."), _("\
Show whether support for GNAT Ravenscar tasks is enabled."),
_("\
Enable or disable support for task/thread switching with the GNAT\n\
Ravenscar run-time library for bareboard configuration."),
NULL, show_ravenscar_task_switching_command,
&set_ravenscar_list, &show_ravenscar_list);
}