I develop C++ application on ARM (Raspberry Pi, g++ (Raspbian 8.3.0-6+rpi1) 8.3.0 ). When I try to debug my code or the application crashes in my code, I get the correct callstack without any problem. But when the application crashes in external library or I step into external library in GDB, the callstack is lost and it does not contain anything useful except the function call.
For example, when I break at the beginning of memcpy function, I get the following:
(gdb) bt
#0 0x76fa4b5c in memcpy () at /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
#1 0x000e6118 in CWatchDog::ComputeBatteryPercentage(float) (this=0x2643140, voltage=3.96600008) at WatchDog.cpp:197
#2 0x000e5c24 in CWatchDog::BatteryControl(CWatchDog::RxPacketData const&) (this=0x2643140, data=...) at WatchDog.cpp:149
... etc ...
but when I step a few lines, after the instruction "vpush", I get only the following:
(gdb) bt
#0 0x76fa4b60 in memcpy () at /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
#1 0x00000000 in ()
Is there any posibility how to enable full call stacks in external functions? I tried building my code with -funwind-tables -fasynchronous-unwind-tables -mapcs-frame but it makes no difference.
It is common on many architectures that you must have either full debug info or a frame pointer for backtracing to work. Sometimes the ABI mandates the use of a frame pointer (in addition to a stack pointer), sometimes not. On architectures with relatively few registers it is useful to optimize away the frame pointer so the register can be used for other things. You can typically prevent it doing this in your own binaries using
-fno-omit-frame-pointer, but that doesn't help you with prebuilt binaries. (On some architectures you must have frame pointers; debug info alone is not enough.)Many Linux distributions provide additional debug packages to install alongside their library packages. These are often not installed by default in order to save disk space and reduce download sizes. GDB will look for the debug info files and use them if it can find them, but will not complain if it cannot.
Here is some information I found about Raspbian debug packages. I don't know if that's specifically what you need, but it shows they exist.