-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.
This commit is contained in:
Vas Crabb 2021-01-28 02:59:43 +11:00
parent 832acf5731
commit 83c9637635
20 changed files with 746 additions and 768 deletions

View File

@ -1015,7 +1015,6 @@ void natural_keyboard::dump(std::ostream &str) const
firstdev = false; firstdev = false;
// loop through all codes // loop through all codes
bool firstkey(true);
for (auto &code : devinfo.codemap) for (auto &code : devinfo.codemap)
{ {
// describe the character code // describe the character code
@ -1027,12 +1026,15 @@ void natural_keyboard::dump(std::ostream &str) const
for (auto &entry : code.second) for (auto &entry : code.second)
{ {
// identify the keys used // identify the keys used
bool firstkey(true);
for (std::size_t field = 0; (entry.field.size() > field) && entry.field[field]; ++field) for (std::size_t field = 0; (entry.field.size() > field) && entry.field[field]; ++field)
{
util::stream_format(str, "%s'%s'", firstkey ? "" : ", ", entry.field[field]->name()); util::stream_format(str, "%s'%s'", firstkey ? "" : ", ", entry.field[field]->name());
firstkey = false;
}
// carriage return // carriage return
str << '\n'; str << '\n';
firstkey = false;
} }
} }
} }

View File

@ -38,9 +38,7 @@ class debug_qt : public osd_module, public debug_module
#endif #endif
{ {
public: public:
debug_qt() debug_qt() : osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(), m_machine(nullptr)
: osd_module(OSD_DEBUG_PROVIDER, "qt"), debug_module(),
m_machine(nullptr)
{ {
} }
@ -78,37 +76,35 @@ MainWindow *mainQtWindow = nullptr;
//============================================================ //============================================================
// Global variable used to feed the xml configuration callbacks // Global variable used to feed the xml configuration callbacks
std::vector<WindowQtConfig*> xmlConfigurations; std::vector<std::unique_ptr<WindowQtConfig> > xmlConfigurations;
void xml_configuration_load(running_machine &machine, config_type cfg_type, util::xml::data_node const *parentnode) void xml_configuration_load(running_machine &machine, config_type cfg_type, util::xml::data_node const *parentnode)
{ {
// We only care about game files // We only care about game files
if (cfg_type != config_type::GAME) if (cfg_type != config_type::GAME)
return; return;
// Might not have any data // Might not have any data
if (parentnode == nullptr) if (!parentnode)
return; return;
for (int i = 0; i < xmlConfigurations.size(); i++)
delete xmlConfigurations[i];
xmlConfigurations.clear(); xmlConfigurations.clear();
// Configuration load // Configuration load
util::xml::data_node const * wnode = nullptr; util::xml::data_node const *wnode = nullptr;
for (wnode = parentnode->get_child("window"); wnode != nullptr; wnode = wnode->get_next_sibling("window")) for (wnode = parentnode->get_child("window"); wnode != nullptr; wnode = wnode->get_next_sibling("window"))
{ {
WindowQtConfig::WindowType type = (WindowQtConfig::WindowType)wnode->get_attribute_int("type", WindowQtConfig::WIN_TYPE_UNKNOWN); WindowQtConfig::WindowType type = (WindowQtConfig::WindowType)wnode->get_attribute_int("type", WindowQtConfig::WIN_TYPE_UNKNOWN);
switch (type) switch (type)
{ {
case WindowQtConfig::WIN_TYPE_MAIN: xmlConfigurations.push_back(new MainWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_MAIN: xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_MEMORY: xmlConfigurations.push_back(new MemoryWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_MEMORY: xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(new DasmWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_DASM: xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(new LogWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_LOG: xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_BREAK_POINTS: xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(new DevicesWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_DEVICES: xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>()); break;
case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: xmlConfigurations.push_back(new DeviceInformationWindowQtConfig()); break; case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>()); break;
default: continue; default: continue;
} }
xmlConfigurations.back()->recoverFromXmlNode(*wnode); xmlConfigurations.back()->recoverFromXmlNode(*wnode);
@ -124,27 +120,24 @@ void xml_configuration_save(running_machine &machine, config_type cfg_type, util
for (int i = 0; i < xmlConfigurations.size(); i++) for (int i = 0; i < xmlConfigurations.size(); i++)
{ {
WindowQtConfig* config = xmlConfigurations[i]; WindowQtConfig &config = *xmlConfigurations[i];
// Create an xml node // Create an xml node
util::xml::data_node *const debugger_node = parentnode->add_child("window", nullptr); util::xml::data_node *const debugger_node = parentnode->add_child("window", nullptr);
if (debugger_node == nullptr)
continue;
// Insert the appropriate information // Insert the appropriate information
config->addToXmlDataNode(*debugger_node); if (debugger_node)
config.addToXmlDataNode(*debugger_node);
} }
} }
void gather_save_configurations() void gather_save_configurations()
{ {
for (int i = 0; i < xmlConfigurations.size(); i++)
delete xmlConfigurations[i];
xmlConfigurations.clear(); xmlConfigurations.clear();
// Loop over all the open windows // Loop over all the open windows
foreach (QWidget* widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (!widget->isVisible()) if (!widget->isVisible())
continue; continue;
@ -153,20 +146,20 @@ void gather_save_configurations()
continue; continue;
// Figure out its type // Figure out its type
if (dynamic_cast<MainWindow*>(widget)) if (dynamic_cast<MainWindow *>(widget))
xmlConfigurations.push_back(new MainWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<MainWindowQtConfig>());
else if (dynamic_cast<MemoryWindow*>(widget)) else if (dynamic_cast<MemoryWindow *>(widget))
xmlConfigurations.push_back(new MemoryWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<MemoryWindowQtConfig>());
else if (dynamic_cast<DasmWindow*>(widget)) else if (dynamic_cast<DasmWindow *>(widget))
xmlConfigurations.push_back(new DasmWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<DasmWindowQtConfig>());
else if (dynamic_cast<LogWindow*>(widget)) else if (dynamic_cast<LogWindow *>(widget))
xmlConfigurations.push_back(new LogWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<LogWindowQtConfig>());
else if (dynamic_cast<BreakpointsWindow*>(widget)) else if (dynamic_cast<BreakpointsWindow *>(widget))
xmlConfigurations.push_back(new BreakpointsWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<BreakpointsWindowQtConfig>());
else if (dynamic_cast<DevicesWindow*>(widget)) else if (dynamic_cast<DevicesWindow *>(widget))
xmlConfigurations.push_back(new DevicesWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<DevicesWindowQtConfig>());
else if (dynamic_cast<DeviceInformationWindow*>(widget)) else if (dynamic_cast<DeviceInformationWindow *>(widget))
xmlConfigurations.push_back(new DeviceInformationWindowQtConfig()); xmlConfigurations.push_back(std::make_unique<DeviceInformationWindowQtConfig>());
xmlConfigurations.back()->buildFromQWidget(widget); xmlConfigurations.back()->buildFromQWidget(widget);
} }
@ -177,45 +170,46 @@ void gather_save_configurations()
// Utilities // Utilities
//============================================================ //============================================================
void load_and_clear_main_window_config(std::vector<WindowQtConfig*>& configList) void load_and_clear_main_window_config(std::vector<std::unique_ptr<WindowQtConfig> > &configList)
{ {
for (int i = 0; i < configList.size(); i++) for (int i = 0; i < configList.size(); i++)
{ {
WindowQtConfig* config = configList[i]; WindowQtConfig &config = *configList[i];
if (config->m_type == WindowQtConfig::WIN_TYPE_MAIN) if (config.m_type == WindowQtConfig::WIN_TYPE_MAIN)
{ {
config->applyToQWidget(mainQtWindow); config.applyToQWidget(mainQtWindow);
configList.erase(configList.begin()+i); configList.erase(configList.begin() + i);
break; break;
} }
} }
} }
void setup_additional_startup_windows(running_machine& machine, std::vector<WindowQtConfig*>& configList) void setup_additional_startup_windows(running_machine &machine, std::vector<std::unique_ptr<WindowQtConfig> > &configList)
{ {
for (int i = 0; i < configList.size(); i++) for (int i = 0; i < configList.size(); i++)
{ {
WindowQtConfig* config = configList[i]; WindowQtConfig &config = *configList[i];
WindowQt* foo = nullptr; WindowQt *foo = nullptr;
switch (config->m_type) switch (config.m_type)
{ {
case WindowQtConfig::WIN_TYPE_MEMORY: case WindowQtConfig::WIN_TYPE_MEMORY:
foo = new MemoryWindow(&machine); break; foo = new MemoryWindow(machine); break;
case WindowQtConfig::WIN_TYPE_DASM: case WindowQtConfig::WIN_TYPE_DASM:
foo = new DasmWindow(&machine); break; foo = new DasmWindow(machine); break;
case WindowQtConfig::WIN_TYPE_LOG: case WindowQtConfig::WIN_TYPE_LOG:
foo = new LogWindow(&machine); break; foo = new LogWindow(machine); break;
case WindowQtConfig::WIN_TYPE_BREAK_POINTS: case WindowQtConfig::WIN_TYPE_BREAK_POINTS:
foo = new BreakpointsWindow(&machine); break; foo = new BreakpointsWindow(machine); break;
case WindowQtConfig::WIN_TYPE_DEVICES: case WindowQtConfig::WIN_TYPE_DEVICES:
foo = new DevicesWindow(&machine); break; foo = new DevicesWindow(machine); break;
case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION: case WindowQtConfig::WIN_TYPE_DEVICE_INFORMATION:
foo = new DeviceInformationWindow(&machine); break; foo = new DeviceInformationWindow(machine); break;
default: break; default:
break;
} }
config->applyToQWidget(foo); config.applyToQWidget(foo);
foo->show(); foo->show();
} }
} }
@ -223,12 +217,13 @@ void setup_additional_startup_windows(running_machine& machine, std::vector<Wind
void bring_main_window_to_front() void bring_main_window_to_front()
{ {
foreach (QWidget* widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (!dynamic_cast<MainWindow*>(widget)) if (dynamic_cast<MainWindow *>(widget))
continue; {
widget->activateWindow(); widget->activateWindow();
widget->raise(); widget->raise();
}
} }
} }
@ -251,7 +246,7 @@ bool debug_qt::nativeEventFilter(const QByteArray &eventType, void *message, lon
void debug_qt::init_debugger(running_machine &machine) void debug_qt::init_debugger(running_machine &machine)
{ {
if (qApp == nullptr) if (!qApp)
{ {
// If you're starting from scratch, create a new qApp // If you're starting from scratch, create a new qApp
new QApplication(qtArgc, qtArgv); new QApplication(qtArgc, qtArgv);
@ -262,7 +257,7 @@ void debug_qt::init_debugger(running_machine &machine)
else else
{ {
// If you've done a hard reset, clear out existing widgets & get ready for re-init // If you've done a hard reset, clear out existing widgets & get ready for re-init
foreach (QWidget* widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (!widget->isWindow() || widget->windowType() != Qt::Window) if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue; continue;
@ -274,8 +269,8 @@ void debug_qt::init_debugger(running_machine &machine)
m_machine = &machine; m_machine = &machine;
// Setup the configuration XML saving and loading // Setup the configuration XML saving and loading
machine.configuration().config_register("debugger", machine.configuration().config_register("debugger",
config_load_delegate(&xml_configuration_load, &machine), config_load_delegate(&xml_configuration_load, &machine),
config_save_delegate(&xml_configuration_save, &machine)); config_save_delegate(&xml_configuration_save, &machine));
} }
@ -298,15 +293,15 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
// Dialog initialization // Dialog initialization
if (oneShot) if (oneShot)
{ {
mainQtWindow = new MainWindow(m_machine); mainQtWindow = new MainWindow(*m_machine);
load_and_clear_main_window_config(xmlConfigurations); load_and_clear_main_window_config(xmlConfigurations);
setup_additional_startup_windows(*m_machine, xmlConfigurations); setup_additional_startup_windows(*m_machine, xmlConfigurations);
mainQtWindow->show(); mainQtWindow->show();
oneShot = false; oneShot = false;
} }
// Insure all top level widgets are visible & bring main window to front // Ensure all top level widgets are visible & bring main window to front
foreach (QWidget* widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (!widget->isWindow() || widget->windowType() != Qt::Window) if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue; continue;
@ -314,9 +309,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
} }
if (firststop) if (firststop)
{
bring_main_window_to_front(); bring_main_window_to_front();
}
// Set the main window to display the proper cpu // Set the main window to display the proper cpu
mainQtWindow->setProcessor(&device); mainQtWindow->setProcessor(&device);
@ -337,7 +330,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
// Hide all top level widgets if requested // Hide all top level widgets if requested
if (mainQtWindow->wantsHide()) if (mainQtWindow->wantsHide())
{ {
foreach (QWidget* widget, QApplication::topLevelWidgets()) foreach (QWidget *widget, QApplication::topLevelWidgets())
{ {
if (!widget->isWindow() || widget->windowType() != Qt::Window) if (!widget->isWindow() || widget->windowType() != Qt::Window)
continue; continue;
@ -355,7 +348,7 @@ void debug_qt::wait_for_debugger(device_t &device, bool firststop)
gather_save_configurations(); gather_save_configurations();
} }
#if defined(WIN32) && !defined(SDLMAME_WIN32) #if defined(WIN32) && !defined(SDLMAME_WIN32)
winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger winwindow_update_cursor_state(*m_machine); // make sure the cursor isn't hidden while in debugger
#endif #endif
} }
@ -369,8 +362,10 @@ void debug_qt::debugger_update()
qApp->processEvents(QEventLoop::AllEvents, 1); qApp->processEvents(QEventLoop::AllEvents, 1);
} }
#else /* SDLMAME_UNIX */ #else // USE_QTDEBUG
MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
MODULE_NOT_SUPPORTED(debug_qt, OSD_DEBUG_PROVIDER, "qt")
#endif #endif
MODULE_DEFINITION(DEBUG_QT, debug_qt) MODULE_DEFINITION(DEBUG_QT, debug_qt)

View File

@ -1,12 +1,6 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #include "emu.h"
#include <QtWidgets/QActionGroup>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QVBoxLayout>
#include "breakpointswindow.h" #include "breakpointswindow.h"
#include "debug/debugcon.h" #include "debug/debugcon.h"
@ -14,13 +8,19 @@
#include "debug/dvbpoints.h" #include "debug/dvbpoints.h"
#include "debug/dvwpoints.h" #include "debug/dvwpoints.h"
#include <QtWidgets/QActionGroup>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QVBoxLayout>
BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) :
BreakpointsWindow::BreakpointsWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr) WindowQt(machine, nullptr)
{ {
setWindowTitle("Debug: All Breakpoints"); setWindowTitle("Debug: All Breakpoints");
if (parent != nullptr) if (parent)
{ {
QPoint parentPos = parent->pos(); QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@ -29,13 +29,13 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
// //
// The main frame and its input and breakpoints widgets // The main frame and its input and breakpoints widgets
// //
QFrame* mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
// The main breakpoints view // The main breakpoints view
m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this);
// Layout // Layout
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setObjectName("vlayout"); vLayout->setObjectName("vlayout");
vLayout->setSpacing(3); vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2); vLayout->setContentsMargins(2,2,2,2);
@ -46,11 +46,11 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
// //
// Menu bars // Menu bars
// //
QActionGroup* typeGroup = new QActionGroup(this); QActionGroup *typeGroup = new QActionGroup(this);
typeGroup->setObjectName("typegroup"); typeGroup->setObjectName("typegroup");
QAction* typeBreak = new QAction("Breakpoints", this); QAction *typeBreak = new QAction("Breakpoints", this);
typeBreak->setObjectName("typebreak"); typeBreak->setObjectName("typebreak");
QAction* typeWatch = new QAction("Watchpoints", this); QAction *typeWatch = new QAction("Watchpoints", this);
typeWatch->setObjectName("typewatch"); typeWatch->setObjectName("typewatch");
typeBreak->setCheckable(true); typeBreak->setCheckable(true);
typeWatch->setCheckable(true); typeWatch->setCheckable(true);
@ -62,7 +62,7 @@ BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent)
connect(typeGroup, &QActionGroup::triggered, this, &BreakpointsWindow::typeChanged); connect(typeGroup, &QActionGroup::triggered, this, &BreakpointsWindow::typeChanged);
// Assemble the options menu // Assemble the options menu
QMenu* optionsMenu = menuBar()->addMenu("&Options"); QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addActions(typeGroup->actions()); optionsMenu->addActions(typeGroup->actions());
} }
@ -91,7 +91,7 @@ void BreakpointsWindow::typeChanged(QAction* changedTo)
} }
// Re-register // Re-register
QVBoxLayout* layout = findChild<QVBoxLayout*>("vlayout"); QVBoxLayout *layout = findChild<QVBoxLayout *>("vlayout");
layout->addWidget(m_breakpointsView); layout->addWidget(m_breakpointsView);
} }
@ -100,10 +100,10 @@ void BreakpointsWindow::typeChanged(QAction* changedTo)
//========================================================================= //=========================================================================
// BreakpointsWindowQtConfig // BreakpointsWindowQtConfig
//========================================================================= //=========================================================================
void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget) void BreakpointsWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup");
if (typeGroup->checkedAction()->text() == "Breakpoints") if (typeGroup->checkedAction()->text() == "Breakpoints")
@ -116,9 +116,9 @@ void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget)
void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget) void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
BreakpointsWindow* window = dynamic_cast<BreakpointsWindow*>(widget); BreakpointsWindow *window = dynamic_cast<BreakpointsWindow *>(widget);
QActionGroup* typeGroup = window->findChild<QActionGroup*>("typegroup"); QActionGroup *typeGroup = window->findChild<QActionGroup *>("typegroup");
typeGroup->actions()[m_bwType]->trigger(); typeGroup->actions()[m_bwType]->trigger();
} }

