Whenever any application crashes the system’s crash reporter(/System/Library/CoreServices/Crash Reporter.app) creates a crash dump.A crash dump is the image of the state of the kernel that was in physical memory when the system failed.
The crash log contains a stack trace with whatever program symbol information found in the application.And if the application has stripped of its debugging information(release build),no usefull information about the application’s stack will be logged.
In such situations we can use the atos(“address to symbol”) tool to convert these addresses back to their symbolic names. It may help us to diagnose and fix the underlying problem causing the crash. .
The following is a portion of a crash log TempConverter.crash.log:
Thread 0 Crashed:
0 com.yourcompany.TempConverter 0x00002b84 0x1000 + 7044
1 com.apple.Foundation 0x929ea9c8 _NSSetObjectValueAndNotify + 136
2 com.apple.Foundation 0x929ea6f4 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 180
27 com.apple.AppKit 0x937f887c NSApplicationMain + 452
28 com.yourcompany.TempConverter 0x000029dc 0x1000 + 6620
29 com.yourcompany.TempConverter 0x000026e0 0x1000 + 5856
Because the TempConverter executable has no symbol information, program locations in the TempConverter code segment are listed as hexadecimal offsets. If enough debugging information is available, the tool also supplies the source file name and line number for the address.
To use this tool –
Open a Terminal window, and set the current directory to the".. /TempConverter D/build/" folder.
Then, issue the following command.
$ atos -o Debug/TempConverter.app/Contents/MacOS/TempConverter 0x00002b84
$ -[ConverterApplicationDelegate setCentigradeTemperature:] (in TempConverter) (ConverterApplicationDelegate.m:42)
The atos tool reads the symbols contained in the TempConverter executable file and uses that information to convert the address 0x00002b84 to its symbolic equivalent, complete with source file name and line number as given above.
The documentation of atos tool is given below:
Usage : atos [-p pid|partial-executable-name][-o executable][-f file][-arch architecture][-s slide][-printHeader][ address ... ]
The process ID (or full or partial executable name) of a currently executing process, or else the path to a Mach-O executable.(Multiple process IDs or paths can also be supplied if necessary,and the two can be mixed in any order.)
When working with a running process,atos considers addresses and symbols defined in all executables currently loaded by that process,at their loaded locations.
When working with a Mach-O executable, atos considers only addresses and symbols defined in that executable, at their default locations (unless the -s option is given).
– s slide:
A numeric address will be converted into the symbol whose corresponding range of addresses contains the specified address. With the -s flag, the indicated slide value is subtracted from all input addresses prior to symbol lookup.
With this flag addresses may optionally be taken from a file,which will be read as if it contained whitespace-separated numeric address arguments.
Address may be given in decimal format, or they may be prefixed by 0x or 0X and given in hexadecimal format.
If no address arguments are given on the command line, atos enters an interactive mode, in which it takes addresses from stdin as if it were reading them from a file.
If an address cannot be converted using the first process or executable specified,any other processes or executables specified will be used, in the order specified
If an address still cannot be converted, it will be reprinted unchanged. Results are printedout one to a line, with numeric addresses given in hexadecimal format.
The -printHeader argument indicates that if a process ID was specified, the first line of atos output should be a header of the form “Looking up symbols in process <pid> named: <process-name>”.
It is possible to get symbols for addresses from a different machine architecture than the system on which atos is running.
For example, when running atos on an Intel-based system, one may wish to get for an address that came from a backtrace of a process running on a PowerPC machine. To do so, use the -arch flag to specify the desired architecture (such as i386 or ppc) and pass in a corresponding symbol-rich Mach-O executable with a binary image of the corresponding architecture.