On Dec 2, 2009, at 4:55 PM, Graham Cox wrote:
> When I get a stack trace in a crash report, as exampled below, can I use the 
> offsets (+71, +50) to locate the relevant line in the source code? What do 
> these numbers actually mean?
> 
> 1   com.apptree.drawkit               0x001c7bb9 -[DKDrawableObject 
> encodeWithCoder:] + 71
> 2   com.mapdiva.ortelius              0x0003c81d -[DKOSymbol 
> encodeWithCoder:] + 50

That's the offset in bytes of the CPU instruction in that function - the 
crashing instruction in the top frame, and the instruction after the call in 
the other frames.

You can recover the line number if you have the binary and dSYM file that match 
the version from the crash.

(The values below are all fake.)

1. Find the binary's UUID in the Binary Images section of the crash log.
    Binary Images:
        0x1000 -     0x1ff7 +com.apptree.drawkit ??? (???) 
<A84E261F-B98E-8ECD-3A40-24C65353BE3E> 
/path/to/DrawKit.framework/Contents/MacOS/DrawKit

2. Find the binary for the version with that UUID.
    % dwarfdump -u /path/to/DrawKit.framework
    UUID: D0358F4B-FCBB-321A-5F9E-E4C36C20ADE9 (x86_64) 
/path/to/DrawKit.framework/Contents/MacOS/DrawKit
    UUID: A84E261F-B98E-8ECD-3A40-24C65353BE3E (i386) 
/path/to/DrawKit.framework/Contents/MacOS/DrawKit

3. Find the dSYM file with that UUID. A Spotlight search for the UUID may work.
    % dwarfdump -u /path/to/DrawKit.framework.dSYM
    UUID: D0358F4B-FCBB-321A-5F9E-E4C36C20ADE9 (x86_64) 
/path/to/DrawKit.framework.dSYM/Contents/Resources/DWARF/DrawKit
    UUID: A84E261F-B98E-8ECD-3A40-24C65353BE3E (i386) 
/path/to/DrawKit.framework.dSYM/Contents/Resources/DWARF/DrawKit

4. Run gdb with that architecture, binary, and dSYM.
    % gdb -arch i386 /path/to/DrawKit.framework
    (gdb) add-dsym /path/to/DrawKit.framework.dSYM

5. Ask gdb for the line number for that function+offset. (Note the actual 
address may not match the one in the crash log.)
    (gdb) x/i '-[DKDrawableObject encodeWithCoder:]' + 71
    0x4bb9 <-[DKDrawableObject encodeWithCoder:]+71> ...
    (gdb) info line *0x4bb9
    Line 55 of "DKDrawableObject.m" starts at address 0x4bb9 
<-[DKDrawableObject encodeWithCoder:]+71> and ends at 0x4bc9 
<-[DKDrawableObject encodeWithCoder:]+87>


-- 
Greg Parker     [email protected]     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to