user529758
user529758

Reputation:

Logging objc_msgSend() on iPhone

I recently ran into a problem for which there were no working solutions on Google. I'd like to log an applications's Objective-C messages to the console or to a file. I didn't write the application so I don't have the source code to recompile with logging included. I have a jailbroken iPhone so no restrictions on how to realize this. I even considered doing this through a MobileSubstrate extension (may I hook objc_msgSend for that application to do some logging?), but had not very much ideas. Can you please help me out with this?

Upvotes: 4

Views: 3190

Answers (1)

cbranch
cbranch

Reputation: 4769

There is a logging mechanism for ObjC messages, but I'm not sure whether you'll get method names without symbol files. Assuming that your jailbroken phone will allow you to run any app under control of the debugger (gdb), you should be able to start the app, set a breakpoint early during the initialization, then do this:

(gdb) call (void)instrumentObjcMessageSends(YES)

The log file will be written to a text file in the tmp folder. More details here:

http://www.dribin.org/dave/blog/archives/2006/04/22/tracing_objc/

Upvotes: 5

Related Questions