View File

@ -1,7 +1,7 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_BREAK_POINTS_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
#define __DEBUG_QT_BREAK_POINTS_WINDOW_H__ #define MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
#include "debuggerview.h" #include "debuggerview.h"
#include "windowqt.h" #include "windowqt.h"
@ -15,17 +15,15 @@ class BreakpointsWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
BreakpointsWindow(running_machine* machine, QWidget* parent=nullptr); BreakpointsWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~BreakpointsWindow(); virtual ~BreakpointsWindow();
private slots: private slots:
void typeChanged(QAction* changedTo); void typeChanged(QAction *changedTo);
private: private:
// Widgets // Widgets
DebuggerView* m_breakpointsView; DebuggerView *m_breakpointsView;
}; };
@ -46,11 +44,10 @@ public:
// Settings // Settings
int m_bwType; int m_bwType;
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif // MAME_DEBUGGER_QT_BREAKPOINTSWINDOW_H
#endif

View File

@ -1,12 +1,6 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #include "emu.h"
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include "dasmwindow.h" #include "dasmwindow.h"
#include "debug/debugcon.h" #include "debug/debugcon.h"
@ -14,13 +8,19 @@
#include "debug/dvdisasm.h" #include "debug/dvdisasm.h"
#include "debug/points.h" #include "debug/points.h"
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QAction>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
DasmWindow::DasmWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr) WindowQt(machine, nullptr)
{ {
setWindowTitle("Debug: Disassembly View"); setWindowTitle("Debug: Disassembly View");
if (parent != nullptr) if (parent)
{ {
QPoint parentPos = parent->pos(); QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@ -29,10 +29,10 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
// //
// The main frame and its input and log widgets // The main frame and its input and log widgets
// //
QFrame* mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
// The top frame & groupbox that contains the input widgets // The top frame & groupbox that contains the input widgets
QFrame* topSubFrame = new QFrame(mainWindowFrame); QFrame *topSubFrame = new QFrame(mainWindowFrame);
// The input edit // The input edit
m_inputEdit = new QLineEdit(topSubFrame); m_inputEdit = new QLineEdit(topSubFrame);
@ -42,28 +42,27 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
m_cpuComboBox = new QComboBox(topSubFrame); m_cpuComboBox = new QComboBox(topSubFrame);
m_cpuComboBox->setObjectName("cpu"); m_cpuComboBox->setObjectName("cpu");
m_cpuComboBox->setMinimumWidth(300); m_cpuComboBox->setMinimumWidth(300);
connect(m_cpuComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DasmWindow::cpuChanged); connect(m_cpuComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DasmWindow::cpuChanged);
// The main disasm window // The main disasm window
m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this); m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this);
connect(m_dasmView, &DebuggerView::updated, this, &DasmWindow::dasmViewUpdated); connect(m_dasmView, &DebuggerView::updated, this, &DasmWindow::dasmViewUpdated);
// Force a recompute of the disassembly region // Force a recompute of the disassembly region
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); downcast<debug_view_disasm *>(m_dasmView->view())->set_expression("curpc");
// Populate the combo box & set the proper cpu // Populate the combo box & set the proper CPU
populateComboBox(); populateComboBox();
setToCurrentCpu(); setToCurrentCpu();
// Layout // Layout
QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); QHBoxLayout *subLayout = new QHBoxLayout(topSubFrame);
subLayout->addWidget(m_inputEdit); subLayout->addWidget(m_inputEdit);
subLayout->addWidget(m_cpuComboBox); subLayout->addWidget(m_cpuComboBox);
subLayout->setSpacing(3); subLayout->setSpacing(3);
subLayout->setContentsMargins(2,2,2,2); subLayout->setContentsMargins(2,2,2,2);
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setSpacing(3); vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2); vLayout->setContentsMargins(2,2,2,2);
vLayout->addWidget(topSubFrame); vLayout->addWidget(topSubFrame);
@ -86,11 +85,11 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
connect(m_runToCursorAct, &QAction::triggered, this, &DasmWindow::runToCursor); connect(m_runToCursorAct, &QAction::triggered, this, &DasmWindow::runToCursor);
// Right bar options // Right bar options
QActionGroup* rightBarGroup = new QActionGroup(this); QActionGroup *rightBarGroup = new QActionGroup(this);
rightBarGroup->setObjectName("rightbargroup"); rightBarGroup->setObjectName("rightbargroup");
QAction* rightActRaw = new QAction("Raw Opcodes", this); QAction *rightActRaw = new QAction("Raw Opcodes", this);
QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
QAction* rightActComments = new QAction("Comments", this); QAction *rightActComments = new QAction("Comments", this);
rightActRaw->setCheckable(true); rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true); rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true); rightActComments->setCheckable(true);
@ -104,7 +103,7 @@ DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
connect(rightBarGroup, &QActionGroup::triggered, this, &DasmWindow::rightBarChanged); connect(rightBarGroup, &QActionGroup::triggered, this, &DasmWindow::rightBarChanged);
// Assemble the options menu // Assemble the options menu
QMenu* optionsMenu = menuBar()->addMenu("&Options"); QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addAction(m_breakpointToggleAct); optionsMenu->addAction(m_breakpointToggleAct);
optionsMenu->addAction(m_breakpointEnableAct); optionsMenu->addAction(m_breakpointEnableAct);
optionsMenu->addAction(m_runToCursorAct); optionsMenu->addAction(m_runToCursorAct);
@ -128,7 +127,7 @@ void DasmWindow::cpuChanged(int index)
void DasmWindow::expressionSubmitted() void DasmWindow::expressionSubmitted()
{ {
const QString expression = m_inputEdit->text(); const QString expression = m_inputEdit->text();
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data()); downcast<debug_view_disasm *>(m_dasmView->view())->set_expression(expression.toLocal8Bit().data());
m_dasmView->viewport()->update(); m_dasmView->viewport()->update();
} }
@ -145,19 +144,19 @@ void DasmWindow::toggleBreakpointAtCursor(bool changedTo)
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address); const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
// If none exists, add a new one // If none exists, add a new one
if (bp == nullptr) if (!bp)
{ {
int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr); int32_t bpindex = cpuinfo->breakpoint_set(address, nullptr, nullptr);
m_machine->debugger().console().printf("Breakpoint %X set\n", bpindex); m_machine.debugger().console().printf("Breakpoint %X set\n", bpindex);
} }
else else
{ {
int32_t bpindex = bp->index(); int32_t bpindex = bp->index();
cpuinfo->breakpoint_clear(bpindex); cpuinfo->breakpoint_clear(bpindex);
m_machine->debugger().console().printf("Breakpoint %X cleared\n", bpindex); m_machine.debugger().console().printf("Breakpoint %X cleared\n", bpindex);
} }
m_machine->debug_view().update_all(); m_machine.debug_view().update_all();
m_machine->debugger().refresh_display(); m_machine.debugger().refresh_display();
} }
refreshAll(); refreshAll();
@ -175,12 +174,12 @@ void DasmWindow::enableBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address // Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address); const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr) if (bp)
{ {
cpuinfo->breakpoint_enable(bp->index(), !bp->enabled()); cpuinfo->breakpoint_enable(bp->index(), !bp->enabled());
m_machine->debugger().console().printf("Breakpoint %X %s\n", (uint32_t)bp->index(), bp->enabled() ? "enabled" : "disabled"); m_machine.debugger().console().printf("Breakpoint %X %s\n", (uint32_t)bp->index(), bp->enabled() ? "enabled" : "disabled");
m_machine->debug_view().update_all(); m_machine.debug_view().update_all();
m_machine->debugger().refresh_display(); m_machine.debugger().refresh_display();
} }
} }
@ -192,7 +191,7 @@ void DasmWindow::runToCursor(bool changedTo)
{ {
if (m_dasmView->view()->cursor_visible()) if (m_dasmView->view()->cursor_visible())
{ {
offs_t const address = downcast<debug_view_disasm*>(m_dasmView->view())->selected_address(); offs_t const address = downcast<debug_view_disasm *>(m_dasmView->view())->selected_address();
m_dasmView->view()->source()->device()->debug()->go(address); m_dasmView->view()->source()->device()->debug()->go(address);
} }
} }
@ -231,7 +230,7 @@ void DasmWindow::dasmViewUpdated()
// Find an existing breakpoint at this address // Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address); const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr) if (bp)
{ {
haveBreakpoint = true; haveBreakpoint = true;
breakpointEnabled = bp->enabled(); breakpointEnabled = bp->enabled();
@ -248,7 +247,7 @@ void DasmWindow::dasmViewUpdated()
void DasmWindow::populateComboBox() void DasmWindow::populateComboBox()
{ {
if (m_dasmView == nullptr) if (!m_dasmView)
return; return;
m_cpuComboBox->clear(); m_cpuComboBox->clear();
@ -261,7 +260,7 @@ void DasmWindow::populateComboBox()
void DasmWindow::setToCurrentCpu() void DasmWindow::setToCurrentCpu()
{ {
device_t* curCpu = m_machine->debugger().console().get_visible_cpu(); device_t *curCpu = m_machine.debugger().console().get_visible_cpu();
if (curCpu) if (curCpu)
{ {
const debug_view_source *source = m_dasmView->view()->source_for_device(curCpu); const debug_view_source *source = m_dasmView->view()->source_for_device(curCpu);
@ -277,14 +276,14 @@ void DasmWindow::setToCurrentCpu()
//========================================================================= //=========================================================================
// DasmWindowQtConfig // DasmWindowQtConfig
//========================================================================= //=========================================================================
void DasmWindowQtConfig::buildFromQWidget(QWidget* widget) void DasmWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
DasmWindow* window = dynamic_cast<DasmWindow*>(widget); DasmWindow *window = dynamic_cast<DasmWindow *>(widget);
QComboBox* cpu = window->findChild<QComboBox*>("cpu"); QComboBox *cpu = window->findChild<QComboBox *>("cpu");
m_cpu = cpu->currentIndex(); m_cpu = cpu->currentIndex();
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
m_rightBar = 0; m_rightBar = 0;
else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes")
@ -293,14 +292,14 @@ void DasmWindowQtConfig::buildFromQWidget(QWidget* widget)
m_rightBar = 2; m_rightBar = 2;
} }
void DasmWindowQtConfig::applyToQWidget(QWidget* widget) void DasmWindowQtConfig::applyToQWidget(QWidget *widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
DasmWindow* window = dynamic_cast<DasmWindow*>(widget); DasmWindow *window = dynamic_cast<DasmWindow *>(widget);
QComboBox* cpu = window->findChild<QComboBox*>("cpu"); QComboBox *cpu = window->findChild<QComboBox *>("cpu");
cpu->setCurrentIndex(m_cpu); cpu->setCurrentIndex(m_cpu);
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); QActionGroup *rightBarGroup = window->findChild<QActionGroup *>("rightbargroup");
rightBarGroup->actions()[m_rightBar]->trigger(); rightBarGroup->actions()[m_rightBar]->trigger();
} }

View File

@ -1,14 +1,14 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_DASM_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_DASMWINDOW_H
#define __DEBUG_QT_DASM_WINDOW_H__ #define MAME_DEBUGGER_QT_DASMWINDOW_H
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QComboBox>
#include "debuggerview.h" #include "debuggerview.h"
#include "windowqt.h" #include "windowqt.h"
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLineEdit>
//============================================================ //============================================================
// The Disassembly Window. // The Disassembly Window.
@ -18,10 +18,9 @@ class DasmWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
DasmWindow(running_machine* machine, QWidget* parent=nullptr); DasmWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~DasmWindow(); virtual ~DasmWindow();
private slots: private slots:
void cpuChanged(int index); void cpuChanged(int index);
void expressionSubmitted(); void expressionSubmitted();
@ -29,25 +28,23 @@ private slots:
void toggleBreakpointAtCursor(bool changedTo); void toggleBreakpointAtCursor(bool changedTo);
void enableBreakpointAtCursor(bool changedTo); void enableBreakpointAtCursor(bool changedTo);
void runToCursor(bool changedTo); void runToCursor(bool changedTo);
void rightBarChanged(QAction* changedTo); void rightBarChanged(QAction *changedTo);
void dasmViewUpdated(); void dasmViewUpdated();
private: private:
void populateComboBox(); void populateComboBox();
void setToCurrentCpu(); void setToCurrentCpu();
// Widgets // Widgets
QLineEdit* m_inputEdit; QLineEdit *m_inputEdit;
QComboBox* m_cpuComboBox; QComboBox *m_cpuComboBox;
DebuggerView* m_dasmView; DebuggerView *m_dasmView;
// Menu items // Menu items
QAction* m_breakpointToggleAct; QAction *m_breakpointToggleAct;
QAction* m_breakpointEnableAct; QAction *m_breakpointEnableAct;
QAction* m_runToCursorAct; QAction *m_runToCursorAct;
}; };
@ -70,11 +67,11 @@ public:
int m_cpu; int m_cpu;
int m_rightBar; int m_rightBar;
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_DASMWINDOW_H

View File

@ -1,54 +1,56 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #include "emu.h"
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QApplication>
#include <QtGui/QPainter>
#include <QtGui/QKeyEvent>
#include "debuggerview.h" #include "debuggerview.h"
#include "modules/lib/osdobj_common.h" #include "modules/lib/osdobj_common.h"
#include <QtCore/QMimeData>
#include <QtGui/QClipboard>
#include <QtGui/QKeyEvent>
#include <QtGui/QPainter>
#include <QtWidgets/QApplication>
#include <QtWidgets/QScrollBar>
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width #define horizontalAdvance width
#endif #endif
DebuggerView::DebuggerView(const debug_view_type& type, DebuggerView::DebuggerView(
running_machine* machine, debug_view_type type,
QWidget* parent) : running_machine &machine,
QWidget *parent) :
QAbstractScrollArea(parent), QAbstractScrollArea(parent),
m_preferBottom(false), m_machine(machine),
m_view(nullptr), m_view(nullptr),
m_machine(machine) m_preferBottom(false)
{ {
// I like setting the font per-view since it doesn't override the menuing fonts. // I like setting the font per-view since it doesn't override the menu fonts.
const char *const selectedFont(downcast<osd_options &>(m_machine->options()).debugger_font()); const char *const selectedFont(downcast<osd_options &>(m_machine.options()).debugger_font());
const float selectedFontSize(downcast<osd_options &>(m_machine->options()).debugger_font_size()); const float selectedFontSize(downcast<osd_options &>(m_machine.options()).debugger_font_size());
QFont viewFontRequest((!*selectedFont || !strcmp(selectedFont, OSDOPTVAL_AUTO)) ? "Courier New" : selectedFont); QFont viewFontRequest((!*selectedFont || !strcmp(selectedFont, OSDOPTVAL_AUTO)) ? "Courier New" : selectedFont);
viewFontRequest.setFixedPitch(true); viewFontRequest.setFixedPitch(true);
viewFontRequest.setStyleHint(QFont::TypeWriter); viewFontRequest.setStyleHint(QFont::TypeWriter);
viewFontRequest.setPointSize((selectedFontSize <= 0) ? 11 : selectedFontSize); viewFontRequest.setPointSize((selectedFontSize <= 0) ? 11 : selectedFontSize);
setFont(viewFontRequest); setFont(viewFontRequest);
m_view = m_machine->debug_view().alloc_view(type, m_view = m_machine.debug_view().alloc_view(
DebuggerView::debuggerViewUpdate, type,
this); DebuggerView::debuggerViewUpdate,
this);
connect(verticalScrollBar(), &QScrollBar::valueChanged, connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &DebuggerView::verticalScrollSlot);
this, &DebuggerView::verticalScrollSlot); connect(horizontalScrollBar(), &QScrollBar::valueChanged, this, &DebuggerView::horizontalScrollSlot);
connect(horizontalScrollBar(), &QScrollBar::valueChanged,
this, &DebuggerView::horizontalScrollSlot);
} }
DebuggerView::~DebuggerView() DebuggerView::~DebuggerView()
{ {
if (m_machine && m_view) if (m_view)
m_machine->debug_view().free_view(*m_view); m_machine.debug_view().free_view(*m_view);
} }
void DebuggerView::paintEvent(QPaintEvent* event) void DebuggerView::paintEvent(QPaintEvent *event)
{ {
// Tell the MAME debug view how much real estate is available // Tell the MAME debug view how much real estate is available
QFontMetrics actualFont = fontMetrics(); QFontMetrics actualFont = fontMetrics();
@ -67,17 +69,10 @@ void DebuggerView::paintEvent(QPaintEvent* event)
const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust;
bool atEnd = false; const bool atEnd = verticalScrollBar()->value() == verticalScrollBar()->maximum();
if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
{
atEnd = true;
}
verticalScrollBar()->setRange(0, verticalScrollSize); verticalScrollBar()->setRange(0, verticalScrollSize);
if (m_preferBottom && atEnd) if (m_preferBottom && atEnd)
{
verticalScrollBar()->setValue(verticalScrollSize); verticalScrollBar()->setValue(verticalScrollSize);
}
// Draw the viewport widget // Draw the viewport widget
QPainter painter(viewport()); QPainter painter(viewport());
@ -104,44 +99,37 @@ void DebuggerView::paintEvent(QPaintEvent* event)
QColor fgColor(0,0,0); QColor fgColor(0,0,0);
QColor bgColor(255,255,255); QColor bgColor(255,255,255);
if(textAttr & DCA_VISITED) if (textAttr & DCA_VISITED)
{
bgColor.setRgb(0xc6, 0xe2, 0xff); bgColor.setRgb(0xc6, 0xe2, 0xff);
}
if(textAttr & DCA_ANCILLARY) if (textAttr & DCA_ANCILLARY)
{
bgColor.setRgb(0xe0, 0xe0, 0xe0); bgColor.setRgb(0xe0, 0xe0, 0xe0);
}
if(textAttr & DCA_SELECTED) if (textAttr & DCA_SELECTED)
{
bgColor.setRgb(0xff, 0x80, 0x80); bgColor.setRgb(0xff, 0x80, 0x80);
}
if(textAttr & DCA_CURRENT) if (textAttr & DCA_CURRENT)
{
bgColor.setRgb(0xff, 0xff, 0x00); bgColor.setRgb(0xff, 0xff, 0x00);
}
if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT))
{
bgColor.setRgb(0xff,0xc0,0x80); bgColor.setRgb(0xff,0xc0,0x80);
}
if(textAttr & DCA_CHANGED) if (textAttr & DCA_CHANGED)
{
fgColor.setRgb(0xff, 0x00, 0x00); fgColor.setRgb(0xff, 0x00, 0x00);
}
if(textAttr & DCA_INVALID) if (textAttr & DCA_INVALID)
{
fgColor.setRgb(0x00, 0x00, 0xff); fgColor.setRgb(0x00, 0x00, 0xff);
}
if(textAttr & DCA_DISABLED) if (textAttr & DCA_DISABLED)
{ {
fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, fgColor.setRgb(
(fgColor.green() + bgColor.green()) >> 1, (fgColor.red() + bgColor.red()) >> 1,
(fgColor.blue() + bgColor.blue()) >> 1); (fgColor.green() + bgColor.green()) >> 1,
(fgColor.blue() + bgColor.blue()) >> 1);
} }
if(textAttr & DCA_COMMENT) if(textAttr & DCA_COMMENT)
{
fgColor.setRgb(0x00, 0x80, 0x00); fgColor.setRgb(0x00, 0x80, 0x00);
}
bgBrush.setColor(bgColor); bgBrush.setColor(bgColor);
painter.setBackground(bgBrush); painter.setBackground(bgBrush);
@ -176,52 +164,54 @@ void DebuggerView::keyPressEvent(QKeyEvent* event)
int keyPress = -1; int keyPress = -1;
switch (event->key()) switch (event->key())
{ {
case Qt::Key_Up: case Qt::Key_Up:
keyPress = DCH_UP; keyPress = DCH_UP;
break; break;
case Qt::Key_Down: case Qt::Key_Down:
keyPress = DCH_DOWN; keyPress = DCH_DOWN;
break; break;
case Qt::Key_Left: case Qt::Key_Left:
keyPress = DCH_LEFT; keyPress = DCH_LEFT;
if (ctrlDown) keyPress = DCH_CTRLLEFT; if (ctrlDown)
break; keyPress = DCH_CTRLLEFT;
case Qt::Key_Right: break;
keyPress = DCH_RIGHT; case Qt::Key_Right:
if (ctrlDown) keyPress = DCH_CTRLRIGHT; keyPress = DCH_RIGHT;
break; if (ctrlDown)
case Qt::Key_PageUp: keyPress = DCH_CTRLRIGHT;
keyPress = DCH_PUP; break;
break; case Qt::Key_PageUp:
case Qt::Key_PageDown: keyPress = DCH_PUP;
keyPress = DCH_PDOWN; break;
break; case Qt::Key_PageDown:
case Qt::Key_Home: keyPress = DCH_PDOWN;
keyPress = DCH_HOME; break;
if (ctrlDown) keyPress = DCH_CTRLHOME; case Qt::Key_Home:
break; keyPress = DCH_HOME;
case Qt::Key_End: if (ctrlDown) keyPress = DCH_CTRLHOME;
keyPress = DCH_END; break;
if (ctrlDown) keyPress = DCH_CTRLEND; case Qt::Key_End:
break; keyPress = DCH_END;
case Qt::Key_0: keyPress = '0'; break; if (ctrlDown) keyPress = DCH_CTRLEND;
case Qt::Key_1: keyPress = '1'; break; break;
case Qt::Key_2: keyPress = '2'; break; case Qt::Key_0: keyPress = '0'; break;
case Qt::Key_3: keyPress = '3'; break; case Qt::Key_1: keyPress = '1'; break;
case Qt::Key_4: keyPress = '4'; break; case Qt::Key_2: keyPress = '2'; break;
case Qt::Key_5: keyPress = '5'; break; case Qt::Key_3: keyPress = '3'; break;
case Qt::Key_6: keyPress = '6'; break; case Qt::Key_4: keyPress = '4'; break;
case Qt::Key_7: keyPress = '7'; break; case Qt::Key_5: keyPress = '5'; break;
case Qt::Key_8: keyPress = '8'; break; case Qt::Key_6: keyPress = '6'; break;
case Qt::Key_9: keyPress = '9'; break; case Qt::Key_7: keyPress = '7'; break;
case Qt::Key_A: keyPress = 'a'; break; case Qt::Key_8: keyPress = '8'; break;
case Qt::Key_B: keyPress = 'b'; break; case Qt::Key_9: keyPress = '9'; break;
case Qt::Key_C: keyPress = 'c'; break; case Qt::Key_A: keyPress = 'a'; break;
case Qt::Key_D: keyPress = 'd'; break; case Qt::Key_B: keyPress = 'b'; break;
case Qt::Key_E: keyPress = 'e'; break; case Qt::Key_C: keyPress = 'c'; break;
case Qt::Key_F: keyPress = 'f'; break; case Qt::Key_D: keyPress = 'd'; break;
default: case Qt::Key_E: keyPress = 'e'; break;
return QWidget::keyPressEvent(event); case Qt::Key_F: keyPress = 'f'; break;
default:
return QWidget::keyPressEvent(event);
} }
m_view->set_cursor_visible(true); m_view->set_cursor_visible(true);
@ -235,26 +225,59 @@ void DebuggerView::keyPressEvent(QKeyEvent* event)
} }
void DebuggerView::mousePressEvent(QMouseEvent* event) void DebuggerView::mousePressEvent(QMouseEvent *event)
{ {
if (m_view == nullptr) if (!m_view)
return; return;
QFontMetrics actualFont = fontMetrics();
const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
const int fontHeight = std::max(1, actualFont.lineSpacing());
debug_view_xy topLeft = m_view->visible_position();
debug_view_xy clickViewPosition;
clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
{ {
QFontMetrics actualFont = fontMetrics();
const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.;
const int fontHeight = std::max(1, actualFont.lineSpacing());
debug_view_xy topLeft = m_view->visible_position();
debug_view_xy clickViewPosition;
clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
m_view->process_click(DCK_LEFT_CLICK, clickViewPosition); m_view->process_click(DCK_LEFT_CLICK, clickViewPosition);
viewport()->update();
update();
} }
else if (event->button() == Qt::MiddleButton)
{
m_view->process_click(DCK_MIDDLE_CLICK, clickViewPosition);
}
else if (event->button() == Qt::RightButton)
{
if (m_view->cursor_supported())
{
m_view->set_cursor_position(clickViewPosition);
m_view->set_cursor_visible(true);
}
}
viewport()->update();
update();
}
void DebuggerView::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *const menu = new QMenu(this);
addItemsToContextMenu(menu);
menu->popup(event->globalPos());
}
void DebuggerView::addItemsToContextMenu(QMenu *menu)
{
QAction *const copyAct = new QAction("Copy Visible", menu);
QAction *const pasteAct = new QAction("Paste", menu);
pasteAct->setEnabled(QApplication::clipboard()->mimeData()->hasText());
connect(copyAct, &QAction::triggered, this, &DebuggerView::copyVisibleSlot);
connect(pasteAct, &QAction::triggered, this, &DebuggerView::pasteSlot);
menu->addAction(copyAct);
menu->addAction(pasteAct);
} }
@ -270,10 +293,46 @@ void DebuggerView::horizontalScrollSlot(int value)
} }
void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate) void DebuggerView::copyVisibleSlot()
{ {
// Get a handle to the DebuggerView being updated & redraw // get visible text
DebuggerView* dView = (DebuggerView*)osdPrivate; debug_view_xy const visarea = m_view->visible_size();
debug_view_char const *viewdata = m_view->viewdata();
if (!viewdata)
return;
// turn into a plain string, trimming trailing whitespace
std::string text;
for (uint32_t row = 0; row < visarea.y; row++, viewdata += visarea.x)
{
std::string::size_type const start = text.length();
for (uint32_t col = 0; col < visarea.x; ++col)
text += wchar_t(viewdata[col].byte);
std::string::size_type const nonblank = text.find_last_not_of("\t\n\v\r ");
if ((nonblank != std::string::npos) && (nonblank >= start))
text.resize(nonblank + 1);
text += "\n";
}
// copy to the clipboard
QApplication::clipboard()->setText(text.c_str());
}
void DebuggerView::pasteSlot()
{
for (QChar ch : QApplication::clipboard()->text())
{
if ((32 <= ch.unicode()) && (127 >= ch.unicode()))
m_view->process_char(ch.unicode());
}
}
void DebuggerView::debuggerViewUpdate(debug_view &debugView, void *osdPrivate)
{
// Get a handle to the DebuggerView being updated and redraw
DebuggerView *dView = reinterpret_cast<DebuggerView *>(osdPrivate);
dView->verticalScrollBar()->setValue(dView->view()->visible_position().y); dView->verticalScrollBar()->setValue(dView->view()->visible_position().y);
dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x); dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x);
dView->viewport()->update(); dView->viewport()->update();

