Last active
December 9, 2021 18:26
-
-
Save sabinM1/15fa868398a19fdebbcaf52102885a3a to your computer and use it in GitHub Desktop.
gdb commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
info gdb //Manual | |
info locals //Vars in local scope | |
info variables //Vars declared outside current scope | |
info functions //Names and datatypes of all defined functions | |
info b //List all breakpoints | |
break funcName //Set breakpoint at function funcName (short: b funcName) | |
break file::line //Set breakpoint at line in file | |
layout next //Cycle through the layouts of gdb | |
p var //Print the value of variable var | |
p var = value //Force set value to a var | |
run //Start the program | |
start //Synonymous to (b main && run). Puts temporary b at main | |
next //Execute the current line in source (short: n) | |
step //Step into function call at current line (short: s) | |
finish //Finish the execution of current function (short: fin) | |
continue //Resume execution (After a breakpoint) (short: c) | |
refresh //Repaint the interface (To fix corrupted interface) | |
shell cmd //Run shell command cmd from gdb prompt | |
python gdb.execute(cmd) //Run a gdb command cmd from python prompt | |
set print pretty on //Enable pretty printing (Put in ~/.gdbinit) | |
$ gdb -c core.num //Examine the dumped core file from a SIGSEGV(shell command) | |
bt //Print backtrace | |
break _exit //Breakpoint at exit of program | |
whatis expr //Print datatype of expr | |
ptype expr //Detailed print of datatype of expr | |
watch var //Stop when var is modified | |
watch -l foo //Watch foo loaction | |
rwatch foo //Stop when foo is read | |
watch foo if foo>10 //Watch foo conditionally | |
delete //Delete all breakpoints | |
delete breakpoint_no //Delete breakpoint breakpoint_no | |
command breakpoint_no //Run user listed commands when breakpoint is hit (End list of commands with 'end') | |
file executable //Load the executable for debugging from inside gdb | |
quit //Quit (short: q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment