Can anyone tell me which command is used to display the source code when debugging through GDB. Would be of great help.
Asked
Active
Viewed 3.5k times
5 Answers
26
You can enter or leave the TUI mode with code window using Ctrl+x A key binding. Or use layout src
command to enter TUI mode. See other TUI key bindings and commands.

ks1322
- 33,961
- 14
- 109
- 164
6
Start gdb using
gdb -tui
. tui stands for Text User Interface.Or, use 'ddd' -- a graphical front end for gdb.

Siddhartha Ghosh
- 2,988
- 5
- 18
- 25
4
The list
command will show the code around the line where the program is currently stopped. If you type list again you'll see more.

Joni
- 108,737
- 14
- 143
- 193
-
1list command shows the below output. (gdb) list No symbol table is loaded. Use the "file" command. – Sarwan Oct 09 '13 at 09:15
-
2You must compile the program with debug information in order to see the source code while debugging. If you use GCC to compile, use the `-g` switch, for example `gcc -g example.c -o example`. – Joni Oct 09 '13 at 09:53
2
By using layout next
we can see the source code on different window. If the program didn't start running we will see empty screen for the beginning, when it starts the program will appear on different window.

Nagmat
- 373
- 4
- 14