From: Tom Tromey Date: Mon, 24 Jun 2019 03:25:46 +0000 (-0600) Subject: Remove deleted breakpoint from TUI display X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0807ab7b88fa5ffb138ba1ee22b33d26e239de2f;p=binutils-gdb.git Remove deleted breakpoint from TUI display PR tui/24722 points out that deleting a breakpoint does not cause the "b" to be removed from the breakpoint display. The issue here was that the breakpoint still exists at the moment the breakpoint-deleted observer is notified. This fixes the problem by specially handling the case where a breakpoint is being removed. gdb/ChangeLog 2019-07-17 Tom Tromey PR tui/24722: * tui/tui-winsource.h (tui_update_all_breakpoint_info) (tui_update_breakpoint_info): Add "being_deleted" parameter. * tui/tui-winsource.c (tui_update_source_window_as_is): Update. (tui_update_all_breakpoint_info): Add "being_deleted" parameter. (tui_update_breakpoint_info): Likewise. * tui/tui-hooks.c (tui_event_create_breakpoint) (tui_event_delete_breakpoint, tui_event_modify_breakpoint): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 54c19e0144a..6635cbfb1a2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2019-07-17 Tom Tromey + + PR tui/24722: + * tui/tui-winsource.h (tui_update_all_breakpoint_info) + (tui_update_breakpoint_info): Add "being_deleted" parameter. + * tui/tui-winsource.c (tui_update_source_window_as_is): Update. + (tui_update_all_breakpoint_info): Add "being_deleted" parameter. + (tui_update_breakpoint_info): Likewise. + * tui/tui-hooks.c (tui_event_create_breakpoint) + (tui_event_delete_breakpoint, tui_event_modify_breakpoint): + Update. + 2019-07-17 Tom Tromey * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s. diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 9bac4a883aa..71010530749 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -91,7 +91,7 @@ tui_register_changed (struct frame_info *frame, int regno) static void tui_event_create_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (nullptr); } /* Breakpoint deletion hook. @@ -99,13 +99,13 @@ tui_event_create_breakpoint (struct breakpoint *b) static void tui_event_delete_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (b); } static void tui_event_modify_breakpoint (struct breakpoint *b) { - tui_update_all_breakpoint_info (); + tui_update_all_breakpoint_info (nullptr); } /* Refresh TUI's frame and register information. This is a hook intended to be diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index c7c04dfe816..22cd54ee9b8 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -106,7 +106,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info, } else { - tui_update_breakpoint_info (win_info, 0); + tui_update_breakpoint_info (win_info, nullptr, false); tui_show_source_content (win_info); tui_update_exec_info (win_info); if (win_info->type == SRC_WIN) @@ -382,15 +382,14 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l) refill (); } -/* Update the execution windows to show the active breakpoints. - This is called whenever a breakpoint is inserted, removed or - has its state changed. */ +/* See tui-winsource.h. */ + void -tui_update_all_breakpoint_info () +tui_update_all_breakpoint_info (struct breakpoint *being_deleted) { for (tui_source_window_base *win : tui_source_windows ()) { - if (tui_update_breakpoint_info (win, FALSE)) + if (tui_update_breakpoint_info (win, being_deleted, false)) { tui_update_exec_info (win); } @@ -398,18 +397,19 @@ tui_update_all_breakpoint_info () } -/* Scan the source window and the breakpoints to update the has_break +/* Scan the source window and the breakpoints to update the break_mode information for each line. - Returns 1 if something changed and the execution window must be + Returns true if something changed and the execution window must be refreshed. */ -int -tui_update_breakpoint_info (struct tui_source_window_base *win, - int current_only) +bool +tui_update_breakpoint_info (struct tui_source_window_base *win, + struct breakpoint *being_deleted, + bool current_only) { int i; - int need_refresh = 0; + bool need_refresh = false; tui_source_window_base *src = (tui_source_window_base *) win; for (i = 0; i < win->content.size (); i++) @@ -435,6 +435,9 @@ tui_update_breakpoint_info (struct tui_source_window_base *win, gdb_assert (line->line_or_addr.loa == LOA_LINE || line->line_or_addr.loa == LOA_ADDRESS); + if (bp == being_deleted) + continue; + for (loc = bp->loc; loc != NULL; loc = loc->next) { if ((win == TUI_SRC_WIN @@ -491,7 +494,7 @@ tui_set_exec_info_content (struct tui_source_window_base *win_info) tui_exec_info_content *content = win_info->execution_info->maybe_allocate_content (win_info->height); - tui_update_breakpoint_info (win_info, 1); + tui_update_breakpoint_info (win_info, nullptr, true); for (int i = 0; i < win_info->content.size (); i++) { tui_exec_info_content &element = content[i]; diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 2a85a008812..c1087f4490a 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -28,14 +28,21 @@ struct tui_win_info; /* Update the execution windows to show the active breakpoints. This is called whenever a breakpoint is inserted, removed or has its - state changed. */ -extern void tui_update_all_breakpoint_info (void); + state changed. Normally BEING_DELETED is nullptr; if not nullptr, + it indicates a breakpoint that is in the process of being deleted, + and which should therefore be ignored by the update. This is done + because the relevant observer is notified before the breakpoint is + removed from the list of breakpoints. */ +extern void tui_update_all_breakpoint_info (struct breakpoint *being_deleted); /* Scan the source window and the breakpoints to update the break_mode - information for each line. Returns 1 if something changed and the - execution window must be refreshed. */ -extern int tui_update_breakpoint_info (struct tui_source_window_base *win, - int current_only); + information for each line. Returns true if something changed and + the execution window must be refreshed. See + tui_update_all_breakpoint_info for a description of + BEING_DELETED. */ +extern bool tui_update_breakpoint_info (struct tui_source_window_base *win, + struct breakpoint *being_deleted, + bool current_only); /* Function to display the "main" routine. */ extern void tui_display_main (void);