【发布时间】:2011-04-09 01:20:02
【问题描述】:
有时编译器会生成 .dSYM 文件。我猜这是一个调试相关的文件,但我不知道它是什么,以及如何使用它。
什么是 .dSYM?如何使用它?
【问题讨论】:
-
在这个惊人的 WWDC 2021 视频中可以找到细致而出色的解释⟹ developer.apple.com/videos/play/wwdc2021/10211 ??
标签: debugging sdk compilation ios
有时编译器会生成 .dSYM 文件。我猜这是一个调试相关的文件,但我不知道它是什么,以及如何使用它。
什么是 .dSYM?如何使用它?
【问题讨论】:
标签: debugging sdk compilation ios
【讨论】:
Xcode 调试符号(dSYM)
dSYM 它是一个Bundle(例如F49088168M.app.dSYM),其中包含映射信息,您可以使用它,例如,将堆栈跟踪解码为可读格式。
结构:
例如,崩溃日志如下所示:
//before
0 libswiftCore.dylib 0x000000018f3c9380 0x18f394000 + 217984
1 libswiftCore.dylib 0x000000018f3c9380 0x18f394000 + 217984
2 libswiftCore.dylib 0x000000018f3c8844 0x18f394000 + 215108
3 libswiftCore.dylib 0x000000018f3a74e0 0x18f394000 + 79072
4 libswiftCore.dylib 0x000000018f3ab0d8 0x18f394000 + 94424
5 F49088168M 0x00000001045ac750 0x104590000 + 116560
6 F49088168M 0x00000001045b7904 0x104590000 + 162052
7 F49088168M 0x00000001045b897c 0x104590000 + 166268
8 F49088168M 0x000000010459d914 0x104590000 + 55572
9 F49088168M 0x00000001045a0e70 0x104590000 + 69232
10 F49088168M 0x00000001045a0f4c 0x104590000 + 69452
dSYM 在行动
//after Symbolicating(dSYM is used)
0 libswiftCore.dylib 0x000000018f3c9380 closure #1 in closure #1 in closure #1 in _assertionFailure+ 217984 (_:_:file:line:flags:) + 452
1 libswiftCore.dylib 0x000000018f3c9380 closure #1 in closure #1 in closure #1 in _assertionFailure+ 217984 (_:_:file:line:flags:) + 452
2 libswiftCore.dylib 0x000000018f3c8844 _assertionFailure+ 215108 (_:_:file:line:flags:) + 468
3 libswiftCore.dylib 0x000000018f3a74e0 _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds+ 79072 (_:wasNativeTypeChecked:) + 208
4 libswiftCore.dylib 0x000000018f3ab0d8 Array.subscript.getter + 84
5 F49088168M 0x00000001045ac750 static ELM327ResponseManager.getResponse(responseStr:obd2Protocol:) + 116560 (ELM327ResponseManager.swift:27)
6 F49088168M 0x00000001045b7904 ELM327Client.dataInput(_:characteristicUuidStr:) + 162052 (ELM327Client.swift:56)
7 F49088168M 0x00000001045b897c protocol witness for BLEClientInputPort.dataInput(_:characteristicUuidStr:) in conformance ELM327Client + 166268 (<compiler-generated>:0)
8 F49088168M 0x000000010459d914 BLEConnection.peripheralDataReceived(data:characteristicUuidStr:) + 55572 (BLEConnection.swift:124)
9 F49088168M 0x00000001045a0e70 BLEConnection.peripheral(_:didUpdateValueFor:error:) + 69232 (BLEConnection.swift:293)
10 F49088168M 0x00000001045a0f4c @objc BLEConnection.peripheral(_:didUpdateValueFor:error:) + 69452 (<compiler-generated>:0)
默认情况下,dSYM 是默认为 release 版本生成的。
你可以检查一下:
Build Settings -> Generate Debug Symbols(GCC_GENERATE_DEBUGGING_SYMBOLS) -> Yes
Build Settings -> Debug Information Format(DEBUG_INFORMATION_FORMAT) -> DWARF with dSYM File
您可以在Products文件夹中找到结果位置
使用dsymutil从.app手动生成dSYM文件
dsymutil F49088168M.app/F49088168M -o F49088168M.app.dSYM
使用symbolicatecrash 表示崩溃
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/Current/Resources/symbolicatecrash "<path>/F49088168M-2020-06-04-212904.crash" "<path>/F49088168M.app.dSYM" > symbolicated.crash
使用dwarfdump手动打开dSYM
dwarfdump --arch arm64 --debug-pubtypes F49088168M.app.dSYM
结果如下:
0x00000065 "PeripheralLogView"
0x000005cc "BLEConnection"
0x000005da "BLEPeripheral"
0x000005e9 "ELM327Client"
*您的 .app 的 dSYM 应包括所有包含的(框架)dSYM
【讨论】: