示例#1
0
void BreakpointDlg::Initialize()
{
    std::vector<BreakpointInfo> bps;
    ManagerST::Get()->GetBreakpointsMgr()->GetBreakpoints(bps);

    // This does the display stuff
    m_listCtrlBreakpoints->Initialise(bps);

    // Store the internal and external ids
    m_ids.clear();
    std::vector<BreakpointInfo>::iterator iter = bps.begin();
    for(; iter != bps.end(); ++iter) {
        struct bpd_IDs IDs(*iter);
        m_ids.push_back(IDs);
    }

    int count = m_listCtrlBreakpoints->GetItemCount();
    bool hasitems = count > 0;
    if (hasitems) {
        // Select the first item if there's not already a selection
        if (m_selectedItem == wxNOT_FOUND) {
            m_selectedItem = 0;
        }
        if (m_selectedItem >= count) {	// e.g. if the selection was the last item, then one is deleted
            m_selectedItem = count-1;
        }
        // Even if an item was previously selected, refreshing the pane means we need to reselect
        m_listCtrlBreakpoints->SetItemState(m_selectedItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
    }

    // Since any change results in Initialize() being rerun, we can do updateUI here
    m_buttonEdit->Enable(hasitems);
    m_buttonDelete->Enable(hasitems);
    // The 'Apply Pending' button is more complicated: it should be hidden,
    // unless there are pending bps to apply,and the debugger is running
    bool pending = ManagerST::Get()->GetBreakpointsMgr()->PendingBreakpointsExist();
    IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
    m_buttonApplyPending->Show( pending && dbgr && dbgr->IsRunning() );
    Layout();
    // Enable DeleteAll if there are either bps or pending bps
    m_buttonDeleteAll->Enable(hasitems || pending);
}
示例#2
0
void BreakptMgr::SetAllBreakpointsEnabledState(bool enabled)
{
    unsigned int successes = 0;
    bool debuggerIsRunning = false;
    bool contIsNeeded = false;

    IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
    if (dbgr && dbgr->IsRunning()) {
        debuggerIsRunning = true;
        contIsNeeded = PauseDebuggerIfNeeded();
    }

    for (size_t i=0; i<m_bps.size(); ++i) {
        BreakpointInfo &bp = m_bps.at(i);
        if (((bp.debugger_id != -1) || !debuggerIsRunning) // Sanity check for when the debugger's running
            && (bp.is_enabled != enabled)) { // No point setting it to the current status
            if (debuggerIsRunning) {
                if (dbgr->SetEnabledState(bp.debugger_id, enabled)) {
                    bp.is_enabled = enabled;
                    ++successes;
                }
            } else {
                bp.is_enabled = enabled;
                ++successes;
            }
        }
    }

    if (debuggerIsRunning && contIsNeeded) {
        dbgr->Continue();
    }

    if (successes) {
        RefreshBreakpointMarkers();
        clMainFrame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();

        wxString msg = wxString::Format(wxT("%u "), successes);
        msg << (enabled ? _("breakpoints enabled") : _("breakpoints disabled"));
        clMainFrame::Get()->SetStatusMessage(msg, 0);
    }
}
示例#3
0
void BreakptMgr::ApplyPendingBreakpoints()
{
    if (!PendingBreakpointsExist()) {
        return; // Nothing to do
    }

    IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
    if (!(dbgr && dbgr->IsRunning())) {
        return; // If the debugger isn't running, there's no point (and we shouldn't have reached here anyway)
    }
    bool contIsNeeded = PauseDebuggerIfNeeded();

    for (size_t i=m_pendingBreakpointsList.size(); i>0; --i) {
        BreakpointInfo bp = m_pendingBreakpointsList.at(i-1);

        // First check to see if the debugger already accepted this one
        // The answer should be no, as acceptance should have removed it from this list
        int index = FindBreakpointById(bp.internal_id, m_bps);
        if (index != wxNOT_FOUND) {
            // Hmm. See if there's a valid debugger_id. If so, the bp *was* accepted, and shouldn't be on the pending list
            if (m_bps.at(index).debugger_id != -1) {
                m_pendingBreakpointsList.erase(m_pendingBreakpointsList.begin()+i-1);
            }
            continue;	// The bp hasn't been assessed yet; it's probably pointless to try to reapply it atm
        }

        // This bp didn't 'take' the first time; "..try, try again" :p
        dbgr->Break(bp);
        m_bps.push_back(bp);
    }

    if (contIsNeeded) {
        dbgr->Continue();
    }

    RefreshBreakpointMarkers();
}
示例#4
0
void BreakptMgr::EditBreakpoint(int index, bool &bpExist)
{
    // sanity
    bpExist = true;
    if (index < 0 || index >= (int)m_bps.size()) {
        wxLogMessage(wxT("BreakptMgr::EditBreakpoint: Insane index"));
        bpExist = false;
        return;
    }

    BreakpointInfo bp = m_bps.at(index);
    BreakptPropertiesDlg dlg(NULL);
    wxString title;
    if (bp.bp_type == BP_type_watchpt) {
        title = _("Properties for watchpoint ");
    } else {
        title = _("Properties for breakpoint ");
    }
    int id = bp.debugger_id;
    if (id == -1) {
        id = bp.internal_id - FIRST_INTERNAL_ID;
    }
    title << id;
    dlg.SetTitle(title);

    dlg.EnterBPData(bp);
    if (dlg.ShowModal() != wxID_OK) {
        return ;
    }

    SetBestBPType(dlg.b);	// The edited data's available. Use it to determine the best bp_type
    if (bp == dlg.b) {
        // Nothing was altered
        return ;
    }

    // We've got our altered dlg.b If the debugger's running, we can update it now
    // Otherwise, it'll be automatically inserted correctly when the debugger starts
    IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
    if (dbgr && dbgr->IsRunning()) {
        if (CanThisBreakpointBeUpdated(dlg.b, bp)) {
            if (dlg.b.ignore_number != bp.ignore_number) {
                if (! SetBPIgnoreCount(dlg.b.debugger_id, dlg.b.ignore_number)) {
                    return;	// Harsh, but what else can one do?
                }
            }
            if (dlg.b.is_enabled != bp.is_enabled) {
                if (! SetBPEnabledState(dlg.b.debugger_id, dlg.b.is_enabled)) {
                    return ;
                }
            }
            if (dlg.b.conditions != bp.conditions) {
                if (! SetBPConditon(dlg.b)) {
                    return ;
                }
            }
            if (dlg.b.commandlist != bp.commandlist) {
                if (! SetBPCommands(dlg.b)) {
                    return ;
                }
            }
        } else {
            // If it can't be updated (because gdb wouldn't be able to cope with the change), replace
            bool contIsNeeded = PauseDebuggerIfNeeded();
            dbgr->RemoveBreak(bp.debugger_id);
            dbgr->Break(dlg.b);
            // dbgr->Break(bp) doesn't set the ignore/disabled/etc states
            // but we can't do it now, as we don't yet know the debugger_id
            // However it will happen later, in SetBreakpointDebuggerID
            if (contIsNeeded) {
                dbgr->Continue();
            }
        }
    }

    // Replace the old data with the new, in m_bps
    m_bps.at(index) = dlg.b;
    DeleteAllBreakpointMarkers();
    RefreshBreakpointMarkers();
}