gdb/tui: avoid extra refresh_window on vertical scroll
authorAndrew Burgess <aburgess@redhat.com>
Thu, 5 Jan 2023 12:26:09 +0000 (12:26 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 27 Jan 2023 16:20:10 +0000 (16:20 +0000)
While working on the previous couple of patches I noticed that when I
scroll the src and asm windows vertically, I get two refresh_window
calls.

The two calls can be traced back to
tui_source_window_base::update_source_window_as_is, in here we call
show_source_content, which calls refresh_window, and then
update_exec_info, which also calls refresh_window.

In this commit I propose making the refresh_window call in
update_exec_info optional.  In update_source_window_as_is I'll then
call update_exec_info before calling show_source_content, and pass a
flag to update_exec_info to defer the refresh.

There are places where update_exec_info is used without any subsequent
refresh_window call (e.g. when a breakpoint is updated), so
update_exec_info does not to call refresh_window in some cases, which
is why I'm using a flag to control the refresh.

With this changes I'm now only seeing a single refresh_window call for
each vertical scroll.

There should be no user visible changes after this commit.

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

index 50efa80576ff7ab9cd4827a5b9ee3b9e4e754357..b5b6079a9095338694e0a425b795d26b21bdd454 100644 (file)
@@ -172,8 +172,8 @@ tui_source_window_base::update_source_window_as_is
     {
       validate_scroll_offsets ();
       update_breakpoint_info (nullptr, false);
+      update_exec_info (false);
       show_source_content ();
-      update_exec_info ();
     }
 }
 
@@ -636,11 +636,10 @@ tui_source_window_base::update_breakpoint_info
   return need_refresh;
 }
 
-/* Function to initialize the content of the execution info window,
-   based upon the input window which is either the source or
-   disassembly window.  */
+/* See tui-winsource.h.  */
+
 void
-tui_source_window_base::update_exec_info ()
+tui_source_window_base::update_exec_info (bool refresh_p)
 {
   update_breakpoint_info (nullptr, true);
   for (int i = 0; i < m_content.size (); i++)
@@ -668,5 +667,6 @@ tui_source_window_base::update_exec_info ()
 
       show_line_number (i);
     }
-  refresh_window ();
+  if (refresh_p)
+    refresh_window ();
 }
index 2762afff0106b06676c4ad5568119df6b6a89e0d..7370ae95d8b57ff5d388429b5b48a811be3e5075 100644 (file)
@@ -148,7 +148,14 @@ public:
 
   virtual bool location_matches_p (struct bp_location *loc, int line_no) = 0;
 
-  void update_exec_info ();
+  /* Fill in the left margin of the current window with execution indicator
+     information, e.g. breakpoint indicators, and line numbers.  When
+     REFRESH_P is true this function will call refresh_window to ensure
+     updates are written to the screen, otherwise the refresh is skipped,
+     which will leave the on screen contents out of date.  When passing
+     false for REFRESH_P you should be planning to call refresh_window
+     yourself.  */
+  void update_exec_info (bool refresh_p = true);
 
   /* Update the window to display the given location.  Does nothing if
      the location is already displayed.  */