From e4ed1e08ef8542be0b75b99ea6490bf1eaef460a Mon Sep 17 00:00:00 2001 From: Nikita Zimin Date: Wed, 3 Jan 2024 13:35:46 +0300 Subject: [PATCH] Debugger turn off switch on the debug toolbar --- emulator/mainwindow.cpp | 5 +++++ emulator/qdebugview.cpp | 33 +++++++++++++++++++++++++++------ emulator/qdebugview.h | 2 ++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/emulator/mainwindow.cpp b/emulator/mainwindow.cpp index 428a1ff..e55c2a3 100644 --- a/emulator/mainwindow.cpp +++ b/emulator/mainwindow.cpp @@ -290,6 +290,9 @@ void MainWindow::updateMenu() ui->actionDebugDisasmView->setChecked(m_dockDisasm->isVisible()); ui->actionDebugMemoryView->setChecked(m_dockMemory->isVisible()); ui->actionDebugTeletypeView->setChecked(m_dockTeletype->isVisible()); + + if (m_debug != nullptr) + m_debug->updateToolbar(); } void MainWindow::updateAllViews() @@ -639,6 +642,8 @@ void MainWindow::debugConsoleView() if (!okShow) { + if (this->isMaximized()) + this->showNormal(); this->adjustSize(); } diff --git a/emulator/qdebugview.cpp b/emulator/qdebugview.cpp index c8e6885..ab5858d 100644 --- a/emulator/qdebugview.cpp +++ b/emulator/qdebugview.cpp @@ -49,17 +49,23 @@ QDebugView::QDebugView(QWidget *mainWindow) : m_breaksCtrl = new QDebugBreakpointsCtrl(this); m_breaksCtrl->setGeometry(x, 0, cxBreaks, cyHeight); x += cxBreaks + 4; - int cxMemmap = cxChar * 21 + cxChar / 2; + int cxMemmap = cxChar * 25; m_memmapCtrl = new QDebugMemoryMapCtrl(this); m_memmapCtrl->setGeometry(x, 0, cxMemmap, cyHeight); + m_actionDebugger = m_toolbar->addAction(QIcon(":/images/iconDebugger.svg"), ""); + m_toolbar->addSeparator(); QAction* actionStepInto = m_toolbar->addAction(QIcon(":/images/iconStepInto.svg"), ""); QAction* actionStepOver = m_toolbar->addAction(QIcon(":/images/iconStepOver.svg"), ""); + m_actionDebugger->setCheckable(true); + QObject::connect(m_actionDebugger, SIGNAL(triggered()), mainWindow, SLOT(debugConsoleView())); QObject::connect(actionStepInto, SIGNAL(triggered()), mainWindow, SLOT(debugStepInto())); QObject::connect(actionStepOver, SIGNAL(triggered()), mainWindow, SLOT(debugStepOver())); setFocusPolicy(Qt::ClickFocus); + + updateToolbar(); } CProcessor* QDebugView::getCurrentProc() const @@ -67,6 +73,11 @@ CProcessor* QDebugView::getCurrentProc() const return g_pBoard->GetCPU(); } +void QDebugView::updateToolbar() +{ + m_actionDebugger->setChecked(true); +} + // Update after Run or Step void QDebugView::updateData() { @@ -183,7 +194,7 @@ void QDebugProcessorCtrl::paintEvent(QPaintEvent * /*event*/) QFont font = Common_GetMonospacedFont(); painter.setFont(font); - QFontMetrics fontmetrics(font); + QFontMetrics fontmetrics = painter.fontMetrics(); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); QColor colorText = palette().color(QPalette::Text); @@ -296,7 +307,7 @@ void QDebugStackCtrl::paintEvent(QPaintEvent * /*event*/) QFont font = Common_GetMonospacedFont(); painter.setFont(font); - QFontMetrics fontmetrics(font); + QFontMetrics fontmetrics = painter.fontMetrics(); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); QColor colorText = palette().color(QPalette::Text); @@ -411,7 +422,7 @@ void QDebugPortsCtrl::paintEvent(QPaintEvent * /*event*/) QFont font = Common_GetMonospacedFont(); painter.setFont(font); - QFontMetrics fontmetrics(font); + QFontMetrics fontmetrics = painter.fontMetrics(); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); @@ -488,7 +499,7 @@ void QDebugBreakpointsCtrl::paintEvent(QPaintEvent * /*event*/) QFont font = Common_GetMonospacedFont(); painter.setFont(font); - QFontMetrics fontmetrics(font); + QFontMetrics fontmetrics = painter.fontMetrics(); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); @@ -524,7 +535,7 @@ void QDebugMemoryMapCtrl::paintEvent(QPaintEvent * /*event*/) QFont font = Common_GetMonospacedFont(); painter.setFont(font); - QFontMetrics fontmetrics(font); + QFontMetrics fontmetrics = painter.fontMetrics(); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); @@ -548,6 +559,16 @@ void QDebugMemoryMapCtrl::paintEvent(QPaintEvent * /*event*/) quint16 addr = (quint16)i * 020000; DrawOctalValue(painter, x, y2 - cyLine * i * 2 + cyLine / 3, addr); } + + quint16 sp = getProc()->GetSP(); + int ysp = y2 - ((y2 - y1) * sp / 65536); + painter.drawLine(x2, ysp, x2 + cxChar, ysp); + painter.drawText(x2 + cxChar, ysp + cyLine / 4, "SP"); + + quint16 pc = getProc()->GetPC(); + int ypc = y2 - ((y2 - y1) * pc / 65536); + painter.drawLine(x2, ypc, x2 + cxChar, ypc); + painter.drawText(x2 + cxChar, ypc + cyLine / 4, "PC"); } ////////////////////////////////////////////////////////////////////// diff --git a/emulator/qdebugview.h b/emulator/qdebugview.h index 4035714..35ee129 100644 --- a/emulator/qdebugview.h +++ b/emulator/qdebugview.h @@ -16,6 +16,7 @@ class QDebugView : public QWidget QDebugView(QWidget *parent = nullptr); CProcessor* getCurrentProc() const; + void updateToolbar(); void updateData(); protected: @@ -25,6 +26,7 @@ class QDebugView : public QWidget private: QToolBar* m_toolbar; + QAction* m_actionDebugger; QDebugCtrl* m_procCtrl; QDebugCtrl* m_stackCtrl; QDebugCtrl* m_portsCtrl;