bool DebuggerManager::HasMenu() const { wxMenuBar *menuBar = Manager::Get()->GetAppFrame()->GetMenuBar(); cbAssert(menuBar); int menu_pos = menuBar->FindMenu(_("&Debug")); return menu_pos != wxNOT_FOUND; }
void DebuggerMenuHandler::OnStep(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); if (m_activeDebugger->IsRunning()) { if(!m_disableContinue) { HideValueTooltip(); m_activeDebugger->Step(); } } else { m_disableContinue = true; ProjectManager *manager = Manager::Get()->GetProjectManager(); if (manager->GetIsRunning() == nullptr) { manager->SetIsRunning(m_activeDebugger); m_activeDebugger->ClearLog(); LogActiveConfig(); if (!m_activeDebugger->Debug(true)) manager->SetIsRunning(nullptr); } m_disableContinue = false; } }
ListCtrlLogger::ListCtrlLogger(const wxArrayString& titles_in, const wxArrayInt& widths_in, bool fixedPitchFont) : control(nullptr), fixed(fixedPitchFont), titles(titles_in), widths(widths_in) { cbAssert(titles.GetCount() == widths.GetCount()); }
void DebuggerMenuHandler::OnToggleBreakpoint(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!ed) return; ed->ToggleBreakpoint(); }
GotoFile::GotoFile(wxWindow* parent, IncrementalSelectIterator *iterator, const wxString &title, const wxString &message) : m_handler(this, iterator) { cbAssert(parent); BuildContent(parent, iterator, title, message); }
void DebuggerMenuHandler::RebuildMenus() { wxMenu *menuWindows = GetMenuById(idMenuDebuggingWindows, true); if (menuWindows) AppendWindowMenuItems(*menuWindows); if (m_activeDebugger) { wxMenu *menuTools = GetMenuById(idMenuTools, true); if (menuTools) m_activeDebugger->SetupToolsMenu(*menuTools); } DebuggerManager *dbgManager = Manager::Get()->GetDebuggerManager(); wxMenu *menu = GetMenuById(idMenuDebugActive, true); if (!menu) return; menu->AppendRadioItem(idMenuDebugActiveTargetsDefault, _("Target's default"), _("Use the debugger associated with the compiler for the active target")); const DebuggerManager::RegisteredPlugins &allDebugger = dbgManager->GetAllDebuggers(); for (DebuggerManager::RegisteredPlugins::const_iterator it = allDebugger.begin(); it != allDebugger.end(); ++it) { const DebuggerManager::ConfigurationVector &configs = it->second.GetConfigurations(); for (DebuggerManager::ConfigurationVector::const_iterator itConf = configs.begin(); itConf != configs.end(); ++itConf) { long id = (*itConf)->GetMenuId(); if (id == wxID_ANY) { id = wxNewId(); (*itConf)->SetMenuId(id); } menu->AppendRadioItem(id, it->first->GetGUIName() + wxT(": ") + (*itConf)->GetName()); Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &DebuggerMenuHandler::OnActiveDebuggerClick); } } if (m_activeDebugger && !dbgManager->IsActiveDebuggerTargetsDefault()) { DebuggerManager::RegisteredPlugins::const_iterator it = allDebugger.find(m_activeDebugger); cbAssert(it != allDebugger.end()); const DebuggerManager::ConfigurationVector &configs = it->second.GetConfigurations(); DebuggerManager::ConfigurationVector::const_iterator itConf = configs.begin(); std::advance(itConf, m_activeDebugger->GetIndexOfActiveConfig()); if (itConf != configs.end()) menu->Check((*itConf)->GetMenuId(), true); else menu->Check(configs.front()->GetMenuId(), true); } else menu->Check(idMenuDebugActiveTargetsDefault, true); }
void DebuggerMenuHandler::OnSetNextStatement(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!ed) return; HideValueTooltip(); m_activeDebugger->SetNextStatement(ed->GetFilename(), ed->GetControl()->GetCurrentLine() + 1); }
void DebuggerMenuHandler::OnContinue(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); if(!m_disableContinue) { HideValueTooltip(); m_activeDebugger->Continue(); } }
void DebuggerMenuHandler::OnAttachToProcess(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); wxString pidStr = cbGetTextFromUser(_("PID to attach to:")); if (!pidStr.empty()) { m_activeDebugger->AttachToProcess(pidStr); } }
cbDebuggerConfiguration* DebuggerManager::PluginData::GetConfiguration(int index) { if (m_configurations.empty()) cbAssert(false); if (index >= static_cast<int>(m_configurations.size())) return nullptr; else return m_configurations[index]; }
void DebuggerMenuHandler::OnAddDataBreakpoint(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); const wxString& word_at_caret = m_activeDebugger->GetEditorWordAtCaret(); if (!word_at_caret.empty()) { if (m_activeDebugger->AddDataBreakpoint(word_at_caret)) Manager::Get()->GetDebuggerManager()->GetBreakpointDialog()->Reload(); } }
void DebuggerMenuHandler::OnSendCommand(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); wxString cmd = cbGetTextFromUser(_("Enter command for Debugger:"), _("Send command to Debugger:"), m_lastCommand); if (cmd.IsEmpty()) return; m_activeDebugger->SendCommand(cmd, false); m_lastCommand = cmd; }
void DisassemblyDlg::OnMixedModeCB(cb_unused wxCommandEvent &event) { DebuggerManager &manager = *Manager::Get()->GetDebuggerManager(); bool newMode = !manager.IsDisassemblyMixedMode(); manager.SetDisassemblyMixedMode(newMode); m_MixedModeCB->SetValue(newMode); cbDebuggerPlugin *plugin = manager.GetActiveDebugger(); cbAssert(plugin); plugin->RequestUpdate(cbDebuggerPlugin::Disassembly); }
bool DebuggerManager::RegisterDebugger(cbDebuggerPlugin *plugin) { RegisteredPlugins::iterator it = m_registered.find(plugin); if (it != m_registered.end()) return false; const wxString &guiName=plugin->GetGUIName(); const wxString &settingsName=plugin->GetSettingsName(); wxRegEx regExSettingsName(wxT("^[a-z_][a-z0-9_]+$")); if (!regExSettingsName.Matches(settingsName)) { wxString s; s = wxString::Format(_("The settings name for the debugger plugin \"%s\" - \"%s\" contains invalid characters"), guiName.c_str(), settingsName.c_str()); Manager::Get()->GetLogManager()->LogError(s); return false; } int normalIndex = -1; GetLogger(normalIndex); plugin->SetupLog(normalIndex); PluginData data; m_registered[plugin] = data; it = m_registered.find(plugin); ProcessSettings(it); // There should be at least one configuration for every plugin. // If this is not the case, something is wrong and should be fixed. cbAssert(!it->second.GetConfigurations().empty()); wxString activeDebuggerName; int activeConfig; ReadActiveDebuggerConfig(activeDebuggerName, activeConfig); if (activeDebuggerName == settingsName) { if (activeConfig > static_cast<int>(it->second.GetConfigurations().size())) activeConfig = 0; m_activeDebugger = plugin; m_activeDebugger->SetActiveConfig(activeConfig); m_menuHandler->SetActiveDebugger(m_activeDebugger); } CreateWindows(); m_menuHandler->RebuildMenus(); return true; }
void DebuggerManager::SetInterfaceFactory(cbDebugInterfaceFactory *factory) { cbAssert(!m_interfaceFactory); m_interfaceFactory = factory; CreateWindows(); m_backtraceDialog->EnableWindow(false); m_cpuRegistersDialog->EnableWindow(false); m_disassemblyDialog->EnableWindow(false); m_examineMemoryDialog->EnableWindow(false); m_threadsDialog->EnableWindow(false); }
cbDebuggerConfiguration& cbDebuggerPlugin::GetActiveConfig() { DebuggerManager::RegisteredPlugins &allPlugins = Manager::Get()->GetDebuggerManager()->GetAllDebuggers(); DebuggerManager::RegisteredPlugins::iterator it = allPlugins.find(this); if (it == allPlugins.end()) cbAssert(false); cbDebuggerConfiguration *config = it->second.GetConfiguration(m_ActiveConfig); if (!config) return *it->second.GetConfigurations().front(); else return *config; }
void DebuggerManager::SetActiveDebugger(cbDebuggerPlugin* activeDebugger, ConfigurationVector::const_iterator config) { RegisteredPlugins::const_iterator it = m_registered.find(activeDebugger); cbAssert(it != m_registered.end()); m_useTargetsDefault = false; m_activeDebugger = activeDebugger; int index = std::distance(it->second.GetConfigurations().begin(), config); m_activeDebugger->SetActiveConfig(index); WriteActiveDebuggerConfig(it->first->GetSettingsName(), index); RefreshUI(); }
CodeBlocksLogEvent::CodeBlocksLogEvent(wxEventType commandType, Logger* logger_in, const wxString& title_in, wxBitmap *icon_in) : wxEvent(wxID_ANY, commandType), logger(logger_in), logIndex(-1), icon(icon_in), title(title_in), window(nullptr) { // special case for add if (commandType == cbEVT_ADD_LOG_WINDOW && logger) { if (Manager::Get()->GetLogManager()->FindIndex(logger) == LogManager::invalid_log) { logIndex = Manager::Get()->GetLogManager()->SetLog(logger); cbAssert(logIndex != LogManager::invalid_log); Manager::Get()->GetLogManager()->Slot(logIndex).title = title; Manager::Get()->GetLogManager()->Slot(logIndex).icon = icon; return; } } logIndex = Manager::Get()->GetLogManager()->FindIndex(logger); }
wxMenu* DebuggerManager::GetMenu() { wxMenuBar *menuBar = Manager::Get()->GetAppFrame()->GetMenuBar(); cbAssert(menuBar); wxMenu *menu = NULL; int menu_pos = menuBar->FindMenu(_("&Debug")); if(menu_pos != wxNOT_FOUND) menu = menuBar->GetMenu(menu_pos); if (!menu) { menu = Manager::Get()->LoadMenu(_T("debugger_menu"),true); // ok, now, where do we insert? // three possibilities here: // a) locate "Compile" menu and insert after it // b) locate "Project" menu and insert after it // c) if not found (?), insert at pos 5 int finalPos = 5; int projcompMenuPos = menuBar->FindMenu(_("&Build")); if (projcompMenuPos == wxNOT_FOUND) projcompMenuPos = menuBar->FindMenu(_("&Compile")); if (projcompMenuPos != wxNOT_FOUND) finalPos = projcompMenuPos + 1; else { projcompMenuPos = menuBar->FindMenu(_("&Project")); if (projcompMenuPos != wxNOT_FOUND) finalPos = projcompMenuPos + 1; } menuBar->Insert(finalPos, menu, _("&Debug")); m_menuHandler->RebuildMenus(); } return menu; }
void DebuggerMenuHandler::OnRunToCursor(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); if (!ed) return; const wxString &line_text = ed->GetControl()->GetLine(ed->GetControl()->GetCurrentLine()); ProjectManager *manager = Manager::Get()->GetProjectManager(); if (manager->GetIsRunning() == nullptr || manager->GetIsRunning() == m_activeDebugger) { manager->SetIsRunning(m_activeDebugger); if (!m_activeDebugger->IsRunning()) { m_activeDebugger->ClearLog(); LogActiveConfig(); } HideValueTooltip(); if (!m_activeDebugger->RunToCursor(ed->GetFilename(), ed->GetControl()->GetCurrentLine() + 1, line_text)) manager->SetIsRunning(nullptr); } }
void DebuggerMenuHandler::OnDetachFromProcess(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); m_activeDebugger->DetachFromProcess(); }
void CDB_driver::ParseOutput(const wxString& output) { m_Cursor.changed = false; static wxString buffer; buffer << output << _T('\n'); m_pDBG->DebugLog(output); if (rePrompt.Matches(buffer)) { int idx = buffer.First(rePrompt.GetMatch(buffer)); cbAssert(idx != wxNOT_FOUND); m_ProgramIsStopped = true; m_QueueBusy = false; DebuggerCmd* cmd = CurrentCommand(); if (cmd) { RemoveTopCommand(false); buffer.Remove(idx); if (buffer[buffer.Length() - 1] == _T('\n')) buffer.Remove(buffer.Length() - 1); cmd->ParseOutput(buffer.Left(idx)); delete cmd; RunQueue(); } } else return; // come back later bool notifyChange = false; // non-command messages (e.g. breakpoint hits) // break them up in lines wxArrayString lines = GetArrayFromString(buffer, _T('\n')); for (unsigned int i = 0; i < lines.GetCount(); ++i) { // Log(_T("DEBUG: ") + lines[i]); // write it in the full debugger log if (lines[i].StartsWith(_T("Cannot execute "))) { Log(lines[i]); } else if (lines[i].Contains(_T("Access violation"))) { m_ProgramIsStopped = true; Log(lines[i]); m_pDBG->BringCBToFront(); Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog(); DoBacktrace(true); InfoWindow::Display(_("Access violation"), lines[i]); break; } else if (notifyChange) continue; // Breakpoint 0 hit // > 38: if (!RegisterClassEx (&wincl)) else if (reBP.Matches(lines[i])) { m_ProgramIsStopped = true; Log(lines[i]); // Code breakpoint / assert m_pDBG->BringCBToFront(); Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog(); DoBacktrace(true); break; } else if (lines[i].Contains(_T("Break instruction exception")) && !m_pDBG->IsTemporaryBreak()) { m_ProgramIsStopped = true; // Code breakpoint / assert m_pDBG->BringCBToFront(); Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog(); DoBacktrace(true); break; } } if (notifyChange) NotifyCursorChanged(); buffer.Clear(); }
void DebuggerMenuHandler::OnRemoveAllBreakpoints(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); Manager::Get()->GetDebuggerManager()->GetBreakpointDialog()->RemoveAllBreakpoints(); }
void DisassemblyDlg::OnRefresh(cb_unused wxCommandEvent& event) { cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger(); cbAssert(plugin); plugin->RequestUpdate(cbDebuggerPlugin::Disassembly); }
const DebuggerDriver* DebuggerState::GetDriver() const { cbAssert(m_pDriver != NULL); return m_pDriver; }
void DebuggerMenuHandler::OnStepOut(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); HideValueTooltip(); m_activeDebugger->StepOut(); }
void DebuggerMenuHandler::OnNextInstr(cb_unused wxCommandEvent& event) { cbAssert(m_activeDebugger); HideValueTooltip(); m_activeDebugger->NextInstruction(); }