views:

177

answers:

2

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!

A: 

NSObjCMessageLoggingEnabled (and its twin instrumentObjcMessageSends(BOOL)) are available in the simulator, but not on the device.

rpetrich
Thanks. I found another (less elegant) way using GDB.
dvorak
+2  A: 

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.

dvorak
You can just put that as an action for the breakpoint in xcode
Frank Szczerba