From patchwork Mon Mar 4 20:41:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31717 Received: (qmail 51996 invoked by alias); 4 Mar 2019 20:41:06 -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 51986 invoked by uid 89); 4 Mar 2019 20:41:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=$10, HContent-Transfer-Encoding:8bit X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Mar 2019 20:41:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2E03B560BD; Mon, 4 Mar 2019 15:41:03 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id EhM8mGo3rUlV; Mon, 4 Mar 2019 15:41:03 -0500 (EST) Received: from murgatroyd.Home (75-166-85-218.hlrn.qwest.net [75.166.85.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id CF3C7560BB; Mon, 4 Mar 2019 15:41:02 -0500 (EST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC] Change the_dummy_target to be a global Date: Mon, 4 Mar 2019 13:41:00 -0700 Message-Id: <20190304204100.27702-1-tromey@adacore.com> MIME-Version: 1.0 While debugging gdb, I printed the target stack and got: (top-gdb) p g_target_stack $10 = { m_top = thread_stratum, m_stack = {0x142b0b0, 0x13da600 , 0x1c70690, 0x13d63b0 , 0x0, 0x0, 0x0} } (This is clearly from before the change to make ravenscar multi-target-capable.) Here, 0x142b0b0 is the singleton dummy target. It seems to me that since this is always a singleton, it would be a bit nicer if it were a global, so that it would be noted in the above. This patch implements this idea, and now I get: (top-gdb) p g_target_stack $2 = { m_top = dummy_stratum, m_stack = {0x1f1b040 , 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} } I did not do the same for the debug target. It didn't seem as useful to me. gdb/ChangeLog 2019-03-04 Tom Tromey * target.c (the_dummy_target): Move later. Change type to "dummy_target". (initialize_targets): Don't initialize the_dummy_target. --- gdb/ChangeLog | 6 ++++++ gdb/target.c | 11 ++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index d5ff932c748..5c0375a59a3 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -106,10 +106,8 @@ static enum exec_direction_kind default_execution_direction static std::unordered_map target_factories; -/* The initial current target, so that there is always a semi-valid - current target. */ +/* The singleton debug target. */ -static struct target_ops *the_dummy_target; static struct target_ops *the_debug_target; /* The target stack. */ @@ -3240,6 +3238,10 @@ dummy_make_corefile_notes (struct target_ops *self, #include "target-delegates.c" +/* The initial current target, so that there is always a semi-valid + current target. */ + +static dummy_target the_dummy_target; static const target_info dummy_target_info = { "None", @@ -3977,8 +3979,7 @@ set_write_memory_permission (const char *args, int from_tty, void initialize_targets (void) { - the_dummy_target = new dummy_target (); - push_target (the_dummy_target); + push_target (&the_dummy_target); the_debug_target = new debug_target ();