Android 动态库死机调试方法
?? ? ? ?#print cmd
?? ? ? ?stream = os.popen(cmd)
?? ? ? ?lines = stream.readlines();
?? ? ? ?list = map(string.strip,lines)
?? ? ? ?return list
?? ?
inputarg = sys.argv
if len(inputarg) < 2:
?? ?print 'Please input panic log'
?? ?exit()
filename = inputarg[1]
readlog = ReadLog(filename)
inputlist = readlog.parse()
for item in inputlist:
?? ?itemsplit = item.split()
?? ?test = ParseContent(itemsplit[-2],itemsplit[-1])
?? ?list = test.addr2line()
?? ?print "%-30s%s" % (list[1],list[0])
?
?
将以上文件保存hy.panic.py?
?
?
2、相关的死机堆栈信息保存?error.txt
?
例如:
?
I/DEBUG ? ( ?634): ? ? ? ? ?#00 ?pc 000078e6 ?/system/lib/libmultiplayerservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#01 ?pc 000087bc ?/system/lib/libmultiplayerservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#02 ?pc 0000e94e ?/system/lib/libsensorservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#03 ?pc 0000a790 ?/system/lib/libsensorservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#04 ?pc 0000d4b2 ?/system/lib/libsensorservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#05 ?pc 0000d852 ?/system/lib/libsensorservice.so
I/DEBUG ? ( ?634): ? ? ? ? ?#06 ?pc 00015ece ?/system/lib/libutils.so
I/DEBUG ? ( ?634): ? ? ? ? ?#07 ?pc 0000153a ?/system/lib/libsystem_server.so
I/DEBUG ? ( ?634): ? ? ? ? ?#08 ?pc 00001756 ?/system/lib/libsystem_server.so
I/DEBUG ? ( ?634): ? ? ? ? ?#09 ?pc 0000adb8 ?/system/lib/libandroid_servers.so
I/DEBUG ? ( ?634): ? ? ? ? ?#10 ?pc 00011cb4 ?/system/lib/libdvm.so
?
?
3、将以上两个文件拷贝到android的编译根路径下面,执行
?
python hy.panic.py error.txt?
?
方法2使用非常方便,相比于加打印效率大大提高。
