From c0d52a2da2672e05ad947c23e8e528a813531b70 Mon Sep 17 00:00:00 2001 From: devinacker Date: Sun, 21 Jul 2019 23:04:06 -0400 Subject: [PATCH] make symbol loading/unloading work a bit better --- bsnes/ui-qt/cartridge/cartridge.cpp | 6 ------ bsnes/ui-qt/debugger/debugger.cpp | 16 ++++++++++++++-- bsnes/ui-qt/debugger/debuggerview.cpp | 7 ++----- .../debugger/disassembler/symbols/symbol_map.cpp | 7 +++++++ .../disassembler/symbols/symbol_map.moc.hpp | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/bsnes/ui-qt/cartridge/cartridge.cpp b/bsnes/ui-qt/cartridge/cartridge.cpp index 207f6826..67b9fb0e 100644 --- a/bsnes/ui-qt/cartridge/cartridge.cpp +++ b/bsnes/ui-qt/cartridge/cartridge.cpp @@ -109,12 +109,6 @@ bool Cartridge::loadNormal(const char *base) { loadMemory(baseName, ".srm", SNES::memory::cartram); loadMemory(baseName, ".rtc", SNES::memory::cartrtc); - #if defined(DEBUGGER) - debugger->symbolsCPU->loadFromFile(nall::basename(baseName), ".sym"); - debugger->symbolsCPU->loadFromFile(nall::basename(baseName), ".cpu.sym"); - debugger->symbolsSMP->loadFromFile(nall::basename(baseName), ".smp.sym"); - #endif - fileName = baseName; name = notdir(nall::basename(baseName)); diff --git a/bsnes/ui-qt/debugger/debugger.cpp b/bsnes/ui-qt/debugger/debugger.cpp index b84fe329..3efa56ca 100644 --- a/bsnes/ui-qt/debugger/debugger.cpp +++ b/bsnes/ui-qt/debugger/debugger.cpp @@ -271,6 +271,16 @@ void Debugger::modifySystemState(unsigned state) { SNES::cpuAnalyst.performFullAnalysis(); } + symbolsCPU->loadFromString(DEFAULT_SYMBOL_MAP_CPU); + symbolsCPU->loadFromFile(nall::basename(symfile), ".sym"); + symbolsCPU->loadFromFile(nall::basename(symfile), ".cpu.sym"); + symbolsSMP->loadFromString(DEFAULT_SYMBOL_MAP_SMP); + symbolsSMP->loadFromFile(nall::basename(symfile), ".smp.sym"); + if (SNES::cartridge.has_sa1()) + symbolsSA1->loadFromFile(nall::basename(symfile), ".sa1.sym"); + else + symbolsSA1->reset(); + string data; if(config().debugger.saveBreakpoints) { breakpointEditor->clear(); @@ -298,8 +308,10 @@ void Debugger::modifySystemState(unsigned state) { } if(config().debugger.saveSymbols) { - debugger->symbolsCPU->saveToFile(nall::basename(symfile), ".cpu.sym"); - debugger->symbolsSMP->saveToFile(nall::basename(symfile), ".smp.sym"); + symbolsCPU->saveToFile(nall::basename(symfile), ".cpu.sym"); + symbolsSMP->saveToFile(nall::basename(symfile), ".smp.sym"); + if (SNES::cartridge.has_sa1()) + symbolsSA1->saveToFile(nall::basename(symfile), ".sa1.sym"); } if(config().debugger.saveBreakpoints) { diff --git a/bsnes/ui-qt/debugger/debuggerview.cpp b/bsnes/ui-qt/debugger/debuggerview.cpp index a09cd62e..d060b4a3 100644 --- a/bsnes/ui-qt/debugger/debuggerview.cpp +++ b/bsnes/ui-qt/debugger/debuggerview.cpp @@ -55,17 +55,14 @@ DebuggerView::DebuggerView(RegisterEdit *registers, DisasmProcessor *processor, symbolsViewerDialog = new SymbolsView(processor); symbolsViewer = new QPushButton("Symbols"); controlLayout->addWidget(symbolsViewer); + connect(symbolsViewer, SIGNAL(clicked(bool)), symbolsViewerDialog, SLOT(show())); } controlLayout->addStretch(); - connect(stepProcessor, SIGNAL(released()), this, SLOT(synchronize())); + connect(stepProcessor, SIGNAL(clicked(bool)), this, SLOT(synchronize())); connect(traceProcessor, SIGNAL(stateChanged(int)), this, SIGNAL(traceStateChanged(int))); - if (processor->getSymbols() != NULL) { - connect(symbolsViewer, SIGNAL(released()), symbolsViewerDialog, SLOT(show())); - } - connect(consoleLayout, SIGNAL(splitterMoved(int,int)), this, SLOT(synchronize())); synchronize(); diff --git a/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.cpp b/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.cpp index 2381caa7..45594edd 100644 --- a/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.cpp +++ b/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.cpp @@ -52,6 +52,12 @@ int32_t SymbolMap::getSymbolIndex(uint32_t address) { return -1; } +// ------------------------------------------------------------------------ +void SymbolMap::reset() { + symbols.reset(); + finishUpdates(); +} + // ------------------------------------------------------------------------ void SymbolMap::addLocation(uint32_t address, const string &name) { addSymbol(address, Symbol::createLocation(address, name)); @@ -186,6 +192,7 @@ void SymbolMap::loadFromString(const string &file) { return; } + symbols.reset(); if (adapter->read(rows, this)) { finishUpdates(); } diff --git a/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.moc.hpp b/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.moc.hpp index 12c76a6d..67648655 100644 --- a/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.moc.hpp +++ b/bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.moc.hpp @@ -71,6 +71,7 @@ class SymbolMap : public QObject { typedef nall::linear_vector SymbolsLists; + void reset(); void addLocation(uint32_t address, const string &name); void addComment(uint32_t address, const string &name); void addSymbol(uint32_t address, const Symbol &name);