View File

@ -1,50 +1,52 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_DEBUGGER_VIEW_H__ #ifndef MAME_DEBUGGER_QT_DEBUGGERVIEW_H
#define __DEBUG_QT_DEBUGGER_VIEW_H__ #define MAME_DEBUGGER_QT_DEBUGGERVIEW_H
#include <QtWidgets/QAbstractScrollArea>
#include "debug/debugvw.h" #include "debug/debugvw.h"
#include <QtWidgets/QAbstractScrollArea>
#include <QtWidgets/QMenu>
class DebuggerView : public QAbstractScrollArea class DebuggerView : public QAbstractScrollArea
{ {
Q_OBJECT Q_OBJECT
public: public:
DebuggerView(const debug_view_type& type, DebuggerView(debug_view_type type, running_machine &machine, QWidget *parent = nullptr);
running_machine* machine,
QWidget* parent=nullptr);
virtual ~DebuggerView(); virtual ~DebuggerView();
void paintEvent(QPaintEvent* event); void paintEvent(QPaintEvent *event);
// Setters and accessors // Setters and accessors
void setPreferBottom(bool pb) { m_preferBottom = pb; } void setPreferBottom(bool pb) { m_preferBottom = pb; }
debug_view* view() { return m_view; } debug_view *view() { return m_view; }
signals: signals:
void updated(); void updated();
protected: protected:
void keyPressEvent(QKeyEvent* event); void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
virtual void addItemsToContextMenu(QMenu *menu);
private slots: private slots:
void verticalScrollSlot(int value); void verticalScrollSlot(int value);
void horizontalScrollSlot(int value); void horizontalScrollSlot(int value);
void copyVisibleSlot();
void pasteSlot();
private: private:
// Callback to allow MAME to refresh the view // Callback to allow MAME to refresh the view
static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate); static void debuggerViewUpdate(debug_view &debugView, void *osdPrivate);
running_machine &m_machine;
debug_view *m_view;
bool m_preferBottom; bool m_preferBottom;
debug_view* m_view;
running_machine* m_machine;
}; };
#endif // MAME_DEBUGGER_QT_DEBUGGERVIEW_H
#endif

