From patchwork Tue May 2 20:50: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: 68674 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 BFD63385275A for ; Tue, 2 May 2023 20:57:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BFD63385275A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683061044; bh=gFTvZRRBM16TqyrKGlIxnQXqV0M86xCk+cU9j6R1p7g=; 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=NjoBmvTEs+LiHxknFBNwAKPwYS4UzvUll5CFiwiP8o/OCgCIZqrmqYQjbqrachBAq 8btNlYTzbia6v4HsgQL8oyX5mlsSLloXhKXIkWlseKePgnIs94tqsero4oCemNBtSa MUd9jWBl2rbzHTfOdmCSKENDsEUVkfc7iREiiVDw= 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 994E7385695C for ; Tue, 2 May 2023 20:56:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 994E7385695C 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 44E3C1E11E; Tue, 2 May 2023 16:56:23 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 28/30] gdb: add interp::on_breakpoint_modified method Date: Tue, 2 May 2023 16:50:08 -0400 Message-Id: <20230502205011.132151-29-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_modified. Change-Id: I4f0a9edea912de431e32451d74224b2022a7c328 --- gdb/breakpoint.c | 47 ++++++++++++++++++++++++++----------------- gdb/breakpoint.h | 5 +++++ gdb/interps.c | 8 ++++++++ gdb/interps.h | 6 ++++++ gdb/mi/mi-cmd-break.c | 2 +- gdb/mi/mi-interp.c | 28 +++++++------------------- gdb/mi/mi-interp.h | 1 + gdb/tracepoint.c | 4 ++-- 8 files changed, 58 insertions(+), 43 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 430e3b959ddf..853fe4978256 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1002,6 +1002,15 @@ set_breakpoint_location_condition (const char *cond_string, bp_location *loc, error (_("Garbage '%s' follows condition"), cond_string); } +/* See breakpoint.h. */ + +void +notify_breakpoint_modified (breakpoint *b) +{ + interps_notify_breakpoint_modified (b); + gdb::observers::breakpoint_modified.notify (b); +} + void set_breakpoint_condition (struct breakpoint *b, const char *exp, int from_tty, bool force) @@ -1094,7 +1103,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp, } mark_breakpoint_modified (b); - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* See breakpoint.h. */ @@ -1438,7 +1447,7 @@ breakpoint_set_commands (struct breakpoint *b, validate_commands_for_breakpoint (b, commands.get ()); b->commands = std::move (commands); - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* Set the internal `silent' flag on the breakpoint. Note that this @@ -1452,7 +1461,7 @@ breakpoint_set_silent (struct breakpoint *b, int silent) b->silent = silent; if (old_silent != silent) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* See breakpoint.h. */ @@ -1469,7 +1478,7 @@ breakpoint_set_thread (struct breakpoint *b, int thread) b->thread = thread; if (old_thread != thread) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* See breakpoint.h. */ @@ -1486,7 +1495,7 @@ breakpoint_set_task (struct breakpoint *b, int task) b->task = task; if (old_task != task) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } static void @@ -1555,7 +1564,7 @@ commands_command_1 (const char *arg, int from_tty, { validate_commands_for_breakpoint (b, cmd.get ()); b->commands = cmd; - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } }); } @@ -2893,7 +2902,7 @@ insert_bp_location (struct bp_location *bl, { /* See also: disable_breakpoints_in_shlibs. */ bl->shlib_disabled = 1; - gdb::observers::breakpoint_modified.notify (bl->owner); + notify_breakpoint_modified (bl->owner); if (!*disabled_breaks) { gdb_printf (tmp_error_stream, @@ -5599,7 +5608,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread) bs->stop = false; /* Increase the hit count even though we don't stop. */ ++(b->hit_count); - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); return; } @@ -5762,7 +5771,7 @@ bpstat_stop_status (const address_space *aspace, b->enable_state = bp_disabled; removed_any = 1; } - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); if (b->silent) bs->print = false; bs->commands = b->commands; @@ -7893,7 +7902,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib) loc->inserted = 0; /* This may cause duplicate notifications for the same breakpoint. */ - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); if (!disabled_shlib_breaks) { @@ -7973,7 +7982,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile) } if (bp_modified) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } } @@ -11095,7 +11104,7 @@ download_tracepoint_locations (void) t = (struct tracepoint *) b; t->number_on_target = b->number; if (bp_location_downloaded) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } } @@ -12863,7 +12872,7 @@ update_breakpoint_locations (code_breakpoint *b, } if (!locations_are_equal (existing_locations, b->loc)) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* Find the SaL locations corresponding to the given LOCSPEC. @@ -13111,7 +13120,7 @@ set_ignore_count (int bptnum, int count, int from_tty) "crossings of breakpoint %d."), count, bptnum); } - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); return; } @@ -13365,7 +13374,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable) } update_global_location_list (UGLL_DONT_INSERT); - gdb::observers::breakpoint_modified.notify (loc->owner); + notify_breakpoint_modified (loc->owner); } /* Calculates LOC_NUM for LOC by traversing the bp_location chain of LOC's @@ -13422,7 +13431,7 @@ enable_disable_bp_location (bp_location *loc, bool enable) target_disable_tracepoint (loc); update_global_location_list (UGLL_DONT_INSERT); - gdb::observers::breakpoint_modified.notify (loc->owner); + notify_breakpoint_modified (loc->owner); } /* Enable or disable a range of breakpoint locations. BP_NUM is the @@ -13467,7 +13476,7 @@ disable_breakpoint (struct breakpoint *bpt) update_global_location_list (UGLL_DONT_INSERT); - gdb::observers::breakpoint_modified.notify (bpt); + notify_breakpoint_modified (bpt); } /* Enable or disable the breakpoint(s) or breakpoint location(s) @@ -13592,7 +13601,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition, bpt->enable_count = count; update_global_location_list (UGLL_MAY_INSERT); - gdb::observers::breakpoint_modified.notify (bpt); + notify_breakpoint_modified (bpt); } @@ -14063,7 +14072,7 @@ static void trace_pass_set_count (struct tracepoint *tp, int count, int from_tty) { tp->pass_count = count; - gdb::observers::breakpoint_modified.notify (tp); + notify_breakpoint_modified (tp); if (from_tty) gdb_printf (_("Setting tracepoint %d's passcount to %d\n"), tp->number, count); diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 7c5cf3f2bef4..5cf49c4d7cce 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1946,4 +1946,9 @@ extern void describe_other_breakpoints (struct gdbarch *, extern void enable_disable_bp_location (bp_location *loc, bool enable); + +/* Notify interpreters and observers that breakpoint B was modified. */ + +extern void notify_breakpoint_modified (breakpoint *b); + #endif /* !defined (BREAKPOINT_H) */ diff --git a/gdb/interps.c b/gdb/interps.c index dc36af64f4c4..d572f92f4aa0 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -575,6 +575,14 @@ interps_notify_breakpoint_deleted (breakpoint *b) interps_notify (&interp::on_breakpoint_deleted, b); } +/* See interps.h. */ + +void +interps_notify_breakpoint_modified (breakpoint *b) +{ + interps_notify (&interp::on_breakpoint_modified, b); +} + /* This just adds the "interpreter-exec" command. */ void _initialize_interpreter (); void diff --git a/gdb/interps.h b/gdb/interps.h index 0e17b14735c0..6fda2ba372f1 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -172,6 +172,9 @@ class interp : public intrusive_list_node /* Notify the interpreter that breakpoint B was deleted. */ virtual void on_breakpoint_deleted (breakpoint *b) {} + /* Notify the interpreter that breakpoint B was modified. */ + virtual void on_breakpoint_modified (breakpoint *b) {} + private: /* The memory for this is static, it comes from literal strings (e.g. "cli"). */ const char *m_name; @@ -347,6 +350,9 @@ extern void interps_notify_breakpoint_created (breakpoint *b); /* Notify all interpreters that breakpoint B was deleted. */ extern void interps_notify_breakpoint_deleted (breakpoint *b); +/* Notify all interpreters that breakpoint B was modified. */ +extern void interps_notify_breakpoint_modified (breakpoint *b); + /* well-known interpreters */ #define INTERP_CONSOLE "console" #define INTERP_MI2 "mi2" diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index e5432d589900..72d30a8d44e3 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -467,7 +467,7 @@ mi_cmd_break_passcount (const char *command, char **argv, int argc) if (t) { t->pass_count = p; - gdb::observers::breakpoint_modified.notify (t); + notify_breakpoint_modified (t); } else { diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 334d7f9c5a82..2e30b15a4862 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_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); @@ -620,10 +619,8 @@ mi_interp::on_breakpoint_deleted (breakpoint *b) gdb_flush (this->event_channel); } -/* Emit notification about modified breakpoint. */ - -static void -mi_breakpoint_modified (struct breakpoint *b) +void +mi_interp::on_breakpoint_modified (breakpoint *b) { if (mi_suppress_notification.breakpoint) return; @@ -631,21 +628,12 @@ mi_breakpoint_modified (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 (); - gdb_printf (mi->event_channel, - "breakpoint-modified"); - mi_print_breakpoint_for_event (mi, b); + target_terminal::scoped_restore_terminal_state term_state; + target_terminal::ours_for_output (); + gdb_printf (this->event_channel, "breakpoint-modified"); + mi_print_breakpoint_for_event (this, b); - gdb_flush (mi->event_channel); - } + gdb_flush (this->event_channel); } static void @@ -984,8 +972,6 @@ _initialize_mi_interp () interp_factory_register (INTERP_MI4, mi_interp_factory); interp_factory_register (INTERP_MI, mi_interp_factory); - gdb::observers::breakpoint_modified.attach (mi_breakpoint_modified, - "mi-interp"); gdb::observers::command_param_changed.attach (mi_command_param_changed, "mi-interp"); gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp"); diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h index 61b8739b9b3c..52cce4c7cf4c 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -68,6 +68,7 @@ class mi_interp final : public interp void on_tsv_modified (const trace_state_variable *tsv) override; void on_breakpoint_created (breakpoint *b) override; void on_breakpoint_deleted (breakpoint *b) override; + void on_breakpoint_modified (breakpoint *b) override; /* MI's output channels */ mi_console_file *out; diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index e6ef87475060..2f4eb9c48a46 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1639,7 +1639,7 @@ start_tracing (const char *notes) loc->gdbarch); if (bp_location_downloaded) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* Send down all the trace state variables too. */ @@ -3138,7 +3138,7 @@ merge_uploaded_tracepoints (struct uploaded_tp **uploaded_tps) /* Notify 'breakpoint-modified' observer that at least one of B's locations was changed. */ for (breakpoint *b : modified_tp) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); free_uploaded_tps (uploaded_tps); }