From patchwork Mon Jul 21 20:39:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 2126 Received: (qmail 15088 invoked by alias); 21 Jul 2014 20:39:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 15050 invoked by uid 89); 21 Jul 2014 20:39:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 21 Jul 2014 20:39:23 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6LKdMp3027316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 Jul 2014 16:39:22 -0400 Received: from barimba.redhat.com (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6LKdJat031247; Mon, 21 Jul 2014 16:39:20 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] fix to_open debug setting Date: Mon, 21 Jul 2014 14:39:14 -0600 Message-Id: <1405975154-19517-1-git-send-email-tromey@redhat.com> This is a follow-on to the patch to auto-generate target debug methods. While working on that patch I noticed that the to_open debug setting will never work. There is no path by which debug_to_open can be called. This patch fixes the problem by using a generic function as the implementation of the various "target" subcommands, and then putting the debug printing there. This is also a tiny step toward fixing PR 7250 (and apparently why command contexts were introduced). Built and regtested on x86-64 Fedora 20. 2014-07-21 Tom Tromey * target.c (open_target): New function. (add_target_with_completer): Use set_cmd_sfunc, set_cmd_context. (debug_to_open): Remove. (setup_target_debug): Update. --- gdb/ChangeLog | 7 +++++++ gdb/target.c | 28 ++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index b9310cf..0db21e2 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -118,8 +118,6 @@ static struct target_ops debug_target; static void init_dummy_target (void); -static void debug_to_open (char *, int); - /* Pointer to array of target architecture structures; the size of the array; the current index into the array; the allocated size of the array. */ @@ -345,6 +343,19 @@ complete_target_initialization (struct target_ops *t) install_delegators (t); } +/* This is used to implement the various target commands. */ + +static void +open_target (char *args, int from_tty, struct cmd_list_element *command) +{ + struct target_ops *ops = get_cmd_context (command); + + if (targetdebug) + fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty); + + ops->to_open (args, from_tty); +} + /* 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. */ @@ -380,8 +391,9 @@ 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->to_shortname, no_class, t->to_open, t->to_doc, - &targetlist); + c = add_cmd (t->to_shortname, no_class, NULL, t->to_doc, &targetlist); + set_cmd_sfunc (c, open_target); + set_cmd_context (c, t); if (completer != NULL) set_cmd_completer (c, completer); } @@ -2946,13 +2958,6 @@ init_dummy_target (void) install_dummy_methods (&dummy_target); } -static void -debug_to_open (char *args, int from_tty) -{ - debug_target.to_open (args, from_tty); - - fprintf_unfiltered (gdb_stdlog, "target_open (%s, %d)\n", args, from_tty); -} void target_close (struct target_ops *targ) @@ -3397,7 +3402,6 @@ setup_target_debug (void) { memcpy (&debug_target, ¤t_target, sizeof debug_target); - current_target.to_open = debug_to_open; init_debug_target (¤t_target); }