Skip to content

Instantly share code, notes, and snippets.

@pqnga
Last active August 29, 2015 14:00
Show Gist options
  • Save pqnga/47748e4b4a0984a9e76f to your computer and use it in GitHub Desktop.
Save pqnga/47748e4b4a0984a9e76f to your computer and use it in GitHub Desktop.
This script help symbolicate an ios crash log
# Author: @pqnga
# This gist is inspired from an answer from stackoverlow.com
# http://stackoverflow.com/questions/13574933/ios-crash-reports-atos-not-working-as-expected/13576028#13576028
# Use it when you want to symbolicate a crash log like this:
# 5 MyApp 0x0044e89a 0x29000 + 4348058
def symbolicate(app_file, architecture, log_line)
cmd_get_slide = "otool -arch #{architecture} -l #{app_file} | grep -B 3 -A 8 -m 2 \"__TEXT\""
result = %x[#{cmd_get_slide}]
vmaddr_position = result.index("vmaddr")
slide = result[vmaddr_position + 7, 10].hex
items = log_line.split(' ');
load_address = items[3]
stack_address = items[2]
symbol_address = slide.to_i + stack_address.hex - load_address.hex
cmd = "/Applications/Xcode.app/Contents/Developer/usr/bin/atos -arch #{architecture} -o #{app_file} #{symbol_address.to_s(16)}"
symbolicate_result = %x[#{cmd}]
puts "\nSymbolicated result:\n#{symbolicate_result}\n"
end
# Usage
app_file = "~/Downloads/build/MyApp.app/MyApp"
architecture = "armv7"
log_line = "11 MyApp 0x003c527b 0x56000 + 3601019"
symbolicate(app_file, architecture, log_line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment