Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB TUI: Scroll assembly view above current instruction?

Tags:

assembly

gdb

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.

like image 939
Chuck R Avatar asked Oct 26 '14 12:10

Chuck R


People also ask

How do I scroll up in GDB?

When in GDB mode, the user is in command mode or scroll mode. When in command mode, the user is typing in commands to interact with GDB. When in scroll mode, the user can scroll through the GDB output. You can enter scroll mode by typing page up and quit scroll mode by typing q , i or enter .

How do I show disassembly in GDB?

From within gdb press Ctrl x 2 and the screen will split into 3 parts. First part will show you the normal code in high level language. Second will show you the assembly equivalent and corresponding instruction Pointer .

How do I change focus in GDB?

Text you type always goes into the command window, so normally you only need to change focus for scrolling around in registers, asm, or source. You can use command history while the focus is on the asm window by using control-p and control-n, like emacs.


2 Answers

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

like image 97
dbrank0 Avatar answered Sep 19 '22 13:09

dbrank0


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.

like image 24
ibodi Avatar answered Sep 20 '22 13:09

ibodi