Skip to content

Commit

Permalink
Allow movement from a register value to a memory value
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Apr 15, 2023
1 parent e657aa9 commit f18a2db
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/memoryviewerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ MemoryViewerWidget::MemoryViewerWidget(QWidget *parent)
[=] { setEnabled(true); });
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun,
this, [=] { this->updateView(); });
connect(ProcessorHandler::get(), &ProcessorHandler::memoryFocusAddressChanged,
this, &MemoryViewerWidget::setCentralAddress);
}

MemoryViewerWidget::~MemoryViewerWidget() { delete m_ui; }
Expand Down
8 changes: 8 additions & 0 deletions src/processorhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ class ProcessorHandler : public QObject {
/// Returns true if the simulator is currently in "run" mode.
static bool isRunning() { return get()->_isRunning(); }

static void setMemoryFocusAddress(AInt address) {
emit get()->memoryFocusAddressChanged(address);
}

/**
* @brief run
* Asynchronously runs the current processor. During this, the processor will
Expand Down Expand Up @@ -249,6 +253,10 @@ class ProcessorHandler : public QObject {
void procStateChangedNonRun(); // processorReset | processorReversed |
// processorClockedNonRun

// Emitted whenever the global memory focus address for the application should
// change.
void memoryFocusAddressChanged(AInt address);

private slots:
/**
* @brief syscallTrap
Expand Down
14 changes: 10 additions & 4 deletions src/registerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ void RegisterWidget::showContextMenu(const QPoint &pos) {
// If the register is not read only, add "set register value" action.
if (m_model->flags(index) & Qt::ItemIsEditable) {
menu.addAction("Set register value", [&]() {
// A dialog which says "Register value"
// A text field which is pre-filled with the current value of the register
// A button which says "Set"
// A button which says "Cancel"
QInputDialog dialog(this);
dialog.setWindowTitle("Set register value");
dialog.setLabelText("Register value");
Expand All @@ -88,6 +84,16 @@ void RegisterWidget::showContextMenu(const QPoint &pos) {
});
}

auto goToAddressAction = QAction("Go to address");
goToAddressAction.setToolTip("Make all memory viewers move to the address "
"contained in the selected register");
connect(&goToAddressAction, &QAction::triggered, [&]() {
const auto address = m_model->data(index, Qt::EditRole).toULongLong();
ProcessorHandler::setMemoryFocusAddress(address);
});
menu.addAction(&goToAddressAction);
menu.setToolTipsVisible(true);

menu.exec(m_ui->registerView->viewport()->mapToGlobal(pos));
}

Expand Down

0 comments on commit f18a2db

Please sign in to comment.