View File

@ -8,18 +8,17 @@
#include "deviceinformationwindow.h" #include "deviceinformationwindow.h"
DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : DeviceInformationWindow::DeviceInformationWindow(running_machine &machine, device_t *device, QWidget *parent) :
WindowQt(machine, nullptr) WindowQt(machine, nullptr),
m_device(device)
{ {
m_device = device; if (parent)
if (parent != nullptr)
{ {
QPoint parentPos = parent->pos(); QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400);
} }
if(m_device) if (m_device)
fill_device_information(); fill_device_information();
} }
@ -30,10 +29,7 @@ DeviceInformationWindow::~DeviceInformationWindow()
void DeviceInformationWindow::fill_device_information() void DeviceInformationWindow::fill_device_information()
{ {
char title[4069]; setWindowTitle(util::string_format("Debug: Device %s", m_device->tag()).c_str());
sprintf(title, "Debug: Device %s", m_device->tag());
setWindowTitle(title);
QFrame *mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
@ -53,9 +49,11 @@ void DeviceInformationWindow::fill_device_information()
int cpos = 3; int cpos = 3;
device_interface *intf = m_device->interfaces().first(); device_interface *intf = m_device->interfaces().first();
if(intf) { if (intf)
{
gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0); gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0);
while(intf) { while(intf)
{
gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1); gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1);
cpos++; cpos++;
intf = intf->interface_next(); intf = intf->interface_next();
@ -65,16 +63,19 @@ void DeviceInformationWindow::fill_device_information()
vLayout->addWidget(primaryFrame); vLayout->addWidget(primaryFrame);
device_memory_interface *d_memory; device_memory_interface *d_memory;
if(m_device->interface(d_memory)) { if (m_device->interface(d_memory))
{
QFrame *f = new QFrame(mainWindowFrame); QFrame *f = new QFrame(mainWindowFrame);
f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QVBoxLayout *vb = new QVBoxLayout(f); QVBoxLayout *vb = new QVBoxLayout(f);
bool first = true; bool first = true;
for(int i=0; i<d_memory->max_space_count(); i++) for (int i=0; i<d_memory->max_space_count(); i++)
if(d_memory->has_space(i)) { if (d_memory->has_space(i))
{
QFrame *ff = new QFrame(f); QFrame *ff = new QFrame(f);
QHBoxLayout *hb = new QHBoxLayout(ff); QHBoxLayout *hb = new QHBoxLayout(ff);
if(first) { if (first)
{
hb->addWidget(new QLabel("Memory maps")); hb->addWidget(new QLabel("Memory maps"));
first = false; first = false;
} }
@ -92,9 +93,9 @@ void DeviceInformationWindow::fill_device_information()
void DeviceInformationWindow::set_device(const char *tag) void DeviceInformationWindow::set_device(const char *tag)
{ {
m_device = m_machine->root_device().subdevice(tag); m_device = m_machine.root_device().subdevice(tag);
if(!m_device) if (!m_device)
m_device = &m_machine->root_device(); m_device = &m_machine.root_device();
fill_device_information(); fill_device_information();
} }
@ -107,18 +108,18 @@ const char *DeviceInformationWindow::device_tag() const
//========================================================================= //=========================================================================
// DeviceInformationWindowQtConfig // DeviceInformationWindowQtConfig
//========================================================================= //=========================================================================
void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget) void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); DeviceInformationWindow *window = dynamic_cast<DeviceInformationWindow *>(widget);
m_device_tag = window->device_tag(); m_device_tag = window->device_tag();
} }
void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget) void DeviceInformationWindowQtConfig::applyToQWidget(QWidget *widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
DeviceInformationWindow* window = dynamic_cast<DeviceInformationWindow*>(widget); DeviceInformationWindow *window = dynamic_cast<DeviceInformationWindow *>(widget);
window->set_device(m_device_tag.c_str()); window->set_device(m_device_tag.c_str());
} }

View File

@ -1,7 +1,7 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
#define __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ #define MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H
#include "windowqt.h" #include "windowqt.h"
@ -13,7 +13,7 @@ class DeviceInformationWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
DeviceInformationWindow(running_machine* machine, device_t* device = nullptr, QWidget* parent=nullptr); DeviceInformationWindow(running_machine &machine, device_t *device = nullptr, QWidget* parent=nullptr);
virtual ~DeviceInformationWindow(); virtual ~DeviceInformationWindow();
void set_device(const char *tag); void set_device(const char *tag);
@ -43,11 +43,11 @@ public:
~DeviceInformationWindowQtConfig() {} ~DeviceInformationWindowQtConfig() {}
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_DEVICEINFORMATIONWINDOW_H

View File

@ -4,9 +4,9 @@
#include "deviceswindow.h" #include "deviceswindow.h"
#include "deviceinformationwindow.h" #include "deviceinformationwindow.h"
DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) DevicesWindowModel::DevicesWindowModel(running_machine &machine, QObject *parent) :
m_machine(machine)
{ {
m_machine = machine;
} }
DevicesWindowModel::~DevicesWindowModel() DevicesWindowModel::~DevicesWindowModel()
@ -15,12 +15,13 @@ DevicesWindowModel::~DevicesWindowModel()
QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const
{ {
if(!index.isValid() || role != Qt::DisplayRole) if (!index.isValid() || role != Qt::DisplayRole)
return QVariant(); return QVariant();
device_t *dev = static_cast<device_t *>(index.internalPointer()); device_t *dev = static_cast<device_t *>(index.internalPointer());
switch(index.column()) { switch (index.column())
case 0: return dev == &m_machine->root_device() ? QString("<root>") : QString(dev->basetag()); {
case 0: return (dev == &m_machine.root_device()) ? QString("<root>") : QString(dev->basetag());
case 1: return QString(dev->name()); case 1: return QString(dev->name());
} }
@ -29,7 +30,7 @@ QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const
Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return 0; return 0;
return QAbstractItemModel::flags(index); return QAbstractItemModel::flags(index);
@ -37,30 +38,33 @@ Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const
QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const
{ {
if(role != Qt::DisplayRole || section < 0 || section >= 2) if (role != Qt::DisplayRole || section < 0 || section >= 2)
return QVariant(); return QVariant();
return QString(section ? "Name" : "Tag"); return QString(section ? "Name" : "Tag");
} }
QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const
{ {
if(!hasIndex(row, column, parent)) if (!hasIndex(row, column, parent))
return QModelIndex(); return QModelIndex();
device_t *target = nullptr; device_t *target = nullptr;
if(!parent.isValid()) { if (!parent.isValid())
if(row == 0) {
target = &m_machine->root_device(); if (row == 0)
target = &m_machine.root_device();
} else { }
else
{
device_t *dparent = static_cast<device_t *>(parent.internalPointer()); device_t *dparent = static_cast<device_t *>(parent.internalPointer());
int count = row; int count = row;
for(target = dparent->subdevices().first(); count && target; target = target->next()) for(target = dparent->subdevices().first(); count && target; target = target->next())
count--; count--;
} }
if(target) if (target)
return createIndex(row, column, target); return createIndex(row, column, target);
return QModelIndex(); return QModelIndex();
@ -68,19 +72,20 @@ QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &pa
QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const
{ {
if(!index.isValid()) if (!index.isValid())
return QModelIndex(); return QModelIndex();
device_t *dchild = static_cast<device_t *>(index.internalPointer()); device_t *dchild = static_cast<device_t *>(index.internalPointer());
device_t *dparent = dchild->owner(); device_t *dparent = dchild->owner();
if(!dparent) if (!dparent)
return QModelIndex(); return QModelIndex();
device_t *dpp = dparent->owner(); device_t *dpp = dparent->owner();
int row = 0; int row = 0;
if(dpp) { if (dpp)
for(device_t *child = dpp->subdevices().first(); child && child != dparent; child = child->next()) {
for (device_t *child = dpp->subdevices().first(); child && child != dparent; child = child->next())
row++; row++;
} }
return createIndex(row, 0, dparent); return createIndex(row, 0, dparent);
@ -88,7 +93,7 @@ QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const
int DevicesWindowModel::rowCount(const QModelIndex &parent) const int DevicesWindowModel::rowCount(const QModelIndex &parent) const
{ {
if(!parent.isValid()) if (!parent.isValid())
return 1; return 1;
device_t *dparent = static_cast<device_t *>(parent.internalPointer()); device_t *dparent = static_cast<device_t *>(parent.internalPointer());
@ -102,7 +107,7 @@ int DevicesWindowModel::columnCount(const QModelIndex &parent) const
DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : DevicesWindow::DevicesWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr), WindowQt(machine, nullptr),
m_devices_model(machine) m_devices_model(machine)
{ {
@ -151,17 +156,17 @@ void DevicesWindow::activated(const QModelIndex &index)
//========================================================================= //=========================================================================
// DevicesWindowQtConfig // DevicesWindowQtConfig
//========================================================================= //=========================================================================
void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) void DevicesWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
// DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); // DevicesWindow *window = dynamic_cast<DevicesWindow *>(widget);
} }
void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) void DevicesWindowQtConfig::applyToQWidget(QWidget *widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
// DevicesWindow* window = dynamic_cast<DevicesWindow*>(widget); // DevicesWindow *window = dynamic_cast<DevicesWindow *>(widget);
} }

View File

@ -1,12 +1,12 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_DEVICES_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_DEVICESWINDOW_H
#define __DEBUG_QT_DEVICES_WINDOW_H__ #define MAME_DEBUGGER_QT_DEVICESWINDOW_H
#include <QtWidgets/QTreeView>
#include "windowqt.h" #include "windowqt.h"
#include <QtWidgets/QTreeView>
//============================================================ //============================================================
// The model for the treeview // The model for the treeview
@ -17,21 +17,19 @@ class DevicesWindowModel : public QAbstractItemModel
Q_OBJECT Q_OBJECT
public: public:
explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0); explicit DevicesWindowModel(running_machine &machine, QObject *parent = nullptr);
~DevicesWindowModel(); ~DevicesWindowModel();
QVariant data(const QModelIndex &index, int role) const; QVariant data(const QModelIndex &index, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
int role = Qt::DisplayRole) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const; QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;
private: private:
running_machine *m_machine; running_machine &m_machine;
}; };
//============================================================ //============================================================
@ -42,7 +40,7 @@ class DevicesWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
DevicesWindow(running_machine* machine, QWidget* parent=nullptr); DevicesWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~DevicesWindow(); virtual ~DevicesWindow();
public slots: public slots:
@ -71,11 +69,11 @@ public:
~DevicesWindowQtConfig() {} ~DevicesWindowQtConfig() {}
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_DEVICESWINDOW_H

View File

@ -10,12 +10,12 @@
#include "debug/dvdisasm.h" #include "debug/dvdisasm.h"
LogWindow::LogWindow(running_machine* machine, QWidget* parent) : LogWindow::LogWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr) WindowQt(machine, nullptr)
{ {
setWindowTitle("Debug: Machine Log"); setWindowTitle("Debug: Machine Log");
if (parent != nullptr) if (parent)
{ {
QPoint parentPos = parent->pos(); QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@ -24,12 +24,10 @@ LogWindow::LogWindow(running_machine* machine, QWidget* parent) :
// //
// The main frame and its input and log widgets // The main frame and its input and log widgets
// //
QFrame* mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
// The main log view // The main log view
m_logView = new DebuggerView(DVT_LOG, m_logView = new DebuggerView(DVT_LOG, m_machine, this);
m_machine,
this);
// Layout // Layout
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
@ -49,13 +47,13 @@ LogWindow::~LogWindow()
//========================================================================= //=========================================================================
// LogWindowQtConfig // LogWindowQtConfig
//========================================================================= //=========================================================================
void LogWindowQtConfig::buildFromQWidget(QWidget* widget) void LogWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
} }
void LogWindowQtConfig::applyToQWidget(QWidget* widget) void LogWindowQtConfig::applyToQWidget(QWidget *widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
} }

View File

@ -1,7 +1,7 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_LOG_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_LOGWINDOW_H
#define __DEBUG_QT_LOG_WINDOW_H__ #define MAME_DEBUGGER_QT_LOGWINDOW_H
#include "debuggerview.h" #include "debuggerview.h"
#include "windowqt.h" #include "windowqt.h"
@ -15,13 +15,12 @@ class LogWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
LogWindow(running_machine* machine, QWidget* parent=nullptr); LogWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~LogWindow(); virtual ~LogWindow();
private: private:
// Widgets // Widgets
DebuggerView* m_logView; DebuggerView *m_logView;
}; };
@ -38,11 +37,11 @@ public:
~LogWindowQtConfig() {} ~LogWindowQtConfig() {}
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_LOGWINDOW_H

View File

