lldb断点对类class c中的所有方法 [英] lldb breakpoint on all methods in class objective c

查看:219
本文介绍了lldb断点对类class c中的所有方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用lldb自动在Objective C类的所有方法上设置断点?

How can I automate setting a breakpoint on all methods in an Objective C class using lldb?

这对于学习复杂遗留类的行为很有用。我正在使用Xcode(包括lldb)进行iOS开发,手动浏览Xcode中的(大)文件并单击每个方法旁边的装订线来设置断点很麻烦。

This is useful for learning the behavior of a complicated legacy class. I am using Xcode (includes lldb) for iOS development, and it is cumbersome to manually go through the (large) file in Xcode and click the gutter next to each method to set breakpoints.

推荐答案

一种选择是使用正则表达式断点。

One option is to use regex breakpoints.

breakpoint set -r '\[ClassName .*\]$'

您可以使用正则表达式来适应你的需求。

You can play around with the regexp to suit your needs.

该命令将创建一个断点,该断点在该类实现的所有方法上停止。但是,从超类继承的方法将没有断点。

The command will create a breakpoint that stops on all methods implemented by that class. However, there will be no breakpoints on methods inherited from superclasses.

要获取超类的方法,您必须使用条件断点。例如,如果超类是 UIViewController ,您可以执行以下操作:

To get methods on the superclass, you'll have to use a conditional breakpoint. For example, if the superclass is UIViewController, you could do something like:

br s -r '\[UIViewController .*\]$' -c '(BOOL)[(id)$arg1 isKindOfClass:[CustomVC class]]'

对于x86更改(id)$ arg1 *(id *) ($ ebp + 8)

最后,如果您真的想了解各种类的控制流程,请查看dtrace。它可能比调试器更适合这种情况。

Finally, if you really want to learn about the control flow through various classes, check out dtrace. It's probably more suited to this than a debugger.

这篇关于lldb断点对类class c中的所有方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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