diff options
author | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-22 22:05:19 +0100 |
---|---|---|
committer | Pavel Pisa <pisa@cmp.felk.cvut.cz> | 2019-02-22 22:05:19 +0100 |
commit | b7c2d05a1a83dd91052ca6df20c2f60c802e773e (patch) | |
tree | 9dae0d407c0848b9f703bbbc37278d445e04158b /qtmips_gui | |
parent | 372af906107bceed8a174d5aa907034d35cfe760 (diff) | |
download | qtmips-b7c2d05a1a83dd91052ca6df20c2f60c802e773e.tar.gz qtmips-b7c2d05a1a83dd91052ca6df20c2f60c802e773e.tar.bz2 qtmips-b7c2d05a1a83dd91052ca6df20c2f60c802e773e.zip |
Add support for goto to selected symbol address.
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/MainWindow.ui | 8 | ||||
-rw-r--r-- | qtmips_gui/gotosymboldialog.cpp | 32 | ||||
-rw-r--r-- | qtmips_gui/gotosymboldialog.h | 30 | ||||
-rw-r--r-- | qtmips_gui/gotosymboldialog.ui | 88 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 19 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.h | 1 | ||||
-rw-r--r-- | qtmips_gui/memorydock.cpp | 2 | ||||
-rw-r--r-- | qtmips_gui/memorydock.h | 1 | ||||
-rw-r--r-- | qtmips_gui/qtmips_gui.pro | 9 |
9 files changed, 186 insertions, 4 deletions
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 @@ <string>Terminal</string> </property> </action> + <action name="actionShow_Symbol"> + <property name="text"> + <string>Show Symbol</string> + </property> + <property name="toolTip"> + <string>Show Symbol</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources> 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 <QDialog> +#include <QList> +#include <QStringList> + +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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GoToSymbolDialog</class> + <widget class="QDialog" name="GoToSymbolDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>331</height> + </rect> + </property> + <property name="windowTitle"> + <string>Go To Symbol DIalog</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetMaximumSize</enum> + </property> + <item> + <widget class="QListWidget" name="listSymbols"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QPushButton" name="pushShowProg"> + <property name="text"> + <string>Show program</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushShowMem"> + <property name="text"> + <string>Show memory</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pushClose"> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <tabstops> + <tabstop>listSymbols</tabstop> + <tabstop>pushShowProg</tabstop> + <tabstop>pushShowMem</tabstop> + <tabstop>pushClose</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> 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 |