Parsing of IOS crash files (i)
No matter how careful we are in the process of developing the program, we will always inadvertently encounter a program flash-back. Brain Repair When you are in front of a group of people confidently holding your app for function rehearsal, the smooth operation is ruthlessly crash interrupted. Reminiscent of Lao Luo in the release of Smartisan OS when said, he prepared 10 mobile phones, if one has a problem, change one, if 10 after hanging he will not do mobile phone. All right, let's talk about it today. Ioscrash file composition and commonly used analysis tools.
There is a WWDC 2010 video recommended for everyone to take a look at the video name "Understanding Crash Reports on IPhone OS", the video details the structure of the Crash file. Of course, if you don't have time to read it, you may want to review the following article.
I. Structure of the crash file
When the program runs crash, the system will record the running information of the last moment of the run and store it in a file, which is what we call the crash file. iOS crash logs are usually made up of the following 6 parts.
1. Process information (Progress information)
Incident Idnetifier |
Unique identifier of the crash report, different crash |
Crashreporter Key |
The unique key value corresponding to the device ID (not the udid of the real device, which Apple has not been able to secure in order to protect the user's privacy iOS6). This value is usually the same when the same version of the app on the same device occurs crash. |
Hardware Model |
Represents the type of device in which the crash occurred, and "ipad4,4" represents the ipad Air |
Process |
The process name that represents crash, usually the name of our app, [] which is the ID of the process at that time. |
Path |
Executable program on the phone storage location, note the path to Xxx.app/xxx,xxx.app is actually as a bundle, the real executable is actually the bundle inside of XXX, interested can check the relevant information on their own, have the opportunity I will also introduce to |
Identifier |
Your app's indentifier, usually "com.xxx.yyy", XXX represents your company's domain name, yyy represents an app |
Version |
The version number of the current app, consisting of two fields in Info.plist, and CFBundleShortVersionString CFBundleVersion |
Code Type |
CPU architecture of the current app |
Parent Process |
The parent process of the current process, since iOS apps are usually single-process, the general parent process is LAUNCHD |
2. Basic Information
Date/time |
Crash occurrence of time, readable string |
OS Version |
The number in the system version, () represents the time Bulid number |
Report Version |
Crash log format, is basically 104, different version contains the fields may have different |
3, Exception (very important)
Exception Type |
Exception type |
Exception Subtype: |
Exception subtype |
Crashed Thread |
The thread number in which the exception occurred |
4. Thread BackTrace
The crash call stack of the thread that occurs crash, from top to bottom, represents the order of the calls, the top one represents the location where the exception is thrown, and in turn you can see the order in which the API is called. The information indicates that this time crash appears Xxxviewcontroller 323 rows, the function call of the error is ordercountloadfailed.
5. Thread State
Crash time occurs, the state of the thread, usually we can get the relevant information according to the crash stack, this part of the general do not care.
6, Binary Images
Crash moment app loads all the libraries, where the first line is the information of our app executable when crash occurs, can be seen as ARMV7, the package of the executable file is the UUID bit c0f......cd65, When parsing crash, the UUID of the dSYM file must be the same as this to complete the symbolic parsing of the crash.
Ii. Common types of crash
1. Watchdog Timeout
Exception code:0x8badf00d, not very intuitive, can be read as "Eat bad food", meaning that don ' t block main thread
Next there is a description:
Application Specific information:
Com.xxx.yyy failed to resume in time
For this type of crash, we should look at the correct things to do when the app is initialized, whether the main thread requests the network, or other time-consuming things that are stuck in the normal initialization process.
Usually the system allows an app to boot up to a maximum of 5 s for the user event, and if it exceeds the 5s,app it will be terminated by the system. There will be a corresponding time requirement when launch,resume,suspend,quit. In the highlight thread we can see where it was called when it was terminated, Xxxappdelegate plus the line number.
PS. In order to facilitate debugging when connecting Xcode debugging, the system temporarily disables watchdog, so the discovery of such problems requires the use of a normal startup mode.
2. User Force-quit
Exception Codes:0xdeadfa11, Deadfall
This forced exit with what we usually say kill the background task operation is not quite the same, usually in the program bug caused the system can not respond to use long press the Power key, when the screen appears when the Shutdown Confirmation screen press the home button to close the current program.
3. Low Memory termination
Unlike the general crash structure, which usually consists of free pages,wired pages,purgeable pages,largest process, the colleague lists information about all the processes that the system is running at the current moment.
About memory warning you can see an article I wrote earlier iOS memory warning warning level.
When the app is running, the system will usually warn you when the memory is tight, terminate the program that hangs in the background, and end the process of the current foreground if the memory is not enough.
When the memory warning is received, we should release as much memory as possible, and crash can actually be seen as a protection against the app.
4, Crash due to bugs
Because the program bug caused by crash usually strange, difficult to generalize. Most of the situation through the crash log can locate the problem, of course, do not rule out some of the incurable diseases look half a day is not worth the trouble. This is only to see the foundation, a little bit, always find clues. You can also turn to Google when you do not see the big God, there are people who have the same bug as you
Iii. Common Exception Type & Exception Code
1. Exception Type
1) exc_bad_access
This type of excpetion is our longest-running crash and is typically used to access memory that is not changed. The "()" Behind the general Exc_bad_access will also have additional information.
SIGSEGV: This type should be rarely seen after switching arc, usually due to repeated release of the object.
SIGABRT: The abort signal is received, usually the container in the Foundation library does some testing in order to protect the state, such as inserting nil into the array medium, and encountering such errors.
SEGV: (segmentation violation), representing invalid memory address, such as null pointer, uninitialized pointer, stack overflow, etc.;
Sigbus: Bus error, unlike SIGSEGV, SIGSEGV accesses an invalid address, while Sigbus accesses a valid address, but bus access exceptions (such as address alignment issues)
Sigill: Attempt to execute an illegal instruction that may not be recognized or has no permissions
2)EXC_BAD_INSTRUCTION
This type of exception is usually caused by a thread executing an illegal instruction
3)EXC_ARITHMETIC
This exception is thrown in addition to the 0 error
2. Exception Code
0xbaaaaaad |
This type of log means that the crash log is not a real crash, it simply contains the running state of the entire system at some point in time. Can usually be triggered by the user accidentally by pressing the home key and the volume key at the same time |
0xbad22222 |
When a VoIP program is activated too frequently in the background, the system may terminate such programs |
0x8badf00d |
This has been described earlier, program startup or recovery time too long by watch dog termination |
0xc00010ff |
The program executes a lot of CPU-and GPU-intensive operations, causing the device to overheat, triggering system overheating protection is terminated by the system |
0xdead10cc |
System resources are also used when the program is retired to the background, such as contacts being terminated by the system |
0xdeadfa11 |
As mentioned earlier, the program does not respond to user forced shutdown |
Iii. ways to obtain crash
1, the Machine
By connecting the test machine through Xcode, all crash logs that occur on the machine can be read directly from the device.
2. itunes Connect
Get the crash log reported to the user via itunes Connect background.
3, third-party crash collection system
There are many excellent third-party crash collection systems that greatly facilitate our collection of crash, even with the ability to symbolize crash logs. More commonly used are crashlytics,flurry and so on.
Iv. Appendices
Apple official Documentation: Understanding and Analyzing IOS application Crash Reports
Technical Note TN2123 Crashreporter
Https://developer.apple.com/library/ios/qa/qa1592/_index.html
WWDC Video: Understanding Crash Reports on IPhone OS
Crash Log recording is the time of crash, the call stack of functions, and threads and other information written to the file. Generally are directly written 16 of the address, if not symbolized, it is basically difficult to obtain useful information, the next one we will talk about crash log of the symbolic, popular point is to let the crash log into our readable format.
Note:smileevday reserves all rights to this article
Reprint please the source of the famous source
All the content in this article represents a personal point of view, if there is something wrong, please point out.
Ios:crash file Analysis (i)