]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove tui_alloc_source_buffer
authorTom Tromey <tom@tromey.com>
Sat, 6 Jul 2019 21:52:13 +0000 (15:52 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 15 Aug 2019 18:29:28 +0000 (12:29 -0600)
There is no longer any need for tui_alloc_source_buffer.  The two
callers of this function immediately change the contents of the
window, undoing the work done by this function.

This required adding a move constructor to tui_source_element -- a
mildly surprising find, but without this, resizing the vector will
cause crashes.  This issue was masked earlier because
tui_alloc_source_buffer handled this.

Note that a patch for this bug was submitted here:

    https://sourceware.org/ml/gdb-patches/2019-08/msg00094.html

That patch is better, IMO, but the author as yet hasn't responded to a
request for a ChangeLog entry.

gdb/ChangeLog
2019-08-15  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
(struct tui_source_element): Add DISABLE_COPY_AND_ASSIGN, and move
constructor.
* tui/tui-winsource.c (tui_alloc_source_buffer): Remove.
* tui/tui-source.c (tui_set_source_content): Update.
* tui/tui-disasm.c (tui_set_disassem_content): Update.

gdb/ChangeLog
gdb/tui/tui-disasm.c
gdb/tui/tui-source.c
gdb/tui/tui-winsource.c
gdb/tui/tui-winsource.h

index 8ede3e360b03f8bd9d2d949e1ec850081ef047d3..946e737022dea0825e3bb701ca20b4fa66b6c871 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-15  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-winsource.h (tui_alloc_source_buffer): Don't declare.
+       (struct tui_source_element): Add DISABLE_COPY_AND_ASSIGN, and move
+       constructor.
+       * tui/tui-winsource.c (tui_alloc_source_buffer): Remove.
+       * tui/tui-source.c (tui_set_source_content): Update.
+       * tui/tui-disasm.c (tui_set_disassem_content): Update.
+
 2019-08-15  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-winsource.h (tui_line_is_displayed): Don't declare.
index e55f35da214d5b0b0b9baf6bcd6edbf06c2f48ec..2394394708537156d8cbdd59634cfc64d4235807 100644 (file)
@@ -179,8 +179,6 @@ tui_set_disassem_content (tui_source_window_base *win_info,
   if (pc == 0)
     return TUI_FAILURE;
 
-  tui_alloc_source_buffer (win_info);
-
   win_info->gdbarch = gdbarch;
   win_info->start_line_or_addr.loa = LOA_ADDRESS;
   win_info->start_line_or_addr.u.addr = pc;
index 7c173f8a6f96b8b05d2437905908da72e002ad05..3d88f66d5491d43f761ba02c3f8022cb96544e3f 100644 (file)
@@ -135,7 +135,6 @@ tui_set_source_content (tui_source_window_base *win_info,
       int line_width, nlines;
 
       ret = TUI_SUCCESS;
-      tui_alloc_source_buffer (win_info);
       line_width = win_info->width - 1;
       /* Take hilite (window border) into account, when
         calculating the number of lines.  */
index a85269657cf15c51e6923b112696b74e619f2eff..121f19abd8b2e885e80e0dbcdbb303fd8d569ca6 100644 (file)
@@ -620,23 +620,3 @@ tui_source_window_base::update_exec_info ()
     }
   execution_info->refresh_window ();
 }
-
-
-void
-tui_alloc_source_buffer (struct tui_source_window_base *win_info)
-{
-  int i, line_width, max_lines;
-
-  /* The window width/height includes the highlight box.  Determine actual
-     content dimensions, including string null-terminators.  */
-  max_lines = win_info->height - 2;
-  line_width = win_info->width - 2 + 1;
-
-  /* Allocate the buffer for the source lines.  */
-  win_info->content.resize (max_lines);
-  for (i = 0; i < max_lines; i++)
-    {
-      if (win_info->content[i].line == nullptr)
-       win_info->content[i].line = (char *) xmalloc (line_width);
-    }
-}
index 237c4daf037512e8b14acae83fbd67dc4f14e3ad..bff2560aaf3b5aac6e64c31ce3ee3cc93fa2048d 100644 (file)
@@ -69,6 +69,17 @@ struct tui_source_element
     xfree (line);
   }
 
+  DISABLE_COPY_AND_ASSIGN (tui_source_element);
+
+  tui_source_element (tui_source_element &&other)
+    : line (other.line),
+      line_or_addr (other.line_or_addr),
+      is_exec_point (other.is_exec_point),
+      break_mode (other.break_mode)
+  {
+    other.line = nullptr;
+  }
+
   char *line = nullptr;
   struct tui_line_or_address line_or_addr;
   bool is_exec_point = false;
@@ -173,9 +184,6 @@ extern void tui_update_source_windows_with_line (struct symtab *,
 extern void tui_clear_source_content (struct tui_source_window_base *);
 extern void tui_erase_source_content (struct tui_source_window_base *);
 
-extern void tui_alloc_source_buffer (struct tui_source_window_base *);
-
-
 /* Constant definitions. */
 #define SCROLL_THRESHOLD 2     /* Threshold for lazy scroll.  */