]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
target factories, target open and multiple instances of targets
authorPedro Alves <palves@redhat.com>
Wed, 2 May 2018 23:37:32 +0000 (00:37 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 2 May 2018 23:53:12 +0000 (00:53 +0100)
Currently, to open a target, with "target TARGET_NAME", GDB finds the
target_ops instance with "TARGET_NAME" as short name, and then calls
its target_ops::open virtual method.  In reality, there's no actual
target/name lookup, a pointer to the target_ops object was associated
with the "target TARGET_NAME" command at add_target time (when GDB is
initialized), as the command's context.

This creates a chicken and egg situation.  Consider the case of
wanting to open multiple remote connections.  We want to be able to
have one remote target_ops instance per connection, but, if we're not
connected yet, so we don't yet have an instance to call target->open()
on...

This patch fixes this by separating out common info about a target_ops
to a separate structure (shortname, longname, doc), and changing the
add_target routine to take a reference to such an object instead of a
pointer to a target_ops, and a pointer to a factory function that is
responsible to open an instance of the corresponding target when the
user types "target TARGET_NAME".

 -extern void add_target (struct target_ops *);
 +extern void add_target (const target_info &info, target_open_ftype *func);

I.e. this factory function replaces the target_ops::open virtual
method.

For static/singleton targets, nothing changes, the target_open_ftype
function pushes the global target_ops instance on the target stack.
At target_close time, the connection is tor down, but the global
target_ops object remains live.

However, targets that support being open multiple times will make
their target_open_ftype routine allocate a new target_ops instance on
the heap [e.g., new remote_target()], and push that on the stack.  At
target_close time, the new object is destroyed (by the
target_ops::close virtual method).

Both the core target and the remote targets will support being open
multiple times (others could/should too, but those were my stopping
point), but not in this patch yet.  We need to get rid of more globals
first before that'd be useful.

Native targets are somewhat special, given find_default_run_target &
friends.  Those routines also expect to return a target_ops pointer,
even before we've open the target.  However, we'll never need more
than one instance of the native target, so we can assume/require that
native targets are global/simpletons, and have the backends register a
pointer to the native target_ops.  Since all native targets inherit
inf_child_target, we can centralize that registration.  See
add_inf_child_target, get_native_target/set_native_target and
find_default_run_target.

gdb/ChangeLog:
2018-05-02  Pedro Alves  <palves@redhat.com>

* aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Use
add_inf_child_target.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Use
add_inf_child_target.
* aix-thread.c (aix_thread_target_info): New.
(aix_thread_target) <shortname, longname, doc>: Delete.
<info>: New.
* alpha-bsd-nat.c (_initialize_alphabsd_nat): Use
add_inf_child_target.
* alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
add_inf_child_target.
* amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Use
add_inf_child_target.
* amd64-linux-nat.c (_initialize_amd64_linux_nat): Use
add_inf_child_target.
* amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Use
add_inf_child_target.
* amd64-obsd-nat.c (_initialize_amd64obsd_nat): Use
add_inf_child_target.
* arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Use
add_inf_child_target.
* arm-linux-nat.c (_initialize_arm_linux_nat): Use
add_inf_child_target.
* arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Use
add_inf_child_target.
* bfd-target.c (target_bfd_target_info): New.
(target_bfd) <shortname, longname, doc>: Delete.
<info>: New.
* bsd-kvm.c (bsd_kvm_target_info): New.
(bsd_kvm_target) <shortname, longname, doc>: Delete.
<info>: New.
(bsd_kvm_target::open): Rename to ...
(bsd_kvm_target_open): ... this.  Adjust.
* bsd-uthread.c (bsd_uthread_target_info): New.
(bsd_uthread_target) <shortname, longname, doc>: Delete.
<info>: New.
* corefile.c (core_file_command): Adjust.
* corelow.c (core_target_info): New.
(core_target) <shortname, longname, doc>: Delete.
<info>: New.
(core_target::open): Rename to ...
(core_target_open): ... this.  Adjust.
* ctf.c (ctf_target_info): New.
(ctf_target) <shortname, longname, doc>: Delete.
<info>: New.
(ctf_target::open): Rename to ...
(ctf_target_open): ... this.
(_initialize_ctf): Adjust.
* exec.c (exec_target_info): New.
(exec_target) <shortname, longname, doc>: Delete.
<info>: New.
(exec_target::open): Rename to ...
(exec_target_open): ... this.
* gdbcore.h (core_target_open): Declare.
* go32-nat.c (_initialize_go32_nat): Use add_inf_child_target.
* hppa-linux-nat.c (_initialize_hppa_linux_nat): Use
add_inf_child_target.
* hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Use
add_inf_child_target.
* hppa-obsd-nat.c (_initialize_hppaobsd_nat): Use
add_inf_child_target.
* i386-darwin-nat.c (_initialize_i386_darwin_nat): Use
add_inf_child_target.
* i386-fbsd-nat.c (_initialize_i386fbsd_nat): Use
add_inf_child_target.
* i386-gnu-nat.c (_initialize_i386gnu_nat): Use
add_inf_child_target.
* i386-linux-nat.c (_initialize_i386_linux_nat): Use
add_inf_child_target.
* i386-nbsd-nat.c (_initialize_i386nbsd_nat): Use
add_inf_child_target.
* i386-obsd-nat.c (_initialize_i386obsd_nat): Use
add_inf_child_target.
* ia64-linux-nat.c (_initialize_ia64_linux_nat): Use
add_inf_child_target.
* inf-child.c (inf_child_target_info): New.
(inf_child_target::info): New.
(inf_child_open_target): Remove 'target' parameter.  Use
get_native_target instead.
(inf_child_target::open): Delete.
(add_inf_child_target): New.
* inf-child.h (inf_child_target) <shortname, longname, doc, open>:
Delete.
<info>: New.
(add_inf_child_target): Declare.
(inf_child_open_target): Declare.
* linux-thread-db.c (thread_db_target_info): New.
(thread_db_target) <shortname, longname, doc>: Delete.
<info>: New.
* m32r-linux-nat.c (_initialize_m32r_linux_nat): Use
add_inf_child_target.
* m68k-bsd-nat.c (_initialize_m68kbsd_nat): Use
add_inf_child_target.
* m68k-linux-nat.c (_initialize_m68k_linux_nat): Use
add_inf_child_target.
* m88k-bsd-nat.c (_initialize_m88kbsd_nat): Use
add_inf_child_target.
* make-target-delegates (print_class): Adjust.
* mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Use
add_inf_child_target.
* mips-linux-nat.c (_initialize_mips_linux_nat): Use
add_inf_child_target.
* mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Use
add_inf_child_target.
* mips64-obsd-nat.c (_initialize_mips64obsd_nat): Use
add_inf_child_target.
* nto-procfs.c (nto_native_target_info): New.
(nto_procfs_target_native) <shortname, longname, doc>:
Delete.
<info>: New.
(nto_procfs_target_info): New.
(nto_procfs_target_procfs) <shortname, longname, doc>:
Delete.
<info>: New.
(init_procfs_targets): Adjust.
* ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Use
add_inf_child_target.
* ppc-linux-nat.c (_initialize_ppc_linux_nat): Use
add_inf_child_target.
* ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Use
add_inf_child_target.
* ppc-obsd-nat.c (_initialize_ppcobsd_nat): Use
add_inf_child_target.
* ravenscar-thread.c (ravenscar_target_info): New.
(ravenscar_thread_target) <shortname, longname, doc>:
Delete.
<info>: New.
* record-btrace.c (record_btrace_target_info):
(record_btrace_target) <shortname, longname, doc>: Delete.
<info>: New.
(record_btrace_target::open): Rename to ...
(record_btrace_target_open): ... this.  Adjust.
* record-full.c (record_longname, record_doc): New.
(record_full_base_target) <shortname, longname, doc>: Delete.
<info>: New.
(record_full_target_info): New.
(record_full_target): <shortname>: Delete.
<info>: New.
(record_full_core_open_1, record_full_open_1): Update comments.
(record_full_base_target::open): Rename to ...
(record_full_open): ... this.
(cmd_record_full_restore): Update.
(_initialize_record_full): Update.
* remote-sim.c (remote_sim_target_info): New.
(gdbsim_target) <shortname, longname, doc>: Delete.
<info>: New.
(gdbsim_target::open): Rename to ...
(gdbsim_target_open): ... this.
(_initialize_remote_sim): Adjust.
* remote.c (remote_doc): New.
(remote_target_info): New.
(remote_target) <shortname, longname, doc>: Delete.
<info>: New.
(extended_remote_target_info): New.
(extended_remote_target) <shortname, longname, doc>: Delete.
<info>: New.
(remote_target::open_1): Make static.  Adjust.
* rs6000-nat.c (_initialize_rs6000_nat): Use add_inf_child_target.
* s390-linux-nat.c (_initialize_s390_nat): Use
add_inf_child_target.
* sh-nbsd-nat.c (_initialize_shnbsd_nat): Use
add_inf_child_target.
* sol-thread.c (thread_db_target_info): New.
(sol_thread_target) <shortname, longname, doc>: Delete.
<info>: New.
* sparc-linux-nat.c (_initialize_sparc_linux_nat): Use
add_inf_child_target.
* sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Use
add_inf_child_target.
* sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Use
add_inf_child_target.
* sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
add_inf_child_target.
* sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Use
add_inf_child_target.
* sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Use
add_inf_child_target.
* spu-linux-nat.c (_initialize_spu_nat): Use
add_inf_child_target.
* spu-multiarch.c (spu_multiarch_target_info): New.
(spu_multiarch_target) <shortname, longname, doc>: Delete.
<info>: New.
* target-delegates.c: Regenerate.
* target.c: Include <unordered_map>.
(target_ops_p): Delete.
(DEF_VEC_P(target_ops_p)): Delete.
(target_factories): New.
(test_target_info): New.
(test_target_ops::info): New.
(open_target): Adjust to use target_factories.
(add_target_with_completer): Rename to ...
(add_target): ... this.  Change prototype.  Register target_info
and open callback in target_factories.  Register target_info in
command context instead of target_ops.
(add_target): Delete old implementation.
(add_deprecated_target_alias): Change prototype.  Adjust.
(the_native_target): New.
(set_native_target, get_native_target): New.
(find_default_run_target): Use the_native_target.
(find_attach_target, find_run_target): Simplify.
(target_ops::open): Delete.
(dummy_target_info): New.
(dummy_target::shortname, dummy_target::longname)
(dummy_target::doc): Delete.
(dummy_target::info): New.
(debug_target::shortname, debug_target::longname)
(debug_target::doc): Delete.
(debug_target::info): New.
* target.h (struct target_info): New.
(target_ops::~target_ops): Add comment.
(target_ops::info): New.
(target_ops::shortname, target_ops::longname, target_ops::doc): No
longer virtual.  Implement in terms of target_info.
(set_native_target, get_native_target): Declare.
(target_open_ftype): New.
(add_target, add_target_with_completer)
(add_deprecated_target_alias): Change prototype.
(test_target) <shortname, longname, doc>: Delete.
<info>: New.
* tilegx-linux-nat.c (_initialize_tile_linux_nat): Use
add_inf_child_target.
* tracefile-tfile.c (tfile_target_info): New.
(tfile_target) <shortname, longname, doc>: Delete.
<info>: New.
(tfile_target::open): Rename to ...
(tfile_target_open): ... this.
(_initialize_tracefile_tfile): Adjust.
* vax-bsd-nat.c (_initialize_vaxbsd_nat): Use
add_inf_child_target.
* windows-nat.c (_initialize_windows_nat): Use
add_inf_child_target.
* xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Use
add_inf_child_target.

73 files changed:
gdb/ChangeLog
gdb/aarch64-fbsd-nat.c
gdb/aarch64-linux-nat.c
gdb/aix-thread.c
gdb/alpha-bsd-nat.c
gdb/alpha-linux-nat.c
gdb/amd64-fbsd-nat.c
gdb/amd64-linux-nat.c
gdb/amd64-nbsd-nat.c
gdb/amd64-obsd-nat.c
gdb/arm-fbsd-nat.c
gdb/arm-linux-nat.c
gdb/arm-nbsd-nat.c
gdb/bfd-target.c
gdb/bsd-kvm.c
gdb/bsd-uthread.c
gdb/corefile.c
gdb/corelow.c
gdb/ctf.c
gdb/exec.c
gdb/gdbcore.h
gdb/go32-nat.c
gdb/hppa-linux-nat.c
gdb/hppa-nbsd-nat.c
gdb/hppa-obsd-nat.c
gdb/i386-darwin-nat.c
gdb/i386-fbsd-nat.c
gdb/i386-gnu-nat.c
gdb/i386-linux-nat.c
gdb/i386-nbsd-nat.c
gdb/i386-obsd-nat.c
gdb/ia64-linux-nat.c
gdb/inf-child.c
gdb/inf-child.h
gdb/linux-thread-db.c
gdb/m32r-linux-nat.c
gdb/m68k-bsd-nat.c
gdb/m68k-linux-nat.c
gdb/make-target-delegates
gdb/mips-fbsd-nat.c
gdb/mips-linux-nat.c
gdb/mips-nbsd-nat.c
gdb/mips64-obsd-nat.c
gdb/nto-procfs.c
gdb/ppc-fbsd-nat.c
gdb/ppc-linux-nat.c
gdb/ppc-nbsd-nat.c
gdb/ppc-obsd-nat.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/record-full.c
gdb/remote-sim.c
gdb/remote.c
gdb/rs6000-nat.c
gdb/s390-linux-nat.c
gdb/sh-nbsd-nat.c
gdb/sol-thread.c
gdb/sparc-linux-nat.c
gdb/sparc-nbsd-nat.c
gdb/sparc64-fbsd-nat.c
gdb/sparc64-linux-nat.c
gdb/sparc64-nbsd-nat.c
gdb/sparc64-obsd-nat.c
gdb/spu-linux-nat.c
gdb/spu-multiarch.c
gdb/target-delegates.c
gdb/target.c
gdb/target.h
gdb/tilegx-linux-nat.c
gdb/tracefile-tfile.c
gdb/vax-bsd-nat.c
gdb/windows-nat.c
gdb/xtensa-linux-nat.c

index c221991513c56fb24f8ab88066319cd1ce01440a..221268bb8d8e143d55d649239ce591b9a653d76a 100644 (file)
@@ -1,3 +1,239 @@
+2018-05-02  Pedro Alves  <palves@redhat.com>
+
+       * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Use
+       add_inf_child_target.
+       * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Use
+       add_inf_child_target.
+       * aix-thread.c (aix_thread_target_info): New.
+       (aix_thread_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * alpha-bsd-nat.c (_initialize_alphabsd_nat): Use
+       add_inf_child_target.
+       * alpha-linux-nat.c (_initialize_alpha_linux_nat): Use
+       add_inf_child_target.
+       * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Use
+       add_inf_child_target.
+       * amd64-linux-nat.c (_initialize_amd64_linux_nat): Use
+       add_inf_child_target.
+       * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Use
+       add_inf_child_target.
+       * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Use
+       add_inf_child_target.
+       * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Use
+       add_inf_child_target.
+       * arm-linux-nat.c (_initialize_arm_linux_nat): Use
+       add_inf_child_target.
+       * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Use
+       add_inf_child_target.
+       * bfd-target.c (target_bfd_target_info): New.
+       (target_bfd) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * bsd-kvm.c (bsd_kvm_target_info): New.
+       (bsd_kvm_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (bsd_kvm_target::open): Rename to ...
+       (bsd_kvm_target_open): ... this.  Adjust.
+       * bsd-uthread.c (bsd_uthread_target_info): New.
+       (bsd_uthread_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * corefile.c (core_file_command): Adjust.
+       * corelow.c (core_target_info): New.
+       (core_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (core_target::open): Rename to ...
+       (core_target_open): ... this.  Adjust.
+       * ctf.c (ctf_target_info): New.
+       (ctf_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (ctf_target::open): Rename to ...
+       (ctf_target_open): ... this.
+       (_initialize_ctf): Adjust.
+       * exec.c (exec_target_info): New.
+       (exec_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (exec_target::open): Rename to ...
+       (exec_target_open): ... this.
+       * gdbcore.h (core_target_open): Declare.
+       * go32-nat.c (_initialize_go32_nat): Use add_inf_child_target.
+       * hppa-linux-nat.c (_initialize_hppa_linux_nat): Use
+       add_inf_child_target.
+       * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Use
+       add_inf_child_target.
+       * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Use
+       add_inf_child_target.
+       * i386-darwin-nat.c (_initialize_i386_darwin_nat): Use
+       add_inf_child_target.
+       * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Use
+       add_inf_child_target.
+       * i386-gnu-nat.c (_initialize_i386gnu_nat): Use
+       add_inf_child_target.
+       * i386-linux-nat.c (_initialize_i386_linux_nat): Use
+       add_inf_child_target.
+       * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Use
+       add_inf_child_target.
+       * i386-obsd-nat.c (_initialize_i386obsd_nat): Use
+       add_inf_child_target.
+       * ia64-linux-nat.c (_initialize_ia64_linux_nat): Use
+       add_inf_child_target.
+       * inf-child.c (inf_child_target_info): New.
+       (inf_child_target::info): New.
+       (inf_child_open_target): Remove 'target' parameter.  Use
+       get_native_target instead.
+       (inf_child_target::open): Delete.
+       (add_inf_child_target): New.
+       * inf-child.h (inf_child_target) <shortname, longname, doc, open>:
+       Delete.
+       <info>: New.
+       (add_inf_child_target): Declare.
+       (inf_child_open_target): Declare.
+       * linux-thread-db.c (thread_db_target_info): New.
+       (thread_db_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * m32r-linux-nat.c (_initialize_m32r_linux_nat): Use
+       add_inf_child_target.
+       * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Use
+       add_inf_child_target.
+       * m68k-linux-nat.c (_initialize_m68k_linux_nat): Use
+       add_inf_child_target.
+       * m88k-bsd-nat.c (_initialize_m88kbsd_nat): Use
+       add_inf_child_target.
+       * make-target-delegates (print_class): Adjust.
+       * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Use
+       add_inf_child_target.
+       * mips-linux-nat.c (_initialize_mips_linux_nat): Use
+       add_inf_child_target.
+       * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Use
+       add_inf_child_target.
+       * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Use
+       add_inf_child_target.
+       * nto-procfs.c (nto_native_target_info): New.
+       (nto_procfs_target_native) <shortname, longname, doc>:
+       Delete.
+       <info>: New.
+       (nto_procfs_target_info): New.
+       (nto_procfs_target_procfs) <shortname, longname, doc>:
+       Delete.
+       <info>: New.
+       (init_procfs_targets): Adjust.
+       * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Use
+       add_inf_child_target.
+       * ppc-linux-nat.c (_initialize_ppc_linux_nat): Use
+       add_inf_child_target.
+       * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Use
+       add_inf_child_target.
+       * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Use
+       add_inf_child_target.
+       * ravenscar-thread.c (ravenscar_target_info): New.
+       (ravenscar_thread_target) <shortname, longname, doc>:
+       Delete.
+       <info>: New.
+       * record-btrace.c (record_btrace_target_info):
+       (record_btrace_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (record_btrace_target::open): Rename to ...
+       (record_btrace_target_open): ... this.  Adjust.
+       * record-full.c (record_longname, record_doc): New.
+       (record_full_base_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (record_full_target_info): New.
+       (record_full_target): <shortname>: Delete.
+       <info>: New.
+       (record_full_core_open_1, record_full_open_1): Update comments.
+       (record_full_base_target::open): Rename to ...
+       (record_full_open): ... this.
+       (cmd_record_full_restore): Update.
+       (_initialize_record_full): Update.
+       * remote-sim.c (remote_sim_target_info): New.
+       (gdbsim_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (gdbsim_target::open): Rename to ...
+       (gdbsim_target_open): ... this.
+       (_initialize_remote_sim): Adjust.
+       * remote.c (remote_doc): New.
+       (remote_target_info): New.
+       (remote_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (extended_remote_target_info): New.
+       (extended_remote_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (remote_target::open_1): Make static.  Adjust.
+       * rs6000-nat.c (_initialize_rs6000_nat): Use add_inf_child_target.
+       * s390-linux-nat.c (_initialize_s390_nat): Use
+       add_inf_child_target.
+       * sh-nbsd-nat.c (_initialize_shnbsd_nat): Use
+       add_inf_child_target.
+       * sol-thread.c (thread_db_target_info): New.
+       (sol_thread_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * sparc-linux-nat.c (_initialize_sparc_linux_nat): Use
+       add_inf_child_target.
+       * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Use
+       add_inf_child_target.
+       * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Use
+       add_inf_child_target.
+       * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Use
+       add_inf_child_target.
+       * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Use
+       add_inf_child_target.
+       * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Use
+       add_inf_child_target.
+       * spu-linux-nat.c (_initialize_spu_nat): Use
+       add_inf_child_target.
+       * spu-multiarch.c (spu_multiarch_target_info): New.
+       (spu_multiarch_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * target-delegates.c: Regenerate.
+       * target.c: Include <unordered_map>.
+       (target_ops_p): Delete.
+       (DEF_VEC_P(target_ops_p)): Delete.
+       (target_factories): New.
+       (test_target_info): New.
+       (test_target_ops::info): New.
+       (open_target): Adjust to use target_factories.
+       (add_target_with_completer): Rename to ...
+       (add_target): ... this.  Change prototype.  Register target_info
+       and open callback in target_factories.  Register target_info in
+       command context instead of target_ops.
+       (add_target): Delete old implementation.
+       (add_deprecated_target_alias): Change prototype.  Adjust.
+       (the_native_target): New.
+       (set_native_target, get_native_target): New.
+       (find_default_run_target): Use the_native_target.
+       (find_attach_target, find_run_target): Simplify.
+       (target_ops::open): Delete.
+       (dummy_target_info): New.
+       (dummy_target::shortname, dummy_target::longname)
+       (dummy_target::doc): Delete.
+       (dummy_target::info): New.
+       (debug_target::shortname, debug_target::longname)
+       (debug_target::doc): Delete.
+       (debug_target::info): New.
+       * target.h (struct target_info): New.
+       (target_ops::~target_ops): Add comment.
+       (target_ops::info): New.
+       (target_ops::shortname, target_ops::longname, target_ops::doc): No
+       longer virtual.  Implement in terms of target_info.
+       (set_native_target, get_native_target): Declare.
+       (target_open_ftype): New.
+       (add_target, add_target_with_completer)
+       (add_deprecated_target_alias): Change prototype.
+       (test_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       * tilegx-linux-nat.c (_initialize_tile_linux_nat): Use
+       add_inf_child_target.
+       * tracefile-tfile.c (tfile_target_info): New.
+       (tfile_target) <shortname, longname, doc>: Delete.
+       <info>: New.
+       (tfile_target::open): Rename to ...
+       (tfile_target_open): ... this.
+       (_initialize_tracefile_tfile): Adjust.
+       * vax-bsd-nat.c (_initialize_vaxbsd_nat): Use
+       add_inf_child_target.
+       * windows-nat.c (_initialize_windows_nat): Use
+       add_inf_child_target.
+       * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Use
+       add_inf_child_target.
+
 2018-05-02  Pedro Alves  <palves@redhat.com>
 
        * linux-nat.h (linux_nat_target) <low_new_thread,
index 5ffbf1fdb1949de567c0ac3f9c39d7d20e5d6c98..a50656353cdffe2ef7ecf1d29d6038ff7b4479d3 100644 (file)
@@ -128,5 +128,5 @@ aarch64_fbsd_nat_target::store_registers (struct regcache *regcache,
 void
 _initialize_aarch64_fbsd_nat (void)
 {
-  add_target (&the_aarch64_fbsd_nat_target);
+  add_inf_child_target (&the_aarch64_fbsd_nat_target);
 }
index 63ef4d1cf8da9a7ca80e4fe7b67ac926051be507..26b956482eec61d6bb83e8167d7e812a461dc0c2 100644 (file)
@@ -837,11 +837,9 @@ triggers a breakpoint or watchpoint."),
 void
 _initialize_aarch64_linux_nat (void)
 {
-  struct target_ops *t = &the_aarch64_linux_nat_target;
-
   add_show_debug_regs_command ();
 
   /* Register the target.  */
   linux_target = &the_aarch64_linux_nat_target;
-  add_target (t);
+  add_inf_child_target (&the_aarch64_linux_nat_target);
 }
index 410fb55e72713e318cc4a7f483b9c152585b656e..d328bdd872ae0ba9af10eab3c0ada90fd68badc0 100644 (file)
@@ -108,18 +108,20 @@ struct pd_thread {
 
 /* This module's target-specific operations, active while pd_able is true.  */
 
+static const target_info aix_thread_target_info = {
+  "aix-threads",
+  N_("AIX pthread support"),
+  N_("AIX pthread support")
+};
+
 class aix_thread_target final : public target_ops
 {
 public:
   aix_thread_target ()
   { to_stratum = thread_stratum; }
 
-  const char *shortname () override
-  { return "aix-threads"; }
-  const char *longname () override
-  { return _("AIX pthread support"); }
-  const char *doc () override
-  { return _("AIX pthread support"); }
+  const target_info &info () const override
+  { return aix_thread_target_info; }
 
   void detach (inferior *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
index 234dac9500232a27e44f7f43793b871404f90fc7..77271ec6f73932ce089e2729e8349929c3671e37 100644 (file)
@@ -196,7 +196,7 @@ alphabsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 void
 _initialize_alphabsd_nat (void)
 {
-  add_target (&the_alpha_bsd_nat_target);
+  add_inf_child_target (&the_alpha_bsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (alphabsd_supply_pcb);
index e08e19d2e25a7f142fa55a2d0ee79b321d883208..e23674a4947af13a330b84ce823603044388dac1 100644 (file)
@@ -104,5 +104,5 @@ void
 _initialize_alpha_linux_nat (void)
 {
   linux_target = &the_alpha_linux_nat_target;
-  add_target (&the_alpha_linux_nat_target);
+  add_inf_child_target (&the_alpha_linux_nat_target);
 }
index fbec9b1579e2992bf55dfbbb124fcc71ab2e761c..6e0a1f9636e4dcadb72554b4c21b329cf3704763 100644 (file)
@@ -217,7 +217,7 @@ _initialize_amd64fbsd_nat (void)
   amd64_native_gregset32_reg_offset = amd64fbsd32_r_reg_offset;
   amd64_native_gregset64_reg_offset = amd64fbsd64_r_reg_offset;
 
-  add_target (&the_amd64_fbsd_nat_target);
+  add_inf_child_target (&the_amd64_fbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (amd64fbsd_supply_pcb);
index 9177c3eec27c9fd07dd668a47f7f0c9ceeba312c..1cb4c2c627f23f4911e834e12ed0a3e315bc953a 100644 (file)
@@ -421,5 +421,5 @@ _initialize_amd64_linux_nat (void)
   linux_target = &the_amd64_linux_nat_target;
 
   /* Add the target.  */
-  add_target (linux_target);
+  add_inf_child_target (linux_target);
 }
index e1c07dfb4c996a886d9e43a5aa142a50dd9f32df..f92983b4f58dbf5ef75653464751adb995de440e 100644 (file)
@@ -63,5 +63,5 @@ _initialize_amd64nbsd_nat (void)
   amd64_native_gregset32_num_regs = ARRAY_SIZE (amd64nbsd32_r_reg_offset);
   amd64_native_gregset64_reg_offset = amd64nbsd_r_reg_offset;
 
-  add_target (&the_amd64_nbsd_nat_target);
+  add_inf_child_target (&the_amd64_nbsd_nat_target);
 }
index d6756d9463f5713d48a4ddea783250342be40df2..0e89e3f574bd96bf0143a0389335af7511f46f2a 100644 (file)
@@ -135,7 +135,7 @@ _initialize_amd64obsd_nat (void)
   amd64_native_gregset32_num_regs = ARRAY_SIZE (amd64obsd32_r_reg_offset);
   amd64_native_gregset64_reg_offset = amd64obsd_r_reg_offset;
 
-  add_target (&the_amd64_obsd_nat_target);
+  add_inf_child_target (&the_amd64_obsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (amd64obsd_supply_pcb);
index f31ee5fa1d13464e89d94c6623152cfeeb170bbe..be733ff7467a2c2f3fcde03d7e1afe3a7acef78e 100644 (file)
@@ -148,5 +148,5 @@ arm_fbsd_nat_target::read_description ()
 void
 _initialize_arm_fbsd_nat (void)
 {
-  add_target (&the_arm_fbsd_nat_target);
+  add_inf_child_target (&the_arm_fbsd_nat_target);
 }
index 2d4d8071b02d6b1d76e514b904601aa70a49d08a..30030b4eb06019b05a2adc8cf0297139f80c9816 100644 (file)
@@ -1330,9 +1330,7 @@ arm_linux_nat_target::low_new_fork (struct lwp_info *parent, pid_t child_pid)
 void
 _initialize_arm_linux_nat (void)
 {
-  target_ops *t = &the_arm_linux_nat_target;
-
   /* Register the target.  */
   linux_target = &the_arm_linux_nat_target;
-  add_target (t);
+  add_inf_child_target (&the_arm_linux_nat_target);
 }
index 9d58b35a2a11aecd9893040e9cba6db15ba49a2a..3a1ddeaf4e859f68f9f06a0288420e8123f67a94 100644 (file)
@@ -469,7 +469,7 @@ static struct core_fns arm_netbsd_elfcore_fns =
 void
 _initialize_arm_netbsd_nat (void)
 {
-  add_target (&the_arm_netbsd_nat_target);
+  add_inf_child_target (&the_arm_netbsd_nat_target);
 
   deprecated_add_core_fns (&arm_netbsd_elfcore_fns);
 }
index 7ac8bc3c612c7ca3194b0deee826873f68d6a971..ba194d7b04b8de117a47426ef785ac5af91bd899 100644 (file)
 #include "gdb_bfd.h"
 
 /* A target that wraps a BFD.  */
+
+static const target_info target_bfd_target_info = {
+  "bfd",
+  N_("BFD backed target"),
+  N_("You should never see this")
+};
+
 class target_bfd : public target_ops
 {
 public:
   explicit target_bfd (struct bfd *bfd);
   ~target_bfd () override;
 
-  const char *shortname () override
-  { return "bfd"; }
-
-  const char *longname () override
-  { return _("BFD backed target"); }
-
-  const char *doc () override
-  { return _("You should never see this"); }
+  const target_info &info () const override
+  { return target_bfd_target_info; }
 
   void close () override;
 
index af182e247b12a6e361bf1ff98a001d78985441b2..336dbf2b976334050d730e753779c74e51ad6f42 100644 (file)
@@ -63,25 +63,22 @@ static ptid_t bsd_kvm_ptid;
 
 /* The libkvm target.  */
 
+static const target_info bsd_kvm_target_info = {
+  "kvm",
+  N_("Kernel memory interface"),
+  N_("Use a kernel virtual memory image as a target.\n\
+Optionally specify the filename of a core dump.")
+};
+
 class bsd_kvm_target final : public target_ops
 {
 public:
   bsd_kvm_target ()
   { this->to_stratum = process_stratum; }
 
-  const char *shortname () override
-  { return "kvm"; }
-
-  const char *longname () override
-  { return _("Kernel memory interface"); }
-
-  const char *doc () override
-  {
-    return _("Use a kernel virtual memory image as a target.\n\
-Optionally specify the filename of a core dump.");
-  }
+  const target_info &info () const override
+  { return bsd_kvm_target_info; }
 
-  void open (const char *, int) override;
   void close () override;
 
   void fetch_registers (struct regcache *, int) override;
@@ -105,7 +102,7 @@ Optionally specify the filename of a core dump.");
 static bsd_kvm_target bsd_kvm_ops;
 
 static void
-bsd_kvm_target::open (const char *arg, int from_tty)
+bsd_kvm_target_open (const char *arg, int from_tty)
 {
   char errbuf[_POSIX2_LINE_MAX];
   char *execfile = NULL;
@@ -388,7 +385,7 @@ bsd_kvm_add_target (int (*supply_pcb)(struct regcache *, struct pcb *))
   gdb_assert (bsd_kvm_supply_pcb == NULL);
   bsd_kvm_supply_pcb = supply_pcb;
 
-  add_target (&bsd_kvm_ops);
+  add_target (bsd_kvm_target_info, bsd_kvm_target_open);
   
   add_prefix_cmd ("kvm", class_obscure, bsd_kvm_cmd, _("\
 Generic command for manipulating the kernel memory interface."),
index efcec1e3967d450623cd8d94a594e1831592c394..1505cfede70541ab9b777b4401a05fdb45c46013 100644 (file)
 
 #include "bsd-uthread.h"
 
+static const target_info bsd_uthread_target_info = {
+  "bsd-uthreads",
+  N_("BSD user-level threads"),
+  N_("BSD user-level threads")
+};
+
 struct bsd_uthread_target final : public target_ops
 {
   bsd_uthread_target ()
   { to_stratum = thread_stratum; }
 
-  const char *shortname () override
-  { return "bsd-uthreads"; }
-
-  const char *longname () override
-  { return _("BSD user-level threads"); }
-
-  const char *doc () override
-  { return _("BSD user-level threads"); }
+  const target_info &info () const override
+  { return bsd_uthread_target_info; }
 
   void close () override;
 
index c849a106466d9e46a274a174201f2f418e172ee9..114de836403c4c0e60d7f2d56c019100be1570b7 100644 (file)
@@ -62,12 +62,14 @@ core_file_command (const char *filename, int from_tty)
 {
   dont_repeat ();              /* Either way, seems bogus.  */
 
-  gdb_assert (the_core_target != NULL);
-
   if (!filename)
-    the_core_target->detach (current_inferior (), from_tty);
+    {
+      gdb_assert (the_core_target != NULL);
+
+      the_core_target->detach (current_inferior (), from_tty);
+    }
   else
-    the_core_target->open (filename, from_tty);
+    core_target_open (filename, from_tty);
 }
 \f
 
index e7d9a7ed51d635ebd1479239d21452ab127af011..97a957c8fcf6defa0afa0339f259816184958813 100644 (file)
 
 /* The core file target.  */
 
+static const target_info core_target_info = {
+  "core",
+  N_("Local core dump file"),
+  N_("Use a core file as a target.  Specify the filename of the core file.")
+};
+
 class core_target final : public target_ops
 {
 public:
   core_target ()
   { to_stratum = process_stratum; }
 
-  const char *shortname () override
-  { return "core"; }
-
-  const char *longname () override
-  { return _("Local core dump file"); }
+  const target_info &info () const override
+  { return core_target_info; }
 
-  const char *doc () override
-  {
-    return _("\
-Use a core file as a target.  Specify the filename of the core file.");
-  }
-
-  void open (const char *, int) override;
   void close () override;
   void detach (inferior *, int) override;
   void fetch_registers (struct regcache *, int) override;
@@ -313,10 +309,10 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
     inferior_ptid = ptid;                      /* Yes, make it current.  */
 }
 
-/* This routine opens and sets up the core file bfd.  */
+/* See gdbcore.h.  */
 
 void
-core_target::open (const char *arg, int from_tty)
+core_target_open (const char *arg, int from_tty)
 {
   const char *p;
   int siggy;
@@ -1031,5 +1027,5 @@ _initialize_corelow (void)
                    the_core_target->longname ());
   the_core_target = &core_ops;
 
-  add_target_with_completer (&core_ops, filename_completer);
+  add_target (core_target_info, core_target_open, filename_completer);
 }
index 90d6f6c025f6e3bc94afb204aa6ee58b067f9d5f..cae5d221cb1c3f4a8143df60ea12b0df75101ccd 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
 
 /* The CTF target.  */
 
+static const target_info ctf_target_info = {
+  "ctf",
+  N_("CTF file"),
+  N_("(Use a CTF directory as a target.\n\
+Specify the filename of the CTF directory.")
+};
+
 class ctf_target final : public tracefile_target
 {
 public:
-  const char *shortname () override
-  { return "ctf"; }
-
-  const char *longname () override
-  { return _("CTF file"); }
+  const target_info &info () const override
+  { return ctf_target_info; }
 
-  const char *doc () override
-  {
-    return _("\
-Use a CTF directory as a target.\n\
-Specify the filename of the CTF directory.");
-  }
-
-  void open (const char *, int) override;
   void close () override;
   void fetch_registers (struct regcache *, int) override;
   enum target_xfer_status xfer_partial (enum target_object object,
@@ -1108,8 +1104,8 @@ ctf_read_tp (struct uploaded_tp **uploaded_tps)
    definitions from the first packet.  Set the start position at the
    second packet which contains events on trace blocks.  */
 
-void
-ctf_target::open (const char *dirname, int from_tty)
+static void
+ctf_target_open (const char *dirname, int from_tty)
 {
   struct bt_ctf_event *event;
   uint32_t event_id;
@@ -1724,6 +1720,6 @@ void
 _initialize_ctf (void)
 {
 #if HAVE_LIBBABELTRACE
-  add_target_with_completer (&ctf_ops, filename_completer);
+  add_target (ctf_target_info, ctf_target_open, filename_completer);
 #endif
 }
index b1c4ca179987a0bdfaf1ff7089476c1199c9a1cb..3023ff7e5aa9570a4f8200137c70c4dd263ef4ed 100644 (file)
 
 void (*deprecated_file_changed_hook) (const char *);
 
+static const target_info exec_target_info = {
+  "exec",
+  N_("Local exec file"),
+  N_("Use an executable file as a target.\n\
+Specify the filename of the executable file.")
+};
+
 /* The target vector for executable files.  */
 
 struct exec_target final : public target_ops
@@ -56,20 +63,9 @@ struct exec_target final : public target_ops
   exec_target ()
   { to_stratum = file_stratum; }
 
-  const char *shortname () override
-  { return "exec"; }
-
-  const char *longname () override
-  { return _("Local exec file"); }
+  const target_info &info () const override
+  { return exec_target_info; }
 
-  const char *doc () override
-  {
-    return _("\
-Use an executable file as a target.\n\
-Specify the filename of the executable file.");
-  }
-
-  void open (const char *, int) override;
   void close () override;
   enum target_xfer_status xfer_partial (enum target_object object,
                                        const char *annex,
@@ -99,8 +95,8 @@ show_write_files (struct ui_file *file, int from_tty,
 }
 
 
-void
-exec_target::open (const char *args, int from_tty)
+static void
+exec_target_open (const char *args, int from_tty)
 {
   target_preopen (from_tty);
   exec_file_attach (args, from_tty);
@@ -1090,5 +1086,5 @@ Show writing into executable and core files."), NULL,
                           show_write_files,
                           &setlist, &showlist);
 
-  add_target_with_completer (&exec_ops, filename_completer);
+  add_target (exec_target_info, exec_target_open, filename_completer);
 }
index 04a235dd9040c9a46a6bf575e4d000ef66a1dcba..401c213d4824ec6c22c4dd6c3a5ca31a3b0a4ebf 100644 (file)
@@ -143,6 +143,10 @@ extern struct target_ops *the_core_target;
 
 extern int write_files;
 
+/* Open and set up the core file bfd.  */
+
+extern void core_target_open (const char *arg, int from_tty);
+
 extern void core_file_command (const char *filename, int from_tty);
 
 extern void exec_file_attach (const char *filename, int from_tty);
index 32699ac758c77028a98592abaedebb9d7eab6413..980180b23a1e84783b2e3e0a764a85b588c68c73 100644 (file)
@@ -2090,7 +2090,7 @@ _initialize_go32_nat (void)
   x86_dr_low.get_addr = go32_get_dr;
   x86_set_debug_register_length (4);
 
-  add_target (&the_go32_nat_target);
+  add_inf_child_target (&the_go32_nat_target);
 
   /* Initialize child's cwd as empty to be initialized when starting
      the child.  */
index 708eff0447a46016aaa1aca44b2ed122c49fd8a3..bc6c234d513773f767d841bc35e36f8542321dc5 100644 (file)
@@ -391,5 +391,5 @@ _initialize_hppa_linux_nat (void)
 {
   /* Register the target.  */
   linux_target = &the_hppa_linux_nat_target;
-  add_target (&the_hppa_linux_nat_target);
+  add_inf_child_target (&the_hppa_linux_nat_target);
 }
index 1497166145ca67495d4871df9affe5042ece774e..3547d655437ea75d231f86b48f1b735acee96930 100644 (file)
@@ -231,5 +231,5 @@ hppa_nbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 void
 _initialize_hppanbsd_nat (void)
 {
-  add_target (&the_hppa_nbsd_nat_target);
+  add_inf_child_target (&the_hppa_nbsd_nat_target);
 }
index 2dfb8933d1ebd7178f949c8683d2b254ecae4551..43c2dcc2b84da634de6d57d2c4c5e3ad3f92a082 100644 (file)
@@ -255,5 +255,5 @@ hppa_obsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 void
 _initialize_hppaobsd_nat (void)
 {
-  add_target (&the_hppa_obsd_nat_target);
+  add_inf_child_target (&the_hppa_obsd_nat_target);
 }
index 48f1a7921dfcfc73252cee0a0dcab442227d5fa6..e57b12693f029b4606e3056e04b295d098a93543 100644 (file)
@@ -659,5 +659,5 @@ _initialize_i386_darwin_nat (void)
   x86_set_debug_register_length (4);
 #endif
 
-  add_target (&darwin_target);
+  add_inf_child_target (&darwin_target);
 }
index f69dc605302238926e3a40de6b5270890b1890b7..0d3762a7f03ef59310663d62d6648de64d3bf4e2 100644 (file)
@@ -177,7 +177,7 @@ i386_fbsd_nat_target::supports_stopped_by_hw_breakpoint ()
 void
 _initialize_i386fbsd_nat (void)
 {
-  add_target (&the_i386_fbsd_nat_target);
+  add_inf_child_target (&the_i386_fbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (i386fbsd_supply_pcb);
index de7d62a26991ea18412e904cda4d2ed1391c9b63..8bb036dac3d93d52adbcf909b95d0282530181e9 100644 (file)
@@ -440,5 +440,5 @@ _initialize_i386gnu_nat (void)
 #endif /* i386_DEBUG_STATE */
 
   /* Register the target.  */
-  add_target (&the_i386_gnu_nat_target);
+  add_inf_child_target (&the_i386_gnu_nat_target);
 }
index 786eec227f3ba14f4915fd4952858799d2231f99..653832430610adb2cf61a13573c3750bd1720ab2 100644 (file)
@@ -717,5 +717,5 @@ _initialize_i386_linux_nat (void)
   linux_target = &the_i386_linux_nat_target;
 
   /* Add the target.  */
-  add_target (linux_target);
+  add_inf_child_target (linux_target);
 }
index 508abdc92eed57ee8041b24f61605133b6dcbdfd..bc875e07cd5b92fb113f28efd1ff4e20253a4dd1 100644 (file)
@@ -76,7 +76,7 @@ static i386_bsd_nat_target<nbsd_nat_target> the_i386_nbsd_nat_target;
 void
 _initialize_i386nbsd_nat (void)
 {
-  add_target (&the_i386_nbsd_nat_target);
+  add_inf_child_target (&the_i386_nbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (i386nbsd_supply_pcb);
index 2a09f3e0d635df44cea189384ab9051301b024b1..a3221edc8564d69508f05ae0fbb5c83b6a216f9e 100644 (file)
@@ -93,7 +93,7 @@ static i386_bsd_nat_target<obsd_nat_target> the_i386_obsd_nat_target;
 void
 _initialize_i386obsd_nat (void)
 {
-  add_target (&i386_obsd_nat_target);
+  add_inf_child_target (&i386_obsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (i386obsd_supply_pcb);
index 64878ec27791d4ec04a74b2e4223d243d732fa5d..f73e17ac765f3ef316a4b5e8472b2b0aedfc415b 100644 (file)
@@ -929,9 +929,7 @@ ia64_linux_nat_target::low_status_is_event (int status)
 void
 _initialize_ia64_linux_nat (void)
 {
-  struct target_ops *t = &the_ia64_linux_nat_target;
-
   /* Register the target.  */
   linux_target = &the_ia64_linux_nat_target;
-  add_target (t);
+  add_inf_child_target (&the_ia64_linux_nat_target);
 }
index 8e5ebfa2c2276cfb4a416f4b233037fb03d53906..2f5babebce7fea9b15a89df126625192fd183e12 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 
+static const target_info inf_child_target_info = {
+  "native",
+  N_("Native process"),
+  N_("Native process (started by the \"run\" command).")
+};
+
+const target_info &
+inf_child_target::info () const
+{
+  return inf_child_target_info;
+}
+
 /* Helper function for child_wait and the derivatives of child_wait.
    HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
    translation of that in OURSTATUS.  */
@@ -139,9 +151,14 @@ static int inf_child_explicitly_opened;
 /* See inf-child.h.  */
 
 void
-inf_child_open_target (struct target_ops *target, const char *arg,
-                      int from_tty)
+inf_child_open_target (const char *arg, int from_tty)
 {
+  target_ops *target = get_native_target ();
+
+  /* There's always only ever one native target, and if we get here,
+     it better be an inf-child target.  */
+  gdb_assert (dynamic_cast<inf_child_target *> (target) != NULL);
+
   target_preopen (from_tty);
   push_target (target);
   inf_child_explicitly_opened = 1;
@@ -149,12 +166,6 @@ inf_child_open_target (struct target_ops *target, const char *arg,
     printf_filtered ("Done.  Use the \"run\" command to start a process.\n");
 }
 
-void
-inf_child_target::open (const char *arg, int from_tty)
-{
-  inf_child_open_target (this, arg, from_tty);
-}
-
 /* Implement the to_disconnect target_ops method.  */
 
 void
@@ -426,3 +437,12 @@ inf_child_target::inf_child_target ()
 {
   this->to_stratum = process_stratum;
 }
+
+/* See inf-child.h.  */
+
+void
+add_inf_child_target (inf_child_target *target)
+{
+  set_native_target (target);
+  add_target (inf_child_target_info, inf_child_open_target);
+}
index b754a951881b4fd8a9b03276b00ef43685de568a..6316f3062da106d9257b23319509770cb821e2fa 100644 (file)
@@ -32,16 +32,8 @@ public:
   inf_child_target ();
   ~inf_child_target () override = 0;
 
-  const char *shortname () override
-  { return "native"; }
+  const target_info &info () const override;
 
-  const char *longname () override
-  { return _("Native process"); }
-
-  const char *doc () override
-  { return _("Native process (started by the \"run\" command)."); }
-
-  void open (const char *arg, int from_tty) override;
   void close () override;
 
   void disconnect (const char *, int) override;
@@ -124,4 +116,13 @@ protected:
 /* This is for native targets which use a unix/POSIX-style waitstatus.  */
 extern void store_waitstatus (struct target_waitstatus *, int);
 
+/* Register TARGET as native target and set it up to respond to the
+   "target native" command.  */
+extern void add_inf_child_target (inf_child_target *target);
+
+/* target_open_ftype callback for inf-child targets.  Used by targets
+   that want to register an alternative target_info object.  Most
+   targets use add_inf_child_target instead.  */
+extern void inf_child_open_target (const char *arg, int from_tty);
+
 #endif
index 8ef6801ee810605c717607f0a938981f058a4658..8feab6f0cab6cb628359706dd787d1d40aaead50 100644 (file)
    of the ptid_t prevents thread IDs changing when libpthread is
    loaded or unloaded.  */
 
+static const target_info thread_db_target_info = {
+  "multi-thread",
+  N_("multi-threaded child process."),
+  N_("Threads and pthreads support.")
+};
+
 class thread_db_target final : public target_ops
 {
 public:
   thread_db_target ();
 
-  const char *shortname () override
-  { return "multi-thread"; }
-  const char *longname () override
-  { return _("multi-threaded child process."); }
-  const char *doc () override
-  { return _("Threads and pthreads support."); }
+  const target_info &info () const override
+  { return thread_db_target_info; }
 
   void detach (inferior *, int) override;
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
index e156df38b551924c9ef81b184b0ecdca4a212240..09a019a7b1082c217720576d218c81a589c89221 100644 (file)
@@ -242,5 +242,5 @@ _initialize_m32r_linux_nat (void)
 {
   /* Register the target.  */
   linux_target = &the_m32r_linux_nat_target;
-  add_target (&the_m32r_linux_nat_target);
+  add_inf_child_target (&the_m32r_linux_nat_target);
 }
index 379924815b90bc8f0fced3bdee47795e10291b20..af907adb78a1be10fb9b744b12d6634d756e1447 100644 (file)
@@ -225,7 +225,7 @@ m68kbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 void
 _initialize_m68kbsd_nat (void)
 {
-  add_target (&the_m68k_bsd_nat_target);
+  add_inf_child_target (&the_m68k_bsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (m68kbsd_supply_pcb);
index 0b6651de22cc974da41cc621af365e07b5812d2c..e25154cdd7025d3deafd9c0faf870e03e4a048df 100644 (file)
@@ -520,5 +520,5 @@ _initialize_m68k_linux_nat (void)
 {
   /* Register the target.  */
   linux_target = &the_m68k_linux_nat_target;
-  add_target (&the_m68k_linux_nat_target);
+  add_inf_child_target (&the_m68k_linux_nat_target);
 }
index 83a1afcadfb0481bdd6e7ba746174d5b32e579bb..b8cf63cd0bd4678c43b78925ba2acf38e6033e74 100755 (executable)
@@ -392,9 +392,7 @@ sub print_class($) {
     print "{\n";
     print "  $name ();\n";
     print "\n";
-    print "  const char *shortname () override;\n";
-    print "  const char *longname () override;\n";
-    print "  const char *doc () override;\n";
+    print "  const target_info &info () const override;\n";
     print "\n";
 
     for $name (@delegators) {
index 7bf0e8e35fab5f6534990acb5a1f805b439e0d17..04fbb2ad1a7d23a929d5f2fd3933c983368bfaa3 100644 (file)
@@ -129,5 +129,5 @@ mips_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 void
 _initialize_mips_fbsd_nat (void)
 {
-  add_target (&the_mips_fbsd_nat_target);
+  add_inf_child_target (&the_mips_fbsd_nat_target);
 }
index 37ce35b2512aa3590eae00e4c22df8209eddef9e..4e0c51bd2dd998b5f094d56fd15e67a0a716fccb 100644 (file)
@@ -802,5 +802,5 @@ triggers a breakpoint or watchpoint."),
                           &maintenance_show_cmdlist);
 
   linux_target = &the_mips_linux_nat_target;
-  add_target (&the_mips_linux_nat_target);
+  add_inf_child_target (&the_mips_linux_nat_target);
 }
index 74b2060c135c77f5b9f4fecb6fed0eeec1a419d1..b9fc6279d095b98640e6aa2f4e45e9f686d3d632 100644 (file)
@@ -116,5 +116,5 @@ mips_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
 void
 _initialize_mipsnbsd_nat (void)
 {
-  add_target (&the_mips_nbsd_nat_target);
+  add_inf_child_target (&the_mips_nbsd_nat_target);
 }
index 8005ec9d3eec52c5a22ba1014f6fdfb2e6392895..7f14b09108b263e40c9f8cde0588795697605504 100644 (file)
@@ -118,5 +118,5 @@ mips64_obsd_nat_target::store_registers (struct regcache *regcache, int regnum)
 void
 _initialize_mips64obsd_nat (void)
 {
-  add_target (&the_mips64_obsd_nat_target);
+  add_inf_child_target (&the_mips64_obsd_nat_target);
 }
index f3ba877840add66ecdfec47741d0b5d33c635093..51559e6c3ed7c3e378f91ade992be1b8ce547eec 100644 (file)
@@ -128,28 +128,31 @@ struct nto_procfs_target : public inf_child_target
 };
 
 /* For "target native".  */
-struct nto_procfs_target_native final : public nto_procfs_target
-{
-  /* Leave shortname as "native".  */
 
-  const char *longname () override
-  { return _("QNX Neutrino local process"); }
+static const target_info nto_native_target_info = {
+  "native",
+  N_("QNX Neutrino local process"),
+  N_("QNX Neutrino local process (started by the \"run\" command).")
+};
 
-  const char *doc () override
-  { return _("QNX Neutrino local process (started by the \"run\" command)."); }
+class nto_procfs_target_native final : public nto_procfs_target
+{
+  const target_info &info () const override
+  { return nto_native_target_info; }
 };
 
 /* For "target procfs <node>".  */
-struct nto_procfs_target_procfs final : public nto_procfs_target
-{
-  const char *shortname () override
-  { return "procfs"; }
 
-  const char *longname () override
-  { return _("QNX Neutrino local or remote process"); }
+static const target_info nto_procfs_target_info = {
+  "procfs",
+  N_("QNX Neutrino local or remote process"),
+  N_("QNX Neutrino process.  target procfs <node>")
+};
 
-  const char *doc () override
-  { return _("QNX Neutrino process.  target procfs <node>"); }
+struct nto_procfs_target_procfs final : public nto_procfs_target
+{
+  const target_info &info () const override
+  { return nto_procfs_target_info; }
 };
 
 static ptid_t do_attach (ptid_t ptid);
@@ -1519,10 +1522,11 @@ static void
 init_procfs_targets (void)
 {
   /* Register "target native".  This is the default run target.  */
-  add_target (&nto_native_ops);
+  add_target (nto_native_target_info, inf_child_open_target);
+  set_native_target (&nto_native_ops);
 
   /* Register "target procfs <node>".  */
-  add_target (&nto_procfs_ops);
+  add_target (nto_procfs_target_info, inf_child_open_target);
 }
 
 #define OSTYPE_NTO 1
index 501514f6da01276dacf3fb9f5b1e15ecd3525ed0..6ca4bbac39324ed8fb5c346f19934d3b3618a5ab 100644 (file)
@@ -204,7 +204,7 @@ ppcfbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 void
 _initialize_ppcfbsd_nat (void)
 {
-  add_target (&the_ppc_fbsd_nat_target);
+  add_inf_child_target (&the_ppc_fbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (ppcfbsd_supply_pcb);
index a1c3dc8fe335a9a54f3a85aa444e9ddcbc381152..142333933930fb5cb74820a8066cc4fff14fb405 100644 (file)
@@ -2509,5 +2509,5 @@ _initialize_ppc_linux_nat (void)
   gdb::observers::thread_exit.attach (ppc_linux_thread_exit);
 
   /* Register the target.  */
-  add_target (linux_target);
+  add_inf_child_target (linux_target);
 }
index 3120b2ea2f9b975a49ef51813ffc425bcf8d3425..f6e3884a3d5cca6ed9bb7586cb6c390d5204967b 100644 (file)
@@ -186,5 +186,5 @@ _initialize_ppcnbsd_nat (void)
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (ppcnbsd_supply_pcb);
 
-  add_target (&the_ppc_nbsd_nat_target);
+  add_inf_child_target (&the_ppc_nbsd_nat_target);
 }
index 974100192998446aeb0acd212802bff002559a12..781b09c7fe4a87283eee58c21a17819ed5aa00c3 100644 (file)
@@ -190,7 +190,7 @@ ppcobsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 void
 _initialize_ppcobsd_nat (void)
 {
-  add_target (&the_ppc_obsd_nat_target);
+  add_inf_child_target (&the_ppc_obsd_nat_target);
 
   /* General-purpose registers.  */
   ppcobsd_reg_offsets.r0_offset = offsetof (struct reg, gpr);
index 03cbe3d9e7abe945d80b9e61656a0ca0bb11d892..5f3e179deca76292dd565dffc0a7f5d8e47eca46 100644 (file)
@@ -73,19 +73,19 @@ static const char first_task_name[] = "system__tasking__debug__first_task";
 static const char ravenscar_runtime_initializer[] =
   "system__bb__threads__initialize";
 
+static const target_info ravenscar_target_info = {
+  "ravenscar",
+  N_("Ravenscar tasks."),
+  N_("Ravenscar tasks support.")
+};
+
 struct ravenscar_thread_target final : public target_ops
 {
   ravenscar_thread_target ()
   { to_stratum = thread_stratum; }
 
-  const char *shortname () override
-  { return "ravenscar"; }
-
-  const char *longname () override
-  { return _("Ravenscar tasks."); }
-
-  const char *doc () override
-  { return _("Ravenscar tasks support."); }
+  const target_info &info () const override
+  { return ravenscar_target_info; }
 
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
   void resume (ptid_t, int, enum gdb_signal) override;
index 63621240e66da706aa36110a119de74e717a465f..a7a565b865a71d9e8dd8c61b91fabfa0b68d9934 100644 (file)
 #include "vec.h"
 #include <algorithm>
 
+static const target_info record_btrace_target_info = {
+  "record-btrace",
+  N_("Branch tracing target"),
+  N_("Collect control-flow trace and provide the execution history.")
+};
+
 /* The target_ops of record-btrace.  */
 
 class record_btrace_target final : public target_ops
@@ -49,16 +55,9 @@ public:
   record_btrace_target ()
   { to_stratum = record_stratum; }
 
-  const char *shortname () override
-  { return "record-btrace"; }
-
-  const char *longname () override
-  { return _("Branch tracing target"); }
+  const target_info &info () const override
+  { return record_btrace_target_info; }
 
-  const char *doc () override
-  { return _("Collect control-flow trace and provide the execution history."); }
-
-  void open (const char *, int) override;
   void close () override;
   void async (int) override;
 
@@ -372,10 +371,10 @@ private:
   std::forward_list<thread_info *> m_threads;
 };
 
-/* The open method of target record-btrace.  */
+/* Open target record-btrace.  */
 
-void
-record_btrace_target::open (const char *args, int from_tty)
+static void
+record_btrace_target_open (const char *args, int from_tty)
 {
   /* If we fail to enable btrace for one thread, disable it for the threads for
      which it was successfully enabled.  */
@@ -3314,7 +3313,7 @@ to see the actual buffer size."), NULL, show_record_pt_buffer_size_value,
                            &set_record_btrace_pt_cmdlist,
                            &show_record_btrace_pt_cmdlist);
 
-  add_target (&record_btrace_ops);
+  add_target (record_btrace_target_info, record_btrace_target_open);
 
   bfcache = htab_create_alloc (50, bfcache_hash, bfcache_eq, NULL,
                               xcalloc, xfree);
index 58f4be4fea0a55e5a9895b195ede9816d6110e4e..79f5c0fa0a64079628ef5ff836c489a00b998f1b 100644 (file)
@@ -206,6 +206,11 @@ static unsigned int record_full_insn_num = 0;
    than count of insns presently in execution log).  */
 static ULONGEST record_full_insn_count;
 
+static const char record_longname[]
+  = N_("Process record and replay target");
+static const char record_doc[]
+  = N_("Log program while executing and replay execution from log.");
+
 /* Base class implementing functionality common to both the
    "record-full" and "record-core" targets.  */
 
@@ -215,15 +220,8 @@ public:
   record_full_base_target ()
   { to_stratum = record_stratum; }
 
-  const char *shortname () override = 0;
-
-  const char *longname () override
-  { return _("Process record and replay target"); }
-
-  const char *doc () override
-  { return _("Log program while executing and replay execution from log."); }
+  const target_info &info () const override = 0;
 
-  void open (const char *, int) override;
   void close () override;
   void async (int) override;
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
@@ -257,11 +255,17 @@ public:
 
 /* The "record-full" target.  */
 
+static const target_info record_full_target_info = {
+  "record-full",
+  record_longname,
+  record_doc,
+};
+
 class record_full_target final : public record_full_base_target
 {
 public:
-  const char *shortname () override
-  { return "record-full"; }
+  const target_info &info () const override
+  { return record_full_target_info; }
 
   void commit_resume () override;
   void resume (ptid_t, int, enum gdb_signal) override;
@@ -285,11 +289,17 @@ public:
 
 /* The "record-core" target.  */
 
+static const target_info record_full_core_target_info = {
+  "record-core",
+  record_longname,
+  record_doc,
+};
+
 class record_full_core_target final : public record_full_base_target
 {
 public:
-  const char *shortname () override
-  { return "record-core"; }
+  const target_info &info () const override
+  { return record_full_core_target_info; }
 
   void resume (ptid_t, int, enum gdb_signal) override;
   void disconnect (const char *, int) override;
@@ -900,7 +910,7 @@ record_full_async_inferior_event_handler (gdb_client_data data)
   inferior_event_handler (INF_REG_EVENT, NULL);
 }
 
-/* Open the process record target.  */
+/* Open the process record target for 'core' files.  */
 
 static void
 record_full_core_open_1 (const char *name, int from_tty)
@@ -930,7 +940,7 @@ record_full_core_open_1 (const char *name, int from_tty)
   record_full_restore ();
 }
 
-/* "open" target method for 'live' processes.  */
+/* Open the process record target for 'live' processes.  */
 
 static void
 record_full_open_1 (const char *name, int from_tty)
@@ -954,10 +964,10 @@ record_full_open_1 (const char *name, int from_tty)
 
 static void record_full_init_record_breakpoints (void);
 
-/* "open" target method.  Open the process record target.  */
+/* Open the process record target.  */
 
-void
-record_full_base_target::open (const char *name, int from_tty)
+static void
+record_full_open (const char *name, int from_tty)
 {
   if (record_debug)
     fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
@@ -2519,7 +2529,7 @@ static void
 cmd_record_full_restore (const char *args, int from_tty)
 {
   core_file_command (args, from_tty);
-  record_full_ops.open (args, from_tty);
+  record_full_open (args, from_tty);
 }
 
 /* Save the execution log to a file.  We use a modified elf corefile
@@ -2808,9 +2818,9 @@ _initialize_record_full (void)
   record_full_first.next = NULL;
   record_full_first.type = record_full_end;
 
-  add_target (&record_full_ops);
-  add_deprecated_target_alias (&record_full_ops, "record");
-  add_target (&record_full_core_ops);
+  add_target (record_full_target_info, record_full_open);
+  add_deprecated_target_alias (record_full_target_info, "record");
+  add_target (record_full_core_target_info, record_full_open);
 
   add_prefix_cmd ("full", class_obscure, cmd_record_full_start,
                  _("Start full execution recording."), &record_full_cmdlist,
index bbbc02fcb70c71f41f90f2a6df2a57547a8fc4b9..5fd24cbdb1ab3ea4d62fe5e9658901ca9567c32c 100644 (file)
@@ -75,22 +75,21 @@ void simulator_command (char *args, int from_tty);
    sim_* are the interface to the simulator (see remote-sim.h).
    gdbsim_* are stuff which is internal to gdb.  */
 
+static const target_info gdbsim_target_info = {
+  "sim",
+  N_("simulator"),
+  N_("Use the compiled-in simulator.")
+};
+
 struct gdbsim_target final
   : public memory_breakpoint_target<target_ops>
 {
   gdbsim_target ()
   { to_stratum = process_stratum; }
 
-  const char *shortname () override
-  { return "sim"; }
-
-  const char *longname () override
-  { return _("simulator"); }
+  const target_info &info () const override
+  { return gdbsim_target_info; }
 
-  const char *doc () override
-  { return _("Use the compiled-in simulator."); }
-
-  void open (const char *, int) override;
   void close () override;
 
   void detach (inferior *inf, int) override;
@@ -701,8 +700,8 @@ gdbsim_target::create_inferior (const char *exec_file,
    Targets should supply this routine, if only to provide an error message.  */
 /* Called when selecting the simulator.  E.g. (gdb) target sim name.  */
 
-void
-gdbsim_target::open (const char *args, int from_tty)
+static void
+gdbsim_target_open (const char *args, int from_tty)
 {
   int len;
   char *arg_buf;
@@ -1344,7 +1343,7 @@ _initialize_remote_sim (void)
 {
   struct cmd_list_element *c;
 
-  add_target (&gdbsim_ops);
+  add_target (gdbsim_target_info, gdbsim_target_open);
 
   c = add_com ("sim", class_obscure, simulator_command,
               _("Send a command to the simulator."));
index 09c23a398af2aa3d385e1c6591d3967b523897dc..89cba546673fe9de37f45d6d1be5d0632dccfad9 100644 (file)
 
 /* The remote target.  */
 
+static const char remote_doc[] = N_("\
+Use a remote computer via a serial line, using a gdb-specific protocol.\n\
+Specify the serial device it is connected to\n\
+(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
+
+static const target_info remote_target_info = {
+  "remote",
+  N_("Remote serial target in gdb-specific protocol"),
+  remote_doc
+};
+
 class remote_target : public target_ops
 {
 public:
@@ -86,24 +97,15 @@ public:
     to_stratum = process_stratum;
   }
 
-  const char *shortname () override
-  { return "remote"; }
-
-  const char *longname () override
-  { return _("Remote serial target in gdb-specific protocol"); }
-
-  const char *doc () override
-  {
-    return _("\
-Use a remote computer via a serial line, using a gdb-specific protocol.\n\
-Specify the serial device it is connected to\n\
-(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).");
-  }
+  const target_info &info () const override
+  { return remote_target_info; }
 
   thread_control_capabilities get_thread_control_capabilities () override
   { return tc_schedlock; }
 
-  void open (const char *, int) override;
+  /* Open a remote connection.  */
+  static void open (const char *, int);
+
   void close () override;
 
   void detach (inferior *, int) override;
@@ -376,23 +378,27 @@ Specify the serial device it is connected to\n\
   enum exec_direction_kind execution_direction () override;
 
 protected:
-  void open_1 (const char *name, int from_tty, int extended_p);
+  static void open_1 (const char *name, int from_tty, int extended_p);
   void start_remote (int from_tty, int extended_p);
 };
 
+static const target_info extended_remote_target_info = {
+  "extended-remote",
+  N_("Extended remote serial target in gdb-specific protocol"),
+  remote_doc
+};
+
 /* Set up the extended remote target by extending the standard remote
    target and adding to it.  */
 
 class extended_remote_target final : public remote_target
 {
 public:
-  const char *shortname () override
-  { return "extended-remote"; }
+  const target_info &info () const override
+  { return extended_remote_target_info; }
 
-  const char *longname () override
-  { return _("Extended remote serial target in gdb-specific protocol"); }
-
-  void open (const char *, int) override;
+  /* Open an extended-remote connection.  */
+  static void open (const char *, int);
 
   bool can_create_inferior () override { return true; }
   void create_inferior (const char *, const std::string &,
@@ -5268,7 +5274,10 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
       puts_filtered (name);
       puts_filtered ("\n");
     }
-  push_target (this);          /* Switch to using remote target now.  */
+
+  remote_target *target
+    = extended_p ? &extended_remote_ops : &remote_ops;
+  push_target (target);                /* Switch to using remote target now.  */
 
   /* Register extra event sources in the event loop.  */
   remote_async_inferior_event_token
@@ -5336,7 +5345,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
 
     TRY
       {
-       start_remote (from_tty, extended_p);
+       target->start_remote (from_tty, extended_p);
       }
     CATCH (ex, RETURN_MASK_ALL)
       {
@@ -14007,8 +14016,8 @@ _initialize_remote (void)
      time.  */
   remote_state = new_remote_state ();
 
-  add_target (&remote_ops);
-  add_target (&extended_remote_ops);
+  add_target (remote_target_info, remote_target::open);
+  add_target (extended_remote_target_info, extended_remote_target::open);
 
   /* Hook into new objfile notification.  */
   gdb::observers::new_objfile.attach (remote_new_objfile);
index 0880d3748e03e76199f458edcee790d3f8e874b1..e9f064710add8490481bf29bac3d9b6679e9ba20 100644 (file)
@@ -671,5 +671,5 @@ rs6000_nat_target::xfer_shared_libraries
 void
 _initialize_rs6000_nat (void)
 {
-  add_target (&the_rs6000_nat_target);
+  add_inf_child_target (&the_rs6000_nat_target);
 }
index 7d17e9d1c9c6ffd86a4592602a404bdc7082bc85..c54c8d212d6062e9381b30ae0ab855e222ad6593 100644 (file)
@@ -1065,11 +1065,9 @@ s390_linux_nat_target::read_description ()
 void
 _initialize_s390_nat (void)
 {
-  struct target_ops *t = &the_s390_linux_nat_target;
-
   /* Register the target.  */
   linux_target = &the_s390_linux_nat_target;
-  add_target (t);
+  add_inf_child_target (&the_s390_linux_nat_target);
 
   /* A maintenance command to enable showing the PER state.  */
   add_setshow_boolean_cmd ("show-debug-regs", class_maintenance,
index f776e1c07bbf9b9573bf5f5ccc518179ec31d596..6bd089e32b31f332ccaec8a958734498fbb4cd19 100644 (file)
@@ -99,5 +99,5 @@ sh_nbsd_nat_target::store_registers (struct regcache *regcache, int regno)
 void
 _initialize_shnbsd_nat (void)
 {
-  add_target (&the_sh_nbsd_nat_target);
+  add_inf_child_target (&the_sh_nbsd_nat_target);
 }
index d5c2400c7ed63a831b9832b341d10a9d58912147..22dd8d6eaab403c1fa07dcc4903f6bddb131f5a5 100644 (file)
 #include "minsyms.h"
 #include "objfiles.h"
 
+static const target_info thread_db_target_info = {
+  "solaris-threads",
+  N_("Solaris threads and pthread."),
+  N_("Solaris threads and pthread support.")
+};
+
 class sol_thread_target final : public target_ops
 {
 public:
   sol_thread_target ()
   { this->to_stratum = thread_stratum; }
 
-  const char *shortname () override
-  { return "solaris-threads"; }
-  const char *longname () override
-  { return _("Solaris threads and pthread."); }
-  const char *doc () override
-  { return _("Solaris threads and pthread support."); }
+  const target_info &info () const override
+  { return thread_db_target_info; }
 
   void detach (inferior *, int) override;
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
index c32d0ec0ebabdfa8682ccb84e01a38650d539fd2..2df0025135ca65ac115f8601de23e16ae65f1dbf 100644 (file)
@@ -73,5 +73,5 @@ _initialize_sparc_linux_nat (void)
 
   /* Register the target.  */
   linux_target = &the_sparc_linux_nat_target;
-  add_target (&the_sparc_linux_nat_target);
+  add_inf_child_target (&the_sparc_linux_nat_target);
 }
index 5ff723d3422a5b96b940c04fa09fbfa9c9ad6a41..e1ed44202cd164af5d7ea74facddc87667b999dc 100644 (file)
@@ -63,7 +63,7 @@ _initialize_sparcnbsd_nat (void)
   sparc_gregmap = &sparc32nbsd_gregmap;
   sparc_fpregmap = &sparc32_bsd_fpregmap;
 
-  add_target (&sparc_nbsd_nat_target);
+  add_inf_child_target (&sparc_nbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (sparc32nbsd_supply_pcb);
index 00c1ece2db571730f1bc8924f2ccf0f644ed1a01..20c6a28d18f7a37d14aa16d1426fffae633dba8b 100644 (file)
@@ -65,9 +65,7 @@ static sparc_target<fbsd_nat_target> the_sparc64_fbsd_nat_target;
 void
 _initialize_sparc64fbsd_nat (void)
 {
-  struct target_ops *t;
-
-  add_target (&the_sparc64_fbsd_nat_target);
+  add_inf_child_target (&the_sparc64_fbsd_nat_target);
 
   sparc_gregmap = &sparc64fbsd_gregmap;
 
index 9ac1afe6dca429340c0b0afada5fcab4ec250b77..ba9397e3d994ac993f08284a80ac1569d7d8a56e 100644 (file)
@@ -91,13 +91,11 @@ fill_fpregset (const struct regcache *regcache,
 void
 _initialize_sparc64_linux_nat (void)
 {
-  target_ops *t = &the_sparc64_linux_nat_target;
-
   sparc_fpregmap = &sparc64_bsd_fpregmap;
 
   /* Register the target.  */
   linux_target = &the_sparc64_linux_nat_target;
-  add_target (t);
+  add_inf_child_target (&the_sparc64_linux_nat_target);
 
   sparc_gregmap = &sparc64_linux_ptrace_gregmap;
 }
index a0bfd8138e920e76b15c32bc012c9233a55c45cd..ac760b341d0e260757a11f1dc7eb5f6a1e4957d7 100644 (file)
@@ -180,7 +180,7 @@ _initialize_sparc64nbsd_nat (void)
   sparc_gregset_supplies_p = sparc64nbsd_gregset_supplies_p;
   sparc_fpregset_supplies_p = sparc64nbsd_fpregset_supplies_p;
 
-  add_target (&the_sparc64_nbsd_nat_target);
+  add_inf_child_target (&the_sparc64_nbsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (sparc64nbsd_supply_pcb);
index 67629aa05ede3c36fca067cc6f0518a9aa11d348..eeef363036397218b48c8f9a3bcdad8007d852ea 100644 (file)
@@ -123,7 +123,7 @@ _initialize_sparc64obsd_nat (void)
   sparc_fpregmap = &sparc64_bsd_fpregmap;
 
   /* Add some extra features to the generic SPARC target.  */
-  add_target (&the_sparc64_obsd_nat_target);
+  add_inf_child_target (&the_sparc64_obsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (sparc64obsd_supply_pcb);
index 8b4c643b2cdfd4593c30745c5451a2e0544f5a7b..c289bb75fe1abb9a5c48dff60208ee9b3c9b94e9 100644 (file)
@@ -658,5 +658,5 @@ spu_linux_nat_target::can_use_hw_breakpoint (enum bptype type,
 void 
 _initialize_spu_nat (void)
 {
-  add_target (&the_spu_linux_nat_target);
+  add_inf_child_target (&the_spu_linux_nat_target);
 }
index 1886807d37bbaa9c19604844b27781b0bf8ae237..5da5e4e7fcdaded5ea207273a1aab3dbc2fb6dd8 100644 (file)
 
 /* The SPU multi-architecture support target.  */
 
+static const target_info spu_multiarch_target_info = {
+  "spu",
+  N_("SPU multi-architecture support."),
+  N_("SPU multi-architecture support.")
+};
+
 struct spu_multiarch_target final : public target_ops
 {
   spu_multiarch_target ()
   { to_stratum = arch_stratum; };
 
-  const char *shortname () override
-  { return "spu"; }
-
-  const char *longname () override
-  { return _("SPU multi-architecture support."); }
-
-  const char *doc () override
-  { return _("SPU multi-architecture support."); }
+  const target_info &info () const override
+  { return spu_multiarch_target_info; }
 
   void mourn_inferior () override;
 
index c06b700d6f294d53157a8699dfc5d5f1034203ef..da7434712249b79dc84324cc6e0b2f2837517cd7 100644 (file)
@@ -8,9 +8,7 @@ struct dummy_target : public target_ops
 {
   dummy_target ();
 
-  const char *shortname () override;
-  const char *longname () override;
-  const char *doc () override;
+  const target_info &info () const override;
 
   void post_attach (int arg0) override;
   void detach (inferior *arg0, int arg1) override;
@@ -178,9 +176,7 @@ struct debug_target : public target_ops
 {
   debug_target ();
 
-  const char *shortname () override;
-  const char *longname () override;
-  const char *doc () override;
+  const target_info &info () const override;
 
   void post_attach (int arg0) override;
   void detach (inferior *arg0, int arg1) override;
index 3ed5537e2d5af58b0be0df11b467c786200a0869..d96cdec418824a7cbbeb0589d1663b00a0c199a4 100644 (file)
@@ -49,6 +49,7 @@
 #include "byte-vector.h"
 #include "terminal.h"
 #include <algorithm>
+#include <unordered_map>
 
 static void generic_tls_error (void) ATTRIBUTE_NORETURN;
 
@@ -103,10 +104,14 @@ static const char *default_pid_to_str (struct target_ops *ops, ptid_t ptid);
 static enum exec_direction_kind default_execution_direction
     (struct target_ops *self);
 
-/* Vector of existing target structures. */
-typedef struct target_ops *target_ops_p;
-DEF_VEC_P (target_ops_p);
-static VEC (target_ops_p) *target_structs;
+/* Mapping between target_info objects (which have address identity)
+   and corresponding open/factory function/callback.  Each add_target
+   call adds one entry to this map, and registers a "target
+   TARGET_NAME" command that when invoked calls the factory registered
+   here.  The target_info object is associated with the command via
+   the command's context.  */
+static std::unordered_map<const target_info *, target_open_ftype *>
+  target_factories;
 
 /* The initial current target, so that there is always a semi-valid
    current target.  */
@@ -179,6 +184,27 @@ target_command (const char *arg, int from_tty)
                  gdb_stdout);
 }
 
+#if GDB_SELF_TEST
+namespace selftests {
+
+/* A mock process_stratum target_ops that doesn't read/write registers
+   anywhere.  */
+
+static const target_info test_target_info = {
+  "test",
+  N_("unit tests target"),
+  N_("You should never see this"),
+};
+
+const target_info &
+test_target_ops::info () const
+{
+  return test_target_info;
+}
+
+} /* namespace selftests */
+#endif /* GDB_SELF_TEST */
+
 /* Default target_has_* methods for process_stratum targets.  */
 
 int
@@ -304,30 +330,33 @@ target_has_execution_current (void)
 static void
 open_target (const char *args, int from_tty, struct cmd_list_element *command)
 {
-  struct target_ops *ops = (struct target_ops *) get_cmd_context (command);
+  auto *ti = static_cast<target_info *> (get_cmd_context (command));
+  target_open_ftype *func = target_factories[ti];
 
   if (targetdebug)
-    fprintf_unfiltered (gdb_stdlog, "-> %s->to_open (...)\n",
-                       ops->shortname ());
+    fprintf_unfiltered (gdb_stdlog, "-> %s->open (...)\n",
+                       ti->shortname);
 
-  ops->open (args, from_tty);
+  func (args, from_tty);
 
   if (targetdebug)
-    fprintf_unfiltered (gdb_stdlog, "<- %s->to_open (%s, %d)\n",
-                       ops->shortname (), args, from_tty);
+    fprintf_unfiltered (gdb_stdlog, "<- %s->open (%s, %d)\n",
+                       ti->shortname, args, from_tty);
 }
 
-/* Add possible target architecture T to the list and add a new
-   command 'target T->shortname ()'.  Set COMPLETER as the command's
-   completer if not NULL.  */
+/* See target.h.  */
 
 void
-add_target_with_completer (struct target_ops *t,
-                          completer_ftype *completer)
+add_target (const target_info &t, target_open_ftype *func,
+           completer_ftype *completer)
 {
   struct cmd_list_element *c;
 
-  VEC_safe_push (target_ops_p, target_structs, t);
+  auto &func_slot = target_factories[&t];
+  if (func_slot != nullptr)
+    internal_error (__FILE__, __LINE__,
+                   _("target already added (\"%s\")."), t.shortname);
+  func_slot = func;
 
   if (targetlist == NULL)
     add_prefix_cmd ("target", class_run, target_command, _("\
@@ -337,35 +366,27 @@ Remaining arguments are interpreted by the target protocol.  For more\n\
 information on the arguments for a particular protocol, type\n\
 `help target ' followed by the protocol name."),
                    &targetlist, "target ", 0, &cmdlist);
-  c = add_cmd (t->shortname (), no_class, t->doc (), &targetlist);
+  c = add_cmd (t.shortname, no_class, t.doc, &targetlist);
+  set_cmd_context (c, (void *) &t);
   set_cmd_sfunc (c, open_target);
-  set_cmd_context (c, t);
   if (completer != NULL)
     set_cmd_completer (c, completer);
 }
 
-/* Add a possible target architecture to the list.  */
-
-void
-add_target (struct target_ops *t)
-{
-  add_target_with_completer (t, NULL);
-}
-
 /* See target.h.  */
 
 void
-add_deprecated_target_alias (struct target_ops *t, const char *alias)
+add_deprecated_target_alias (const target_info &tinfo, const char *alias)
 {
   struct cmd_list_element *c;
   char *alt;
 
   /* If we use add_alias_cmd, here, we do not get the deprecated warning,
      see PR cli/15104.  */
-  c = add_cmd (alias, no_class, t->doc (), &targetlist);
+  c = add_cmd (alias, no_class, tinfo.doc, &targetlist);
   set_cmd_sfunc (c, open_target);
-  set_cmd_context (c, t);
-  alt = xstrprintf ("target %s", t->shortname ());
+  set_cmd_context (c, (void *) &tinfo);
+  alt = xstrprintf ("target %s", tinfo.shortname);
   deprecate_cmd (c, alt);
 }
 
@@ -2420,6 +2441,32 @@ show_auto_connect_native_target (struct ui_file *file, int from_tty,
                    value);
 }
 
+/* A pointer to the target that can respond to "run" or "attach".
+   Native targets are always singletons and instantiated early at GDB
+   startup.  */
+static target_ops *the_native_target;
+
+/* See target.h.  */
+
+void
+set_native_target (target_ops *target)
+{
+  if (the_native_target != NULL)
+    internal_error (__FILE__, __LINE__,
+                   _("native target already set (\"%s\")."),
+                   the_native_target->longname ());
+
+  the_native_target = target;
+}
+
+/* See target.h.  */
+
+target_ops *
+get_native_target ()
+{
+  return the_native_target;
+}
+
 /* Look through the list of possible targets for a target that can
    execute a run or attach command without any other data.  This is
    used to locate the default process stratum.
@@ -2430,36 +2477,12 @@ show_auto_connect_native_target (struct ui_file *file, int from_tty,
 static struct target_ops *
 find_default_run_target (const char *do_mesg)
 {
-  struct target_ops *runable = NULL;
-
-  if (auto_connect_native_target)
-    {
-      struct target_ops *t;
-      int count = 0;
-      int i;
-
-      for (i = 0; VEC_iterate (target_ops_p, target_structs, i, t); ++i)
-       {
-         if (t->can_run ())
-           {
-             runable = t;
-             ++count;
-           }
-       }
-
-      if (count != 1)
-       runable = NULL;
-    }
+  if (auto_connect_native_target && the_native_target != NULL)
+    return the_native_target;
 
-  if (runable == NULL)
-    {
-      if (do_mesg)
-       error (_("Don't know how to %s.  Try \"help target\"."), do_mesg);
-      else
-       return NULL;
-    }
-
-  return runable;
+  if (do_mesg != NULL)
+    error (_("Don't know how to %s.  Try \"help target\"."), do_mesg);
+  return NULL;
 }
 
 /* See target.h.  */
@@ -2467,20 +2490,15 @@ find_default_run_target (const char *do_mesg)
 struct target_ops *
 find_attach_target (void)
 {
-  struct target_ops *t;
-
   /* If a target on the current stack can attach, use it.  */
-  for (t = target_stack; t != NULL; t = t->beneath)
+  for (target_ops *t = target_stack; t != NULL; t = t->beneath)
     {
       if (t->can_attach ())
-       break;
+       return t;
     }
 
   /* Otherwise, use the default run target for attaching.  */
-  if (t == NULL)
-    t = find_default_run_target ("attach");
-
-  return t;
+  return find_default_run_target ("attach");
 }
 
 /* See target.h.  */
@@ -2488,20 +2506,15 @@ find_attach_target (void)
 struct target_ops *
 find_run_target (void)
 {
-  struct target_ops *t;
-
   /* If a target on the current stack can run, use it.  */
-  for (t = target_stack; t != NULL; t = t->beneath)
+  for (target_ops *t = target_stack; t != NULL; t = t->beneath)
     {
       if (t->can_create_inferior ())
-       break;
+       return t;
     }
 
   /* Otherwise, use the default run target.  */
-  if (t == NULL)
-    t = find_default_run_target ("run");
-
-  return t;
+  return find_default_run_target ("run");
 }
 
 bool
@@ -2614,12 +2627,6 @@ target_thread_address_space (ptid_t ptid)
   return aspace;
 }
 
-void
-target_ops::open (const char *, int)
-{
-  gdb_assert_not_reached ("target_ops::open called");
-}
-
 void
 target_ops::close ()
 {
@@ -3332,50 +3339,32 @@ dummy_make_corefile_notes (struct target_ops *self,
 #include "target-delegates.c"
 
 
+static const target_info dummy_target_info = {
+  "None",
+  N_("None"),
+  ""
+};
+
 dummy_target::dummy_target ()
 {
   to_stratum = dummy_stratum;
 }
 
-const char *
-dummy_target::shortname ()
-{
-  return "None";
-}
-
-const char *
-dummy_target::longname ()
-{
-  return _("None");
-}
-
-const char *
-dummy_target::doc ()
-{
-  return "";
-}
-
 debug_target::debug_target ()
 {
   to_stratum = debug_stratum;
 }
 
-const char *
-debug_target::shortname ()
+const target_info &
+dummy_target::info () const
 {
-  return beneath->shortname ();
+  return dummy_target_info;
 }
 
-const char *
-debug_target::longname ()
-{
-  return beneath->longname ();
-}
-
-const char *
-debug_target::doc ()
+const target_info &
+debug_target::info () const
 {
-  return beneath->doc ();
+  return beneath->info ();
 }
 
 \f
index cd49fce92bcab0cb72faacade106b98d2689ca8d..b37702b501dd1fbc172197e47c3d1635bdb86281 100644 (file)
@@ -404,27 +404,44 @@ typedef void async_callback_ftype (enum inferior_event_type event_type,
 #define TARGET_DEFAULT_RETURN(ARG)
 #define TARGET_DEFAULT_FUNC(ARG)
 
+/* Each target that can be activated with "target TARGET_NAME" passes
+   the address of one of these objects to add_target, which uses the
+   object's address as unique identifier, and registers the "target
+   TARGET_NAME" command using SHORTNAME as target name.  */
+
+struct target_info
+{
+  /* Name of this target.  */
+  const char *shortname;
+
+  /* Name for printing.  */
+  const char *longname;
+
+  /* Documentation.  Does not include trailing newline, and starts
+     with a one-line description (probably similar to longname).  */
+  const char *doc;
+};
+
 struct target_ops
   {
     struct target_ops *beneath;        /* To the target under this one.  */
 
+    /* Free resources associated with the target.  Note that singleton
+       targets, like e.g., native targets, are global objects, not
+       heap allocated, and are thus only deleted on GDB exit.  The
+       main teardown entry point is the "close" method, below.  */
     virtual ~target_ops () {}
 
-    /* Name this target type.  */
-    virtual const char *shortname () = 0;
-
-    /* Name for printing.  */
-    virtual const char *longname () = 0;
+    /* Return a reference to this target's unique target_info
+       object.  */
+    virtual const target_info &info () const = 0;
 
-    /* Documentation.  Does not include trailing newline, and starts
-       ith a one-line description (probably similar to longname).  */
-    virtual const char *doc () = 0;
+    /* Name this target type.  */
+    const char *shortname ()
+    { return info ().shortname; }
 
-    /* The open routine takes the rest of the parameters from the
-       command, and (if successful) pushes a new target onto the
-       stack.  Targets should supply this routine, if only to provide
-       an error message.  */
-    virtual void open (const char *, int);
+    const char *longname ()
+    { return info ().longname; }
 
     /* Close the target.  This is where the target can handle
        teardown.  Heap-allocated targets should delete themselves
@@ -1226,6 +1243,15 @@ struct target_ops
       TARGET_DEFAULT_IGNORE ();
   };
 
+/* Native target backends call this once at initialization time to
+   inform the core about which is the target that can respond to "run"
+   or "attach".  Note: native targets are always singletons.  */
+extern void set_native_target (target_ops *target);
+
+/* Get the registered native target, if there's one.  Otherwise return
+   NULL.  */
+extern target_ops *get_native_target ();
+
 /* The ops structure for our "current" target process.  This should
    never be NULL.  If there is no target, it points to the dummy_target.  */
 
@@ -2207,15 +2233,25 @@ int target_verify_memory (const gdb_byte *data,
    no matter where it is on the list.  Returns 0 if no
    change, 1 if removed from stack.  */
 
-extern void add_target (struct target_ops *);
+/* Type of callback called when the user activates a target with
+   "target TARGET_NAME".  The callback routine takes the rest of the
+   parameters from the command, and (if successful) pushes a new
+   target onto the stack.  */
+typedef void target_open_ftype (const char *args, int from_tty);
+
+/* Add the target described by INFO to the list of possible targets
+   and add a new command 'target $(INFO->shortname)'.  Set COMPLETER
+   as the command's completer if not NULL.  */
 
-extern void add_target_with_completer (struct target_ops *t,
-                                      completer_ftype *completer);
+extern void add_target (const target_info &info,
+                       target_open_ftype *func,
+                       completer_ftype *completer = NULL);
 
-/* Adds a command ALIAS for target T and marks it deprecated.  This is useful
-   for maintaining backwards compatibility when renaming targets.  */
+/* Adds a command ALIAS for the target described by INFO and marks it
+   deprecated.  This is useful for maintaining backwards compatibility
+   when renaming targets.  */
 
-extern void add_deprecated_target_alias (struct target_ops *t,
+extern void add_deprecated_target_alias (const target_info &info,
                                         const char *alias);
 
 extern void push_target (struct target_ops *);
@@ -2466,20 +2502,7 @@ public:
     to_stratum = process_stratum;
   }
 
-  const char *shortname () override
-  {
-    return NULL;
-  }
-
-  const char *longname () override
-  {
-    return NULL;
-  }
-
-  const char *doc () override
-  {
-    return NULL;
-  }
+  const target_info &info () const override;
 
   bool has_registers () override
   {
index a374d8bd2efe8e2f6c110da6185ae369762962b3..753d81859d61f1f8eeaaf1645a308dbfd7c531cc 100644 (file)
@@ -168,5 +168,5 @@ void
 _initialize_tile_linux_nat (void)
 {
   linux_target = &the_tilegx_linux_nat_target;
-  add_target (&the_tilegx_linux_nat_target);
+  add_inf_child_target (&the_tilegx_linux_nat_target);
 }
index d224ad9760ad9ff7be1d2358179a5ac148325d2e..f4fdd3674da2047e6e8192f71118a1aadeaf341b 100644 (file)
 
 /* The tfile target.  */
 
+static const target_info tfile_target_info = {
+  "tfile",
+  N_("Local trace dump file"),
+  N_("Use a trace file as a target.  Specify the filename of the trace file.")
+};
+
 class tfile_target final : public tracefile_target
 {
  public:
-  const char *shortname () override
-  { return "tfile"; }
-
-  const char *longname () override
-  { return _("Local trace dump file"); }
-
-  const char *doc () override
-  {
-    return _("\
-Use a trace file as a target.  Specify the filename of the trace file.");
-  }
+  const target_info &info () const override
+  { return tfile_target_info; }
 
-  void open (const char *, int) override;
   void close () override;
   void fetch_registers (struct regcache *, int) override;
   enum target_xfer_status xfer_partial (enum target_object object,
@@ -451,8 +447,10 @@ tfile_read (gdb_byte *readbuf, int size)
     error (_("Premature end of file while reading trace file"));
 }
 
-void
-tfile_target::open (const char *arg, int from_tty)
+/* Open the tfile target.  */
+
+static void
+tfile_target_open (const char *arg, int from_tty)
 {
   int flags;
   int scratch_chan;
@@ -1139,5 +1137,5 @@ tfile_append_tdesc_line (const char *line)
 void
 _initialize_tracefile_tfile (void)
 {
-  add_target_with_completer (&tfile_ops, filename_completer);
+  add_target (tfile_target_info, tfile_target_open, filename_completer);
 }
index 6fc1b47940d75bcfa064144c2cb4efac6d0159d8..7f7b54a84125701a4254dbfbded66b8b6656ddc2 100644 (file)
@@ -135,7 +135,7 @@ vaxbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
 void
 _initialize_vaxbsd_nat (void)
 {
-  add_target (&the_vax_bsd_nat_target);
+  add_inf_child_target (&the_vax_bsd_nat_target);
 
   /* Support debugging kernel virtual memory images.  */
   bsd_kvm_add_target (vaxbsd_supply_pcb);
index f5a66c1f1c2e89d88d146162c940845d5dfd46fe..16ebd176072a6888aa7bfb0a7f15b500e9421b31 100644 (file)
@@ -3018,7 +3018,7 @@ _initialize_windows_nat (void)
      calling x86_set_debug_register_length function
      in processor windows specific native file.  */
 
-  add_target (&the_windows_nat_target);
+  add_inf_child_target (&the_windows_nat_target);
 
 #ifdef __CYGWIN__
   cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
index d5465a7d9d93878852308bb1f2a52f866a5e0bdf..8d9659b7f98c0f2f4b5641b230abc8a4c91db829 100644 (file)
@@ -365,5 +365,5 @@ _initialize_xtensa_linux_nat (void)
     }
 
   linux_target = &the_xtensa_linux_nat_target;
-  add_target (&the_xtensa_linux_nat_target);
+  add_inf_child_target (&the_xtensa_linux_nat_target);
 }