From patchwork Tue May 2 20:50: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: 68670 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 E523D385B514 for ; Tue, 2 May 2023 20:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E523D385B514 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683061014; bh=/YfHuh1FfbcT4sF9uKUbPbgCmTCA9LhbobRnoOAV+bM=; 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=hx61jFRrSgdcZYv/lyKYlncuWRFbbFBiNIRpyZD5rhpMBDR9/jratiWalDooZJ6dw CvzK2GfKRFIj008fV5oWC7rVH8ZCk4C476AqfJZQ/nl45DrD6qw4LeLSaUzunzuZM3 NV37ig19wurA0XPs4zLmxPu2YScWmritnFkWnwKo= 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 632F13857718 for ; Tue, 2 May 2023 20:56:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 632F13857718 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 1988E1E11B; Tue, 2 May 2023 16:56:23 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 26/30] gdb: add interp::on_breakpoint_created method Date: Tue, 2 May 2023 16:50:06 -0400 Message-Id: <20230502205011.132151-27-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 idea as previous patches, but for breakpoint_created. Change-Id: I614113c924edc243590018b8fb3bf69cb62215ef --- gdb/breakpoint.c | 12 +++++++++++- gdb/interps.c | 8 ++++++++ gdb/interps.h | 6 ++++++ gdb/mi/mi-interp.c | 28 +++++++--------------------- gdb/mi/mi-interp.h | 1 + 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 30d438d06df9..a600bc7cc7fc 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8004,6 +8004,15 @@ catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp, pspace = current_program_space; } +/* Notify interpreters and observers that breakpoint B was created. */ + +static void +notify_breakpoint_created (breakpoint *b) +{ + interps_notify_breakpoint_created (b); + gdb::observers::breakpoint_created.notify (b); +} + breakpoint * install_breakpoint (int internal, std::unique_ptr &&arg, int update_gll) { @@ -8013,7 +8022,8 @@ install_breakpoint (int internal, std::unique_ptr &&arg, int update_ set_tracepoint_count (breakpoint_count); if (!internal) mention (b); - gdb::observers::breakpoint_created.notify (b); + + notify_breakpoint_created (b); if (update_gll) update_global_location_list (UGLL_MAY_INSERT); diff --git a/gdb/interps.c b/gdb/interps.c index c727913e4806..f8f97513ac66 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -559,6 +559,14 @@ interps_notify_tsv_modified (const trace_state_variable *tsv) interps_notify (&interp::on_tsv_modified, tsv); } +/* See interps.h. */ + +void +interps_notify_breakpoint_created (breakpoint *b) +{ + interps_notify (&interp::on_breakpoint_created, b); +} + /* This just adds the "interpreter-exec" command. */ void _initialize_interpreter (); void diff --git a/gdb/interps.h b/gdb/interps.h index 7bd57cb05ecc..b1e2903e1571 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -166,6 +166,9 @@ class interp : public intrusive_list_node /* Notify the interpreter that trace state variable TSV was modified. */ virtual void on_tsv_modified (const trace_state_variable *tsv) {} + /* Notify the interpreter that breakpoint B was created. */ + virtual void on_breakpoint_created (breakpoint *b) {} + private: /* The memory for this is static, it comes from literal strings (e.g. "cli"). */ const char *m_name; @@ -335,6 +338,9 @@ extern void interps_notify_tsv_deleted (const trace_state_variable *tsv); /* Notify all interpreters that trace state variable TSV was modified. */ extern void interps_notify_tsv_modified (const trace_state_variable *tsv); +/* Notify all interpreters that breakpoint B was created. */ +extern void interps_notify_breakpoint_created (breakpoint *b); + /* well-known interpreters */ #define INTERP_CONSOLE "console" #define INTERP_MI2 "mi2" diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 65b9bd3693a2..d7df572546c4 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -60,7 +60,6 @@ static int mi_interp_query_hook (const char *ctlstr, va_list ap) static void mi_insert_notify_hooks (void); static void mi_remove_notify_hooks (void); -static void mi_breakpoint_created (struct breakpoint *b); static void mi_breakpoint_deleted (struct breakpoint *b); static void mi_breakpoint_modified (struct breakpoint *b); static void mi_command_param_changed (const char *param, const char *value); @@ -588,10 +587,8 @@ mi_print_breakpoint_for_event (struct mi_interp *mi, breakpoint *bp) } } -/* Emit notification about a created breakpoint. */ - -static void -mi_breakpoint_created (struct breakpoint *b) +void +mi_interp::on_breakpoint_created (breakpoint *b) { if (mi_suppress_notification.breakpoint) return; @@ -599,22 +596,13 @@ mi_breakpoint_created (struct breakpoint *b) if (b->number <= 0) return; - SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi = as_mi_interp (top_level_interpreter ()); - - if (mi == NULL) - continue; - - target_terminal::scoped_restore_terminal_state term_state; - target_terminal::ours_for_output (); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); - gdb_printf (mi->event_channel, - "breakpoint-created"); - mi_print_breakpoint_for_event (mi, b); + gdb_printf (this->event_channel, "breakpoint-created"); + mi_print_breakpoint_for_event (this, b); - gdb_flush (mi->event_channel); - } + gdb_flush (this->event_channel); } /* Emit notification about deleted breakpoint. */ @@ -1009,8 +997,6 @@ _initialize_mi_interp () interp_factory_register (INTERP_MI4, mi_interp_factory); interp_factory_register (INTERP_MI, mi_interp_factory); - gdb::observers::breakpoint_created.attach (mi_breakpoint_created, - "mi-interp"); gdb::observers::breakpoint_deleted.attach (mi_breakpoint_deleted, "mi-interp"); gdb::observers::breakpoint_modified.attach (mi_breakpoint_modified, diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index 11ec5ddf3781..bbd47422e962 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -66,6 +66,7 @@ class mi_interp final : public interp void on_tsv_created (const trace_state_variable *tsv) override; void on_tsv_deleted (const trace_state_variable *tsv) override; void on_tsv_modified (const trace_state_variable *tsv) override; + void on_breakpoint_created (breakpoint *b) override; /* MI's output channels */ mi_console_file *out;