aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-disasm.c34
-rw-r--r--gdb/tui/tui-io.c4
-rw-r--r--gdb/tui/tui-layout.c7
-rw-r--r--gdb/tui/tui-status.c8
-rw-r--r--gdb/tui/tui-win.c3
-rw-r--r--gdb/tui/tui-winsource.c7
-rw-r--r--gdb/tui/tui.c13
7 files changed, 50 insertions, 26 deletions
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 627f71c..07453b4 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -100,6 +100,9 @@ tui_disassemble (struct gdbarch *gdbarch,
{
bool term_out = disassembler_styling && gdb_stdout->can_emit_style_escape ();
string_file gdb_dis_out (term_out);
+ struct ui_file *stream = (addr_size == nullptr
+ ? (decltype (stream))&null_stream
+ : (decltype (stream))&gdb_dis_out);
/* Must start with an empty list. */
asm_lines.clear ();
@@ -108,11 +111,13 @@ tui_disassemble (struct gdbarch *gdbarch,
for (int i = 0; i < count; ++i)
{
tui_asm_line tal;
- CORE_ADDR orig_pc = pc;
+
+ /* Save the instruction address. */
+ tal.addr = pc;
try
{
- pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL);
+ pc += gdb_print_insn (gdbarch, pc, stream, NULL);
}
catch (const gdb_exception_error &except)
{
@@ -124,25 +129,24 @@ tui_disassemble (struct gdbarch *gdbarch,
return pc;
}
+ /* If that's all we need, continue. */
+ if (addr_size == nullptr)
+ {
+ asm_lines.push_back (std::move (tal));
+ continue;
+ }
+
/* Capture the disassembled instruction. */
tal.insn = gdb_dis_out.release ();
/* And capture the address the instruction is at. */
- tal.addr = orig_pc;
- print_address (gdbarch, orig_pc, &gdb_dis_out);
+ print_address (gdbarch, tal.addr, &gdb_dis_out);
tal.addr_string = gdb_dis_out.release ();
+ tal.addr_size = (term_out
+ ? len_without_escapes (tal.addr_string)
+ : tal.addr_string.size ());
- if (addr_size != nullptr)
- {
- size_t new_size;
-
- if (term_out)
- new_size = len_without_escapes (tal.addr_string);
- else
- new_size = tal.addr_string.size ();
- *addr_size = std::max (*addr_size, new_size);
- tal.addr_size = new_size;
- }
+ *addr_size = std::max (*addr_size, tal.addr_size);
asm_lines.push_back (std::move (tal));
}
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index c97e8fd..84cad93 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -319,7 +319,9 @@ tui_apply_style (WINDOW *w, ui_file_style style)
wattron (w, A_NORMAL);
wattroff (w, A_BOLD);
wattroff (w, A_DIM);
+#ifdef A_ITALIC
wattroff (w, A_ITALIC);
+#endif
wattroff (w, A_UNDERLINE);
wattroff (w, A_REVERSE);
if (last_color_pair != -1)
@@ -368,8 +370,10 @@ tui_apply_style (WINDOW *w, ui_file_style style)
gdb_assert_not_reached ("invalid intensity");
}
+#ifdef A_ITALIC
if (style.is_italic ())
wattron (w, A_ITALIC);
+#endif
if (style.is_underline ())
wattron (w, A_UNDERLINE);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 558055d..95d20fb 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -37,7 +37,6 @@
#include "tui/tui-layout.h"
#include "tui/tui-source.h"
#include "gdb_curses.h"
-#include "gdbsupport/gdb-safe-ctype.h"
/* The layouts. */
static std::vector<std::unique_ptr<tui_layout_split>> layouts;
@@ -381,14 +380,14 @@ tui_register_window (const char *name, window_factory &&factory)
for (const char &c : name_copy)
{
- if (ISSPACE (c))
+ if (c_isspace (c))
error (_("invalid whitespace character in window name"));
- if (!ISALNUM (c) && strchr ("-_.", c) == nullptr)
+ if (!c_isalnum (c) && strchr ("-_.", c) == nullptr)
error (_("invalid character '%c' in window name"), c);
}
- if (!ISALPHA (name_copy[0]))
+ if (!c_isalpha (name_copy[0]))
error (_("window name must start with a letter, not '%c'"), name_copy[0]);
/* We already check above for all the builtin window names. If we get
diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c
index c2d3873..1e09975 100644
--- a/gdb/tui/tui-status.c
+++ b/gdb/tui/tui-status.c
@@ -271,10 +271,14 @@ tui_show_frame_info (const frame_info_ptr &fi)
symtab_and_line sal = find_frame_sal (fi);
const char *func_name;
+ std::optional<CORE_ADDR> tmp_pc = get_frame_pc_if_available (fi);
/* find_frame_sal does not always set PC, but we want to ensure
that it is available in the SAL. */
- if (get_frame_pc_if_available (fi, &sal.pc))
- func_name = tui_get_function_from_frame (fi);
+ if (tmp_pc.has_value ())
+ {
+ sal.pc = *tmp_pc;
+ func_name = tui_get_function_from_frame (fi);
+ }
else
func_name = _("<unavailable>");
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index d4fbbf1..b411d07 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -45,7 +45,6 @@
#include "tui/tui-win.h"
#include "gdb_curses.h"
-#include <ctype.h>
#include "readline/readline.h"
#include <signal.h>
#include <string_view>
@@ -1041,7 +1040,7 @@ parse_scrolling_args (const char *arg,
/* Process the number of lines to scroll. */
std::string copy = arg;
buf_ptr = &copy[0];
- if (isdigit (*buf_ptr))
+ if (c_isdigit (*buf_ptr))
{
char *num_str;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index a545c48..2fe4914 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -26,7 +26,6 @@
#include "value.h"
#include "source.h"
#include "objfiles.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
@@ -109,7 +108,7 @@ tui_copy_source_line (const char **ptr, int *length)
}
else if (c == '\t')
process_tab ();
- else if (ISCNTRL (c))
+ else if (c_iscntrl (c))
{
result.push_back ('^');
result.push_back (c + 0100);
@@ -461,7 +460,9 @@ tui_source_window_base::rerender ()
/* 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);
+ std::optional<CORE_ADDR> tmp_pc = get_frame_pc_if_available (frame);
+ if (tmp_pc.has_value ())
+ sal.pc = *tmp_pc;
maybe_update (get_frame_arch (frame), sal);
update_exec_info (false);
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 5883d6c..01aee2f 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -125,6 +125,19 @@ tui_rl_switch_mode (int notused1, int notused2)
}
else
{
+ /* If we type "foo", entering it into the readline buffer
+
+ (gdb) foo
+ ^
+ and then switch to TUI and back, we may get back
+
+ (gdb) foo
+ ^
+ which is confusing because "foo" is no longer part of the
+ readline buffer. Fix this by clearing it before switching to
+ TUI. */
+ rl_clear_visible_line ();
+
/* If tui_enable throws, we'll re-prep below. */
rl_deprep_terminal ();
tui_enable ();