NSObjCMessageLogging在 iPhone 3.0 上启用
我正在调试一个为 iPhone OS 2.2.1 编写的程序,并且必须针对 3.0 稍微重写。 拥有所有正在执行的 Objective-C 消息调用(包括“幕后”调用)的列表将非常有用。
我在网站上找到了 NSObjCMessageLoggingEnabled,但不确定它是否适用于 iPhone。 有谁知道这是否/如何工作,如果不是,是否有其他方法可以实现同样的目标?
谢谢!
I'm debugging a program that was written for iPhone OS 2.2.1 and has to be slightly rewritten for 3.0. Having a list of all the Objective-C message calls that are being made, including "behind-the-scenes" calls, would be very useful.
I found NSObjCMessageLoggingEnabled on a website, but am not sure if it works with the iPhone. Does anyone know if/how this works, and if not, if there is another way I could achieve the same thing?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于找到了一种相对简单(尽管一点也不优雅)的方法来做到这一点。
在 iPhone 上调试时,我为 objc_msgSend 设置了一个断点。 然后我输入了这个简单的 GDB 脚本:
这会打印出每个方法调用。 它并不完美,因为它打印出消息发送到的对象的类名,而不是对象本身,但它可以满足我的需要。
请注意,这仅适用于 iPhone 本身。
I finally figured a out a relatively simple (although not at all elegant) way to do this.
While debugging on the iPhone, I set up a breakpoint for objc_msgSend. I then typed in this simple GDB script:
This prints out each method call. It's not perfect, because it prints out the class name of the object the message is being sent to, and not the object itself, but it works for what I needed.
Note this will only work on the iPhone itself.
NSObjCMessageLoggingEnabled
(及其孪生instrumentObjcMessageSends(BOOL)
)在模拟器中可用,但在设备上不可用。NSObjCMessageLoggingEnabled
(and its twininstrumentObjcMessageSends(BOOL)
) are available in the simulator, but not on the device.