dwarf2 中的堆栈展开

发布于 2024-10-20 22:27:53 字数 334 浏览 5 评论 0原文

我不明白 dwarf2 中的堆栈展开如何确保在一些非常基本的 ABI(应用程序二进制接口)场景中参数的可靠恢复。考虑 ABI,它规定前三个参数必须位于寄存器上并位于堆栈上。据我了解,dwarf2 堆栈展开机制确保如果正确填充 CFI 表,就可以在当前帧的调用点获取寄存器的值。然而,这并不能让您进入调用者的序言并知道参数寄存器的内容是什么。因此,我认为应该有一种方法可以找到寄存器的值,即使在同一帧的不同点(.debug_frame 部分中编码的表仅给出前一帧中的位置)。

我的理解有什么问题吗?在这种情况下,基于 dwarf2 调试格式的调试器如何工作?对于参数在堆栈上传递的体系结构,恢复程序中所有点(对于任何帧)的值不会有任何问题。

I don't understand that how the stack unwinding in dwarf2 ensures reliable recovery of arguments in some very basic ABI(Application Binary Interface) scenarios. Consider a ABI, which says that the first three arguments have to be on registers and rest on stack. As I understand the dwarf2 stack unwinding mechanism ensures that if the CFI table is filled properly, one can get the values of registers at the call point of current frame. This, however, doesn't let you to go up to the prologue of caller and know what were the contents of argument registers. So, I think there should have been a way to find the values of registers even in the same frame at different points (the table encoded in .debug_frame section only gives the locations in the previous frame).

Is there anything wrong in my understanding? How do debuggers based on dwarf2 debugging formats work in such cases? For the architectures where arguments are passed on stack, there will not be any issue to recover the values at all points in program (for any frame).

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

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

发布评论

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

评论(1

蝶舞 2024-10-27 22:27:53

我想我当时的理解并不正确。 dwarf2 中堆栈展开的工作方式是使用调用帧信息 (CFI)。这将使调试器创建前一帧之一的状态。该帧的位置表达式将使调试器知道参数的位置。

I think my understanding wasn't correct at that time. The way stack unwinding works in dwarf2 is by using Call Frame Information (CFI). This will let debugger create the state of one of the previous frames. The location expressions for that frame will let debugger know about the location of the arguments.

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