Debugging
如何使用 GDB 進行步入、跨步和退出?
我在 GDB 中輸入了內容
help
,但沒有找到任何有關 step-into、step-over 和 step-out 的資訊。_start
我在(break _start
)中的彙程式序中放置了一個斷點。之後我輸入next
並完成了調試。我想這是因為它完成了_start
,並沒有按我的意願介入。
help running
提供一些提示:有
step
和next
指令(還有nexti
和stepi
)。(gdb) help next Step program, proceeding through subroutine calls. Usage: next [N] Unlike "step", if the current source line calls a subroutine, this command does not enter the subroutine, but instead steps over the call, in effect treating it as a single source line.
所以我們可以看到進入
step
子程序,但會越過子程序。next
step
andstepi
(和next
and )通過nexti
“行”或“指令”增量來區分。step -- Step program until it reaches a different source line stepi -- Step one instruction exactly
相關的是
finish
:(gdb) help finish Execute until selected stack frame returns. Usage: finish Upon return, the value returned is printed and put in the value history.
更多有用的資訊位於https://sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html