Skip to content

Commit

Permalink
Debugger turn off switch on the debug toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Jan 3, 2024
1 parent 8a9f74e commit e4ed1e0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
5 changes: 5 additions & 0 deletions emulator/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -639,6 +642,8 @@ void MainWindow::debugConsoleView()

if (!okShow)
{
if (this->isMaximized())
this->showNormal();
this->adjustSize();
}

Expand Down
33 changes: 27 additions & 6 deletions emulator/qdebugview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,35 @@ 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
{
return g_pBoard->GetCPU();
}

void QDebugView::updateToolbar()
{
m_actionDebugger->setChecked(true);
}

// Update after Run or Step
void QDebugView::updateData()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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");
}

//////////////////////////////////////////////////////////////////////
2 changes: 2 additions & 0 deletions emulator/qdebugview.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QDebugView : public QWidget
QDebugView(QWidget *parent = nullptr);

CProcessor* getCurrentProc() const;
void updateToolbar();
void updateData();

protected:
Expand All @@ -25,6 +26,7 @@ class QDebugView : public QWidget

private:
QToolBar* m_toolbar;
QAction* m_actionDebugger;
QDebugCtrl* m_procCtrl;
QDebugCtrl* m_stackCtrl;
QDebugCtrl* m_portsCtrl;
Expand Down

0 comments on commit e4ed1e0

Please # to comment.