Created
September 15, 2011 12:22
-
-
Save jamztang/1219102 to your computer and use it in GitHub Desktop.
symbolizecrashlog fixed script for iOS apps. (Fixed regex for both .crash and copy/pasted crash logs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
AWK_SCRIPT=/tmp/symbolizecrashlog_$$.awk | |
SH_SCRIPT=/tmp/symbolizecrashlog_$$.sh | |
if [[ $# < 2 ]] | |
then | |
echo "Usage: $0 [ -arch <arch> ] symbol-file [ crash.log, ... ]" | |
exit 1 | |
fi | |
ARCH_PARAMS='' | |
if [[ "${1}" == '-arch' ]] | |
then | |
ARCH_PARAMS="-arch ${2}" | |
shift 2 | |
fi | |
SYMBOL_FILE="${1}" | |
shift | |
cat > "${AWK_SCRIPT}" << _END | |
/^[0-9]+ +[-._a-zA-Z0-9]+[ \t]*0x[0-9a-fA-F]+ / { | |
addr_index = index(\$0,\$3); | |
end_index = addr_index+length(\$3); | |
line_legnth = length; | |
printf("echo '%s'\"\$(symbolize %s '%s')\"\n",substr(\$0,1,end_index), | |
\$3,substr(\$0,end_index+1,line_legnth-end_index)); | |
next; | |
} | |
{ gsub(/'/,"'\\\\''"); printf("echo '%s'\n",\$0); } | |
_END | |
function symbolize() | |
{ | |
# Translate the address using atos | |
SYMBOL=$(atos -o "${SYMBOL_FILE}" ${ARCH_PARAMS} "${1}" 2>/dev/null) | |
# If successful, output the translated symbol. If atos returns an address, output the original symbol | |
if [[ "${SYMBOL##0x[0-9a-fA-F]*}" ]] | |
then | |
echo -n "${SYMBOL}" | |
else | |
echo -n "${2}" | |
fi | |
} | |
awk -f "${AWK_SCRIPT}" $* > "${SH_SCRIPT}" | |
. "${SH_SCRIPT}" | |
rm -f "${AWK_SCRIPT}" "${SH_SCRIPT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment