這是我在 cli 上調試快速內容的例程:
$ gcc myprogram.c -g -o myprogram $ gdb -tui myprogram (gdb) break main (gdb) run
您將使程式運行並在 main 處停止。之後,這是我最常用的指令:
Command | Short version | Description |
---|---|---|
step | s | Step in |
next | n | Step over |
until 123 | unt 123 | Run until line 123 |
info locals | i lo | Prints local variables |
print myvar | p myvar | Prints myvar value once |
display myvar | disp myvar | Displays myvar value on every execution |
undisplay myvar | und myvar | Stops displaying myvar value |
set myvar = 0 | s myvar = 0 | Sets the value of myvar to 0 |
break 456 | b 456 | Adds a breakpoint on line 456 |
info breakpoints | i b | Lists all breakpoints |
delete | d | Delete all breakpoints |
list main | l main | Go to function main |
list foo.c:789 | l foo.c:789 | Go to file foo.c on line 789 |
where | whe | Prints where the execution is at right now |
kill | k | Kills the current execution |
如果需要,Ctrl-l 會刷新螢幕。 focus cmd 使箭頭鍵在命令列上工作,focus src 使其捲動顯示的原始碼。
以上是使用gdb快速調試的詳細內容。更多資訊請關注PHP中文網其他相關文章!