From b7c2d05a1a83dd91052ca6df20c2f60c802e773e Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Fri, 22 Feb 2019 22:05:19 +0100 Subject: Add support for goto to selected symbol address. Signed-off-by: Pavel Pisa --- qtmips_gui/MainWindow.ui | 8 ++++ qtmips_gui/gotosymboldialog.cpp | 32 +++++++++++++++ qtmips_gui/gotosymboldialog.h | 30 ++++++++++++++ qtmips_gui/gotosymboldialog.ui | 88 +++++++++++++++++++++++++++++++++++++++++ qtmips_gui/mainwindow.cpp | 19 ++++++++- qtmips_gui/mainwindow.h | 1 + qtmips_gui/memorydock.cpp | 2 + qtmips_gui/memorydock.h | 1 + qtmips_gui/qtmips_gui.pro | 9 +++-- 9 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 qtmips_gui/gotosymboldialog.cpp create mode 100644 qtmips_gui/gotosymboldialog.h create mode 100644 qtmips_gui/gotosymboldialog.ui (limited to 'qtmips_gui') diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui index 27bc045..755f539 100644 --- a/qtmips_gui/MainWindow.ui +++ b/qtmips_gui/MainWindow.ui @@ -373,6 +373,14 @@ Terminal + + + Show Symbol + + + Show Symbol + + diff --git a/qtmips_gui/gotosymboldialog.cpp b/qtmips_gui/gotosymboldialog.cpp new file mode 100644 index 0000000..59927f2 --- /dev/null +++ b/qtmips_gui/gotosymboldialog.cpp @@ -0,0 +1,32 @@ +#include "gotosymboldialog.h" +#include "ui_gotosymboldialog.h" + +GoToSymbolDialog::GoToSymbolDialog(QWidget *parent, QStringList &symlist) : + QDialog(parent), + ui(new Ui::GoToSymbolDialog) +{ + ui->setupUi(this); + + connect(ui->pushShowProg, SIGNAL(clicked()), this, SLOT(show_prog())); + connect(ui->pushShowMem, SIGNAL(clicked()), this, SLOT(show_mem())); + connect(ui->pushClose, SIGNAL(clicked()), this, SLOT(close())); + + ui->listSymbols->addItems(symlist); +} + +GoToSymbolDialog::~GoToSymbolDialog() +{ + delete ui; +} + +void GoToSymbolDialog::show_prog() { + std::uint32_t address = 0; + emit obtain_value_for_name(address, ui->listSymbols->currentItem()->text()); + emit program_focus_addr(address); +} + +void GoToSymbolDialog::show_mem() { + std::uint32_t address = 0; + emit obtain_value_for_name(address, ui->listSymbols->currentItem()->text()); + emit memory_focus_addr(address); +} diff --git a/qtmips_gui/gotosymboldialog.h b/qtmips_gui/gotosymboldialog.h new file mode 100644 index 0000000..27e8df2 --- /dev/null +++ b/qtmips_gui/gotosymboldialog.h @@ -0,0 +1,30 @@ +#ifndef GOTOSYMBOLDIALOG_H +#define GOTOSYMBOLDIALOG_H + +#include +#include +#include + +namespace Ui { +class GoToSymbolDialog; +} + +class GoToSymbolDialog : public QDialog +{ + Q_OBJECT + +public: + explicit GoToSymbolDialog(QWidget *parent, QStringList &symlist); + ~GoToSymbolDialog(); +signals: + void program_focus_addr(std::uint32_t); + void memory_focus_addr(std::uint32_t); + bool obtain_value_for_name(std::uint32_t &value, QString name) const; +public slots: + void show_prog(); + void show_mem(); +private: + Ui::GoToSymbolDialog *ui; +}; + +#endif // GOTOSYMBOLDIALOG_H diff --git a/qtmips_gui/gotosymboldialog.ui b/qtmips_gui/gotosymboldialog.ui new file mode 100644 index 0000000..f5b24e7 --- /dev/null +++ b/qtmips_gui/gotosymboldialog.ui @@ -0,0 +1,88 @@ + + + GoToSymbolDialog + + + + 0 + 0 + 400 + 331 + + + + Go To Symbol DIalog + + + + + + QLayout::SetMaximumSize + + + + + + + + + + Show program + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Show memory + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + + listSymbols + pushShowProg + pushShowMem + pushClose + + + + diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index bbb3a3b..253ab03 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -37,6 +37,7 @@ #include "aboutdialog.h" #include "ossyscall.h" #include "fontsize.h" +#include "gotosymboldialog.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { machine = nullptr; @@ -81,6 +82,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); connect(ui->actionReload, SIGNAL(triggered(bool)), this, SLOT(machine_reload())); + connect(ui->actionShow_Symbol, SIGNAL(triggered(bool)), this, SLOT(show_symbol_dialog())); connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); connect(ui->actionProgram_memory, SIGNAL(triggered(bool)), this, SLOT(show_program())); connect(ui->actionMemory, SIGNAL(triggered(bool)), this, SLOT(show_memory())); @@ -129,7 +131,7 @@ void MainWindow::start() { void MainWindow::create_core(const machine::MachineConfig &config) { // Create machine - machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config); + machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config, true); // Remove old machine if (machine != nullptr) @@ -235,6 +237,21 @@ SHOW_HANDLER(peripherals) SHOW_HANDLER(terminal) #undef SHOW_HANDLER +void MainWindow::show_symbol_dialog(){ + if (machine == nullptr || machine->symbol_table() == nullptr) + return; + QStringList *symnames = machine->symbol_table()->names(); + GoToSymbolDialog *gotosyboldialog = new GoToSymbolDialog(this, *symnames); + connect(gotosyboldialog, SIGNAL(program_focus_addr(std::uint32_t)), + program, SIGNAL(focus_addr(std::uint32_t))); + connect(gotosyboldialog, SIGNAL(memory_focus_addr(std::uint32_t)), + memory, SIGNAL(focus_addr(std::uint32_t))); + connect(gotosyboldialog, SIGNAL(obtain_value_for_name(std::uint32_t&,QString)), + machine->symbol_table(), SLOT(name_to_value(std::uint32_t&,QString))); + gotosyboldialog->exec(); + delete symnames; +} + void MainWindow::about_qtmips() { AboutDialog *aboutdialog = new AboutDialog(this); diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 61e6896..796dd33 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -74,6 +74,7 @@ public slots: void show_cache_program(); void show_peripherals(); void show_terminal(); + void show_symbol_dialog(); // Actions - help menu void about_qtmips(); void about_qt(); diff --git a/qtmips_gui/memorydock.cpp b/qtmips_gui/memorydock.cpp index 323f053..2e0f780 100644 --- a/qtmips_gui/memorydock.cpp +++ b/qtmips_gui/memorydock.cpp @@ -91,6 +91,8 @@ MemoryDock::MemoryDock(QWidget *parent, QSettings *settings) : Super(parent) { memory_content, SLOT(go_to_address(std::uint32_t))); connect(memory_content, SIGNAL(address_changed(std::uint32_t)), go_edit, SLOT(set_value(std::uint32_t))); + connect(this, SIGNAL(focus_addr(std::uint32_t)), + memory_content, SLOT(focus_address(std::uint32_t))); } void MemoryDock::setup(machine::QtMipsMachine *machine) { diff --git a/qtmips_gui/memorydock.h b/qtmips_gui/memorydock.h index 5dd366f..b7e1f85 100644 --- a/qtmips_gui/memorydock.h +++ b/qtmips_gui/memorydock.h @@ -53,6 +53,7 @@ public: signals: void machine_setup(machine::QtMipsMachine *machine); + void focus_addr(std::uint32_t); private: diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 541798a..acdbd55 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -61,7 +61,8 @@ SOURCES += \ terminaldock.cpp \ peripheralsview.cpp \ coreview/multitext.cpp \ - fontsize.cpp + fontsize.cpp \ + gotosymboldialog.cpp HEADERS += \ mainwindow.h \ @@ -98,13 +99,15 @@ HEADERS += \ terminaldock.h \ peripheralsview.h \ coreview/multitext.h \ - fontsize.h + fontsize.h \ + gotosymboldialog.h FORMS += \ NewDialog.ui \ NewDialogCache.ui \ MainWindow.ui \ - peripheralsview.ui + peripheralsview.ui \ + gotosymboldialog.ui RESOURCES += \ icons.qrc -- cgit v1.2.3