@ -1,14 +1,6 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #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 "mainwindow.h"
#include "debug/debugcon.h" #include "debug/debugcon.h"
@ -16,8 +8,16 @@
#include "debug/dvdisasm.h" #include "debug/dvdisasm.h"
#include "debug/points.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), WindowQt(machine, nullptr),
m_historyIndex(0), m_historyIndex(0),
m_inputHistory() m_inputHistory()
@ -27,7 +27,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// //
// The main frame and its input and log widgets // The main frame and its input and log widgets
// //
QFrame* mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
// The input line // The input line
m_inputEdit = new QLineEdit(mainWindowFrame); m_inputEdit = new QLineEdit(mainWindowFrame);
@ -36,13 +36,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// The log view // The log view
m_consoleView = new DebuggerView(DVT_CONSOLE, m_consoleView = new DebuggerView(DVT_CONSOLE, m_machine, mainWindowFrame);
m_machine,
mainWindowFrame);
m_consoleView->setFocusPolicy(Qt::NoFocus); m_consoleView->setFocusPolicy(Qt::NoFocus);
m_consoleView->setPreferBottom(true); m_consoleView->setPreferBottom(true);
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->addWidget(m_consoleView); vLayout->addWidget(m_consoleView);
vLayout->addWidget(m_inputEdit); vLayout->addWidget(m_inputEdit);
vLayout->setSpacing(3); vLayout->setSpacing(3);
@ -65,11 +63,11 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(m_runToCursorAct, &QAction::triggered, this, &MainWindow::runToCursor); connect(m_runToCursorAct, &QAction::triggered, this, &MainWindow::runToCursor);
// Right bar options // Right bar options
QActionGroup* rightBarGroup = new QActionGroup(this); QActionGroup *rightBarGroup = new QActionGroup(this);
rightBarGroup->setObjectName("rightbargroup"); rightBarGroup->setObjectName("rightbargroup");
QAction* rightActRaw = new QAction("Raw Opcodes", this); QAction *rightActRaw = new QAction("Raw Opcodes", this);
QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); QAction *rightActEncrypted = new QAction("Encrypted Opcodes", this);
QAction* rightActComments = new QAction("Comments", this); QAction *rightActComments = new QAction("Comments", this);
rightActRaw->setCheckable(true); rightActRaw->setCheckable(true);
rightActEncrypted->setCheckable(true); rightActEncrypted->setCheckable(true);
rightActComments->setCheckable(true); rightActComments->setCheckable(true);
@ -83,7 +81,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
connect(rightBarGroup, &QActionGroup::triggered, this, &MainWindow::rightBarChanged); connect(rightBarGroup, &QActionGroup::triggered, this, &MainWindow::rightBarChanged);
// Assemble the options menu // Assemble the options menu
QMenu* optionsMenu = menuBar()->addMenu("&Options"); QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addAction(m_breakpointToggleAct); optionsMenu->addAction(m_breakpointToggleAct);
optionsMenu->addAction(m_breakpointEnableAct); optionsMenu->addAction(m_breakpointEnableAct);
optionsMenu->addAction(m_runToCursorAct); optionsMenu->addAction(m_runToCursorAct);
@ -93,22 +91,20 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
// //
// Images menu // Images menu
// //
image_interface_enumerator imageIterTest(m_machine->root_device()); image_interface_enumerator imageIterTest(m_machine.root_device());
if (imageIterTest.first() != nullptr) if (imageIterTest.first())
{
createImagesMenu(); createImagesMenu();
}
// //
// Dock window menu // Dock window menu
// //
QMenu* dockMenu = menuBar()->addMenu("Doc&ks"); QMenu *dockMenu = menuBar()->addMenu("Doc&ks");
setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
// The processor dock // The processor dock
QDockWidget* cpuDock = new QDockWidget("processor", this); QDockWidget *cpuDock = new QDockWidget("processor", this);
cpuDock->setObjectName("cpudock"); cpuDock->setObjectName("cpudock");
cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea); cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
m_procFrame = new ProcessorDockWidget(m_machine, cpuDock); m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
@ -118,7 +114,7 @@ MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
dockMenu->addAction(cpuDock->toggleViewAction()); dockMenu->addAction(cpuDock->toggleViewAction());
// The disassembly dock // The disassembly dock
QDockWidget* dasmDock = new QDockWidget("dasm", this); QDockWidget *dasmDock = new QDockWidget("dasm", this);
dasmDock->setObjectName("dasmdock"); dasmDock->setObjectName("dasmdock");
dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); 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 // Cpu swap
m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor)); 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); m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
// Window title // 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 // Used to intercept the user clicking 'X' in the upper corner
void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
debugActQuit(); debugActQuit();
@ -162,18 +157,14 @@ void MainWindow::closeEvent(QCloseEvent* event)
// Used to intercept the user hitting the up arrow in the input widget // 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 // Only filter keypresses
QKeyEvent* keyEvent = nullptr; QKeyEvent *keyEvent = nullptr;
if (event->type() == QEvent::KeyPress) if (event->type() == QEvent::KeyPress)
{
keyEvent = static_cast<QKeyEvent*>(event); keyEvent = static_cast<QKeyEvent*>(event);
}
else else
{
return QObject::eventFilter(obj, event); return QObject::eventFilter(obj, event);
}
// Catch up & down keys // Catch up & down keys
if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) 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) void MainWindow::toggleBreakpointAtCursor(bool changedTo)
{ {
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); 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(); offs_t const address = downcast<debug_view_disasm *>(dasmView)->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug(); device_debug *const cpuinfo = dasmView->source()->device()->debug();
@ -225,15 +216,11 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
// If none exists, add a new one // If none exists, add a new one
std::string command; std::string command;
if (bp == nullptr) if (!bp)
{
command = string_format("bpset 0x%X", address); command = string_format("bpset 0x%X", address);
}
else else
{
command = string_format("bpclear 0x%X", bp->index()); 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(); refreshAll();
@ -243,7 +230,7 @@ void MainWindow::toggleBreakpointAtCursor(bool changedTo)
void MainWindow::enableBreakpointAtCursor(bool changedTo) void MainWindow::enableBreakpointAtCursor(bool changedTo)
{ {
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); 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(); offs_t const address = dasmView->selected_address();
device_debug *const cpuinfo = dasmView->source()->device()->debug(); device_debug *const cpuinfo = dasmView->source()->device()->debug();
@ -251,11 +238,11 @@ void MainWindow::enableBreakpointAtCursor(bool changedTo)
// Find an existing breakpoint at this address // Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address); const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr) if (bp)
{ {
int32_t const bpindex = bp->index(); int32_t const bpindex = bp->index();
std::string command = string_format(bp->enabled() ? "bpdisable 0x%X" : "bpenable 0x%X", bpindex); 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) void MainWindow::runToCursor(bool 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 (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 address = downcast<debug_view_disasm*>(dasmView)->selected_address(); offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
std::string command = string_format("go 0x%X", 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") if (changedTo->text() == "Raw Opcodes")
{
dasmView->set_right_column(DASM_RIGHTCOL_RAW); dasmView->set_right_column(DASM_RIGHTCOL_RAW);
}
else if (changedTo->text() == "Encrypted Opcodes") else if (changedTo->text() == "Encrypted Opcodes")
{
dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
}
else if (changedTo->text() == "Comments") else if (changedTo->text() == "Comments")
{
dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
}
m_dasmFrame->view()->viewport()->update(); m_dasmFrame->view()->viewport()->update();
} }
@ -305,12 +288,12 @@ void MainWindow::executeCommand(bool withClear)
// A blank command is a "silent step" // A blank command is a "silent step"
if (command == "") if (command == "")
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->single_step(); m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
return; return;
} }
// Send along the command // 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 // Add history & set the index to be the top of the stack
addToHistory(command); addToHistory(command);
@ -332,24 +315,25 @@ void MainWindow::mountImage(bool changedTo)
{ {
// The image interface index was assigned to the QAction's data memeber // The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); 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); 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(); refreshAll();
return; return;
} }
// File dialog // File dialog
QString filename = QFileDialog::getOpenFileName(this, QString filename = QFileDialog::getOpenFileName(
"Select an image file", this,
QDir::currentPath(), "Select an image file",
tr("All files (*.*)")); QDir::currentPath(),
tr("All files (*.*)"));
if (img->load(filename.toUtf8().data()) != image_init_result::PASS) 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(); refreshAll();
return; return;
} }
@ -359,13 +343,13 @@ void MainWindow::mountImage(bool changedTo)
unmountAct->setEnabled(true); unmountAct->setEnabled(true);
// Set the mount name // Set the mount name
QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title(); QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : "))); baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString(img->filename()); const QString newTitle = baseString + QString(" : ") + QString(img->filename());
parentMenuItem->setTitle(newTitle); 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(); refreshAll();
} }
@ -373,31 +357,31 @@ void MainWindow::mountImage(bool changedTo)
void MainWindow::unmountImage(bool changedTo) void MainWindow::unmountImage(bool changedTo)
{ {
// The image interface index was assigned to the QAction's data memeber // The image interface index was assigned to the QAction's data memeber
const int imageIndex = dynamic_cast<QAction*>(sender())->data().toInt(); 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); device_image_interface *img = iter.byindex(imageIndex);
img->unload(); img->unload();
// Deactivate the unmount menu option // Deactivate the unmount menu option
dynamic_cast<QAction*>(sender())->setEnabled(false); dynamic_cast<QAction *>(sender())->setEnabled(false);
// Set the mount name // Set the mount name
QMenu* parentMenuItem = dynamic_cast<QMenu*>(sender()->parent()); QMenu *parentMenuItem = dynamic_cast<QMenu *>(sender()->parent());
QString baseString = parentMenuItem->title(); QString baseString = parentMenuItem->title();
baseString.truncate(baseString.lastIndexOf(QString(" : "))); baseString.truncate(baseString.lastIndexOf(QString(" : ")));
const QString newTitle = baseString + QString(" : ") + QString("[empty slot]"); const QString newTitle = baseString + QString(" : ") + QString("[empty slot]");
parentMenuItem->setTitle(newTitle); parentMenuItem->setTitle(newTitle);
m_machine->debugger().console().printf("Image successfully unmounted.\n"); m_machine.debugger().console().printf("Image successfully unmounted.\n");
refreshAll(); refreshAll();
} }
void MainWindow::dasmViewUpdated() void MainWindow::dasmViewUpdated()
{ {
debug_view_disasm *const dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view()); 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 const haveCursor = dasmView->cursor_visible() && (m_machine.debugger().console().get_visible_cpu() == dasmView->source()->device());
bool haveBreakpoint = false; bool haveBreakpoint = false;
bool breakpointEnabled = false; bool breakpointEnabled = false;
if (haveCursor) if (haveCursor)
@ -409,7 +393,7 @@ void MainWindow::dasmViewUpdated()
// Find an existing breakpoint at this address // Find an existing breakpoint at this address
const debug_breakpoint *bp = cpuinfo->breakpoint_find(address); const debug_breakpoint *bp = cpuinfo->breakpoint_find(address);
if (bp != nullptr) if (bp)
{ {
haveBreakpoint = true; haveBreakpoint = true;
breakpointEnabled = bp->enabled(); breakpointEnabled = bp->enabled();
@ -426,7 +410,7 @@ void MainWindow::dasmViewUpdated()
void MainWindow::debugActClose() void MainWindow::debugActClose()
{ {
m_machine->schedule_exit(); m_machine.schedule_exit();
} }
@ -436,7 +420,7 @@ void MainWindow::addToHistory(const QString& command)
return; return;
// Always push back when there is no previous history // 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()); m_inputHistory.push_back(m_inputEdit->text());
return; 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 there is previous history, make sure it's not what you just executed
if (m_inputHistory.back() != m_inputEdit->text()) if (m_inputHistory.back() != m_inputEdit->text())
{
m_inputHistory.push_back(m_inputEdit->text()); m_inputHistory.push_back(m_inputEdit->text());
}
} }
void MainWindow::createImagesMenu() void MainWindow::createImagesMenu()
{ {
QMenu* imagesMenu = menuBar()->addMenu("&Images"); QMenu *imagesMenu = menuBar()->addMenu("&Images");
int interfaceIndex = 0; 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]"); 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()); interfaceMenu->setObjectName(img.device().name());
QAction* mountAct = new QAction("Mount...", interfaceMenu); QAction *mountAct = new QAction("Mount...", interfaceMenu);
QAction* unmountAct = new QAction("Unmount", interfaceMenu); QAction *unmountAct = new QAction("Unmount", interfaceMenu);
mountAct->setObjectName("mount"); mountAct->setObjectName("mount");
mountAct->setData(QVariant(interfaceIndex)); mountAct->setData(QVariant(interfaceIndex));
unmountAct->setObjectName("unmount"); unmountAct->setObjectName("unmount");
@ -490,10 +472,10 @@ void MainWindow::createImagesMenu()
void MainWindowQtConfig::buildFromQWidget(QWidget* widget) void MainWindowQtConfig::buildFromQWidget(QWidget* widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
MainWindow* window = dynamic_cast<MainWindow*>(widget); MainWindow *window = dynamic_cast<MainWindow *>(widget);
m_windowState = window->saveState(); m_windowState = window->saveState();
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); QActionGroup *rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");
if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") if (rightBarGroup->checkedAction()->text() == "Raw Opcodes")
m_rightBar = 0; m_rightBar = 0;
else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") 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); WindowQtConfig::applyToQWidget(widget);
MainWindow* window = dynamic_cast<MainWindow*>(widget); MainWindow *window = dynamic_cast<MainWindow *>(widget);
window->restoreState(m_windowState); window->restoreState(m_windowState);
QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup"); QActionGroup* rightBarGroup = window->findChild<QActionGroup*>("rightbargroup");

View File

@ -1,18 +1,19 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_MAIN_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_MAINWINDOW_H
#define __DEBUG_QT_MAIN_WINDOW_H__ #define MAME_DEBUGGER_QT_MAINWINDOW_H
#include <vector> #include "debuggerview.h"
#include "windowqt.h"
#include "debug/dvdisasm.h"
#include <QtWidgets/QLineEdit> #include <QtWidgets/QLineEdit>
#include <QtWidgets/QVBoxLayout> #include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QComboBox> #include <QtWidgets/QComboBox>
#include "debug/dvdisasm.h" #include <vector>
#include "debuggerview.h"
#include "windowqt.h"
class DasmDockWidget; class DasmDockWidget;
class ProcessorDockWidget; class ProcessorDockWidget;
@ -26,25 +27,24 @@ class MainWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
MainWindow(running_machine* machine, QWidget* parent=nullptr); MainWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~MainWindow(); virtual ~MainWindow();
void setProcessor(device_t* processor); void setProcessor(device_t *processor);
protected: protected:
// Used to intercept the user clicking 'X' in the upper corner // Used to intercept the user clicking 'X' in the upper corner
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent *event);
// Used to intercept the user hitting the up arrow in the input widget // Used to intercept the user hitting the up arrow in the input widget
bool eventFilter(QObject* obj, QEvent* event); bool eventFilter(QObject *obj, QEvent *event);
private slots: private slots:
void toggleBreakpointAtCursor(bool changedTo); void toggleBreakpointAtCursor(bool changedTo);
void enableBreakpointAtCursor(bool changedTo); void enableBreakpointAtCursor(bool changedTo);
void runToCursor(bool changedTo); void runToCursor(bool changedTo);
void rightBarChanged(QAction* changedTo); void rightBarChanged(QAction *changedTo);
void executeCommandSlot(); void executeCommandSlot();
@ -61,15 +61,15 @@ private:
void createImagesMenu(); void createImagesMenu();
// Widgets and docks // Widgets and docks
QLineEdit* m_inputEdit; QLineEdit *m_inputEdit;
DebuggerView* m_consoleView; DebuggerView *m_consoleView;
ProcessorDockWidget* m_procFrame; ProcessorDockWidget *m_procFrame;
DasmDockWidget* m_dasmFrame; DasmDockWidget *m_dasmFrame;
// Menu items // Menu items
QAction* m_breakpointToggleAct; QAction *m_breakpointToggleAct;
QAction* m_breakpointEnableAct; QAction *m_breakpointEnableAct;
QAction* m_runToCursorAct; QAction *m_runToCursorAct;
// Terminal history // Terminal history
int m_historyIndex; int m_historyIndex;
@ -87,45 +87,31 @@ class DasmDockWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
DasmDockWidget(running_machine* machine, QWidget* parent=nullptr) : DasmDockWidget(running_machine &machine, QWidget *parent = nullptr) :
QWidget(parent), QWidget(parent),
m_machine(machine) m_machine(machine)
{ {
m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_dasmView = new DebuggerView(DVT_DISASSEMBLY, m_machine, this);
m_machine,
this);
// Force a recompute of the disassembly region // Force a recompute of the disassembly region
downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc"); downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");
QVBoxLayout* dvLayout = new QVBoxLayout(this); QVBoxLayout *dvLayout = new QVBoxLayout(this);
dvLayout->addWidget(m_dasmView); dvLayout->addWidget(m_dasmView);
dvLayout->setContentsMargins(4,0,4,0); dvLayout->setContentsMargins(4,0,4,0);
} }
virtual ~DasmDockWidget(); virtual ~DasmDockWidget();
DebuggerView *view() { return m_dasmView; }
DebuggerView* view() { return m_dasmView; } QSize minimumSizeHint() const { return QSize(150, 150); }
QSize sizeHint() const { return QSize(150, 200); }
QSize minimumSizeHint() const
{
return QSize(150,150);
}
QSize sizeHint() const
{
return QSize(150,200);
}
private: private:
DebuggerView* m_dasmView; running_machine &m_machine;
running_machine* m_machine; DebuggerView *m_dasmView;
}; };
@ -137,45 +123,30 @@ class ProcessorDockWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ProcessorDockWidget(running_machine* machine, ProcessorDockWidget(running_machine &machine, QWidget *parent = nullptr) :
QWidget* parent=nullptr) :
QWidget(parent), QWidget(parent),
m_processorView(nullptr), m_machine(machine),
m_machine(machine) m_processorView(nullptr)
{ {
m_processorView = new DebuggerView(DVT_STATE, m_processorView = new DebuggerView(DVT_STATE, m_machine, this);
m_machine,
this);
m_processorView->setFocusPolicy(Qt::NoFocus); m_processorView->setFocusPolicy(Qt::NoFocus);
QVBoxLayout* cvLayout = new QVBoxLayout(this); QVBoxLayout *cvLayout = new QVBoxLayout(this);
cvLayout->addWidget(m_processorView); cvLayout->addWidget(m_processorView);
cvLayout->setContentsMargins(4,0,4,2); cvLayout->setContentsMargins(4,0,4,2);
} }
virtual ~ProcessorDockWidget(); virtual ~ProcessorDockWidget();
DebuggerView *view() { return m_processorView; }
DebuggerView* view() { return m_processorView; } QSize minimumSizeHint() const { return QSize(150, 300); }
QSize sizeHint() const { return QSize(200, 300); }
QSize minimumSizeHint() const
{
return QSize(150,300);
}
QSize sizeHint() const
{
return QSize(200,300);
}
private: private:
DebuggerView* m_processorView; running_machine &m_machine;
running_machine* m_machine; DebuggerView *m_processorView;
}; };
@ -197,12 +168,11 @@ public:
int m_rightBar; int m_rightBar;
QByteArray m_windowState; QByteArray m_windowState;
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif // MAME_DEBUGGER_QT_MAINWINDOW_H
#endif

