如何使用 dSYM 解析崩溃文件

2022-12-10

如何使用 dSYM 解析崩溃文件

1. 直接解析奔溃日志文件

  1. 在 mac 找下 symbolicatecrash(Xcode自带的工具)

    find /Applications/Xcode.app -name symbolicatecrash -type f
       
    // 获取到以下
    /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash
    
  2. 获取 .app.dSYM 文件

    直接在 app 的显示包内容中查找

  3. 将 .crash 文件、symbolicatecrash、dSYM 文件放在同一文件夹,执行以下命令

    export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
       
    // xxx 表示 app 名称
    ./symbolicatecrash ./xxx.crash ./xxx.app.dSYM > xxx.crash
    
  4. 最后会在当前文件夹输出符号化后的 .crash 文件

2. 解析某个地址

比如解析以下

4   NetworkTaxiDriver                   0x00116f29 NetworkTaxiDriver + 323369

执行命令

// XXX 表示 app 名称
atos -o XXX.app.dSYM/Contents/Resources/DWARF/XXX -arch [CPU架构] -l [load Address] [address]

上面的例子的 address 计算

0x00116f29 = 1142569;   //将方法地主转化为十进制
1142569-323369 = 819200;//减去偏移地址,得到模块地址
819200 = 0xc8000;  //得到的模块地址在转为十六进制

所以命令为

atos -o XXX.app.dSYM/Contents/Resources/DWARF/XXX -arch arm64 -l 0xc8000 0x00116f29

3. Symbolicate ips file

iOS 15 introduce new format crash logs, which needs a new tool to symbolicate.

  • To support the new JSON-format crash logs generated in macOS Monterey and iOS 15, Instruments includes a new CrashSymbolicator.py script. This Python 3 script replaces the symbolicatecrash utility for JSON-format logs and supports inlined frames with its default options. For more information, see: CrashSymbolicator.py --help. CrashSymbolicator.py is located in the Contents/SharedFrameworks/CoreSymbolicationDT.framework/Resources/ subdirectory within Xcode 13. (78891800)

Find the CrashSymbolicator.py

find /Applications/Xcode.app -name CrashSymbolicator.py -type f

It will output like

/Applications/Xcode.app/Contents/SharedFrameworks/CoreSymbolicationDT.framework/Versions/A/Resources/CrashSymbolicator.py

Then use the python script to symbolicate the crash file.

// -p: input ips
// -o: output file
python3 /Applications/Xcode.app/Contents/SharedFrameworks/CoreSymbolicationDT.framework/Versions/A/Resources/CrashSymbolicator.py -d /xxx.dSYM -o /output.ips -p /input.ips