-
-
Save AdamNorberg/c0cd67ed956d2f1cb9f1b6a03b0ffd8c to your computer and use it in GitHub Desktop.
Symbolicates a sample dump from Activity Monitor
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
#!/usr/bin/env python3 | |
# | |
# To use this, just put the DSYMS in the same directory as the sample dump file, | |
# and run the script from that directory, passing the sample dump file name as only argument | |
# | |
import re, sys, os, subprocess | |
sampleFile = sys.argv[1] | |
for sampleLine in open(sampleFile, 'r').readlines(): | |
match = re.search(r'\?{3}\s*\(in\s+(.*?)\)\s+load address\s*([\d\w]+).*\[([\d\w]+)\]', sampleLine) | |
if match: | |
binary = match.group(1) | |
loadAddress = match.group(2) | |
offset = match.group(3) | |
script = "atos -arch x86_64 -o {0}.*.dSYM/Contents/Resources/DWARF/{1} -l {2} {3} > temp".format(binary, binary, loadAddress, offset) | |
os.system(script) | |
method = open('temp', 'r').read() | |
sampleLine = sampleLine.replace(r'???', method) | |
print(sampleLine, end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for Python3 on 2023-03-06.