View File

@ -1,6 +1,12 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #include "emu.h"
#include "memorywindow.h"
#include "debug/dvmemory.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include <QtGui/QClipboard> #include <QtGui/QClipboard>
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtWidgets/QActionGroup> #include <QtWidgets/QActionGroup>
@ -12,22 +18,16 @@
#include <QtWidgets/QToolTip> #include <QtWidgets/QToolTip>
#include <QtWidgets/QVBoxLayout> #include <QtWidgets/QVBoxLayout>
#include "memorywindow.h"
#include "debug/dvmemory.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width #define horizontalAdvance width
#endif #endif
MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : MemoryWindow::MemoryWindow(running_machine &machine, QWidget *parent) :
WindowQt(machine, nullptr) WindowQt(machine, nullptr)
{ {
setWindowTitle("Debug: Memory View"); setWindowTitle("Debug: Memory View");
if (parent != nullptr) if (parent)
{ {
QPoint parentPos = parent->pos(); QPoint parentPos = parent->pos();
setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
@ -36,10 +36,10 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
// //
// The main frame and its input and log widgets // The main frame and its input and log widgets
// //
QFrame* mainWindowFrame = new QFrame(this); QFrame *mainWindowFrame = new QFrame(this);
// The top frame & groupbox that contains the input widgets // The top frame & groupbox that contains the input widgets
QFrame* topSubFrame = new QFrame(mainWindowFrame); QFrame *topSubFrame = new QFrame(mainWindowFrame);
// The input edit // The input edit
m_inputEdit = new QLineEdit(topSubFrame); m_inputEdit = new QLineEdit(topSubFrame);
@ -49,19 +49,19 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
m_memoryComboBox = new QComboBox(topSubFrame); m_memoryComboBox = new QComboBox(topSubFrame);
m_memoryComboBox->setObjectName("memoryregion"); m_memoryComboBox->setObjectName("memoryregion");
m_memoryComboBox->setMinimumWidth(300); m_memoryComboBox->setMinimumWidth(300);
connect(m_memoryComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged); connect(m_memoryComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged);
// The main memory window // The main memory window
m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this);
// Layout // Layout
QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); QHBoxLayout *subLayout = new QHBoxLayout(topSubFrame);
subLayout->addWidget(m_inputEdit); subLayout->addWidget(m_inputEdit);
subLayout->addWidget(m_memoryComboBox); subLayout->addWidget(m_memoryComboBox);
subLayout->setSpacing(3); subLayout->setSpacing(3);
subLayout->setContentsMargins(2,2,2,2); subLayout->setContentsMargins(2,2,2,2);
QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame);
vLayout->setSpacing(3); vLayout->setSpacing(3);
vLayout->setContentsMargins(2,2,2,2); vLayout->setContentsMargins(2,2,2,2);
vLayout->addWidget(topSubFrame); vLayout->addWidget(topSubFrame);
@ -74,15 +74,15 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
// //
// Create a data format group // Create a data format group
QActionGroup* dataFormat = new QActionGroup(this); QActionGroup *dataFormat = new QActionGroup(this);
dataFormat->setObjectName("dataformat"); dataFormat->setObjectName("dataformat");
QAction* formatActOne = new QAction("1-byte chunks", this); QAction *formatActOne = new QAction("1-byte chunks", this);
QAction* formatActTwo = new QAction("2-byte chunks", this); QAction *formatActTwo = new QAction("2-byte chunks", this);
QAction* formatActFour = new QAction("4-byte chunks", this); QAction *formatActFour = new QAction("4-byte chunks", this);
QAction* formatActEight = new QAction("8-byte chunks", this); QAction *formatActEight = new QAction("8-byte chunks", this);
QAction* formatAct32bitFloat = new QAction("32 bit floating point", this); QAction *formatAct32bitFloat = new QAction("32 bit floating point", this);
QAction* formatAct64bitFloat = new QAction("64 bit floating point", this); QAction *formatAct64bitFloat = new QAction("64 bit floating point", this);
QAction* formatAct80bitFloat = new QAction("80 bit floating point", this); QAction *formatAct80bitFloat = new QAction("80 bit floating point", this);
formatActOne->setObjectName("formatActOne"); formatActOne->setObjectName("formatActOne");
formatActTwo->setObjectName("formatActTwo"); formatActTwo->setObjectName("formatActTwo");
formatActFour->setObjectName("formatActFour"); formatActFour->setObjectName("formatActFour");
@ -112,10 +112,10 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
formatActOne->setChecked(true); formatActOne->setChecked(true);
connect(dataFormat, &QActionGroup::triggered, this, &MemoryWindow::formatChanged); connect(dataFormat, &QActionGroup::triggered, this, &MemoryWindow::formatChanged);
// Create a address display group // Create a address display group
QActionGroup* addressGroup = new QActionGroup(this); QActionGroup *addressGroup = new QActionGroup(this);
addressGroup->setObjectName("addressgroup"); addressGroup->setObjectName("addressgroup");
QAction* addressActLogical = new QAction("Logical Addresses", this); QAction *addressActLogical = new QAction("Logical Addresses", this);
QAction* addressActPhysical = new QAction("Physical Addresses", this); QAction *addressActPhysical = new QAction("Physical Addresses", this);
addressActLogical->setCheckable(true); addressActLogical->setCheckable(true);
addressActPhysical->setCheckable(true); addressActPhysical->setCheckable(true);
addressActLogical->setActionGroup(addressGroup); addressActLogical->setActionGroup(addressGroup);
@ -126,22 +126,22 @@ MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
connect(addressGroup, &QActionGroup::triggered, this, &MemoryWindow::addressChanged); connect(addressGroup, &QActionGroup::triggered, this, &MemoryWindow::addressChanged);
// Create a reverse view radio // Create a reverse view radio
QAction* reverseAct = new QAction("Reverse View", this); QAction *reverseAct = new QAction("Reverse View", this);
reverseAct->setObjectName("reverse"); reverseAct->setObjectName("reverse");
reverseAct->setCheckable(true); reverseAct->setCheckable(true);
reverseAct->setShortcut(QKeySequence("Ctrl+R")); reverseAct->setShortcut(QKeySequence("Ctrl+R"));
connect(reverseAct, &QAction::toggled, this, &MemoryWindow::reverseChanged); connect(reverseAct, &QAction::toggled, this, &MemoryWindow::reverseChanged);
// Create increase and decrease bytes-per-line actions // Create increase and decrease bytes-per-line actions
QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); QAction *increaseBplAct = new QAction("Increase Bytes Per Line", this);
QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); QAction *decreaseBplAct = new QAction("Decrease Bytes Per Line", this);
increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); increaseBplAct->setShortcut(QKeySequence("Ctrl+P"));
decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); decreaseBplAct->setShortcut(QKeySequence("Ctrl+O"));
connect(increaseBplAct, &QAction::triggered, this, &MemoryWindow::increaseBytesPerLine); connect(increaseBplAct, &QAction::triggered, this, &MemoryWindow::increaseBytesPerLine);
connect(decreaseBplAct, &QAction::triggered, this, &MemoryWindow::decreaseBytesPerLine); connect(decreaseBplAct, &QAction::triggered, this, &MemoryWindow::decreaseBytesPerLine);
// Assemble the options menu // Assemble the options menu
QMenu* optionsMenu = menuBar()->addMenu("&Options"); QMenu *optionsMenu = menuBar()->addMenu("&Options");
optionsMenu->addActions(dataFormat->actions()); optionsMenu->addActions(dataFormat->actions());
optionsMenu->addSeparator(); optionsMenu->addSeparator();
optionsMenu->addActions(addressGroup->actions()); optionsMenu->addActions(addressGroup->actions());
@ -173,17 +173,17 @@ void MemoryWindow::memoryRegionChanged(int index)
m_memTable->viewport()->update(); m_memTable->viewport()->update();
// Update the data format radio buttons to the memory region's default // Update the data format radio buttons to the memory region's default
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
switch(memView->get_data_format()) switch (memView->get_data_format())
{ {
case 1: dataFormatMenuItem("formatActOne")->setChecked(true); break; case 1: dataFormatMenuItem("formatActOne")->setChecked(true); break;
case 2: dataFormatMenuItem("formatActTwo")->setChecked(true); break; case 2: dataFormatMenuItem("formatActTwo")->setChecked(true); break;
case 4: dataFormatMenuItem("formatActFour")->setChecked(true); break; case 4: dataFormatMenuItem("formatActFour")->setChecked(true); break;
case 8: dataFormatMenuItem("formatActEight")->setChecked(true); break; case 8: dataFormatMenuItem("formatActEight")->setChecked(true); break;
case 9: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break; case 9: dataFormatMenuItem("formatAct32bitFloat")->setChecked(true); break;
case 10: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break; case 10: dataFormatMenuItem("formatAct64bitFloat")->setChecked(true); break;
case 11: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break; case 11: dataFormatMenuItem("formatAct80bitFloat")->setChecked(true); break;
default: break; default: break;
} }
} }
@ -191,7 +191,7 @@ void MemoryWindow::memoryRegionChanged(int index)
void MemoryWindow::expressionSubmitted() void MemoryWindow::expressionSubmitted()
{ {
const QString expression = m_inputEdit->text(); const QString expression = m_inputEdit->text();
downcast<debug_view_memory*>(m_memTable->view())->set_expression(expression.toLocal8Bit().data()); downcast<debug_view_memory *>(m_memTable->view())->set_expression(expression.toLocal8Bit().data());
// Make the cursor pop // Make the cursor pop
m_memTable->view()->set_cursor_visible(true); m_memTable->view()->set_cursor_visible(true);
@ -208,57 +208,43 @@ void MemoryWindow::expressionSubmitted()
void MemoryWindow::formatChanged(QAction* changedTo) void MemoryWindow::formatChanged(QAction* changedTo)
{ {
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
if (changedTo->text() == "1-byte chunks") if (changedTo->text() == "1-byte chunks")
{
memView->set_data_format(1); memView->set_data_format(1);
}
else if (changedTo->text() == "2-byte chunks") else if (changedTo->text() == "2-byte chunks")
{
memView->set_data_format(2); memView->set_data_format(2);
}
else if (changedTo->text() == "4-byte chunks") else if (changedTo->text() == "4-byte chunks")
{
memView->set_data_format(4); memView->set_data_format(4);
}
else if (changedTo->text() == "8-byte chunks") else if (changedTo->text() == "8-byte chunks")
{
memView->set_data_format(8); memView->set_data_format(8);
}
else if (changedTo->text() == "32 bit floating point") else if (changedTo->text() == "32 bit floating point")
{
memView->set_data_format(9); memView->set_data_format(9);
}
else if (changedTo->text() == "64 bit floating point") else if (changedTo->text() == "64 bit floating point")
{
memView->set_data_format(10); memView->set_data_format(10);
}
else if (changedTo->text() == "80 bit floating point") else if (changedTo->text() == "80 bit floating point")
{
memView->set_data_format(11); memView->set_data_format(11);
}
m_memTable->viewport()->update(); m_memTable->viewport()->update();
} }
void MemoryWindow::addressChanged(QAction* changedTo) void MemoryWindow::addressChanged(QAction* changedTo)
{ {
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
if (changedTo->text() == "Logical Addresses") if (changedTo->text() == "Logical Addresses")
{
memView->set_physical(false); memView->set_physical(false);
}
else if (changedTo->text() == "Physical Addresses") else if (changedTo->text() == "Physical Addresses")
{
memView->set_physical(true); memView->set_physical(true);
}
m_memTable->viewport()->update(); m_memTable->viewport()->update();
} }
void MemoryWindow::reverseChanged(bool changedTo) void MemoryWindow::reverseChanged(bool changedTo)
{ {
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
memView->set_reverse(changedTo); memView->set_reverse(changedTo);
m_memTable->viewport()->update(); m_memTable->viewport()->update();
} }
@ -266,7 +252,7 @@ void MemoryWindow::reverseChanged(bool changedTo)
void MemoryWindow::increaseBytesPerLine(bool changedTo) void MemoryWindow::increaseBytesPerLine(bool changedTo)
{ {
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory*>(m_memTable->view());
memView->set_chunks_per_row(memView->chunks_per_row() + 1); memView->set_chunks_per_row(memView->chunks_per_row() + 1);
m_memTable->viewport()->update(); m_memTable->viewport()->update();
} }
@ -274,7 +260,7 @@ void MemoryWindow::increaseBytesPerLine(bool changedTo)
void MemoryWindow::decreaseBytesPerLine(bool checked) void MemoryWindow::decreaseBytesPerLine(bool checked)
{ {
debug_view_memory* memView = downcast<debug_view_memory*>(m_memTable->view()); debug_view_memory *memView = downcast<debug_view_memory *>(m_memTable->view());
memView->set_chunks_per_row(memView->chunks_per_row() - 1); memView->set_chunks_per_row(memView->chunks_per_row() - 1);
m_memTable->viewport()->update(); m_memTable->viewport()->update();
} }
@ -282,20 +268,18 @@ void MemoryWindow::decreaseBytesPerLine(bool checked)
void MemoryWindow::populateComboBox() void MemoryWindow::populateComboBox()
{ {
if (m_memTable == nullptr) if (!m_memTable)
return; return;
m_memoryComboBox->clear(); m_memoryComboBox->clear();
for (auto &source : m_memTable->view()->source_list()) for (auto &source : m_memTable->view()->source_list())
{
m_memoryComboBox->addItem(source->name()); m_memoryComboBox->addItem(source->name());
}
} }
void MemoryWindow::setToCurrentCpu() void MemoryWindow::setToCurrentCpu()
{ {
device_t* curCpu = m_machine->debugger().console().get_visible_cpu(); device_t *curCpu = m_machine.debugger().console().get_visible_cpu();
if (curCpu) if (curCpu)
{ {
const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); const debug_view_source *source = m_memTable->view()->source_for_device(curCpu);
@ -309,13 +293,14 @@ void MemoryWindow::setToCurrentCpu()
// I have a hard time storing QActions as class members. This is a substitute. // I have a hard time storing QActions as class members. This is a substitute.
QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName) QAction *MemoryWindow::dataFormatMenuItem(const QString& itemName)
{ {
QList<QMenu*> menus = menuBar()->findChildren<QMenu*>(); QList<QMenu *> menus = menuBar()->findChildren<QMenu *>();
for (int i = 0; i < menus.length(); i++) for (int i = 0; i < menus.length(); i++)
{ {
if (menus[i]->title() != "&Options") continue; if (menus[i]->title() != "&Options")
QList<QAction*> actions = menus[i]->actions(); continue;
QList<QAction *> actions = menus[i]->actions();
for (int j = 0; j < actions.length(); j++) for (int j = 0; j < actions.length(); j++)
{ {
if (actions[j]->objectName() == itemName) if (actions[j]->objectName() == itemName)
@ -329,36 +314,25 @@ QAction* MemoryWindow::dataFormatMenuItem(const QString& itemName)
//========================================================================= //=========================================================================
// DebuggerMemView // DebuggerMemView
//========================================================================= //=========================================================================
void DebuggerMemView::mousePressEvent(QMouseEvent* event) void DebuggerMemView::addItemsToContextMenu(QMenu *menu)
{ {
const bool leftClick = event->button() == Qt::LeftButton; DebuggerView::addItemsToContextMenu(menu);
const bool rightClick = event->button() == Qt::RightButton;
if (leftClick || rightClick) if (view()->cursor_visible())
{ {
QFontMetrics actualFont = fontMetrics(); debug_view_memory &memView = downcast<debug_view_memory &>(*view());
const double fontWidth = actualFont.horizontalAdvance(QString(100, '_')) / 100.; debug_view_memory_source const &source = downcast<debug_view_memory_source const &>(*memView.source());
const int fontHeight = std::max(1, actualFont.lineSpacing()); address_space *const addressSpace = source.space();
if (addressSpace)
debug_view_xy topLeft = view()->visible_position();
debug_view_xy clickViewPosition;
clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
if (leftClick)
{ {
view()->process_click(DCK_LEFT_CLICK, clickViewPosition); // get the last known PC to write to this memory location
} debug_view_xy const pos = view()->cursor_position();
else if (rightClick) offs_t const address = memView.addressAtCursorPosition(pos);
{
// Display the last known PC to write to this memory location & copy it onto the clipboard
debug_view_memory* memView = downcast<debug_view_memory*>(view());
const offs_t address = memView->addressAtCursorPosition(clickViewPosition);
const debug_view_memory_source* source = downcast<const debug_view_memory_source*>(memView->source());
address_space* addressSpace = source->space();
offs_t a = address & addressSpace->logaddrmask(); offs_t a = address & addressSpace->logaddrmask();
bool good = false;
if (!addressSpace->device().memory().translate(addressSpace->spacenum(), TRANSLATE_READ_DEBUG, a)) if (!addressSpace->device().memory().translate(addressSpace->spacenum(), TRANSLATE_READ_DEBUG, a))
{ {
QToolTip::showText(QCursor::pos(), "Bad address", nullptr); m_lastPc = "Bad address";
} }
else else
{ {
@ -366,69 +340,64 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event)
auto dis = addressSpace->device().machine().disable_side_effects(); auto dis = addressSpace->device().machine().disable_side_effects();
switch (addressSpace->data_width()) switch (addressSpace->data_width())
{ {
case 8: case 8: memValue = addressSpace->read_byte(a); break;
memValue = addressSpace->read_byte(a); case 16: memValue = addressSpace->read_word_unaligned(a); break;
break; case 32: memValue = addressSpace->read_dword_unaligned(a); break;
case 64: memValue = addressSpace->read_qword_unaligned(a); break;
case 16:
memValue = addressSpace->read_word_unaligned(a);
break;
case 32:
memValue = addressSpace->read_dword_unaligned(a);
break;
case 64:
memValue = addressSpace->read_qword_unaligned(a);
break;
} }
const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(), offs_t const pc = source.device()->debug()->track_mem_pc_from_space_address_data(
address, addressSpace->spacenum(),
memValue); address,
if (pc != (offs_t)(-1)) memValue);
if (pc != offs_t(-1))
{ {
// TODO: You can specify a box that the tooltip stays alive within - might be good? m_lastPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16);
const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); good = true;
QToolTip::showText(QCursor::pos(), addressAndPc, nullptr);
// Copy the PC into the clipboard as well
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(QString("%1").arg(pc, 2, 16));
} }
else else
{ {
QToolTip::showText(QCursor::pos(), "UNKNOWN PC", nullptr); m_lastPc = "Unknown PC";
} }
} }
}
viewport()->update(); if (!menu->isEmpty())
update(); menu->addSeparator();
QAction *const act = new QAction(m_lastPc, menu);
act->setEnabled(good);
connect(act, &QAction::triggered, this, &DebuggerMemView::copyLastPc);
menu->addAction(act);
}
} }
} }
void DebuggerMemView::copyLastPc()
{
QApplication::clipboard()->setText(m_lastPc);
}
//========================================================================= //=========================================================================
// MemoryWindowQtConfig // MemoryWindowQtConfig
//========================================================================= //=========================================================================
void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget) void MemoryWindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
WindowQtConfig::buildFromQWidget(widget); WindowQtConfig::buildFromQWidget(widget);
MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); MemoryWindow *window = dynamic_cast<MemoryWindow *>(widget);
QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); QComboBox *memoryRegion = window->findChild<QComboBox*>("memoryregion");
m_memoryRegion = memoryRegion->currentIndex(); m_memoryRegion = memoryRegion->currentIndex();
QAction* reverse = window->findChild<QAction*>("reverse"); QAction *reverse = window->findChild<QAction *>("reverse");
m_reverse = reverse->isChecked(); m_reverse = reverse->isChecked();
QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
if (addressGroup->checkedAction()->text() == "Logical Addresses") if (addressGroup->checkedAction()->text() == "Logical Addresses")
m_addressMode = 0; m_addressMode = 0;
else if (addressGroup->checkedAction()->text() == "Physical Addresses") else if (addressGroup->checkedAction()->text() == "Physical Addresses")
m_addressMode = 1; m_addressMode = 1;
QActionGroup* dataFormat = window->findChild<QActionGroup*>("dataformat"); QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
if (dataFormat->checkedAction()->text() == "1-byte chunks") if (dataFormat->checkedAction()->text() == "1-byte chunks")
m_dataFormat = 0; m_dataFormat = 0;
else if (dataFormat->checkedAction()->text() == "2-byte chunks") else if (dataFormat->checkedAction()->text() == "2-byte chunks")
@ -446,20 +415,21 @@ void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget)
} }
void MemoryWindowQtConfig::applyToQWidget(QWidget* widget) void MemoryWindowQtConfig::applyToQWidget(QWidget *widget)
{ {
WindowQtConfig::applyToQWidget(widget); WindowQtConfig::applyToQWidget(widget);
MemoryWindow* window = dynamic_cast<MemoryWindow*>(widget); MemoryWindow *window = dynamic_cast<MemoryWindow *>(widget);
QComboBox* memoryRegion = window->findChild<QComboBox*>("memoryregion"); QComboBox *memoryRegion = window->findChild<QComboBox *>("memoryregion");
memoryRegion->setCurrentIndex(m_memoryRegion); memoryRegion->setCurrentIndex(m_memoryRegion);
QAction* reverse = window->findChild<QAction*>("reverse"); QAction *reverse = window->findChild<QAction *>("reverse");
if (m_reverse) reverse->trigger(); if (m_reverse)
reverse->trigger();
QActionGroup* addressGroup = window->findChild<QActionGroup*>("addressgroup"); QActionGroup *addressGroup = window->findChild<QActionGroup*>("addressgroup");
addressGroup->actions()[m_addressMode]->trigger(); addressGroup->actions()[m_addressMode]->trigger();
QActionGroup* dataFormat = window->findChild<QActionGroup*>("dataformat"); QActionGroup *dataFormat = window->findChild<QActionGroup*>("dataformat");
dataFormat->actions()[m_dataFormat]->trigger(); dataFormat->actions()[m_dataFormat]->trigger();
} }

View File

@ -1,14 +1,14 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_MEMORY_WINDOW_H__ #ifndef MAME_DEBUGGER_QT_MEMORYWINDOW_H
#define __DEBUG_QT_MEMORY_WINDOW_H__ #define MAME_DEBUGGER_QT_MEMORYWINDOW_H
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QComboBox>
#include "debuggerview.h" #include "debuggerview.h"
#include "windowqt.h" #include "windowqt.h"
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLineEdit>
class DebuggerMemView; class DebuggerMemView;
@ -20,31 +20,27 @@ class MemoryWindow : public WindowQt
Q_OBJECT Q_OBJECT
public: public:
MemoryWindow(running_machine* machine, QWidget* parent=nullptr); MemoryWindow(running_machine &machine, QWidget *parent = nullptr);
virtual ~MemoryWindow(); virtual ~MemoryWindow();
private slots: private slots:
void memoryRegionChanged(int index); void memoryRegionChanged(int index);
void expressionSubmitted(); void expressionSubmitted();
void formatChanged(QAction* changedTo); void formatChanged(QAction *changedTo);
void addressChanged(QAction* changedTo); void addressChanged(QAction *changedTo);
void reverseChanged(bool changedTo); void reverseChanged(bool changedTo);
void increaseBytesPerLine(bool changedTo); void increaseBytesPerLine(bool changedTo);
void decreaseBytesPerLine(bool checked=false); void decreaseBytesPerLine(bool checked = false);
private: private:
void populateComboBox(); void populateComboBox();
void setToCurrentCpu(); void setToCurrentCpu();
QAction* dataFormatMenuItem(const QString& itemName); QAction *dataFormatMenuItem(const QString &itemName);
private:
// Widgets // Widgets
QLineEdit* m_inputEdit; QLineEdit *m_inputEdit;
QComboBox* m_memoryComboBox; QComboBox *m_memoryComboBox;
DebuggerMemView* m_memTable; DebuggerMemView *m_memTable;
}; };
@ -53,16 +49,23 @@ private:
//========================================================================= //=========================================================================
class DebuggerMemView : public DebuggerView class DebuggerMemView : public DebuggerView
{ {
Q_OBJECT
public: public:
DebuggerMemView(const debug_view_type& type, DebuggerMemView(const debug_view_type& type, running_machine &machine, QWidget *parent = nullptr)
running_machine* machine,
QWidget* parent=nullptr)
: DebuggerView(type, machine, parent) : DebuggerView(type, machine, parent)
{} {}
virtual ~DebuggerMemView() {} virtual ~DebuggerMemView() {}
protected: protected:
void mousePressEvent(QMouseEvent* event); virtual void addItemsToContextMenu(QMenu *menu) override;
private slots:
void copyLastPc();
private:
QString m_lastPc;
}; };
@ -89,11 +92,11 @@ public:
int m_dataFormat; int m_dataFormat;
int m_memoryRegion; int m_memoryRegion;
void buildFromQWidget(QWidget* widget); void buildFromQWidget(QWidget *widget);
void applyToQWidget(QWidget* widget); void applyToQWidget(QWidget *widget);
void addToXmlDataNode(util::xml::data_node &node) const; void addToXmlDataNode(util::xml::data_node &node) const;
void recoverFromXmlNode(util::xml::data_node const &node); void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_MEMORYWINDOW_H

