Skip to content

Commit

Permalink
make symbol loading/unloading work a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
devinacker committed Jul 22, 2019
1 parent 25f3229 commit c0d52a2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
6 changes: 0 additions & 6 deletions bsnes/ui-qt/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
16 changes: 14 additions & 2 deletions bsnes/ui-qt/debugger/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions bsnes/ui-qt/debugger/debuggerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions bsnes/ui-qt/debugger/disassembler/symbols/symbol_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -186,6 +192,7 @@ void SymbolMap::loadFromString(const string &file) {
return;
}

symbols.reset();
if (adapter->read(rows, this)) {
finishUpdates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class SymbolMap : public QObject {

typedef nall::linear_vector<Symbols> 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);
Expand Down

0 comments on commit c0d52a2

Please sign in to comment.