bool BreakptMgr::DelBreakpoint(const int id) { int index = FindBreakpointById(id, m_bps); if (index == wxNOT_FOUND) { return false; } //remove it from the debugger if it's running IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger(); if (dbgr && dbgr->IsRunning()) { if (id > FIRST_INTERNAL_ID) { // This shouldn't happen while the debugger is running (debugger_id should be valid) // But if it does, assume it was a bp that gdb couldn't create, and just remove from the bp list } else { bool contIsNeeded = PauseDebuggerIfNeeded(); if (dbgr->RemoveBreak(id)) { // Strangely, -break-delete doesn't output any confirmation except for ^done. So do it here wxString msg = ((m_bps.at(index).bp_type == BP_type_watchpt) ? _("Watchpoint ") : _("Breakpoint ")); ManagerST::Get()->UpdateAddLine(msg + wxString::Format(_("%u deleted"), id)); } if (contIsNeeded) { dbgr->Continue(); } } } // Delete all markers before removing bp from the vector. Otherwise if id was the last in a file... DeleteAllBreakpointMarkers(); m_bps.erase(m_bps.begin()+index); RefreshBreakpointMarkers(); return true; }
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(); }