在Xcode中,有没有办法绕过一行或多行的“All Exceptions”断点?

时间:2021-05-10 10:33:53

I'm being driven slowly insane by this line of code:

我被这行代码慢慢驱使:

NSDictionary* rectangle3FontAttributes = @{NSFontAttributeName: [UIFont fontWithName: @"TrajanPro3-Regular" size: 18], NSForegroundColorAttributeName: theCoverLogoColor, NSParagraphStyleAttributeName: rectangle3Style};

...which for some reason causes an internal exception. The program continues without a problem but my exceptions breakpoint catches it every time causing the viewport to change the file I was looking at and requiring me to press "continue" on each and every...single...run.

......由于某种原因导致内部异常。该程序继续没有问题,但我的异常断点每次捕获它导致视口更改我正在查看的文件,并要求我按“继续”每个...单...运行。

Is there a pragma or something to bypass exception breakpoints for a few line?

是否有一个pragma或什么东西绕过几行的异常断点?

FYI, it's not even an NSException. It's listed in the call stack as __cxa_throw called by TFFileDescriptorContext(char const *)

仅供参考,它甚至不是NSException。它在调用堆栈中列为__cxa_throw,由TFFileDescriptorContext调用(char const *)

2 个解决方案

#1


If you aren't debugging C++ code, or just don't care about C++ exceptions, turn on only the ObjC exceptions, then you won't hit this one.

如果您没有调试C ++代码,或者只是不关心C ++异常,请仅启用ObjC异常,然后您就不会遇到这个异常。

If that doesn't do it, it is possible in lldb to write Python based breakpoint commands (though you can't store them in the Breakpoint Editor yet.) It's pretty easy to make a Python command that restarts the debugger based on the callers of the current stop. There's an example of a simple Python based breakpoint command in the docs at:

如果没有这样做,可以在lldb中编写基于Python的断点命令(虽然你还不能将它们存储在断点编辑器中。)很容易制作一个Python命令,根据调用者重新启动调试器目前停止。在以下文档中有一个简单的基于Python的断点命令的示例:

http://lldb.llvm.org/python-reference.html

You'll want to do something like:

你会想要做的事情:

def AvoidTTFileDescriptorContext(frame, bp_loc, dict):
    parent = frame.thread.frames[1]
    if parent.name == "TFFileDescriptorContext":
        return False
    else:
        return True

Put this function in, say, ~/lldb_bkpt_cmds.py.

把这个函数放在〜/ lldb_bkpt_cmds.py中。

The exception breakpoint is an ordinary breakpoint, so if you do:

异常断点是一个普通的断点,所以如果你这样做:

(lldb) break list

in the Xcode console you can find it. Say it is breakpoint 1, then do:

在Xcode控制台中,您可以找到它。说它是断点1,然后做:

(lldb) command script import ~/lldb_bkpt_cmds.py
(lldb) break command add -F lldb_bkpt_cmds.AvoidTTFileDescriptorContext 1

Then Xcode will auto-continue when it hits this breakpoint and the caller's name is TFFileDescriptorContext.

然后Xcode会在遇到此断点时自动继续,并且调用者的名称是TFFileDescriptorContext。

#2


I'm not 100% sure that you're looking exactly for this, but there is a control named Ignore in Edit breakpoint dialog.

我并不是100%确定你正在寻找这个,但是在Edit breakpoint对话框中有一个名为Ignore的控件。

在Xcode中,有没有办法绕过一行或多行的“All Exceptions”断点?

#1


If you aren't debugging C++ code, or just don't care about C++ exceptions, turn on only the ObjC exceptions, then you won't hit this one.

如果您没有调试C ++代码,或者只是不关心C ++异常,请仅启用ObjC异常,然后您就不会遇到这个异常。

If that doesn't do it, it is possible in lldb to write Python based breakpoint commands (though you can't store them in the Breakpoint Editor yet.) It's pretty easy to make a Python command that restarts the debugger based on the callers of the current stop. There's an example of a simple Python based breakpoint command in the docs at:

如果没有这样做,可以在lldb中编写基于Python的断点命令(虽然你还不能将它们存储在断点编辑器中。)很容易制作一个Python命令,根据调用者重新启动调试器目前停止。在以下文档中有一个简单的基于Python的断点命令的示例:

http://lldb.llvm.org/python-reference.html

You'll want to do something like:

你会想要做的事情:

def AvoidTTFileDescriptorContext(frame, bp_loc, dict):
    parent = frame.thread.frames[1]
    if parent.name == "TFFileDescriptorContext":
        return False
    else:
        return True

Put this function in, say, ~/lldb_bkpt_cmds.py.

把这个函数放在〜/ lldb_bkpt_cmds.py中。

The exception breakpoint is an ordinary breakpoint, so if you do:

异常断点是一个普通的断点,所以如果你这样做:

(lldb) break list

in the Xcode console you can find it. Say it is breakpoint 1, then do:

在Xcode控制台中,您可以找到它。说它是断点1,然后做:

(lldb) command script import ~/lldb_bkpt_cmds.py
(lldb) break command add -F lldb_bkpt_cmds.AvoidTTFileDescriptorContext 1

Then Xcode will auto-continue when it hits this breakpoint and the caller's name is TFFileDescriptorContext.

然后Xcode会在遇到此断点时自动继续,并且调用者的名称是TFFileDescriptorContext。

#2


I'm not 100% sure that you're looking exactly for this, but there is a control named Ignore in Edit breakpoint dialog.

我并不是100%确定你正在寻找这个,但是在Edit breakpoint对话框中有一个名为Ignore的控件。

在Xcode中,有没有办法绕过一行或多行的“All Exceptions”断点?