在arm-linux中打印堆栈跟踪

我按照这篇文章打印堆栈跟踪如何在我的gcc C ++应用程序崩溃时生成堆栈跟踪。 它在x86 linux中运行良好。 谁能教我如何让它在arm-linux上运行?

我正在使用arm-linux-gcc 4.4.3。

[root@FriendlyARM /]# ./test1 Error: signal 11: [0x0] 

在x86中

 mickey@mickeyvm:~/Desktop/workspace/test/testCatchSeg/src$ ./test1 Error: signal 11: ./test1(_Z7handleri+0x19)[0x804876d] [0xedd400] ./test1(_Z3bazv+0x10)[0x80487c2] ./test1(_Z3barv+0xb)[0x80487e1] ./test1(_Z3foov+0xb)[0x80487ee] ./test1(main+0x22)[0x8048812] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x84de37] ./test1[0x80486c1] 

这就是我为arm-linux编译的方法

  arm-linux-g++ -g -rdynamic ./testCatchSeg.cpp -o testCatchSeg 

在分支到子例程时,ARM不会将返回地址存储在堆栈中,而是在调用其他函数之前,期望任何调用子例程的函数将链接寄存器保存到自己的堆栈帧,因此无法在没有调试信息的情况下跟踪堆栈帧。

我刚刚使用backtrace()与GCC for ARM合作。 对我来说关键是使用-funwind-tables进行编译。 否则堆栈深度始终为1(即空)。