Example #1
0
void clTernServer::OnTernWorkerThreadDone(const clTernWorkerThread::Reply& reply)
{
    m_workerThread->Stop();
    wxDELETE(m_workerThread);
    RecycleIfNeeded();

    m_entries.clear();
    CL_DEBUGS(reply.json);

    switch(reply.requestType) {
    case clTernWorkerThread::kFunctionTip:
        m_jsCCManager->OnFunctionTipReady(ProcessCalltip(reply.json), reply.filename);
        break;
    case clTernWorkerThread::kCodeCompletion:
        ProcessOutput(reply.json, m_entries);
        m_jsCCManager->OnCodeCompleteReady(m_entries, reply.filename);
        break;
    case clTernWorkerThread::kFindDefinition: {
        clTernDefinition loc;
        if(ProcessDefinitionOutput(reply.json, loc)) {
            m_jsCCManager->OnDefinitionFound(loc);
        }
    }
    break;
    case clTernWorkerThread::kReparse: {
        // TODO ??
    } break;
    case clTernWorkerThread::kReset:
        // TODO ??
        break;
    }
}
Example #2
0
void LLDBConnector::DeleteAllBreakpoints()
{
    if(!IsRunning()) {
        m_pendingDeletionBreakpoints.clear();
        m_breakpoints.clear();

        LLDBEvent event(wxEVT_LLDB_BREAKPOINTS_UPDATED);
        event.SetBreakpoints(GetAllBreakpoints());
        ProcessEvent(event);
        return;
    }

    // mark all breakpoints for deletion
    CL_DEBUGS(wxString() << "codelite: DeleteAllBreakpoints called");
    m_pendingDeletionBreakpoints.swap(m_breakpoints);

    if(!IsCanInteract()) {
        Interrupt(kInterruptReasonDeleteAllBreakpoints);

    } else {
        LLDBCommand command;
        command.SetCommandType(kCommandDeleteAllBreakpoints);
        SendCommand(command);
        m_pendingDeletionBreakpoints.clear();
    }
}
Example #3
0
void clTernServer::PrintMessage(const wxString& message)
{
    wxString msg;
    msg << message;
    msg.Trim().Trim(false);
    CL_DEBUGS(msg);
}
void LLDBConnector::DeleteBreakpoints()
{
    if ( IsCanInteract() ) {
        CL_DEBUGS(wxString () << "codelite: deleting breakpoints (total of " << m_pendingDeletionBreakpoints.size() << " breakpoints)");
        LLDBCommand command;
        command.SetCommandType( kCommandDeleteBreakpoint );
        command.SetBreakpoints( m_pendingDeletionBreakpoints );
        SendCommand( command );
        CL_DEBUGS(wxString () << "codelite: DeleteBreakpoints celar pending deletionbreakpoints queue");
        m_pendingDeletionBreakpoints.clear();
    
    } else {
        CL_DEBUG("codelite: interrupting codelite-lldb for kInterruptReasonDeleteBreakpoint");
        Interrupt( kInterruptReasonDeleteBreakpoint );
    }
}
Example #5
0
void XDebugComThread::DoSendCommand(const wxString& command, clSocketBase::Ptr_t client)
{
    // got message, process it
    if(!client) {
        return;
    }
    CL_DEBUGS(wxString() << "CodeLite >>> " << command);

    wxMemoryBuffer buff;
    buff.AppendData(command.mb_str(wxConvISO8859_1), command.length());
    buff.AppendByte(0);
    std::string cmd((const char*)buff.GetData(), buff.GetDataLen());
    client->Send(cmd);
}
FileNameVector_t CompilationDatabase::GetCompileCommandsFiles() const
{
    wxFileName databaseFile(GetFileName());
    wxFileName fn(databaseFile);

    // Usually it will be under the top folder
    fn.RemoveLastDir();

    // Since we can have multiple "compile_commands.json" files, we take the most updated file
    // Prepare a list of files to check
    FileNameVector_t files;
    std::queue<std::pair<wxString, int> > dirs;

    // we start with the current path
    dirs.push(std::make_pair(fn.GetPath(), 0));

    const int MAX_DEPTH = 2; // If no files were found, scan 2 levels only

    while(!dirs.empty()) {
        std::pair<wxString, int> curdir = dirs.front();
        dirs.pop();
        if(files.empty() && (curdir.second > MAX_DEPTH)) {
            CL_DEBUG("Could not find compile_commands.json files while reaching depth 2, aborting");
            break;
        }

        wxFileName fn(curdir.first, "compile_commands.json");
        if(fn.Exists()) {
            CL_DEBUGS("CompilationDatabase: found file: " + fn.GetFullPath());
            files.push_back(fn);
        }

        // Check to see if there are more directories to recurse
        wxDir dir;
        if(dir.Open(curdir.first)) {
            wxString dirname;
            bool cont = dir.GetFirst(&dirname, "", wxDIR_DIRS);
            while(cont) {
                wxString new_dir;
                new_dir << curdir.first << wxFileName::GetPathSeparator() << dirname;
                dirs.push(std::make_pair(new_dir, curdir.second + 1));
                dirname.Clear();
                cont = dir.GetNext(&dirname);
            }
        }
    }
    return files;
}
FileNameVector_t CompilationDatabase::GetCompileCommandsFiles() const
{
    wxFileName databaseFile(GetFileName());
    wxFileName fn(databaseFile);

    // Usually it will be under the top folder
    fn.RemoveLastDir();

    // Since we can have multiple "compile_commands.json" files, we take the most updated file
    // Prepare a list of files to check
    FileNameVector_t files;
    std::queue<wxString> dirs;

    // we start with the current path
    dirs.push(fn.GetPath());

    while(!dirs.empty()) {
        wxString curdir = dirs.front();
        dirs.pop();

        wxFileName fn(curdir, "compile_commands.json");
        if(fn.Exists() /*&& // file exists
           (fn.GetModificationTime().GetTicks() >
            databaseFile.GetModificationTime().GetTicks())*/) // and its newer than the database file
        {
            CL_DEBUGS("CompilationDatabase: found file: " + fn.GetFullPath());
            files.push_back(fn);
        }

        // Check to see if there are more directories to recurse
        wxDir dir;
        if(dir.Open(curdir)) {
            wxString dirname;
            bool cont = dir.GetFirst(&dirname, "", wxDIR_DIRS);
            while(cont) {
                wxString new_dir;
                new_dir << curdir << wxFileName::GetPathSeparator() << dirname;
                dirs.push(new_dir);
                dirname.Clear();
                cont = dir.GetNext(&dirname);
            }
        }
    }
    return files;
}
Example #8
0
void LLDBConnector::ClearBreakpointDeletionQueue()
{
    CL_DEBUGS(wxString() << "codelite: ClearBreakpointDeletionQueue called");
    m_pendingDeletionBreakpoints.clear();
}
Example #9
0
void LLDBPlugin::OnLLDBStopped(LLDBEvent& event)
{
    event.Skip();
    CL_DEBUGS(wxString() << "CODELITE>> LLDB stopped at " << event.GetFileName() << ":" << event.GetLinenumber());
    m_connector.SetCanInteract(true);

    if(event.GetInterruptReason() == kInterruptReasonNone) {

        if(m_raisOnBpHit) { EventNotifier::Get()->TopFrame()->Raise(); }

        // Mark the debugger line / file
        IEditor* editor = m_mgr->FindEditor(event.GetFileName());
        if(!editor && wxFileName::Exists(event.GetFileName())) {
            // Try to open the editor
            editor = m_mgr->OpenFile(event.GetFileName(), "", event.GetLinenumber() - 1);
        }

        if(editor) {
            // select it first
            if(editor != m_mgr->GetActiveEditor()) {
                m_mgr->SelectPage(editor->GetCtrl());

            } else {
                // just make sure that the page has the focus
                editor->SetActive();
            }

            // clear the markers
            ClearDebuggerMarker();
            SetDebuggerMarker(editor->GetCtrl(), event.GetLinenumber() - 1);

        } else {
            ClearDebuggerMarker();
        }

        // request for local variables
        m_connector.RequestLocals();

        wxString message;
        if(!m_stopReasonPrompted && event.ShouldPromptStopReason(message)) {
            m_stopReasonPrompted = true; // show this message only once per debug session
            wxString msg;
            msg << "Program stopped\nStop reason: " << message;
            ::wxMessageBox(msg, "CodeLite", wxICON_ERROR | wxOK | wxCENTER);
        }

    } else if(event.GetInterruptReason() == kInterruptReasonApplyBreakpoints) {
        CL_DEBUG("Applying breakpoints and continue...");
        m_connector.ApplyBreakpoints();
        m_connector.Continue();

    } else if(event.GetInterruptReason() == kInterruptReasonDeleteAllBreakpoints) {
        CL_DEBUG("Deleting all breakpoints");
        m_connector.DeleteAllBreakpoints();
        m_connector.Continue();

    } else if(event.GetInterruptReason() == kInterruptReasonDeleteBreakpoint) {
        CL_DEBUG("Deleting all pending deletion breakpoints");
        m_connector.DeleteBreakpoints();
        m_connector.Continue();

    } else if(event.GetInterruptReason() == kInterruptReasonDetaching) {
        CL_DEBUG("Detaching from process");
        m_connector.Detach();
    }
}