From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31765 invoked by alias); 2 Jul 2013 16:37:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 31698 invoked by uid 89); 2 Jul 2013 16:37:40 -0000 X-Spam-SWARE-Status: No, score=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 02 Jul 2013 16:37:38 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r62GbbkA015624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 2 Jul 2013 12:37:37 -0400 Received: from barimba.redhat.com (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r62Gba0F014749; Tue, 2 Jul 2013 12:37:37 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: RFC: don't call add_target for thread_db_ops Date: Tue, 02 Jul 2013 16:37:00 -0000 Message-Id: <1372783053-14925-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-07/txt/msg00078.txt.bz2 Right now, "help target" will include this line: target multi-thread -- Threads and pthreads support However, it doesn't make sense to invoke "target multi-thread". This patch fixes the problem by not registering the multi-thread target. add_target does some needed initialization of the target_ops, so I broke this out into a new function. It isn't clear to me whether this patch requires a test case or not. I'm not sure whether there are other unregistered targets; but if there are, it seems unlikely that we test for their absence from the help. Built and regtested on x86-64 Fedora 18. * 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. --- gdb/linux-thread-db.c | 3 ++- gdb/target.c | 23 ++++++++++++++++------- gdb/target.h | 5 +++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 23c29c9..3696827 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 920f916..5bf8059 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 1bf716e..00dad64 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1837,6 +1837,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 @@ -1855,6 +1858,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. */ -- 1.8.1.4