diff --git a/Core/Debugger/DebugInterface.h b/Core/Debugger/DebugInterface.h index 7a000d4df9..321f3f0a65 100644 --- a/Core/Debugger/DebugInterface.h +++ b/Core/Debugger/DebugInterface.h @@ -41,7 +41,6 @@ public: virtual void runToBreakpoint() {} virtual int getColor(unsigned int address){return 0xFFFFFFFF;} virtual const char *getDescription(unsigned int address) {return "";} - virtual const char *findSymbolForAddress(unsigned int address) { return NULL; }; virtual bool getSymbolValue(char* symbol, u32& dest) { return false; }; virtual bool initExpression(const char* exp, PostfixExpression& dest) { return false; }; virtual bool parseExpression(PostfixExpression& exp, u32& dest) { return false; }; diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 16242c2f1f..4216e0f734 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -58,7 +58,7 @@ void parseDisasm(const char* disasm, char* opcode, char* arguments, bool insertS u32 branchTarget; sscanf(disasm+3,"%08x",&branchTarget); - const char* addressSymbol = DisassemblyManager::getCpu()->findSymbolForAddress(branchTarget); + const char* addressSymbol = symbolMap.GetLabelName(branchTarget); if (addressSymbol != NULL && insertSymbols) { arguments += sprintf(arguments,"%s",addressSymbol); @@ -615,7 +615,7 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool case MACRO_LI: dest.name = name; - addressSymbol = DisassemblyManager::getCpu()->findSymbolForAddress(immediate); + addressSymbol = symbolMap.GetLabelName(immediate); if (addressSymbol != NULL && insertSymbols) { sprintf(buffer,"%s,%s",DisassemblyManager::getCpu()->GetRegName(0,rt),addressSymbol); @@ -631,7 +631,7 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo& dest, bool case MACRO_MEMORYIMM: dest.name = name; - addressSymbol = DisassemblyManager::getCpu()->findSymbolForAddress(immediate); + addressSymbol = symbolMap.GetLabelName(immediate); if (addressSymbol != NULL && insertSymbols) { sprintf(buffer,"%s,%s",DisassemblyManager::getCpu()->GetRegName(0,rt),addressSymbol); diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index 1662e9af97..a0e7f2e7a4 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -120,6 +120,8 @@ void SymbolMap::AddSymbol(const char *symbolname, unsigned int vaddress, size_t uniqueEntries.insert((const MapEntryUniqueInfo)e); entryRanges[e.vaddress + e.size] = e.vaddress; } + + AddLabel(symbolname,vaddress); } void SymbolMap::RemoveSymbolNum(int symbolnum){ @@ -250,7 +252,13 @@ bool SymbolMap::LoadNocashSym(const char *filename) *seperator = 0; sscanf(seperator+1,"%08X",&size); } - AddSymbol(value,address,size,ST_FUNCTION); + + if (size != 1) + { + AddSymbol(value,address,size,ST_FUNCTION); + } else { + AddLabel(value,address); + } } } @@ -367,6 +375,24 @@ bool SymbolMap::getSymbolValue(char* symbol, u32& dest) return false; } +void SymbolMap::AddLabel(const char* name, u32 address) +{ + Label label; + strcpy(label.name,name); + label.name[127] = 0; + + labels[address] = label; +} + +const char* SymbolMap::GetLabelName(u32 address) +{ + auto it = labels.find(address); + if (it == labels.end()) + return NULL; + + return it->second.name; +} + static char descriptionTemp[256]; const char *SymbolMap::GetDescription(unsigned int address) const diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index 5486e6f1e8..ad39b9e7da 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -75,6 +75,8 @@ public: void UseFuncSignaturesFile(const char *filename, u32 maxAddress); void CompileFuncSignaturesFile(const char *filename) const; + void AddLabel(const char* name, u32 address); + const char* GetLabelName(u32 address); private: struct MapEntryUniqueInfo { u32 address; @@ -87,6 +89,11 @@ private: } }; + struct Label + { + char name[128]; + }; + struct MapEntry : public MapEntryUniqueInfo { char name[128]; u32 unknown; @@ -99,7 +106,8 @@ private: // TODO } }; - + + std::map labels; std::set uniqueEntries; std::vector entries; std::map entryRanges; diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index 156d18bdd4..af3e351588 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -230,11 +230,6 @@ const char *MIPSDebugInterface::getDescription(unsigned int address) return symbolMap.GetDescription(address); } -const char *MIPSDebugInterface::findSymbolForAddress(unsigned int address) -{ - return symbolMap.getDirectSymbol(address); -} - bool MIPSDebugInterface::getSymbolValue(char* symbol, u32& dest) { return symbolMap.getSymbolValue(symbol,dest); diff --git a/Core/MIPS/MIPSDebugInterface.h b/Core/MIPS/MIPSDebugInterface.h index 39b6bc5eba..f01aa49640 100644 --- a/Core/MIPS/MIPSDebugInterface.h +++ b/Core/MIPS/MIPSDebugInterface.h @@ -40,7 +40,6 @@ public: virtual void runToBreakpoint(); virtual int getColor(unsigned int address); virtual const char *getDescription(unsigned int address); - virtual const char *findSymbolForAddress(unsigned int address); virtual bool getSymbolValue(char* symbol, u32& dest); virtual bool initExpression(const char* exp, PostfixExpression& dest); virtual bool parseExpression(PostfixExpression& exp, u32& dest); diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index c8e1ae05f3..8d9aee7fff 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -206,7 +206,7 @@ bool CtrlDisAsmView::getDisasmAddressText(u32 address, char* dest, bool abbrevia { if (displaySymbols) { - const char* addressSymbol = debugger->findSymbolForAddress(address); + const char* addressSymbol = symbolMap.GetLabelName(address); if (addressSymbol != NULL) { for (int k = 0; addressSymbol[k] != 0; k++) @@ -1023,7 +1023,7 @@ void CtrlDisAsmView::updateStatusBarText() // TODO: Could also be a float... { u32 data = Memory::Read_U32(line.info.dataAddress); - const char* addressSymbol = debugger->findSymbolForAddress(data); + const char* addressSymbol = symbolMap.GetLabelName(data); if (addressSymbol) { sprintf(text,"[%08X] = %s (%08X)",line.info.dataAddress,addressSymbol,data); @@ -1041,7 +1041,7 @@ void CtrlDisAsmView::updateStatusBarText() if (line.info.isBranch) { - const char* addressSymbol = debugger->findSymbolForAddress(line.info.branchTarget); + const char* addressSymbol = symbolMap.GetLabelName(line.info.branchTarget); if (addressSymbol == NULL) { sprintf(text,"%08X",line.info.branchTarget); @@ -1157,7 +1157,7 @@ std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size) { MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(debugger,start+i); - if (info.isBranch && debugger->findSymbolForAddress(info.branchTarget) == NULL) + if (info.isBranch && symbolMap.GetLabelName(info.branchTarget) == NULL) { if (branchAddresses.find(info.branchTarget) == branchAddresses.end()) { @@ -1189,7 +1189,7 @@ std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size) } if (line.info.isBranch && !line.info.isBranchToRegister - && debugger->findSymbolForAddress(line.info.branchTarget) == NULL + && symbolMap.GetLabelName(line.info.branchTarget) == NULL && branchAddresses.find(line.info.branchTarget) != branchAddresses.end()) { sprintf(buffer,"pos_%08X",line.info.branchTarget); diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 67e436e0fb..5e7a4a8826 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -457,7 +457,7 @@ void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col) else wsprintf(dest,L"0x%08X",mc.end-mc.start); } else { - const char* sym = cpu->findSymbolForAddress(displayedBreakPoints_[index].addr); + const char* sym = symbolMap.GetLabelName(displayedBreakPoints_[index].addr); if (sym != NULL) { std::wstring s = ConvertUTF8ToWString(sym); @@ -625,7 +625,7 @@ void CtrlStackTraceView::GetColumnText(wchar_t* dest, int row, int col) break; case SF_ENTRYNAME: { - const char* sym = cpu->findSymbolForAddress(frames[row].entry); + const char* sym = symbolMap.GetLabelName(frames[row].entry); if (sym != NULL) { wcscpy(dest, ConvertUTF8ToWString(sym).c_str()); } else {