Starting to load symbols

This commit is contained in:
Zoe Roux
2021-02-06 18:29:15 +01:00
parent 0e16f81042
commit a826168eb2
8 changed files with 90 additions and 8 deletions
+19 -2
View File
@@ -10,19 +10,21 @@
#include <iostream>
#include <utility>
#include <QMessageBox>
#include <fstream>
using namespace ComSquare::CPU;
namespace ComSquare::Debugger
{
CPUDebug::CPUDebug(CPU &basicCPU, SNES &snes)
CPUDebug::CPUDebug(const CPU &basicCPU, SNES &snes)
: CPU(basicCPU),
_window(new ClosableWindow<CPUDebug>(*this, &CPUDebug::disableDebugger)),
_ui(),
_model(*this),
_painter(*this),
_stackModel(this->_bus, *this),
_snes(snes)
_snes(snes),
_labels(this->_loadLabels(snes.cartridge->getRomPath()))
{
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
@@ -306,6 +308,21 @@ namespace ComSquare::Debugger
return "";
return "[" + Utility::to_hex(valueAddr, Utility::AsmPrefix) + "]";
}
std::vector<Label> CPUDebug::_loadLabels(std::filesystem::path romPath) const
{
std::vector<Label> labels;
std::string symbolPath = romPath.replace_extension(".sym");
std::ifstream sym(symbolPath);
if (sym) {
std::vector<Label> symLabels = WlaDx.parse(sym);
labels.insert(labels.end(),
std::make_move_iterator(symLabels.begin()),
std::make_move_iterator(symLabels.end()));
}
return labels;
}
}
DisassemblyModel::DisassemblyModel(ComSquare::Debugger::CPUDebug &cpu) : QAbstractTableModel(), _cpu(cpu){ }