It's called the TUI (no kidding). Start for example with gdbtui or gdb -tui ...


Please also see this answer by Ciro Santilli. It wasn't available in 2012 to the best of my knowledge, but definitely worth a look.

Answer from 0xC0000022L on Stack Overflow
🌐
Brown
cs.brown.edu › courses › cs033 › docs › guides › gdb.pdf pdf
CSCI0330 Intro Computer Systems Doeppner gdb Cheatsheet Fall 2018
Quits​ gdb. ... layout​ is a terminal interface which allows the user to view the source file while debugging.
🌐
GNU Project
sourceware.org › gdb › onlinedocs › gdb › TUI-Commands.html
TUI Commands (Debugging with GDB)
March 7, 2022 - Here is a more complex example, showing a horizontal layout: (gdb) tui new-layout example {-horizontal src 1 asm 1} 2 status 0 cmd 1
Discussions

Does anyone use GDB without the TUI? If so, how? What are the use cases for not using the TUI?
I didn't even know it had a 'TUI'. So no, I never use the tui when using gdb. More on reddit.com
🌐 r/C_Programming
15
6
June 17, 2022
How do I explore this code with gdb?
Try this: $ gdb -ex 'layout regs' add_ints (gdb) start layout regs shows all the registers. start will breakpoint your program at the beginning. Sometimes you may need starti instead. Then you can step through your assembly line by line (n). If you do so, you'll see the crash on ret. There's nowhere to return, and so the instruction pointer flies off to the "address" argc, as this at the top of the stack (Linux only). That's why you couldn't see what was going on after the crash. It seems like perhaps you meant to link libc? You also didn't choose an entry point when linking (ld), so it chooses the instruction with the lowest address as the entry point. If you linked libc, your ret would have somewhere to return. $ cc -no-pie -o add_ints add_ints.o You can do the same thing with start in this program to step through it. More on reddit.com
🌐 r/asm
6
4
September 26, 2023
🌐
GNU
ftp.gnu.org › old-gnu › Manuals › gdb › html_chapter › gdb_19.html
Debugging with GDB - GDB Text User Interface
When the TUI mode is left, the curses window management is left and GDB operates using its standard mode writing on the terminal directly. When the TUI mode is entered, the control is given back to the curses windows. The screen is then refreshed. ... Use a TUI layout with only one window.
🌐
Desy
zeuthen.desy.de › dv › documentation › unixguide › infohtml › gdb › TUI-Commands.html
TUI Commands - Debugging with GDB
Note that if gdb's stdout is not ... (see The gdb/mi Interface), most of these commands will fail with an error, because it would not be possible or desirable to enable curses window management. ... List and give the size of all displayed windows. ... Display the next layout...
🌐
Apple Developer
developer.apple.com › library › archive › documentation › DeveloperTools › gdb › gdb › gdb_23.html
Debugging with gdb - gdb Text User Interface
The following layouts are available: ... On top of the command window a status line gives various information concerning the current process begin debugged. The status line is updated when the information it shows changes. The following fields are displayed: ... Indicates the current gdb target ...
🌐
Ecoscentric
doc.ecoscentric.com › gnutools › doc › gdb › TUI-Commands.html
Debugging with GDB: TUI Commands
Note that if GDB’s stdout is not connected to a terminal, or GDB has been started with the machine interface interpreter (see The GDB/MI Interface), most of these commands will fail with an error, because it would not be possible or desirable to enable curses window management. ... Activate TUI mode. The last active TUI window layout will be used if TUI mode has prevsiouly been used in the current debugging session, otherwise a default layout is used.
Find elsewhere
🌐
GitHub
gist.github.com › savanovich › eb6ee6b264e773968e71
GDB cheatsheet · GitHub
(gdb) p/a 0x54320 $1 = 0x54320 <_initialize_vx+396> (gdb) p/a &h $2 = 0x7ffff7dd7820 <h> # same as (gdb) info symbol 0x54320 (gdb) info symbol &h h in section .bss of /lib/x86_64-linux-gnu/libc.so.6 (gdb) p (int)$rax $3 = -1
🌐
Ubuntu Forums
ubuntuforums.org › showthread.php
gdb doesnot display source code - Forum
February 22, 2006 - A help and support forum for Ubuntu Linux.
🌐
niranjanmr
niranjanmr.wordpress.com › 2013 › 04 › 28 › using-gdb-layout-when-debugging-assembly-language-programs
Using gdb layout when debugging Assembly Language Programs | niranjanmr
April 28, 2013 - After setting the break point run the program by typing “run” (or just “r”) at the gdb prompt which will stop at the first break point , which in our case is the _start function. At this point lets invoke “asm” layout by typing “layout asm” at the gdb prompt:
🌐
USC CS and ECE
bytes.usc.edu › cs104 › wiki › gdb
GDB Cheat Sheet
Note: function breakpoints will not work on functions that take strings as arguments (it’s complicated) on your course VM due to an incompatibility between GCC and GDB. However, this will work properly on newer systems. layout next From the begining of GDB, entering ‘layout next’ once the program is running will show you source code around your current location in the program.
🌐
Dirac
dirac.org › linux › gdb › 02a-Memory_Layout_And_The_Stack.php
Peter's gdb Tutorial: Memory Layout And The Stack
To effectively learn how to use GDB, you must understand frames, which are also called stack frames because they're the frames that comprise the stack. To learn about the stack, we need to learn about the memory layout of an executing program.
🌐
GitHub
gist.github.com › edi33416 › c977eda93dcfc56be1fc20925f406f54
GDB intro layout · GitHub
GDB intro layout. GitHub Gist: instantly share code, notes, and snippets.
🌐
Reddit
reddit.com › r/c_programming › does anyone use gdb without the tui? if so, how? what are the use cases for not using the tui?
r/C_Programming on Reddit: Does anyone use GDB without the TUI? If so, how? What are the use cases for not using the TUI?
June 17, 2022 -

