Remove tui_alloc_source_buffer
[deliverable/binutils-gdb.git] / gdb / tui / tui-source.c
index f0bac24bfea4d6b5837cee4603ab605bc97567e1..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.  */
@@ -251,7 +250,9 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
       l.loa = LOA_LINE;
       l.u.line_no = content[0].line_or_addr.u.line_no
        + num_to_scroll;
-      if (l.u.line_no > s->nlines)
+      const std::vector<off_t> *offsets;
+      if (g_source_cache.get_line_charpos (s, &offsets)
+         && l.u.line_no > offsets->size ())
        /* line = s->nlines - win_info->content_size + 1; */
        /* elz: fix for dts 23398.  */
        l.u.line_no = content[0].line_or_addr.u.line_no;
@@ -291,3 +292,48 @@ tui_source_window::location_matches_p (struct bp_location *loc, int line_no)
          && filename_cmp (fullname,
                           symtab_to_fullname (loc->symtab)) == 0);
 }
+
+/* See tui-source.h.  */
+
+bool
+tui_source_window::line_is_displayed (int line) const
+{
+  bool is_displayed = false;
+  int threshold = SCROLL_THRESHOLD;
+  int i = 0;
+  while (i < content.size () - threshold && !is_displayed)
+    {
+      is_displayed
+       = (content[i].line_or_addr.loa == LOA_LINE
+          && content[i].line_or_addr.u.line_no == line);
+      i++;
+    }
+
+  return is_displayed;
+}
+
+void
+tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal,
+                                int line_no, CORE_ADDR addr)
+{
+  int start_line = (line_no - (viewport_height / 2)) + 1;
+  if (start_line <= 0)
+    start_line = 1;
+
+  bool source_already_displayed = (sal.symtab != 0
+                                  && showing_source_p (fullname));
+
+  struct tui_line_or_address l;
+
+  l.loa = LOA_LINE;
+  l.u.line_no = start_line;
+  if (!(source_already_displayed
+       && line_is_displayed (line_no)))
+    tui_update_source_window (this, get_frame_arch (fi),
+                             sal.symtab, l, TRUE);
+  else
+    {
+      l.u.line_no = line_no;
+      set_is_exec_point_at (l);
+    }
+}
This page took 0.025574 seconds and 4 git commands to generate.