From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 118403858436; Tue, 30 May 2023 19:10:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 118403858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685473838; bh=0S/xT8Do7552HOD/E13M19YEA06iCHrITTfuCiBVVSM=; h=From:To:Subject:Date:From; b=HmVpoNtqXxYYXucjpGsoFk+uwn0MKyVJcXe5x04ZOO4sFUpQ3dSnG2mhdZaYEDvAL n1bflaXL/1MH9tI6zul1sDLTRsysnvdcqjRlLOcSi9MNMMgc5/0n2BMm4uqkR1qvxK T7X+kYdDdeffK23QZPq5n5uUxasJ7E50Ugj+a1Ws= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: add interp::on_breakpoint_modified method X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: e4239559f48767a4fe6778017908a96649330be5 X-Git-Newrev: 19081eb5f18e9e9c6855935c1149afa9a5edfbe1 Message-Id: <20230530191038.118403858436@sourceware.org> Date: Tue, 30 May 2023 19:10:38 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D19081eb5f18e= 9e9c6855935c1149afa9a5edfbe1 commit 19081eb5f18e9e9c6855935c1149afa9a5edfbe1 Author: Simon Marchi Date: Fri Apr 21 09:45:30 2023 -0400 gdb: add interp::on_breakpoint_modified method =20 Same idea as previous patches, but for breakpoint_modified. =20 Change-Id: I4f0a9edea912de431e32451d74224b2022a7c328 Diff: --- 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 76847f360ad..0a520cfc169 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -995,6 +995,15 @@ set_breakpoint_location_condition (const char *cond_st= ring, bp_location *loc, error (_("Garbage '%s' follows condition"), cond_string); } =20 +/* 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) @@ -1087,7 +1096,7 @@ set_breakpoint_condition (struct breakpoint *b, const= char *exp, } mark_breakpoint_modified (b); =20 - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 /* See breakpoint.h. */ @@ -1431,7 +1440,7 @@ breakpoint_set_commands (struct breakpoint *b, validate_commands_for_breakpoint (b, commands.get ()); =20 b->commands =3D std::move (commands); - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 /* Set the internal `silent' flag on the breakpoint. Note that this @@ -1445,7 +1454,7 @@ breakpoint_set_silent (struct breakpoint *b, int sile= nt) =20 b->silent =3D silent; if (old_silent !=3D silent) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 /* See breakpoint.h. */ @@ -1462,7 +1471,7 @@ breakpoint_set_thread (struct breakpoint *b, int thre= ad) =20 b->thread =3D thread; if (old_thread !=3D thread) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 /* See breakpoint.h. */ @@ -1479,7 +1488,7 @@ breakpoint_set_task (struct breakpoint *b, int task) =20 b->task =3D task; if (old_task !=3D task) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 static void @@ -1548,7 +1557,7 @@ commands_command_1 (const char *arg, int from_tty, { validate_commands_for_breakpoint (b, cmd.get ()); b->commands =3D cmd; - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } }); } @@ -2886,7 +2895,7 @@ insert_bp_location (struct bp_location *bl, { /* See also: disable_breakpoints_in_shlibs. */ bl->shlib_disabled =3D 1; - gdb::observers::breakpoint_modified.notify (bl->owner); + notify_breakpoint_modified (bl->owner); if (!*disabled_breaks) { gdb_printf (tmp_error_stream,=20 @@ -5575,7 +5584,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, threa= d_info *thread) bs->stop =3D 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; } =20 @@ -5738,7 +5747,7 @@ bpstat_stop_status (const address_space *aspace, b->enable_state =3D bp_disabled; removed_any =3D 1; } - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); if (b->silent) bs->print =3D false; bs->commands =3D b->commands; @@ -7868,7 +7877,7 @@ disable_breakpoints_in_unloaded_shlib (struct so_list= *solib) loc->inserted =3D 0; =20 /* This may cause duplicate notifications for the same breakpoint. */ - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); =20 if (!disabled_shlib_breaks) { @@ -7948,7 +7957,7 @@ disable_breakpoints_in_freed_objfile (struct objfile = *objfile) } =20 if (bp_modified) - gdb::observers::breakpoint_modified.notify (&b); + notify_breakpoint_modified (&b); } } =20 @@ -11057,7 +11066,7 @@ download_tracepoint_locations (void) tracepoint &t =3D gdb::checked_static_cast (b); t.number_on_target =3D b.number; if (bp_location_downloaded) - gdb::observers::breakpoint_modified.notify (&b); + notify_breakpoint_modified (&b); } } =20 @@ -12826,7 +12835,7 @@ update_breakpoint_locations (code_breakpoint *b, } =20 if (!locations_are_equal (existing_locations, b->locations ())) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } =20 /* Find the SaL locations corresponding to the given LOCSPEC. @@ -13075,7 +13084,7 @@ set_ignore_count (int bptnum, int count, int from_t= ty) "crossings of breakpoint %d."), count, bptnum); } - gdb::observers::breakpoint_modified.notify (&b); + notify_breakpoint_modified (&b); return; } =20 @@ -13329,7 +13338,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num,= bool enable) } update_global_location_list (UGLL_DONT_INSERT); =20 - gdb::observers::breakpoint_modified.notify (loc->owner); + notify_breakpoint_modified (loc->owner); } =20 /* Calculates LOC_NUM for LOC by traversing the bp_location chain of LOC's @@ -13386,7 +13395,7 @@ enable_disable_bp_location (bp_location *loc, bool = enable) target_disable_tracepoint (loc); =20 update_global_location_list (UGLL_DONT_INSERT); - gdb::observers::breakpoint_modified.notify (loc->owner); + notify_breakpoint_modified (loc->owner); } =20 /* Enable or disable a range of breakpoint locations. BP_NUM is the @@ -13431,7 +13440,7 @@ disable_breakpoint (struct breakpoint *bpt) =20 update_global_location_list (UGLL_DONT_INSERT); =20 - gdb::observers::breakpoint_modified.notify (bpt); + notify_breakpoint_modified (bpt); } =20 /* Enable or disable the breakpoint(s) or breakpoint location(s) @@ -13556,7 +13565,7 @@ enable_breakpoint_disp (struct breakpoint *bpt, enu= m bpdisp disposition, bpt->enable_count =3D count; update_global_location_list (UGLL_MAY_INSERT); =20 - gdb::observers::breakpoint_modified.notify (bpt); + notify_breakpoint_modified (bpt); } =20 =20 @@ -14027,7 +14036,7 @@ static void trace_pass_set_count (struct tracepoint *tp, int count, int from_tty) { tp->pass_count =3D 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 709d27fa4db..da150585f73 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -2007,4 +2007,9 @@ extern void describe_other_breakpoints (struct gdbarc= h *, =20 extern void enable_disable_bp_location (bp_location *loc, bool enable); =20 + +/* 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 dc36af64f4c..d572f92f4aa 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); } =20 +/* 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 0e17b14735c..6fda2ba372f 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -172,6 +172,9 @@ public: /* Notify the interpreter that breakpoint B was deleted. */ virtual void on_breakpoint_deleted (breakpoint *b) {} =20 + /* 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. "c= li"). */ const char *m_name; @@ -347,6 +350,9 @@ extern void interps_notify_breakpoint_created (breakpoi= nt *b); /* Notify all interpreters that breakpoint B was deleted. */ extern void interps_notify_breakpoint_deleted (breakpoint *b); =20 +/* 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 48b58587488..082c4da58a3 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -470,7 +470,7 @@ mi_cmd_break_passcount (const char *command, const char= *const *argv, if (t) { t->pass_count =3D 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 02d2bc893b7..73a193d5ce4 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_l= ist ap) static void mi_insert_notify_hooks (void); static void mi_remove_notify_hooks (void); =20 -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); @@ -621,10 +620,8 @@ mi_interp::on_breakpoint_deleted (breakpoint *b) gdb_flush (this->event_channel); } =20 -/* 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; @@ -632,21 +629,12 @@ mi_breakpoint_modified (struct breakpoint *b) if (b->number <=3D 0) return; =20 - SWITCH_THRU_ALL_UIS () - { - struct mi_interp *mi =3D as_mi_interp (top_level_interpreter ()); - - if (mi =3D=3D 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); =20 - gdb_flush (mi->event_channel); - } + gdb_flush (this->event_channel); } =20 static void @@ -985,8 +973,6 @@ _initialize_mi_interp () interp_factory_register (INTERP_MI4, mi_interp_factory); interp_factory_register (INTERP_MI, mi_interp_factory); =20 - 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 52c88a1c2b7..8ec8bc00a83 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -68,6 +68,7 @@ public: 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; =20 /* MI's output channels */ mi_console_file *out; diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2368730f1a0..f297cea5b43 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1640,7 +1640,7 @@ start_tracing (const char *notes) loc.probe.prob->set_semaphore (loc.probe.objfile, loc.gdbarch); =20 if (bp_location_downloaded) - gdb::observers::breakpoint_modified.notify (&b); + notify_breakpoint_modified (&b); } =20 /* Send down all the trace state variables too. */ @@ -3134,7 +3134,7 @@ merge_uploaded_tracepoints (struct uploaded_tp **uplo= aded_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); =20 free_uploaded_tps (uploaded_tps); }