Hari Honor
Hari Honor

Reputation: 8924

In Xcode, is there a way to bypass the "All Exceptions" breakpoints just for one or more lines?

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?

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

Upvotes: 3

Views: 1450

Answers (2)

Jim Ingham
Jim Ingham

Reputation: 27228

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.

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:

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.

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:

(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.

Upvotes: 2

heximal
heximal

Reputation: 10517

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

enter image description here

Upvotes: 1

Related Questions