From patchwork Fri Sep 8 18:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75566 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1EBFD38708B4 for ; Fri, 8 Sep 2023 19:03:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EBFD38708B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199810; bh=TwHRft3NHKYpGC5115i8Ogouh1INX1LRMgDxpyn9scg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TJQY4hyD3/HGTrLgyZT0+EzJBJzaBMWx/gA9IMY36/vwfzKjrLwwbBdCVMyc0aooM h1DZhe3hmr6O9mhGVbW9GN7QNdQzIXcAsO9y/EnJJkp2CgDj+UbnyrU/OGfomEWx19 vPlb/3ajGBYsNQIWajtyQzUkLI3tJRG1tvZF4s5o= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 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) 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 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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.