gdb - 如何一次性获取 gdb 中的整个堆栈跟踪?

标签 gdb kernel

我正在调试内核,显然错误处理程序在 ARM 上运行的方式是它们在到达任何实际代码之前要经过数百层 __pabt_usr。不管怎样,我通过模拟器远程进行调试,并且一点一点地获取跟踪很慢。有没有办法一次性获取全部内容?

编辑:反向打印堆栈跟踪也会有帮助。

最佳答案

我不知道是否可以给出完整的回溯,但您可以向“bt”提供数字参数以获取更多帧:

(gdb) bt 10
#0  x () at test.c:4
#1  0x080483bf in x () at test.c:4
#2  0x080483bf in x () at test.c:4
#3  0x080483bf in x () at test.c:4
#4  0x080483bf in x () at test.c:4
#5  0x080483bf in x () at test.c:4
#6  0x080483bf in x () at test.c:4
#7  0x080483bf in x () at test.c:4
#8  0x080483bf in x () at test.c:4
#9  0x080483bf in x () at test.c:4
(More stack frames follow...)

这也适用于负数,它给出最外层的框架:

(gdb) bt -2
#122467 0x080483bf in x () at test.c:4
#122468 0x080483bf in x () at test.c:4

因此,如果您需要最后几帧,可以使用负数。

关于gdb - 如何一次性获取 gdb 中的整个堆栈跟踪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4292581/

相关文章:

c - 了解 C 中的栈帧

objective-c - 运行代码返回垃圾;在调试器中输入会返回正确的结果

kernel - 内核中的native_write_msr是做什么的?

android - 这个内核源码能用吗?

macos - 进程在调试器中崩溃;我怎么杀掉它

gdb - 从核心文件恢复程序状态

c++ - gdb 错误 : Unable to execute epoll_wait: (4) Interrupted system call

c - 在 linux 中的中断上下文中运行用户线程

c - 从 Linux 内核运行外部二进制文件

c - 使用 netlink 从旧内核上的套接字获取 inode