当前位置:   article > 正文

符号化的正确姿势_error: can't find "binary images" section in log f

error: can't find "binary images" section in log file at ./symbolicatecrash

在这里插入图片描述

GUI方式

将 .ips crash report 文件拖放到 Xcode > Window > Devices and Simulators > View Device Logs中, 然后导出 .crash 符号化文件.

使用条件: crash report 对应的 Archive 包是在本机构建的

symbolicatecrash

symbolicatecrash 是一个 exec (可执行文件), Xcode自带, iOS 15 之前的系统产生的 crash report, 可以直接被整个符号化, 文件路径可以通过 find 来查找1 , 结果是:

/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash

使用方式参考如下示例:

// 若执行路径与文件路径不同, 需要补充完整的URI绝对路径
$ symbolicatecrash xxx.ips xxx.dSYM > symbolicated.crash
  • 1
  • 2

常见问题

1. Error: “DEVELOPER_DIR” is not defined at /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash line 69.

DEVELOPER_DIR是执行所依赖的环境变量, 解决办法如下:

```shell
$ export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
```
  • 1
  • 2
  • 3
2. Error: No crash report version in xxx.ips at /Applications/Xcode.app/…/symbolicatecrash line 1365.

iOS 15 及之后的版本产生的 crash report, 格式有变, 已经无法使用 symbolicatecrash 符号化

> **Xcode 13 Release Notes > Instruments > New Features**
> 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)
  • 1
  • 2
3. UUID2 不匹配
// 查看dSYM文件的UUID
$ dwarfdump --uuid <dSYM path>
  • 1
  • 2

atos命令

The atos command converts numeric (数字的) addresses to their symbolic (符号的) equivalents (复数, 等同物, 对应物). If full debug symbol information is available, for example in a .app.dSYM sitting beside a .app, then the output of atos will include file name and source line number information.

常用参数 (参数顺序没有要求)

  1. -o <binary-image-file> | <dSYM>

    The path to a binary image file or dSYM in which to look up symbols.

  2. -l <load-address>

    The load address of the binary image. This value is always assumed to be in hex, even without a “0x” prefix. The input addresses are assumed to be in a binary image
    with that load address. Load addresses for binary images can be found in the Binary Images: section at the bottom of crash, sample, leaks, and malloc_history reports.

  3. -arch architecture

    The particular architecure of a binary image file in which to look up symbols.

使用方式

// atos -arch 指令集 -0 dsym -l 调用地址 符号模块地址
// load adress:可执行指令部分相对镜像文件中的起始加载地址 address to symbolicate:调用函数的地址
atos -arch <Binary Architecture> -o <Path to dSYM file>/Contents/Resources/DWARF/<binary image name> -l <load address> <address to symbolicate>
  • 1
  • 2
  • 3

示例

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib              0x00000001cb264b00 specialized _fatalErrorMessage+ 2112256 (_:_:file:line:flags:) + 296
1   libswiftCore.dylib              0x00000001cb264b00 specialized _fatalErrorMessage+ 2112256 (_:_:file:line:flags:) + 296
2   libswiftCore.dylib              0x00000001cb070524 _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds+ 62756 (_:wasNativeTypeChecked:) + 232
3   libswiftCore.dylib              0x00000001cb073510 Array.subscript.getter + 84
4   appName                             0x00000001005feba0 0x1004f0000 + 1108896
5   appName                             0x00000001005fcc88 0x1004f0000 + 1100936
6   appName                             0x00000001005fce84 0x1004f0000 + 1101444
7   UIKitCore                       0x00000001c9f180f0 -[UIApplication 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
借助xcrun实现交互式
// 执行如下命令
$ xcrun atos -o appName.dSYM/Contents/Resources/DWARF/appName -l 0x1004f0000 -arch arm64
// 然后在换行处输入
0x00000001005feba0
// 终端输出
AppDelegate.updateRootViewController() (in ) (AppDelegate.swift:104)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
直接使用 atos
// 解析整个
atos -o xxx.app.dSYM/Contents/Resources/DWARF/xxx -l 0x00000001c4fe7000 -arch arm64
// 解析单行
atos -arch arm64 -o xxx.app.dSYM/Contents/Resources/DWARF/xxx -l 0x00000001c4fe7000 0x00000001a2d6e29c
  • 1
  • 2
  • 3
  • 4

CrashSymbolicator.py

  • 脚本所在位置:

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

  • 怎样使用
// -d: dSYM符号表文件, -o: 输出符号化的文件, -p: iOS系统生成的crashReport
$ python3 CrashSymbolicator.py -d <dSYM> -o <symbolicated.crash> -p <xxx.ips>
  • 1
  • 2

思考

  1. 怎么查看 crash report 的 UUID ?

  1. 怎样使用find快速查找文件路径 ; ↩︎

  2. 什么是UUID ? ; ↩︎

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/276957
推荐阅读
相关标签
  

闽ICP备14008679号