From patchwork Tue May 2 20:49:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 68653 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 EE31B385773B for ; Tue, 2 May 2023 20:52:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE31B385773B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683060760; bh=8qbzpZrYetf4+gmopI7KdHYVH27F+k/RX+YzQbLiA1I=; 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=hcLf5z+4aaEDykPKym09jvqqIGCDHhH3xVBACHskzmMHLFPX+3LdEAjGdrf4EzLuS KZX8YKoj3ILQ1GIMaVL+bNK/7Le0LhtqY8ywMDR4jDNn0jxAoCGLhgMku+XBOubYip Ak9SR7HnlWPw2okeCC1KcypDNj6vx4/JTrp2yn38= 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 E20F93858D1E for ; Tue, 2 May 2023 20:52:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E20F93858D1E 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5FA741E0D4; Tue, 2 May 2023 16:52:15 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 08/30] gdb: add interp::on_sync_execution_done method Date: Tue, 2 May 2023 16:49:48 -0400 Message-Id: <20230502205011.132151-9-simon.marchi@efficios.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230502205011.132151-1-simon.marchi@efficios.com> References: <20230502205011.132151-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3497.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE 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.29 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" Same as previous patches, but for sync_execution_done. Except that here, we only want to notify the interpreter that is executing the command, not all interpreters. Change-Id: I729c719447b5c5f29af65dbf6fed9132e2cd308b --- gdb/cli/cli-interp.c | 12 ++---------- gdb/cli/cli-interp.h | 1 + gdb/infrun.c | 2 +- gdb/interps.h | 4 ++++ gdb/mi/mi-interp.c | 16 +++------------- gdb/mi/mi-interp.h | 1 + gdb/observable.c | 1 - gdb/observable.h | 3 --- 8 files changed, 12 insertions(+), 28 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 98bc2033f2c6..00310542a8db 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -152,15 +152,9 @@ cli_interp_base::on_no_history () print_no_history_reason (this->interp_ui_out ()); } -/* Observer for the sync_execution_done notification. */ - -static void -cli_base_on_sync_execution_done () +void +cli_interp_base::on_sync_execution_done () { - cli_interp_base *cli = as_cli_interp_base (top_level_interpreter ()); - if (cli == nullptr) - return; - display_gdb_prompt (NULL); } @@ -361,8 +355,6 @@ _initialize_cli_interp () interp_factory_register (INTERP_CONSOLE, cli_interp_factory); /* Note these all work for both the CLI and TUI interpreters. */ - gdb::observers::sync_execution_done.attach (cli_base_on_sync_execution_done, - "cli-interp-base"); gdb::observers::command_error.attach (cli_base_on_command_error, "cli-interp-base"); gdb::observers::user_selected_context_changed.attach diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index 7fc22a042d73..4680c8070fd0 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -38,6 +38,7 @@ class cli_interp_base : public interp void on_normal_stop (bpstat *bs, int print_frame) override; void on_exited (int status) override; void on_no_history () override; + void on_sync_execution_done () override; private: struct saved_output_files diff --git a/gdb/infrun.c b/gdb/infrun.c index f86ec7a2ed81..8d648cf04f0a 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4206,7 +4206,7 @@ check_curr_ui_sync_execution_done (void) && !gdb_in_secondary_prompt_p (ui)) { target_terminal::ours (); - gdb::observers::sync_execution_done.notify (); + top_level_interpreter ()->on_sync_execution_done (); ui->register_file_handler (); } } diff --git a/gdb/interps.h b/gdb/interps.h index 915a5f74eb73..349ffb1bdcf7 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -102,6 +102,10 @@ class interp : public intrusive_list_node execution because there is no more history. */ virtual void on_no_history () {} + /* Notify the interpreter that a synchronous command it started has + finished. */ + virtual void on_sync_execution_done () {} + private: /* The memory for this is static, it comes from literal strings (e.g. "cli"). */ const char *m_name; diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index a147c46ecf3b..21c0fb6e73f7 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -82,7 +82,6 @@ static void mi_breakpoint_modified (struct breakpoint *b); static void mi_command_param_changed (const char *param, const char *value); static void mi_memory_changed (struct inferior *inf, CORE_ADDR memaddr, ssize_t len, const bfd_byte *myaddr); -static void mi_on_sync_execution_done (void); /* Display the MI prompt. */ @@ -268,20 +267,13 @@ mi_execute_command_wrapper (const char *cmd) mi_execute_command (cmd, ui->instream == ui->stdin_stream); } -/* Observer for the synchronous_command_done notification. */ - -static void -mi_on_sync_execution_done (void) +void +mi_interp::on_sync_execution_done () { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - - if (mi == NULL) - return; - /* If MI is sync, then output the MI prompt now, indicating we're ready for further input. */ if (!mi_async_p ()) - display_mi_prompt (mi); + display_mi_prompt (this); } /* mi_execute_command_wrapper wrapper suitable for INPUT_HANDLER. */ @@ -1246,8 +1238,6 @@ _initialize_mi_interp () "mi-interp"); gdb::observers::command_error.attach (mi_on_command_error, "mi-interp"); gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp"); - gdb::observers::sync_execution_done.attach (mi_on_sync_execution_done, - "mi-interp"); gdb::observers::user_selected_context_changed.attach (mi_user_selected_context_changed, "mi-interp"); } diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index aeebc3207526..15ba8dab15bd 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -47,6 +47,7 @@ class mi_interp final : public interp void on_normal_stop (struct bpstat *bs, int print_frame) override; void on_exited (int status) override; void on_no_history () override; + void on_sync_execution_done () override; /* MI's output channels */ mi_console_file *out; diff --git a/gdb/observable.c b/gdb/observable.c index 502e2d988cd1..f52989d7a638 100644 --- a/gdb/observable.c +++ b/gdb/observable.c @@ -34,7 +34,6 @@ bool observer_debug = false; DEFINE_OBSERVABLE (normal_stop); DEFINE_OBSERVABLE (signal_received); -DEFINE_OBSERVABLE (sync_execution_done); DEFINE_OBSERVABLE (command_error); DEFINE_OBSERVABLE (target_changed); DEFINE_OBSERVABLE (executable_changed); diff --git a/gdb/observable.h b/gdb/observable.h index b06d13be0362..4be05efa0231 100644 --- a/gdb/observable.h +++ b/gdb/observable.h @@ -57,9 +57,6 @@ extern observable normal_stop; /* The inferior was stopped by a signal. */ extern observable signal_received; -/* A synchronous command finished. */ -extern observable<> sync_execution_done; - /* An error was caught while executing a command. */ extern observable<> command_error;