In a C++ application I have 2 threads (thread1
and thread2
) from the same class. They are running a loop very fast and nothing should made any blocking calls inside the loop:
while (!end) {
//dostuff, no blocking!
}
cout << "ended" << endl;
There is some bug in the application, because when I run only one thread at a time, and I set its end
property, it can quit from the loop successfully.
However, if I run both threads, sometimes one of the threads is not able to break out from the loop (in spite of having its end
property set).
The loop itself is quite big (few hundred lines), I can put a (conditional)breakpoint into it, but when I'm stepping, I lose the functionality (as the thread should run fast), so even if I found which line blocks, it might be the wrong way.
So, my question: is there any option in gdb for having a breakpoint which behaves like a watchdog? I.e: it should break the thread if withing a certain time it won't be hit, so I can check which line causes the trouble.