mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-11 23:53:55 +00:00
commit
e2468dbec8
@ -219,6 +219,35 @@ void SymbolMap::SaveSymbolMap(const char *filename) const
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
bool SymbolMap::LoadNocashSym(const char *filename)
|
||||
{
|
||||
FILE *f = fopen(filename,"r");
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
while (!feof(f))
|
||||
{
|
||||
char line[256],value[256];
|
||||
char *p = fgets(line,256,f);
|
||||
if(p == NULL)
|
||||
break;
|
||||
|
||||
u32 address;
|
||||
if (sscanf(line,"%08X %s",&address,value) != 2) continue;
|
||||
if (address == 0 && strcmp(value,"0") == 0) continue;
|
||||
|
||||
if (value[0] == '.') // data directives
|
||||
{
|
||||
continue; // not supported yet
|
||||
} else { // labels
|
||||
AddSymbol(value,address,0,ST_FUNCTION);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
int SymbolMap::GetSymbolNum(unsigned int address, SymbolType symmask) const
|
||||
{
|
||||
for (size_t i = 0, n = entries.size(); i < n; i++)
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
SymbolMap() {}
|
||||
bool LoadSymbolMap(const char *filename);
|
||||
void SaveSymbolMap(const char *filename) const;
|
||||
bool LoadNocashSym(const char *ilename);
|
||||
void AddSymbol(const char *symbolname, unsigned int vaddress, size_t size, SymbolType symbol);
|
||||
void ResetSymbolMap();
|
||||
void AnalyzeBackwards();
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
|
||||
#include "Common/StringUtils.h"
|
||||
#include "file/file_util.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
@ -181,25 +183,45 @@ void WindowsHost::BootDone()
|
||||
Core_EnableStepping(!g_Config.bAutoRun);
|
||||
}
|
||||
|
||||
static std::string SymbolMapFilename(const char *currentFilename)
|
||||
static std::string SymbolMapFilename(const char *currentFilename, char* ext)
|
||||
{
|
||||
std::string result = currentFilename;
|
||||
size_t dot = result.rfind('.');
|
||||
if (dot == result.npos)
|
||||
return result + ".map";
|
||||
FileInfo info;
|
||||
|
||||
result.replace(dot, result.npos, ".map");
|
||||
return result;
|
||||
std::string result = currentFilename;
|
||||
|
||||
// can't fail, definitely exists if it gets this far
|
||||
getFileInfo(currentFilename, &info);
|
||||
if (info.isDirectory)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char* slash = "\\";
|
||||
#else
|
||||
char* slash = "/";
|
||||
#endif
|
||||
if (!endsWith(result,slash))
|
||||
result += slash;
|
||||
|
||||
return result + ".ppsspp-symbols" + ext;
|
||||
} else {
|
||||
size_t dot = result.rfind('.');
|
||||
if (dot == result.npos)
|
||||
return result + ext;
|
||||
|
||||
result.replace(dot, result.npos, ext);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowsHost::AttemptLoadSymbolMap()
|
||||
{
|
||||
return symbolMap.LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str()).c_str());
|
||||
bool result1 = symbolMap.LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(),".map").c_str());
|
||||
bool result2 = symbolMap.LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(),".sym").c_str());
|
||||
return result1 || result2;
|
||||
}
|
||||
|
||||
void WindowsHost::SaveSymbolMap()
|
||||
{
|
||||
symbolMap.SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str()).c_str());
|
||||
symbolMap.SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(),".map").c_str());
|
||||
}
|
||||
|
||||
void WindowsHost::AddSymbol(std::string name, u32 addr, u32 size, int type=0)
|
||||
|
Loading…
Reference in New Issue
Block a user