I need to debug a multithreading bug. So to have the condition that generates the crash I need to stop one thread at a specific point in my code and wait for another thread to reach a second breakpoint.
The problem I have now is that if one thread hits a breakpoint, all other threads are suspended. Is there a way to only stop one thread and let the others run until they hit the second breakpoint?
Upon reaching a breakpoint, by default, GDB pauses all threads until the user types cont . The user can change the behavior to request that GDB only pause the threads that hit a breakpoint, allowing other threads to continue executing.
You might be pushing "Run" instead of "Debug" in which case your program is not running with the help of gdb, in which case you cannot expect breakpoints to work! In Xcode 6.4, there is now only a Run button and whether it runs a debug configuration or not depends on the currently selected scheme settings.
New in Xcode 13, if a breakpoint is not resolved to any location by LLDB, Xcode will show you a dashed icon. There is a myriad of reasons why a breakpoint is not resolved but there are some common explanations. If you hover over the unresolved breakpoint icon, we have a tooltip that can help you out.
I know two ways: If you run into the first breakpoint you should see the debug navigator on the left side of xcode with a list of currently running threads. The thread you are currently on should be expanded. Right click on this thread and select 'suspend thread'. This is it.
If you later want to continue it, you can just click on resume. (In order to see the threads the execution has to be pause so you either have to be in a break point to do this or pause the app yourself! )
Other more fun option:
When you hit the first breakpoint, you could go into console and write
po [NSThread sleepForTimeInterval:3600]
that should pause the thread in the current context at that breakpoint for one hour.
Then resume the execution in Xcode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With