Readinglist |
Quick Links |
Algorithms |
Apple |
AssemblyLanguage |
BASH |
C-Programmming |
CommonLisp |
Computer Security |
CuisSmalltalk |
Databases |
Emacs |
Exploitation |
Functional Programming |
Firewalls |
Git |
GNUSmalltalk |
Haskell |
Javascript |
Julia |
Linux |
Machine Learning |
Metasploit |
Machine Learning |
Networking |
Operating Systems |
Open Data Science |
Odin |
Picolisp |
Pharo Smalltalk |
Purescript |
Python |
Racket |
Scheme |
Social Engineering |
Unity |
vim |
V |
Web Development |
Windows WSL |
Zig
Using the C Debugger
The GBD Tutorial,
Online Docs
- Compile your program with '-g'
gcc -g main.c
run gbd
gdb a.out
exit gbd
(gdb) quit
Common Commands
- help List gdb command categories
- help category List gdb commands of category
- help command Displays description of command
- -------------------------------------------------------
- apropos search-word Display commands list containing search-word in their help description
- info args
- i args Displays arguments of current function
- info breakpoints
- info break
- info b
- i b Displays list of breakpoints
- info break breakpoint-number
- i b breakpoint-number Displays description of breakpoint having breakpoint-number
- info watchpoints
- i watchpoints Displays list of watchpoints
- info registers
- i r Display processor's register contents
- info threads
- i threads Display information about current thread
- info set
- i set List set-able options
- -------------------------------------------------------
- r Start running program until a breakpoint or end of program
- -------------------------------------------------------
- break funname
- break line-no
- break ClassName::funcName Set a breakpoint at specified function or line number.
- break +line-offset
- break -line-offset Set a breakpoint at specified number of lines forward or backward from current line of execution.
- break filename:funcname Set a breapoint at specified funcname of given filename.
- break filename:line-no Set a breakpoint at given line-no of specified filename.
- break *address Set a breakpoint at specified instrunction address.
- break line-no if condition Set a conditional breakpoint at line-no of current file. Program will suspend only when condition is true.
- break line thread thread-no Set a breakpoint at line in thread with thread-no.
- -------------------------------------------------------
- tbreak tbreak is similar to break but it will temporary breakpoint. i.e. Breakpoint will be deleted once it is hit.
- -------------------------------------------------------
- watch condition Set a watchpoint for given condition. Program will suspend when condition is true.
- -------------------------------------------------------
- clear
- clear function
- clear line-number Delete breakpoints as identified by command option.
- Delete all breakpoints in function
- -------------------------------------------------------
- Delete breakpoints at given line
- delete Delete all breakpoints, watchpoints, or catchpoints.
- delete breakpoint-number
- delete range Delete the breakpoints, watchpoints, or catchpoints specified by number or ranges.
- -------------------------------------------------------
- disable breakpoint-number
- disable range
- -------------------------------------------------------
- enable breakpoint-number
- enable range Enable/Disable breakpoints, watchpoints or catchpoints specified by number or ranges.
- enable breakpoint-number once Enables given breakpoint once. And disables it after it is hit.
- -------------------------------------------------------
- continue
- c Continues/Resumes running the program until the next breakpoint or end of program
- continue number Continue but ignore current breakpoint number times.
- -------------------------------------------------------
- finish Continue until the current function is finished
- -------------------------------------------------------
- step Runs the next line of the program
- step N Runs the next N lines of program
- -------------------------------------------------------
- next Like s, but it does not step into functions
- print var Prints the current value of the variable "var"
- set var=val Assign "val" value to the variable "var"
- backtrace Prints a stack trace
- q Quit from gdb
External Links
http:///wiki/?gbddebugger