gcc -g myprog.c -o myprog
Start ddd and load program
ddd myprog
Load a program. (You can skip this step because we load the program in previous step)
file myprog
Breakpoints
Set a breakpoint at specific line (e.g. break at line 7 of myprog.c)break myprog.c:7
Set a breakpoint at when calling specific function (e.g break when myfunc is called)
break myfunc
Set a conditional breakpoint (e.g. variable myvar <= 3)
break myprog.c:7 if myvar <= 3
Show breakpoints
info breakpoints
Ignore specific breakpoint (e.g. ignore breakpoint 1 for 100 times. You can get number from "show breakpoints")
ignore 1 100
Delete a breakpoint (Delete breakpoint 1. You can get number from "show breakpoints")
delete 1
Control
Set watchpoint. (Stop execution when program changes the specific variable)watch myvar
Continue running after it hit a breakpoint
continue
Finish (Finish current function)
finish
Step Over (Trace into a function)
step
Next (Treat function as a normal statement)
next
Run/Restart the program
run
Variables
Print content of specific variable (e.g. print content of myvar)print myvar
Print in hexadecimal
print/X myvar
No comments:
Post a Comment