Based on the question "Step over" when debugging multithreaded programs in Visual Studio, consider the following scenario:
Thread A running some code starts Thread B and keep going until the point where Thread A needs the result of Thread B. For the sake of sanity, let's assume the following scheme:
Thread A
line 1 // <---- Starts Thread B
line 2
line 3 // <---- Breakpoint
line 4
line 5 // <---- Wait for Thread B
Thread B
line 1
line 2 // <------ When the code breaks, stoped here
line 3
line 4
What happens when one click on the "step over" button?
I can think of three things:
- A go to line 4. B stays in line 2 until the "continue" button was pressed.
- A go to line 4. B go to line 3
- A go to line 4. While A don't stop at line 4, B keeps going indefinitely. As soon as A stop again, B stops. This means that B can be in line 4 or exited while A is going from line 3 to 4.
If I was asked to guess, I'd choose my option 3.
Following that line, there's a way to debug threads line by line like my option 2? I'm asking in terms of there is any C++ debugger able to halt all threads and step over line by line each one individually?