[PATCH 05/61] Remove deleted breakpoint from TUI display

Tom Tromey tom@tromey.com
Thu Jul 4 17:04:00 GMT 2019


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.

2019-07-04  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.
---
 gdb/ChangeLog           | 12 ++++++++++++
 gdb/tui/tui-hooks.c     |  6 +++---
 gdb/tui/tui-winsource.c | 29 ++++++++++++++++-------------
 gdb/tui/tui-winsource.h | 19 +++++++++++++------
 4 files changed, 44 insertions(+), 22 deletions(-)

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);
-- 
2.17.2



More information about the Gdb-patches mailing list