如何调试目标上的 stackoverflow 问题
我想知道我们如何继续调试目标上的 STACKOVERFLOW 问题。 我的意思是我们应该遵循哪些步骤才能得出结论。
I want to know how do we proceed to debug a STACKOVERFLOW issue on targets .
I mean what are the steps we should follow to reach a conclusion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将一个单词的内存写入观察点放置在堆栈空间末尾之后。然后,当该位置被写入时,调试器将中断,您可以看到出了什么问题。
Put a memory write watchpoint for one word past the end of your stack space. Then the debugger will break in when that spot gets written to, and you can see what's at fault.
所有堆栈都可以在启动时填充特定的十六进制值(例如 0xAAAAAAAA)。然后使用特殊例程,您可以通过计算堆栈末尾已知值(0xAA..)的数量来定期监视所有堆栈的最大使用量,直到找到第一个差异。
All stacks can be filled at start up with certain hex value (for example 0xAAAAAAAA). And then using special routine you can monitor all stack's maximum usage periodically by calculating the quantity of known values (0xAA..) from end of stack until finds the first difference.
通过 gdb 等调试器运行它。堆栈溢出时的回溯将准确地告诉您哪个或哪些函数正在无限重复。从那里,找出这些函数的哪些输入没有改变,并且不将函数(如果是递归的)移向将结束递归的基本情况。
Run it through a debugger such as gdb. The backtrace at the time of the stack overflow will tell you exactly which function or functions are repeating indefinitely. From there, figure out which input(s) to those functions are not changing, and not moving the function (if it's recursive) towards a base-case that will end the recursion.