NSObjCMessageLoggingEnabled with iPhone 3.0
-
06-07-2019 - |
Question
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!
Solution
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:
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.
OTHER TIPS
NSObjCMessageLoggingEnabled
(and its twin instrumentObjcMessageSends(BOOL)
) are available in the simulator, but not on the device.