I’ve typically only used my IDE’s native debugger, but I’ve switched to GDB predominately now.

By default, there is no TUI, I need to specify with —tui

I can’t really justify it? Even if I’m using GDB’s Python interpreter or looking at local variables.

Top answer
1 of 11
9
I didn't even know it had a 'TUI'. So no, I never use the tui when using gdb.
2 of 11
7
I've never liked using GDB's TUI, so I always use the command interface. My typical workflow on all platforms is a vertically-maximized Vim window and a vertically maximized terminal window. The terminal runs a long-term GDB session exclusively, with file set to the program I'm writing, usually set by initial the command line. $ gdb myprogram gdb> Alternatively use file after starting GDB. Occasionally useful if my project has multiple binaries, and I want to examine a different program. gdb> file myprogram I use make and Vim's :mak command for building from within the editor, so I don't need to change context just to build. The quickfix list takes me straight to warnings/errors. Often I'm writing something that takes input from standard input. So I use the run (r) command to set this up (along with any command line arguments). gdb> r r My usual workflow is edit, :mak, r, repeat. If I want to test a different input or use different options, change the run configuration using run again: gdb> r -x -b k GDB has an annoying, flow-breaking yes/no prompt for this, so I suggest set confirm no in your .gdbinit to disable it. Sometimes the program is stuck in a loop and I just want it to stop. I avoid CTRL-C since it can confuse GDB (another GDB issue), so I'll stop it from Vim with pkill: :!pkill myprogram On that note, you can run commands from GDB with !, which is another way to avoid having an extra terminal window open: gdb> !rm myprogram.o In any case, GDB will re-read the binary on the next run and update breakpoints, so it's mostly seamless. If there's a function I want to look at I set a breakpoint on it, then run. gdb> b somefunc gdb> r Alternatively use a line number, which I read from Vim. Though, note, unlike a typical GUI debugger, GDB cannot track how that line moves between builds. An empty command repeats the last command, so once I'm at a break point, I'll type next (n), then press enter each time I want to advance a line, often with my eye on the context in Vim in the other window (an area where the TUI helps, but GDB could overall be better). gdb> n gdb> gdb> If I want to advance to the next breakpoint, I use continue (c): gdb> c If I'm walking through a loop, I want to see how variables change, but it's tedious to keep printing (p) the same variables again and again. So I use display (disp) to display an expression with each prompt, much like the "watch" window in Visual Studio. For example, if my loop variable is i over some string str, this will show me the current character in character format (/c). gdb> disp/c str[i] You can add multiple expressions like this. Use undisplay to remove them. Too many breakpoints? Use info breakpoints (i b) to list them, then delete (d) the unwanted ones by ID. gdb> i b gdb> d 3 5 8 Ultimately that's just 9 GDB commands to cover 99% of use cases: r, c, n, disp, k, b, i, d, p. Some extra debugging notes: GDB doesn't break on "signals" on Windows, and by default MSVCRT abort (including abort-calling features like assert and -ftrapv) is just raise(SIGABRT) which isn't trapped. There are a couple workarounds, but the most expedient is to set a breakpoint on abort. My favorite related tool is __builtin_trap() since it simply inserts a trap instruction, so you don't have a bunch of junk stack frames in the way while debugging (glibc and libsanitizer are terrible about this). On all platforms, ASan doesn't break GDB on error, which is a serious annoyance. Fortunately you can work around this, too, with an environment variable (also here cutting out some of the noise): export ASAN_OPTIONS=abort_on_error=1:print_legend=0 Similarly, with UBSan you can use -fsanitize-undefined-trap-on-error. With these required workarounds, you'd think libsanitizer wasn't intended to be used with debuggers!
🌐
Reddit
reddit.com › r/c_programming › gdb is showing me assembly code instead of c code. how can i fix this?
r/C_Programming on Reddit: gdb is showing me assembly code instead of c code. How can I fix this?
August 21, 2021 -

