binutils-gdb/gdb/x86-linux-nat.c

325 lines
8.9 KiB
C
Raw Permalink Normal View History

Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
/* Native-dependent code for GNU/Linux x86 (i386 and x86-64).
Copyright (C) 1999-2020 Free Software Foundation, Inc.
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "inferior.h"
#include "elf/common.h"
#include "gdb_proc_service.h"
#include "nat/gdb_ptrace.h"
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
#include <sys/user.h>
#include <sys/procfs.h>
#include <sys/uio.h>
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
#include "x86-nat.h"
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
#ifndef __x86_64__
#include "i386-linux-nat.h"
#endif
#include "x86-linux-nat.h"
#include "i386-linux-tdep.h"
#ifdef __x86_64__
#include "amd64-linux-tdep.h"
#endif
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/x86-xstate.h"
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
#include "nat/linux-btrace.h"
#include "nat/linux-nat.h"
2015-03-24 15:05:44 +01:00
#include "nat/x86-linux.h"
Move low-level Linux x86 debug register code to a shared file This commit moves the now-identical low-level Linux x86 debug register code from gdb/x86-linux-nat.c and gdb/gdbserver/linux-x86-low.c into a new shared file gdb/nat/x86-linux-dregs.c. gdb/ChangeLog: * nat/x86-linux-dregs.h: New file. * nat/x86-linux-dregs.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add nat/x86-linux-dregs.h. (x86-linux-dregs.o): New rule. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-dregs.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * x86-linux-nat.c: Include nat/x86-linux-dregs.h. (u_debugreg_offset): Moved to nat/x86-linux-dregs.c. (x86_linux_dr_get): Likewise. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_update_debug_registers): Likewise. gdb/gdbserver/ChangeLog: * Makefile.in (x86-linux-dregs.o): New rule. * configure.srv: Add x86-linux-dregs.o to relevant targets. * linux-x86-low.c: Include nat/x86-linux-dregs.h. (u_debugreg_offset): Moved to nat/x86-linux-dregs.c. (x86_linux_dr_get): Likewise. (x86_linux_dr_set): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (x86_linux_update_debug_registers): Likewise.
2015-03-24 15:05:45 +01:00
#include "nat/x86-linux-dregs.h"
#include "nat/linux-ptrace.h"
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
linux_nat_target: More low methods This converts the remaining linux-nat.c hooks low_ methods like had been started in a previous patch. The linux_nat_set_foo routines are all gone with this. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * linux-nat.h (linux_nat_target) <low_new_thread, low_delete_thread, low_new_fork, low_forget_process, low_prepare_to_resume, low_siginfo_fixup, low_status_is_event>: New virtual methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_new_fork_ftype, linux_nat_set_new_fork) (linux_nat_forget_process_ftype, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume, linux_nat_set_status_is_event): Delete. * linux-fork.c (delete_fork): Adjust to call low method. * linux-nat.c (linux_nat_new_thread, linux_nat_delete_thread) (linux_nat_new_fork, linux_nat_forget_process_hook) (linux_nat_prepare_to_resume, linux_nat_siginfo_fixup) (linux_nat_status_is_event): (linux_nat_target::follow_fork, lwp_free, add_lwp, detach_one_lwp) (linux_resume_one_lwp_throw, linux_handle_extended_wait): Adjust to call low method. (sigtrap_is_event): Rename to ... (linux_nat_target::low_status_is_event): ... this. (linux_nat_set_status_is_event): Delete. (save_stop_reason, linux_nat_wait_1) (linux_nat_target::mourn_inferior, siginfo_fixup): Adjust to call low methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_set_new_fork, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume): Delete. * aarch64-linux-nat.c: All linux_nat_set_* callbacks converted to low virtual methods. * amd64-linux-nat.c: Likewise. * arm-linux-nat.c: Likewise. * i386-linux-nat.c: Likewise. * ia64-linux-nat.c: Likewise. * mips-linux-nat.c: Likewise. * ppc-linux-nat.c: Likewise. * s390-linux-nat.c: Likewise. * sparc64-linux-nat.c: Likewise. * x86-linux-nat.c: Likewise. * x86-linux-nat.h: Include "nat/x86-linux.h". (x86_linux_nat_target) <low_new_fork, low_forget_process, low_prepare_to_resume, low_new_thread, low_delete_thread>: Override methods.
2018-05-03 01:37:27 +02:00
/* linux_nat_target::low_new_fork implementation. */
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
linux_nat_target: More low methods This converts the remaining linux-nat.c hooks low_ methods like had been started in a previous patch. The linux_nat_set_foo routines are all gone with this. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * linux-nat.h (linux_nat_target) <low_new_thread, low_delete_thread, low_new_fork, low_forget_process, low_prepare_to_resume, low_siginfo_fixup, low_status_is_event>: New virtual methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_new_fork_ftype, linux_nat_set_new_fork) (linux_nat_forget_process_ftype, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume, linux_nat_set_status_is_event): Delete. * linux-fork.c (delete_fork): Adjust to call low method. * linux-nat.c (linux_nat_new_thread, linux_nat_delete_thread) (linux_nat_new_fork, linux_nat_forget_process_hook) (linux_nat_prepare_to_resume, linux_nat_siginfo_fixup) (linux_nat_status_is_event): (linux_nat_target::follow_fork, lwp_free, add_lwp, detach_one_lwp) (linux_resume_one_lwp_throw, linux_handle_extended_wait): Adjust to call low method. (sigtrap_is_event): Rename to ... (linux_nat_target::low_status_is_event): ... this. (linux_nat_set_status_is_event): Delete. (save_stop_reason, linux_nat_wait_1) (linux_nat_target::mourn_inferior, siginfo_fixup): Adjust to call low methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_set_new_fork, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume): Delete. * aarch64-linux-nat.c: All linux_nat_set_* callbacks converted to low virtual methods. * amd64-linux-nat.c: Likewise. * arm-linux-nat.c: Likewise. * i386-linux-nat.c: Likewise. * ia64-linux-nat.c: Likewise. * mips-linux-nat.c: Likewise. * ppc-linux-nat.c: Likewise. * s390-linux-nat.c: Likewise. * sparc64-linux-nat.c: Likewise. * x86-linux-nat.c: Likewise. * x86-linux-nat.h: Include "nat/x86-linux.h". (x86_linux_nat_target) <low_new_fork, low_forget_process, low_prepare_to_resume, low_new_thread, low_delete_thread>: Override methods.
2018-05-03 01:37:27 +02:00
void
x86_linux_nat_target::low_new_fork (struct lwp_info *parent, pid_t child_pid)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
pid_t parent_pid;
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
struct x86_debug_reg_state *parent_state;
struct x86_debug_reg_state *child_state;
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
/* NULL means no watchpoint has ever been set in the parent. In
that case, there's nothing to do. */
if (parent->arch_private == NULL)
return;
/* Linux kernel before 2.6.33 commit
72f674d203cd230426437cdcf7dd6f681dad8b0d
will inherit hardware debug registers from parent
on fork/vfork/clone. Newer Linux kernels create such tasks with
zeroed debug registers.
GDB core assumes the child inherits the watchpoints/hw
breakpoints of the parent, and will remove them all from the
forked off process. Copy the debug registers mirrors into the
new process so that all breakpoints and watchpoints can be
removed together. The debug registers mirror will become zeroed
in the end before detaching the forked off process, thus making
this compatible with older Linux kernels too. */
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
parent_pid = parent->ptid.pid ();
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
parent_state = x86_debug_reg_state (parent_pid);
child_state = x86_debug_reg_state (child_pid);
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
*child_state = *parent_state;
}
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
x86_linux_nat_target::~x86_linux_nat_target ()
{
}
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02: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
x86_linux_nat_target::post_startup_inferior (ptid_t ptid)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
x86_cleanup_dregs ();
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
linux_nat_target::post_startup_inferior (ptid);
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
}
#ifdef __x86_64__
/* Value of CS segment register:
64bit process: 0x33
32bit process: 0x23 */
#define AMD64_LINUX_USER64_CS 0x33
/* Value of DS segment register:
LP64 process: 0x0
X32 process: 0x2b */
#define AMD64_LINUX_X32_DS 0x2b
#endif
/* Get Linux/x86 target description from running target. */
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 struct target_desc *
x86_linux_nat_target::read_description ()
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
int tid;
int is_64bit = 0;
#ifdef __x86_64__
int is_x32;
#endif
static uint64_t xcr0;
uint64_t xcr0_features_bits;
/* GNU/Linux LWP ID's are process ID's. */
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
tid = inferior_ptid.lwp ();
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
if (tid == 0)
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
tid = inferior_ptid.pid (); /* Not a threaded program. */
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
#ifdef __x86_64__
{
unsigned long cs;
unsigned long ds;
/* Get CS register. */
errno = 0;
cs = ptrace (PTRACE_PEEKUSER, tid,
offsetof (struct user_regs_struct, cs), 0);
if (errno != 0)
perror_with_name (_("Couldn't get CS register"));
is_64bit = cs == AMD64_LINUX_USER64_CS;
/* Get DS register. */
errno = 0;
ds = ptrace (PTRACE_PEEKUSER, tid,
offsetof (struct user_regs_struct, ds), 0);
if (errno != 0)
perror_with_name (_("Couldn't get DS register"));
is_x32 = ds == AMD64_LINUX_X32_DS;
if (sizeof (void *) == 4 && is_64bit && !is_x32)
error (_("Can't debug 64-bit process with 32-bit GDB"));
}
#elif HAVE_PTRACE_GETFPXREGS
if (have_ptrace_getfpxregs == -1)
{
elf_fpxregset_t fpxregs;
if (ptrace (PTRACE_GETFPXREGS, tid, 0, (int) &fpxregs) < 0)
{
have_ptrace_getfpxregs = 0;
Convert have_ptrace_getregset to a tri-state boolean have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have some conditions like "if (have_ptrace_getregset)", which is not correct. I'll explain why it is not correct in the following example. This fix to this problem to replace the test (have_ptrace_getregset) to test (have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc. However Doug thinks it hinders readability https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide to add a new enum tribool and change have_ptrace_getregset to it, in order to make these tests more readable. have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in $ARCH_linux_read_description according to the capability of the kernel. However, it is possible that have_ptrace_getregset is used before it is set to 0 or 1, which means it is still -1. This is shown below. (gdb) run Starting program: gdb/testsuite/gdb.base/break Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?p have_ptrace_getregset $1 = TRIBOOL_UNKNOWN top?c Continuing. Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?c Continuing. Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117 117 { PTRACE_GETREGSET command is used even GDB doesn't know whether PTRACE_GETREGSET is supported or not. It is wrong, but works on x86. However it doesn't work on arm-linux if the kernel doesn't support PTRACE_GETREGSET at all. We'll get: (gdb) run Starting program: gdb/testsuite/gdb.base/break warning: Unable to fetch general register. PC register is not available gdb: 2015-06-23 Yao Qi <yao.qi@linaro.org> * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister): Likewise. (fetch_fpregs, store_fpregister): Likewise. (store_fpregister, store_fpregs): Likewise. (fetch_register, fetch_regs): Likewise. (store_register, store_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Check have_ptrace_getregset is TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE or TRIBOOL_FALSE. * i386-linux-nat.c (fetch_xstateregs): Check have_ptrace_getregset is not TRIBOOL_TRUE. (store_xstateregs): Likewise. * linux-nat.c (have_ptrace_getregset): Change its type to enum tribool. * linux-nat.h (tribool): New enum. * x86-linux-nat.c (x86_linux_read_description): Use enum tribool. Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
have_ptrace_getregset = TRIBOOL_FALSE;
return i386_linux_read_description (X86_XSTATE_X87_MASK);
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
}
}
#endif
Convert have_ptrace_getregset to a tri-state boolean have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have some conditions like "if (have_ptrace_getregset)", which is not correct. I'll explain why it is not correct in the following example. This fix to this problem to replace the test (have_ptrace_getregset) to test (have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc. However Doug thinks it hinders readability https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide to add a new enum tribool and change have_ptrace_getregset to it, in order to make these tests more readable. have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in $ARCH_linux_read_description according to the capability of the kernel. However, it is possible that have_ptrace_getregset is used before it is set to 0 or 1, which means it is still -1. This is shown below. (gdb) run Starting program: gdb/testsuite/gdb.base/break Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?p have_ptrace_getregset $1 = TRIBOOL_UNKNOWN top?c Continuing. Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?c Continuing. Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117 117 { PTRACE_GETREGSET command is used even GDB doesn't know whether PTRACE_GETREGSET is supported or not. It is wrong, but works on x86. However it doesn't work on arm-linux if the kernel doesn't support PTRACE_GETREGSET at all. We'll get: (gdb) run Starting program: gdb/testsuite/gdb.base/break warning: Unable to fetch general register. PC register is not available gdb: 2015-06-23 Yao Qi <yao.qi@linaro.org> * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister): Likewise. (fetch_fpregs, store_fpregister): Likewise. (store_fpregister, store_fpregs): Likewise. (fetch_register, fetch_regs): Likewise. (store_register, store_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Check have_ptrace_getregset is TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE or TRIBOOL_FALSE. * i386-linux-nat.c (fetch_xstateregs): Check have_ptrace_getregset is not TRIBOOL_TRUE. (store_xstateregs): Likewise. * linux-nat.c (have_ptrace_getregset): Change its type to enum tribool. * linux-nat.h (tribool): New enum. * x86-linux-nat.c (x86_linux_read_description): Use enum tribool. Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
uint64_t xstateregs[(X86_XSTATE_SSE_SIZE / sizeof (uint64_t))];
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
struct iovec iov;
iov.iov_base = xstateregs;
iov.iov_len = sizeof (xstateregs);
/* Check if PTRACE_GETREGSET works. */
if (ptrace (PTRACE_GETREGSET, tid,
(unsigned int) NT_X86_XSTATE, &iov) < 0)
Convert have_ptrace_getregset to a tri-state boolean have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have some conditions like "if (have_ptrace_getregset)", which is not correct. I'll explain why it is not correct in the following example. This fix to this problem to replace the test (have_ptrace_getregset) to test (have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc. However Doug thinks it hinders readability https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide to add a new enum tribool and change have_ptrace_getregset to it, in order to make these tests more readable. have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in $ARCH_linux_read_description according to the capability of the kernel. However, it is possible that have_ptrace_getregset is used before it is set to 0 or 1, which means it is still -1. This is shown below. (gdb) run Starting program: gdb/testsuite/gdb.base/break Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?p have_ptrace_getregset $1 = TRIBOOL_UNKNOWN top?c Continuing. Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?c Continuing. Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117 117 { PTRACE_GETREGSET command is used even GDB doesn't know whether PTRACE_GETREGSET is supported or not. It is wrong, but works on x86. However it doesn't work on arm-linux if the kernel doesn't support PTRACE_GETREGSET at all. We'll get: (gdb) run Starting program: gdb/testsuite/gdb.base/break warning: Unable to fetch general register. PC register is not available gdb: 2015-06-23 Yao Qi <yao.qi@linaro.org> * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister): Likewise. (fetch_fpregs, store_fpregister): Likewise. (store_fpregister, store_fpregs): Likewise. (fetch_register, fetch_regs): Likewise. (store_register, store_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Check have_ptrace_getregset is TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE or TRIBOOL_FALSE. * i386-linux-nat.c (fetch_xstateregs): Check have_ptrace_getregset is not TRIBOOL_TRUE. (store_xstateregs): Likewise. * linux-nat.c (have_ptrace_getregset): Change its type to enum tribool. * linux-nat.h (tribool): New enum. * x86-linux-nat.c (x86_linux_read_description): Use enum tribool. Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
have_ptrace_getregset = TRIBOOL_FALSE;
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
else
{
Convert have_ptrace_getregset to a tri-state boolean have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have some conditions like "if (have_ptrace_getregset)", which is not correct. I'll explain why it is not correct in the following example. This fix to this problem to replace the test (have_ptrace_getregset) to test (have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc. However Doug thinks it hinders readability https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide to add a new enum tribool and change have_ptrace_getregset to it, in order to make these tests more readable. have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in $ARCH_linux_read_description according to the capability of the kernel. However, it is possible that have_ptrace_getregset is used before it is set to 0 or 1, which means it is still -1. This is shown below. (gdb) run Starting program: gdb/testsuite/gdb.base/break Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?p have_ptrace_getregset $1 = TRIBOOL_UNKNOWN top?c Continuing. Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?c Continuing. Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117 117 { PTRACE_GETREGSET command is used even GDB doesn't know whether PTRACE_GETREGSET is supported or not. It is wrong, but works on x86. However it doesn't work on arm-linux if the kernel doesn't support PTRACE_GETREGSET at all. We'll get: (gdb) run Starting program: gdb/testsuite/gdb.base/break warning: Unable to fetch general register. PC register is not available gdb: 2015-06-23 Yao Qi <yao.qi@linaro.org> * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister): Likewise. (fetch_fpregs, store_fpregister): Likewise. (store_fpregister, store_fpregs): Likewise. (fetch_register, fetch_regs): Likewise. (store_register, store_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Check have_ptrace_getregset is TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE or TRIBOOL_FALSE. * i386-linux-nat.c (fetch_xstateregs): Check have_ptrace_getregset is not TRIBOOL_TRUE. (store_xstateregs): Likewise. * linux-nat.c (have_ptrace_getregset): Change its type to enum tribool. * linux-nat.h (tribool): New enum. * x86-linux-nat.c (x86_linux_read_description): Use enum tribool. Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
have_ptrace_getregset = TRIBOOL_TRUE;
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
/* Get XCR0 from XSAVE extended state. */
xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
/ sizeof (uint64_t))];
}
}
/* Check the native XCR0 only if PTRACE_GETREGSET is available. If
PTRACE_GETREGSET is not available then set xcr0_features_bits to
zero so that the "no-features" descriptions are returned by the
switches below. */
Convert have_ptrace_getregset to a tri-state boolean have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have some conditions like "if (have_ptrace_getregset)", which is not correct. I'll explain why it is not correct in the following example. This fix to this problem to replace the test (have_ptrace_getregset) to test (have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc. However Doug thinks it hinders readability https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide to add a new enum tribool and change have_ptrace_getregset to it, in order to make these tests more readable. have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in $ARCH_linux_read_description according to the capability of the kernel. However, it is possible that have_ptrace_getregset is used before it is set to 0 or 1, which means it is still -1. This is shown below. (gdb) run Starting program: gdb/testsuite/gdb.base/break Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?p have_ptrace_getregset $1 = TRIBOOL_UNKNOWN top?c Continuing. Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128 128 { top?c Continuing. Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117 117 { PTRACE_GETREGSET command is used even GDB doesn't know whether PTRACE_GETREGSET is supported or not. It is wrong, but works on x86. However it doesn't work on arm-linux if the kernel doesn't support PTRACE_GETREGSET at all. We'll get: (gdb) run Starting program: gdb/testsuite/gdb.base/break warning: Unable to fetch general register. PC register is not available gdb: 2015-06-23 Yao Qi <yao.qi@linaro.org> * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly. (amd64_linux_store_inferior_registers): Likewise. * arm-linux-nat.c (fetch_fpregister): Likewise. (fetch_fpregs, store_fpregister): Likewise. (store_fpregister, store_fpregs): Likewise. (fetch_register, fetch_regs): Likewise. (store_register, store_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Check have_ptrace_getregset is TRIBOOL_UNKNOWN. Set have_ptrace_getregset to TRIBOOL_TRUE or TRIBOOL_FALSE. * i386-linux-nat.c (fetch_xstateregs): Check have_ptrace_getregset is not TRIBOOL_TRUE. (store_xstateregs): Likewise. * linux-nat.c (have_ptrace_getregset): Change its type to enum tribool. * linux-nat.h (tribool): New enum. * x86-linux-nat.c (x86_linux_read_description): Use enum tribool. Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 15:03:11 +02:00
if (have_ptrace_getregset == TRIBOOL_TRUE)
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
xcr0_features_bits = xcr0 & X86_XSTATE_ALL_MASK;
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
else
xcr0_features_bits = 0;
if (is_64bit)
{
#ifdef __x86_64__
return amd64_linux_read_description (xcr0_features_bits, is_x32);
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
#endif
}
else
{
const struct target_desc * tdesc
= i386_linux_read_description (xcr0_features_bits);
if (tdesc == NULL)
tdesc = i386_linux_read_description (X86_XSTATE_SSE_MASK);
return tdesc;
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
}
gdb_assert_not_reached ("failed to return tdesc");
}
/* Enable branch tracing. */
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 btrace_target_info *
x86_linux_nat_target::enable_btrace (ptid_t ptid,
const struct btrace_config *conf)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
struct btrace_target_info *tinfo = nullptr;
Rewrite TRY/CATCH This rewrites gdb's TRY/CATCH to plain C++ try/catch. The patch was largely written by script, though one change (to a comment in common-exceptions.h) was reverted by hand. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c: Use C++ exception handling. * x86-linux-nat.c: Use C++ exception handling. * windows-nat.c: Use C++ exception handling. * varobj.c: Use C++ exception handling. * value.c: Use C++ exception handling. * valprint.c: Use C++ exception handling. * valops.c: Use C++ exception handling. * unittests/parse-connection-spec-selftests.c: Use C++ exception handling. * unittests/cli-utils-selftests.c: Use C++ exception handling. * typeprint.c: Use C++ exception handling. * tui/tui.c: Use C++ exception handling. * tracefile-tfile.c: Use C++ exception handling. * top.c: Use C++ exception handling. * thread.c: Use C++ exception handling. * target.c: Use C++ exception handling. * symmisc.c: Use C++ exception handling. * symfile-mem.c: Use C++ exception handling. * stack.c: Use C++ exception handling. * sparc64-linux-tdep.c: Use C++ exception handling. * solib.c: Use C++ exception handling. * solib-svr4.c: Use C++ exception handling. * solib-spu.c: Use C++ exception handling. * solib-frv.c: Use C++ exception handling. * solib-dsbt.c: Use C++ exception handling. * selftest-arch.c: Use C++ exception handling. * s390-tdep.c: Use C++ exception handling. * rust-lang.c: Use C++ exception handling. * rust-exp.y: Use C++ exception handling. * rs6000-tdep.c: Use C++ exception handling. * rs6000-aix-tdep.c: Use C++ exception handling. * riscv-tdep.c: Use C++ exception handling. * remote.c: Use C++ exception handling. * remote-fileio.c: Use C++ exception handling. * record-full.c: Use C++ exception handling. * record-btrace.c: Use C++ exception handling. * python/python.c: Use C++ exception handling. * python/py-value.c: Use C++ exception handling. * python/py-utils.c: Use C++ exception handling. * python/py-unwind.c: Use C++ exception handling. * python/py-type.c: Use C++ exception handling. * python/py-symbol.c: Use C++ exception handling. * python/py-record.c: Use C++ exception handling. * python/py-record-btrace.c: Use C++ exception handling. * python/py-progspace.c: Use C++ exception handling. * python/py-prettyprint.c: Use C++ exception handling. * python/py-param.c: Use C++ exception handling. * python/py-objfile.c: Use C++ exception handling. * python/py-linetable.c: Use C++ exception handling. * python/py-lazy-string.c: Use C++ exception handling. * python/py-infthread.c: Use C++ exception handling. * python/py-inferior.c: Use C++ exception handling. * python/py-gdb-readline.c: Use C++ exception handling. * python/py-framefilter.c: Use C++ exception handling. * python/py-frame.c: Use C++ exception handling. * python/py-finishbreakpoint.c: Use C++ exception handling. * python/py-cmd.c: Use C++ exception handling. * python/py-breakpoint.c: Use C++ exception handling. * python/py-arch.c: Use C++ exception handling. * printcmd.c: Use C++ exception handling. * ppc-linux-tdep.c: Use C++ exception handling. * parse.c: Use C++ exception handling. * p-valprint.c: Use C++ exception handling. * objc-lang.c: Use C++ exception handling. * mi/mi-main.c: Use C++ exception handling. * mi/mi-interp.c: Use C++ exception handling. * mi/mi-cmd-stack.c: Use C++ exception handling. * mi/mi-cmd-break.c: Use C++ exception handling. * main.c: Use C++ exception handling. * linux-thread-db.c: Use C++ exception handling. * linux-tdep.c: Use C++ exception handling. * linux-nat.c: Use C++ exception handling. * linux-fork.c: Use C++ exception handling. * linespec.c: Use C++ exception handling. * language.c: Use C++ exception handling. * jit.c: Use C++ exception handling. * infrun.c: Use C++ exception handling. * infcmd.c: Use C++ exception handling. * infcall.c: Use C++ exception handling. * inf-loop.c: Use C++ exception handling. * i386-tdep.c: Use C++ exception handling. * i386-linux-tdep.c: Use C++ exception handling. * guile/scm-value.c: Use C++ exception handling. * guile/scm-type.c: Use C++ exception handling. * guile/scm-symtab.c: Use C++ exception handling. * guile/scm-symbol.c: Use C++ exception handling. * guile/scm-pretty-print.c: Use C++ exception handling. * guile/scm-ports.c: Use C++ exception handling. * guile/scm-param.c: Use C++ exception handling. * guile/scm-math.c: Use C++ exception handling. * guile/scm-lazy-string.c: Use C++ exception handling. * guile/scm-frame.c: Use C++ exception handling. * guile/scm-disasm.c: Use C++ exception handling. * guile/scm-cmd.c: Use C++ exception handling. * guile/scm-breakpoint.c: Use C++ exception handling. * guile/scm-block.c: Use C++ exception handling. * guile/guile-internal.h: Use C++ exception handling. * gnu-v3-abi.c: Use C++ exception handling. * gdbtypes.c: Use C++ exception handling. * frame.c: Use C++ exception handling. * frame-unwind.c: Use C++ exception handling. * fbsd-tdep.c: Use C++ exception handling. * f-valprint.c: Use C++ exception handling. * exec.c: Use C++ exception handling. * event-top.c: Use C++ exception handling. * event-loop.c: Use C++ exception handling. * eval.c: Use C++ exception handling. * dwarf2read.c: Use C++ exception handling. * dwarf2loc.c: Use C++ exception handling. * dwarf2-frame.c: Use C++ exception handling. * dwarf2-frame-tailcall.c: Use C++ exception handling. * dwarf-index-write.c: Use C++ exception handling. * dwarf-index-cache.c: Use C++ exception handling. * dtrace-probe.c: Use C++ exception handling. * disasm-selftests.c: Use C++ exception handling. * darwin-nat.c: Use C++ exception handling. * cp-valprint.c: Use C++ exception handling. * cp-support.c: Use C++ exception handling. * cp-abi.c: Use C++ exception handling. * corelow.c: Use C++ exception handling. * completer.c: Use C++ exception handling. * compile/compile-object-run.c: Use C++ exception handling. * compile/compile-object-load.c: Use C++ exception handling. * compile/compile-cplus-symbols.c: Use C++ exception handling. * compile/compile-c-symbols.c: Use C++ exception handling. * common/selftest.c: Use C++ exception handling. * common/new-op.c: Use C++ exception handling. * cli/cli-script.c: Use C++ exception handling. * cli/cli-interp.c: Use C++ exception handling. * cli/cli-cmds.c: Use C++ exception handling. * c-varobj.c: Use C++ exception handling. * btrace.c: Use C++ exception handling. * breakpoint.c: Use C++ exception handling. * break-catch-throw.c: Use C++ exception handling. * arch-utils.c: Use C++ exception handling. * amd64-tdep.c: Use C++ exception handling. * ada-valprint.c: Use C++ exception handling. * ada-typeprint.c: Use C++ exception handling. * ada-lang.c: Use C++ exception handling. * aarch64-tdep.c: Use C++ exception handling. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c: Use C++ exception handling. * linux-low.c: Use C++ exception handling. * gdbreplay.c: Use C++ exception handling.
2019-04-04 00:02:42 +02:00
try
{
tinfo = linux_enable_btrace (ptid, conf);
}
Rename gdb exception types This renames the gdb exception types. The old types were only needed due to the macros in common-exception.h that are now gone. The intermediate layer of gdb_exception_RETURN_MASK_ALL did not seem needed, so this patch removes it entirely. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * common/common-exceptions.h (gdb_exception_RETURN_MASK_ALL): Remove. (gdb_exception_error): Rename from gdb_exception_RETURN_MASK_ERROR. (gdb_exception_quit): Rename from gdb_exception_RETURN_MASK_QUIT. (gdb_quit_bad_alloc): Update. * aarch64-tdep.c: Update. * ada-lang.c: Update. * ada-typeprint.c: Update. * ada-valprint.c: Update. * amd64-tdep.c: Update. * arch-utils.c: Update. * break-catch-throw.c: Update. * breakpoint.c: Update. * btrace.c: Update. * c-varobj.c: Update. * cli/cli-cmds.c: Update. * cli/cli-interp.c: Update. * cli/cli-script.c: Update. * common/common-exceptions.c: Update. * common/new-op.c: Update. * common/selftest.c: Update. * compile/compile-c-symbols.c: Update. * compile/compile-cplus-symbols.c: Update. * compile/compile-object-load.c: Update. * compile/compile-object-run.c: Update. * completer.c: Update. * corelow.c: Update. * cp-abi.c: Update. * cp-support.c: Update. * cp-valprint.c: Update. * darwin-nat.c: Update. * disasm-selftests.c: Update. * dtrace-probe.c: Update. * dwarf-index-cache.c: Update. * dwarf-index-write.c: Update. * dwarf2-frame-tailcall.c: Update. * dwarf2-frame.c: Update. * dwarf2loc.c: Update. * dwarf2read.c: Update. * eval.c: Update. * event-loop.c: Update. * event-top.c: Update. * exec.c: Update. * f-valprint.c: Update. * fbsd-tdep.c: Update. * frame-unwind.c: Update. * frame.c: Update. * gdbtypes.c: Update. * gnu-v3-abi.c: Update. * guile/guile-internal.h: Update. * guile/scm-block.c: Update. * guile/scm-breakpoint.c: Update. * guile/scm-cmd.c: Update. * guile/scm-disasm.c: Update. * guile/scm-frame.c: Update. * guile/scm-lazy-string.c: Update. * guile/scm-math.c: Update. * guile/scm-param.c: Update. * guile/scm-ports.c: Update. * guile/scm-pretty-print.c: Update. * guile/scm-symbol.c: Update. * guile/scm-symtab.c: Update. * guile/scm-type.c: Update. * guile/scm-value.c: Update. * i386-linux-tdep.c: Update. * i386-tdep.c: Update. * inf-loop.c: Update. * infcall.c: Update. * infcmd.c: Update. * infrun.c: Update. * jit.c: Update. * language.c: Update. * linespec.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * main.c: Update. * mi/mi-cmd-break.c: Update. * mi/mi-cmd-stack.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * objc-lang.c: Update. * p-valprint.c: Update. * parse.c: Update. * ppc-linux-tdep.c: Update. * printcmd.c: Update. * python/py-arch.c: Update. * python/py-breakpoint.c: Update. * python/py-cmd.c: Update. * python/py-finishbreakpoint.c: Update. * python/py-frame.c: Update. * python/py-framefilter.c: Update. * python/py-gdb-readline.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * python/py-lazy-string.c: Update. * python/py-linetable.c: Update. * python/py-objfile.c: Update. * python/py-param.c: Update. * python/py-prettyprint.c: Update. * python/py-progspace.c: Update. * python/py-record-btrace.c: Update. * python/py-record.c: Update. * python/py-symbol.c: Update. * python/py-type.c: Update. * python/py-unwind.c: Update. * python/py-utils.c: Update. * python/py-value.c: Update. * python/python.c: Update. * record-btrace.c: Update. * record-full.c: Update. * remote-fileio.c: Update. * remote.c: Update. * riscv-tdep.c: Update. * rs6000-aix-tdep.c: Update. * rs6000-tdep.c: Update. * rust-exp.y: Update. * rust-lang.c: Update. * s390-tdep.c: Update. * selftest-arch.c: Update. * solib-dsbt.c: Update. * solib-frv.c: Update. * solib-spu.c: Update. * solib-svr4.c: Update. * solib.c: Update. * sparc64-linux-tdep.c: Update. * stack.c: Update. * symfile-mem.c: Update. * symmisc.c: Update. * target.c: Update. * thread.c: Update. * top.c: Update. * tracefile-tfile.c: Update. * tui/tui.c: Update. * typeprint.c: Update. * unittests/cli-utils-selftests.c: Update. * unittests/parse-connection-spec-selftests.c: Update. * valops.c: Update. * valprint.c: Update. * value.c: Update. * varobj.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * xml-support.c: Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * gdbreplay.c: Update. * linux-low.c: Update. * server.c: Update.
2019-04-03 23:59:07 +02:00
catch (const gdb_exception_error &exception)
{
error (_("Could not enable branch tracing for %s: %s"),
Make exceptions use std::string and be self-managing This changes the exception's "message" member to be a shared_ptr wrapping a std::string. This allows removing the stack of exception messages, because now exceptions will self-destruct when needed. This also adds a noexcept copy constructor and operator= to gdb_exception, plus a "what" method. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c (gdb_xml_parser::parse): Update. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * value.c (show_convenience): Update. * unittests/cli-utils-selftests.c (test_number_or_range_parser) (test_parse_flags_qcs): Update. * thread.c (thr_try_catch_cmd): Update. * target.c (target_translate_tls_address): Update. * stack.c (print_frame_arg, read_frame_local, read_frame_arg) (info_frame_command_core, frame_apply_command_count): Update. * rust-exp.y (rust_lex_exception_test): Update. * riscv-tdep.c (riscv_print_one_register_info): Update. * remote.c (remote_target::enable_btrace): Update. * record-btrace.c (record_btrace_enable_warn): Update. * python/py-utils.c (gdbpy_convert_exception): Update. * printcmd.c (do_one_display, print_variable_and_value): Update. * mi/mi-main.c (mi_print_exception): Update. * mi/mi-interp.c (mi_cmd_interpreter_exec): Use SCOPE_EXIT. * mi/mi-cmd-stack.c (list_arg_or_local): Update. * linux-nat.c (linux_nat_target::attach): Update. * linux-fork.c (class scoped_switch_fork_info): Update. * infrun.c (displaced_step_prepare): Update. * infcall.c (call_function_by_hand_dummy): Update. * guile/scm-exception.c (gdbscm_scm_from_gdb_exception): Update. * gnu-v3-abi.c (print_one_vtable): Update. * frame.c (get_prev_frame_always): Update. * f-valprint.c (info_common_command_for_block): Update. * exec.c (try_open_exec_file): Update. * exceptions.c (print_exception, exception_print) (exception_fprintf, exception_print_same): Update. * dwarf2-frame.c (dwarf2_build_frame_info): Update. * dwarf-index-cache.c (index_cache::store) (index_cache::lookup_gdb_index): Update. * darwin-nat.c (maybe_cache_shell): Update. * cp-valprint.c (cp_print_value_fields): Update. * compile/compile-cplus-symbols.c (gcc_cplus_convert_symbol) (gcc_cplus_symbol_address): Update. * compile/compile-c-symbols.c (gcc_convert_symbol) (gcc_symbol_address, generate_c_for_for_one_variable): Update. * common/selftest.c: Update. * common/common-exceptions.h (struct gdb_exception) <message>: Now a std::string. (exception_try_scope_entry, exception_try_scope_exit): Don't declare. (struct exception_try_scope): Remove. (TRY): Don't use exception_try_scope. (struct gdb_exception): Add constructor, operator=. <what>: New method. (struct gdb_exception_RETURN_MASK_ALL) (struct gdb_exception_RETURN_MASK_ERROR) (struct gdb_exception_RETURN_MASK_QUIT): Add constructor. (struct gdb_quit_bad_alloc): Update. * common/common-exceptions.c (exception_none): Change initializer. (struct catcher) <state, exception>: Initialize inline. <prev>: Remove member. (current_catcher): Remove. (catchers): New global. (exceptions_state_mc_init): Simplify. (catcher_pop): Remove. (exceptions_state_mc, exceptions_state_mc_catch): Update. (try_scope_depth, exception_try_scope_entry) (exception_try_scope_exit): Remove. (throw_exception_sjlj): Update. (exception_messages, exception_messages_size): Remove. (throw_it): Simplify. (gdb_exception_sliced_copy): Remove. (throw_exception_cxx): Update. * cli/cli-script.c (script_from_file): Update. * breakpoint.c (insert_bp_location, update_breakpoint_locations): Update. * ada-valprint.c (ada_val_print): Update. * ada-lang.c (ada_to_fixed_type_1, ada_exception_name_addr) (create_excep_cond_exprs): Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c (handle_btrace_general_set, handle_qxfer_btrace) (handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup) (captured_main, main): Update. * gdbreplay.c (main): Update.
2019-01-28 18:11:10 +01:00
target_pid_to_str (ptid).c_str (), exception.what ());
}
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
return tinfo;
}
/* Disable branch tracing. */
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
x86_linux_nat_target::disable_btrace (struct btrace_target_info *tinfo)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
enum btrace_error errcode = linux_disable_btrace (tinfo);
if (errcode != BTRACE_ERR_NONE)
error (_("Could not disable branch tracing."));
}
/* Teardown branch tracing. */
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
x86_linux_nat_target::teardown_btrace (struct btrace_target_info *tinfo)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
/* Ignore errors. */
linux_disable_btrace (tinfo);
}
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
enum btrace_error
x86_linux_nat_target::read_btrace (struct btrace_data *data,
struct btrace_target_info *btinfo,
enum btrace_read_type type)
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
return linux_read_btrace (data, btinfo, type);
}
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
/* See to_btrace_conf in target.h. */
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 struct btrace_config *
x86_linux_nat_target::btrace_conf (const struct btrace_target_info *btinfo)
record btrace: add configuration struct Add a struct to describe the branch trace configuration and use it for enabling branch tracing. The user will be able to set configuration fields for each tracing format to be used for new threads. The actual configuration that is active for a given thread will be shown in the "info record" command. At the moment, the configuration struct only contains a format field that is set to the only available format. The format is the only configuration option that can not be set via set commands. It is given as argument to the "record btrace" command when starting recording. 2015-02-09 Markus Metzger <markus.t.metzger@intel.com> * Makefile.in (XMLFILES): Add btrace-conf.dtd. * x86-linux-nat.c (x86_linux_enable_btrace): Update parameters. (x86_linux_btrace_conf): New. (x86_linux_create_target): Initialize to_btrace_conf. * nat/linux-btrace.c (linux_enable_btrace): Update parameters. Check format. Split into this and ... (linux_enable_bts): ... this. (linux_btrace_conf): New. (perf_event_skip_record): Renamed into ... (perf_event_skip_bts_record): ... this. Updated users. (linux_disable_btrace): Split into this and ... (linux_disable_bts): ... this. (linux_read_btrace): Check format. * nat/linux-btrace.h (linux_enable_btrace): Update parameters. (linux_btrace_conf): New. (btrace_target_info)<ptid>: Moved. (btrace_target_info)<conf>: New. (btrace_target_info): Split into this and ... (btrace_tinfo_bts): ... this. Updated users. * btrace.c (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf) (btrace_conf_children, btrace_conf_attributes) (btrace_conf_elements): New. * btrace.h (btrace_enable): Update parameters. (btrace_conf, parse_xml_btrace_conf): New. * common/btrace-common.h (btrace_config): New. * feature/btrace-conf.dtd: New. * record-btrace.c (record_btrace_conf): New. (record_btrace_cmdlist): New. (record_btrace_enable_warn, record_btrace_open): Pass &record_btrace_conf. (record_btrace_info): Print recording format. (cmd_record_btrace_bts_start): New. (cmd_record_btrace_start): Call cmd_record_btrace_bts_start. (_initialize_record_btrace): Add "record btrace bts" subcommand. Add "record bts" alias command. * remote.c (remote_state)<btrace_config>: New. (remote_btrace_reset, PACKET_qXfer_btrace_conf): New. (remote_protocol_features): Add qXfer:btrace-conf:read. (remote_open_1): Call remote_btrace_reset. (remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF. (btrace_target_info)<conf>: New. (btrace_sync_conf, btrace_read_config): New. (remote_enable_btrace): Update parameters. Call btrace_sync_conf and btrace_read_conf. (remote_btrace_conf): New. (init_remote_ops): Initialize to_btrace_conf. (_initialize_remote): Add qXfer:btrace-conf packet. * target.c (target_enable_btrace): Update parameters. (target_btrace_conf): New. * target.h (target_enable_btrace): Update parameters. (target_btrace_conf): New. (target_object)<TARGET_OBJECT_BTRACE_CONF>: New. (target_ops)<to_enable_btrace>: Update parameters and comment. (target_ops)<to_btrace_conf>: New. * target-delegates: Regenerate. * target-debug.h (target_debug_print_const_struct_btrace_config_p) (target_debug_print_const_struct_btrace_target_info_p): New. NEWS: Announce new command and new packet. doc/ * gdb.texinfo (Process Record and Replay): Describe the "record btrace bts" command. (General Query Packets): Describe qXfer:btrace-conf:read packet. (Branch Trace Configuration Format): New. gdbserver/ * linux-low.c (linux_low_enable_btrace): Update parameters. (linux_low_btrace_conf): New. (linux_target_ops)<to_btrace_conf>: Initialize. * server.c (current_btrace_conf): New. (handle_btrace_enable): Rename to ... (handle_btrace_enable_bts): ... this. Pass &current_btrace_conf to target_enable_btrace. Update comment. Update users. (handle_qxfer_btrace_conf): New. (qxfer_packets): Add btrace-conf entry. (handle_query): Report qXfer:btrace-conf:read as supported packet. * target.h (target_ops)<enable_btrace>: Update parameters and comment. (target_ops)<read_btrace_conf>: New. (target_enable_btrace): Update parameters. (target_read_btrace_conf): New. testsuite/ * gdb.btrace/delta.exp: Update "info record" output. * gdb.btrace/enable.exp: Update "info record" output. * gdb.btrace/finish.exp: Update "info record" output. * gdb.btrace/instruction_history.exp: Update "info record" output. * gdb.btrace/next.exp: Update "info record" output. * gdb.btrace/nexti.exp: Update "info record" output. * gdb.btrace/step.exp: Update "info record" output. * gdb.btrace/stepi.exp: Update "info record" output. * gdb.btrace/nohist.exp: Update "info record" output.
2013-11-28 15:44:13 +01:00
{
return linux_btrace_conf (btinfo);
}
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
/* Helper for ps_get_thread_area. Sets BASE_ADDR to a pointer to
the thread local storage (or its descriptor) and returns PS_OK
on success. Returns PS_ERR on failure. */
ps_err_e
x86_linux_get_thread_area (pid_t pid, void *addr, unsigned int *base_addr)
{
/* NOTE: cagney/2003-08-26: The definition of this buffer is found
in the kernel header <asm-i386/ldt.h>. It, after padding, is 4 x
4 byte integers in size: `entry_number', `base_addr', `limit',
and a bunch of status bits.
The values returned by this ptrace call should be part of the
regcache buffer, and ps_get_thread_area should channel its
request through the regcache. That way remote targets could
provide the value using the remote protocol and not this direct
call.
Is this function needed? I'm guessing that the `base' is the
address of a descriptor that libthread_db uses to find the
thread local address base that GDB needs. Perhaps that
descriptor is defined by the ABI. Anyway, given that
libthread_db calls this function without prompting (gdb
requesting tls base) I guess it needs info in there anyway. */
unsigned int desc[4];
/* This code assumes that "int" is 32 bits and that
GET_THREAD_AREA returns no more than 4 int values. */
gdb_assert (sizeof (int) == 4);
#ifndef PTRACE_GET_THREAD_AREA
#define PTRACE_GET_THREAD_AREA 25
#endif
if (ptrace (PTRACE_GET_THREAD_AREA, pid, addr, &desc) < 0)
return PS_ERR;
*base_addr = desc[1];
return PS_OK;
}
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_x86_linux_nat ();
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
linux_nat_target: More low methods This converts the remaining linux-nat.c hooks low_ methods like had been started in a previous patch. The linux_nat_set_foo routines are all gone with this. gdb/ChangeLog: 2018-05-02 Pedro Alves <palves@redhat.com> * linux-nat.h (linux_nat_target) <low_new_thread, low_delete_thread, low_new_fork, low_forget_process, low_prepare_to_resume, low_siginfo_fixup, low_status_is_event>: New virtual methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_new_fork_ftype, linux_nat_set_new_fork) (linux_nat_forget_process_ftype, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume, linux_nat_set_status_is_event): Delete. * linux-fork.c (delete_fork): Adjust to call low method. * linux-nat.c (linux_nat_new_thread, linux_nat_delete_thread) (linux_nat_new_fork, linux_nat_forget_process_hook) (linux_nat_prepare_to_resume, linux_nat_siginfo_fixup) (linux_nat_status_is_event): (linux_nat_target::follow_fork, lwp_free, add_lwp, detach_one_lwp) (linux_resume_one_lwp_throw, linux_handle_extended_wait): Adjust to call low method. (sigtrap_is_event): Rename to ... (linux_nat_target::low_status_is_event): ... this. (linux_nat_set_status_is_event): Delete. (save_stop_reason, linux_nat_wait_1) (linux_nat_target::mourn_inferior, siginfo_fixup): Adjust to call low methods. (linux_nat_set_new_thread, linux_nat_set_delete_thread) (linux_nat_set_new_fork, linux_nat_set_forget_process) (linux_nat_forget_process, linux_nat_set_siginfo_fixup) (linux_nat_set_prepare_to_resume): Delete. * aarch64-linux-nat.c: All linux_nat_set_* callbacks converted to low virtual methods. * amd64-linux-nat.c: Likewise. * arm-linux-nat.c: Likewise. * i386-linux-nat.c: Likewise. * ia64-linux-nat.c: Likewise. * mips-linux-nat.c: Likewise. * ppc-linux-nat.c: Likewise. * s390-linux-nat.c: Likewise. * sparc64-linux-nat.c: Likewise. * x86-linux-nat.c: Likewise. * x86-linux-nat.h: Include "nat/x86-linux.h". (x86_linux_nat_target) <low_new_fork, low_forget_process, low_prepare_to_resume, low_new_thread, low_delete_thread>: Override methods.
2018-05-03 01:37:27 +02:00
_initialize_x86_linux_nat ()
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
{
/* Initialize the debug register function vectors. */
Rename 32- and 64-bit Intel files from "i386" to "x86" This commit renames nine files that contain code used by both 32- and 64-bit Intel ports such that their names are prefixed with "x86" rather than "i386". All types, functions and variables within these files are likewise renamed such that their names are prefixed with "x86" rather than "i386". This makes GDB follow the convention used by gdbserver such that 32-bit Intel code lives in files called "i386-*", 64-bit Intel code lives in files called "amd64-*", and code for both 32- and 64-bit Intel lives in files called "x86-*". This commit only renames OS-independent files. The Linux ports of both GDB and gdbserver now follow the i386/amd64/x86 convention fully. Some ports still use the old convention where "i386" in file/function/ type/variable names can mean "32-bit only" or "32- and 64-bit" but I don't want to touch ports I can't fully test except where absolutely necessary. gdb/ChangeLog: * i386-nat.h: Renamed as... * x86-nat.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-nat.c: Renamed as... * x86-nat.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * common/i386-xstate.h: Renamed as... * common/x86-xstate.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-cpuid.h: Renamed as... * nat/x86-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-gcc-cpuid.h: Renamed as... * nat/x86-gcc-cpuid.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.h: Renamed as... * nat/x86-dregs.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * nat/i386-dregs.c: Renamed as... * nat/x86-dregs.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. gdb/gdbserver/ChangeLog: * i386-low.h: Renamed as... * x86-low.h: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated. * i386-low.c: Renamed as... * x86-low.c: New file. All type, function and variable name prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 16:16:11 +02:00
x86_dr_low.set_control = x86_linux_dr_set_control;
x86_dr_low.set_addr = x86_linux_dr_set_addr;
x86_dr_low.get_addr = x86_linux_dr_get_addr;
x86_dr_low.get_status = x86_linux_dr_get_status;
x86_dr_low.get_control = x86_linux_dr_get_control;
x86_set_debug_register_length (sizeof (void *));
Move duplicated code into new files This commit moves the duplicated code in {i386,amd64}-linux-nat.c into the new files x86-linux-nat.[ch]. Additionally, a new file i386-linux-nat.h was required to expose a value required by the 32-bit code in x86-linux-nat.c. gdb/ 2014-07-11 Gary Benson <gbenson@redhat.com> * i386-linux-nat.h: New file. * x86-linux-nat.h: Likewise. * x86-linux-nat.c: Likewise. * Makefile.in (HFILES_NO_SRCDIR): Add the above new headers. * config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o. * config/i386/linux64.mh (NATDEPFILES): Likewise. * amd64-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise. * i386-linux-nat.c (x86-linux-nat.h): New include. (PTRACE_GETREGSET): Now in x86-linux-nat.h. (PTRACE_SETREGSET): Likewise. (arch_lwp_info): Now in x86-linux-nat.c. (have_ptrace_getregset): Now in x86-linux-nat.h. (x86_linux_dr_get): Now in x86-linux-nat.c. (x86_linux_dr_set): Likewise. (x86_linux_dr_get_addr): Likewise. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (update_debug_registers_callback): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. (x86_linux_prepare_to_resume): Likewise. (x86_linux_new_thread): Likewise. (x86_linux_new_fork): Likewise. (x86_linux_get_thread_area): Likewise. (super_post_startup_inferior): Likewise. (x86_linux_child_post_startup_inferior): Likewise. (AMD64_LINUX_USER64_CS): Likewise. (AMD64_LINUX_X32_DS): Likewise. (x86_linux_read_description): Likewise. (x86_linux_enable_btrace): Likewise. (x86_linux_disable_btrace): Likewise. (x86_linux_teardown_btrace): Likewise. (x86_linux_read_btrace): Likewise. (x86_linux_create_target): Likewise. (x86_linux_add_target): Likewise.
2014-07-10 16:43:56 +02:00
}