3

I need to see a stack trace in AOSP C/C++ code. I have found some solutions but all of them not show properly function's names.

1. The solution from http://yongbingchen.github.io/blog/2013/05/09/dump-stack-in-android-native-c-code/ gives the following result:
01-22 11:19:24.737 CallStack ( 3304): #00 pc 0004440b /system/lib/hw/bluetooth.default.so (dump_stack_android+42) 01-22 11:19:24.737 CallStack ( 3304): #01 pc 0008b7f5 /system/lib/hw/bluetooth.default.so (btif_gatt_check_encrypted_link+32) 01-22 11:19:24.737 CallStack ( 3304): #02 pc 0008870f /system/lib/hw/bluetooth.default.so 01-22 11:19:24.737 CallStack ( 3304): #03 pc 0007ea5f /system/lib/hw/bluetooth.default.so 01-22 11:19:24.737 CallStack ( 3304): #04 pc 00126c5f /system/lib/hw/bluetooth.default.so 01-22 11:19:24.737 CallStack ( 3304): #05 pc 00125673 /system/lib/hw/bluetooth.default.so 01-22 11:19:24.737 CallStack ( 3304): #06 pc 00126963 /system/lib/hw/bluetooth.default.so 01-22 11:19:24.737 CallStack ( 3304): #07 pc 00047313 /system/lib/libc.so (_ZL15__pthread_startPv+22) 01-22 11:19:24.737 CallStack ( 3304): #08 pc 00019e5d /system/lib/libc.so (__start_thread+6)

As you can see the lines from #02 to #06 have no function's names

2. The solution from https://stackoverflow.com/a/28858941/10691263 working fine for the desctop project after adding -rdynamic flag. However, after integrating this code with AOSP I got the same result as in the previous example.
It looks like some symbols in bluetooth.default.so are hidden. I tried to change -fvisibility flag in Android.mk from hidden to default but received the following compiling error: system/bt/btcore/src/hal_util.c:90: error: undefined reference to 'hw_get_module' clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Please help me find a solution that will be able to show a callstack with all function's names for AOSP.

  • `not show properly function's names` the function names (or function themselves) are probably removed after the code is compiled. You can try to compile with debugging symbols enabled and try writing some smart library that in case of call stack dump will try to extract the debugging symbols from specified program location, but you will / can still see some functions names missing (inlined, optimized, merged, etc...). C is not java, in C there is only assembly. – KamilCuk Jan 23 '19 at 10:15

0 Answers0