Files
clang-p2996/lldb/test/API/functionalities/thread/ignore_suspended/main.cpp
Ilya Bukonkin 3b43f00629 [lldb] Check if thread was suspended during previous stop added.
Encountered the following situation: Let we started thread T1 and it hit
breakpoint on B1 location. We suspended T1 and continued the process.
Then we started thread T2 which hit for example the same location B1.
This time in a breakpoint callback we decided not to stop returning
false.

Expected result: process continues (as if T2 did not hit breakpoint) its
workflow with T1 still suspended. Actual result: process do stops (as if
T2 callback returned true).

Solution: We need invalidate StopInfo for threads that was previously
suspended just because something that is already inactive can not be the
reason of stop. Thread::GetPrivateStopInfo() may be appropriate place to
do it, because it gets called (through Thread::GetStopInfo()) every time
before process reports stop and user gets chance to change
m_resume_state again i.e if we see m_resume_state == eStateSuspended
it definitely means it was set during previous stop and it also means
this thread can not be stopped again (cos' it was frozen during
previous stop).

Differential revision: https://reviews.llvm.org/D80112
2020-06-11 15:02:46 -07:00

36 lines
771 B
C++

// Test simulates situation when suspended thread could stop process
// where thread that is a real reason of stop says process
// should not stop in it's action handler.
#include <chrono>
#include <thread>
void thread1() {
// Will be suspended at breakpoint stop
// Set first breakpoint here
}
void thread2() {
/*
Prevent threads from stopping simultaneously
*/
std::this_thread::sleep_for(std::chrono::seconds(1));
// Set second breakpoint here
}
int main() {
// Create a thread
std::thread thread_1(thread1);
// Create another thread.
std::thread thread_2(thread2);
// Wait for the thread that was not suspeneded
thread_2.join();
// Wait for thread that was suspended
thread_1.join(); // Set third breakpoint here
return 0;
}