Ejemplo n.º 1
0
void LLDBPlugin::OnLLDBStarted(LLDBEvent& event)
{
    event.Skip();
    InitializeUI();
    LoadLLDBPerspective();

    // If this is a normal debug session, a start notification
    // should follow a 'Run' command
    switch(event.GetSessionType()) {
    case kDebugSessionTypeCore:
        CL_DEBUG("CODELITE>> LLDB started (core file)");
        break;

    case kDebugSessionTypeAttach: {
        LLDBSettings settings;
        m_raisOnBpHit = settings.Load().IsRaiseWhenBreakpointHit();
        CL_DEBUG("CODELITE>> LLDB started (attached)");
        m_connector.SetAttachedToProcess(event.GetSessionType() == kDebugSessionTypeAttach);
        // m_connector.Continue();
        break;
    }
    case kDebugSessionTypeNormal: {
        LLDBSettings settings;
        m_raisOnBpHit = settings.Load().IsRaiseWhenBreakpointHit();
        CL_DEBUG("CODELITE>> LLDB started (normal)");
        m_connector.Run();
        break;
    }
    }

    wxCommandEvent e2(wxEVT_DEBUG_STARTED);
    EventNotifier::Get()->AddPendingEvent(e2);
}
Ejemplo n.º 2
0
void LLDBPlugin::OnLLDBBreakpointsUpdated(LLDBEvent& event)
{
    event.Skip();
    // update the ui (mainly editors)
    // this is done by replacing the breakpoints list with a new one (the updated one we take from LLDB)
    m_mgr->SetBreakpoints(LLDBBreakpoint::ToBreakpointInfoVector(event.GetBreakpoints()));
}
Ejemplo n.º 3
0
void LLDBTooltip::OnLLDBVariableExpanded(LLDBEvent& event)
{
    int variableId = event.GetVariableId();
	wxUnusedVar(variableId);
    std::map<int, wxTreeItemId>::iterator iter = m_itemsPendingExpansion.find(event.GetVariableId());
    if(iter == m_itemsPendingExpansion.end()) {
        // does not belong to us
        event.Skip();
        return;
    }

    wxTreeItemId parentItem = iter->second;

    // add the variables to the tree
    for(size_t i = 0; i < event.GetVariables().size(); ++i) {
        DoAddVariable(parentItem, event.GetVariables().at(i));
    }

    // Expand the parent item
    if(m_treeCtrl->HasChildren(parentItem)) {
        m_treeCtrl->Expand(parentItem);
    }

    // remove it
    m_itemsPendingExpansion.erase(iter);
}
Ejemplo n.º 4
0
void LLDBPlugin::OnLLDBExpressionEvaluated(LLDBEvent& event)
{
    CHECK_IS_LLDB_SESSION();

    // hide any tooltip
    if(!event.GetVariables().empty() && m_mgr->GetActiveEditor()) {
        if(!m_tooltip) { m_tooltip = new LLDBTooltip(this); }
        m_tooltip->Show(event.GetExpression(), event.GetVariables().at(0));
    }
}
Ejemplo n.º 5
0
void LLDBLocalsView::OnLLDBLocalsUpdated(LLDBEvent& event)
{
    // FIXME: optimize this to only retrieve the top levle variables
    // the children should be obtained in the 'OnItemExpading' event handler
    event.Skip();
    wxWindowUpdateLocker locker(m_treeList);
    Enable(true);

    m_treeList->DeleteChildren(m_treeList->GetRootItem());
    CL_DEBUG("Updating locals view");
    DoAddVariableToView(event.GetVariables(), m_treeList->GetRootItem());
}
Ejemplo n.º 6
0
void MainDialog::OnLLDBBreakpointsUpdated(LLDBEvent& e)
{
    e.Skip();
    
    wxString msg;
    const LLDBBreakpoint::Vec_t &bps = e.GetBreakpoints();
    for(size_t i=0; i<bps.size(); ++i) {
        msg << bps.at(i)->ToString() << "\n";
    }
    
    m_textCtrlLog->AppendText("Breakpoints updated:\n");
    m_textCtrlLog->AppendText( msg );
}
Ejemplo n.º 7
0
void LLDBDebuggerPlugin::OnLLDBStopped(LLDBEvent& event)
{
    event.Skip();
    wxFileName fn( event.GetFileName() );
    CL_DEBUG(wxString() << "CODELITE>> LLDB stopped at " << event.GetFileName() << ":" << event.GetLinenumber() );
    if ( fn.FileExists() ) {
        if ( m_mgr->OpenFile( fn.GetFullPath(), "", event.GetLinenumber() ) ) {
            IEditor* editor = m_mgr->GetActiveEditor();
            if ( editor ) {
                editor->GetSTC()->ScrollToLine( event.GetLinenumber() );
            }
        }
    }
}
Ejemplo n.º 8
0
void LLDBLocalsView::OnLLDBVariableExpanded(LLDBEvent& event)
{
    int variableId = event.GetVariableId();
    // try to locate this item in our map
    LLDBLocalsView::IntItemMap_t::iterator iter = m_pendingExpandItems.find(variableId);
    if(iter == m_pendingExpandItems.end()) {
        // does not belong to us - skip it
        event.Skip();
        return;
    }

    // add the variables
    DoAddVariableToView(event.GetVariables(), iter->second);
    m_pendingExpandItems.erase(iter);
}
Ejemplo n.º 9
0
void LLDBPlugin::OnLLDBExited(LLDBEvent& event)
{
    event.Skip();
    m_connector.SetGoingDown(true);

    // Stop the debugger ( do not notify about it, since we are in the handler...)
    m_connector.Cleanup();

    // Save current perspective before destroying the session
    if(m_isPerspectiveLoaded) {
        m_mgr->SavePerspective("LLDB-debugger");

        // Restore the old perspective
        m_mgr->LoadPerspective("Default");
        m_isPerspectiveLoaded = false;
    }

    DestroyUI();

    // Reset various state variables
    DoCleanup();

    CL_DEBUG("CODELITE>> LLDB exited");

    // Also notify codelite's event
    clDebugEvent e2(wxEVT_DEBUG_ENDED);
    EventNotifier::Get()->AddPendingEvent(e2);

    {
        clDebugEvent e(wxEVT_DEBUG_ENDED);
        EventNotifier::Get()->AddPendingEvent(e);
    }
}
Ejemplo n.º 10
0
void LLDBPlugin::OnLLDBRunning(LLDBEvent& event)
{
    event.Skip();
    m_connector.SetCanInteract(false);

    // When the IDE loses the focus - clear the debugger marker
    ClearDebuggerMarker();
}
Ejemplo n.º 11
0
void LLDBPlugin::OnLLDBCrashed(LLDBEvent& event)
{
    event.Skip();
    // Report it as crash only if not going down (i.e. we got an LLDBExit event)
    if(!m_connector.IsGoingDown()) {
        ::wxMessageBox(_("LLDB crashed! Terminating debug session"), "CodeLite", wxOK | wxICON_ERROR | wxCENTER);
    }
    OnLLDBExited(event);
}
Ejemplo n.º 12
0
void LLDBDebuggerPlugin::OnLLDBStarted(LLDBEvent& event)
{
    event.Skip();
    m_isRunning = true;
    
    CL_DEBUG("CODELITE>> LLDB started");
    wxCommandEvent e2(wxEVT_DEBUG_STARTED);
    EventNotifier::Get()->AddPendingEvent( e2 );
}
Ejemplo n.º 13
0
void LLDBDebuggerPlugin::OnLLDBExited(LLDBEvent& event)
{
    event.Skip();
    m_isRunning = false;
    CL_DEBUG("CODELITE>> LLDB exited");
    // Also notify codelite's event
    wxCommandEvent e2(wxEVT_DEBUG_ENDED);
    EventNotifier::Get()->AddPendingEvent( e2 );
}
Ejemplo n.º 14
0
void LLDBPlugin::OnLLDBLaunchSuccess(LLDBEvent& event)
{
    event.Skip();
    m_connector.SetCanInteract(true);
    m_connector.SetIsRunning(true);

    CL_DEBUG("CODELITE>> Applying breakpoints...");
    m_connector.ApplyBreakpoints();
    m_connector.Next();
}
Ejemplo n.º 15
0
void LLDBPlugin::OnLLDBStoppedOnEntry(LLDBEvent& event)
{
    event.Skip();
    m_connector.SetCanInteract(true);
    m_connector.SetIsRunning(true);

    CL_DEBUG("CODELITE>> Applying breakpoints...");
    m_connector.ApplyBreakpoints();
    CL_DEBUG("CODELITE>> continue...");
    m_connector.Continue();
}
Ejemplo n.º 16
0
void LLDBPlugin::OnLLDBCrashed(LLDBEvent& event)
{
    event.Skip();
    // Report it as crash only if not going down (i.e. we got an LLDBExit event)
    if(!m_connector.IsGoingDown()) {
        // SetGoingDown() before displaying message box to cope with reentering this function whilst waiting for OK.
        m_connector.SetGoingDown(true);
        ::wxMessageBox(_("LLDB crashed! Terminating debug session"), "CodeLite", wxOK | wxICON_ERROR | wxCENTER);
        OnLLDBExited(event);
    }
}
Ejemplo n.º 17
0
void MainDialog::OnLLDBStarted(LLDBEvent& e)
{
    e.Skip();
    m_textCtrlLog->AppendText(wxString() << "LLDB Started successfully\n");
    
    LLDBCommand command;
    command.SetCommandType( kCommandRun );
    command.SetCommandArguments( "" );
    m_connector.SendCommand( command );
    m_textCtrlLog->AppendText("Running...\n");
}
Ejemplo n.º 18
0
void MainDialog::OnLLDBStoppedOnFirstEntry(LLDBEvent& e)
{
    e.Skip();
    m_textCtrlLog->AppendText(wxString() << "LLDB stopped on first entry\n");
    
    // place all breakpoints and move on
    m_textCtrlLog->AppendText("Setting breakpoint at main...\n");
    m_connector.AddBreakpoint("main");
    m_connector.ApplyBreakpoints();
    m_textCtrlLog->AppendText("Continue...\n");
    m_connector.Continue();
}
Ejemplo n.º 19
0
void MainDialog::OnLLDBStopped(LLDBEvent& e)
{
    e.Skip();
    
    wxString msg;
    msg << "Process stopped. " << e.GetFileName() << ":" << e.GetLinenumber();
    m_textCtrlLog->AppendText(msg + "\n");
    m_textCtrlLog->AppendText("Backtrace:\n");
    m_textCtrlLog->AppendText(e.GetBacktrace().ToString() + "\n");
    
    // If we have an "Interrupt reason" set, then the stop was due to user request
    // handle this separately
    if ( e.GetInterruptReason() == kInterruptReasonApplyBreakpoints ) {
        // Apply breakpoints failed, due to debugger can not interact
        // now that we stopped - try it again
        m_connector.ApplyBreakpoints();
        m_connector.Continue();

    } else if ( e.GetInterruptReason() == kInterruptReasonDeleteAllBreakpoints ) {
        // Could not delete all breakpoints because the debugger was not 
        // in an interactive mode - do it now
        m_connector.DeleteBreakpoints();
        m_connector.Continue();

    }
}
Ejemplo n.º 20
0
void LLDBPlugin::OnLLDBStarted(LLDBEvent& event)
{
    event.Skip();

    const auto settings = LLDBSettings().Load();
    m_showThreadNames = settings.HasFlag(kLLDBOptionShowThreadNames);
    m_showFileNamesOnly = settings.HasFlag(kLLDBOptionShowFileNamesOnly);

    InitializeUI();
    LoadLLDBPerspective();

    // If this is a normal debug session, a start notification
    // should follow a 'Run' command
    switch(event.GetSessionType()) {
    case kDebugSessionTypeCore:
        CL_DEBUG("CODELITE>> LLDB started (core file)");
        break;

    case kDebugSessionTypeAttach: {
        m_raisOnBpHit = settings.IsRaiseWhenBreakpointHit();
        CL_DEBUG("CODELITE>> LLDB started (attached)");
        m_connector.SetAttachedToProcess(event.GetSessionType() == kDebugSessionTypeAttach);
        // m_connector.Continue();
        break;
    }
    case kDebugSessionTypeNormal: {
        m_raisOnBpHit = settings.IsRaiseWhenBreakpointHit();
        CL_DEBUG("CODELITE>> LLDB started (normal)");
        m_connector.Run();
        break;
    }
    }

    // notify plugins that the debugger just started
    {
        clDebugEvent eventStarted(wxEVT_DEBUG_STARTED);
        eventStarted.SetClientData(NULL);
        EventNotifier::Get()->ProcessEvent(eventStarted);
    }
}
Ejemplo n.º 21
0
void LLDBThreadsView::OnLLDBStopped(LLDBEvent& event)
{
    event.Skip();
    DoCleanup();
    // Update the thread view
    const LLDBThread::Vect_t& threads = event.GetThreads();
    for(size_t i = 0; i < threads.size(); ++i) {
        const LLDBThread& thr = threads.at(i);
        if(thr.IsActive()) { m_selectedThread = i; }
        wxVector<wxVariant> cols;
        cols.push_back(thr.GetId() == wxNOT_FOUND ? wxString() : wxString() << thr.GetId());
        cols.push_back(thr.GetName());
        cols.push_back(thr.GetStopReasonString());
        cols.push_back(thr.GetFunc());
        cols.push_back(m_plugin->GetFilenameForDisplay(thr.GetFile()));
        cols.push_back(thr.GetLine() == wxNOT_FOUND ? wxString() : wxString() << thr.GetLine());
        m_dvListCtrlThreads->AppendItem(cols, (wxUIntPtr) new LLDBThreadViewClientData(thr));
    }

    if((wxNOT_FOUND != m_selectedThread) && ((int)m_dvListCtrlThreads->GetItemCount() > m_selectedThread)) {
        const auto item = m_dvListCtrlThreads->RowToItem(m_selectedThread);
        if(item.IsOk()) { m_dvListCtrlThreads->EnsureVisible(item); }
    }
}
Ejemplo n.º 22
0
void LLDBConnector::OnLLDBExited(LLDBEvent& event)
{
    event.Skip();
    m_isRunning = false;
}
Ejemplo n.º 23
0
void LLDBConnector::OnLLDBStarted(LLDBEvent& event)
{
    event.Skip();
    m_isRunning = true;
}
Ejemplo n.º 24
0
void MainDialog::OnLLDBRunning(LLDBEvent& e)
{
    e.Skip();
    m_textCtrlLog->AppendText("Debuggee process state is Running...\n");
}
Ejemplo n.º 25
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();
    }
}
Ejemplo n.º 26
0
void LLDBPlugin::OnLLDBDeletedAllBreakpoints(LLDBEvent& event)
{
    event.Skip();
    m_mgr->DeleteAllBreakpoints();
}
Ejemplo n.º 27
0
void LLDBDebugger::OnTerminated(LLDBEvent& e)
{
    e.Skip();
    m_isRunning = false;
}
Ejemplo n.º 28
0
void LLDBLocalsView::OnLLDBRunning(LLDBEvent& event)
{
    event.Skip();
    Cleanup();
}
Ejemplo n.º 29
0
void MainDialog::OnLLDBExited(LLDBEvent& e)
{
    e.Skip();
    m_textCtrlLog->AppendText(wxString() << "LLDB Exited\n");
}
Ejemplo n.º 30
0
void LLDBLocalsView::OnLLDBStarted(LLDBEvent& event)
{
    event.Skip();
    Cleanup();
}