如何静态转储在Cocoa应用程序中调用的所有ObjC方法? [英] How to statically dump all ObjC methods called in a Cocoa App?

查看:148
本文介绍了如何静态转储在Cocoa应用程序中调用的所有ObjC方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个基于Cocoa的Mac或iOS应用程序。我想在我的应用程序的源代码 上运行一个静态分析器来检索所有Objective-C方法的列表 strong>称为。是否有可以执行此操作的工具?



以下几点:


  1. 我在寻找一个静态解决方案。我不是在寻找动态解决方案


  2. 可以对二进制或源代码运行的任何东西都是可以接受的。


  3. 理想情况下,输出只是一个重复的Objective-C方法列表,如:

     
    ...
    - [MyClass foo]
    ...
    + [NSMutableString stringWithCapacity:]
    ...
    - [NSString length]
    ...

    (如果它不是去重的,那么很酷)


  4. <


  5. 我熟悉 class-dump ,但AFAIK会将二进制文件中声明的类转储,而不是二进制文件中的方法。这不是我想要的。如果我错了,您可以使用类别转储执行此操作,请更正我。


  6. 这是可行的。所以如果不是,这也是一个很好的答案。 :)



解决方案

我最清楚的是 otx ,它是 otool 的一个包装,可以在objc_msgSend()调用站点重建选择器。



http://otx.osxninja.com/


Assume I have a Cocoa-based Mac or iOS app. I'd like to run a static analyzer on my app's source code or my app's binary to retrieve a list of all Objective-C methods called therein. Is there a tool that can do this?

A few points:

  1. I am looking for a static solution. I am not looking for a dynamic solution.

  2. Something which can be run against either a binary or source code is acceptable.

  3. Ideally the output would just be a massive de-duped list of Objective-C methods like:

    …
    -[MyClass foo]
    …
    +[NSMutableString stringWithCapacity:]
    …
    -[NSString length]
    …
    

    (If it's not de-duped that's cool)

  4. If other types of symbols (C functions, static vars, etc) are present, that is fine.

  5. I'm familiar with class-dump, but AFAIK, it dumps the declared Classes in your binary, not the called methods in your binary. That's not what I'm looking for. If I am wrong, and you can do this with class-dump, please correct me.

  6. I'm not entirely sure this is feasible. So if it's not, that's a good answer too. :)

解决方案

The closest I'm aware of is otx, which is a wrapper around otool and can reconstruct the selectors at objc_msgSend() call sites.

http://otx.osxninja.com/

这篇关于如何静态转储在Cocoa应用程序中调用的所有ObjC方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