Files
clang-p2996/lldb/test/API/functionalities/load_after_attach/main.cpp
Pavel Labath 9413ead7bc [lldb/test] Add ability to specify environment when spawning processes
We only had that ability for regular debugger launches. This meant that
it was not possible to use the normal dlopen patterns in attach tests.
This fixes that.
2021-09-28 14:13:50 +02:00

26 lines
624 B
C++

#include "dylib.h"
#include <cassert>
#include <cstdio>
#include <thread>
#include <chrono>
int main(int argc, char* argv[]) {
// Wait until debugger is attached.
int main_thread_continue = 0;
int i = 0;
int timeout = 10;
for (i = 0; i < timeout; i++) {
std::this_thread::sleep_for(std::chrono::seconds(1)); // break here
if (main_thread_continue) {
break;
}
}
assert(i != timeout && "timed out waiting for debugger");
// dlopen the 'liblib_b.so' shared library.
void* dylib_handle = dylib_open("lib_b");
assert(dylib_handle && "dlopen failed");
return i; // break after dlopen
}