How to get native heap malloc's backtrace?

219 views
Skip to first unread message

gavinl...@gmail.com

unread,
Jul 13, 2017, 10:43:39 AM7/13/17
to android-porting

my phone is nexus 6 build aosp of shamu-userdebug which version is :
N6F26Uandroid-7.1.1_r28

I want to get my app native heap info the backtrace of malloc or other allocation. I followed  https://android.googlesource.com/platform/bionic/+/master/libc/malloc_debug/README.md.


for example:
i did this command:

adb shell stop
adb shell setprop libc.debug.malloc.options backtrace
adb shell setprop wrap.<my app name> '"LIBC_DEBUG_MALLOC_OPTIONS=backtrace logwrapper"'
adb shell start


but I get nothing from logcat.

As I expect, I would get the following information from logcat:

infomation of backtrace like this:

04-14 09:40:38.242  5029  5029 F DEBUG   : Build fingerprint: 'Android/aosp_shamu/shamu:7.1.1/N6F26U/:userdebug/test-keys'
04-14 09:40:38.242  5029  5029 F DEBUG   : Revision: '0'
04-14 09:40:38.246  5029  5029 F DEBUG   : ABI: 'arm'
04-14 09:40:38.246  5029  5029 F DEBUG   : pid: 5009, tid: 5009, name: putmethod.latin  >>> com.android.my app name <<<
04-14 09:40:38.246  5029  5029 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
04-14 09:40:38.246  5029  5029 F DEBUG   :     r0 00024104  r1 0002411c  r2 00000000  r3 00000000
04-14 09:40:38.246  5029  5029 F DEBUG   :     r4 00000000  r5 be9f1094  r6 000024b0  r7 0000004c
04-14 09:40:38.247  5029  5029 F DEBUG   :     r8 00000054  r9 00000004  sl 00000023  fp be9f1038
04-14 09:40:38.247  5029  5029 F DEBUG   :     ip be9f0fe8  sp be9f1020  lr b3296af9  pc a9fb5580  cpsr 600e0010
04-14 09:40:38.250  5029  5029 F DEBUG   : 
04-14 09:40:38.250  5029  5029 F DEBUG   : backtrace:
04-14 09:40:38.250  5029  5029 F DEBUG   :     #00 pc 000c2580  /system/lib/libjni_latinime.so (__cxa_get_globals+276)
04-14 09:40:38.250  5029  5029 F DEBUG   :     #01 pc 000c280c  /system/lib/libjni_latinime.so (__cxa_begin_catch+12)
04-14 09:40:38.250  5029  5029 F DEBUG   :     #02 pc 0007a1d0  /system/lib/libjni_latinime.so


so, How to get malloc's backtrace ? 

thx
kun
Reply all
Reply to author
Forward
0 new messages