31#include "gdbsupport/gdb-safe-ctype.h"
50 if (adapter.begin () != adapter.end ())
56 if (addr != (CORE_ADDR) 0)
72 const char *lineptr = *ptr;
87 result.append (lineptr, lineptr + skip_bytes);
88 lineptr += skip_bytes;
97 auto process_tab = [&] ()
102 for (
int j = column % max_tab_len;
105 result.push_back (
' ');
108 if (c ==
'\n' || c ==
'\r' || c ==
'\0')
114 else if (ISCNTRL (c))
116 result.push_back (
'^');
117 result.push_back (c + 0100);
122 result.push_back (
'^');
123 result.push_back (
'?');
127 result.push_back (c);
129 while (c !=
'\0' && c !=
'\n' && c !=
'\r');
131 if (c ==
'\r' && *lineptr ==
'\n')
135 if (length !=
nullptr)
191 win_info->update_source_window (
gdbarch, sal);
200 if (sal.
symtab !=
nullptr)
207 win_info->update_source_window (
gdbarch, sal);
214 int half_width = (
width - 2) / 2;
222 if (strlen (str) >= half_width)
225 x_pos = half_width - strlen (str);
240 gdb_assert (
m_pad.get () !=
nullptr);
241 WINDOW *w =
m_pad.get ();
245 const char *next = strpbrk (
string,
"\033");
248 size_t n_chars = next ==
nullptr ? strlen (
string) : next - string;
269 std::string copy (
string, n_chars);
278 gdb_assert (*next ==
'\033');
283 std::string copy (next, n_read);
288 gdb_assert_not_reached (
"unhandled escape");
307 wmove (
m_pad.get (), lineno, 0);
323 wnoutrefresh (
handle.get ());
325 int pad_width = getmaxx (
m_pad.get ());
333 tui_debug_printf (
"content_width = %d, pad_x = %d, m_horizontal_offset = %d",
340 gdb_assert (pad_x >= 0);
347 gdb_assert (pad_width > 0 ||
m_pad.get () ==
nullptr);
348 gdb_assert (pad_x +
view_width <= pad_width ||
m_pad.get () ==
nullptr);
365 int required_pad_height =
m_content.size ();
370 || required_pad_height > getmaxy (
m_pad.get ()))
373 int pad_width =
m_pad ==
nullptr ? 0 : getmaxx (
m_pad.get ());
382 || required_pad_height > getmaxy (
m_pad.get ()))
384 pad_width = required_pad_width;
389 m_pad.reset (newpad (required_pad_height, pad_width));
391 if (
m_pad ==
nullptr)
393 int reduced_width = std::max (pad_width / 2,
width);
394 if (reduced_width == pad_width)
395 error (_(
"failed to setup source window"));
396 pad_width = reduced_width;
399 while (
m_pad ==
nullptr);
404 required_pad_width, getmaxx (
m_pad.get ()));
407 gdb_assert (
m_pad !=
nullptr);
408 werase (
m_pad.get ());
409 for (
int lineno = 0; lineno <
m_content.size (); lineno++)
485 if (sal.symtab == NULL)
493 if (sal.pspace ==
nullptr)
517 int pad_width = getmaxx (
m_pad.get ());
563 bool changed =
false;
573 if (content_loa.
loa == l.
loa
579 if (new_state !=
m_content[i].is_exec_point)
597 if (win->update_breakpoint_info (being_deleted,
false))
598 win->update_exec_info ();
611 (
struct breakpoint *being_deleted,
bool current_only)
614 bool need_refresh =
false;
627 tui_bp_flags mode = 0;
630 if (&
bp == being_deleted)
643 if (
bp.first_loc ().cond)
666 for (
int i = 0; i <
m_content.size (); i++)
693 mvwaddstr (
handle.get (), i + 1, 1, element);
breakpoint_range all_breakpoints()
frame_info_ptr deprecated_safe_get_selected_frame(void)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
observable styling_changed
struct program_space * current_program_space
struct symtab_and_line get_current_source_symtab_and_line(void)
struct objfile * objfile() const
struct gdbarch * arch() const
struct compunit_symtab * compunit() const
enum tui_line_or_address_kind loa
union tui_line_or_address::@192 u
bool set_location(struct gdbarch *gdbarch, const struct symtab_and_line &sal, const char *procname)
~tui_source_window_base()
virtual bool set_contents(struct gdbarch *gdbarch, const struct symtab_and_line &sal)=0
void do_erase_source_content(const char *string)
void show_source_line(int lineno)
void puts_to_pad_with_skip(const char *string, int skip)
void do_scroll_horizontal(int num_to_scroll) override
struct tui_line_or_address m_start_line_or_addr
int m_pad_requested_width
void refresh_window() override
void update_source_window(struct gdbarch *gdbarch, const struct symtab_and_line &sal)
gdb::observers::token m_observable
struct gdbarch * m_gdbarch
virtual void erase_source_content()=0
void update_tab_width() override
std::vector< tui_source_element > m_content
virtual bool location_matches_p(struct bp_location *loc, int line_no)=0
std::unique_ptr< WINDOW, curses_deleter > m_pad
bool validate_scroll_offsets()
void show_source_content()
void set_is_exec_point_at(struct tui_line_or_address l)
bool update_breakpoint_info(struct breakpoint *being_deleted, bool current_only)
void update_source_window_as_is(struct gdbarch *gdbarch, const struct symtab_and_line &sal)
virtual void show_line_number(int offset) const
void update_exec_info(bool refresh_p=true)
void check_and_display_highlight_if_needed()
virtual bool can_box() const
virtual const char * name() const =0
std::unique_ptr< WINDOW, curses_deleter > handle
bool find_line_pc(struct symtab *symtab, int line, CORE_ADDR *pc)
struct symtab * find_pc_line_symtab(CORE_ADDR pc)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
unsigned int tui_tab_width
void tui_get_begin_asm_address(struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
void tui_set_reverse_mode(WINDOW *w, bool reverse)
void tui_puts(const char *string, WINDOW *w)
tui_location_tracker tui_location
bool tui_left_margin_verbose
void tui_update_all_breakpoint_info(struct breakpoint *being_deleted)
void tui_update_source_windows_with_line(struct symtab_and_line sal)
void tui_update_source_windows_with_addr(struct gdbarch *gdbarch, CORE_ADDR addr)
std::string tui_copy_source_line(const char **ptr, int *length)
#define TUI_EXECINFO_SIZE
#define tui_debug_printf(fmt,...)
#define TUI_SCOPED_DEBUG_START_END(fmt,...)
bool skip_ansi_escape(const char *buf, int *n_read)