问题描述
我想在特定类中特定属性的 objectAtIndex:方法上设置符号断点。
I would like to set a symbolic breakpoint on "objectAtIndex:" method of a specific property in a specific class.
请参见以下代码:
@interface Foo
...
@property (strong,nonatomic) NSMutableArray *fooArray;
...
@end
我尝试了以下操作:
-
-[[Foo fooArray] objectAtIndex:]
-
-[Foo :: fooArray objectAtIndex:]
-
-[Foo :: fooArray objectAtIndex]
-
Foo :: fooArray :: objectAtIndex:
-
Foo :: fooArray :: objectAtIndex
-
Foo :: fooArray :: objectAtIndex()
-[[Foo fooArray] objectAtIndex:]
-[Foo::fooArray objectAtIndex:]
-[Foo::fooArray objectAtIndex]
Foo::fooArray::objectAtIndex:
Foo::fooArray::objectAtIndex
Foo::fooArray::objectAtIndex()
这些解决方案均无效。
任何
推荐答案
经过一番挖掘,我找到了解决之道。
After some digging, I found a way to work this out. That's kinda ugly.
这涉及到在第一个断点触发的命令中动态创建条件断点。
It involves creating a conditional breakpoint dynamically, in a command triggered by a first breakpoint.
首先,只要您的fooArray准备好就中断。我选择了 fooArray
访问器,但可以更早完成:
First, break whenever your fooArray is ready. I settled on the fooArray
accessor, but it could be done earlier :
断点集--name-[Foo fooArray]
然后,想要的是<$在此特定数组对象上调用c $ c> objectAtIndex:。首先让我们将其指针放在变量中:
Then, what you want is break when objectAtIndex:
is called on this specific array object. First let's put its pointer in a variable :
expr id $ watch = self-> _fooArray
,然后在以下条件下使用此变量创建新的断点:
and then create a new breakpoint, using this variable in the condition :
断点集--name-[__ NSArrayI objectAtIndex:]-条件 $ rdi == $ watch
-
$ rdi
包含self
x86_64
。在ARM上使用$ r0
。 (请参阅Clark Cox的。) 永远不会调用 -
-[NSArray objectAtIndex:]
。如Peter所述,NSArray是一个类集群,而您的数组实际上是__ NSArrayI
。
$rdi
containsself
, at least onx86_64
. Use$r0
on ARM. (See Clark Cox's great post on the topic.)-[NSArray objectAtIndex:]
is never called. As Peter mentioned, NSArray is a class cluster, and your array is actually an__NSArrayI
.
或者,在Xcode中:
Or, in Xcode :
(不要忘记选中继续框。)
(Don't forget to check the "continue" box.)
这不是真的漂亮,但似乎可以用!
It's not really beautiful, but it seems to work !
这篇关于如何在“ objectAtIndex:”上设置断点XCode 4中特定类中特定属性的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!