Getting crash log
We can get crash log for logcat service.
adb logcat -b crash -d -T 100
Then, we got following outputs.
The output messages contain pointer counter where crash, with which we can locate to the crash line.
Locating to crash line
Addr2line is a tool used to detect crash line through the library which crash occurs and with the pointer counter.
Note: You must not stripe the symbols of the library, so that addr2line could detect correct line.
addr2line -e library_path pointer_counter
Scripts
Following script is used to detect crash line automaticlly.
LIB_PATH=path_of_your_library_crashed
echo LIB_PATH=$LIB_PATH
adb logcat -b crash -d -T 100 > crash_log.txt
start_line=$(grep -n "\*\*\*" crash_log.txt | tail -n 1 | awk -F: '{print $1}')
tail -n +$start_line crash_log.txt > last_crash_log.txt
cat last_crash_log.txt
echo -e "\n"
echo -e "\033[33mposition: \033[0m"
addrs=$(cat last_crash_log.txt | grep '#' | awk '{print $10}')
for addr in ${addrs[@]}
do
echo -n $addr" "
get_file_line_by_address $LIB_PATH $addr
done
rm crash_log.txt
rm last_crash_log.txt