Hello I recently started learning c and so I'm currently learning to use the gdb bebugger. I'm finding that when I run my code with the debugger I only get asm code instead the c I've written. I can't find any solutions to this on the web.

This is a walk through of what I'm doing:

gcc test.c -o debug

gdb ./debug

layout next

After I type layout next I get a screen of the code I've written but in asm. Is there a solution to this?

🌐
Swarthmore College
cs.swarthmore.edu › ~zpalmer › cs75 › s23 › guides › gdb
CS75: Debugging x86-64 Assembly with GDB
The first line will ensure that GDB shows assembly in Intel syntax (which we are using in the class) rather than AT&T syntax (which we are not). The next line defines a layout mode which displays the contents of registers at the top, the disassembled program in the middle, and the command window at the bottom.
🌐
University of Washington
courses.cs.washington.edu › courses › cse351 › 17au › gdb
CSE 351 GDB
(gdb) layout asm (gdb) layout regs · Note that you want to do them in that order so that the registers window is on top.
🌐
Reddit
reddit.com › r/asm › how do i explore this code with gdb?
r/asm on Reddit: How do I explore this code with gdb?
September 26, 2023 -

This code is from book I'm using to learn (Introduction to 64 bit Intel Assembly Language Programming for Linux).

segment . data 
a dq 175 
b dq 4097 
segment . text 
global main 
main : 
mov rax , [a] ; mov a into rax 
add rax, [b] ; add b to rax 
xor rax, rax 
ret 

How do I compile it so that I can explore it with gdb on Fedora?

I've tried:

nasm -f elf64 -g -o add_ints.o add_ints.asm 

And then

ld -o add_ints add_ints.o

But when I ran gdb on add_ints and tried r I got a segmentation fault.

🌐
NUS Computing
comp.nus.edu.sg › ~liangzk › cs5231 › stacklayout.pdf pdf
Using GNU's GDB Debugger Memory Layout And The Stack By Peter Jay Salzman
about the stack, we need to learn about the memory layout of an executing · program. The discussion will mainly be theoretical, but to keep things interesting · we'll conclude the chapter with an example of the stack and stack frames using · GDB. The material learned in this chapter may seem rather theoretical, but it does serve ·