bool LLDBConnector::ConnectToDebugger(int timeout, const wxString &socketPath) { clSocketClient *client = new clSocketClient(); m_socket.reset( client ); client->SetPath( socketPath.IsEmpty() ? GetDebugServerPath() : socketPath ); CL_DEBUG("Connecting to codelite-lldb on %s", GetDebugServerPath()); long msTimeout = timeout * 1000; long retriesCount = msTimeout / 250; // We try every 250 ms to connect bool connected = false; for(long i=0; i<retriesCount; ++i) { if ( !client->Connect() ) { wxThread::Sleep(250); continue; } connected = true; break; } if ( !connected ) { return false; } // Start the lldb event thread // and start a listener thread which will read replies // from codelite-lldb and convert them into LLDBEvent socket_t fd = m_socket->GetSocket(); m_thread = new LLDBNetworkListenerThread(this, fd); m_thread->Start(); CL_DEBUG("Successfully connected to codelite-lldb"); return true; }
void LLDBConnector::StopDebugServer() { if(m_process) { m_process->SetHardKill(true); // kill -9 m_process->Terminate(); m_process = NULL; } wxLogNull noLog; wxRemoveFile(GetDebugServerPath()); }
wxString LLDBConnector::GetConnectString() const { wxString connectString; LLDBSettings settings; bool useTcp = settings.Load().IsUsingRemoteProxy(); if(useTcp) { connectString << settings.GetProxyIp() << ":" << settings.GetProxyPort(); } else { connectString << GetDebugServerPath(); } return connectString; }
bool LLDBConnector::ConnectToLocalDebugger(LLDBConnectReturnObject& ret, int timeout) { #ifndef __WXMSW__ clSocketClient* client = new clSocketClient(); m_socket.reset(client); clDEBUG() << "Connecting to codelite-lldb on:" << GetDebugServerPath(); long msTimeout = timeout * 1000; long retriesCount = msTimeout / 250; // We try every 250 ms to connect bool connected = false; for(long i = 0; i < retriesCount; ++i) { if(!client->ConnectLocal(GetDebugServerPath())) { wxThread::Sleep(250); continue; } connected = true; break; } if(!connected) { return false; } // Start the lldb event thread // and start a listener thread which will read replies // from codelite-lldb and convert them into LLDBEvent socket_t fd = m_socket->GetSocket(); m_pivot.Clear(); m_thread = new LLDBNetworkListenerThread(this, m_pivot, fd); m_thread->Start(); clDEBUG() << "Successfully connected to codelite-lldb"; return true; #else clWARNING() << "LLDB Debugger: can't connect to local debugger - this is not support on MSW"; return false; #endif }
bool LLDBConnector::LaunchLocalDebugServer() { #ifdef __WXMSW__ // Not supported :( ::wxMessageBox(_("Locally debugging with LLDB on Windows is not supported by LLDB"), "CodeLite", wxICON_WARNING|wxOK|wxCENTER); return false; #endif CL_DEBUG("Launching codelite-lldb"); // Start the debugger if ( m_process ) { // another debugger process is already running return false; } // Apply the environment before we start wxStringMap_t om; #ifdef __WXMAC__ // set the LLDB_DEBUGSERVER_PATH env variable wxFileName debugserver(wxStandardPaths::Get().GetExecutablePath()); debugserver.SetFullName( "debugserver" ); debugserver.RemoveLastDir(); debugserver.AppendDir("SharedSupport"); om["LLDB_DEBUGSERVER_PATH"] = debugserver.GetFullPath(); #endif EnvSetter es(NULL, &om); wxFileName fnCodeLiteLLDB(wxStandardPaths::Get().GetExecutablePath()); fnCodeLiteLLDB.SetFullName( "codelite-lldb" ); wxString command; command << fnCodeLiteLLDB.GetFullPath() << " -s " << GetDebugServerPath(); m_process = ::CreateAsyncProcess(this, command); if ( !m_process ) { CL_ERROR("LLDBConnector: failed to launch codelite-lldb: %s", fnCodeLiteLLDB.GetFullPath()); return false; } else { CL_DEBUG("codelite-lldb launched successfully. PID=%d\n", m_process->GetPid()); } return true; }
bool LLDBConnector::LaunchLocalDebugServer() { #if !BUILD_CODELITE_LLDB // Not supported :( ::wxMessageBox(_("Locally debugging with LLDB on Windows is not supported by LLDB"), "CodeLite", wxICON_WARNING | wxOK | wxCENTER); return false; #endif clDEBUG() << "Launching codelite-lldb"; // Start the debugger if(m_process) { // another debugger process is already running return false; } // Apply the environment before we start // set the LLDB_DEBUGSERVER_PATH env variable wxStringMap_t om; om["LLDB_DEBUGSERVER_PATH"] = m_debugserver; EnvSetter es(NULL, &om); wxFileName fnCodeLiteLLDB(clStandardPaths::Get().GetBinaryFullPath("codelite-lldb")); wxString command; command << fnCodeLiteLLDB.GetFullPath() << " -s " << GetDebugServerPath(); clDEBUG() << "LLDB_DEBUGSERVER_PATH is set to" << m_debugserver; m_process = ::CreateAsyncProcess(this, command); if(!m_process) { clERROR() << "LLDBConnector: failed to launch codelite-lldb:" << fnCodeLiteLLDB.GetFullPath(); return false; } else { clDEBUG() << "codelite-lldb launched successfully. PID=" << m_process->GetPid(); } return true; }