From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 06EFD3858C20 for ; Fri, 8 Sep 2023 19:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06EFD3858C20 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 638951E0C3; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 02/21] gdb: make interp_lookup_existing a method of struct ui Date: Fri, 8 Sep 2023 14:22:56 -0400 Message-ID: <20230908190227.96319-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908190227.96319-1-simon.marchi@efficios.com> References: <20230908190227.96319-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3497.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: No behavior changes expected. Change-Id: I2bd15b70425326a3b499b9346217b93f76175999 --- gdb/interps.c | 22 ++-------------------- gdb/ui.c | 12 ++++++++++++ gdb/ui.h | 4 ++++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index adac98125239..3ddcfe9566fe 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -41,11 +41,6 @@ #include "gdbsupport/buildargv.h" #include "gdbsupport/scope-exit.h" -/* The magic initialization routine for this module. */ - -static struct interp *interp_lookup_existing (struct ui *ui, - const char *name); - interp::interp (const char *name) : m_name (name) { @@ -93,7 +88,7 @@ interp_factory_register (const char *name, interp_factory_func func) static void interp_add (struct ui *ui, struct interp *interp) { - gdb_assert (interp_lookup_existing (ui, interp->name ()) == NULL); + gdb_assert (ui->lookup_existing_interp (interp->name ()) == nullptr); ui->interp_list.push_back (*interp); } @@ -158,19 +153,6 @@ interp_set (struct interp *interp, bool top_level) "to a newer version of MI.")); } -/* Look up the interpreter for NAME. If no such interpreter exists, - return NULL, otherwise return a pointer to the interpreter. */ - -static struct interp * -interp_lookup_existing (struct ui *ui, const char *name) -{ - for (interp &interp : ui->interp_list) - if (strcmp (interp.name (), name) == 0) - return &interp; - - return nullptr; -} - /* See interps.h. */ struct interp * @@ -180,7 +162,7 @@ interp_lookup (struct ui *ui, const char *name) return NULL; /* Only create each interpreter once per top level. */ - struct interp *interp = interp_lookup_existing (ui, name); + interp *interp = ui->lookup_existing_interp (name); if (interp != NULL) return interp; diff --git a/gdb/ui.c b/gdb/ui.c index f3dd14bfd3e0..ae87dcda2453 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -147,6 +147,18 @@ ui::register_file_handler () string_printf ("ui-%d", num), true); } +/* See ui.h. */ + +interp * +ui::lookup_existing_interp (const char *name) const +{ + for (interp &interp : this->interp_list) + if (strcmp (interp.name (), name) == 0) + return &interp; + + return nullptr; +} + /* See top.h. */ void diff --git a/gdb/ui.h b/gdb/ui.h index c5e65c0393d8..23c6b2e1a3d9 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -158,6 +158,10 @@ struct ui : public intrusive_list_node /* Return true if this UI's input fd is a tty. */ bool input_interactive_p () const; + + /* Look up the interpreter for NAME. If no such interpreter exists, + return nullptr, otherwise return a pointer to the interpreter. */ + interp *lookup_existing_interp (const char *name) const; }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. -- 2.42.0