]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ChangeLog
gdb/tui: asm window handles invalid memory and scrolls better
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 11 Jan 2020 01:38:28 +0000 (01:38 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 24 Jan 2020 00:10:33 +0000 (00:10 +0000)
commit733d0a679536628eb1be4b4b8aa6384de24ff1f1
tree9a8f6e77b400a79b40433763852d33b78e77b423
parent2f267673f0fdee9287e6d404ecd4f2d29da0d2f2
gdb/tui: asm window handles invalid memory and scrolls better

This started as a patch to enable the asm window to handle attempts to
disassemble invalid memory, but it ended up expanding into a
significant rewrite of how the asm window handles scrolling.  These
two things ended up being tied together as it was impossible to
correctly test scrolling into invalid memory when the asm window would
randomly behave weirdly while scrolling.

Things that should work nicely now; scrolling to the bottom or top of
the listing with PageUp, PageDown, Up Arrow, Down Arrow and we should
be able to scroll past small areas of memory that don't have symbols
associated with them.  It should also be possible to scroll to the
start of a section even if there's no symbol at the start of the
section.

Adding tests for this scrolling was a little bit of a problem.  First
I would have liked to add tests for PageUp / PageDown, but the tuiterm
library we use doesn't support these commands right now due to only
emulating a basic ascii terminal.  Changing this to emulate a more
complex terminal would require adding support for more escape sequence
control codes, so I've not tried to tackle that in this patch.

Next, I would have liked to test scrolling to the start or end of the
assembler listing and then trying to scroll even more, however, this
is a problem because in a well behaving GDB a scroll at the start/end
has no effect.  What we need to do is:

  - Move to start of assembler listing,
  - Send scroll up command,
  - Wait for all curses output,
  - Ensure the assembler listing is unchanged, we're still at the
    start of the listing.

The problem is that there is no curses output, so how long do we wait
at step 3?  The same problem exists for scrolling to the bottom of the
assembler listing.  However, when scrolling down you can at least see
the end coming, so I added a test for this case, however, this feels
like an area of code that is massively under tested.

gdb/ChangeLog:

PR tui/9765
* minsyms.c (lookup_minimal_symbol_by_pc_section): Update header
comment, add extra parameter, and update to store previous symbol
when appropriate.
* minsyms.h (lookup_minimal_symbol_by_pc_section): Update comment,
add extra parameter.
* tui/tui-disasm.c (tui_disassemble): Update header comment,
remove unneeded parameter, add try/catch around gdb_print_insn,
rewrite to add items to asm_lines vector.
(tui_find_backward_disassembly_start_address): New function.
(tui_find_disassembly_address): Updated throughout.
(tui_disasm_window::set_contents): Update for changes to
tui_disassemble.
(tui_disasm_window::do_scroll_vertical): No need to adjust the
number of lines to scroll.

gdb/testsuite/ChangeLog:

PR tui/9765
* gdb.tui/tui-layout-asm.exp: Add scrolling test for asm window.

Change-Id: I323987c8fd316962c937e73c17d952ccd3cfa66c
gdb/ChangeLog
gdb/minsyms.c
gdb/minsyms.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/tui-layout-asm.exp
gdb/tui/tui-disasm.c