Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inspect 'super' when debugging objc in gdb

From within xcode, gdb gives the following:

> po self
<SomeClassName: 0x6672e50>

So far so good... But:

> po super
No symbol "super" in current context.

In the interest of clarity, what I really want to do is send a message to super while debugging. For example, I want to do something like this:

> po [super doSomething]

But how do I reference super from within the gdb environment? Thanks!

like image 671
Jim Avatar asked May 30 '11 00:05

Jim


Video Answer


2 Answers

Something to keep in mind here, is that super == self. It's the same object pointer, but the super keyword tells the message dispatch code to start looking for an implementation one level back in the class hierarchy.

like image 50
NSResponder Avatar answered Oct 17 '22 19:10

NSResponder


Hey, we were just talking about this! The word super doesn't have any effect except as the receiver of a message, i.e., [super doSomething]. It's just a note to the compiler that it should search for the implementation of a method in the superclass rather than the current class object.

If you want an object's actual superclass object, use the NSObject protocol's superclass method: [self superclass].


I don't know how to do exactly what you want. How about a debugger hook? Put this into your class:

- (void) callSupersDoSomething {
    [super doSomething];
}

and then you can call [self callSupersDoSomething] from the debugger.

like image 44
jscs Avatar answered Oct 17 '22 20:10

jscs