summaryrefslogtreecommitdiffstats
path: root/src/osd/modules/debugger/qt/mainwindow.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-28 02:59:43 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-28 02:59:43 +1100
commit83c9637635c575972c039d7d63a48d788e41ba34 (patch)
tree59bad3ada8a0f0f61bf503da21acef0f237d4d6b /src/osd/modules/debugger/qt/mainwindow.cpp
parent832acf5731d68ca411b5fb358ddb4e79ef0faffa (diff)
-Qt debugger updates:
* Added context menu with Copy Visible and Paste commands to debug views (partially addresses #6066). * Made memory view last PC display a context menu item. * Fixed crash on right-clicking a memory view showing something other than an address space. -debugger: Fixed commas in dumpkbd output.
Diffstat (limited to 'src/osd/modules/debugger/qt/mainwindow.cpp')
-rw-r--r--src/osd/modules/debugger/qt/mainwindow.cpp162
1 files changed, 72 insertions, 90 deletions
diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp
index 75e25c2670d..b0043c06dee 100644
--- a/src/osd/modules/debugger/qt/mainwindow.cpp
+++ b/src/osd/modules/debugger/qt/mainwindow.cpp
@@ -1,14 +1,6 @@
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner
#include "emu.h"
-#include <QtWidgets/QAction>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QDockWidget>
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QFileDialog>
-#include <QtGui/QCloseEvent>
-
#include "mainwindow.h"
#include "debug/debugcon.h"
@@ -16,8 +8,16 @@
#include "debug/dvdisasm.h"
#include "debug/points.h"
+#include <QtGui/QCloseEvent>
+#include <QtWidgets/QAction>
+#include <QtWidgets/QDockWidget>
+#include <QtWidgets/QFileDialog>
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QMenuBar>
+#include <QtWidgets/QScrollBar>
+
-MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
+MainWindow::MainWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr),
m_historyIndex(0),
m_inputHistory()
@@ -27,7 +27,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
//
// The main frame and its input and log widgets
//
- QFrame* mainWindowFrame = new QFrame(this);
+ QFrame *mainWindowFrame = new QFrame(this);
// The input line
m_inputEdit = new QLineEdit(mainWindowFrame);
@@ -36,13 +36,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// The log view
- m_consoleView = new DebuggerView(DVT_CONSOLE,
- m_machine,
- mainWindowFrame);
+ m_consoleView = new DebuggerView(DVT_CONSOLE, m_machine, mainWindowFrame);
m_consoleView->setFocusPolicy(Qt::NoFocus);
m_consoleView->setPreferBottom(true);
- QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
+ QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->addWidget(m_consoleView);
vLayout->addWidget(m_inputEdit);
vLayout->setSpacing(3);
@@ -65,11 +63,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(m_runToCursorAct, &QAction::triggered, this, &MainWindow::runToCursor);
// Right bar options
- QActionGroup* rightBarGroup = new QActionGroup(this);
+ QActionGroup *rightBarGroup = new QActionGroup(this);
rightBarGroup->setObjectName("rightbargroup");
- QAction* rightActRaw = new QAction("Raw Opcodes", this);
- QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
- QAction* rightActComments = new QAction("Comments", this);
+ QAction *rightActRaw = new QAction("Raw Opcodes", this);
+ QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
+ QAction *rightActComments = new QAction("Comments", this);
rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true);
@@ -83,7 +81,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(rightBarGroup, &QActionGroup::triggered, this, &MainWindow::rightBarChanged);
// Assemble the options menu
- QMenu* optionsMenu = menuBar()->addMenu("&Options");
+ QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addAction(m_breakpointToggleAct);
optionsMenu->addAction(m_breakpointEnableAct);
optionsMenu->addAction(m_runToCursorAct);
@@ -93,22 +91,20 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
//
// Images menu
//
- image_interface_enumerator imageIterTest(m_machine->root_device());
- if (imageIterTest.first() != nullptr)
- {
+ image_interface_enumerator imageIterTest(m_machine.root_device());
+ if (imageIterTest.first())
createImagesMenu();
- }
//
// Dock window menu
//
- QMenu* dockMenu = menuBar()->addMenu("Doc&ks");
+ QMenu *dockMenu = menuBar()->addMenu("Doc&ks");
setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
// The processor dock
- QDockWidget* cpuDock = new QDockWidget("processor", this);
+ QDockWidget *cpuDock = new QDockWidget("processor", this);
cpuDock->setObjectName("cpudock");
cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
@@ -118,7 +114,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
dockMenu->addAction(cpuDock->toggleViewAction());
// The disassembly dock
- QDockWidget* dasmDock = new QDockWidget("dasm", this);
+ QDockWidget *dasmDock = new QDockWidget("dasm", this);
dasmDock->setObjectName("dasmdock");
dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
@@ -135,7 +131,7 @@ MainWindow::~MainWindow()
}
-void MainWindow::setProcessor(device_t* processor)
+void MainWindow::setProcessor(device_t *processor)
{
// Cpu swap
m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor));
@@ -146,13 +142,12 @@ void MainWindow::setProcessor(device_t* processor)
m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
// Window title
- string_format("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
- setWindowTitle(string_format("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()).c_str());
+ setWindowTitle(string_format("Debug: %s - %s '%s'", m_machine.system().name, processor->name(), processor->tag()).c_str());
}
// Used to intercept the user clicking 'X' in the upper corner
-void MainWindow::closeEvent(QCloseEvent* event)
+void MainWindow::closeEvent(QCloseEvent *event)
{
debugActQuit();
@@ -162,18 +157,14 @@ void MainWindow::closeEvent(QCloseEvent* event)
// Used to intercept the user hitting the up arrow in the input widget
-bool MainWindow::eventFilter(QObject* obj, QEvent* event)
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
// Only filter keypresses
- QKeyEvent* keyEvent = nullptr;
+ QKeyEvent *keyEvent = nullptr;
if (event->type() == QEvent::KeyPress)
- {
keyEvent = static_cast<QKeyEvent*>(event);
- }
else
- {
return QObject::eventFilter(obj, event);
- }
// Catch up & down keys
if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
@@ -215,7 +206,7 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* event)
void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -225,15 +216,11 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
// If none exists, add a new one
std::string command;
- if (bp == nullptr)
- {
+ if (!bp)
command = string_format("bpset 0x%X", address);
- }
else
- {
command = string_format("bpclear 0x%X", bp->index());
- }
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
refreshAll();
@@ -243,7 +230,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
void MainWindow::enableBreakpointAtCursor(bool changedTo)
{
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t const address = dasmView->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug();
@@ -251,11 +238,11 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
int32_t const bpindex = bp->index();
std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex);
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
}
@@ -265,31 +252,27 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
void MainWindow::runToCursor(bool changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- if (dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device()))
+ debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ if (dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device()))
{
offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
std::string command = string_format("go 0x%X", address);
- m_machine->debugger().console().execute_command(command.c_str(), true);
+ m_machine.debugger().console().execute_command(command.c_str(), true);
}
}
-void MainWindow::rightBarChanged(QAction* changedTo)
+void MainWindow::rightBarChanged(QAction *changedTo)
{
- debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+ debug_view_disasm *dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
+
if (changedTo->text() == "Raw Opcodes")
- {
dasmView->set_right_column(DASM_RIGHTCOL_RAW);
- }
else if (changedTo->text() == "Encrypted Opcodes")
- {
dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
- }
else if (changedTo->text() == "Comments")
- {
dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
- }
+
m_dasmFrame->view()->viewport()->update();
}
@@ -305,12 +288,12 @@ void MainWindow::executeCommand(bool withClear)
// A blank command is a "silent step"
if (command == "")
{
- m_machine->debugger().console().get_visible_cpu()->debug()->single_step();
+ m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
return;
}
// Send along the command
- m_machine->debugger().console().execute_command(command.toLocal8Bit().data(), true);
+ m_machine.debugger().console().execute_command(command.toLocal8Bit().data(), true);
// Add history & set the index to be the top of the stack
addToHistory(command);
@@ -332,24 +315,25 @@ void MainWindow::mountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
- image_interface_enumerator iter(m_machine->root_device());
+ image_interface_enumerator iter(m_machine.root_device());
device_image_interface *img = iter.byindex(imageIndex);
- if (img == nullptr)
+ if (!img)
{
- m_machine->debugger().console().printf("Something is wrong with the mount menu.\n");
+ m_machine.debugger().console().printf("Something is wrong with the mount menu.\n");
refreshAll();
return;
}
// File dialog
- QString filename = QFileDialog::getOpenFileName(this,
- "Select an image file",
- QDir::currentPath(),
- tr("All files (*.*)"));
+ QString filename = QFileDialog::getOpenFileName(
+ this,
+ "Select an image file",
+ QDir::currentPath(),
+ tr("All files (*.*)"));
if (img->load(filename.toUtf8().data()) != image_init_result::PASS)
{
- m_machine->debugger().console().printf("Image could not be mounted.\n");
+ m_machine.debugger().console().printf("Image could not be mounted.\n");
refreshAll();
return;
}
@@ -359,13 +343,13 @@ void MainWindow::mountImage(bool changedTo)
unmountAct->setEnabled(true);
// Set the mount name
- QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
+ QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle);
- m_machine->debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
+ m_machine.debugger().console().printf("Image %s mounted successfully.\n", filename.toUtf8().data());
refreshAll();
}
@@ -373,31 +357,31 @@ void MainWindow::mountImage(bool changedTo)
void MainWindow::unmountImage(bool changedTo)
{
// The image interface index was assigned to the QAction's data memeber
- const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt();
- image_interface_enumerator iter(m_machine->root_device());
+ const int imageIndex = dynamic_cast<QAction *>(sender())->data().toInt();
+ image_interface_enumerator iter(m_machine.root_device());
device_image_interface *img = iter.byindex(imageIndex);
img->unload();
// Deactivate the unmount menu option
- dynamic_cast<QAction*>(sender())->setEnabled(false);
+ dynamic_cast<QAction *>(sender())->setEnabled(false);
// Set the mount name
- QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent());
+ QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle);
- m_machine->debugger().console().printf("Image successfully unmounted.\n");
+ m_machine.debugger().console().printf("Image successfully unmounted.\n");
refreshAll();
}
void MainWindow::dasmViewUpdated()
{
- debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
- bool const haveCursor = dasmView->cursor_visible() && (m_machine->debugger().console().get_visible_cpu() == dasmView->source()->device());
+ debug_view_disasm *const dasmView = downcast<debug_view_disasm *>(m_dasmFrame->view()->view());
+ bool const haveCursor = dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device());
bool haveBreakpoint = false;
bool breakpointEnabled = false;
if (haveCursor)
@@ -409,7 +393,7 @@ void MainWindow::dasmViewUpdated()
// Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
- if (bp != nullptr)
+ if (bp)
{
haveBreakpoint = true;
breakpointEnabled = bp->enabled();
@@ -426,7 +410,7 @@ void MainWindow::dasmViewUpdated()
void MainWindow::debugActClose()
{
- m_machine->schedule_exit();
+ m_machine.schedule_exit();
}
@@ -436,7 +420,7 @@ void MainWindow::addToHistory(const QString& command)
return;
// Always push back when there is no previous history
- if (m_inputHistory.size() == 0)
+ if (m_inputHistory.empty())
{
m_inputHistory.push_back(m_inputEdit->text());
return;
@@ -444,26 +428,24 @@ void MainWindow::addToHistory(const QString& command)
// If there is previous history, make sure it's not what you just executed
if (m_inputHistory.back() != m_inputEdit->text())
- {
m_inputHistory.push_back(m_inputEdit->text());
- }
}
void MainWindow::createImagesMenu()
{
- QMenu* imagesMenu = menuBar()->addMenu("&Images");
+ QMenu *imagesMenu = menuBar()->addMenu("&Images");
int interfaceIndex = 0;
- for (device_image_interface &img : image_interface_enumerator(m_machine->root_device()))
+ for (device_image_interface &img : image_interface_enumerator(m_machine.root_device()))
{
std::string menuName = string_format("%s : %s", img.device().name(), img.exists() ? img.filename() : "[empty slot]");
- QMenu* interfaceMenu = imagesMenu->addMenu(menuName.c_str());
+ QMenu *interfaceMenu = imagesMenu->addMenu(menuName.c_str());
interfaceMenu->setObjectName(img.device().name());
- QAction* mountAct = new QAction("Mount...", interfaceMenu);
- QAction* unmountAct = new QAction("Unmount", interfaceMenu);
+ QAction *mountAct = new QAction("Mount...", interfaceMenu);
+ QAction *unmountAct = new QAction("Unmount", interfaceMenu);
mountAct->setObjectName("mount");
mountAct->setData(QVariant(interfaceIndex));
unmountAct->setObjectName("unmount");
@@ -490,10 +472,10 @@ void MainWindow::createImagesMenu()
void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
{
WindowQtConfig::buildFromQWidget(widget);
- MainWindow* window = dynamic_cast<MainWindow*>(widget);
+ MainWindow *window = dynamic_cast<MainWindow *>(widget);
m_windowState = window->saveState();
- QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
+ QActionGroup *rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
m_rightBar = 0;
else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
@@ -503,10 +485,10 @@ void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
}
-void MainWindowQtConfig::applyToQWidget(QWidget* widget)
+void MainWindowQtConfig::applyToQWidget(QWidget *widget)
{
WindowQtConfig::applyToQWidget(widget);
- MainWindow* window = dynamic_cast<MainWindow*>(widget);
+ MainWindow *window = dynamic_cast<MainWindow *>(widget);
window->restoreState(m_windowState);
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");