diff --git a/src/debug_clang.cc b/src/debug_clang.cc index 9503a2e..e02e935 100644 --- a/src/debug_clang.cc +++ b/src/debug_clang.cc @@ -101,8 +101,26 @@ void Debug::Clang::start(const std::string &command, const boost::filesystem::pa } lldb::SBError error; - if(!plugin.empty() && plugin!="host") - process = std::unique_ptr(new lldb::SBProcess(target.ConnectRemote(*listener, url.c_str(), plugin.c_str(), error))); + if(!plugin.empty() && plugin!="host") { + process = std::unique_ptr(new lldb::SBProcess(target.ConnectRemote(*listener, url.c_str(), "gdb-remote", error))); + if(error.Fail()) { + Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true); + if(callback) + callback(-1); + return; + } + lldb::SBEvent event; + while(true) { + if(listener->GetNextEvent(event)) { + if((event.GetType() & lldb::SBProcess::eBroadcastBitStateChanged)>0) { + auto state=process->GetStateFromEvent(event); + if(state==lldb::StateType::eStateConnected) + break; + } + } + } + process->RemoteLaunch(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, lldb::eLaunchFlagNone, false, error); + } else process = std::unique_ptr(new lldb::SBProcess(target.Launch(*listener, argv, const_cast(environ), nullptr, nullptr, nullptr, path.string().c_str(), lldb::eLaunchFlagNone, false, error))); if(error.Fail()) {