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: Jerry Krinock <email@hidden>
- Date: Tue, 26 Jan 2010 09:14:38 -0800
On 2010 Jan 23, at 22:14, Clark Cox wrote:
> On Sat, Jan 23, 2010 at 9:42 PM, Roland King <email@hidden> wrote:
>> 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 ]
Thank you, Roland. That works. I filed a bug, 7579542, quoted below.
>
> And since, you're just printing the description: ...
Yes, but actually I want to send other messages. I was just using that as a trivial example. Anyhow, thanks for the info in debugDescription. That will prove useful too.
Jerry
Apple Bug ID 7579542
Debugging with gdb, Ninth Edition, for GDB version 6.3.50.20050815-cvs
Summary: The document "Debugging with GDB" ▸ Using GDB with Different Languages ▸ Objective-C/C++ gives incorrect syntax for using the 'print' command.
Steps to Reproduce:
1. In debugging, need to send an Obj-C message.
2. Read http://developer.apple.com/mac/library/DOCUMENTATION/DeveloperTools/gdb/gdb/gdb_13.html
Expected Results:
Correct syntax should be given for the 'print' command.
Actual Results:
Incorrect syntax, as quoted here:
************************************
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.
************************************
Running this command fails because gdb it tries to evaluate '-' as a unary minus
Notes:
Note that 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 'print -[object hash]' in the documentation should instead say 'print (unsigned int)[object hash]'. Also, more examples should be given where the message returns an object which you would want to print with po.
_______________________________________________
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