简体   繁体   English

如何在iOS中使用dSYM文件解码崩溃日志?

[英]How to decode a Crash log using dSYM file in iOS?

My iOS application crashed. 我的iOS应用程序崩溃了。 I would like to read the crash log with the dSYM file. 我想用dSYM文件读取崩溃日志。 How is it possible? 这怎么可能?

First of all, you need three files: the dSYM file, the application file and the crash log. 首先,您需要三个文件:dSYM文件,应用程序文件和崩溃日志。

Open the X Code, in the project navigator reveal the Products folder, and "Show in finder" the app file. 打开X代码,在项目导航器中显示Products文件夹,并在“查找器中显示”应用程序文件。 Here you will find the dSYM file too. 在这里你也可以找到dSYM文件。 Copy them to a folder. 将它们复制到一个文件夹。

Now open the terminal, and navigate to the folder you copied previously the two files. 现在打开终端,然后导航到之前复制的两个文件的文件夹。 Run: dwarfdump --uuid Application_name.app/Application_name You should receive the application's UUID. 运行: dwarfdump --uuid Application_name.app/Application_name您应该收到应用程序的UUID。 Run the following command: dwarfdump --uuid Application_name.app.dSYM - you will receive the UUID again, which should match the previously received UUID. 运行以下命令: dwarfdump --uuid Application_name.app.dSYM - 您将再次收到UUID,该UUID应与先前收到的UUID匹配。

Open the crash log (X Code - Organizer - crashes), and find the line where appears the "Binary images" title. 打开崩溃日志(X代码 - 管理器 - 崩溃),找到出现“二进制图像”标题的行。 Here is another UUID in the first line, which should match again with the previously received in the terminal. 这是第一行中的另一个UUID,它应该与先前在终端中接收的UUID再次匹配。

Now, you are assured the crash was logged in the build you are examining, so open again the crash log file, find the Thread 0 section, and there should be two lines with your application name and two addresses. 现在,您确信崩溃已记录在您正在检查的构建中,因此请再次打开崩溃日志文件,找到Thread 0部分,并且应该有两行包含您的应用程序名称和两个地址。 Such as: 如:

Application_name 0x123456
Application_name 0x987654

In the terminal you should run now: atos -arch armv7 -o address1 address2 (the address1 and address2 should be replaced with the previous two addresses, and the armv7 with your system's - it is shown at the lines, where you got the UUIDs). 在终端你应该现在运行: atos -arch armv7 -o address1 address2 (地址1和地址2应该用前两个地址替换,armv7用你的系统替换 - 它显示在你获得UUID的行上) 。

Happy debugging! 快乐的调试!

EDIT: I would like to mention this post as base of mine. 编辑:我想提到这篇帖子作为我的基础。

Actually, you can't decode the dSYM file, but get the error detail from it 1. find the crash thread and address from log file:following is 0x0nnn 2. find the native Code Type from log file: following is arm64 实际上,您无法解码dSYM文件,但从中获取错误详细信息1.从日志文件中找到崩溃线程和地址:以下是0x0nnn 2.从日志文件中查找本机代码类型:以下是arm64
3. find the dSYM file(symbol file),extract from .xcarchive: following is xx.app.dSYM 3.找到dSYM文件(符号文件),从.xcarchive中提取:以下是xx.app.dSYM

dwarfdump --lookup 0x0nnn --arch=[arm64 armv6 armv7] xx.app.dSYM

Inspiration 灵感

https://developer.apple.com/library/archive/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATEWITHXCODE https://developer.apple.com/library/archive/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-SYMBOLICATEWITHXCODE

Steps to get a dsym file 获取dsym文件的步骤

  • Build the iOS app for Archive 为Archive创建iOS应用程序
  • Extract the MyApp.xcarchive 解压缩MyApp.xcarchive
  • Inside that file, you will find your dSYM file. 在该文件中,您将找到您的dSYM文件。

Get your device crash log 获取设备崩溃日志

Pull the .crash file off a device. 从设备中拉出.crash文件。 I normally use xCode for this. 我通常使用xCode。

Line-by-line method 逐行方法

atos -arch arm64 -o TheElements.app.dSYM/Contents/Resources/DWARF/TheElements -l 0x1000e4000 0x00000001000effdc

0x1000e4000 = address of your app's image
0x00000001000effdc = is the stripped name of the symbol you want to turn into a readable name

Pro method 亲方法

Get the location of symbolicatecrash executable. 获取symbolicatecrash可执行文件的位置。

In xCode 9, the file you want is here: 在xCode 9中,您需要的文件位于:

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

Print symbolicated crash log to terminal 将符号化的崩溃日志打印到终端

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

./symbolicatecrash -v crash_log_20_9_2018.crash myapp.app.dSYM

Reading

Nice instructions for atos here: How to symbolicate crash log Xcode? 这里有很好的atos说明: 如何象征崩溃日志Xcode?

Way to perform the same without the dsym file here: https://medium.com/@Mrugraj/crash-re-symbolication-5c28d3a3a883 在没有dsym文件的情况下执行相同的方法: https ://medium.com/@Mrugraj/crash-re-symbolication-5c28d3a3a883

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM