Android uses addr2line to analyze error information, androidaddr2line
System: Ubuntu12.04
Mobile phone system: Android5.0
There will be a lot of bugs in the development process of Android. Using tools can help us analyze problems, especially the stack will be printed out in some system error messages, based on the stack error message, we can locate the file and code error. Next we will record the process of using addr2line.
First, compile an eng version on the computer and install it on the mobile phone. An error occurred during testing or debugging. The error message is as follows:
01-23 11:45:38.782 D/AEE/AED (10995): coredump_socket_create: 1090501-23 11:45:38.783 I/AEE/AED (10995): $** *** *** *** *** *** *** *** Exception *** *** *** *** *** *** *** **$01-23 11:45:38.783 I/AEE/AED (10995): Build Info: 'L0:ALPS.L0.MP6.V3_GIONEE6752.LWT.L:MT6752:S01,GiONEE/GN9006/GN9006:5.0/LRX21M/1421905945:eng/release-keys'01-23 11:45:38.784 I/AEE/AED (10995): Flavor Info: 'None'01-23 11:45:38.784 I/AEE/AED (10995): Exception Log Time:[Fri Jan 23 11:45:38 CST 2015] [65998.900000]01-23 11:45:38.784 I/AEE/AED (10995): 01-23 11:45:38.785 I/AEE/AED (10995): Exception Class: Native (NE)01-23 11:45:38.785 I/AEE/AED (10995): Exception Type: SIGSEGV01-23 11:45:38.785 I/AEE/AED (10995): 01-23 11:45:38.785 I/AEE/AED (10995): Current Executing Process: 01-23 11:45:38.785 I/AEE/AED (10995): pid: 10905, tid: 1094401-23 11:45:38.785 I/AEE/AED (10995): com.gionee.gallery01-23 11:45:38.785 I/AEE/AED (10995): 01-23 11:45:38.786 I/AEE/AED (10995): Backtrace: 01-23 11:45:38.786 I/AEE/AED (10995): #00 pc 0000b23c /system/lib/libz.so (inflate+712)01-23 11:45:38.786 I/AEE/AED (10995): #01 pc 000187e3 /system/lib/libpng.so (png_read_IDAT_data+210)01-23 11:45:38.786 I/AEE/AED (10995): #02 pc 0000d965 /system/lib/libpng.so (png_read_row+288)01-23 11:45:38.786 I/AEE/AED (10995): #03 pc 0000db7d /system/lib/libpng.so (png_read_rows+56)01-23 11:45:38.786 I/AEE/AED (10995): #04 pc 001d9aec /system/lib/libskia.so (SkPNGImageDecoder::onDecodeSubset(SkBitmap*, SkIRect const&)+2412)01-23 11:45:38.786 I/AEE/AED (10995): #05 pc 001cf1dc /system/lib/libskia.so (SkImageDecoder::decodeSubset(SkBitmap*, SkIRect const&, SkColorType, int, void*)+108)01-23 11:45:38.786 I/AEE/AED (10995): #06 pc 00095107 /system/lib/libandroid_runtime.so01-23 11:45:38.786 I/AEE/AED (10995): #07 pc 000178f9 /data/dalvik-cache/arm/system@framework@boot.oat01-23 11:45:38.786 I/AEE/AED (10995): 01-23 11:45:38.786 I/AEE/AED (10995): $** *** *** *** *** *** *** *** Exception *** *** *** *** *** *** *** **$01-23 11:45:38.786 D/AEE/AED (10995): aed_report_dumpstate: filepath /sdcard/mtklog/aee_exp/temp/db.LjXvBw, pid 10905, tid 10944, exp_class 1, db_opt 0
If you want to find this line
#01 pc 000187e3/system/lib/libpng. so (png_read_IDAT_data + 210)
Error code information can be found on the computer (in the android directory of your compilation system): libpng. so
The search result is as follows:
dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$ find -name libpng.so./out/target/product/gionee6752_lwt_l/obj_arm/lib/libpng.so./out/target/product/gionee6752_lwt_l/obj_arm/SHARED_LIBRARIES/libpng_intermediates/LINKED/libpng.so./out/target/product/gionee6752_lwt_l/obj/lib/libpng.so./out/target/product/gionee6752_lwt_l/obj/SHARED_LIBRARIES/libpng_intermediates/LINKED/libpng.so./out/target/product/gionee6752_lwt_l/symbols/system/lib/libpng.so./out/target/product/gionee6752_lwt_l/symbols/system/lib64/libpng.so./out/target/product/gionee6752_lwt_l/system/lib/libpng.so./out/target/product/gionee6752_lwt_l/system/lib64/libpng.so./out/target/product/gionee_backup/symbols/system/lib/libpng.so./out/target/product/gionee_backup/symbols/system/lib64/libpng.sodzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$
The two rows contain the symbols characters.
./Out/target/product/gionee6752_lwt_l/symbols/system/lib/libpng. so
./Out/target/product/gionee6752_lwt_l/symbols/system/lib64/libpng. so
In this way, you can use addr2line to find the number of wrong file lines. Note that the version you burned to your mobile phone must be consistent with the version on your computer. This data is accurate.
dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$ addr2line -e ./out/target/product/gionee6752_lwt_l/symbols/system/lib/libpng.so 000187e3/home/dzt/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp/external/libpng/pngrutil.c:3995dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$ addr2line -e ./out/target/product/gionee6752_lwt_l/symbols/system/lib64/libpng.so 000187e3/home/dzt/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp/external/libpng/pngrtran.c:105dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$
If the corresponding number of rows is found, this result will be output.
dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$ addr2line -e ./out/target/product/gionee6752_lwt_l/system/lib/libpng.so 000187e3??:0dzt@dzt-All-Series:~/D/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$
In this way, you can find the wrong line of code by printing the stack information, which is more helpful for us to locate the problem.
This section describes a method for printing stacks.
Open the call stack method, and throw an exception of a null pointer in the case of an error, and then print the stack.
Public void setSpeakerphoneOn (boolean on ){
IAudioService service = getService ();
Try {
Throw new NullPointerException ("the debug exception for speaker ");
Service. setSpeakerphoneOn (on );
} Catch (RemoteException e ){
Log. e (TAG, "Dead object in setSpeakerphoneOn", e );
} Catch (NullPointerException e ){
E. printStackTrace ();
}
}