首页 > Xcode如何设置condition给-[__NSArrayM insertObject:atIndex:]断点

Xcode如何设置condition给-[__NSArrayM insertObject:atIndex:]断点

最近程序总是出现
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
* First throw call stack:
(0x185aa82d8 0x196ef40e4 0x18598f4c0 0x18a816f80 0x18a555704 0x18a56d2c4 0x18a7234f4 0x18a706f10 0x1003de5c8 0x1004c22fc 0x1001c6040 0x185a4e2c4 0x18598b450 0x1868baa80 0x100197670 0x100184d20 0x1001835dc 0x10072146c 0x1869a9f9c 0x185a60240 0x185a5f4e4 0x185a5d594 0x1859892d4 0x18f2876fc 0x18a586f40 0x10024fae0 0x19759ea08)

我想设置一个条件断点,当insertObject第一个参数为nil时触发断点,否则程序继续运行。

如何设置condition呢?谢谢。


$arg1==nil
$arg2==nil
$arg3==nil

忘了是123了,试试看吧

http://philcai.com/2015/10/29/Debug-CUICatalog-Invalid-asset-name-supplied-null/


lldb/gdb设置Symbolic断点有个前提条件,即需要知道该方法在Mach-O文件中的地址,或者该方法在头文件中声明了。私有方法不符合以上任一条件,因此想直接在Xcode中设置Symbolic断点是不会有效的。
如果你在console中直接使用lldb打断点

br set -F "[_NSArrayM insertObject:atIndex:]"

会得到

Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

一个可行的思路是通过class-dump获取到SDK中私有方法的symbol,封装到一个空的动态库中,再导入到lldb中
https://stackoverflow.com/questions/17554070/import-class-dump-info-into-gdb

题主不妨试试。


使用assert语法,不用设置断点

assert(someVar != nil, "Some alert information")

【热门文章】
【热门文章】