From patchwork Fri Sep 8 18:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75561 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 DC8403858408 for ; Fri, 8 Sep 2023 19:03:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC8403858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199781; bh=l/wrcPVrOWhtzotpHZ6Ib/ORxMKgqnmtGbDiOV4KcJg=; 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=OQtmeZ444K45UlHP2gOC4IhrT8wEM4KCGp8aA/GVXbugofd1xgSlIA7cT6fJ6iUi3 EAo53fvtwhtDkWTJnjFfwDdV8cjjufRwxr3ij/8siticaXeQ4aZBJ0Zfuzcf3x0BQY /ACphPftsSwntH62jlFJNZpfcVWLO9vHOHGkbiDQ= 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 6F5DF3858C5E for ; Fri, 8 Sep 2023 19:02:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F5DF3858C5E 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 0607A1E0C2; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 01/21] gdb: use intrusive_list for struct ui linked list Date: Fri, 8 Sep 2023 14:22:55 -0400 Message-ID: <20230908190227.96319-2-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" Replace the hand-made list with intrusive_list. Change-Id: If003cafda2f680794b9b6ae63236f19dd40908af --- gdb/infrun.c | 4 ++-- gdb/top.c | 4 ++-- gdb/ui.c | 29 ++++------------------------- gdb/ui.h | 29 ++++++++++++----------------- 4 files changed, 20 insertions(+), 46 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 4730d2904423..aaa7b2de14cd 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5454,9 +5454,9 @@ handle_no_resumed (struct execution_control_state *ecs) { bool any_sync = false; - for (ui *ui : all_uis ()) + for (ui &ui : all_uis ()) { - if (ui->prompt_state == PROMPT_BLOCKED) + if (ui.prompt_state == PROMPT_BLOCKED) { any_sync = true; break; diff --git a/gdb/top.c b/gdb/top.c index 2322e55f1db4..483e201140e7 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1783,9 +1783,9 @@ quit_force (int *exit_arg, int from_tty) /* History is currently shared between all UIs. If there's any UI with a terminal, save history. */ - for (ui *ui : all_uis ()) + for (ui &ui : all_uis ()) { - if (ui->input_interactive_p ()) + if (ui.input_interactive_p ()) { save = 1; break; diff --git a/gdb/ui.c b/gdb/ui.c index 38ec61ea6731..f3dd14bfd3e0 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -33,7 +33,7 @@ struct ui *main_ui; struct ui *current_ui; -struct ui *ui_list; +intrusive_list ui_list; /* The highest UI number ever assigned. */ @@ -56,34 +56,13 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) { unbuffer_stream (instream_); - if (ui_list == NULL) - ui_list = this; - else - { - struct ui *last; - - for (last = ui_list; last->next != NULL; last = last->next) - ; - last->next = this; - } + ui_list.push_back (*this); } ui::~ui () { - struct ui *ui, *uiprev; - - uiprev = NULL; - - for (ui = ui_list; ui != NULL; uiprev = ui, ui = ui->next) - if (ui == this) - break; - - gdb_assert (ui != NULL); - - if (uiprev != NULL) - uiprev->next = next; - else - ui_list = next; + gdb_assert (this->is_linked ()); + ui_list.erase (ui_list.iterator_to (*this)); delete m_gdb_stdin; delete m_gdb_stdout; diff --git a/gdb/ui.h b/gdb/ui.h index ed75e041e5f2..c5e65c0393d8 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -51,7 +51,7 @@ enum prompt_state example, to create a separate MI channel on its own stdio streams. */ -struct ui +struct ui : public intrusive_list_node { /* Create a new UI. */ ui (FILE *instream, FILE *outstream, FILE *errstream); @@ -59,9 +59,6 @@ struct ui DISABLE_COPY_AND_ASSIGN (ui); - /* Pointer to next in singly-linked list. */ - struct ui *next = nullptr; - /* Convenient handle (UI number). Unique across all UIs. */ int num; @@ -172,16 +169,17 @@ extern struct ui *main_ui; extern struct ui *current_ui; /* The list of all UIs. */ -extern struct ui *ui_list; +extern intrusive_list ui_list; /* State for SWITCH_THRU_ALL_UIS. */ class switch_thru_all_uis { public: - switch_thru_all_uis () : m_iter (ui_list), m_save_ui (¤t_ui) + switch_thru_all_uis () : m_iter (ui_list.begin ()), m_save_ui (¤t_ui) { - current_ui = ui_list; + if (m_iter != ui_list.end ()) + current_ui = &*m_iter; } DISABLE_COPY_AND_ASSIGN (switch_thru_all_uis); @@ -189,22 +187,21 @@ class switch_thru_all_uis /* If done iterating, return true; otherwise return false. */ bool done () const { - return m_iter == NULL; + return m_iter == ui_list.end (); } /* Move to the next UI, setting current_ui if iteration is not yet complete. */ void next () { - m_iter = m_iter->next; - if (m_iter != NULL) - current_ui = m_iter; + ++m_iter; + if (m_iter != ui_list.end ()) + current_ui = &*m_iter; } private: - /* Used to iterate through the UIs. */ - struct ui *m_iter; + intrusive_list::iterator m_iter; /* Save and restore current_ui. */ scoped_restore_tmpl m_save_ui; @@ -215,13 +212,11 @@ class switch_thru_all_uis #define SWITCH_THRU_ALL_UIS() \ for (switch_thru_all_uis stau_state; !stau_state.done (); stau_state.next ()) -using ui_range = next_range; - /* An adapter that can be used to traverse over all UIs. */ static inline -ui_range all_uis () +intrusive_list &all_uis () { - return ui_range (ui_list); + return ui_list; } #endif /* UI_H */ 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. From patchwork Fri Sep 8 18:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75562 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 1604D3853D19 for ; Fri, 8 Sep 2023 19:03:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1604D3853D19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199789; bh=3Xy7T3hD0amvNvzLEjiGIK9UVQafVnmgjuGQWEd+MwM=; 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=bqSfBhy5eCxZCuE7WDO+LL2QRg2u2sg2/IVZ75KcxpzR/Lw4+nlgPTj3jDqdIhANL /EziHMcMd1QX1NC/iVZ/MtMQ4r8msHfLJ9lccbFG/GRXDVNvamanRzOtvKC1+tHHY1 mc/rQso0iPF+kg+oy6Obyi0JoklYi/Kt73goNzLs= 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 1D6A43858C2D for ; Fri, 8 Sep 2023 19:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D6A43858C2D 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 A3E641E0D0; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 03/21] gdb: make interp_add a method of struct ui Date: Fri, 8 Sep 2023 14:22:57 -0400 Message-ID: <20230908190227.96319-4-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: Ice8958068fd4025e23bff87bcdee45a5f64a41c4 --- gdb/interps.c | 12 +----------- gdb/ui.c | 10 ++++++++++ gdb/ui.h | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index 3ddcfe9566fe..b05a6c4eb875 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -83,16 +83,6 @@ interp_factory_register (const char *name, interp_factory_func func) interpreter_factories.emplace_back (name, func); } -/* Add interpreter INTERP to the gdb interpreter list. The - interpreter must not have previously been added. */ -static void -interp_add (struct ui *ui, struct interp *interp) -{ - gdb_assert (ui->lookup_existing_interp (interp->name ()) == nullptr); - - ui->interp_list.push_back (*interp); -} - /* This sets the current interpreter to be INTERP. If INTERP has not been initialized, then this will also run the init method. @@ -170,7 +160,7 @@ interp_lookup (struct ui *ui, const char *name) if (strcmp (factory.name, name) == 0) { interp = factory.func (factory.name); - interp_add (ui, interp); + ui->add_interp (interp); return interp; } diff --git a/gdb/ui.c b/gdb/ui.c index ae87dcda2453..624187ac73c3 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -159,6 +159,16 @@ ui::lookup_existing_interp (const char *name) const return nullptr; } +/* See ui.h. */ + +void +ui::add_interp (interp *interp) +{ + gdb_assert (this->lookup_existing_interp (interp->name ()) == nullptr); + + this->interp_list.push_back (*interp); +} + /* See top.h. */ void diff --git a/gdb/ui.h b/gdb/ui.h index 23c6b2e1a3d9..48cad96b3fb8 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -162,6 +162,10 @@ struct ui : public intrusive_list_node /* 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; + + /* Add interpreter INTERP to this UI's interpreter list. The + interpreter must not have previously been added. */ + void add_interp (interp *interp); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. From patchwork Fri Sep 8 18:22:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75563 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 DDAEF3853830 for ; Fri, 8 Sep 2023 19:03:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDAEF3853830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199791; bh=DMc+Fj7g/NPfN8HrwiL/75yNdCRr+X7QsPaB6m5MLt0=; 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=SBKOtMvdALnGd2sTgzjKA0KOK//F2WfERXdvZ1kXlbft2Lrya7UP4c5TOKgjwRZhc jIHShQlvWZZQpO5CuHvoVtzLeKKphuWav/mjOQOp/FlpeZJGkIjmKNA3K2/07IynFn gcZm9x8Ikdy10D7JM6V79+PqnL/cQaZqrNM9O7hs= 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 225363858402 for ; Fri, 8 Sep 2023 19:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 225363858402 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 BBD9E1E0D2; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 04/21] gdb: make interp_lookup a method of struct ui Date: Fri, 8 Sep 2023 14:22:58 -0400 Message-ID: <20230908190227.96319-5-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" This requires exposing some things about interpreter factories in interps.h, for ui.c to use it. No behavior changes expected. Change-Id: I7a9e93621c0588e367b5356916d4dad90757bb3d --- gdb/cli/cli-script.c | 2 +- gdb/interps.c | 58 ++++++++++++-------------------------------- gdb/interps.h | 25 ++++++++++++++----- gdb/mi/mi-interp.c | 4 +-- gdb/python/python.c | 2 +- gdb/ui.c | 25 ++++++++++++++++++- gdb/ui.h | 6 +++++ 7 files changed, 68 insertions(+), 54 deletions(-) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 8ec5689ebcfd..49ba854c2a09 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -702,7 +702,7 @@ execute_control_command (struct command_line *cmd, int from_tty) /* Make sure we use the console uiout. It's possible that we are executing breakpoint commands while running the MI interpreter. */ - interp *console = interp_lookup (current_ui, INTERP_CONSOLE); + interp *console = current_ui->lookup_interp (INTERP_CONSOLE); scoped_restore save_uiout = make_scoped_restore (¤t_uiout, console->interp_ui_out ()); diff --git a/gdb/interps.c b/gdb/interps.c index b05a6c4eb875..bd95c3175adb 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -48,22 +48,6 @@ interp::interp (const char *name) interp::~interp () = default; -/* An interpreter factory. Maps an interpreter name to the factory - function that instantiates an interpreter by that name. */ - -struct interp_factory -{ - interp_factory (const char *name_, interp_factory_func func_) - : name (name_), func (func_) - {} - - /* This is the name in "-i=INTERP" and "interpreter-exec INTERP". */ - const char *name; - - /* The function that creates the interpreter. */ - interp_factory_func func; -}; - /* The registered interpreter factories. */ static std::vector interpreter_factories; @@ -83,6 +67,18 @@ interp_factory_register (const char *name, interp_factory_func func) interpreter_factories.emplace_back (name, func); } +/* See interps.h. */ + +const interp_factory * +find_interp_factory (const char *name) +{ + for (const interp_factory &factory : interpreter_factories) + if (strcmp (factory.name, name) == 0) + return &factory; + + return nullptr; +} + /* This sets the current interpreter to be INTERP. If INTERP has not been initialized, then this will also run the init method. @@ -145,35 +141,11 @@ interp_set (struct interp *interp, bool top_level) /* See interps.h. */ -struct interp * -interp_lookup (struct ui *ui, const char *name) -{ - if (name == NULL || strlen (name) == 0) - return NULL; - - /* Only create each interpreter once per top level. */ - interp *interp = ui->lookup_existing_interp (name); - if (interp != NULL) - return interp; - - for (const interp_factory &factory : interpreter_factories) - if (strcmp (factory.name, name) == 0) - { - interp = factory.func (factory.name); - ui->add_interp (interp); - return interp; - } - - return NULL; -} - -/* See interps.h. */ - void set_top_level_interpreter (const char *name) { /* Find it. */ - struct interp *interp = interp_lookup (current_ui, name); + struct interp *interp = current_ui->lookup_interp (name); if (interp == NULL) error (_("Interpreter `%s' unrecognized"), name); @@ -194,7 +166,7 @@ current_interp_set_logging (ui_file_up logfile, bool logging_redirect, struct interp * scoped_restore_interp::set_interp (const char *name) { - struct interp *interp = interp_lookup (current_ui, name); + struct interp *interp = current_ui->lookup_interp (name); struct interp *old_interp = current_ui->current_interpreter; if (interp) @@ -290,7 +262,7 @@ interpreter_exec_cmd (const char *args, int from_tty) interp *old_interp = current_ui->current_interpreter; - interp_to_use = interp_lookup (current_ui, prules[0]); + interp_to_use = current_ui->lookup_interp (prules[0]); if (interp_to_use == NULL) error (_("Could not find interpreter \"%s\"."), prules[0]); diff --git a/gdb/interps.h b/gdb/interps.h index 287df2c8c810..433d92439eba 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -36,6 +36,22 @@ struct trace_state_variable; typedef struct interp *(*interp_factory_func) (const char *name); +/* An interpreter factory. Maps an interpreter name to the factory + function that instantiates an interpreter by that name. */ + +struct interp_factory +{ + interp_factory (const char *name_, interp_factory_func func_) + : name (name_), func (func_) + {} + + /* This is the name in "-i=INTERP" and "interpreter-exec INTERP". */ + const char *name; + + /* The function that creates the interpreter. */ + interp_factory_func func; +}; + /* Each interpreter kind (CLI, MI, etc.) registers itself with a call to this function, passing along its name, and a pointer to a function that creates a new instance of an interpreter with that @@ -45,6 +61,9 @@ typedef struct interp *(*interp_factory_func) (const char *name); extern void interp_factory_register (const char *name, interp_factory_func func); +/* Return the interpreter factory for NAME. Return nullptr if not found. */ +extern const interp_factory *find_interp_factory (const char *name); + extern void interp_exec (struct interp *interp, const char *command); class interp : public intrusive_list_node @@ -193,12 +212,6 @@ class interp : public intrusive_list_node bool inited = false; }; -/* Look up the interpreter for NAME, creating one if none exists yet. - If NAME is not a interpreter type previously registered with - interp_factory_register, return NULL; otherwise return a pointer to - the interpreter. */ -extern struct interp *interp_lookup (struct ui *ui, const char *name); - /* Set the current UI's top level interpreter to the interpreter named NAME. Throws an error if NAME is not a known interpreter or the interpreter fails to initialize. */ diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index b3b0f5bb1f51..946fed5867c4 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -162,7 +162,7 @@ mi_cmd_interpreter_exec (const char *command, const char *const *argv, error (_("-interpreter-exec: " "Usage: -interpreter-exec interp command")); - interp_to_use = interp_lookup (current_ui, argv[0]); + interp_to_use = current_ui->lookup_interp (argv[0]); if (interp_to_use == NULL) error (_("-interpreter-exec: could not find interpreter \"%s\""), argv[0]); @@ -416,7 +416,7 @@ mi_interp::on_normal_stop (struct bpstat *bs, int print_frame) mi_uiout->field_string ("reason", async_reason_lookup (reason)); } - interp *console_interp = interp_lookup (current_ui, INTERP_CONSOLE); + interp *console_interp = current_ui->lookup_interp (INTERP_CONSOLE); /* We only want to print the displays once, and we want it to look just how it would on the console, so we use this to diff --git a/gdb/python/python.c b/gdb/python/python.c index 6a978d632e9a..a1aaa29d0ce5 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -683,7 +683,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw) /* Use the console interpreter uiout to have the same print format for console or MI. */ - interp = interp_lookup (current_ui, "console"); + interp = current_ui->lookup_interp ("console"); current_uiout = interp->interp_ui_out (); if (to_string) diff --git a/gdb/ui.c b/gdb/ui.c index 624187ac73c3..a7b81c077e9a 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -169,7 +169,30 @@ ui::add_interp (interp *interp) this->interp_list.push_back (*interp); } -/* See top.h. */ +/* See interps.h. */ + +interp * +ui::lookup_interp (const char *name) +{ + if (name == nullptr || strlen (name) == 0) + return nullptr; + + /* Only create each interpreter once per UI. */ + interp *interp = this->lookup_existing_interp (name); + if (interp != nullptr) + return interp; + + const interp_factory *factory = find_interp_factory (name); + if (factory == nullptr) + return nullptr; + + interp = factory->func (factory->name); + this->add_interp (interp); + + return interp; +} + +/* See ui.h. */ void ui::unregister_file_handler () diff --git a/gdb/ui.h b/gdb/ui.h index 48cad96b3fb8..aeb26c68823a 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -163,6 +163,12 @@ struct ui : public intrusive_list_node return nullptr, otherwise return a pointer to the interpreter. */ interp *lookup_existing_interp (const char *name) const; + /* Look up the interpreter for NAME, creating one if none exists yet. + If NAME is not a interpreter type previously registered with + interp_factory_register, return nullptr; otherwise return a pointer to + the interpreter. */ + interp *lookup_interp (const char *name); + /* Add interpreter INTERP to this UI's interpreter list. The interpreter must not have previously been added. */ void add_interp (interp *interp); From patchwork Fri Sep 8 18:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75567 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 01318387689A for ; Fri, 8 Sep 2023 19:03:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01318387689A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199837; bh=PljKX5S1YDTktxJOsk+pXCCWGKKVXfyJi/LbXQTYk6g=; 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=J7hoiywSKWMXfb9jtCXmt7g9vPQmZB+EsEKwv+XNctF7L4h+4wRDamSvzm2ANbsap zqCfbvxq5VA56B2BK3946sT5Vs74fkmDE1z+LrWv44H6h/dfJ9V1eHHB/ENklaOIEZ aUa7dBNKTWWaamlyfHzM6DCwpJYvDm2HkLrouQoY= 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 077E83858408 for ; Fri, 8 Sep 2023 19:02:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 077E83858408 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 D45061E110; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 05/21] gdb: remove ui:::add_interp and ui::lookup_existing_interp Date: Fri, 8 Sep 2023 14:22:59 -0400 Message-ID: <20230908190227.96319-6-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" These two methods are only used internally, in ui::lookup_interp. I first thought of making them private, but really I think we can just inline their code in ui::lookup_interp, it's nothing fancy. Change-Id: Ib65c7d49b698a6a57722c148a228bb18888c4e42 --- gdb/ui.c | 32 +++++--------------------------- gdb/ui.h | 8 -------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/gdb/ui.c b/gdb/ui.c index a7b81c077e9a..4bb63ed63030 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -147,28 +147,6 @@ 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 ui.h. */ - -void -ui::add_interp (interp *interp) -{ - gdb_assert (this->lookup_existing_interp (interp->name ()) == nullptr); - - this->interp_list.push_back (*interp); -} - /* See interps.h. */ interp * @@ -178,16 +156,16 @@ ui::lookup_interp (const char *name) return nullptr; /* Only create each interpreter once per UI. */ - interp *interp = this->lookup_existing_interp (name); - if (interp != nullptr) - return interp; + for (auto &candidate : this->interp_list) + if (strcmp (candidate.name (), name) == 0) + return &candidate; const interp_factory *factory = find_interp_factory (name); if (factory == nullptr) return nullptr; - interp = factory->func (factory->name); - this->add_interp (interp); + interp *interp = factory->func (factory->name); + this->interp_list.push_back (*interp); return interp; } diff --git a/gdb/ui.h b/gdb/ui.h index aeb26c68823a..b9ca9c0c80a0 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -159,19 +159,11 @@ 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; - /* Look up the interpreter for NAME, creating one if none exists yet. If NAME is not a interpreter type previously registered with interp_factory_register, return nullptr; otherwise return a pointer to the interpreter. */ interp *lookup_interp (const char *name); - - /* Add interpreter INTERP to this UI's interpreter list. The - interpreter must not have previously been added. */ - void add_interp (interp *interp); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. From patchwork Fri Sep 8 18:23:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75565 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 B5E16385C6E7 for ; Fri, 8 Sep 2023 19:03:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5E16385C6E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199809; bh=YprK4/GIgN7WzXGfnRVmdvo/Zs2kWdih2O+VVBbuFy8=; 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=FYIovN9ERDPdXvwNUaAHV/QJaGsubfzfkHyrpfRgpLKRGI13wejfGWSBM1iftLTyp eCNyYWPSbWFYUs9scWY7aHTkzhkmRt4bGZT6azqo5P68eXLxYOwjMpbAhmc647sPqJ KzgjLD48EgVgBH45hdotv8vFhpTKitMtkULuJoBA= 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 0754F3858404 for ; Fri, 8 Sep 2023 19:02:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0754F3858404 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 0FDE31E11B; Fri, 8 Sep 2023 15:02:30 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 06/21] gdb: uncover some current_ui uses in interp_set Date: Fri, 8 Sep 2023 14:23:00 -0400 Message-ID: <20230908190227.96319-7-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" A following patch will make interp_set a method of struct ui. Before doing this, I'd like to uncover all the hidden uses of current_ui, as they will be replaced with a passed-in `ui` parameter, and then `this`. So, replace uses of the current_uiout macro with the long form. Change-Id: I8de2e6a451de11ff9040322bd0869021171dcf7f --- gdb/interps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index bd95c3175adb..9d27d6a2bd2c 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -102,7 +102,7 @@ interp_set (struct interp *interp, bool top_level) if (old_interp != NULL) { - current_uiout->flush (); + current_ui->m_current_uiout->flush (); old_interp->suspend (); } @@ -126,7 +126,7 @@ interp_set (struct interp *interp, bool top_level) } /* Do this only after the interpreter is initialized. */ - current_uiout = interp->interp_ui_out (); + current_ui->m_current_uiout = interp->interp_ui_out (); /* Clear out any installed interpreter hooks/event handlers. */ clear_interpreter_hooks (); From patchwork Fri Sep 8 18:23:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75564 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 02326385C6DA for ; Fri, 8 Sep 2023 19:03:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02326385C6DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199803; bh=rcW9LrtQNIXroHykdJillmSkc7nFUb8v66YtU0hmnSo=; 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=im/J26buFriQYQ/mBgufK62LWgFNHIqCXv6smkJbnOGA/3ng/CV39PEB8J1sZROBX T0ywPhGsEtHwfVriai49xauee5xXxLer7nR++H+vjvYulDH6EdpxorteA0YnrittZY W72mBlCTkoSi/TKJVIxBfHqM0X3G51cQdlwjaMfs= 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 2E3A13858410 for ; Fri, 8 Sep 2023 19:02:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E3A13858410 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 274271E1A6; Fri, 8 Sep 2023 15:02:30 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 07/21] gdb: add backlink to ui in interp Date: Fri, 8 Sep 2023 14:23:01 -0400 Message-ID: <20230908190227.96319-8-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" Interps are bound to a single parent UI. Pass this UI down when constructing interps, so that they'll be able to use it internally, instead of using current_ui. Change-Id: Ife900d501ae26d1a7a1d06b1d5f4013917235d7a --- gdb/cli/cli-interp.c | 14 +++++++------- gdb/cli/cli-interp.h | 2 +- gdb/interps.c | 5 +++-- gdb/interps.h | 7 +++++-- gdb/mi/mi-interp.c | 4 ++-- gdb/mi/mi-interp.h | 4 ++-- gdb/python/py-dap.c | 8 ++++---- gdb/tui/tui-interp.c | 8 ++++---- gdb/ui.c | 2 +- 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 6a175f7baa13..374d379ec7a3 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -31,8 +31,8 @@ #include "thread-fsm.h" #include "inferior.h" -cli_interp_base::cli_interp_base (const char *name) - : interp (name) +cli_interp_base::cli_interp_base (ui *ui, const char *name) + : interp (ui, name) {} cli_interp_base::~cli_interp_base () @@ -43,7 +43,7 @@ cli_interp_base::~cli_interp_base () class cli_interp final : public cli_interp_base { public: - explicit cli_interp (const char *name); + explicit cli_interp (ui *ui, const char *name); ~cli_interp () = default; void init (bool top_level) override; @@ -58,8 +58,8 @@ class cli_interp final : public cli_interp_base std::unique_ptr m_cli_uiout; }; -cli_interp::cli_interp (const char *name) - : cli_interp_base (name), +cli_interp::cli_interp (ui *ui, const char *name) + : cli_interp_base (ui, name), m_cli_uiout (new cli_ui_out (gdb_stdout)) { } @@ -317,9 +317,9 @@ cli_interp_base::set_logging (ui_file_up logfile, bool logging_redirect, /* Factory for CLI interpreters. */ static struct interp * -cli_interp_factory (const char *name) +cli_interp_factory (ui *ui, const char *name) { - return new cli_interp (name); + return new cli_interp (ui, name); } /* Standard gdb initialization hook. */ diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index a1a20b678942..b92a49b3fc40 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -25,7 +25,7 @@ class cli_interp_base : public interp { public: - explicit cli_interp_base (const char *name); + explicit cli_interp_base (ui *ui, const char *name); virtual ~cli_interp_base () = 0; void set_logging (ui_file_up logfile, bool logging_redirect, diff --git a/gdb/interps.c b/gdb/interps.c index 9d27d6a2bd2c..0575128b8124 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -41,8 +41,9 @@ #include "gdbsupport/buildargv.h" #include "gdbsupport/scope-exit.h" -interp::interp (const char *name) - : m_name (name) +interp::interp (ui *ui, const char *name) + : m_ui (ui), + m_name (name) { } diff --git a/gdb/interps.h b/gdb/interps.h index 433d92439eba..278ee5aff9a5 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -34,7 +34,7 @@ struct inferior; struct so_list; struct trace_state_variable; -typedef struct interp *(*interp_factory_func) (const char *name); +using interp_factory_func = interp *(*) (ui *ui, const char *name); /* An interpreter factory. Maps an interpreter name to the factory function that instantiates an interpreter by that name. */ @@ -69,7 +69,7 @@ extern void interp_exec (struct interp *interp, const char *command); class interp : public intrusive_list_node { public: - explicit interp (const char *name); + explicit interp (ui *ui, const char *name); virtual ~interp () = 0; virtual void init (bool top_level) @@ -202,6 +202,9 @@ class interp : public intrusive_list_node /* Notify the interpreter that inferior INF's memory was changed. */ virtual void on_memory_changed (inferior *inf, CORE_ADDR addr, ssize_t len, const bfd_byte *data) {} +protected: + /* Backlink to the UI owning this interpreter. */ + ui *m_ui; private: /* The memory for this is static, it comes from literal strings (e.g. "cli"). */ diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 946fed5867c4..be9dacaf9304 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -925,9 +925,9 @@ mi_interp::set_logging (ui_file_up logfile, bool logging_redirect, /* Factory for MI interpreters. */ static struct interp * -mi_interp_factory (const char *name) +mi_interp_factory (ui *ui, const char *name) { - return new mi_interp (name); + return new mi_interp (ui, name); } void _initialize_mi_interp (); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index f9af61f0a571..54ba70bdab88 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -29,8 +29,8 @@ struct mi_console_file; class mi_interp final : public interp { public: - mi_interp (const char *name) - : interp (name) + mi_interp (ui *ui, const char *name) + : interp (ui, name) {} void init (bool top_level) override; diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c index 3444eccb6fb6..724a4925938c 100644 --- a/gdb/python/py-dap.c +++ b/gdb/python/py-dap.c @@ -27,8 +27,8 @@ class dap_interp final : public interp { public: - explicit dap_interp (const char *name) - : interp (name), + explicit dap_interp (ui *ui, const char *name) + : interp (ui, name), m_ui_out (new cli_ui_out (gdb_stdout)) { } @@ -93,9 +93,9 @@ _initialize_py_interp () { /* The dap code uses module typing, available starting python 3.5. */ #if PY_VERSION_HEX >= 0x03050000 - interp_factory_register ("dap", [] (const char *name) -> interp * + interp_factory_register ("dap", [] (ui *ui, const char *name) -> interp * { - return new dap_interp (name); + return new dap_interp (ui, name); }); #endif } diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 299cc4caea09..227b37f374dc 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -42,8 +42,8 @@ static bool tui_start_enabled = false; class tui_interp final : public cli_interp_base { public: - explicit tui_interp (const char *name) - : cli_interp_base (name) + explicit tui_interp (ui *ui, const char *name) + : cli_interp_base (ui, name) {} void init (bool top_level) override; @@ -159,9 +159,9 @@ tui_interp::exec (const char *command_str) /* Factory for TUI interpreters. */ static struct interp * -tui_interp_factory (const char *name) +tui_interp_factory (ui *ui, const char *name) { - return new tui_interp (name); + return new tui_interp (ui, name); } void _initialize_tui_interp (); diff --git a/gdb/ui.c b/gdb/ui.c index 4bb63ed63030..8c04dc92b89e 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -164,7 +164,7 @@ ui::lookup_interp (const char *name) if (factory == nullptr) return nullptr; - interp *interp = factory->func (factory->name); + interp *interp = factory->func (this, factory->name); this->interp_list.push_back (*interp); return interp; From patchwork Fri Sep 8 18:23:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75568 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 9ADA5385483F for ; Fri, 8 Sep 2023 19:04:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9ADA5385483F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199894; bh=MEfHqkLml38SP3pvvYdOMkmLVv2fVKuqQf9vUFu4QQM=; 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=QqlFhOow05L7JNUl/Pb24MhKHuUlFjwI8qABSXDcb9sIzBiETgCI/oPwCuq+iLfxQ UhFb/L2M5c38mtrEONy0oeR+eDiq+BMIhT2fn47/Ak7bSgHzS9+G9VYkvMMzrbJPk3 6N5849yRIRn/LkGis3KJjT7412/6VxjJc2qfN6t8= 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 047353858C20 for ; Fri, 8 Sep 2023 19:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 047353858C20 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 AEAE71E092; Fri, 8 Sep 2023 15:04:30 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 08/21] gdb: pass ui down to gdb_setup_readline and gdb_disable_readline Date: Fri, 8 Sep 2023 14:23:02 -0400 Message-ID: <20230908190227.96319-9-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" This is useful for the upcoming patches that make interps use m_ui instead of current_ui. Change-Id: I27a3e586a7e1063050b84714fe408e57953ec108 --- gdb/cli/cli-interp.c | 4 ++-- gdb/event-top.c | 8 ++------ gdb/event-top.h | 4 ++-- gdb/mi/mi-interp.c | 4 ++-- gdb/top.c | 2 +- gdb/tui/tui-interp.c | 4 ++-- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 374d379ec7a3..f0fa26919e76 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -206,7 +206,7 @@ cli_interp::resume () stream = NULL; } - gdb_setup_readline (1); + gdb_setup_readline (ui, 1); ui->input_handler = command_line_handler; @@ -217,7 +217,7 @@ cli_interp::resume () void cli_interp::suspend () { - gdb_disable_readline (); + gdb_disable_readline (current_ui); } void diff --git a/gdb/event-top.c b/gdb/event-top.c index d1be23bcbe9b..54f199d2e393 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -1275,10 +1275,8 @@ async_sigtstp_handler (gdb_client_data arg) loop. */ void -gdb_setup_readline (int editing) +gdb_setup_readline (ui *ui, int editing) { - struct ui *ui = current_ui; - /* If the input stream is connected to a terminal, turn on editing. However, that is only allowed on the main UI, as we can only have one instance of readline. Also, INSTREAM might be nullptr when @@ -1316,10 +1314,8 @@ gdb_setup_readline (int editing) interface, like the cli & the mi. */ void -gdb_disable_readline (void) +gdb_disable_readline (ui *ui) { - struct ui *ui = current_ui; - if (ui->command_editing) gdb_rl_callback_handler_remove (); ui->unregister_file_handler (); diff --git a/gdb/event-top.h b/gdb/event-top.h index f7247f5c4f23..ab78f95a9f62 100644 --- a/gdb/event-top.h +++ b/gdb/event-top.h @@ -30,8 +30,8 @@ struct cmd_list_element; FIXME: these should really go into top.h. */ extern void display_gdb_prompt (const char *new_prompt); -extern void gdb_setup_readline (int); -extern void gdb_disable_readline (void); +extern void gdb_setup_readline (ui *ui, int editing); +extern void gdb_disable_readline (ui *ui); extern void gdb_init_signals (void); extern void change_line_handler (int); diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index be9dacaf9304..3095301b2f11 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -122,7 +122,7 @@ mi_interp::resume () /* As per hack note in mi_interpreter_init, swap in the output channels... */ - gdb_setup_readline (0); + gdb_setup_readline (ui, 0); ui->call_readline = gdb_readline_no_editing_callback; ui->input_handler = mi_execute_command_input_handler; @@ -142,7 +142,7 @@ mi_interp::resume () void mi_interp::suspend () { - gdb_disable_readline (); + gdb_disable_readline (current_ui); } void diff --git a/gdb/top.c b/gdb/top.c index 483e201140e7..a1ef328242c8 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1714,7 +1714,7 @@ undo_terminal_modifications_before_exit (void) #if defined(TUI) tui_disable (); #endif - gdb_disable_readline (); + gdb_disable_readline (current_ui); current_ui = saved_top_level; } diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 227b37f374dc..af99501ac69f 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -121,7 +121,7 @@ tui_interp::resume () stream = NULL; } - gdb_setup_readline (1); + gdb_setup_readline (ui, 1); ui->input_handler = tui_command_line_handler; @@ -135,7 +135,7 @@ tui_interp::resume () void tui_interp::suspend () { - gdb_disable_readline (); + gdb_disable_readline (current_ui); tui_start_enabled = tui_active; tui_disable (); } From patchwork Fri Sep 8 18:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75569 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 F0AC53876897 for ; Fri, 8 Sep 2023 19:04:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0AC53876897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199895; bh=i9Jkof/byX/aQahlB9pYZro/zSnvSU/E01STv0ubShQ=; 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=yCL6XUeZU7/N4KKxdnj1W0/h8dLFSUB+SfKI+Sw3OX1KlGkLIFfI9QKSIOue1iyzc TQrMXpvKJEEyWXlZSGCq7OJpvZbAZaN/aaI+8xRZr/hqW7WjUPJ21Y6UjlIJnipSEm a3JTE629njJDy/gHFK3rBher9W24sZkWSQ9uPfdw= 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 3856B3858C27 for ; Fri, 8 Sep 2023 19:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3856B3858C27 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 CBC2A1E0C2; Fri, 8 Sep 2023 15:04:30 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 09/21] gdb/python: use m_ui instead of current_ui in dap_interp::init Date: Fri, 8 Sep 2023 14:23:03 -0400 Message-ID: <20230908190227.96319-10-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" Change-Id: I95dd19952f22bb92eafad46cb1c6f22b63e09783 --- gdb/python/py-dap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c index 724a4925938c..652ce9cb0eda 100644 --- a/gdb/python/py-dap.c +++ b/gdb/python/py-dap.c @@ -83,8 +83,8 @@ dap_interp::init (bool top_level) if (result_obj == nullptr) gdbpy_handle_exception (); - current_ui->input_fd = -1; - current_ui->m_input_interactive_p = false; + m_ui->input_fd = -1; + m_ui->m_input_interactive_p = false; } void _initialize_py_interp (); From patchwork Fri Sep 8 18:23:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75570 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 D8021387093F for ; Fri, 8 Sep 2023 19:04:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8021387093F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199895; bh=v1tIZtiK8WFGXEkBuwYYeZRqKwEqIAAronxfiBINyZY=; 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=NjyP8iyUWIG1NvZlnoeQkddehHvuS3s9YgYgG03CH+2MRr8v971l8A22hn8Vt1nta Ae20yX+csVkenv/S5QyLQ8V3TlhQf8zngRCGqQek6L3VusqbJFYizfflccliVxTKIX +AbfbRNVmBfFhlR7/h+ZnoaRMoI0cCxZ9zOKCQgE= 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 788183858C2D for ; Fri, 8 Sep 2023 19:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 788183858C2D 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 EE3AD1E0C3; Fri, 8 Sep 2023 15:04:30 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 10/21] gdb/mi: use m_ui instead of current_ui in mi_interp::init Date: Fri, 8 Sep 2023 14:23:04 -0400 Message-ID: <20230908190227.96319-11-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" gdb_stdout accesses current_ui under the hood. Use m_ui to get the stdout file instead. Add an stdout method to ui to help with that (it would feel wrong to access ui::m_gdb_stdout directly). Change-Id: I03739df387c8de01bc692d7ddddbb66544555630 --- gdb/mi/mi-interp.c | 2 +- gdb/ui.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 3095301b2f11..f260d98837cf 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -86,7 +86,7 @@ mi_interp::init (bool top_level) /* Store the current output channel, so that we can create a console channel that encapsulates and prefixes all gdb_output-type bits coming from the rest of the debugger. */ - mi->raw_stdout = gdb_stdout; + mi->raw_stdout = m_ui->stdout (); /* Create MI console channels, each with a different prefix so they can be distinguished. */ diff --git a/gdb/ui.h b/gdb/ui.h index b9ca9c0c80a0..be89ab3d6848 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -150,6 +150,9 @@ struct ui : public intrusive_list_node /* The current ui_out. */ struct ui_out *m_current_uiout = nullptr; + ui_file *stdout () + { return m_gdb_stdout; } + /* Register the UI's input file descriptor in the event loop. */ void register_file_handler (); From patchwork Fri Sep 8 18:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75573 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 9FA413853D39 for ; Fri, 8 Sep 2023 19:05:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FA413853D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199923; bh=QC/UV5tC/mjYMhLUdd9H5LFxUAY/BKCjfQ2CbzZU7rM=; 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=y2iQc9IuSxUfjz0s8UiaDPWtYMY2cb6lnmlv7jdSB3plPMT+s2XMCkP6p9KF5CUed 1APETo2XfiDXnuMy7kBybxqZoLbl+ATntuArAt5GsP5jlVhMP5HJlPHehy6b09ZWfg 684wyIYzTJ5tXXS9M2JnyR66GgXygkisr4VkD4UA= 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 8F17C3858402 for ; Fri, 8 Sep 2023 19:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F17C3858402 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 0E06D1E0D0; Fri, 8 Sep 2023 15:04:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 11/21] gdb/cli: use m_ui instead of current_ui in cli_interp::resume Date: Fri, 8 Sep 2023 14:23:05 -0400 Message-ID: <20230908190227.96319-12-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: I7fd944c99d249b3080d74d949186fe92795568eb --- gdb/cli/cli-interp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index f0fa26919e76..8f1dbef56a6e 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -190,25 +190,22 @@ cli_interp::init (bool top_level) void cli_interp::resume () { - struct ui *ui = current_ui; - struct ui_file *stream; - /*sync_execution = 1; */ /* gdb_setup_readline will change gdb_stdout. If the CLI was previously writing to gdb_stdout, then set it to the new gdb_stdout afterwards. */ - stream = m_cli_uiout->set_stream (gdb_stdout); + ui_file *stream = m_cli_uiout->set_stream (gdb_stdout); if (stream != gdb_stdout) { m_cli_uiout->set_stream (stream); stream = NULL; } - gdb_setup_readline (ui, 1); + gdb_setup_readline (m_ui, 1); - ui->input_handler = command_line_handler; + m_ui->input_handler = command_line_handler; if (stream != NULL) m_cli_uiout->set_stream (gdb_stdout); From patchwork Fri Sep 8 18:23:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75571 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 370063830B64 for ; Fri, 8 Sep 2023 19:05:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 370063830B64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199901; bh=pjhVujp/ZrIi261cDad8N7qre98rNzlKa1uIzFHJmkc=; 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=iAJH51bYYkWzLJerOAqcaD/S8zVsJk9rLQPFDg6VrQLWkeoD6/wDC57tSfzp7hy+D ZLVOHq1hwDi4p1sJ4vwzVnv9qvrgFUt13TmuZPUP+EH2h+t1/+HVgB+gPuA7PQGb/9 zE107SGYQKs8qUOgnmEBaNdXWqRxqncL3I6t6fCY= 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 BB5673858416 for ; Fri, 8 Sep 2023 19:04:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB5673858416 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 25EFF1E0D2; Fri, 8 Sep 2023 15:04:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 12/21] gdb/tui: use m_ui instead of current_ui in tui_interp::resume Date: Fri, 8 Sep 2023 14:23:06 -0400 Message-ID: <20230908190227.96319-13-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: I607a50a7ed83d9afd536d41d6318fc4cd24d8192 --- gdb/tui/tui-interp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index af99501ac69f..87c079949f4b 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -107,23 +107,20 @@ tui_command_line_handler (gdb::unique_xmalloc_ptr &&rl) void tui_interp::resume () { - struct ui *ui = current_ui; - struct ui_file *stream; - /* gdb_setup_readline will change gdb_stdout. If the TUI was previously writing to gdb_stdout, then set it to the new gdb_stdout afterwards. */ - stream = tui_old_uiout->set_stream (gdb_stdout); + ui_file *stream = tui_old_uiout->set_stream (gdb_stdout); if (stream != gdb_stdout) { tui_old_uiout->set_stream (stream); stream = NULL; } - gdb_setup_readline (ui, 1); + gdb_setup_readline (m_ui, 1); - ui->input_handler = tui_command_line_handler; + m_ui->input_handler = tui_command_line_handler; if (stream != NULL) tui_old_uiout->set_stream (gdb_stdout); From patchwork Fri Sep 8 18:23:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75574 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 D31EF385DC3A for ; Fri, 8 Sep 2023 19:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D31EF385DC3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199950; bh=vzza817Rd8NktCESl7MEQRrvRlAO/aTEQ70eSvtPG/8=; 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=OgLBNN4A/6/N55kFrfilJSgQVhZRcYNhcpLvy0CwW4APTpKTJhTKE7zWBU3aMmGz2 20YztDkGlL5POq8uuTrP/T1tQ0OfagoS4W3a4fdDvVKkfYPmwa8dd8qfWO2FmkJTBX drL4BaMDOGqhfzGebPzWcjaKntyksd2rwrofBNSM= 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 3D4EF3858425 for ; Fri, 8 Sep 2023 19:04:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D4EF3858425 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 53B701E110; Fri, 8 Sep 2023 15:04:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 13/21] gdb/mi: use m_ui instead of current_ui in mi_interp::resume Date: Fri, 8 Sep 2023 14:23:07 -0400 Message-ID: <20230908190227.96319-14-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: Ic379a18d6a6d83a55cd4a6d1239d4daa98966cc8 --- gdb/mi/mi-interp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index f260d98837cf..b676e22f3550 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -118,14 +118,13 @@ void mi_interp::resume () { struct mi_interp *mi = this; - struct ui *ui = current_ui; /* As per hack note in mi_interpreter_init, swap in the output channels... */ - gdb_setup_readline (ui, 0); + gdb_setup_readline (m_ui, 0); - ui->call_readline = gdb_readline_no_editing_callback; - ui->input_handler = mi_execute_command_input_handler; + m_ui->call_readline = gdb_readline_no_editing_callback; + m_ui->input_handler = mi_execute_command_input_handler; gdb_stdout = mi->out; /* Route error and log output through the MI. */ From patchwork Fri Sep 8 18:23:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75572 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 54D543853D26 for ; Fri, 8 Sep 2023 19:05:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54D543853D26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199922; bh=W0cUx4UYXAsvFcdhPLg9YJKOY9aJuRu7UjfsjVxJZCE=; 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=QlJLbJw2g7ay+p3FzxPG3thJXLh+G/v1kazYuaWZ2U+W35H+M+keWInW7K512qUXd //oYy/z5g6dtPVf0+rr5w8ZQmrsHxTPCGeX99vMitVq4lsP8SZ2CfGVfSJUOdjic08 LHDp4tD8szt3R/cIyxz6f+XyIpNY2B0Jyg2zklcs= 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 8DD0C385843A for ; Fri, 8 Sep 2023 19:04:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DD0C385843A 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 81A131E11B; Fri, 8 Sep 2023 15:04:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 14/21] gdb/cli: use m_ui instead of current_ui in cli_interp::suspend Date: Fri, 8 Sep 2023 14:23:08 -0400 Message-ID: <20230908190227.96319-15-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: Ice542e98b7add70f40c32e8d477bec4605d3ca3f --- gdb/cli/cli-interp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 8f1dbef56a6e..2980c87479cc 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -214,7 +214,7 @@ cli_interp::resume () void cli_interp::suspend () { - gdb_disable_readline (current_ui); + gdb_disable_readline (m_ui); } void From patchwork Fri Sep 8 18:23:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75575 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 C276E385DC07 for ; Fri, 8 Sep 2023 19:06:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C276E385DC07 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199978; bh=YCqhTZyjDyqkf1bvgzL9YzC4ELYFoQOSoFK4WglOWnE=; 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=V0r7OCaHYiBgux8yFcJewVv9cyg4WPo3SqQxwQ3j5lAIpNYWkaOggQ3wSZR4k5EZc 3KIUN92yR/4zxaM7eSsWBsw4/vOmhF3yNVDR464tzYfnPDrBAf/69Tdsee5jErD1aW EbD77KW4BTtqehenB5AMAn5lcPmoooKk5wBcehDY= 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 61B6D3858430 for ; Fri, 8 Sep 2023 19:04:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61B6D3858430 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 9F7D51E1A6; Fri, 8 Sep 2023 15:04:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 15/21] gdb/tui: use m_ui instead of current_ui in tui_interp::suspend Date: Fri, 8 Sep 2023 14:23:09 -0400 Message-ID: <20230908190227.96319-16-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: I61d7f849909a333403c6fb978bfe8efcc39d58fa --- gdb/tui/tui-interp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 87c079949f4b..2520b7158d45 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -132,7 +132,7 @@ tui_interp::resume () void tui_interp::suspend () { - gdb_disable_readline (current_ui); + gdb_disable_readline (m_ui); tui_start_enabled = tui_active; tui_disable (); } From patchwork Fri Sep 8 18:23:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75576 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 216483882106 for ; Fri, 8 Sep 2023 19:06:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 216483882106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200017; bh=p0tUh1PZOWL+NyR0cQbRK9ib8M8079Uqsm/phi92Hvk=; 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=evxQRH/mkoxIVRW+FFgmeZ7uhttM0fnw4rGuCQb5ZcrAvh11zwVdjf5yMHPB7v3MD s8yn8BAIOuyr6mUryljhrjU4RmcX7pBJ6i8A9/dEe4h5/g/eLZ3DKS4r4NfdtCBDH4 1LSv4ld4VtxO9/jsS9U7X8qcQ0yoKQfDlWUA31Fk= 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 6F6DF3858426 for ; Fri, 8 Sep 2023 19:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F6DF3858426 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 00E611E092; Fri, 8 Sep 2023 15:06:31 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 16/21] gdb/mi: use m_ui instead of current_ui in mi_interp::suspend Date: Fri, 8 Sep 2023 14:23:10 -0400 Message-ID: <20230908190227.96319-17-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: I17d11fb5ed38a51bc0ea9708ec5e290bb54d41c1 --- gdb/mi/mi-interp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index b676e22f3550..60a2ed0bcc4c 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -141,7 +141,7 @@ mi_interp::resume () void mi_interp::suspend () { - gdb_disable_readline (current_ui); + gdb_disable_readline (m_ui); } void From patchwork Fri Sep 8 18:23:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75578 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 4E23D387093F for ; Fri, 8 Sep 2023 19:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E23D387093F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200019; bh=Bxo1Qaiq98qw7JK2jg/z2WTvrvfjO5wRS+M9h1HcQ+U=; 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=BaKrldxV1KlhqpOJlF2fGNXHqIBQJ/jZUVgusphVUdtxEyHA3wieyedxbWWePRNGp ZXV9rbiZJsaEIMmKyWPGPzDzGAlpVcGrm3Pi/TggfPo+XxYmfxxdHiUXimHlAW1+cN tU0TMhAVEiVtoEne7fCTgLk0dZYnfFtkQicBIU/s= 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 C96923857355 for ; Fri, 8 Sep 2023 19:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C96923857355 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 3985C1E0C2; Fri, 8 Sep 2023 15:06:32 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 17/21] gdb: pass current_ui down to interp_set Date: Fri, 8 Sep 2023 14:23:11 -0400 Message-ID: <20230908190227.96319-18-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" In preparation for making interp_set a method of struct ui. No behavior changes expected. Change-Id: I507c7701438967502d714ecda99401d785806cab --- gdb/interps.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index 0575128b8124..18758f1f7af6 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -92,24 +92,24 @@ find_interp_factory (const char *name) are caused by CLI commands. */ static void -interp_set (struct interp *interp, bool top_level) +interp_set (ui *ui, struct interp *interp, bool top_level) { - struct interp *old_interp = current_ui->current_interpreter; + struct interp *old_interp = ui->current_interpreter; /* If we already have an interpreter, then trying to set top level interpreter is kinda pointless. */ - gdb_assert (!top_level || !current_ui->current_interpreter); - gdb_assert (!top_level || !current_ui->top_level_interpreter); + gdb_assert (!top_level || !ui->current_interpreter); + gdb_assert (!top_level || !ui->top_level_interpreter); if (old_interp != NULL) { - current_ui->m_current_uiout->flush (); + ui->m_current_uiout->flush (); old_interp->suspend (); } - current_ui->current_interpreter = interp; + ui->current_interpreter = interp; if (top_level) - current_ui->top_level_interpreter = interp; + ui->top_level_interpreter = interp; if (interpreter_p != interp->name ()) interpreter_p = interp->name (); @@ -127,7 +127,7 @@ interp_set (struct interp *interp, bool top_level) } /* Do this only after the interpreter is initialized. */ - current_ui->m_current_uiout = interp->interp_ui_out (); + ui->m_current_uiout = interp->interp_ui_out (); /* Clear out any installed interpreter hooks/event handlers. */ clear_interpreter_hooks (); @@ -151,7 +151,7 @@ set_top_level_interpreter (const char *name) if (interp == NULL) error (_("Interpreter `%s' unrecognized"), name); /* Install it. */ - interp_set (interp, true); + interp_set (current_ui, interp, true); } void @@ -267,10 +267,10 @@ interpreter_exec_cmd (const char *args, int from_tty) if (interp_to_use == NULL) error (_("Could not find interpreter \"%s\"."), prules[0]); - interp_set (interp_to_use, false); + interp_set (current_ui, interp_to_use, false); SCOPE_EXIT { - interp_set (old_interp, false); + interp_set (current_ui, old_interp, false); }; for (i = 1; i < nrules; i++) From patchwork Fri Sep 8 18:23:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75580 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 8267D3853D12 for ; Fri, 8 Sep 2023 19:07:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8267D3853D12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200047; bh=y0SX7Hb6+g+LrEfL6M4Hw06nVQ7fgOLyBRDqJ5AelFI=; 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=S7aDucL2gBgZZRP6LHFP6DeYpPARicrMHdkaza9THNUBGD0ZzOytLsAd71Xei+A8m KET2e9IGi9NIVR2l/8awuNnHC/xs41f7sCQIx2tvac3g6SRKoRGxzf0GLTXFqu9U2/ nh3Q6r3AOkUrPNsnQ8Ycol1/dXr/iKO+EqBDksJk= 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 E22E03857020 for ; Fri, 8 Sep 2023 19:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E22E03857020 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 51E421E0C3; Fri, 8 Sep 2023 15:06:32 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 18/21] gdb: make interp_set a method of struct ui Date: Fri, 8 Sep 2023 14:23:12 -0400 Message-ID: <20230908190227.96319-19-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.0 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" Move interp_set to ui::set_current_interpreter. Change-Id: I7e83ca7732bb6229a1e61dc0e3832f54c20c3f52 --- gdb/interps.c | 66 +++------------------------------------------------ gdb/ui.c | 51 +++++++++++++++++++++++++++++++++++++++ gdb/ui.h | 12 ++++++++++ 3 files changed, 66 insertions(+), 63 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index 18758f1f7af6..465c174ea794 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -80,66 +80,6 @@ find_interp_factory (const char *name) return nullptr; } -/* This sets the current interpreter to be INTERP. If INTERP has not - been initialized, then this will also run the init method. - - The TOP_LEVEL parameter tells if this new interpreter is - the top-level one. The top-level is what is requested - on the command line, and is responsible for reporting general - notification about target state changes. For example, if - MI is the top-level interpreter, then it will always report - events such as target stops and new thread creation, even if they - are caused by CLI commands. */ - -static void -interp_set (ui *ui, struct interp *interp, bool top_level) -{ - struct interp *old_interp = ui->current_interpreter; - - /* If we already have an interpreter, then trying to - set top level interpreter is kinda pointless. */ - gdb_assert (!top_level || !ui->current_interpreter); - gdb_assert (!top_level || !ui->top_level_interpreter); - - if (old_interp != NULL) - { - ui->m_current_uiout->flush (); - old_interp->suspend (); - } - - ui->current_interpreter = interp; - if (top_level) - ui->top_level_interpreter = interp; - - if (interpreter_p != interp->name ()) - interpreter_p = interp->name (); - - bool warn_about_mi1 = false; - - /* Run the init proc. */ - if (!interp->inited) - { - interp->init (top_level); - interp->inited = true; - - if (streq (interp->name (), "mi1")) - warn_about_mi1 = true; - } - - /* Do this only after the interpreter is initialized. */ - ui->m_current_uiout = interp->interp_ui_out (); - - /* Clear out any installed interpreter hooks/event handlers. */ - clear_interpreter_hooks (); - - interp->resume (); - - if (warn_about_mi1) - warning (_("MI version 1 is deprecated in GDB 13 and " - "will be removed in GDB 14. Please upgrade " - "to a newer version of MI.")); -} - /* See interps.h. */ void @@ -151,7 +91,7 @@ set_top_level_interpreter (const char *name) if (interp == NULL) error (_("Interpreter `%s' unrecognized"), name); /* Install it. */ - interp_set (current_ui, interp, true); + current_ui->set_current_interpreter (interp, true); } void @@ -267,10 +207,10 @@ interpreter_exec_cmd (const char *args, int from_tty) if (interp_to_use == NULL) error (_("Could not find interpreter \"%s\"."), prules[0]); - interp_set (current_ui, interp_to_use, false); + current_ui->set_current_interpreter (interp_to_use, false); SCOPE_EXIT { - interp_set (current_ui, old_interp, false); + current_ui->set_current_interpreter (old_interp, false); }; for (i = 1; i < nrules; i++) diff --git a/gdb/ui.c b/gdb/ui.c index 8c04dc92b89e..2db899eb9c31 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -172,6 +172,57 @@ ui::lookup_interp (const char *name) /* See ui.h. */ +void +ui::set_current_interpreter (interp *interp, bool top_level) +{ + struct interp *old_interp = this->current_interpreter; + + /* If we already have an interpreter, then trying to + set top level interpreter is kinda pointless. */ + gdb_assert (!top_level || !this->current_interpreter); + gdb_assert (!top_level || !this->top_level_interpreter); + + if (old_interp != NULL) + { + m_current_uiout->flush (); + old_interp->suspend (); + } + + this->current_interpreter = interp; + if (top_level) + this->top_level_interpreter = interp; + + if (interpreter_p != interp->name ()) + interpreter_p = interp->name (); + + bool warn_about_mi1 = false; + + /* Run the init proc. */ + if (!interp->inited) + { + interp->init (top_level); + interp->inited = true; + + if (streq (interp->name (), "mi1")) + warn_about_mi1 = true; + } + + /* Do this only after the interpreter is initialized. */ + m_current_uiout = interp->interp_ui_out (); + + /* Clear out any installed interpreter hooks/event handlers. */ + clear_interpreter_hooks (); + + interp->resume (); + + if (warn_about_mi1) + warning (_("MI version 1 is deprecated in GDB 13 and " + "will be removed in GDB 14. Please upgrade " + "to a newer version of MI.")); +} + +/* See ui.h. */ + void ui::unregister_file_handler () { diff --git a/gdb/ui.h b/gdb/ui.h index be89ab3d6848..4f6a32991d6d 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -167,6 +167,18 @@ struct ui : public intrusive_list_node interp_factory_register, return nullptr; otherwise return a pointer to the interpreter. */ interp *lookup_interp (const char *name); + + /* This sets the current interpreter of this UI to be INTERP. If INTERP has + not been initialized, then this will also run the init method. + + The TOP_LEVEL parameter tells if this new interpreter is + the top-level one. The top-level is what is requested + on the command line, and is responsible for reporting general + notification about target state changes. For example, if + MI is the top-level interpreter, then it will always report + events such as target stops and new thread creation, even if they + are caused by CLI commands. */ + void set_current_interpreter (interp *interp, bool top_level); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. From patchwork Fri Sep 8 18:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75577 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 62290388205A for ; Fri, 8 Sep 2023 19:06:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 62290388205A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200018; bh=3LpgRulcWCbRxTnOuTuCcNnDJmNshoYzc/NNpUkBOUU=; 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=MY8Q6g48RZPTOHXTZOvuWaURAVMTO8jUf/6G6I82QueHz0BIy3dzRjY3EyKS982Lv TJGZwtsWwwDKAr/ez5ImTyyrIlE+fxJaQ3wJnSObtATNZ/hEI753EAmh4wCuiVkf// lmb0ZkzDC9GOMUzLoK1O5iHvKjS08f5FhGkA0RC8= 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 E5F143856DC2 for ; Fri, 8 Sep 2023 19:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5F143856DC2 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 66E171E0D0; Fri, 8 Sep 2023 15:06:32 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 19/21] gdb: pass down current_ui to set_top_level_interpreter Date: Fri, 8 Sep 2023 14:23:13 -0400 Message-ID: <20230908190227.96319-20-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" In preparation for making set_top_level_interpreter a method of struct ui. Change-Id: I9d1a67f01f49743ef72c002bd7876e6d2f97b77a --- gdb/interps.c | 6 +++--- gdb/interps.h | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index 465c174ea794..f954d503538c 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -83,15 +83,15 @@ find_interp_factory (const char *name) /* See interps.h. */ void -set_top_level_interpreter (const char *name) +set_top_level_interpreter (ui *ui, const char *name) { /* Find it. */ - struct interp *interp = current_ui->lookup_interp (name); + struct interp *interp = ui->lookup_interp (name); if (interp == NULL) error (_("Interpreter `%s' unrecognized"), name); /* Install it. */ - current_ui->set_current_interpreter (interp, true); + ui->set_current_interpreter (interp, true); } void diff --git a/gdb/interps.h b/gdb/interps.h index 278ee5aff9a5..4c094bf33e32 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -215,10 +215,11 @@ class interp : public intrusive_list_node bool inited = false; }; -/* Set the current UI's top level interpreter to the interpreter named - NAME. Throws an error if NAME is not a known interpreter or the - interpreter fails to initialize. */ -extern void set_top_level_interpreter (const char *name); +/* Set UI's top level interpreter to the interpreter named NAME. + + Throws an error if NAME is not a known interpreter or the interpreter fails + to initialize. */ +extern void set_top_level_interpreter (ui *ui, const char *name); /* Temporarily set the current interpreter, and reset it on destruction. */ From patchwork Fri Sep 8 18:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75579 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 CC8DC388264E for ; Fri, 8 Sep 2023 19:07:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC8DC388264E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200021; bh=UprgNMu5NCzIfSR7/M3l3SnHniks59fwelOYTyhbCog=; 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=p0x48LIJtS/rrDKVa69HSS433IwUTVFZqrvSS1jwwrm6LYvyCDpLRh5jdiM40+MHN f4cdSMIs+9KUiFRrlMxMvQjFXsbw8T183cTJrFPq79WeMVcRJsDuBOoJECfSJvHGyy 7rpU1LNg1q08kyX3KmBjnD4tk5gIdFm9LA4T5QD4= 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 0F242385770D for ; Fri, 8 Sep 2023 19:06:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F242385770D 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 7C40F1E0D2; Fri, 8 Sep 2023 15:06:32 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 20/21] gdb: make set_top_level_interpreter a method of struct ui Date: Fri, 8 Sep 2023 14:23:14 -0400 Message-ID: <20230908190227.96319-21-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.0 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: Ie3ab2a2f2191a9df769c51ea81d564724789c6f6 --- gdb/interps.c | 14 -------------- gdb/interps.h | 6 ------ gdb/main.c | 2 +- gdb/ui.c | 17 ++++++++++++++++- gdb/ui.h | 6 ++++++ 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/gdb/interps.c b/gdb/interps.c index f954d503538c..f30357405877 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -80,20 +80,6 @@ find_interp_factory (const char *name) return nullptr; } -/* See interps.h. */ - -void -set_top_level_interpreter (ui *ui, const char *name) -{ - /* Find it. */ - struct interp *interp = ui->lookup_interp (name); - - if (interp == NULL) - error (_("Interpreter `%s' unrecognized"), name); - /* Install it. */ - ui->set_current_interpreter (interp, true); -} - void current_interp_set_logging (ui_file_up logfile, bool logging_redirect, bool debug_redirect) diff --git a/gdb/interps.h b/gdb/interps.h index 4c094bf33e32..8416d657fb9a 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -215,12 +215,6 @@ class interp : public intrusive_list_node bool inited = false; }; -/* Set UI's top level interpreter to the interpreter named NAME. - - Throws an error if NAME is not a known interpreter or the interpreter fails - to initialize. */ -extern void set_top_level_interpreter (ui *ui, const char *name); - /* Temporarily set the current interpreter, and reset it on destruction. */ class scoped_restore_interp diff --git a/gdb/main.c b/gdb/main.c index cf46f6acb208..58a79c518999 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1136,7 +1136,7 @@ captured_main_1 (struct captured_main_args *context) /* Install the default UI. All the interpreters should have had a look at things by now. Initialize the default interpreter. */ - set_top_level_interpreter (interpreter_p.c_str ()); + current_ui->set_top_level_interpreter (interpreter_p.c_str ()); if (!quiet) { diff --git a/gdb/ui.c b/gdb/ui.c index 2db899eb9c31..ec74cc91cd21 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -223,6 +223,21 @@ ui::set_current_interpreter (interp *interp, bool top_level) /* See ui.h. */ +void +ui::set_top_level_interpreter (const char *name) +{ + /* Find it. */ + struct interp *interp = this->lookup_interp (name); + + if (interp == NULL) + error (_("Interpreter `%s' unrecognized"), name); + + /* Install it. */ + this->set_current_interpreter (interp, true); +} + +/* See ui.h. */ + void ui::unregister_file_handler () { @@ -278,7 +293,7 @@ new_ui_command (const char *args, int from_tty) current_ui = ui.get (); - set_top_level_interpreter (interpreter_name); + current_ui->set_top_level_interpreter (interpreter_name); top_level_interpreter ()->pre_command_loop (); diff --git a/gdb/ui.h b/gdb/ui.h index 4f6a32991d6d..cebf112f971c 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -179,6 +179,12 @@ struct ui : public intrusive_list_node events such as target stops and new thread creation, even if they are caused by CLI commands. */ void set_current_interpreter (interp *interp, bool top_level); + + /* Set this UI's top level interpreter to the interpreter named NAME. + + Throws an error if NAME is not a known interpreter or the interpreter fails + to initialize. */ + void set_top_level_interpreter (const char *name); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. From patchwork Fri Sep 8 18:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75581 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 832363870C00 for ; Fri, 8 Sep 2023 19:07:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 832363870C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694200076; bh=D/PgcsWoxQNUkprdJNPerXOJUWGh30V3DmDt0zxevSE=; 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=QWLAWSZIJJcEDgXvo6fJO5B77lu4iKv++4bSX+JGW+oybVUaLb599UcTASCj+BqWs 3K51tKPj9KId4rS49FdkJjGiVnqN/i10QEYTch+am/D9/mlaNvvbLszv2NdlmiIWgP lZBKOEpgtAdz0MSzqlxoUfkQge2Gu+wUd2i8oa9M= 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 79C633856962 for ; Fri, 8 Sep 2023 19:06:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 79C633856962 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 923141E110; Fri, 8 Sep 2023 15:06:32 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 21/21] gdb: make top_level_interpreter a method of struct ui Date: Fri, 8 Sep 2023 14:23:15 -0400 Message-ID: <20230908190227.96319-22-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.0 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" Rename the field to m_top_level_interpreter and make it private. Adjust all callers to use `current_ui->top_level_interpreter ()`. Change-Id: I6b5461d47d566af5fffc835454c08dd9a1dc9570 --- gdb/event-top.c | 2 +- gdb/infrun.c | 4 ++-- gdb/interps.c | 8 +------- gdb/interps.h | 3 --- gdb/linespec.c | 3 ++- gdb/main.c | 4 ++-- gdb/mi/mi-interp.c | 4 ++-- gdb/solib.c | 4 +++- gdb/tui/tui.c | 2 +- gdb/ui.c | 6 +++--- gdb/ui.h | 8 +++++++- gdb/utils.c | 5 +++-- 12 files changed, 27 insertions(+), 26 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 54f199d2e393..0dd85cb24d49 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -299,7 +299,7 @@ change_line_handler (int editing) /* Don't try enabling editing if the interpreter doesn't support it (e.g., MI). */ - if (!top_level_interpreter ()->supports_command_editing () + if (!current_ui->top_level_interpreter ()->supports_command_editing () || !command_interp ()->supports_command_editing ()) return; diff --git a/gdb/infrun.c b/gdb/infrun.c index aaa7b2de14cd..9129abba8524 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2916,7 +2916,7 @@ clear_proceed_status_thread (struct thread_info *tp) static void notify_about_to_proceed () { - top_level_interpreter ()->on_about_to_proceed (); + current_ui->top_level_interpreter ()->on_about_to_proceed (); gdb::observers::about_to_proceed.notify (); } @@ -4282,7 +4282,7 @@ check_curr_ui_sync_execution_done (void) && !gdb_in_secondary_prompt_p (ui)) { target_terminal::ours (); - top_level_interpreter ()->on_sync_execution_done (); + current_ui->top_level_interpreter ()->on_sync_execution_done (); ui->register_file_handler (); } } diff --git a/gdb/interps.c b/gdb/interps.c index f30357405877..0c5afa970651 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -222,12 +222,6 @@ interpreter_completer (struct cmd_list_element *ignore, } } -struct interp * -top_level_interpreter (void) -{ - return current_ui->top_level_interpreter; -} - /* See interps.h. */ struct interp * @@ -245,7 +239,7 @@ interps_notify (void (interp::*method) (Args...), Args... args) { SWITCH_THRU_ALL_UIS () { - interp *tli = top_level_interpreter (); + interp *tli = current_ui->top_level_interpreter (); if (tli != nullptr) (tli->*method) (args...); } diff --git a/gdb/interps.h b/gdb/interps.h index 8416d657fb9a..1073d0516cfe 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -258,9 +258,6 @@ extern void current_interp_set_logging (ui_file_up logfile, bool logging_redirect, bool debug_redirect); -/* Returns the top-level interpreter. */ -extern struct interp *top_level_interpreter (void); - /* Return the current UI's current interpreter. */ extern struct interp *current_interpreter (void); diff --git a/gdb/linespec.c b/gdb/linespec.c index fa733d880e38..bfee951bef2a 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -48,6 +48,7 @@ #include "gdbsupport/def-vector.h" #include #include "inferior.h" +#include "ui.h" /* An enumeration of the various things a user might attempt to complete for a linespec location. */ @@ -3168,7 +3169,7 @@ decode_line_full (struct location_spec *locspec, int flags, if (select_mode == NULL) { - if (top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) + if (current_ui->top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) select_mode = multiple_symbols_all; else select_mode = multiple_symbols_select_mode (); diff --git a/gdb/main.c b/gdb/main.c index 58a79c518999..c31e28a79a74 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -430,7 +430,7 @@ start_event_loop () get around to resetting the prompt, which leaves readline in a messed-up state. Reset it here. */ current_ui->prompt_state = PROMPT_NEEDED; - top_level_interpreter ()->on_command_error (); + current_ui->top_level_interpreter ()->on_command_error (); /* This call looks bizarre, but it is required. If the user entered a command that caused an error, after_char_processing_hook won't be called from @@ -470,7 +470,7 @@ captured_command_loop () /* Give the interpreter a chance to print a prompt, if necessary */ if (ui->prompt_state != PROMPT_BLOCKED) - top_level_interpreter ()->pre_command_loop (); + current_ui->top_level_interpreter ()->pre_command_loop (); /* Now it's time to start the event loop. */ start_event_loop (); diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 60a2ed0bcc4c..30ba7a347b48 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -235,7 +235,7 @@ mi_interp::on_sync_execution_done () static void mi_execute_command_input_handler (gdb::unique_xmalloc_ptr &&cmd) { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + mi_interp *mi = as_mi_interp (current_ui->top_level_interpreter ()); struct ui *ui = current_ui; ui->prompt_state = PROMPT_NEEDED; @@ -630,7 +630,7 @@ mi_output_running (struct thread_info *thread) { SWITCH_THRU_ALL_UIS () { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); + mi_interp *mi = as_mi_interp (current_ui->top_level_interpreter ()); if (mi == NULL) continue; diff --git a/gdb/solib.c b/gdb/solib.c index 4f980e9365c4..e434c7145e4b 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -54,6 +54,7 @@ #include "source.h" #include "cli/cli-style.h" #include "solib-target.h" +#include "ui.h" /* See solib.h. */ @@ -1146,7 +1147,8 @@ info_sharedlibrary_command (const char *pattern, int from_tty) uiout->field_skip ("to"); } - if (! top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () + if (!(current_ui->top_level_interpreter ()->interp_ui_out () + ->is_mi_like_p ()) && so->symbols_loaded && !objfile_has_symbols (so->objfile)) { diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 941c65c970f3..818f5f8a1382 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -399,7 +399,7 @@ tui_enable (void) /* If the top level interpreter is not the console/tui (e.g., MI), enabling curses will certainly lose. */ - interp = top_level_interpreter ()->name (); + interp = current_ui->top_level_interpreter ()->name (); if (strcmp (interp, INTERP_TUI) != 0) error (_("Cannot enable the TUI when the interpreter is '%s'"), interp); diff --git a/gdb/ui.c b/gdb/ui.c index ec74cc91cd21..e3d4a4765b80 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -180,7 +180,7 @@ ui::set_current_interpreter (interp *interp, bool top_level) /* If we already have an interpreter, then trying to set top level interpreter is kinda pointless. */ gdb_assert (!top_level || !this->current_interpreter); - gdb_assert (!top_level || !this->top_level_interpreter); + gdb_assert (!top_level || this->m_top_level_interpreter == nullptr); if (old_interp != NULL) { @@ -190,7 +190,7 @@ ui::set_current_interpreter (interp *interp, bool top_level) this->current_interpreter = interp; if (top_level) - this->top_level_interpreter = interp; + this->m_top_level_interpreter = interp; if (interpreter_p != interp->name ()) interpreter_p = interp->name (); @@ -295,7 +295,7 @@ new_ui_command (const char *args, int from_tty) current_ui->set_top_level_interpreter (interpreter_name); - top_level_interpreter ()->pre_command_loop (); + current_ui->top_level_interpreter ()->pre_command_loop (); /* Make sure the file is not closed. */ stream.release (); diff --git a/gdb/ui.h b/gdb/ui.h index cebf112f971c..1ba45760c186 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -86,7 +86,6 @@ struct ui : public intrusive_list_node /* Each UI has its own independent set of interpreters. */ intrusive_list interp_list; interp *current_interpreter = nullptr; - interp *top_level_interpreter = nullptr; /* The interpreter that is active while `interp_exec' is active, NULL at all other times. */ @@ -185,6 +184,13 @@ struct ui : public intrusive_list_node Throws an error if NAME is not a known interpreter or the interpreter fails to initialize. */ void set_top_level_interpreter (const char *name); + + /* Return this UI's top level interpreter. */ + interp *top_level_interpreter () + { return m_top_level_interpreter; } + +private: + interp *m_top_level_interpreter = nullptr; }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. diff --git a/gdb/utils.c b/gdb/utils.c index cacd6cbd23e6..ef46b6bc292d 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1606,8 +1606,9 @@ pager_file::puts (const char *linebuffer) /* Don't do any filtering or wrapping if both are disabled. */ if (batch_flag || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX) - || top_level_interpreter () == NULL - || top_level_interpreter ()->interp_ui_out ()->is_mi_like_p ()) + || current_ui->top_level_interpreter () == NULL + || (current_ui->top_level_interpreter ()->interp_ui_out () + ->is_mi_like_p ())) { flush_wrap_buffer (); m_stream->puts (linebuffer);