/* TUI display source/assembly window.
- Copyright (C) 1998-2020 Free Software Foundation, Inc.
+ Copyright (C) 1998-2023 Free Software Foundation, Inc.
Contributed by Hewlett-Packard Company.
#include "source.h"
#include "objfiles.h"
#include "filenames.h"
+#include "safe-ctype.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-winsource.h"
#include "tui/tui-source.h"
#include "tui/tui-disasm.h"
+#include "tui/tui-location.h"
#include "gdb_curses.h"
/* Function to display the "main" routine. */
tui_update_source_windows_with_addr (gdbarch, addr);
s = find_pc_line_symtab (addr);
- tui_update_locator_fullname (s);
+ tui_location.set_location (s);
}
}
}
{
/* Nothing. */
}
- else if (c < 040 && c != '\t')
+ else if (c == '\t')
+ process_tab ();
+ else if (ISCNTRL (c))
{
result.push_back ('^');
result.push_back (c + 0100);
result.push_back ('?');
++column;
}
- else if (c == '\t')
- process_tab ();
else
result.push_back (c);
}
if (sal.symtab != nullptr)
{
find_line_pc (sal.symtab, sal.line, &sal.pc);
- gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+ gdbarch = sal.symtab->compunit ()->objfile ()->arch ();
}
for (struct tui_source_window_base *win_info : tui_source_windows ())
/* See tui-winsource.h. */
void
-tui_source_window_base::refresh_pad ()
+tui_source_window_base::refresh_window ()
{
+ /* tui_win_info::refresh_window would draw the empty background window to
+ the screen, potentially creating a flicker. */
+ wnoutrefresh (handle.get ());
+
int pad_width = std::max (m_max_length, width);
int left_margin = 1 + TUI_EXECINFO_SIZE + extra_margin ();
int view_width = width - left_margin - 1;
scrolled beyond where we clip. */
m_horizontal_offset = pad_x;
prefresh (m_pad.get (), 0, pad_x, y + 1, x + left_margin,
- y + 1 + m_content.size (), x + left_margin + view_width - 1);
+ y + m_content.size (), x + left_margin + view_width - 1);
}
void
check_and_display_highlight_if_needed ();
int pad_width = std::max (m_max_length, width);
- if (m_pad == nullptr || pad_width > getmaxx (m_pad.get ()))
+ if (m_pad == nullptr || pad_width > getmaxx (m_pad.get ())
+ || m_content.size () > getmaxy (m_pad.get ()))
m_pad.reset (newpad (m_content.size (), pad_width));
werase (m_pad.get ());
for (int lineno = 0; lineno < m_content.size (); lineno++)
show_source_line (lineno);
- refresh_pad ();
-
refresh_window ();
}
m_start_line_or_addr.loa = LOA_ADDRESS;
m_start_line_or_addr.u.addr = 0;
- gdb::observers::source_styling_changed.attach
+ gdb::observers::styling_changed.attach
(std::bind (&tui_source_window::style_changed, this),
- m_observable);
+ m_observable, "tui-winsource");
}
tui_source_window_base::~tui_source_window_base ()
{
- gdb::observers::source_styling_changed.detach (m_observable);
+ gdb::observers::styling_changed.detach (m_observable);
}
/* See tui-data.h. */
{
struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
- struct frame_info *frame = deprecated_safe_get_selected_frame ();
+ frame_info_ptr frame = deprecated_safe_get_selected_frame ();
struct gdbarch *gdbarch = get_frame_arch (frame);
struct symtab *s = find_pc_line_symtab (get_frame_pc (frame));
sal = get_current_source_symtab_and_line ();
if (sal.symtab == NULL)
{
- struct frame_info *fi = deprecated_safe_get_selected_frame ();
+ frame_info_ptr fi = deprecated_safe_get_selected_frame ();
if (fi != nullptr)
sal = find_pc_line (get_frame_pc (fi), 0);
}
if (offset < 0)
offset = 0;
m_horizontal_offset = offset;
- refresh_pad ();
+ refresh_window ();
}
}
if (content_loa.loa == l.loa
&& ((l.loa == LOA_LINE && content_loa.u.line_no == l.u.line_no)
- || (l.loa == LOA_ADDRESS && content_loa.u.addr == l.u.addr)))
- new_state = true;
+ || (l.loa == LOA_ADDRESS && content_loa.u.addr == l.u.addr)))
+ new_state = true;
else
new_state = false;
if (new_state != m_content[i].is_exec_point)
- {
- changed = true;
- m_content[i].is_exec_point = new_state;
- }
+ {
+ changed = true;
+ m_content[i].is_exec_point = new_state;
+ }
i++;
}
if (changed)
line = &m_content[i];
if (current_only && !line->is_exec_point)
- continue;
+ continue;
/* Scan each breakpoint to see if the current line has something to
- do with it. Identify enable/disabled breakpoints as well as
- those that we already hit. */
+ do with it. Identify enable/disabled breakpoints as well as
+ those that we already hit. */
tui_bp_flags mode = 0;
- iterate_over_breakpoints ([&] (breakpoint *bp) -> bool
- {
- struct bp_location *loc;
-
+ for (breakpoint *bp : all_breakpoints ())
+ {
if (bp == being_deleted)
- return false;
+ continue;
- for (loc = bp->loc; loc != NULL; loc = loc->next)
+ for (bp_location *loc : bp->locations ())
{
if (location_matches_p (loc, i))
{
mode |= TUI_BP_HARDWARE;
}
}
- return false;
- });
+ }
+
if (line->break_mode != mode)
- {
- line->break_mode = mode;
- need_refresh = true;
- }
+ {
+ line->break_mode = mode;
+ need_refresh = true;
+ }
}
return need_refresh;
}