14
votes

I've only just started using GDB recently, but I'm super impressed by it. No wonder it's the de-facto debugger for many users. One minor annoyance that I've found, though, is that I find myself unable to scroll above the current instruction in the TUI assembly view. I can scroll up and down just fine so long as display buffer is underneath the current instruction.

Other than something like x/20i [address] (which kind of defeats the purpose of a scrollable window) or altering the memory with a jump and setting a subsequent breakpoint, is there any way to tell the TUI assembly view to look at another location that might be above (lower memory than) the current instruction?

Edit: This only seems to happen when attached to an already running process, not when using gdb to launch the process. Sometimes I can scroll up until the current instruction, other times I can't scroll up t all.

2
Lacking any other answers, you can look into using one of gdb front-ends, which will allow you to scroll disassembly (among other things). See here: sourceware.org/gdb/wiki/GDB%20Front%20Endsdbrank0
Thanks! Using cgdb resolved my problem!MarSoft
I've raised an issue for this, as it's driving me mad: sourceware.org/bugzilla/show_bug.cgi?id=26024Edd Barrett
Remark: The bug linked above points out that the bug happens when the program crashed with SIGSEGV, and the bug is fixed in gdb 10, so upgrading is an option.user202729

2 Answers

5
votes

There seems to be some kind of issue with scrolling assembly in gdb tui like you explain, but a simple workaround exists.

So, first enable tui and disassembly view by pressing ctrl+x ctrl+a. Then show disassembly view by entering layout asm or something similar.

Now that windows should let you scroll with keys or mouse, but if it stops (which for me sometimes happens at beginning of some function) enter the usual disassemble command and disassembly view will update to that location.

Example:

disass main
disass 0x1234

5
votes

I've found a small hack. If you're in layout asm mode and you can't scroll to the current instruction you can execute command layout split and then layout asm and the first line will be the current one.