diff options
Diffstat (limited to 'gdb/tui')
-rw-r--r-- | gdb/tui/tui-command.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-command.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-data.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-data.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.c | 16 | ||||
-rw-r--r-- | gdb/tui/tui-disasm.h | 4 | ||||
-rw-r--r-- | gdb/tui/tui-file.c | 8 | ||||
-rw-r--r-- | gdb/tui/tui-file.h | 13 | ||||
-rw-r--r-- | gdb/tui/tui-hooks.c | 11 | ||||
-rw-r--r-- | gdb/tui/tui-hooks.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-interp.c | 6 | ||||
-rw-r--r-- | gdb/tui/tui-io.c | 43 | ||||
-rw-r--r-- | gdb/tui/tui-io.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-layout.c | 10 | ||||
-rw-r--r-- | gdb/tui/tui-layout.h | 7 | ||||
-rw-r--r-- | gdb/tui/tui-location.c | 2 | ||||
-rw-r--r-- | gdb/tui/tui-location.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-regs.c | 6 | ||||
-rw-r--r-- | gdb/tui/tui-regs.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-source.c | 6 | ||||
-rw-r--r-- | gdb/tui/tui-source.h | 4 | ||||
-rw-r--r-- | gdb/tui/tui-status.c | 13 | ||||
-rw-r--r-- | gdb/tui/tui-status.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-win.c | 8 | ||||
-rw-r--r-- | gdb/tui/tui-win.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-wingeneral.c | 11 | ||||
-rw-r--r-- | gdb/tui/tui-wingeneral.h | 2 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.c | 37 | ||||
-rw-r--r-- | gdb/tui/tui-winsource.h | 4 | ||||
-rw-r--r-- | gdb/tui/tui.c | 30 | ||||
-rw-r--r-- | gdb/tui/tui.h | 2 |
31 files changed, 149 insertions, 114 deletions
diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c index 677721d..9bd33e2 100644 --- a/gdb/tui/tui-command.c +++ b/gdb/tui/tui-command.c @@ -1,6 +1,6 @@ /* Specific command window processing. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-command.h b/gdb/tui/tui-command.h index 61f8cf3..2f82291 100644 --- a/gdb/tui/tui-command.h +++ b/gdb/tui/tui-command.h @@ -1,6 +1,6 @@ /* Specific command window processing. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 962dbc5..7d1d055 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -1,6 +1,6 @@ /* TUI data manipulation routines. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 6f2087b..dd33a59 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -1,6 +1,6 @@ /* TUI data manipulation routines. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index cd82853..627f71c 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -1,6 +1,6 @@ /* Disassembly display. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -98,7 +98,7 @@ tui_disassemble (struct gdbarch *gdbarch, CORE_ADDR pc, int count, size_t *addr_size = nullptr) { - bool term_out = source_styling && gdb_stdout->can_emit_style_escape (); + bool term_out = disassembler_styling && gdb_stdout->can_emit_style_escape (); string_file gdb_dis_out (term_out); /* Must start with an empty list. */ @@ -485,12 +485,10 @@ tui_disasm_window::addr_is_displayed (CORE_ADDR addr) const } void -tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) +tui_disasm_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) { CORE_ADDR low; - struct gdbarch *frame_arch = get_frame_arch (fi); - if (find_pc_partial_function (sal.pc, NULL, &low, NULL) == 0) { /* There is no symbol available for current PC. There is no @@ -498,7 +496,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) low = sal.pc; } else - low = tui_get_low_disassembly_address (frame_arch, low, sal.pc); + low = tui_get_low_disassembly_address (gdbarch, low, sal.pc); struct tui_line_or_address a; @@ -507,7 +505,7 @@ tui_disasm_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) if (!addr_is_displayed (sal.pc)) { sal.pc = low; - update_source_window (frame_arch, sal); + update_source_window (gdbarch, sal); } else { @@ -548,9 +546,7 @@ run_tests () } /* namespace selftests */ #endif /* GDB_SELF_TEST */ -void _initialize_tui_disasm (); -void -_initialize_tui_disasm () +INIT_GDB_FILE (tui_disasm) { #if GDB_SELF_TEST selftests::register_test ("tui-disasm", selftests::tui::disasm::run_tests); diff --git a/gdb/tui/tui-disasm.h b/gdb/tui/tui-disasm.h index a49719a..173cc8b 100644 --- a/gdb/tui/tui-disasm.h +++ b/gdb/tui/tui-disasm.h @@ -1,6 +1,6 @@ /* Disassembly display. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -42,7 +42,7 @@ struct tui_disasm_window : public tui_source_window_base bool location_matches_p (struct bp_location *loc, int line_no) override; - void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override; + void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override; void erase_source_content () override { diff --git a/gdb/tui/tui-file.c b/gdb/tui/tui-file.c index 17ac138..df6f503 100644 --- a/gdb/tui/tui-file.c +++ b/gdb/tui/tui-file.c @@ -1,5 +1,5 @@ /* UI_FILE - a generic STDIO like output stream. - Copyright (C) 1999-2024 Free Software Foundation, Inc. + Copyright (C) 1999-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -21,7 +21,7 @@ #include "tui/tui-command.h" void -tui_file::puts (const char *linebuffer) +tui_file::do_puts (const char *linebuffer) { tui_puts (linebuffer); if (!m_buffered) @@ -29,7 +29,7 @@ tui_file::puts (const char *linebuffer) } void -tui_file::write (const char *buf, long length_buf) +tui_file::do_write (const char *buf, long length_buf) { tui_write (buf, length_buf); if (!m_buffered) @@ -41,5 +41,5 @@ tui_file::flush () { if (m_buffered) tui_cmd_win ()->refresh_window (); - stdio_file::flush (); + escape_buffering_file::flush (); } diff --git a/gdb/tui/tui-file.h b/gdb/tui/tui-file.h index 6178a90..b6dc058 100644 --- a/gdb/tui/tui-file.h +++ b/gdb/tui/tui-file.h @@ -1,5 +1,5 @@ /* TUI_FILE - a STDIO-like output stream for the TUI. - Copyright (C) 1999-2024 Free Software Foundation, Inc. + Copyright (C) 1999-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -23,18 +23,21 @@ /* A STDIO-like output stream for the TUI. */ -class tui_file : public stdio_file +class tui_file : public escape_buffering_file { public: tui_file (FILE *stream, bool buffered) - : stdio_file (stream), + : escape_buffering_file (stream), m_buffered (buffered) {} - void write (const char *buf, long length_buf) override; - void puts (const char *) override; void flush () override; +protected: + + void do_write (const char *buf, long length_buf) override; + void do_puts (const char *) override; + private: /* True if this stream is buffered. */ diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 25358d0..024fedd 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -1,6 +1,6 @@ /* GDB hooks for TUI. - Copyright (C) 2001-2024 Free Software Foundation, Inc. + Copyright (C) 2001-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -35,6 +35,7 @@ #include "tui/tui-regs.h" #include "tui/tui-status.h" #include "tui/tui-winsource.h" +#include "tui/tui-wingeneral.h" static void tui_new_objfile_hook (struct objfile* objfile) @@ -106,6 +107,8 @@ tui_refresh_frame_and_register_information () target_terminal::scoped_restore_terminal_state term_state; target_terminal::ours_for_output (); + tui_batch_rendering defer; + if (from_stack) { frame_info_ptr fi; @@ -150,6 +153,8 @@ tui_dummy_print_frame_info_listing_hook (struct symtab *s, static void tui_inferior_exit (struct inferior *inf) { + tui_batch_rendering defer; + /* Leave the SingleKey mode to make sure the gdb prompt is visible. */ tui_set_key_mode (TUI_COMMAND_MODE); tui_show_frame_info (0); @@ -257,9 +262,7 @@ tui_remove_hooks (void) tui_attach_detach_observers (false); } -void _initialize_tui_hooks (); -void -_initialize_tui_hooks () +INIT_GDB_FILE (tui_hooks) { /* Install the permanent hooks. */ gdb::observers::new_objfile.attach (tui_new_objfile_hook, "tui-hooks"); diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h index 21ba169..6fee785 100644 --- a/gdb/tui/tui-hooks.h +++ b/gdb/tui/tui-hooks.h @@ -1,6 +1,6 @@ /* External/Public TUI hools header file, for GDB the GNU debugger. - Copyright (C) 2004-2024 Free Software Foundation, Inc. + Copyright (C) 2004-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c index 25761be..3d0e152 100644 --- a/gdb/tui/tui-interp.c +++ b/gdb/tui/tui-interp.c @@ -1,6 +1,6 @@ /* TUI Interpreter definitions for GDB, the GNU debugger. - Copyright (C) 2003-2024 Free Software Foundation, Inc. + Copyright (C) 2003-2025 Free Software Foundation, Inc. This file is part of GDB. @@ -161,9 +161,7 @@ tui_interp_factory (const char *name) return new tui_interp (name); } -void _initialize_tui_interp (); -void -_initialize_tui_interp () +INIT_GDB_FILE (tui_interp) { interp_factory_register (INTERP_TUI, tui_interp_factory); diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index e64f0dd..c97e8fd 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -1,6 +1,6 @@ /* TUI support I/O functions. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -42,12 +42,12 @@ #include "gdbsupport/filestuff.h" #include "completer.h" #include "gdb_curses.h" -#include <map> +#include "gdbsupport/unordered_map.h" #include "pager.h" #include "gdbsupport/gdb-checked-static-cast.h" /* This redefines CTRL if it is not already defined, so it must come - after terminal state releated include files like <term.h> and + after terminal state related include files like <term.h> and "gdb_curses.h". */ #include "readline/readline.h" @@ -178,9 +178,19 @@ tui_putc (char c) update_cmdwin_start_line (); } +/* Hasher for colors. */ + +struct color_hash +{ + size_t operator() (const ui_file_style::color &color) const noexcept + { + return color.hash (); + } +}; + /* This maps colors to their corresponding color index. */ -static std::map<ui_file_style::color, int> color_map; +static gdb::unordered_map<ui_file_style::color, int, color_hash> color_map; /* This holds a pair of colors and is used to track the mapping between a color pair index and the actual colors. */ @@ -190,16 +200,27 @@ struct color_pair int fg; int bg; - bool operator< (const color_pair &o) const + bool operator== (const color_pair &other) const noexcept + { + return fg == other.fg && bg == other.bg; + } +}; + +struct color_pair_hash +{ + using is_avalanching = void; + + size_t operator() (const color_pair &val) const noexcept { - return fg < o.fg || (fg == o.fg && bg < o.bg); + static_assert (std::has_unique_object_representations_v<color_pair>); + return ankerl::unordered_dense::detail::wyhash::hash (&val, sizeof (val)); } }; /* This maps pairs of colors to their corresponding color pair index. */ -static std::map<color_pair, int> color_pair_map; +static gdb::unordered_map<color_pair, int, color_pair_hash> color_pair_map; /* This is indexed by ANSI color offset from the base color, and holds the corresponding curses color constant. */ @@ -298,6 +319,8 @@ tui_apply_style (WINDOW *w, ui_file_style style) wattron (w, A_NORMAL); wattroff (w, A_BOLD); wattroff (w, A_DIM); + wattroff (w, A_ITALIC); + wattroff (w, A_UNDERLINE); wattroff (w, A_REVERSE); if (last_color_pair != -1) wattroff (w, COLOR_PAIR (last_color_pair)); @@ -345,6 +368,12 @@ tui_apply_style (WINDOW *w, ui_file_style style) gdb_assert_not_reached ("invalid intensity"); } + if (style.is_italic ()) + wattron (w, A_ITALIC); + + if (style.is_underline ()) + wattron (w, A_UNDERLINE); + if (style.is_reverse ()) wattron (w, A_REVERSE); diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h index 66b3b90..aa931f8 100644 --- a/gdb/tui/tui-io.h +++ b/gdb/tui/tui-io.h @@ -1,6 +1,6 @@ /* TUI support I/O functions. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 79b7289..558055d 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -1,6 +1,6 @@ /* TUI layout window management. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -24,7 +24,7 @@ #include "frame.h" #include "cli/cli-decode.h" #include "cli/cli-utils.h" -#include <unordered_set> +#include "gdbsupport/unordered_set.h" #include "tui/tui.h" #include "tui/tui-command.h" @@ -1221,7 +1221,7 @@ tui_new_layout_command (const char *spec, int from_tty) std::vector<std::unique_ptr<tui_layout_split>> splits; splits.emplace_back (new tui_layout_split (is_vertical)); - std::unordered_set<std::string> seen_windows; + gdb::unordered_set<std::string> seen_windows; while (true) { spec = skip_spaces (spec); @@ -1294,9 +1294,7 @@ tui_new_layout_command (const char *spec, int from_tty) /* Function to initialize gdb commands, for tui window layout manipulation. */ -void _initialize_tui_layout (); -void -_initialize_tui_layout () +INIT_GDB_FILE (tui_layout) { struct cmd_list_element *layout_cmd = add_basic_prefix_cmd ("layout", class_tui, _("\ diff --git a/gdb/tui/tui-layout.h b/gdb/tui/tui-layout.h index 22d7c72..6046bb6 100644 --- a/gdb/tui/tui-layout.h +++ b/gdb/tui/tui-layout.h @@ -1,6 +1,6 @@ /* TUI layout window management. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -27,8 +27,7 @@ #include "tui/tui.h" #include "tui/tui-data.h" #include "gdbsupport/iterator-range.h" - -#include <unordered_map> +#include "gdbsupport/unordered_map.h" /* Values that can be returned when handling a request to adjust a window's size. */ @@ -368,7 +367,7 @@ typedef std::function<tui_win_info * (const char *name)> window_factory; /* The type for a data structure that maps a window name to that window's factory function. */ -typedef std::unordered_map<std::string, window_factory> window_types_map; +typedef gdb::unordered_map<std::string, window_factory> window_types_map; /* Register a new TUI window type. NAME is the name of the window type. FACTORY is a function that can be called to instantiate the diff --git a/gdb/tui/tui-location.c b/gdb/tui/tui-location.c index 8e63d4f..24a14fb 100644 --- a/gdb/tui/tui-location.c +++ b/gdb/tui/tui-location.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2021-2024 Free Software Foundation, Inc. +/* Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/tui/tui-location.h b/gdb/tui/tui-location.h index 5eda4bd..eecefbc 100644 --- a/gdb/tui/tui-location.h +++ b/gdb/tui/tui-location.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021-2024 Free Software Foundation, Inc. +/* Copyright (C) 2021-2025 Free Software Foundation, Inc. This file is part of GDB. diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 5158c06..ac2757a 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -1,6 +1,6 @@ /* TUI display registers in window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -566,9 +566,7 @@ tui_reggroup_completer (struct cmd_list_element *ignore, complete_on_enum (tracker, extra, text, word); } -void _initialize_tui_regs (); -void -_initialize_tui_regs () +INIT_GDB_FILE (tui_regs) { struct cmd_list_element **tuicmd, *cmd; diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h index 48f6aa0..5f7afa6 100644 --- a/gdb/tui/tui-regs.h +++ b/gdb/tui/tui-regs.h @@ -1,6 +1,6 @@ /* TUI display registers in window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 9a0a041..e2dff84 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -1,6 +1,6 @@ /* TUI display source window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -207,7 +207,7 @@ tui_source_window::line_is_displayed (int line) const } void -tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) +tui_source_window::maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) { int start_line = (sal.line - ((height - box_size ()) / 2)) + 1; if (start_line <= 0) @@ -219,7 +219,7 @@ tui_source_window::maybe_update (const frame_info_ptr &fi, symtab_and_line sal) if (!(source_already_displayed && line_is_displayed (sal.line))) { sal.line = start_line; - update_source_window (get_frame_arch (fi), sal); + update_source_window (gdbarch, sal); } else { diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h index 9cad4ff..626ac40 100644 --- a/gdb/tui/tui-source.h +++ b/gdb/tui/tui-source.h @@ -1,6 +1,6 @@ /* TUI display source window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -46,7 +46,7 @@ struct tui_source_window : public tui_source_window_base bool showing_source_p (const char *filename) const; - void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) override; + void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) override; void erase_source_content () override { diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c index 5239415..c2d3873 100644 --- a/gdb/tui/tui-status.c +++ b/gdb/tui/tui-status.c @@ -1,6 +1,6 @@ /* TUI status line. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -253,8 +253,8 @@ tui_status_window::rerender () waddstr (handle.get (), string.c_str ()); wclrtoeol (handle.get ()); (void) wstandend (handle.get ()); + refresh_window (); - wmove (handle.get (), 0, 0); } /* Function to print the frame information for the TUI. The windows @@ -278,8 +278,9 @@ tui_show_frame_info (const frame_info_ptr &fi) else func_name = _("<unavailable>"); + struct gdbarch *gdbarch = get_frame_arch (fi); status_changed_p - = tui_location.set_location (get_frame_arch (fi), sal, func_name); + = tui_location.set_location (gdbarch, sal, func_name); /* If the status information has not changed, then frame information has not changed. If frame information has not changed, then the windows' @@ -289,7 +290,7 @@ tui_show_frame_info (const frame_info_ptr &fi) for (struct tui_source_window_base *win_info : tui_source_windows ()) { - win_info->maybe_update (fi, sal); + win_info->maybe_update (gdbarch, sal); win_info->update_exec_info (); } } @@ -324,9 +325,7 @@ tui_update_command (const char *arg, int from_tty) /* Function to initialize gdb commands, for tui window stack manipulation. */ -void _initialize_tui_stack (); -void -_initialize_tui_stack () +INIT_GDB_FILE (tui_stack) { add_com ("update", class_tui, tui_update_command, _("\ diff --git a/gdb/tui/tui-status.h b/gdb/tui/tui-status.h index 8b507fd..2a84732 100644 --- a/gdb/tui/tui-status.h +++ b/gdb/tui/tui-status.h @@ -1,6 +1,6 @@ /* TUI status line. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 33b24d8..d4fbbf1 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1,6 +1,6 @@ /* TUI window generic functions. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -969,6 +969,8 @@ tui_set_win_size (const char *arg, bool set_width_p) new_size = curr_size + input_no; } + tui_batch_rendering defer; + /* Now change the window's height, and adjust all other windows around it. */ if (set_width_p) @@ -1089,9 +1091,7 @@ bool tui_left_margin_verbose = false; /* Function to initialize gdb commands, for tui window manipulation. */ -void _initialize_tui_win (); -void -_initialize_tui_win () +INIT_GDB_FILE (tui_win) { static struct cmd_list_element *tui_setlist; static struct cmd_list_element *tui_showlist; diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index 1521993..64153cf 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -1,6 +1,6 @@ /* TUI window generic functions. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index 369d152..de4ef52 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -1,6 +1,6 @@ /* General window behavior. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -56,7 +56,12 @@ void tui_win_info::refresh_window () { if (handle != NULL) - wnoutrefresh (handle.get ()); + { + if (suppress_output) + wnoutrefresh (handle.get ()); + else + wrefresh (handle.get ()); + } } /* Draw a border around the window. */ @@ -75,7 +80,7 @@ box_win (struct tui_win_info *win_info, /* tui_apply_style resets the style entirely, so be sure to call it before applying ATTRS. */ - if (cli_styling) + if (term_cli_styling ()) tui_apply_style (win, (highlight_flag ? tui_active_border_style.style () : tui_border_style.style ())); diff --git a/gdb/tui/tui-wingeneral.h b/gdb/tui/tui-wingeneral.h index b037e79..0e0e5fe 100644 --- a/gdb/tui/tui-wingeneral.h +++ b/gdb/tui/tui-wingeneral.h @@ -1,6 +1,6 @@ /* General window behavior. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 83d9fc0..a545c48 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -1,6 +1,6 @@ /* TUI display source/assembly window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -37,6 +37,7 @@ #include "tui/tui-source.h" #include "tui/tui-disasm.h" #include "tui/tui-location.h" +#include "tui/tui-wingeneral.h" #include "gdb_curses.h" /* Function to display the "main" routine. */ @@ -52,10 +53,10 @@ tui_display_main () tui_get_begin_asm_address (&gdbarch, &addr); if (addr != (CORE_ADDR) 0) { - struct symtab *s; + tui_batch_rendering defer; tui_update_source_windows_with_addr (gdbarch, addr); - s = find_pc_line_symtab (addr); + struct symtab *s = find_pc_line_symtab (addr); tui_location.set_location (s); } } @@ -184,7 +185,7 @@ tui_source_window_base::update_source_window_with_addr (struct gdbarch *gdbarch, if (addr != 0) sal = find_pc_line (addr, 0); - update_source_window (gdbarch, sal); + maybe_update (gdbarch, sal); } /* Function to ensure that the source and/or disassembly windows @@ -455,25 +456,15 @@ tui_source_window_base::rerender () } else if (deprecated_safe_get_selected_frame () != NULL) { - symtab_and_line cursal - = get_current_source_symtab_and_line (current_program_space); 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)); - if (this != tui_src_win ()) - find_line_pc (s, cursal.line, &cursal.pc); - - /* This centering code is copied from tui_source_window::maybe_update. - It would be nice to do centering more often, and do it in just one - location. But since this is a regression fix, handle this - conservatively for now. */ - int start_line = (cursal.line - ((height - box_size ()) / 2)) + 1; - if (start_line <= 0) - start_line = 1; - cursal.line = start_line; - - update_source_window (gdbarch, cursal); + symtab_and_line sal = find_frame_sal (frame); + + /* find_frame_sal does not always set SAL.PC, but we want to ensure + that it is available in the SAL before updating the window. */ + get_frame_pc_if_available (frame, &sal.pc); + + maybe_update (get_frame_arch (frame), sal); + update_exec_info (false); } else { @@ -607,6 +598,8 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l) void tui_update_all_breakpoint_info (struct breakpoint *being_deleted) { + tui_batch_rendering defer; + for (tui_source_window_base *win : tui_source_windows ()) { if (win->update_breakpoint_info (being_deleted, false)) diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h index 2883ec9..b531f0e 100644 --- a/gdb/tui/tui-winsource.h +++ b/gdb/tui/tui-winsource.h @@ -1,6 +1,6 @@ /* TUI display source/assembly window. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -160,7 +160,7 @@ public: /* Update the window to display the given location. Does nothing if the location is already displayed. */ - virtual void maybe_update (const frame_info_ptr &fi, symtab_and_line sal) = 0; + virtual void maybe_update (struct gdbarch *gdbarch, symtab_and_line sal) = 0; void update_source_window_as_is (struct gdbarch *gdbarch, const struct symtab_and_line &sal); diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 59aa1bc..5883d6c 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -1,6 +1,6 @@ /* General functions for the WDB TUI. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. @@ -61,13 +61,18 @@ show_tui_debug (struct ui_file *file, int from_tty, } /* This redefines CTRL if it is not already defined, so it must come - after terminal state releated include files like <term.h> and + after terminal state related include files like <term.h> and "gdb_curses.h". */ #include "readline/readline.h" /* Tells whether the TUI is active or not. */ bool tui_active = false; -static bool tui_finish_init = true; + +/* Tells whether the TUI should do deferred curses initialization. + If TRIBOOL_TRUE, then yes. If TRIBOOL_FALSE. then no (because + initialization is already done). If TRIBOOL_UNKNOWN, then no (because + initialization failed). */ +static tribool tui_finish_init = TRIBOOL_TRUE; enum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE; @@ -387,10 +392,18 @@ tui_enable (void) if (tui_active) return; + tui_batch_rendering defer; + /* To avoid to initialize curses when gdb starts, there is a deferred curses initialization. This initialization is made only once and the first time the curses mode is entered. */ - if (tui_finish_init) + if (tui_finish_init == TRIBOOL_UNKNOWN) + { + /* Initialization failed before, just throw a generic error, don't try + again. */ + error (_("Cannot enable the TUI")); + } + else if (tui_finish_init == TRIBOOL_TRUE) { WINDOW *w; SCREEN *s; @@ -410,6 +423,9 @@ tui_enable (void) if (!gdb_stderr->isatty ()) error (_("Cannot enable the TUI when output is not a terminal")); + /* Don't try initialization again. */ + tui_finish_init = TRIBOOL_UNKNOWN; + s = newterm (NULL, stdout, stdin); #ifdef __MINGW32__ /* The MinGW port of ncurses requires $TERM to be unset in order @@ -468,7 +484,7 @@ tui_enable (void) tui_set_win_focus_to (tui_src_win ()); keypad (tui_cmd_win ()->handle.get (), TRUE); wrefresh (tui_cmd_win ()->handle.get ()); - tui_finish_init = false; + tui_finish_init = TRIBOOL_FALSE; } else { @@ -602,9 +618,7 @@ tui_get_command_dimension (unsigned int *width, return true; } -void _initialize_tui (); -void -_initialize_tui () +INIT_GDB_FILE (tui) { struct cmd_list_element **tuicmd; diff --git a/gdb/tui/tui.h b/gdb/tui/tui.h index 319bd2e..3a9d955 100644 --- a/gdb/tui/tui.h +++ b/gdb/tui/tui.h @@ -1,6 +1,6 @@ /* External/Public TUI Header File. - Copyright (C) 1998-2024 Free Software Foundation, Inc. + Copyright (C) 1998-2025 Free Software Foundation, Inc. Contributed by Hewlett-Packard Company. |