GDB如何跨步、跨步、跨步?

Pic*_*ana 71 programming debugging gdb

help在 GDB 时打字,但没有找到任何关于进入、跨步和退出的信息。我在_start( break _start)的汇编程序中放置了一个断点。之后我打字next,它完成了调试。我猜是因为它完成了_start并且没有按照我的意愿进入

任何人都可以提供帮助?

Ste*_*ris 68

help running 提供了一些提示:

stepnext指令(还有nextistepi)。

(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.
Run Code Online (Sandbox Code Playgroud)

所以我们可以看到stepsteps进入子程序,但是next跳过子程序。

stepstepi(以及nextnexti)由“线”或“指令”的增量进行区分。

step -- Step program until it reaches a different source line
stepi -- Step one instruction exactly
Run Code Online (Sandbox Code Playgroud)

相关的是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.
Run Code Online (Sandbox Code Playgroud)

更多有用的信息位于https://sourceware.org/gdb/onlinedocs/gdb/Continuing-and-Stepping.html

  • 有没有办法走出去?我在帮助运行中找不到它。 (5认同)
  • GDB 中的“finish”或“fin”,是“IDEA”或“Eclipse”中的“step-out”。 (4认同)
  • 你所说的“走出去”是什么意思?`finish` 命令将完成当前堆栈帧,这通常会完成当前子程序并返回给调用者。 (3认同)
  • `for(i=0;i<10;i++) { printf("%d\n",i); }` 是一行源代码,但有多条指令。 (2认同)

小智 8

使用命令“完成”;这有时与“步出”执行相同的操作。它将完成堆栈正在执行的操作(通常是一个函数),然后转到下一行。查看命令以获取更多信息。