I am running into an error in my iOS app, and the Stack Trace is not particularly illuminating. When I run the command bt on the (lldb) debugger console, it spits out a full back trace, like this:
frame #0: 0x39de23e4 libsystem_c.dylib`__vfprintf + 28
frame #1: 0x39df82c6 libsystem_c.dylib`__v2printf + 374
frame #2: 0x39da723c libsystem_c.dylib`_vsnprintf + 348
frame #3: 0x39da7b2c libsystem_c.dylib`vsnprintf_l + 32
frame #4: 0x39da7b06 libsystem_c.dylib`snprintf_l + 22
frame #5: 0x2f0a19d0 CoreFoundation`__CFStringAppendFormatCore + 8464
frame #6: 0x2f010610 CoreFoundation`_CFStringCreateWithFormatAndArgumentsAux + 76
frame #7: 0x2f9e8162 Foundation`-[NSPlaceholderString initWithFormat:locale:arguments:] + 130
frame #8: 0x2f9e8068 Foundation`+[NSString stringWithFormat:] + 60
* frame #9: 0x002ce4e0 myApp`PFMD5HashFromData(data=0x18109b60) + 412 at PFHash.m:63
frame #10: 0x002d4e42 myApp`-[PFJSONCacheItem initWithObject:](self=0x18109890, _cmd=0x31facc39, object=0x18138b90) + 286 at PFInternalUtils.m:286
frame #11: 0x002d500a myApp`+[PFJSONCacheItem cacheFromObject:](self=0x006e00c8, _cmd=0x0058acb3, object=0x18138b90) + 74 at PFInternalUtils.m:300
frame #12: 0x002e56d8 myApp`-[PFObject(self=0x18151620, _cmd=0x0058bdd1, object=0x18138b90, key=0x0064a2e8) checkForChangesToMutableContainer:forKey:]
Is it possible to use the LLDB debug console to view human-readable data at specific memory addresses?
For example, the values that show up like this:
(self=0x18109890, _cmd=0x31facc39, object=0x18138b90)
Can I print out these values so I can see the data at these memory addresses?
For example: if I had the following value in memory:
// NSString @ memory address: 0x123456
NSString *example = @"exampleString";
What LLDB command could I use to see the human-readable value of exampleString
at memory address 0x123456
?
Per the suggestions of others (thanks Jim Ingham) and various internet searches, I have tried the following commands:
(lldb) expr *((MyObjectType *) 0x123456)
(lldb) frame variable *object
memory read -s1 -fu -c10000 0x123456 --force
and a few others, but all these give me are even more memory addresses, or memory dumps that are not human-readable. What I am hoping to do, is read or print out the actual values that would have flowed through my program to see some clues about what could be going wrong.
I was finally able to print the values based on the advice I have received in this post so far. The reason I was getting more cryptic memory addresses was because I was trying to evaluate pre-complied binaries. When I ran the suggested commands against my own project code, everything worked.
Sure. If you want raw memory dumps, try the memory read
command. If you have debug info for the type of the object, you can pass it to the -t
option to memory read
(this is more useful for arrays of objects.)
Or you can use the expression parser, something like:
(lldb) expr ((MyObjectType *) 0x18138b90)
If you are in frames with debug info, you can also use frame variable
to view locals & arguments. So for instance:
(lldb) frame variable *object
should show you the contents of object
.