Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get function names from call stack

I am working on an Android program which calls in to native code. That native code is segfaulting, and since getting debugging working through the android NDK is not really doable, I'm left with a callstack like the following (captured from ddms). My question is whether there is something I can manually run after the fact to translate the memory addresses in the callstack to function names so I can see where this is segfaulting.

Thanks

02-22 14:47:39.231: DEBUG/dalvikvm(504): Trying to load lib /data/data/android.TestApp/lib/libDM.so 0x43b7c938
02-22 14:47:39.301: DEBUG/dalvikvm(504): Added shared lib /data/data/android.TestApp/lib/libDM.so 0x43b7c938
02-22 14:47:39.310: DEBUG/dalvikvm(504): No JNI_OnLoad found in /data/data/android.TestApp/lib/libDM.so 0x43b7c938
02-22 14:47:39.406: DEBUG/dalvikvm(504): +++ not scanning '/system/lib/libwebcore.so' for 'onLoadModel' (wrong CL)
02-22 14:47:39.410: DEBUG/dalvikvm(504): +++ not scanning '/system/lib/libmedia_jni.so' for 'onLoadModel' (wrong CL)
02-22 14:47:39.410: DEBUG/dalvikvm(504): +++ not scanning '/system/lib/libexif.so' for 'onLoadModel' (wrong CL)
02-22 14:47:39.410: DEBUG/dalvikvm(504): +++ not scanning '/system/lib/libsrec_jni.so' for 'onLoadModel' (wrong CL)
02-22 14:47:39.569: INFO/DEBUG(28): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-22 14:47:39.569: INFO/DEBUG(28): Build fingerprint: 'generic/sdk/generic/:2.1/ERD79/22607:eng/test-keys'
02-22 14:47:39.569: INFO/DEBUG(28): pid: 504, tid: 504  >>> android.TestApp <<<
02-22 14:47:39.569: INFO/DEBUG(28): signal 11 (SIGSEGV), fault addr 00000008
02-22 14:47:39.581: INFO/DEBUG(28):  r0 00000000  r1 00000068  r2 00002350  r3 80facc00
02-22 14:47:39.581: INFO/DEBUG(28):  r4 beb3c918  r5 000024b8  r6 fffacafc  r7 0000aa98
02-22 14:47:39.581: INFO/DEBUG(28):  r8 00000000  r9 000024b8  10 fffacafc  fp 00000000
02-22 14:47:39.581: INFO/DEBUG(28):  ip afbc30c8  sp beb3c858  lr 80dffdf3  pc 80dfb18a  cpsr 40000030
02-22 14:47:39.711: INFO/DEBUG(28):          #00  pc 001fb18a  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:39.733: INFO/DEBUG(28):          #01  pc 001ffdee  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:39.740: INFO/DEBUG(28):          #02  pc 0031cc2c  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:39.754: INFO/DEBUG(28):          #03  pc 0031cd74  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:39.761: INFO/DEBUG(28):          #04  pc 0000f1f4  /system/lib/libdvm.so
02-22 14:47:39.769: INFO/DEBUG(28):          #05  pc 00038018  /system/lib/libdvm.so
02-22 14:47:39.779: INFO/DEBUG(28):          #06  pc 000316a2  /system/lib/libdvm.so
02-22 14:47:39.790: INFO/DEBUG(28):          #07  pc 0003d31c  /system/lib/libdvm.so
02-22 14:47:39.810: INFO/DEBUG(28):          #08  pc 00013f58  /system/lib/libdvm.so
02-22 14:47:39.810: INFO/DEBUG(28):          #09  pc 00019888  /system/lib/libdvm.so
02-22 14:47:39.820: INFO/DEBUG(28):          #10  pc 00018d5c  /system/lib/libdvm.so
02-22 14:47:39.846: INFO/DEBUG(28):          #11  pc 0004d3bc  /system/lib/libdvm.so
02-22 14:47:39.852: INFO/DEBUG(28):          #12  pc 00054e74  /system/lib/libdvm.so
02-22 14:47:39.871: INFO/DEBUG(28):          #13  pc 00013f58  /system/lib/libdvm.so
02-22 14:47:39.871: INFO/DEBUG(28):          #14  pc 00019888  /system/lib/libdvm.so
02-22 14:47:39.889: INFO/DEBUG(28):          #15  pc 00018d5c  /system/lib/libdvm.so
02-22 14:47:39.889: INFO/DEBUG(28):          #16  pc 0004d6d0  /system/lib/libdvm.so
02-22 14:47:39.900: INFO/DEBUG(28):          #17  pc 0003a72c  /system/lib/libdvm.so
02-22 14:47:39.909: INFO/DEBUG(28):          #18  pc 0002be52  /system/lib/libdvm.so
02-22 14:47:39.921: INFO/DEBUG(28):          #19  pc 00026cf4  /system/lib/libandroid_runtime.so
02-22 14:47:39.930: INFO/DEBUG(28):          #20  pc 000279d8  /system/lib/libandroid_runtime.so
02-22 14:47:39.940: INFO/DEBUG(28):          #21  pc 00008cae  /system/bin/app_process
02-22 14:47:39.949: INFO/DEBUG(28):          #22  pc 0000c2c6  /system/lib/libc.so
02-22 14:47:39.969: INFO/DEBUG(28):          #23  pc b00018aa  /system/bin/linker
02-22 14:47:39.981: INFO/DEBUG(28): code around pc:
02-22 14:47:39.981: INFO/DEBUG(28): 80dfb178 fffaaac8 4656b570 4644464d 4680b470 
02-22 14:47:39.981: INFO/DEBUG(28): 80dfb188 6883b081 1c0d1c08 22b04798 46814442 
02-22 14:47:39.981: INFO/DEBUG(28): 80dfb198 46921c10 f73d2600 4642ea90 6c546c13 
02-22 14:47:39.981: INFO/DEBUG(28): code around lr:
02-22 14:47:39.981: INFO/DEBUG(28): 80dffde0 1c064a0b 589b447b 681c1c31 f7fb1c20 
02-22 14:47:39.981: INFO/DEBUG(28): 80dffdf0 1c05f9c5 d0062800 d0042c00 23001c32 
02-22 14:47:39.981: INFO/DEBUG(28): 80dffe00 f7fb1c20 1c28fa15 0000bd70 001a47f8 
02-22 14:47:39.981: INFO/DEBUG(28): stack:
02-22 14:47:39.981: INFO/DEBUG(28):     beb3c818  afe42ad4  
02-22 14:47:39.981: INFO/DEBUG(28):     beb3c81c  ad07ff50  /system/lib/libdvm.so
02-22 14:47:39.990: INFO/DEBUG(28):     beb3c820  0000bd00  [heap]
02-22 14:47:39.990: INFO/DEBUG(28):     beb3c824  00000000  
02-22 14:47:39.990: INFO/DEBUG(28):     beb3c828  00085920  [heap]
02-22 14:47:40.000: INFO/DEBUG(28):     beb3c82c  00000000  
02-22 14:47:40.000: INFO/DEBUG(28):     beb3c830  ffffffff  
02-22 14:47:40.000: INFO/DEBUG(28):     beb3c834  beb3c850  [stack]
02-22 14:47:40.015: INFO/DEBUG(28):     beb3c838  00000000  
02-22 14:47:40.015: INFO/DEBUG(28):     beb3c83c  00000000  
02-22 14:47:40.022: INFO/DEBUG(28):     beb3c840  ad563b21  /system/lib/libicuuc.so
02-22 14:47:40.022: INFO/DEBUG(28):     beb3c844  00085968  [heap]
02-22 14:47:40.030: INFO/DEBUG(28):     beb3c848  00000001  
02-22 14:47:40.050: INFO/DEBUG(28):     beb3c84c  00000000  
02-22 14:47:40.061: INFO/DEBUG(28):     beb3c850  df002777  
02-22 14:47:40.061: INFO/DEBUG(28):     beb3c854  e3a070ad  
02-22 14:47:40.070: INFO/DEBUG(28): #00 beb3c858  ad065714  /system/lib/libdvm.so
02-22 14:47:40.070: INFO/DEBUG(28):     beb3c85c  beb3c918  [stack]
02-22 14:47:40.070: INFO/DEBUG(28):     beb3c860  000024b8  
02-22 14:47:40.090: INFO/DEBUG(28):     beb3c864  fffacafc  
02-22 14:47:40.090: INFO/DEBUG(28):     beb3c868  00000000  
02-22 14:47:40.100: INFO/DEBUG(28):     beb3c86c  80faed2c  
02-22 14:47:40.100: INFO/DEBUG(28):     beb3c870  00000068  
02-22 14:47:40.122: INFO/DEBUG(28):     beb3c874  80dffdf3  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:40.122: INFO/DEBUG(28): #01 beb3c878  80f510dc  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:40.122: INFO/DEBUG(28):     beb3c87c  80faed2c  
02-22 14:47:40.122: INFO/DEBUG(28):     beb3c880  80fa45e0  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:40.122: INFO/DEBUG(28):     beb3c884  80f1cc31  /data/data/android.TestApp/lib/libDM.so
02-22 14:47:41.240: DEBUG/Zygote(30): Process 504 terminated by signal (11)
like image 882
Matt McMinn Avatar asked Feb 22 '10 21:02

Matt McMinn


1 Answers

You should have a copy of arm-eabi-addr2line available in the NDK bin directory. You can use this with a command like:

arm-eabi-addr2line -f -e /path/to/lib/with/symbols.so 0x001fb18a

That will crawl through the debug symbols in the shared lib to get file and line number information. For best results hand it a library that hasn't had the debugging stuff stripped out.

like image 68
fadden Avatar answered Sep 25 '22 16:09

fadden