diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f942217f13..782a2627a8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2013-07-25 Tom Tromey + + * linux-thread-db.c (init_thread_db_ops): Call + complete_target_initialization. + (_initialize_thread_db): Don't call add_target. + * target.c (complete_target_initialization): New function. + (add_target_with_completer): Call it. + * target.h (complete_target_initialization): Declare. + 2013-07-25 Mark Kettenis * hppa-tdep.h (enum hppa_regnum): Add members for all space registers. diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 23c29c9dd1..36968272c0 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -2057,6 +2057,8 @@ init_thread_db_ops (void) thread_db_ops.to_extra_thread_info = thread_db_extra_thread_info; thread_db_ops.to_get_ada_task_ptid = thread_db_get_ada_task_ptid; thread_db_ops.to_magic = OPS_MAGIC; + + complete_target_initialization (&thread_db_ops); } /* Provide a prototype to silence -Wmissing-prototypes. */ @@ -2066,7 +2068,6 @@ void _initialize_thread_db (void) { init_thread_db_ops (); - add_target (&thread_db_ops); /* Defer loading of libthread_db.so until inferior is running. This allows gdb to load correct libthread_db for a given diff --git a/gdb/target.c b/gdb/target.c index 18e10cbdce..37b0a94b0c 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -381,16 +381,12 @@ target_has_execution_current (void) return target_has_execution_1 (inferior_ptid); } -/* Add possible target architecture T to the list and add a new - command 'target T->to_shortname'. Set COMPLETER as the command's - completer if not NULL. */ +/* Complete initialization of T. This ensures that various fields in + T are set, if needed by the target implementation. */ void -add_target_with_completer (struct target_ops *t, - completer_ftype *completer) +complete_target_initialization (struct target_ops *t) { - struct cmd_list_element *c; - /* Provide default values for all "must have" methods. */ if (t->to_xfer_partial == NULL) t->to_xfer_partial = default_xfer_partial; @@ -409,6 +405,19 @@ add_target_with_completer (struct target_ops *t, if (t->to_has_execution == NULL) t->to_has_execution = (int (*) (struct target_ops *, ptid_t)) return_zero; +} + +/* Add possible target architecture T to the list and add a new + command 'target T->to_shortname'. Set COMPLETER as the command's + completer if not NULL. */ + +void +add_target_with_completer (struct target_ops *t, + completer_ftype *completer) +{ + struct cmd_list_element *c; + + complete_target_initialization (t); if (!target_structs) { diff --git a/gdb/target.h b/gdb/target.h index e413e5590e..1cf198f343 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1747,6 +1747,9 @@ int target_verify_memory (const gdb_byte *data, /* Routines for maintenance of the target structures... + complete_target_initialization: Finalize a target_ops by filling in + any fields needed by the target implementation. + add_target: Add a target to the list of all possible targets. push_target: Make this target the top of the stack of currently used @@ -1765,6 +1768,8 @@ extern void add_target (struct target_ops *); extern void add_target_with_completer (struct target_ops *t, completer_ftype *completer); +extern void complete_target_initialization (struct target_ops *t); + /* Adds a command ALIAS for target T and marks it deprecated. This is useful for maintaining backwards compatibility when renaming targets. */