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-status.c8
-rw-r--r--gdb/tui/tui-winsource.c4
-rw-r--r--gdb/tui/tui.c13
4 files changed, 41 insertions, 18 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-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-winsource.c b/gdb/tui/tui-winsource.c
index a545c48..618d72b 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -461,7 +461,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 ();