Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I scroll back in GDB's command window in the TUI mode?

Suppose that

(gdb) print *this 

resulted in 20 lines of output. Yes, there would be Type <return> to continue, or q <return> to quit, but I'd like to scroll back to the top after I got to the bottom of the output.

I don't think http://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html answers my question. It states

<PgUp>
Scroll the active window one page up.

but when the focus is on the command window, PgUp rewinds the command history, instead of scrolling back in the command window. Is it only me who suffers from this behavior?

I'm using PuTTY in order to SSH to Red Hat Linux (if this makes any difference).

like image 445
nodakai Avatar asked Feb 13 '12 07:02

nodakai


People also ask

How to scroll in GDB TUI?

You can enter scroll mode by typing page up and quit scroll mode by typing q , i or enter . The commands available in GDB Mode when in command mode are: cgdbmodekey. Switch back to source window.

How do I quit Tui?

You can enter / leave the TUI mode with one of this combinations: C-x C-a. C-x a. C-x A.

Does LLDB have Tui?

You can also expand the regsiters by register class: I'd like to know how to resize the various windows. If you resize the terminal, the size of the stack view pane seems to remain fixed, so the symbol names always end up truncated.


2 Answers

I found an answer here: http://beej.us/guide/bggdb/

Note that when the SRC window has focus, the arrow keys will move the source code, but when the CMD window has focus, the arrow keys will select the previous and next commands in the command history. (For the record, the commands to move the SRC window single lines and single pages are +, -, <, and >.)

There's also an example session illustrating this:

(gdb) info win         SRC     (36 lines)  <has focus>         CMD     (18 lines) (gdb) fs next Focus set to CMD window. (gdb) info win         SRC     (36 lines)         CMD     (18 lines)  <has focus> (gdb) fs SRC Focus set to SRC window. (gdb) 
like image 168
Lupus Avatar answered Sep 21 '22 15:09

Lupus


One way to see the GDB output history in TUI mode is to enable logging:

set trace-commands on set logging on 

and then tail the log in another shell:

cd where/gdb/is/running tail -f gdb.txt 

This has the advantage of separating scrolling from command interaction, so you can type commands while viewing some past section of the GDB output.

None of the scrolling keys work in my CMD window, so GDB effectively consumes and destroys its own output. Switching out of TUI mode allows me to scroll up, but the output that occurred while in TUI mode is not there--the non-TUI window only shows new output generated after switching out of TUI mode. So far log and tail is the only solution I can find.


Edit: if you activate GDB logging (via set logging on) before switching to TUI mode, you may find that the logging stops upon entering TUI (this is a bug in GDB). You can toggle it back on:

set logging off set logging on 
like image 35
Byron Hawkins Avatar answered Sep 21 '22 15:09

Byron Hawkins