GDB(1)
๐ GDB(1) โ GNU Development Tools ๐
okay bestie, welcome to the GNU Development Tools corner of the manual, bestie. this one's a whole situation โ it's long, it's iconic, and it's literally the debugger manual. let's get into it ๐ซถ
โจ NAME โจ
gdb โ The GNU Debugger. that's it. that's the name. ๐
โจ SYNOPSIS โจ
gdb [OPTIONS] [prog|prog procID|prog core]
like, you can just run it with options, or you can point it at a program, or a program + a process ID, or a program + a core file. three flavors, all valid, all slay ๐
๐ธ DESCRIPTION ๐ธ
so the whole point of a debugger like ROCGDB is to let you peek at what's going on "inside" another program while it's running โ or what that program was doing at the exact moment it crashed ๐ญ it's giving microscope energy, fr fr.
ROCGDB can do four main kinds of things (plus a bunch of supporting stuff around them) to help you catch bugs in the act:
- Start your program, specifying anything that might affect its behavior. ๐
- Make your program stop on specified conditions. โ
- Examine what has happened, when your program has stopped. ๐
- Change things in your program, so you can experiment with correcting the effects of one bug and go on to learn about another. ๐งช
you can use ROCGDB to debug programs written in C, C++, Fortran and Modula-2. multilingual icon behavior ๐
ROCGDB is invoked with the shell command gdb. once it's started, it reads commands from the terminal until you tell it to exit with the ROCGDB command quit or exit. and you can get online help from ROCGDB itself by using the command help โ she's self-aware, she's helpful, she's that girl ๐โโ๏ธ
you can run gdb with no arguments or options; but the most usual way to start ROCGDB is with one argument or two, specifying an executable program as the argument:
gdb program
you can also start with both an executable program and a core file specified:
gdb program core
you can, instead, specify a process ID as a second argument or use option -p, if you want to debug a running process:
gdb program 1234
gdb -p 1234
both of those would attach ROCGDB to process 1234. and with option -p you can omit the program filename entirely โ no program file, no problem ๐
here are some of the most frequently needed ROCGDB commands, aka the starter pack, the greatest hits, the ones you'll actually type:
break [file:][function|line]โ Set a breakpoint at function or line (in file). ๐run [arglist]โ Start your program (with arglist, if specified). ๐โโ๏ธbtโ Backtrace: display the program stack. ๐ชprint exprโ Display the value of an expression. ๐จ๏ธcโ Continue running your program (after stopping, e.g. at a breakpoint). โถ๏ธnextโ Execute next program line (after stopping); step over any function calls in the line. โญ๏ธedit [file:]functionโ look at the program line where it is presently stopped. ๐list [file:]functionโ type the text of the program in the vicinity of where it is presently stopped. ๐stepโ Execute next program line (after stopping); step into any function calls in the line. ๐ฃhelp [name]โ Show information about ROCGDB command name, or general information about using ROCGDB. โquit/exitโ Exit from ROCGDB. ๐
for full details on ROCGDB, see Using GDB: A Guide to the GNU Source-Level Debugger, by Richard M. Stallman and Roland H. Pesch. the same text is available online as the gdb entry in the info program. ๐
โจ OPTIONS โจ
okay so, ground rules first, because the vibes here are specific ๐ง
any arguments other than options specify an executable file and core file (or process ID); that is, the first argument encountered with no associated option flag is equivalent to a --se option, and the second, if any, is equivalent to a -c option if it's the name of a file. many options have both long and abbreviated forms; both are shown here. the long forms are also recognized if you truncate them, so long as enough of the option is present to be unambiguous. so like, truncation slay, but only unambiguous truncation. bestie, do not test her. ๐
the abbreviated forms are shown here with - and long forms are shown with -- to reflect how they are shown in --help. however, ROCGDB recognizes all of the following conventions for most options:
"--option=value"
"--option value"
"-option=value"
"-option value"
"--o=value"
"--o value"
"-o=value"
"-o value"
like, she's flexible. she's accommodating. she contains multitudes ๐โจ
important: all the options and command line arguments you give are processed in sequential order. the order makes a difference when the -x option is used. so don't come for her about ordering, the ordering is load-bearing ๐ฅ
--help,-hโ List all options, with brief explanations. the literal cheat sheet, we love her ๐--symbols=file,-s fileโ Read symbol table from file. ๐--writeโ Enable writing into executable and core files. yes, writing. into files. be normal about it, or don't ๐--exec=file,-e fileโ Use file as the executable file to execute when appropriate, and for examining pure data in conjunction with a core dump. ๐๏ธ--se=fileโ Read symbol table from file and use it as the executable file. two jobs, one flag, main character energy ๐--core=file,-c fileโ Use file as a core dump to examine. ๐พ--command=file,-x fileโ Execute ROCGDB commands from file. ๐--eval-command=command,-ex commandโ Execute given ROCGDB command. โก--init-eval-command=command,-iexโ Execute ROCGDB command before loading the inferior. before!! loading!! the inferior!! timing is everything โฐ--directory=directory,-d directoryโ Add directory to the path to search for source files. ๐๏ธ--nhโ Do not execute commands from~/.config/gdb/gdbinit,~/.gdbinit,~/.config/gdb/gdbearlyinit, or~/.gdbearlyinit. she said not today to all four of those ๐ โโ๏ธ--nx,-nโ Do not execute commands from any.gdbinitor.gdbearlyinitinitialization files. all of them. every single one. no cap ๐ซ--quiet,--silent,-qโ "Quiet". Do not print the introductory and copyright messages. these messages are also suppressed in batch mode. she's being demure, she's being mindful ๐คซ--batchโ Run in batch mode. Exit with status0after processing all the command files specified with-x(and.gdbinit, if not inhibited). Exit with nonzero status if an error occurs in executing the ROCGDB commands in the command files. ๐ฆ
batch mode may be useful for running ROCGDB as a filter, for example to download and run a program on another computer; in order to make this more useful, the message
Program exited normally.
(which is ordinarily issued whenever a program running under ROCGDB control terminates) is not issued when running in batch mode. she's quiet in batch mode, it's her era ๐
--batch-silentโ Run in batch mode, just like--batch, but totally silent. All ROCGDB output is suppressed (stderris unaffected). this is much quieter than--silentand would be useless for an interactive session. like babe, do not try to have a conversation with this mode, it is not conversing with you ๐
this is particularly useful when using targets that give Loading section messages, for example. ๐
note that targets that give their output via ROCGDB, as opposed to writing directly to stdout, will also be made silent. ๐ซ๏ธ
--args prog [arglist]โ Change interpretation of command line so that arguments following this option are passed as arguments to the inferior. so like, everything after--argsbelongs to the program, not to you. boundaries!! โ
as an example, take the following command:
gdb ./a.out -q
it would start ROCGDB with -q, not printing the introductory message. on the other hand, using:
gdb --args ./a.out -q
starts ROCGDB with the introductory message, and passes the option to the inferior. same flags, completely different vibes, iykyk ๐ฆ
--pid=pidโ Attach ROCGDB to an already running program, with the PID pid. ๐ฏ--tuiโ Open the terminal user interface. pretty UI hours ๐ธ--readnowโ Read all symbols from the given symfile on the first access. gimme all of it, immediately, no waiting ๐--readneverโ Do not read symbol files. literally never. not once. ๐--return-child-resultโ ROCGDB's exit code will be the same as the child's exit code. good parenting, honestly ๐ซถ--configurationโ Print details about GDB configuration and then exit. ๐ (note: this one says GDB, and we're keeping it exactly as written, bestie โ you're welcome)--versionโ Print version information and then exit. ๐ท๏ธ--cd=directoryโ Run ROCGDB using directory as its working directory, instead of the current directory. ๐--data-directory=directory,-Dโ Run ROCGDB using directory as its data directory. The data directory is where ROCGDB searches for its auxiliary files. ๐--fullname,-fโ Emacs sets this option when it runs ROCGDB as a subprocess. It tells ROCGDB to output the full file name and line number in a standard, recognizable fashion each time a stack frame is displayed (which includes each time the program stops). This recognizable format looks like two\032characters, followed by the file name, line number and character position separated by colons, and a newline. The Emacs-to-ROCGDB interface program uses the two\032characters as a signal to display the source code for the frame. emacs girlies stay winning ๐งโจ-b baudrateโ Set the line speed (baud rate or bits per second) of any serial interface used by ROCGDB for remote debugging. baudrate, she's retro, she's chic ๐ป-l timeoutโ Set timeout, in seconds, for remote debugging. โณ--tty=deviceโ Run using device for your program's standard input and output. ๐ฅ๏ธ
๐ ENVIRONMENT ๐
(nothing listed here in this manual โ the section exists, it's just living its minimalist truth. a quiet icon. an empty queen.) โจ
๐ SEE ALSO ๐
the full documentation for ROCGDB is maintained as a Texinfo manual. if the info and gdb programs and ROCGDB's Texinfo documentation are properly installed at your site, the command
info gdb
should give you access to the complete manual. ๐๐
Using GDB: A Guide to the GNU Source-Level Debugger, Richard M. Stallman and Roland H. Pesch, July 1991. vintage but still eating ๐
๐ COPYRIGHT ๐
Okay bestie, legal era ๐ โ but like, important legal era, so stay with me.
Copyright ยฉ 1988-2024 Free Software Foundation, Inc.
So here's the tea: you're literally allowed to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation. Iconic of them, honestly ๐ซถ
But there are โจconditionsโจ (iykyk): the Invariant Sections are "Free Software" and "Free Software Needs Free Documentation", the Front-Cover Texts are "A GNU Manual," and the Back-Cover Texts are as in (a) down below ๐
- (a) the FSF's Back-Cover Text, verbatim, no cap: "You are free to copy and modify this GNU Manual. Buying copies from GNU Press supports the FSF in developing GNU and promoting software freedom."
โ๏ธ Legal Disclaimer and Copyright Information
Now we're getting into the AMD part, bestie โ buckle up ๐
AMD ROCm software is made available by Advanced Micro Devices, Inc. under the open source license identified in the top-level directory for the library in the repository on @url{https://github.com/ROCm/,Github.com} โ and real quick, parenthetically: portions of AMD ROCm software are licensed under MITx11 and UIL/NCSA, and for more info on the license you should review the license.txt in the top-level directory for the library on @url{https://github.com/ROCm/,Github.com}. The additional terms and conditions below apply to your use of AMD ROCm technical documentation, periodt.
ยฉ2019-2024 Advanced Micro Devices, Inc. All rights reserved.
So likeโฆ the info in this document is for informational purposes only and may contain technical inaccuracies, omissions, and typographical errors ๐ญ โ it's giving "we're human". The info herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to: product and roadmap changes, component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS flashes, firmware upgrades, or the like. And ngl, any computer system has risks of security vulnerabilities that cannot be completely prevented or mitigated. AMD assumes no obligation to update or otherwise correct or revise this information. However โ and this is the main character clause โ AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes ๐
And now the shouty part, which I'm keeping exactly as loud as it was, because legal caps are sacred:
THIS INFORMATION IS PROVIDED "AS IS." AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS, OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION. AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY RELIANCE, DIRECT, INDIRECT, SPECIAL, OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
๐ธ Trademarks (the โข zone)
- AMD, the AMD Arrow logo, AMD Instinctโข, Radeonโข, AMD ROCmโข, and combinations thereof are trademarks of Advanced Micro Devices, Inc.
- Linuxยฎ is the registered trademark of Linus Torvalds in the U.S. and other countries.
- PCIeยฎ is a registered trademark of PCI-SIG Corporation.
- Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.
Like, that's it, that's the whole legal vibe check ๐ โ you read the fine print, I'm so proud of you fr fr ๐ง
And that's a wrap on the entire page, bestie!! ๐โจ This lil doc ships as gdb-16.3, dated 2026-05-31 โ go forth and debug your heart out ๐๐ฆ๐
๐ฆ where this page comes from
- arch rolling: rocm-gdb 7.2.4-1 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms