问题
用logcat抓取到报错如下
10-26 15:14:46.777 3174 3174 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
10-26 15:14:46.778 1810 1810 I /system/bin/tombstoned: received crash request for pid 3152
10-26 15:14:46.779 3174 3174 I crash_dump32: performing dump of process 3152 (target tid = 3152)
10-26 15:14:46.779 3174 3174 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-26 15:14:46.780 3174 3174 F DEBUG : Build fingerprint: 'Allwinner/virgo_perf1/virgo-perf1:8.1.0/OPM1.171019.026/20191026-150808:userdebug/test-keys'
10-26 15:14:46.780 3174 3174 F DEBUG : Revision: '0'
10-26 15:14:46.780 3174 3174 F DEBUG : ABI: 'arm'
10-26 15:14:46.780 3174 3174 F DEBUG : pid: 3152, tid: 3152, name: r.handwritedemo >>> com.softwinner.handwritedemo <<<
10-26 15:14:46.780 3174 3174 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x906e7573
10-26 15:14:46.780 3174 3174 F DEBUG : r0 906e7573 r1 906e7573 r2 00000010 r3 00000005
10-26 15:14:46.780 3174 3174 F DEBUG : r4 906e7573 r5 00000073 r6 be86e8bc r7 ffffffff
10-26 15:14:46.780 3174 3174 F DEBUG : r8 00000000 r9 ffffffff sl 00000014 fp ad133dce
10-26 15:14:46.780 3174 3174 F DEBUG : ip 80000000 sp be86e818 lr adc4c00f pc adc27fc2 cpsr 80070030
10-26 15:14:46.688 3152 3152 I r.handwritedemo: type=1400 audit(0.0:47): avc: denied { open } for path="/dev/input" dev="tmpfs" ino=8987 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:input_device:s0 tclass=dir permissive=1
10-26 15:14:46.688 3152 3152 I r.handwritedemo: type=1400 audit(0.0:48): avc: denied { read write } for name="event4" dev="tmpfs" ino=1762 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:input_device:s0 tclass=chr_file permissive=1
10-26 15:14:46.688 3152 3152 I r.handwritedemo: type=1400 audit(0.0:49): avc: denied { open } for path="/dev/input/event4" dev="tmpfs" ino=1762 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:input_device:s0 tclass=chr_file permissive=1
10-26 15:14:46.688 3152 3152 I r.handwritedemo: type=1400 audit(0.0:50): avc: denied { ioctl } for path="/dev/input/event4" dev="tmpfs" ino=1762 ioctlcmd=0x4506 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:input_device:s0 tclass=chr_file permissive=1
10-26 15:14:47.214 3174 3174 F DEBUG :
10-26 15:14:47.214 3174 3174 F DEBUG : backtrace:
10-26 15:14:47.214 3174 3174 F DEBUG : #00 pc 00019fc2 /system/lib/libc.so (strlen+21)
10-26 15:14:47.214 3174 3174 F DEBUG : #01 pc 0003e00b /system/lib/libc.so (__vfprintf+3754)
10-26 15:14:47.214 3174 3174 F DEBUG : #02 pc 00052755 /system/lib/libc.so (vsnprintf+128)
10-26 15:14:47.214 3174 3174 F DEBUG : #03 pc 00006483 /system/lib/liblog.so (__android_log_print+54)
10-26 15:14:47.215 3174 3174 F DEBUG : #04 pc 00004cad /system/lib/libhandwritten.so (input_reader_init(void*)+224)
10-26 15:14:47.215 3174 3174 F DEBUG : #05 pc 000046c9 /system/lib/libhandwritten.so (android::HandWriteHandler::start()+228)
10-26 15:14:47.215 3174 3174 F DEBUG : #06 pc 000a118b /system/lib/libandroid_runtime.so (android::nativeHandwrittenStart(_JNIEnv*, _jobject*, long long, _jobject*, _jobject*, _jobject*, _jobject*, int, int, int, int)+622)
10-26 15:14:47.215 3174 3174 F DEBUG : #07 pc 007dde4d /system/framework/arm/boot-framework.oat (offset 0x2f2000) (android.view.Surface.nativeHandwrittenStart+220)
10-26 15:14:47.215 3174 3174 F DEBUG : #08 pc 00408375 /system/lib/libart.so (art_quick_invoke_stub_internal+68)
10-26 15:14:47.215 3174 3174 F DEBUG : #09 pc 0040d4e7 /system/lib/libart.so (art_quick_invoke_stub+230)
10-26 15:14:47.215 3174 3174 F DEBUG : #10 pc 000b00b7 /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+138)
不像JAVA层的代码那样,告诉你哪一行报了什么错,如何去查呢?
解决步骤
1.从logcat中可以到初步报错信息
10-26 15:14:47.215 3174 3174 F DEBUG : #04 pc 00004cad /system/lib/libhandwritten.so (input_reader_init(void*)+224)
这行报错信息,正是我改动的代码所编译出来的库,报错信息还说了是哪个函数(input_reader_init),但是224不是行数
2.找到libhandwritten.so
路径:out/target/product/virgo-perf1/symbols/system/lib/libhandwritten.so
3.把libhandwritten.so拷贝到prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin下面去,这个路径含有一个名字含有addr2line的工具
4.执行./arm-eabi-addr2line -Cfe libhandwritten.so 0x00004cad,注意最后一个参数对应log中的,然后得到结果
epoll_register_all_input(int, char const*)
frameworks/base/libs/handwritten/InputReader.cpp:117
报错在frameworks/base/libs/handwritten/InputReader.cpp的117行