简体   繁体   English

NSObjCMessageLoggingEnabled与iPhone 3.0

[英]NSObjCMessageLoggingEnabled with iPhone 3.0

I'm debugging a program that was written for iPhone OS 2.2.1 and has to be slightly rewritten for 3.0. 我正在调试一个为iPhone OS 2.2.1编写的程序,并且必须稍微重写为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. 拥有所有正在进行的Objective-C消息调用的列表,包括“幕后”调用,将非常有用。

I found NSObjCMessageLoggingEnabled on a website, but am not sure if it works with the iPhone. 我在网站上找到了NSObjCMessageLoggingEnabled,但我不确定它是否适用于iPhone。 Does anyone know if/how this works, and if not, if there is another way I could achieve the same thing? 有谁知道这是否/如何工作,如果没有,如果有另一种方式我可以实现同样的事情?

Thanks! 谢谢!

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. 在iPhone上进行调试时,我为objc_msgSend设置了一个断点。 I then typed in this simple GDB script: 然后我输入这个简单的GDB脚本:

while 1
printf "[%s %s]", (char *)object_getClassName($r0), (char *) $r1 
c
end

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. 请注意,这只适用于iPhone本身。

NSObjCMessageLoggingEnabled (以及它的双NSObjCMessageLoggingEnabledinstrumentObjcMessageSends(BOOL) )在模拟器中可用,但在设备上不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM