• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gdb: Newbie can't use 'print -[object message]'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >gdb: Newbie can't use 'print -[object message]' (From: Jerry Krinock <email@hidden>)
 >Re: gdb: Newbie can't use 'print -[object message]' (From: Roland King <email@hidden>)
 >Re: gdb: Newbie can't use 'print -[object message]' (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: detecting and acting on xcode version in proj file?
  • Next by Date: Re: what's with the admin privilege business
  • Previous by thread: Re: gdb: Newbie can't use 'print -[object message]'
  • Next by thread: Small question pertaining to memory management
  • Index(es):
    • Date
    • Thread