1 #include <thread> 2 3 #include "lldb/API/LLDB.h" 4 #include "lldb/API/SBDebugger.h" 5 #include "lldb/API/SBTarget.h" 6 7 using namespace lldb; main(int argc,char ** argv)8int main (int argc, char **argv) 9 { 10 // We are expecting the program path and a path to an executable to load 11 if (argc != 2) 12 return 1; 13 const char *program_file = argv[1]; 14 SBDebugger::Initialize(); 15 SBDebugger debugger = SBDebugger::Create(false); 16 auto lambda = [&](){ 17 SBError error; 18 SBTarget target = debugger.CreateTarget(program_file, nullptr, nullptr, 19 false, error); 20 }; 21 22 // Create 3 targets at the same time and make sure we don't crash. 23 std::thread thread1(lambda); 24 std::thread thread2(lambda); 25 std::thread thread3(lambda); 26 thread1.join(); 27 thread2.join(); 28 thread3.join(); 29 SBDebugger::Terminate(); 30 return 0; 31 } 32