文末附上脚本源码
2019.4.24 更新,32位,64位 进程tombstone的兼容
python ./as_tomba.py tombstone_file_path symbol_root_path
在tombstone_file_path目录下生成 tombstone文件名_pid_pname.out 的解析之后文件
python ./as_tomba.py tombstone_file_dir symbol_root_path
将tombstone_file_dir目录下的含有tombstone调用栈的文件解析输出到该目录下相应的输出文件中
如logcat中有如下log:
01-09 14:11:02.220 16332 16811 F libc : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 16811 (HwBinder:16332_), pid 16332 ([email protected])
01-09 14:11:02.278 17079 17079 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
01-09 14:11:02.278 888 888 I /system/bin/tombstoned: received crash request for pid 16811
01-09 14:11:02.280 17079 17079 I crash_dump64: performing dump of process 16332 (target tid = 16811)
01-09 14:11:02.286 17079 17079 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-09 14:11:02.286 17079 17079 F DEBUG : Build fingerprint: 'xiaomi/violet/violet:9/PKQ1.181203.001/9.1.9:user/release-keys'
01-09 14:11:02.286 17079 17079 F DEBUG : Revision: '0'
01-09 14:11:02.286 17079 17079 F DEBUG : ABI: 'arm64'
01-09 14:11:02.286 17079 17079 F DEBUG : pid: 16332, tid: 16811, name: HwBinder:16332_ >>> /vendor/bin/hw/[email protected]_64 <<<
01-09 14:11:02.286 17079 17079 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-09 14:11:02.286 17079 17079 F DEBUG : Abort message: 'Invalid address 0x7be6e0d180 passed to free: value not allocated'
01-09 14:11:02.286 17079 17079 F DEBUG : x0 0000000000000000 x1 00000000000041ab x2 0000000000000006 x3 0000000000000008
01-09 14:11:02.286 17079 17079 F DEBUG : x4 8080808080808080 x5 8080808080808080 x6 8080808080808080 x7 0000000000000008
01-09 14:11:02.286 17079 17079 F DEBUG : x8 0000000000000083 x9 49bf711238106b52 x10 0000000000000000 x11 fffffffc7fffffdf
01-09 14:11:02.286 17079 17079 F DEBUG : x12 0000000000000001 x13 000000005c35b39e x14 000c568e6e9f9200 x15 0000d19ff0bea88d
01-09 14:11:02.286 17079 17079 F DEBUG : x16 0000007c3320f2b8 x17 0000007c3312ec50 x18 ffffffffffffff60 x19 0000000000003fcc
01-09 14:11:02.286 17079 17079 F DEBUG : x20 00000000000041ab x21 0000007be6e0d180 x22 0000000000000000 x23 0000007c3321b8d8
01-09 14:11:02.286 17079 17079 F DEBUG : x24 0000007c254a5eb8 x25 0000007c3092cda0 x26 0000007c254a5eb8 x27 0000007c254a5eb8
01-09 14:11:02.286 17079 17079 F DEBUG : x28 0000007c254a5eb8 x29 0000007c0501f300
01-09 14:11:02.286 17079 17079 F DEBUG : sp 0000007c0501f2c0 lr 0000007c331220c4 pc 0000007c331220ec
01-09 14:11:02.323 711 711 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
01-09 14:11:02.325 17079 17079 F DEBUG :
01-09 14:11:02.325 17079 17079 F DEBUG : backtrace:
01-09 14:11:02.325 17079 17079 F DEBUG : #00 pc 00000000000220ec /system/lib64/libc.so (abort+116)
01-09 14:11:02.325 17079 17079 F DEBUG : #01 pc 00000000000b430c /system/lib64/libc.so (ifree+1172)
01-09 14:11:02.325 17079 17079 F DEBUG : #02 pc 00000000000b4418 /system/lib64/libc.so (je_free+120)
01-09 14:11:02.325 17079 17079 F DEBUG : #03 pc 00000000000cee9c /vendor/lib64/hw/com.qti.chi.override.so (ChxUtils::AndroidMetadata::FreeMetaData(void*)+28)
01-09 14:11:02.325 17079 17079 F DEBUG : #04 pc 0000000000099788 /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::AndroidMetadataHolder::~AndroidMetadataHolder()+160)
01-09 14:11:02.325 17079 17079 F DEBUG : #05 pc 00000000000de150 /vendor/lib64/hw/com.qti.chi.override.so (std::_1::vector_base>::~_vector_base()+72)
01-09 14:11:02.325 17079 17079 F DEBUG : #06 pc 00000000000de034 /vendor/lib64/hw/com.qti.chi.override.so (std::_1::vector>::~vector()+20)
01-09 14:11:02.325 17079 17079 F DEBUG : #07 pc 0000000000099a14 /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::~ChiMetadataManager()+84)
01-09 14:11:02.325 17079 17079 F DEBUG : #08 pc 0000000000099d9c /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::Destroy()+28)
01-09 14:11:02.325 17079 17079 F DEBUG : #09 pc 00000000000ad694 /vendor/lib64/hw/com.qti.chi.override.so (Usecase::DestroyObject(int)+1476)
01-09 14:11:02.325 17079 17079 F DEBUG : #10 pc 000000000005d45c /vendor/lib64/hw/com.qti.chi.override.so (ExtensionModule::TeardownOverrideUsecase(camera3_device const*, int)+220)
01-09 14:11:02.325 17079 17079 F DEBUG : #11 pc 00000000000616f4 /vendor/lib64/hw/com.qti.chi.override.so (ExtensionModule::TeardownOverrideSession(camera3_device const*, unsigned long, void*)+164)
01-09 14:11:02.325 17079 17079 F DEBUG : #12 pc 000000000005bde8 /vendor/lib64/hw/com.qti.chi.override.so (chi_teardown_override_session(camera3_device const*, unsigned long, void*)+56)
01-09 14:11:02.326 17079 17079 F DEBUG : #13 pc 00000000000ccd28 /vendor/lib64/hw/camera.qcom.so (CamX::close(hw_device_t*)+1768)
01-09 14:11:03.363 857 1000 E storaged: getDiskStats failed with result NOT_SUPPORTED and size 0
01-09 14:11:02.324 711 711 I chatty : uid=1000(system) /system/bin/surfaceflinger identical 2 lines
将该log贴到指定文件中跑脚本:
python ./as_tombstone_analysis/as_tomba.py ./as_tombstone_analysis/log_demo/ne_log_crash.txt /home/chengang/Documents/f7b_issue/symbols/9.1.9_in/out/target/product/violet/symbols
01-09 14:11:02.325 17079 17079 F DEBUG : #00 pc 00000000000220ec /system/lib64/libc.so (abort+116)abort
bionic/libc/bionic/abort.cpp:73
01-09 14:11:02.325 17079 17079 F DEBUG : #01 pc 00000000000b430c /system/lib64/libc.so (ifree+1172)je_arena_dalloc
external/jemalloc/include/jemalloc/internal/arena.h:1453
01-09 14:11:02.325 17079 17079 F DEBUG : #02 pc 00000000000b4418 /system/lib64/libc.so (je_free+120)je_free
external/jemalloc/src/jemalloc.c:?
01-09 14:11:02.325 17079 17079 F DEBUG : #03 pc 00000000000cee9c /vendor/lib64/hw/com.qti.chi.override.so (ChxUtils::AndroidMetadata::FreeMetaData(void*)+28)ChxUtils::AndroidMetadata::FreeMetaData(void*)
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxutils.cpp:755
01-09 14:11:02.325 17079 17079 F DEBUG : #04 pc 0000000000099788 /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::AndroidMetadataHolder::~AndroidMetadataHolder()+160)~AndroidMetadataHolder
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxmetadata.cpp:814
01-09 14:11:02.325 17079 17079 F DEBUG : #05 pc 00000000000de150 /vendor/lib64/hw/com.qti.chi.override.so (std::_1::vector_base>::~_vector_base()+72)std::__1::allocator::destroy(ChiMetadataManager::AndroidMetadataHolder*)
external/libcxx/include/memory:1860
01-09 14:11:02.325 17079 17079 F DEBUG : #06 pc 00000000000de034 /vendor/lib64/hw/com.qti.chi.override.so (std::_1::vector>::~vector()+20)~vector
external/libcxx/include/vector:447
01-09 14:11:02.325 17079 17079 F DEBUG : #07 pc 0000000000099a14 /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::~ChiMetadataManager()+84)~ChiMetadataManager
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxmetadata.cpp:965
01-09 14:11:02.325 17079 17079 F DEBUG : #08 pc 0000000000099d9c /vendor/lib64/hw/com.qti.chi.override.so (ChiMetadataManager::Destroy()+28)ChiMetadataManager::Destroy()
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxmetadata.cpp:847
01-09 14:11:02.325 17079 17079 F DEBUG : #09 pc 00000000000ad694 /vendor/lib64/hw/com.qti.chi.override.so (Usecase::DestroyObject(int)+1476)Usecase::DestroyObject(int)
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxusecase.cpp:172
01-09 14:11:02.325 17079 17079 F DEBUG : #10 pc 000000000005d45c /vendor/lib64/hw/com.qti.chi.override.so (ExtensionModule::TeardownOverrideUsecase(camera3_device const*, int)+220)ExtensionModule::TeardownOverrideUsecase(camera3_device const*, int)
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxextensionmodule.cpp:2129
01-09 14:11:02.325 17079 17079 F DEBUG : #11 pc 00000000000616f4 /vendor/lib64/hw/com.qti.chi.override.so (ExtensionModule::TeardownOverrideSession(camera3_device const*, unsigned long, void*)+164)ExtensionModule::TeardownOverrideSession(camera3_device const*, unsigned long, void*)
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxextensionmodule.cpp:2074
01-09 14:11:02.325 17079 17079 F DEBUG : #12 pc 000000000005bde8 /vendor/lib64/hw/com.qti.chi.override.so (chi_teardown_override_session(camera3_device const*, unsigned long, void*)+56)chi_teardown_override_session(camera3_device const*, unsigned long, void*)
vendor/qcom/proprietary/chi-cdk/vendor/chioverride/default/chxextensioninterface.cpp:504
01-09 14:11:02.326 17079 17079 F DEBUG : #13 pc 00000000000ccd28 /vendor/lib64/hw/camera.qcom.so (CamX::close(hw_device_t*)+1768)CamX::close(hw_device_t*)
vendor/qcom/proprietary/camx/src/core/hal/camxhaldevice.cpp:956
自动解析tombstone脚本源码:
# -*- coding: utf-8 -*-
# !/usr/bin/python
import re
import os
import os.path
import time
import gzip
import sys
'''
How to use it?
as_tomba.py tombstone_file_path symbol_file_path
out file :
./tombstone_out.txt
'''
tombstone_file_path = sys.argv[1]
symbols_dir_path = sys.argv[2]
def get_filePath_fileName_fileExt(filename):
(filepath,tempfilename) = os.path.split(filename);
(shotname,extension) = os.path.splitext(tempfilename);
return filepath,shotname,extension
def get_process_pid_name(filename):
f = open(filename)
for line in f:
pattern = re.compile(r"pid:\s([0-9]+?),.+>>> (.+?) <<<")
rst = pattern.search(line)
if rst :
pid = rst.group(1)
name = rst.group(2).lstrip('/').replace('/','#')
return pid,name
return "null","null"
def tomba_dir(ptombstone_file_dir,psymbols_dir_path):
for file_name in os.listdir(tombstone_file_path):
target_file = os.path.join(tombstone_file_path,file_name)
tomba_file(target_file,symbols_dir_path)
def tomba_file(ptombstone_file_path,psymbols_dir_path):
psymbols_dir_path = psymbols_dir_path.rstrip('/')
(pid,pname) = get_process_pid_name(ptombstone_file_path)
f = open(ptombstone_file_path);
(file_p,file_s,file_e) = get_filePath_fileName_fileExt(ptombstone_file_path)
out_file_name = file_s+"_"+pid+"_"+pname+".out"
fp = open(file_p+'/'+out_file_name,'a+')
fp.truncate()
for line in f:
line = line.lstrip()
line = line.strip('\n')
if line.startswith("stack:"):
break
else:
# pattern = re.compile('(#[0-9]{2})(?#调用栈帧数)\s+pc\s+([0-9a-z]{16})(?#pc地址)\s(.+?)\s')
# 64位和32位机器的pc地址长度不同,64位为16位PC地址,32位为8位PC地址
pattern = re.compile('(#[0-9]{2})(?#调用栈帧数)\s+pc\s+([0-9a-z]*)(?#pc地址)\s(.+?)\s')
rst = pattern.search(line)
if rst:
symbol_path = psymbols_dir_path + rst.group(3).strip()
shift_code = rst.group(2)
print line
print symbol_path
print shift_code
print '\n'
analysis_result = tomba_so(symbol_path,shift_code)
fp.write(line)
fp.write(analysis_result)
fp.write('\n')
f.flush()
def tomba_so(symbol_so_path,shift_code):
if(os.path.exists(symbol_so_path)):
cmd_line = "addr2line -Cfe %s %s" %(symbol_so_path,shift_code)
f = os.popen(cmd_line)
result = f.read()
return result
else:
return "no symbol file!!!"
if os.path.isdir(tombstone_file_path):
print(tombstone_file_path + " is a dir")
tomba_dir(tombstone_file_path,symbols_dir_path)
elif os.path.isfile(tombstone_file_path):
print(tombstone_file_path + " is a file")
tomba_file(tombstone_file_path,symbols_dir_path)
else:
print("Wrong Tombstone File Name!")
sys.exit()