View File

@ -1,19 +1,20 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#include "emu.h" #include "emu.h"
#include "windowqt.h"
#include "breakpointswindow.h"
#include "dasmwindow.h"
#include "deviceswindow.h"
#include "logwindow.h"
#include "memorywindow.h"
#include "debug/debugcon.h"
#include "debug/debugcpu.h"
#include <QtWidgets/QMenu> #include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar> #include <QtWidgets/QMenuBar>
#include "windowqt.h"
#include "logwindow.h"
#include "dasmwindow.h"
#include "memorywindow.h"
#include "breakpointswindow.h"
#include "deviceswindow.h"
#include "debug/debugcpu.h"
#include "debug/debugcon.h"
bool WindowQt::s_refreshAll = false; bool WindowQt::s_refreshAll = false;
bool WindowQt::s_hideAll = false; bool WindowQt::s_hideAll = false;
@ -23,83 +24,83 @@ bool WindowQt::s_hideAll = false;
// however, is often used to place each child window & the code to do this can // however, is often used to place each child window & the code to do this can
// be found in most of the inherited classes. // be found in most of the inherited classes.
WindowQt::WindowQt(running_machine* machine, QWidget* parent) : WindowQt::WindowQt(running_machine &machine, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
m_machine(machine) m_machine(machine)
{ {
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
// The Debug menu bar // The Debug menu bar
QAction* debugActOpenMemory = new QAction("New &Memory Window", this); QAction *debugActOpenMemory = new QAction("New &Memory Window", this);
debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M")); debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M"));
connect(debugActOpenMemory, &QAction::triggered, this, &WindowQt::debugActOpenMemory); connect(debugActOpenMemory, &QAction::triggered, this, &WindowQt::debugActOpenMemory);
QAction* debugActOpenDasm = new QAction("New &Dasm Window", this); QAction *debugActOpenDasm = new QAction("New &Dasm Window", this);
debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D")); debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D"));
connect(debugActOpenDasm, &QAction::triggered, this, &WindowQt::debugActOpenDasm); connect(debugActOpenDasm, &QAction::triggered, this, &WindowQt::debugActOpenDasm);
QAction* debugActOpenLog = new QAction("New &Log Window", this); QAction *debugActOpenLog = new QAction("New &Log Window", this);
debugActOpenLog->setShortcut(QKeySequence("Ctrl+L")); debugActOpenLog->setShortcut(QKeySequence("Ctrl+L"));
connect(debugActOpenLog, &QAction::triggered, this, &WindowQt::debugActOpenLog); connect(debugActOpenLog, &QAction::triggered, this, &WindowQt::debugActOpenLog);
QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this); QAction *debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this);
debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B"));
connect(debugActOpenPoints, &QAction::triggered, this, &WindowQt::debugActOpenPoints); connect(debugActOpenPoints, &QAction::triggered, this, &WindowQt::debugActOpenPoints);
QAction* debugActOpenDevices = new QAction("New D&evices Window", this); QAction *debugActOpenDevices = new QAction("New D&evices Window", this);
debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D"));
connect(debugActOpenDevices, &QAction::triggered, this, &WindowQt::debugActOpenDevices); connect(debugActOpenDevices, &QAction::triggered, this, &WindowQt::debugActOpenDevices);
QAction* dbgActRun = new QAction("Run", this); QAction *dbgActRun = new QAction("Run", this);
dbgActRun->setShortcut(Qt::Key_F5); dbgActRun->setShortcut(Qt::Key_F5);
connect(dbgActRun, &QAction::triggered, this, &WindowQt::debugActRun); connect(dbgActRun, &QAction::triggered, this, &WindowQt::debugActRun);
QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this); QAction *dbgActRunAndHide = new QAction("Run And Hide Debugger", this);
dbgActRunAndHide->setShortcut(Qt::Key_F12); dbgActRunAndHide->setShortcut(Qt::Key_F12);
connect(dbgActRunAndHide, &QAction::triggered, this, &WindowQt::debugActRunAndHide); connect(dbgActRunAndHide, &QAction::triggered, this, &WindowQt::debugActRunAndHide);
QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this); QAction *dbgActRunToNextCpu = new QAction("Run to Next CPU", this);
dbgActRunToNextCpu->setShortcut(Qt::Key_F6); dbgActRunToNextCpu->setShortcut(Qt::Key_F6);
connect(dbgActRunToNextCpu, &QAction::triggered, this, &WindowQt::debugActRunToNextCpu); connect(dbgActRunToNextCpu, &QAction::triggered, this, &WindowQt::debugActRunToNextCpu);
QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this); QAction *dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this);
dbgActRunNextInt->setShortcut(Qt::Key_F7); dbgActRunNextInt->setShortcut(Qt::Key_F7);
connect(dbgActRunNextInt, &QAction::triggered, this, &WindowQt::debugActRunNextInt); connect(dbgActRunNextInt, &QAction::triggered, this, &WindowQt::debugActRunNextInt);
QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this); QAction *dbgActRunNextVBlank = new QAction("Run to Next VBlank", this);
dbgActRunNextVBlank->setShortcut(Qt::Key_F8); dbgActRunNextVBlank->setShortcut(Qt::Key_F8);
connect(dbgActRunNextVBlank, &QAction::triggered, this, &WindowQt::debugActRunNextVBlank); connect(dbgActRunNextVBlank, &QAction::triggered, this, &WindowQt::debugActRunNextVBlank);
QAction* dbgActStepInto = new QAction("Step Into", this); QAction *dbgActStepInto = new QAction("Step Into", this);
dbgActStepInto->setShortcut(Qt::Key_F11); dbgActStepInto->setShortcut(Qt::Key_F11);
connect(dbgActStepInto, &QAction::triggered, this, &WindowQt::debugActStepInto); connect(dbgActStepInto, &QAction::triggered, this, &WindowQt::debugActStepInto);
QAction* dbgActStepOver = new QAction("Step Over", this); QAction *dbgActStepOver = new QAction("Step Over", this);
dbgActStepOver->setShortcut(Qt::Key_F10); dbgActStepOver->setShortcut(Qt::Key_F10);
connect(dbgActStepOver, &QAction::triggered, this, &WindowQt::debugActStepOver); connect(dbgActStepOver, &QAction::triggered, this, &WindowQt::debugActStepOver);
QAction* dbgActStepOut = new QAction("Step Out", this); QAction *dbgActStepOut = new QAction("Step Out", this);
dbgActStepOut->setShortcut(QKeySequence("Shift+F11")); dbgActStepOut->setShortcut(QKeySequence("Shift+F11"));
connect(dbgActStepOut, &QAction::triggered, this, &WindowQt::debugActStepOut); connect(dbgActStepOut, &QAction::triggered, this, &WindowQt::debugActStepOut);
QAction* dbgActSoftReset = new QAction("Soft Reset", this); QAction *dbgActSoftReset = new QAction("Soft Reset", this);
dbgActSoftReset->setShortcut(Qt::Key_F3); dbgActSoftReset->setShortcut(Qt::Key_F3);
connect(dbgActSoftReset, &QAction::triggered, this, &WindowQt::debugActSoftReset); connect(dbgActSoftReset, &QAction::triggered, this, &WindowQt::debugActSoftReset);
QAction* dbgActHardReset = new QAction("Hard Reset", this); QAction *dbgActHardReset = new QAction("Hard Reset", this);
dbgActHardReset->setShortcut(QKeySequence("Shift+F3")); dbgActHardReset->setShortcut(QKeySequence("Shift+F3"));
connect(dbgActHardReset, &QAction::triggered, this, &WindowQt::debugActHardReset); connect(dbgActHardReset, &QAction::triggered, this, &WindowQt::debugActHardReset);
QAction* dbgActClose = new QAction("Close &Window", this); QAction *dbgActClose = new QAction("Close &Window", this);
dbgActClose->setShortcut(QKeySequence::Close); dbgActClose->setShortcut(QKeySequence::Close);
connect(dbgActClose, &QAction::triggered, this, &WindowQt::debugActClose); connect(dbgActClose, &QAction::triggered, this, &WindowQt::debugActClose);
QAction* dbgActQuit = new QAction("&Quit", this); QAction *dbgActQuit = new QAction("&Quit", this);
dbgActQuit->setShortcut(QKeySequence::Quit); dbgActQuit->setShortcut(QKeySequence::Quit);
connect(dbgActQuit, &QAction::triggered, this, &WindowQt::debugActQuit); connect(dbgActQuit, &QAction::triggered, this, &WindowQt::debugActQuit);
// Construct the menu // Construct the menu
QMenu* debugMenu = menuBar()->addMenu("&Debug"); QMenu *debugMenu = menuBar()->addMenu("&Debug");
debugMenu->addAction(debugActOpenMemory); debugMenu->addAction(debugActOpenMemory);
debugMenu->addAction(debugActOpenDasm); debugMenu->addAction(debugActOpenDasm);
debugMenu->addAction(debugActOpenLog); debugMenu->addAction(debugActOpenLog);
@ -130,7 +131,7 @@ WindowQt::~WindowQt()
void WindowQt::debugActOpenMemory() void WindowQt::debugActOpenMemory()
{ {
MemoryWindow* foo = new MemoryWindow(m_machine, this); MemoryWindow *foo = new MemoryWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog); // foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@ -140,7 +141,7 @@ void WindowQt::debugActOpenMemory()
void WindowQt::debugActOpenDasm() void WindowQt::debugActOpenDasm()
{ {
DasmWindow* foo = new DasmWindow(m_machine, this); DasmWindow *foo = new DasmWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog); // foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@ -150,7 +151,7 @@ void WindowQt::debugActOpenDasm()
void WindowQt::debugActOpenLog() void WindowQt::debugActOpenLog()
{ {
LogWindow* foo = new LogWindow(m_machine, this); LogWindow *foo = new LogWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog); // foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@ -160,7 +161,7 @@ void WindowQt::debugActOpenLog()
void WindowQt::debugActOpenPoints() void WindowQt::debugActOpenPoints()
{ {
BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this); BreakpointsWindow *foo = new BreakpointsWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog); // foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@ -170,7 +171,7 @@ void WindowQt::debugActOpenPoints()
void WindowQt::debugActOpenDevices() void WindowQt::debugActOpenDevices()
{ {
DevicesWindow* foo = new DevicesWindow(m_machine, this); DevicesWindow *foo = new DevicesWindow(m_machine, this);
// A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon
// foo->setWindowFlags(Qt::Dialog); // foo->setWindowFlags(Qt::Dialog);
// foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint);
@ -180,54 +181,54 @@ void WindowQt::debugActOpenDevices()
void WindowQt::debugActRun() void WindowQt::debugActRun()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->go(); m_machine.debugger().console().get_visible_cpu()->debug()->go();
} }
void WindowQt::debugActRunAndHide() void WindowQt::debugActRunAndHide()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->go(); m_machine.debugger().console().get_visible_cpu()->debug()->go();
hideAll(); hideAll();
} }
void WindowQt::debugActRunToNextCpu() void WindowQt::debugActRunToNextCpu()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->go_next_device(); m_machine.debugger().console().get_visible_cpu()->debug()->go_next_device();
} }
void WindowQt::debugActRunNextInt() void WindowQt::debugActRunNextInt()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->go_interrupt(); m_machine.debugger().console().get_visible_cpu()->debug()->go_interrupt();
} }
void WindowQt::debugActRunNextVBlank() void WindowQt::debugActRunNextVBlank()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->go_vblank(); m_machine.debugger().console().get_visible_cpu()->debug()->go_vblank();
} }
void WindowQt::debugActStepInto() void WindowQt::debugActStepInto()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->single_step(); m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
} }
void WindowQt::debugActStepOver() void WindowQt::debugActStepOver()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->single_step_over(); m_machine.debugger().console().get_visible_cpu()->debug()->single_step_over();
} }
void WindowQt::debugActStepOut() void WindowQt::debugActStepOut()
{ {
m_machine->debugger().console().get_visible_cpu()->debug()->single_step_out(); m_machine.debugger().console().get_visible_cpu()->debug()->single_step_out();
} }
void WindowQt::debugActSoftReset() void WindowQt::debugActSoftReset()
{ {
m_machine->schedule_soft_reset(); m_machine.schedule_soft_reset();
m_machine->debugger().console().get_visible_cpu()->debug()->single_step(); m_machine.debugger().console().get_visible_cpu()->debug()->single_step();
} }
void WindowQt::debugActHardReset() void WindowQt::debugActHardReset()
{ {
m_machine->schedule_hard_reset(); m_machine.schedule_hard_reset();
} }
void WindowQt::debugActClose() void WindowQt::debugActClose()
@ -237,14 +238,14 @@ void WindowQt::debugActClose()
void WindowQt::debugActQuit() void WindowQt::debugActQuit()
{ {
m_machine->schedule_exit(); m_machine.schedule_exit();
} }
//========================================================================= //=========================================================================
// WindowQtConfig // WindowQtConfig
//========================================================================= //=========================================================================
void WindowQtConfig::buildFromQWidget(QWidget* widget) void WindowQtConfig::buildFromQWidget(QWidget *widget)
{ {
m_position.setX(widget->geometry().topLeft().x()); m_position.setX(widget->geometry().topLeft().x());
m_position.setY(widget->geometry().topLeft().y()); m_position.setY(widget->geometry().topLeft().y());
@ -253,7 +254,7 @@ void WindowQtConfig::buildFromQWidget(QWidget* widget)
} }
void WindowQtConfig::applyToQWidget(QWidget* widget) void WindowQtConfig::applyToQWidget(QWidget *widget)
{ {
widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y()); widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y());
} }

