Remove deleted breakpoint from TUI display
authorTom Tromey <tom@tromey.com>
Mon, 24 Jun 2019 03:25:46 +0000 (21:25 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 17 Jul 2019 18:18:53 +0000 (12:18 -0600)
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.

gdb/ChangeLog
gdb/tui/tui-hooks.c
gdb/tui/tui-winsource.c
gdb/tui/tui-winsource.h

index 54c19e0144a7268b44f05f1022a9b3764dd47fed..6635cbfb1a2f8bc6bd8c8da96f4a3ef2545852de 100644 (file)
@@ -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>
 
        * tui/tui-stack.c (tui_show_frame_info): Consolidate "if"s.
index 9bac4a883aa7975b09e52e1de00f6d2fc622dbea..710105307499e59dc274abfb6153535da0051984 100644 (file)
@@ -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
index c7c04dfe816fcd735c6475c6506d7f2aec49adf1..22cd54ee9b8ade2a682f4d98e835f29db3b87070 100644 (file)
@@ -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];
index 2a85a008812df32a7982bcc8324ba7aa571d9249..c1087f4490a972244ab91252b480e8b6f15bbb66 100644 (file)
@@ -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);