print stack trace in arm-linux

做~自己de王妃 提交于 2019-12-01 22:40:13

问题


I followed this post to print stack trace How to generate a stacktrace when my gcc C++ app crashes . It works well in x86 linux. Can anyone teach me how to make it work on arm-linux?

I am using arm-linux-gcc 4.4.3.

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

in 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]

This is how I compile for arm-linux

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

回答1:


ARM does not store the return address on the stack when branching to a subroutine but rather expects any function calling subroutines to save the link register to its own stack frame before calling other functions, so it is impossible to follow stack frames without debug information.




回答2:


I just got backtrace() to work with GCC for ARM. The key for me was compiling with -funwind-tables. Otherwise the stack depth was always 1 (i.e. empty).



来源:https://stackoverflow.com/questions/10877377/print-stack-trace-in-arm-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!