diff options
author | Tom de Vries <tdevries@suse.de> | 2023-11-13 09:31:20 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-11-13 09:31:20 +0100 |
commit | aba9fa5f4be8c27e07c5330957fff17e4160920b (patch) | |
tree | 86bc25803e6a8ea6b70b224ce3778512aed47c5f /gdb | |
parent | e5da53e26f4e3b14c542a0cb65828a3a9e574ca3 (diff) | |
download | gdb-aba9fa5f4be8c27e07c5330957fff17e4160920b.zip gdb-aba9fa5f4be8c27e07c5330957fff17e4160920b.tar.gz gdb-aba9fa5f4be8c27e07c5330957fff17e4160920b.tar.bz2 |
[gdb/tui] Make assert in tui_find_disassembly_address more strict
In tui_find_disassembly_address we find an assert:
...
if (asm_lines.size () < max_lines)
{
if (!possible_new_low.has_value ())
return new_low;
/* Take the best possible match we have. */
new_low = *possible_new_low;
next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines);
last_addr = asm_lines.back ().addr;
gdb_assert (asm_lines.size () >= max_lines);
}
...
The comment right above:
...
/* If we failed to disassemble the required number of lines then the
following walk forward is not going to work, it assumes that
ASM_LINES contains exactly MAX_LINES entries. Instead we should
consider falling back to a previous possible start address in
POSSIBLE_NEW_LOW. */
...
claims that the more strict asm_lines.size () == max_line is required.
Update the assert to reflect this, and move it to after the if because it's
supposed to hold in general, not just when entering the if.
Tested on x86_64-linux.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/tui/tui-disasm.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c index c1ed491..9965ae1 100644 --- a/gdb/tui/tui-disasm.c +++ b/gdb/tui/tui-disasm.c @@ -268,11 +268,8 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) || (last_addr == pc && asm_lines.size () < max_lines)) && new_low != prev_low); - /* If we failed to disassemble the required number of lines then the - following walk forward is not going to work, it assumes that - ASM_LINES contains exactly MAX_LINES entries. Instead we should - consider falling back to a previous possible start address in - POSSIBLE_NEW_LOW. */ + /* If we failed to disassemble the required number of lines, try to fall + back to a previous possible start address in POSSIBLE_NEW_LOW. */ if (asm_lines.size () < max_lines) { if (!possible_new_low.has_value ()) @@ -282,9 +279,12 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from) new_low = *possible_new_low; next_addr = tui_disassemble (gdbarch, asm_lines, new_low, max_lines); last_addr = asm_lines.back ().addr; - gdb_assert (asm_lines.size () >= max_lines); } + /* The following walk forward assumes that ASM_LINES contains exactly + MAX_LINES entries. */ + gdb_assert (asm_lines.size () == max_lines); + /* Scan forward disassembling one instruction at a time until the last visible instruction of the window matches the pc. We keep the disassembled instructions in the 'lines' window |