如何根据gdb中的函数名称跳转到堆栈跟踪中的帧?
我正在调试由于无限递归而导致的堆栈溢出。当堆栈达到 700 次调用深度时,程序将失败。
我想跳转到最初调用该函数的框架。然而,gdb 一次向我显示堆栈顶部大约 20 个条目的堆栈跟踪,我想知道是否可以以某种方式直接跳到调用函数,而无需查看堆栈跟踪来查找其编号。
为此,我希望能够根据堆栈帧的名称而不是编号跳转到堆栈帧。
这可以在gdb中完成吗?
I'm debugging a stack overflow due to infinite recursion. The program fails when the stack is 700 calls deep.
I want to jump to the frame in which the function was initially called. However, gdb shows me the stack trace from the top of the stack about 20 entries at a time, and I wonder if I can somehow skip straight to the calling function without looking through the stack trace to find its number.
To that end, I want to be able to jump to a stack frame based on its name instead of its number.
Can this be done in gdb?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
两个选项:
up 200
将为您带来 200 帧f[rame]
-这将跳转到地址caller-func
的帧。请参阅手册中的框架选择。
Two options:
up 200
will bring you up 200 framesf[rame] <caller-func>
- this will jump to the frame of addresscaller-func
.See Frame Selection in the manual.
您必须将
bt
与减号一起使用。它与bt
类似,但首先打印最外面的n帧。例如:
BT -100
您很可能会在第一个或第二个屏幕上看到需要检查的框架。
一旦使用
bt -100
检测堆栈跟踪,我就可以轻松修复包含大量递归调用的问题。然后发出命令
f <这里是您需要检查的帧的编号>
You have to use
bt
with minus. It is similar tobt
, but print first the outermost n frames.For example:
bt -100
And it is likely you will see the frame that you need to inspect on the first or second screen.
Once insecting the stack trace using
bt -100
helped me to fix a pboblem with a lot of recursive calls easily.And then issue command
f <here the number of your frame you need to inspect>