diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2023-04-21 09:45:30 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2023-05-30 15:07:26 -0400 |
commit | e7692320db944fd157978d9be9f18a86abb997b4 (patch) | |
tree | de4e345dd0090de729d027cfeebd1e22c2147a76 | |
parent | c27ec5c09f3b94704688845e78861977d9bd4d71 (diff) | |
download | gdb-e7692320db944fd157978d9be9f18a86abb997b4.zip gdb-e7692320db944fd157978d9be9f18a86abb997b4.tar.gz gdb-e7692320db944fd157978d9be9f18a86abb997b4.tar.bz2 |
gdb: add interp::on_breakpoint_created method
Same idea as previous patches, but for breakpoint_created.
Change-Id: I614113c924edc243590018b8fb3bf69cb62215ef
-rw-r--r-- | gdb/breakpoint.c | 12 | ||||
-rw-r--r-- | gdb/interps.c | 8 | ||||
-rw-r--r-- | gdb/interps.h | 6 | ||||
-rw-r--r-- | gdb/mi/mi-interp.c | 28 | ||||
-rw-r--r-- | gdb/mi/mi-interp.h | 1 |
5 files changed, 33 insertions, 22 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a94277f..847347f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7979,6 +7979,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<breakpoint> &&arg, int update_gll) { @@ -7988,7 +7997,8 @@ install_breakpoint (int internal, std::unique_ptr<breakpoint> &&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 c727913..f8f9751 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 7bd57cb..b1e2903 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -166,6 +166,9 @@ public: /* 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 f8eb6c5..398459c 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); @@ -589,10 +588,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; @@ -600,22 +597,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. */ @@ -1010,8 +998,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 a796f53..5e7ffdf 100644 --- a/gdb/mi/mi-interp.h +++ b/gdb/mi/mi-interp.h @@ -66,6 +66,7 @@ public: 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; |