如何在GDB中运行之前的指令?

发布于 12-27 12:14 字数 209 浏览 3 评论 0原文

在这里我想问这个问题。当我调试程序时,有时我希望能够再次运行之前的指令。就像在 Microsoft Visual Studio 中一样,我们可以将位置指示器(记住黄色箭头)拖动到您要查找的上一条指令。

例如:

我的程序当前位于第 72 行,假设第 70 行与第 72 行所在的函数相同。现在我想再次重新运行第 70 行。有什么办法可以做到这一点吗?

谢谢。

Here I want to ask this question. When I am debugging a program, sometimes I wish I can run a previous instruction again. Like in Microsoft Visual Studio, we can drag the position indicator (remember the yellow arrow) to the previous instruction you want to locate.

For example:

My program is currently at line 72, and suppose line 70 is in the same function that line 72 sits in. Now I want to re-run line 70 again. Is there any way to do that?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

日久见人心2025-01-03 12:14:32

我想再次重新运行第 70 行

使用 GDB jump 命令

I want to re-run line 70 again

Use the GDB jump command.

緦唸λ蓇2025-01-03 12:14:32

您通常可以使用 call 命令调用 gdb 中的函数:

(gdb) call some_function(arg1, arg2);

但是,如果您想专门返回程序,您始终可以找到相关行的内存位置并将指令指针设置为它。

(gdb) set $eip = <some memory address>

话虽如此,我不知道有什么方法可以完全“放松”程序的状态(如果 Visual Studio 就是这样做的话)。换句话说,任何其他程序状态在第二次时可能会有所不同。

You can normally call functions within gdb with the call command:

(gdb) call some_function(arg1, arg2);

However, if you want to specifically go back the program, you could always find the memory location of the line in question and set the instruction pointer to it.

(gdb) set $eip = <some memory address>

That being said, I don't know of a way to fully "unwind" the program's state, if that's what Visual Studio does. In other words, any other program state may be different the second time through.

旧人2025-01-03 12:14:32

使用gdb命令跳转,eg:

jump 70

Use gdb command jump, e.g.:

jump 70
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文