gdb 6.3 中多个堆栈之间的切换
程序中有两个堆栈:一个是由操作系统创建的,第二个是由程序本身创建的,用于运行一些代码。
当程序在第二个堆栈中崩溃时,我想切换到gdb中的主堆栈并查看回溯。是否可以?
我尝试将 rsp 保存到变量并在崩溃后更改它,但生成的回溯不正确。我认为 gdb 无法区分堆栈中的帧。
There are two stacks in the program: one is created by OS and the second is created by program itself to run some code with it.
When the program crashes in the second stack, I want to switch to the main stack in gdb and see the backtrace. Is it possible?
I tried to save the rsp to a variable and change it after the crash, but the resulting backtrace was not right. I think gdb cannot differentiate frames in stack.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您的方法是正确的,即恢复一些寄存器值以将 GDB 指向正确的堆栈。很难知道您的应用程序在没有任何源代码的情况下如何工作,但对于下面非常简单的 make/swapcontext 应用程序来说:
set $...
命令可以将寄存器设置为其保存的值GDB 此时bt
将找到旧堆栈。I think you were right with the approach of just restoring some register values to point GDB at the right stack. It's difficult to know how your application may have worked without any of its source, but for the very simple make/swapcontext application below:
The
set $...
command can set registers to their saved values from within GDB at which pointbt
will find the old stack.如果您有两个线程和两个堆栈,您可以通过“信息线程”查询线程。
在知道要查看哪个线程的堆栈后,使用“thread”命令选择它。将线程号放在命令后面。
那么你只需要通过'bt'查询堆栈即可
If you have two threads with two stacks you can query the thread by 'info threads'.
After you know which thread's stack you want to see select it with the 'thread' command. Put the number of the thread after the command.
Then you only need to query the stack by 'bt'