I am using some GCD code which dispatches a bunch of similar async blocks. I would like to debug one of these blocks by stepping through it so I’ve set a breakpoint somewhere near the top of the block, but the debugger hits the breakpoint every time a new block is submitted and so I never manage to step through the block, I just get swapped around different threads on the same line.
My question is how do I set a breakpoint so that its conditional upon a certain thread? i.e. it should only trigger if executed on thread 4?
EDIT
I should add that my block’s code is very time intensive, so the scheduler swaps onto another thread before the next line inside the block can be executed, and another freshly scheduled GCD block gets its turn, triggering the same breakpoint.
I don’t think this is exposed through the Xcode Breakpoints UI but in lldb you can modify a breakpoint so it only fires when a (1) thread name matches, (2) dispatch queue name matches, (3) thread ID matches, or (4) thread index number matches. You can specify these criteria when you create the breakpoint (
breakpoint set) or you can add these criteria to an existing breakpoint withbreakpoint modify. Seehelp breakpoint modifyin the Debugger console window for a list of the allowed arguments.