Trace程式crash時滿好用的.
在Android上, 有程式crash時,
通常會產生一串資訊, 重點如下:
10-31 22:50:29.231 F/DEBUG ( 5121): backtrace:
10-31 22:50:29.231 F/DEBUG ( 5121): #00 pc 00000000000ca8c4 /system/lib64/libsurfaceflinger.so (_ZNK4HWC25Layer11isAbandonedEv+56)
10-31 22:50:29.231 F/DEBUG ( 5121): #01 pc 00000000000be370 /system/lib64/libsurfaceflinger.so (_ZN7android5Layer11hasHwcLayerEi+372)
10-31 22:50:29.231 F/DEBUG ( 5121): #02 pc 00000000000bc33c /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger15setUpHWComposerEv+2312)
10-31 22:50:29.231 F/DEBUG ( 5121): #03 pc 00000000000bb03c /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger20handleMessageRefreshEv+108)
10-31 22:50:29.231 F/DEBUG ( 5121): #04 pc 00000000000bae3c /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger17onMessageReceivedEi+124)
10-31 22:50:29.231 F/DEBUG ( 5121): #05 pc 0000000000015e58 /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+336)
10-31 22:50:29.231 F/DEBUG ( 5121): #06 pc 0000000000015c54 /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+60)
10-31 22:50:29.231 F/DEBUG ( 5121): #07 pc 000000000008f620 /system/lib64/libsurfaceflinger.so (_ZN7android12MessageQueue11waitMessageEv+92)
10-31 22:50:29.231 F/DEBUG ( 5121): #08 pc 00000000000b9990 /system/lib64/libsurfaceflinger.so (_ZN7android14SurfaceFlinger3runEv+20)
10-31 22:50:29.232 F/DEBUG ( 5121): #09 pc 0000000000002d08 /system/bin/surfaceflinger (main+960)
10-31 22:50:29.232 F/DEBUG ( 5121): #10 pc 000000000001ba78 /system/lib64/libc.so (__libc_init+88)
10-31 22:50:29.232 F/DEBUG ( 5121): #11 pc 00000000000028a8 /system/bin/surfaceflinger (do_arm64_start+80)
addr2line就是幫助你從這堆東西裡面,
找出在哪段程式碼出錯的工具.
ex:
./aarch64-linux-android-addr2line -e ~/work/BSP/android/out/target/product/Cell/symbols/system/lib64/libsurfaceflinger.so 00000000000ca8c4
注意, 必須是要在out/target/product/[project]/symbol下面的
他會顯示出錯誤的地方在哪個檔案, 第幾行.