问题: 
  
 
我有一种情况,我们在发布期间有媒体播放,并且objc_exception_throw()在此期间大约有5次点击,但总是被捕获,并且它在媒体播放器对象的南边.
我厌倦了(a)必须手动连续n次,或者(b)在播放完成之前必须禁用断点.
我尝试过的:
>使断点忽略前五次命中(问题:它并不总是正好五次)
>使用我的目标作为模块创建我自己的符号断点(问题:没有改变)
我想做什么:
想到的一个解决方案是在断点命中时评估堆栈,并在其中列出特定方法或功能时继续.但我不知道该怎么做.
其他想法也欢迎.
解决方法
 你用 
 Python做到了. 
  
 
        下面定义了一个忽略列表和一个可以作为命令附加到断点的函数.
该函数在回溯中抓取函数的名称,并使用忽略列表将这些名称与这些名称相交.如果任何名称匹配,它将继续运行该过程.这有效地跳过调试器中的不需要的堆栈.
(lldb) b objc_exception_throw
Breakpoint 1: where = libobjc.A.dylib`objc_exception_throw,address = 0x00000000000113c5
(lldb) script
Python Interactive Interpreter. To exit,type 'quit()','exit()' or Ctrl-D.
>>> ignored_functions = ['recurse_then_throw_and_catch']
def continue_ignored(frame,bp_loc,dict):
    global ignored_functions
    names = set([frame.GetFunctionName() for frame in frame.GetThread()])
    all_ignored = set(ignored_functions)
    ignored_here = all_ignored.intersection(names)
    if len(ignored_here) > 0:
        frame.GetThread().GetProcess().Continue()
quit()
(lldb) br comm add -F continue_ignored 1
(lldb) r 
 我在下面的文件中尝试了它,它成功地跳过recurse_then_throw_and_catch中的第一次抛出,并在throw_for_real内部抛出时进入调试器.
#import <Foundation/Foundation.h>
void
f(int n)
{
    if (n <= 0) @throw [NSException exceptionWithName:@"plugh" reason:@"foo" userInfo:nil];
    f(n - 1);
}
void
recurse_then_throw_and_catch(void)
{
    @try {
        f(5);
    } @catch (NSException *e) {
        NSLog(@"Don't care: %@",e);
    }
}
void
throw_for_real(void)
{
    f(2);
}
int
main(void)
{
    recurse_then_throw_and_catch();
    throw_for_real();
} 
 我想你可以将这个函数添加到.lldbinit中,然后根据需要从控制台将它连接到断点. (我认为你不能在Xcode中设置脚本命令.)