summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/qt/mainwindow.c
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2015-02-22 01:06:37 +1100
committer Vas Crabb <vas@vastheman.com>2015-02-22 01:19:09 +1100
commita581728a279f5320245579fbcacf4d5b7268831a (patch)
tree14500370faa2185bd3db346ca9b5dcbdb959289a /src/osd/modules/debugger/qt/mainwindow.c
parentb5afc9dfea42f3c7f361fb2006c9b3df2bc41b00 (diff)
Qt debugger dynamically updates menu items controlling disassembly views
Diffstat (limited to 'src/osd/modules/debugger/qt/mainwindow.c')
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.c141
1 files changed, 99 insertions, 42 deletions
diff --git a/src/osd/modules/debugger/qt/mainwindow.c b/src/osd/modules/debugger/qt/mainwindow.c
index f493741aced..87063adf245 100644
--- a/src/osd/modules/debugger/qt/mainwindow.c
+++ b/src/osd/modules/debugger/qt/mainwindow.c
@@ -43,13 +43,16 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
//
// Options Menu
//
- // Create two commands
- QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this);
- QAction* runToCursorAct = new QAction("Run To Cursor", this);
- breakpointSetAct->setShortcut(Qt::Key_F9);
- runToCursorAct->setShortcut(Qt::Key_F4);
- connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
- connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));
+ // Create three commands
+ m_breakpointToggleAct = new QAction("Toggle Breakpoint at Cursor", this);
+ m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this);
+ m_runToCursorAct = new QAction("Run to Cursor", this);
+ m_breakpointToggleAct->setShortcut(Qt::Key_F9);
+ m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9);
+ m_runToCursorAct->setShortcut(Qt::Key_F4);
+ connect(m_breakpointToggleAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
+ connect(m_breakpointEnableAct, SIGNAL(triggered(bool)), this, SLOT(enableBreakpointAtCursor(bool)));
+ connect(m_runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));
// Right bar options
QActionGroup* rightBarGroup = new QActionGroup(this);
@@ -71,8 +74,9 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// Assemble the options menu
QMenu* optionsMenu = menuBar()->addMenu("&Options");
- optionsMenu->addAction(breakpointSetAct);
- optionsMenu->addAction(runToCursorAct);
+ optionsMenu->addAction(m_breakpointToggleAct);
+ optionsMenu->addAction(m_breakpointEnableAct);
+ optionsMenu->addAction(m_runToCursorAct);
optionsMenu->addSeparator();
optionsMenu->addActions(rightBarGroup->actions());
@@ -109,6 +113,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
dasmDock->setWidget(m_dasmFrame);
+ connect(m_dasmFrame->view(), SIGNAL(updated()), this, SLOT(dasmViewUpdated()));
addDockWidget(Qt::TopDockWidgetArea, dasmDock);
dockMenu->addAction(dasmDock->toggleViewAction());
@@ -200,58 +205,78 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* event)
void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible())
+ debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
{
- if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
+ offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
+ device_debug *const cpuinfo = dasmView->source()->device()->debug();
+
+ // Find an existing breakpoint at this address
+ INT32 bpindex = -1;
+ for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
+ bp != NULL;
+ bp = bp->next())
{
- offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address();
- device_debug *cpuinfo = dasmView->source()->device()->debug();
-
- // Find an existing breakpoint at this address
- INT32 bpindex = -1;
- for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
- bp != NULL;
- bp = bp->next())
+ if (address == bp->address())
{
- if (address == bp->address())
- {
- bpindex = bp->index();
- break;
- }
+ bpindex = bp->index();
+ break;
}
+ }
- // If none exists, add a new one
- astring command;
- if (bpindex == -1)
- {
- command.printf("bpset 0x%X", address);
- }
- else
- {
- command.printf("bpclear 0x%X", bpindex);
- }
- debug_console_execute_command(*m_machine, command, 1);
+ // If none exists, add a new one
+ astring command;
+ if (bpindex == -1)
+ {
+ command.printf("bpset 0x%X", address);
}
+ else
+ {
+ command.printf("bpclear 0x%X", bpindex);
+ }
+ debug_console_execute_command(*m_machine, command, 1);
}
refreshAll();
}
-void MainWindow::runToCursor(bool changedTo)
+void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible())
+ debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
{
- if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
+ offs_t const address = dasmView->selected_address();
+ device_debug *const cpuinfo = dasmView->source()->device()->debug();
+
+ // Find an existing breakpoint at this address
+ device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
+ while ((bp != NULL) && (bp->address() != address))
+ bp = bp->next();
+
+ if (bp != NULL)
{
- offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
+ INT32 const bpindex = bp->index();
astring command;
- command.printf("go 0x%X", address);
+ command.printf(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
debug_console_execute_command(*m_machine, command, 1);
}
}
+
+ refreshAll();
+}
+
+
+void MainWindow::runToCursor(bool changedTo)
+{
+ debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ if (dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()))
+ {
+ offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
+ astring command;
+ command.printf("go 0x%X", address);
+ debug_console_execute_command(*m_machine, command, 1);
+ }
}
@@ -372,6 +397,38 @@ void MainWindow::unmountImage(bool changedTo)
}
+void MainWindow::dasmViewUpdated()
+{
+ debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ bool const haveCursor = dasmView->cursor_visible() && (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device());
+ bool haveBreakpoint = false;
+ bool breakpointEnabled = false;
+ if (haveCursor)
+ {
+ offs_t const address = dasmView->selected_address();
+ device_t *const device = dasmView->source()->device();
+ device_debug *const cpuinfo = device->debug();
+
+ // Find an existing breakpoint at this address
+ device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
+ while ((bp != NULL) && (bp->address() != address))
+ bp = bp->next();
+
+ if (bp != NULL)
+ {
+ haveBreakpoint = true;
+ breakpointEnabled = bp->enabled();
+ }
+ }
+
+ m_breakpointToggleAct->setText(haveBreakpoint ? "Clear Breakpoint at Cursor" : haveCursor ? "Set Breakpoint at Cursor" : "Toggle Breakpoint at Cursor");
+ m_breakpointEnableAct->setText((!haveBreakpoint || breakpointEnabled) ? "Disable Breakpoint at Cursor" : "Enable Breakpoint at Cursor");
+ m_breakpointToggleAct->setEnabled(haveCursor);
+ m_breakpointEnableAct->setEnabled(haveBreakpoint);
+ m_runToCursorAct->setEnabled(haveCursor);
+}
+
+
void MainWindow::debugActClose()
{
m_machine->schedule_exit();