How can I inspect an objective c object in GDB if the code I'm tracing
doesn't have debugger symbols?
For instance, I've got QuickTime Player loaded in GDB, and at one point
I stop just before a call that passes an NSDictionary to another
constructor. Because its objc, I know that 'self' is in r3, the selector
in r4, and thus the NSDictionary is in r5. How can I see what's in that
NSDictionary? Something like
(gdb) print-object $r5
NSDictionary
only shows me the name of the class: "NSDictionary". I also tried
(gdb) call (NSString *)[$r5 description]
$1 = (class NSString *) 0x3af550
(gdb) po $1
NSDictionary
This appears to call the method and store the result in GDB memory. But
still it only shows me the name "NSDictionary". I guess maybe I need to
cast $r5 but I can't figure out the syntax.
Any pointers?
|\/| /| |2 |<
mehaase(at)gmail(dot)com
Michael Ash - 26 Dec 2005 19:51 GMT
> How can I inspect an objective c object in GDB if the code I'm tracing
> doesn't have debugger symbols?
[quoted text clipped - 18 lines]
> still it only shows me the name "NSDictionary". I guess maybe I need to
> cast $r5 but I can't figure out the syntax.
It's showing you this because you have a pointer to the NSDictionary class
in r5. I don't know why it would be doing this, but that's what I can
determine from seeing this. Classes print out their name for their
description. NSDictionary instances should print their contents.
You can verify this by comparing the value of $r5 with the value of [$r5
class]. If they're the same, then it's a class for sure. If they're
different, it's an instance.

Signature
Michael Ash
Rogue Amoeba Software
Peter Ammon - 27 Dec 2005 23:14 GMT
> How can I inspect an objective c object in GDB if the code I'm tracing
> doesn't have debugger symbols?
[quoted text clipped - 20 lines]
>
> Any pointers?
This usually happens because $r5 contains the NSDictionary class itself,
not an instance of NSDictionary.
If you want to confirm this, compare the value of [$5 class] to $r5
itself. Is $r5 is a class, the values will match.
-Peter

Signature
Pull out a splinter to reply.