gpt4 book ai didi

linux - gdb 命令 "until"如何能够跳过循环?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:41:19 24 4
gpt4 key购买 nike

我很好奇gdb是如何实现until命令的。

我的意思是,我能理解“完成”是如何工作的,我们知道在一个函数的开始和结束处,有代码例程来操作 ebp/esp 寄存器,所以 gdb 可以使用它来执行到函数的结束.

但我的问题是,gdb 是如何知道循环结束的?如果没有提供调试符号,我们知道循环可能嵌入另一个内部循环,因此依赖 ecx 寄存器不是解决方案。那它怎么知道一个循环的结束呢? "while""do/while"和 "for"的汇编代码可能不同,不确定是否有 "finish"命令可以查找的模式。

希望看到你的解释。

最佳答案

how does gdb know the end of a loop?

事实并非如此。来自 documentation :

until
Continue running until a source line past the current line, in the current stack
frame, is reached.

This command is used to avoid single stepping through a loop more than once.
It is like the next command, except that when until encounters a jump, it
automatically continues execution until the program counter is greater
than the address of the jump.

它的实现与上面最后一条语句中描述的几乎完全一样。

关于linux - gdb 命令 "until"如何能够跳过循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42456617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com