Is there a way to Track/trace and log all the methods, by Class and Method name, during a debug session?

流过昼夜 提交于 2019-12-18 04:46:15

问题


I am not interested in logging into frameworks or under the covers but only at my source level code upon entry and exit of each method. I would like it to provide Class Name and Method Name and log it to file or at least have it fly by on the screen.

My query is if it is possible with existing Xcode/Debugger/Instruments facilities, can I implement it in an easy way other than an NSLog statement at every method entry and exit, or is there a commercial tool that provides this capability ?

I'm talking source methods here... not execution processes or threads. Thanks.


回答1:


Dave Dribin covers precisely this in his article Tracing Objective-C messages.

The part you are after is probably this:

If you set the NSObjCMessageLoggingEnabled environment variable to YES, the Objective-C runtime will log all dispatched Objective-C messages to a file named /tmp/msgSends-<pid>.




回答2:


Xtrace (https://github.com/johnno1962/Xtrace) has many features and works well for tracing Objective-C. One needs source access to their project, like you appear to have, and can emit messages on entry/exit, like you appear to want.

  • Debug-time configuration - can hard-code or configure tracing while debugging
  • Uncomplicated integration - one .mm and one .h
  • NSRegularExpression matching - classes, methods, types


来源:https://stackoverflow.com/questions/6886353/is-there-a-way-to-track-trace-and-log-all-the-methods-by-class-and-method-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!