Re: RFC: don't call add_target for thread_db_ops

Tom Tromey
2013-07-25T18:25:36Z

Pedro> On 07/25/2013 05:31 PM, Tom Tromey wrote:
Pedro> Thanks. Do you plan on doing the same to the remaining
Pedro> thread_stratum targets? If not, I'll do it at some point.
Pedro> I'd prefer not leaving the incomplete transition in
Pedro> place; it's bound to confuse someone later on. I wouldn't
Pedro> worry much if an affected target goes untested.

Tom> I wasn't planning to, but my main concern was the testing; I will write
Tom> the patch today.

Pedro> Thanks!

Here you go.

Tom

This removes a few more erroneous calls to add_target. These calls
end up installing the target in a user-visible way; but these targets
are all auto-activated and, I think, should never be explicitly
requested.

I have no way to test these.

CCing Ulrich for the SPU case.

* aix-thread.c (_initialize_aix_thread): Use
complete_target_initialization.
* bsd-uthread.c (_initialize_bsd_uthread): Use
complete_target_initialization.
* dec-thread.c (_initialize_dec_thread): Use
complete_target_initialization.
* ravenscar-thread.c (_initialize_ravenscar): Use
complete_target_initialization.
* sol-thread.c (_initialize_sol_thread): Use
complete_target_initialization.
* spu-multiarch.c (_initialize_spu_multiarch): Use
complete_target_initialization.
---
gdb/aix-thread.c | 2 +-
gdb/bsd-uthread.c | 2 +-
gdb/dec-thread.c | 2 +-
gdb/ravenscar-thread.c | 2 +-
gdb/sol-thread.c | 2 +-
gdb/spu-multiarch.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index fd1d69b..70f9a3e 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1837,7 +1837,7 @@ void
_initialize_aix_thread (void)
{
init_aix_thread_ops ();
- add_target (&aix_thread_ops);
+ complete_target_initialization (&aix_thread_ops);

/* Notice when object files get loaded and unloaded. */
observer_attach_new_objfile (new_objfile);
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 6a07985..0a2ea81 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -547,7 +547,7 @@ extern initialize_file_ftype _initialize_bsd_uthread;
void
_initialize_bsd_uthread (void)
{
- add_target (bsd_uthread_target ());
+ complete_target_initialization (bsd_uthread_target ());

bsd_uthread_data = gdbarch_data_register_pre_init (bsd_uthread_init);

diff --git a/gdb/dec-thread.c b/gdb/dec-thread.c
index 27cf004..f07721d 100644
--- a/gdb/dec-thread.c
+++ b/gdb/dec-thread.c
@@ -727,7 +727,7 @@ void
_initialize_dec_thread (void)
{
init_dec_thread_ops ();
- add_target (&dec_thread_ops);
+ complete_target_initialization (&dec_thread_ops);

observer_attach_new_objfile (dec_thread_new_objfile_observer);

diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 0a3100d..26b8171 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -433,7 +433,7 @@ _initialize_ravenscar (void)
ravenscar ops if needed. */
observer_attach_inferior_created (ravenscar_inferior_created);

- add_target (&ravenscar_ops);
+ complete_target_initialization (&ravenscar_ops);

add_prefix_cmd ("ravenscar", no_class, set_ravenscar_command,
_("Prefix command for changing Ravenscar-specific settings"),
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index f1b29a0..c9abaf7 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1276,7 +1276,7 @@ _initialize_sol_thread (void)
resolve (td_thr_getgregs);
resolve (td_thr_setgregs);

- add_target (&sol_thread_ops);
+ complete_target_initialization (&sol_thread_ops);

add_cmd ("sol-threads", class_maintenance, info_solthreads,
_("Show info on Solaris user threads."), &maintenanceinfolist);
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index a74bd30..e93f142 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -410,7 +410,7 @@ _initialize_spu_multiarch (void)
{
/* Install ourselves on the target stack. */
init_spu_ops ();
- add_target (&spu_ops);
+ complete_target_initialization (&spu_ops);

/* Install observers to watch for SPU objects. */
observer_attach_inferior_created (spu_multiarch_inferior_created);
--
1.8.1.4