System: Ubuntu12.04
Mobile phone System: Android5.0
In the development process of Android there will be a lot of bugs, the use of tools can help us to analyze the problem, especially some system error messages will be printed on the stack, we can based on this stack error information to locate which file is the wrong line of code. Here's a record of my use of addr2line.
The first is to compile an eng version on the computer, burn to the phone, in the test or debugging process error, check 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): $** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **$01-23 11:45:38.783 i/aee/aed (10995): Build Info: ' L0:alps. Exception 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 11:45:38 CST 2015] [65998.900000]0 1-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): Curr ent 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/s Ystem/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 (SkBitma p*, Skirect const&) +2412) 01-23 11:45:38.786 i/aee/aed (10995): #05 pc 001cf1dc/system/lib/libskia.so (SkImageDec oder::d ecodesubset (skbitmap*, Skirect const&, skcolortype, int, void*) +108) 01-23 11:45:38.786 i/aee/aed (10995): # PC 00095107/system/lib/libandroid_runtime.so01-23 11:45:38.786 i/aee/aed (10995): #07 pc 000178f9/data/dalvik-c Ache/arm/[email protected] @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/MT klog/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 you compiled the system): libpng.so
Find the results below
[email protected]:~/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.so[email protected]:~/d/dzt/workarea/7501_mp_l/android_mtk_l6752_lwt_mp$
The useful information is these two lines, with the words symbols
./out/target/product/gionee6752_lwt_l/symbols/system/lib/libpng.so
./out/target/product/gionee6752_lwt_l/symbols/system/lib64/libpng.so
This allows you to use Addr2line to find the number of file rows that have been faulted, one thing to be aware that the version you burned to your phone is consistent with the version on your computer, and this data is accurate.
If the corresponding number of rows is found, the result will be output
This allows you to find the wrong line of code by printing the stack information to help us locate the problem.
Here's a way to print a stack
Open the method of the call stack, throw a null pointer to the exception where it is thought to be wrong, capture and print out 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 ();
}
}
Use Addr2line in Android to parse error messages