在gdb中调试objc时如何检查'super'

Jim*_*Jim 8 xcode cocoa gdb objective-c xcode4

从xcode中,gdb给出以下内容:

> po self
<SomeClassName: 0x6672e50>
Run Code Online (Sandbox Code Playgroud)

到目前为止这么好......但是:

> po super
No symbol "super" in current context.
Run Code Online (Sandbox Code Playgroud)

为了清楚起见,我真正想做的是super在调试时发送消息.例如,我想做这样的事情:

> po [super doSomething]
Run Code Online (Sandbox Code Playgroud)

但是我如何super从gdb环境中引用?谢谢!

Jos*_*ell 4

嘿,我们刚刚在谈论这个!除了作为消息的接收者(即 )之外,该词super没有任何作用[super doSomething]。这只是向编译器发出的一个注释,它应该在超类而不是当前类对象中搜索方法的实现。

如果您想要一个对象的实际超类对象,请使用NSObject协议的superclass方法[self superclass]


我不知道如何做你想要的事情。调试器挂钩怎么样?将其放入您的班级中:

- (void) callSupersDoSomething {
    [super doSomething];
}
Run Code Online (Sandbox Code Playgroud)

然后您可以[self callSupersDoSomething]从调试器调用。