1 #include "dylib.h"
2 #include <cassert>
3 #include <cstdio>
4 #include <thread>
5 #include <chrono>
6 
7 int main(int argc, char* argv[]) {
8   // Wait until debugger is attached.
9   int main_thread_continue = 0;
10   int i = 0;
11   int timeout = 10;
12   for (i = 0; i < timeout; i++) {
13     std::this_thread::sleep_for(std::chrono::seconds(1));  // break here
14     if (main_thread_continue) {
15       break;
16     }
17   }
18   assert(i != timeout && "timed out waiting for debugger");
19 
20   // dlopen the 'liblib_b.so' shared library.
21   void* dylib_handle = dylib_open("lib_b");
22   assert(dylib_handle && "dlopen failed");
23 
24   return i; // break after dlopen
25 }
26