Skip to content

Instantly share code, notes, and snippets.

@keithyipkw
Last active October 6, 2020 10:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save keithyipkw/7addfcdb9a640643ab15 to your computer and use it in GitHub Desktop.
Save keithyipkw/7addfcdb9a640643ab15 to your computer and use it in GitHub Desktop.
A dirty fix for crash log symbolication in Xcode
# This patch will force symbolicatecrash to use dSym in atos instead of using release build executables.
#
# After setting the Xcode archive folder to one that outside Library (hidden), Spotlight will find the archives but Xcode still cannot symbolicate crash logs using the archives. If you find some similar errors in the STDERR from symbolicatecrash using the following command, this patch will help
# DEVELOPER_DIR=`xcode-select -print-path` /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash -v -o <symbolicated.crash> <input.crash> 2>v.log
#
# 1 binary images were found.
# Running /Applications/Xcode.app/Contents/Developer/usr/bin/atos -arch armv7 -l 0x82000 -o '<app name>.xcarchive/Products/Applications/<app name>.app/<app name>' <some addresses> |
# ## Warning: Unable to symbolicate from required binary: '<app name>.xcarchive/Products/Applications/<app name>.app/<app name>'
#
# To apply the patch
# cd ~/
# cp /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash ~/
# patch -o symbolicatecrash-fix < symbolicatecrash.patch
# chmod +x symbolicatecrash-fix
#
--- symbolicatecrash 2014-10-08 19:08:23.000000000 +0800
+++ symbolicatecrash-fix 2014-10-10 10:16:28.000000000 +0800
@@ -855,13 +855,24 @@
# run atos for each library
while(my($symbol,$frames) = each(%frames_to_lookup)) {
- # escape the symbol path if it contains single quotes
- my $escapedSymbol = $symbol;
- $escapedSymbol =~ s/\'/\'\\'\'/g;
+
+my $exec_name = basename($symbol);
+my ($dsympath) = $symbol =~ /(^.*)\.xcarchive/i;
+$dsympath = $dsympath . ".xcarchive/dSYMs/$exec_name.app.dSYM/Contents/Resources/DWARF/$exec_name";
+print STDERR "dsympath = $dsympath\n" if $opt{v};
# run atos with the addresses and binary files we just gathered
my $arch = $arch_map{$symbol};
my $base = $base_map{$symbol};
+
+if( -f "$dsympath") {
+$symbol = $dsympath;
+}
+
+ # escape the symbol path if it contains single quotes
+ my $escapedSymbol = $symbol;
+ $escapedSymbol =~ s/\'/\'\\'\'/g;
+
my $cmd = "$atos -arch $arch -l $base -o '$escapedSymbol' @{[ keys %$frames ]} | ";
print STDERR "Running $cmd\n" if $opt{v};
@CooperRS
Copy link

THAT was helpful a few moments ago! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment