This test relies on being able to unwind from an arbitrary place inside libc. While I am not sure this is the cause of the observed flakyness, it is known that we are not able to unwind correctly from some places in (linux) libc. This patch adds additional synchronization to ensure that the inferior is in the main function (instead of pthread guts) when lldb tries to unwind it. At the very least, it should make the test runs more predictable/repeatable.
25 lines
498 B
C++
25 lines
498 B
C++
#include "pseudo_barrier.h"
|
|
#include <thread>
|
|
|
|
|
|
pseudo_barrier_t barrier_before;
|
|
pseudo_barrier_t barrier_after;
|
|
|
|
void break_here() {}
|
|
|
|
void thread_func() {
|
|
pseudo_barrier_wait(barrier_before);
|
|
break_here();
|
|
pseudo_barrier_wait(barrier_after);
|
|
}
|
|
|
|
int main() {
|
|
pseudo_barrier_init(barrier_before, 2);
|
|
pseudo_barrier_init(barrier_after, 2);
|
|
std::thread thread(thread_func);
|
|
pseudo_barrier_wait(barrier_before);
|
|
pseudo_barrier_wait(barrier_after);
|
|
thread.join();
|
|
return 0;
|
|
}
|