-
Notifications
You must be signed in to change notification settings - Fork 0
/
GDB Commands.txt
38 lines (37 loc) · 1.91 KB
/
GDB Commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Relevant gdb commands I've gathered over time:
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)