How to install gdb in linux
- how to use gdb debugger in linux
- how to install gdb debugger in linux
- how to use gdb in linux for debugging
- gdb debugger linux
How to debug in linux terminal.
gdb command in Linux with examples
GDB, the acronym for GNU Debugger, is a powerful debugging tool used to analyze and debug programs written in languages like C, C++, Ada, and Fortran.
It allows developers to inspect the behavior of their programs, step through code, set breakpoints, and examine variable values in real-time. GDB is an essential tool for debugging complex code, providing insights into runtime behavior that are invaluable for troubleshooting and optimization.
Basic Syntax of GDB
gdb [-help] [-nx] [-q] [-batch] [-cd=dir] [-f] [-b bps] [-tty=dev] [-s symfile] [-e prog] [-se prog] [-c core] [-x cmds] [-d dir] [prog[core|procID]]
Example:
The program to be debugged should be compiled with ‘-g’ option.
Gdb commands
The below given C++ file that is saved as ‘gfg.cpp’. We are going to use this file in this article.
Preparing a Program for Debugging with GDB
Compile the above C++ program using the command:
g++ -g -o gfg gfg.cppTo start the debugger of the above ‘gfg’ executable file, enter the command ‘gdb gfg’
- debugging gdb tutorial