2013-07-16 19:41:37 +00:00
|
|
|
// This test is intended to create a situation in which two threads are stopped
|
|
|
|
|
// at a breakpoint and the debugger issues a step-out command.
|
|
|
|
|
|
Centralize libc++ test skipping logic
Summary:
This aims to replace the different decorators we've had on each libc++
test with a single solution. Each libc++ will be assigned to the
"libc++" category and a single central piece of code will decide whether
we are actually able to run libc++ test in the given configuration by
enabling or disabling the category (while giving the user the
opportunity to override this).
I started this effort because I wanted to get libc++ tests running on
android, and none of the existing decorators worked for this use case:
- skipIfGcc - incorrect, we can build libc++ executables on android
with gcc (in fact, after this, we can now do it on linux as well)
- lldbutil.skip_if_library_missing - this checks whether libc++.so is
loaded in the proces, which fails in case of a statically linked
libc++ (this makes copying executables to the remote target easier to
manage).
To make this work I needed to split out the pseudo_barrier code from the
force-included file, as libc++'s atomic does not play well with gcc on
linux, and this made every test fail, even though we need the code only
in the threading tests.
So far, I am only annotating one of the tests with this category. If
this does not break anything, I'll proceed to update the rest.
Reviewers: jingham, zturner, EricWF
Subscribers: srhines, lldb-commits
Differential Revision: https://reviews.llvm.org/D30984
llvm-svn: 299028
2017-03-29 21:01:14 +00:00
|
|
|
#include "pseudo_barrier.h"
|
2015-08-17 20:12:04 +00:00
|
|
|
#include <thread>
|
2013-07-16 19:41:37 +00:00
|
|
|
|
2016-05-10 07:54:25 +00:00
|
|
|
pseudo_barrier_t g_barrier;
|
2013-07-16 19:41:37 +00:00
|
|
|
|
|
|
|
|
volatile int g_test = 0;
|
|
|
|
|
|
|
|
|
|
void step_out_of_here() {
|
|
|
|
|
g_test += 5; // Set breakpoint here
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void *
|
2015-08-17 20:12:04 +00:00
|
|
|
thread_func ()
|
2013-07-16 19:41:37 +00:00
|
|
|
{
|
|
|
|
|
// Wait until both threads are running
|
|
|
|
|
pseudo_barrier_wait(g_barrier);
|
|
|
|
|
|
|
|
|
|
// Do something
|
|
|
|
|
step_out_of_here(); // Expect to stop here after step-out (clang)
|
|
|
|
|
|
|
|
|
|
// Return
|
2020-05-04 14:16:17 -07:00
|
|
|
return NULL; // Expect to stop here after step-out (icc and gcc)
|
2013-07-16 19:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
|
{
|
|
|
|
|
// Don't let either thread do anything until they're both ready.
|
|
|
|
|
pseudo_barrier_init(g_barrier, 2);
|
|
|
|
|
|
|
|
|
|
// Create two threads
|
2015-08-17 20:12:04 +00:00
|
|
|
std::thread thread_1(thread_func);
|
|
|
|
|
std::thread thread_2(thread_func);
|
2013-07-16 19:41:37 +00:00
|
|
|
|
|
|
|
|
// Wait for the threads to finish
|
2015-08-17 20:12:04 +00:00
|
|
|
thread_1.join();
|
|
|
|
|
thread_2.join();
|
2013-07-16 19:41:37 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|