我正在调试内核,显然错误处理程序在 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/