🌐
GNU Project
sourceware.org › gdb
GDB: The GNU Project Debugger
GDB, the GNU Project debugger, allows you to see what is going on `inside' another program while it executes -- or what another program was doing at the moment it crashed.
HomePage
Please wait a moment while we ensure the security of your connection · Protected by Anubis From Techaro. Made with ❤️ in 🇨🇦
Memory (Debugging with GDB)
The addresses and contents printed by the x command are not saved in the value history because there is often too much of them and they would get in the way. Instead, GDB makes these values available for subsequent use in expressions as values of the convenience variables $_ and $__.
🌐
GNU
ftp.gnu.org › gnu › gdb
Index of /gnu/gdb
Index of /gnu/gdb · Apache/2.4.52 (Trisquel_GNU/Linux) Server at ftp.gnu.org Port 443
🌐
GitHub
github.com › bminor › binutils-gdb
GitHub - bminor/binutils-gdb: Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
Unofficial mirror of sourceware binutils-gdb repository. Updated daily. - bminor/binutils-gdb
Starred by 654 users
Forked by 643 users
Languages   C 45.2% | Makefile 24.3% | Assembly 14.6% | C++ 5.1% | DTrace 4.4% | Roff 1.1%
🌐
Dzyoba
alex.dzyoba.com › blog › gdb-source-path
How to point GDB to your sources | There is no magic here
To find the sources GDB parses .debug_info section to find all DIEs with tag DW_TAG_compile_unit. The DIE with this tag has 2 main attributes DW_AT_comp_dir (compilation directory) and DW_AT_name - path to the source file.
🌐
Apple Developer
developer.apple.com › library › archive › documentation › DeveloperTools › gdb › gdb › gdb_8.html
Debugging with gdb - Examining Source Files
GDB can print parts of your program's source, since the debugging information recorded in the program tells GDB what source files were used to build it. When your program stops, GDB spontaneously prints the line where it stopped. Likewise, when you select a stack frame (see section Selecting ...
🌐
MIT
web.mit.edu › gnu › doc › html › gdb_9.html
Debugging with GDB - Examining Source Files
Executable programs sometimes do ... could be moved between the compilation and your debugging session. GDB has a list of directories to search for source files; this is called the source path....
🌐
GNU Project
sourceware.org › gdb › current › onlinedocs › gdb.html › Source.html
Source (Debugging with GDB)
GDB can print parts of your program’s source, since the debugging information recorded in the program tells GDB what source files were used to build it. When your program stops, GDB spontaneously prints the line where it stopped. Likewise, when you select a stack frame (see Selecting a Frame), ...
🌐
Desy
zeuthen.desy.de › unix › unixguide › infohtml › gdb › Source-Path.html
Source Path - Debugging with GDB
Executable programs sometimes do ... could be moved between the compilation and your debugging session. gdb has a list of directories to search for source files; this is called the source path....
Find elsewhere
🌐
Opensource.com
opensource.com › article › 21 › 3 › debug-code-gdb
Learn to debug code with the GNU Debugger | Opensource.com
The GNU Debugger, more commonly known by its command, gdb, is an interactive console to help you step through source code, analyze what gets executed, and essentially reverse-engineer what's going wrong in a buggy application.
🌐
GNU
ftp.gnu.org › old-gnu › Manuals › gdb › html_node › gdb_48.html
Debugging with GDB - Source Path
Executable programs sometimes do ... could be moved between the compilation and your debugging session. GDB has a list of directories to search for source files; this is called the source path....
🌐
VisualGDB
visualgdb.com › gdbreference › commands › info_source
GDB Command Reference - info source command
Starting program: /home/bazis/test Temporary breakpoint 1, main (argc=1, argv=0xbffff064) at test.cpp:5 5 std::cout << "Hello!" << std::endl; (gdb) info source Current source file is test.cpp Compilation directory is /home/bazis Located in /home/bazis/test.cpp Contains 7 lines.
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_developer_toolset › 12 › html › user_guide › chap-gdb
Chapter 8. GNU Debugger (GDB) | User Guide | Red Hat Developer Toolset | 12 | Red Hat Documentation
Once you start the execution, gdb displays the lines that are surrounding the line on which the execution stops, typically when you set a breakpoint. You can also display the code that is surrounding a particular line: ... Copy to Clipboard Copied! ... Copy to Clipboard Copied! ... Copy to Clipboard Copied! ... Example 8.4. Listing the Source ...
🌐
Linux From Scratch
linuxfromscratch.org › blfs › view › svn › general › gdb.html
GDB-16.3
If you have built the API documentation, it is now in gdb/doc/doxy.
🌐
GitHub
github.com › bminor › binutils-gdb › tree › master › gdb
binutils-gdb/gdb at master · bminor/binutils-gdb
README for GDB release This is GDB, the GNU source-level debugger. A summary of new features is in the file `gdb/NEWS'. Check the GDB home page at http://www.gnu.org/software/gdb/ for up to date release information, mailing list links and archives, etc.
Author   bminor
Top answer
1 of 2
11

The simplest way is to extract the package source code somewhere: go to an appropriate directory, then run

apt source glibc

In gdb, add the corresponding directory to the source path by using the directory command.

You may also want the detached debug symbols; I don’t know whether Devuan provides debug symbol packages in general (dbgsym packages), but I see it ships libc6-dbg which has the same purpose:

sudo apt install libc6-dbg

Here’s an example gdb session:

$ gdb ls
...
(gdb) directory ~/Debian/glibc
Source directories searched: /home/steve/Debian/glibc:$cdir:$cwd
(gdb) break malloc
Breakpoint 1 at 0x46c8
(gdb) run
Starting program: /bin/ls 

Breakpoint 1, malloc (n=1441) at dl-minimal.c:50
50    if (alloc_end == 0)
2 of 2
1

Some further indications for Ubuntu 22.04 beyond what Stephen said.

To get debug symbols and source, some setup is needed as in:

# Get debug symbols.
printf "deb http://ddebs.ubuntu.com %s main restricted universe multiverse\n" $(lsb_release -cs){,-updates,-security,-proposed} | \
 sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt install ubuntu-dbgsym-keyring
sudo apt update
sudo apt install coreutils-dbgsym

# Get source as per: https://askubuntu.com/questions/496549/error-you-must-put-some-source-uris-in-your-sources-list
# Produces directory "coreutils-8.32"
sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /'
/etc/apt/sources.list sudo apt-get update
apt source coreutils

Then, to get GDB to actually find the sources, you might need to either cd into the downloaded source, or play with stuff like:

set substitute-path . glibc-2.35

as mentioned at: https://askubuntu.com/questions/487222/how-to-install-debug-symbols-for-installed-packages/1434174#1434174

source-level debugger

GNU_gdb_12.1_screenshot.png
The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, Assembly, C, C++, D, Fortran, Haskell, Go, Objective-C, OpenCL C, … Wikipedia
Factsheet
Developer GNU Project
Initial release 1986; 39 years ago (1986)
Stable release 16.3
/ 20 April 2025
Factsheet
Developer GNU Project
Initial release 1986; 39 years ago (1986)
Stable release 16.3
/ 20 April 2025
🌐
Wikipedia
en.wikipedia.org › wiki › GNU_Debugger
GNU Debugger - Wikipedia
1 month ago - Command definitions placed in the local file .gdbinit are automatically loaded at the beginning of the gdb session. Command definitions can also be saved in ordinary files and loaded using the source command.
🌐
GNU Project
sourceware.org › gdb › current
Current GDB
The sources to GDB are available via FTP, git and WWW.