bool BreakptMgr::AddBreakpoint(const BreakpointInfo &bp) { if (bp.bp_type != BP_type_watchpt && bp.file.IsEmpty() && bp.function_name.IsEmpty() && bp.memory_address.IsEmpty() && bp.lineno == wxNOT_FOUND) { // no function nor file? no memory address? // do nothing then return true; } IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger(); if (dbgr && dbgr->IsRunning()) { // If the debugger is already running, tell it we want a new bp // If not, they'll all be added together when the debugger does start bool contIsNeeded = PauseDebuggerIfNeeded(); dbgr->Break(bp); if (contIsNeeded) { dbgr->Continue(); } } BreakpointInfo newBreakpoint(bp); SetBestBPType(newBreakpoint); BreakpointInfoVec_t::const_iterator iter = std::find(m_bps.begin(), m_bps.end(), newBreakpoint); if ( iter == m_bps.end() ) { // new breakpoint m_bps.push_back( newBreakpoint ); } DeleteAllBreakpointMarkers(); RefreshBreakpointMarkers(); return true; }
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(); }
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(); }