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  <tom@tromey.com>

	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.
This commit is contained in:
Tom Tromey
2019-06-23 21:25:46 -06:00
parent 9ad7fdef7c
commit 0807ab7b88
4 changed files with 44 additions and 22 deletions

@ -1,3 +1,15 @@
2019-07-17 Tom Tromey <tom@tromey.com>
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 <tom@tromey.com> 2019-07-17 Tom Tromey <tom@tromey.com>
* tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s. * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s.

@ -91,7 +91,7 @@ tui_register_changed (struct frame_info *frame, int regno)
static void static void
tui_event_create_breakpoint (struct breakpoint *b) tui_event_create_breakpoint (struct breakpoint *b)
{ {
tui_update_all_breakpoint_info (); tui_update_all_breakpoint_info (nullptr);
} }
/* Breakpoint deletion hook. /* Breakpoint deletion hook.
@ -99,13 +99,13 @@ tui_event_create_breakpoint (struct breakpoint *b)
static void static void
tui_event_delete_breakpoint (struct breakpoint *b) tui_event_delete_breakpoint (struct breakpoint *b)
{ {
tui_update_all_breakpoint_info (); tui_update_all_breakpoint_info (b);
} }
static void static void
tui_event_modify_breakpoint (struct breakpoint *b) 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 /* Refresh TUI's frame and register information. This is a hook intended to be

@ -106,7 +106,7 @@ tui_update_source_window_as_is (struct tui_source_window_base *win_info,
} }
else else
{ {
tui_update_breakpoint_info (win_info, 0); tui_update_breakpoint_info (win_info, nullptr, false);
tui_show_source_content (win_info); tui_show_source_content (win_info);
tui_update_exec_info (win_info); tui_update_exec_info (win_info);
if (win_info->type == SRC_WIN) 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 (); refill ();
} }
/* Update the execution windows to show the active breakpoints. /* See tui-winsource.h. */
This is called whenever a breakpoint is inserted, removed or
has its state changed. */
void void
tui_update_all_breakpoint_info () tui_update_all_breakpoint_info (struct breakpoint *being_deleted)
{ {
for (tui_source_window_base *win : tui_source_windows ()) 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); 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. 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. */ refreshed. */
int bool
tui_update_breakpoint_info (struct tui_source_window_base *win, tui_update_breakpoint_info (struct tui_source_window_base *win,
int current_only) struct breakpoint *being_deleted,
bool current_only)
{ {
int i; int i;
int need_refresh = 0; bool need_refresh = false;
tui_source_window_base *src = (tui_source_window_base *) win; tui_source_window_base *src = (tui_source_window_base *) win;
for (i = 0; i < win->content.size (); i++) 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 gdb_assert (line->line_or_addr.loa == LOA_LINE
|| line->line_or_addr.loa == LOA_ADDRESS); || line->line_or_addr.loa == LOA_ADDRESS);
if (bp == being_deleted)
continue;
for (loc = bp->loc; loc != NULL; loc = loc->next) for (loc = bp->loc; loc != NULL; loc = loc->next)
{ {
if ((win == TUI_SRC_WIN 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 tui_exec_info_content *content
= win_info->execution_info->maybe_allocate_content (win_info->height); = 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++) for (int i = 0; i < win_info->content.size (); i++)
{ {
tui_exec_info_content &element = content[i]; tui_exec_info_content &element = content[i];

@ -28,14 +28,21 @@ struct tui_win_info;
/* Update the execution windows to show the active breakpoints. This /* Update the execution windows to show the active breakpoints. This
is called whenever a breakpoint is inserted, removed or has its is called whenever a breakpoint is inserted, removed or has its
state changed. */ state changed. Normally BEING_DELETED is nullptr; if not nullptr,
extern void tui_update_all_breakpoint_info (void); 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 /* Scan the source window and the breakpoints to update the break_mode
information for each line. Returns 1 if something changed and the information for each line. Returns true if something changed and
execution window must be refreshed. */ the execution window must be refreshed. See
extern int tui_update_breakpoint_info (struct tui_source_window_base *win, tui_update_all_breakpoint_info for a description of
int current_only); 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. */ /* Function to display the "main" routine. */
extern void tui_display_main (void); extern void tui_display_main (void);