aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-22 22:05:19 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-22 22:05:19 +0100
commitb7c2d05a1a83dd91052ca6df20c2f60c802e773e (patch)
tree9dae0d407c0848b9f703bbbc37278d445e04158b
parent372af906107bceed8a174d5aa907034d35cfe760 (diff)
downloadqtmips-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>
-rw-r--r--qtmips_gui/MainWindow.ui8
-rw-r--r--qtmips_gui/gotosymboldialog.cpp32
-rw-r--r--qtmips_gui/gotosymboldialog.h30
-rw-r--r--qtmips_gui/gotosymboldialog.ui88
-rw-r--r--qtmips_gui/mainwindow.cpp19
-rw-r--r--qtmips_gui/mainwindow.h1
-rw-r--r--qtmips_gui/memorydock.cpp2
-rw-r--r--qtmips_gui/memorydock.h1
-rw-r--r--qtmips_gui/qtmips_gui.pro9
-rw-r--r--qtmips_machine/programloader.cpp33
-rw-r--r--qtmips_machine/programloader.h2
-rw-r--r--qtmips_machine/qtmips_machine.pro6
-rw-r--r--qtmips_machine/qtmipsmachine.cpp13
-rw-r--r--qtmips_machine/qtmipsmachine.h5
-rw-r--r--qtmips_machine/symboltable.cpp98
-rw-r--r--qtmips_machine/symboltable.h82
16 files changed, 421 insertions, 8 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
diff --git a/qtmips_machine/programloader.cpp b/qtmips_machine/programloader.cpp
index 750fd00..859bab4 100644
--- a/qtmips_machine/programloader.cpp
+++ b/qtmips_machine/programloader.cpp
@@ -130,3 +130,36 @@ std::uint32_t ProgramLoader::end() {
std::uint32_t ProgramLoader::get_executable_entry() {
return executable_entry;
}
+
+SymbolTable *ProgramLoader::get_symbol_table() {
+ SymbolTable *p_st = new SymbolTable();
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr;
+ Elf_Data *data;
+ int count, ii;
+
+ elf_version(EV_CURRENT);
+
+ while (1) {
+ if ((scn = elf_nextscn(this->elf, scn)) == NULL)
+ return p_st;
+ gelf_getshdr(scn, &shdr);
+ if (shdr.sh_type == SHT_SYMTAB) {
+ /* found a symbol table, go print it. */
+ break;
+ }
+ }
+
+ data = elf_getdata(scn, NULL);
+ count = shdr.sh_size / shdr.sh_entsize;
+
+ /* rettrieve the symbol names */
+ for (ii = 0; ii < count; ++ii) {
+ GElf_Sym sym;
+ gelf_getsym(data, ii, &sym);
+ p_st->add_symbol(elf_strptr(elf, shdr.sh_link, sym.st_name),
+ sym.st_value, sym.st_size, sym.st_info, sym.st_other);
+ }
+
+ return p_st;
+}
diff --git a/qtmips_machine/programloader.h b/qtmips_machine/programloader.h
index 607bdb0..b275c2f 100644
--- a/qtmips_machine/programloader.h
+++ b/qtmips_machine/programloader.h
@@ -43,6 +43,7 @@
#include <qvector.h>
#include <qstring.h>
#include <memory.h>
+#include "symboltable.h"
namespace machine {
@@ -55,6 +56,7 @@ public:
void to_memory(Memory *mem); // Writes all loaded sections to memory
std::uint32_t end(); // Return address after which there is no more code for sure
std::uint32_t get_executable_entry();
+ SymbolTable *get_symbol_table();
private:
int fd;
Elf *elf;
diff --git a/qtmips_machine/qtmips_machine.pro b/qtmips_machine/qtmips_machine.pro
index 961800c..9964357 100644
--- a/qtmips_machine/qtmips_machine.pro
+++ b/qtmips_machine/qtmips_machine.pro
@@ -27,7 +27,8 @@ SOURCES += \
physaddrspace.cpp \
peripheral.cpp \
serialport.cpp \
- peripspiled.cpp
+ peripspiled.cpp \
+ symboltable.cpp
HEADERS += \
qtmipsmachine.h \
@@ -45,4 +46,5 @@ HEADERS += \
physaddrspace.h \
peripheral.h \
serialport.h \
- peripspiled.h
+ peripspiled.h \
+ symboltable.h
diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp
index 37e5461..e1ecf93 100644
--- a/qtmips_machine/qtmipsmachine.cpp
+++ b/qtmips_machine/qtmipsmachine.cpp
@@ -39,13 +39,17 @@
using namespace machine;
-QtMipsMachine::QtMipsMachine(const MachineConfig &cc) : QObject(), mcnf(&cc) {
+QtMipsMachine::QtMipsMachine(const MachineConfig &cc, bool load_symtab) :
+ QObject(), mcnf(&cc) {
MemoryAccess *cpu_mem;
stat = ST_READY;
+ symtab = nullptr;
ProgramLoader program(cc.elf());
mem_program_only = new Memory();
program.to_memory(mem_program_only);
+ if (load_symtab)
+ symtab = program.get_symbol_table();
program_end = program.end();
regs = new Registers();
if (program.get_executable_entry())
@@ -102,6 +106,9 @@ QtMipsMachine::~QtMipsMachine() {
if (mem_program_only != nullptr)
delete mem_program_only;
mem_program_only = nullptr;
+ if (symtab != nullptr)
+ delete symtab;
+ symtab = nullptr;
}
const MachineConfig &QtMipsMachine::config() {
@@ -145,6 +152,10 @@ PeripSpiLed *QtMipsMachine::peripheral_spi_led() {
return perip_spi_led;
}
+const SymbolTable *QtMipsMachine::symbol_table() {
+ return symtab;
+}
+
const Core *QtMipsMachine::core() {
return cr;
}
diff --git a/qtmips_machine/qtmipsmachine.h b/qtmips_machine/qtmipsmachine.h
index b49cb2f..1c80b9c 100644
--- a/qtmips_machine/qtmipsmachine.h
+++ b/qtmips_machine/qtmipsmachine.h
@@ -49,13 +49,14 @@
#include <peripheral.h>
#include <serialport.h>
#include <peripspiled.h>
+#include <symboltable.h>
namespace machine {
class QtMipsMachine : public QObject {
Q_OBJECT
public:
- QtMipsMachine(const MachineConfig &cc);
+ QtMipsMachine(const MachineConfig &cc, bool load_symtab = false);
~QtMipsMachine();
const MachineConfig &config();
@@ -69,6 +70,7 @@ public:
Cache *cache_data_rw();
SerialPort *serial_port();
PeripSpiLed *peripheral_spi_led();
+ const SymbolTable *symbol_table();
const Core *core();
const CoreSingle *core_singe();
const CorePipelined *core_pipelined();
@@ -122,6 +124,7 @@ private:
QTimer *run_t;
unsigned int time_chunk;
+ SymbolTable *symtab;
std::uint32_t program_end;
enum Status stat;
void set_status(enum Status st);
diff --git a/qtmips_machine/symboltable.cpp b/qtmips_machine/symboltable.cpp
new file mode 100644
index 0000000..f22acaa
--- /dev/null
+++ b/qtmips_machine/symboltable.cpp
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*******************************************************************************
+ * QtMips - MIPS 32-bit Architecture Subset Simulator
+ *
+ * Implemented to support following courses:
+ *
+ * B35APO - Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b35apo
+ *
+ * B4M35PAP - Advanced Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start
+ *
+ * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz>
+ * Copyright (c) 2019 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ *
+ * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
+ * Czech Technical University (http://www.cvut.cz/)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ ******************************************************************************/
+
+#include "symboltable.h"
+
+using namespace machine;
+
+SymbolTableEntry::SymbolTableEntry(QString name, std::uint32_t value,
+ std::uint32_t size, unsigned char info, unsigned char other) {
+ this->name = name;
+ this->value = value;
+ this->size = size;
+ this->info = info;
+ this->other = other;
+}
+
+SymbolTable::SymbolTable(QObject *parent) : QObject(parent),
+ map_value_to_symbol(), map_name_to_symbol() {
+}
+
+SymbolTable::~SymbolTable() {
+ while (!map_value_to_symbol.isEmpty()) {
+ SymbolTableEntry *p_ste = map_value_to_symbol.first();
+ p_ste = map_value_to_symbol.take(p_ste->value);
+ map_name_to_symbol.remove(p_ste->name);
+ delete p_ste;
+ }
+}
+
+void SymbolTable::add_symbol(QString name, std::uint32_t value, std::uint32_t size,
+ unsigned char info, unsigned char other) {
+ SymbolTableEntry *p_ste = new SymbolTableEntry(name, value, size, info, other);
+ map_value_to_symbol.insert(value, p_ste);
+ map_name_to_symbol.insert(name, p_ste);
+}
+
+bool SymbolTable::name_to_value(std::uint32_t &value, QString name) const {
+ SymbolTableEntry *p_ste = map_name_to_symbol.value(name);
+ if (p_ste == nullptr) {
+ value = 0;
+ return false;
+ }
+ value = p_ste->value;
+ return true;
+}
+
+bool SymbolTable::value_to_name(QString &name, std::uint32_t value) const {
+ SymbolTableEntry *p_ste = map_value_to_symbol.value(value);
+ if (p_ste == nullptr) {
+ name = "";
+ return false;
+ }
+ name = p_ste->name;
+ return true;
+}
+
+QStringList *SymbolTable::names() const {
+ QStringList *l = new QStringList();
+
+ auto i = map_name_to_symbol.begin();
+ while (i != map_name_to_symbol.end()) {
+ l->append(i.value()->name);
+ i++;
+ }
+ return l;
+}
diff --git a/qtmips_machine/symboltable.h b/qtmips_machine/symboltable.h
new file mode 100644
index 0000000..174917c
--- /dev/null
+++ b/qtmips_machine/symboltable.h
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*******************************************************************************
+ * QtMips - MIPS 32-bit Architecture Subset Simulator
+ *
+ * Implemented to support following courses:
+ *
+ * B35APO - Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b35apo
+ *
+ * B4M35PAP - Advanced Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start
+ *
+ * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz>
+ * Copyright (c) 2019 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ *
+ * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
+ * Czech Technical University (http://www.cvut.cz/)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ ******************************************************************************/
+
+#ifndef SYMBOLTABLE_H
+#define SYMBOLTABLE_H
+
+#include <QString>
+#include <QObject>
+#include <QMap>
+#include <QMultiMap>
+#include <QStringList>
+
+namespace machine {
+
+class SymbolTableEntry {
+ friend class SymbolTable;
+ SymbolTableEntry(QString name, std::uint32_t value, std::uint32_t size,
+ unsigned char info = 0, unsigned char other = 0);
+protected:
+ QString name;
+ std::uint32_t value;
+ std::uint32_t size;
+ unsigned char info;
+ unsigned char other;
+};
+
+class SymbolTable : public QObject
+{
+ Q_OBJECT
+public:
+ SymbolTable(QObject *parent = 0);
+ ~SymbolTable();
+
+ void add_symbol(QString name, std::uint32_t value, std::uint32_t size,
+ unsigned char info = 0, unsigned char other = 0);
+ QStringList *names() const;
+public slots:
+ bool name_to_value(std::uint32_t &value, QString name) const;
+ bool value_to_name(QString &name, std::uint32_t value) const;
+signals:
+
+
+private:
+ QMultiMap<std::uint32_t, SymbolTableEntry*> map_value_to_symbol;
+ QMap<QString, SymbolTableEntry*> map_name_to_symbol;
+};
+
+}
+
+#endif // SYMBOLTABLE_H