android native开发偶尔会遭遇native库异常导致程序崩溃,打入来的log如下:
06-05 18:52:57.566: I/DEBUG(8139): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 06-05 18:52:57.566: I/DEBUG(8139): Build fingerprint: 'htc_asia_wwe/htc_saga/saga:2.3.3/GRI40/27073:user/release-keys' 06-05 18:52:57.566: I/DEBUG(8139): pid: 8246, tid: 8258 >>> com.teon <<< 06-05 18:52:57.566: I/DEBUG(8139): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00883000 06-05 18:52:57.566: I/DEBUG(8139): r0 4c8869c0 r1 00882fe8 r2 00000600 r3 00000000 06-05 18:52:57.576: I/DEBUG(8139): r4 00000001 r5 00882628 r6 45882920 r7 00000010 06-05 18:52:57.576: I/DEBUG(8139): r8 00000000 r9 00882628 10 00001401 fp 00000000 06-05 18:52:57.576: I/DEBUG(8139): ip 80b091c8 sp 458828a8 lr 80e8cc7d pc afd0ceb8 cpsr 20000010 06-05 18:52:57.576: I/DEBUG(8139): d0 0000000000000000 d1 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d2 0000000000000000 d3 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d4 0000000000000000 d5 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d6 0000002800000000 d7 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d8 0000000000000000 d9 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d10 0000000000000000 d11 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d12 0000000000000000 d13 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d14 0000000000000000 d15 0000000000000000 06-05 18:52:57.576: I/DEBUG(8139): d16 401000004051c7e0 d17 7e37e43c8800759c 06-05 18:52:57.586: I/DEBUG(8139): d18 bf29d485528174dc d19 3ec6cd878c3b46a7 06-05 18:52:57.586: I/DEBUG(8139): d20 3fd5c6d5a10f7452 d21 3fce67efe86ccc15 06-05 18:52:57.586: I/DEBUG(8139): d22 3ff0000000000000 d23 0000000000000000 06-05 18:52:57.586: I/DEBUG(8139): d24 3ff0000000000000 d25 0000000000000000 06-05 18:52:57.586: I/DEBUG(8139): d26 0000000000000000 d27 0000000000000000 06-05 18:52:57.586: I/DEBUG(8139): d28 0000000000000000 d29 0000000000000000 06-05 18:52:57.596: I/DEBUG(8139): d30 0000000000000000 d31 0000000000000000 06-05 18:52:57.606: I/DEBUG(8139): scr 60000012 06-05 18:52:57.656: I/DEBUG(8139): #00 pc 0000ceb8 /system/lib/libc.so 06-05 18:52:57.656: I/DEBUG(8139): #01 pc 0008cc7a /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #02 pc 0008ce0c /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #03 pc 0008d626 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #04 pc 0008eaf6 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #05 pc 0008ec04 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #06 pc 0008f7b2 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #07 pc 0006c080 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #08 pc 0006c2f4 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #09 pc 00083bec /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #10 pc 00014842 /system/lib/egl/libGLESv1_CM_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #11 pc 0001d6fc /system/lib/egl/libGLESv1_CM_adreno200.so 06-05 18:52:57.656: I/DEBUG(8139): #12 pc 0001dc88 /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #13 pc 00063ec6 /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #14 pc 00064ef6 /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #15 pc 00015dfa /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #16 pc 0001f898 /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #17 pc 0001dbae /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): #18 pc 00020794 /data/data/com.teon/lib/libteon.so 06-05 18:52:57.656: I/DEBUG(8139): code around pc: 06-05 18:52:57.656: I/DEBUG(8139): afd0ce98 f400071d f5d1f000 f5d1f040 e2522040 06-05 18:52:57.656: I/DEBUG(8139): afd0cea8 3a000009 f5d1f080 f5d1f0c0 f5d1f100 06-05 18:52:57.656: I/DEBUG(8139): afd0ceb8 f421020d f421420d f5d1f100 e2522040 06-05 18:52:57.656: I/DEBUG(8139): afd0cec8 f400022d f400422d 2afffff8 e2822040 06-05 18:52:57.656: I/DEBUG(8139): afd0ced8 e2522020 3a000003 f421020d e2522020 06-05 18:52:57.656: I/DEBUG(8139): code around lr: 06-05 18:52:57.656: I/DEBUG(8139): 80e8cc5c 000cf8dc b1c99007 2030f8dc 6970087f 06-05 18:52:57.656: I/DEBUG(8139): 80e8cc6c bf382f01 93012701 c008f8cd e9d0f7cf 06-05 18:52:57.656: I/DEBUG(8139): 80e8cc7c 9b019903 c008f8dd 085b084d bf382d01 06-05 18:52:57.656: I/DEBUG(8139): 80e8cc8c 2b012501 2301bf38 25019503 21301c6a 06-05 18:52:57.656: I/DEBUG(8139): 80e8cc9c fb01980a 2218c402 0105fb02 34084630 06-05 18:52:57.656: I/DEBUG(8139): stack: 06-05 18:52:57.656: I/DEBUG(8139): 45882868 80b03f50 /system/lib/libgsl.so 06-05 18:52:57.656: I/DEBUG(8139): 4588286c c00c0923 06-05 18:52:57.656: I/DEBUG(8139): 45882870 4588288c 06-05 18:52:57.656: I/DEBUG(8139): 45882874 0000000c 06-05 18:52:57.666: I/DEBUG(8139): 45882878 ffffffff 06-05 18:52:57.666: I/DEBUG(8139): 4588287c 00000000 06-05 18:52:57.666: I/DEBUG(8139): 45882880 00000001 06-05 18:52:57.666: I/DEBUG(8139): 45882884 80e9bcc5 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.666: I/DEBUG(8139): 45882888 0087ed90 06-05 18:52:57.666: I/DEBUG(8139): 4588288c 66688000 06-05 18:52:57.666: I/DEBUG(8139): 45882890 4c886000 06-05 18:52:57.666: I/DEBUG(8139): 45882894 00000001 06-05 18:52:57.666: I/DEBUG(8139): 45882898 00000020 06-05 18:52:57.666: I/DEBUG(8139): 4588289c 00000001 06-05 18:52:57.666: I/DEBUG(8139): 458828a0 df002777 06-05 18:52:57.666: I/DEBUG(8139): 458828a4 e3a070ad 06-05 18:52:57.666: I/DEBUG(8139): #00 458828a8 4c886000 06-05 18:52:57.666: I/DEBUG(8139): 458828ac 80e8cc7d /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.666: I/DEBUG(8139): #01 458828b0 0087ec30 06-05 18:52:57.666: I/DEBUG(8139): 458828b4 00000040 06-05 18:52:57.666: I/DEBUG(8139): 458828b8 0087ec30 06-05 18:52:57.666: I/DEBUG(8139): 458828bc 00000001 06-05 18:52:57.666: I/DEBUG(8139): 458828c0 00000000 06-05 18:52:57.666: I/DEBUG(8139): 458828c4 80e89aa9 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.666: I/DEBUG(8139): 458828c8 00001000 06-05 18:52:57.666: I/DEBUG(8139): 458828cc 00000001 06-05 18:52:57.666: I/DEBUG(8139): 458828d0 fffff050 06-05 18:52:57.666: I/DEBUG(8139): 458828d4 fffff37c 06-05 18:52:57.666: I/DEBUG(8139): 458828d8 00605124 06-05 18:52:57.666: I/DEBUG(8139): 458828dc 00000001 06-05 18:52:57.666: I/DEBUG(8139): 458828e0 0087eec8 06-05 18:52:57.666: I/DEBUG(8139): 458828e4 80fc6e54 06-05 18:52:57.666: I/DEBUG(8139): 458828e8 00000000 06-05 18:52:57.676: I/DEBUG(8139): 458828ec 80e9b9e5 /system/lib/egl/libGLESv2_adreno200.so 06-05 18:52:57.676: I/DEBUG(8139): 458828f0 45882920 06-05 18:52:57.676: I/DEBUG(8139): 458828f4 0087ec30 06-05 18:52:57.676: I/DEBUG(8139): 458828f8 45882920 06-05 18:52:57.676: I/DEBUG(8139): 458828fc 00605120 06-05 18:52:57.676: I/DEBUG(8139): 45882900 0087ec30 06-05 18:52:57.676: I/DEBUG(8139): 45882904 00000000 06-05 18:52:57.676: I/DEBUG(8139): 45882908 45882920 06-05 18:52:57.676: I/DEBUG(8139): 4588290c 00605120 06-05 18:52:57.676: I/DEBUG(8139): 45882910 0087ec30 06-05 18:52:57.676: I/DEBUG(8139): 45882914 80e8ce11 /system/lib/egl/libGLESv2_adreno200.so一堆内存地址,很难看得懂,所以需要使用ndk提供的ndk-stack命令进行调试
1.把上面的异常log保存为 log.txt 文件
2.cmd 进入 cd <ndk路径>
3.调试命令:ndk路径>ndk-stack -sym <工程路径\obj\local\armeabi> -dump <log.txt路径>
enter:出异常的代码文件信息出来了
(注:调用顺序为自下而上)