View File

@ -1,13 +1,13 @@
// license:BSD-3-Clause // license:BSD-3-Clause
// copyright-holders:Andrew Gardner // copyright-holders:Andrew Gardner
#ifndef __DEBUG_QT_WINDOW_QT_H__ #ifndef MAME_DEBUGGER_QT_WINDOWQT_H
#define __DEBUG_QT_WINDOW_QT_H__ #define MAME_DEBUGGER_QT_WINDOWQT_H
#include <QtWidgets/QMainWindow>
#include "config.h" #include "config.h"
#include "debugger.h" #include "debugger.h"
#include <QtWidgets/QMainWindow>
//============================================================ //============================================================
// The Qt window that everyone derives from. // The Qt window that everyone derives from.
@ -17,7 +17,7 @@ class WindowQt : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
WindowQt(running_machine* machine, QWidget* parent=nullptr); WindowQt(running_machine &machine, QWidget *parent = nullptr);
virtual ~WindowQt(); virtual ~WindowQt();
// The interface to an all-window refresh // The interface to an all-window refresh
@ -51,7 +51,7 @@ protected slots:
protected: protected:
running_machine* m_machine; running_machine &m_machine;
static bool s_refreshAll; static bool s_refreshAll;
static bool s_hideAll; static bool s_hideAll;
@ -89,11 +89,11 @@ public:
QPoint m_size; QPoint m_size;
QPoint m_position; QPoint m_position;
virtual void buildFromQWidget(QWidget* widget); virtual void buildFromQWidget(QWidget *widget);
virtual void applyToQWidget(QWidget* widget); virtual void applyToQWidget(QWidget *widget);
virtual void addToXmlDataNode(util::xml::data_node &node) const; virtual void addToXmlDataNode(util::xml::data_node &node) const;
virtual void recoverFromXmlNode(util::xml::data_node const &node); virtual void recoverFromXmlNode(util::xml::data_node const &node);
}; };
#endif #endif // MAME_DEBUGGER_QT_WINDOWQT_H