macOS Xcode debugging: can I single-step just one thread while another thread runs free?

This seems like a very basic question but I couldn't find an answer to this yet:

I have a simple C++ command-line application which has its main() thread and from this it forks a service pthread (BSD thread). This service thread performs the I/O on the console. When I just let it run, it works as expected.

The question is: I would like to pause and single-step only the main() thread while the service thread continues to run free in the background, but so far the Xcode debugger insists on always pausing or resuming all threads at the same time, apparently (regardless whether the pause was due to clicking the pause icon or hitting a breakpoint in either thread).

Have I overlooked something or is it in fact impossible in Xcode to pause and single-step only one of the threads in a Mac application?

(I'm not questioning that in most cases the observed behaviour is the desired and most practical one, I'd just need single-thread debugging right now.)

Accepted Answer

I don’t think you can do this from the Xcode GUI but in LLDB you can use the -m option to determine whether other threads will run. In the LLDB prompt, type help thread step-in (or help thread step-over) for more info.

This should work at the LLDB prompt in Xcode’s console panel.

Be aware that many parts of macOS are multi-threaded and so the this-thread option may well hang if you call into framework code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

macOS Xcode debugging: can I single-step just one thread while another thread runs free?
 
 
Q