Re: gdb: Newbie can't use 'print -[object message]'
Re: gdb: Newbie can't use 'print -[object message]'
- Subject: Re: gdb: Newbie can't use 'print -[object message]'
- From: Roland King <email@hidden>
- Date: Sun, 24 Jan 2010 13:42:24 +0800
You probably aren't misinterpreting the documentation, that's what it says.
However as far as I know you don't need the '-' and it doesn't work that way (it tries to evaluate it as a unary minus), you do need to tell it however what the return type of the function is because gdb never knows unless it's an object.
So I think that 'print -[object hash]' in the documentation should really say 'print (unsigned int)[ object hash ]' and for what you're doing, since the function returns an object (NSString*) you want to use po again on the result
po [ 0x2e18fb80 description ]
or, somewhat uselessly
p (NSString*)[ 0x2e18fb80 description ]
which will give you the address of the string, which is likely not what you want, unless it is.
On 24-Jan-2010, at 1:32 PM, Jerry Krinock wrote:
> I know how to print the result of a -description message to an Obj-C object in gdb by using 'po'. But I would sometimes like to print the results of other messages. In the document "Debugging with GDB", I found this:
>
> ************************************
>
> The Print Command With Objective-C
>
> The print command has also been extended to accept methods. For example:
>
> print -[object hash]
>
> will tell GDB to send the hash message to object and print the result.
>
> ************************************
>
> Great! So, while debugging, just to test this, I asked gdb for the -description of the object at 0x2e18fb80 as shown below, but it gave me a bad answer....
>
> (gdb) print -[0x2e18fb80 description]
> Argument to negate operation not a number.
>
> How am I misinterpreting the documentation?
>
> Thanks,
>
> Jerry
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden