Some work on symbol export, minor cleanups

This commit is contained in:
Henrik Rydgård 2025-03-29 07:57:09 +01:00
parent b2a94a7deb
commit 1a93d8a1f9
9 changed files with 69 additions and 50 deletions

View file

@ -86,7 +86,11 @@ std::string NiceTimeFormat(int seconds);
// TODO: We actually also have Buffer, with .Printf(), which is almost as convenient. Should maybe improve that instead?
class StringWriter {
public:
explicit StringWriter(char *buffer, size_t bufSize) : start_(buffer), p_(buffer), bufSize_(bufSize) {
StringWriter(char *buffer, size_t bufSize) : start_(buffer), p_(buffer), bufSize_(bufSize) {
buffer[0] = '\0';
}
template<size_t sz>
explicit StringWriter(char (&buffer)[sz]) : start_(buffer), p_(buffer), bufSize_(sz) {
buffer[0] = '\0';
}
StringWriter(const StringWriter &) = delete;

View file

@ -45,8 +45,6 @@ static bool g_exitOnAssert;
static AssertNoCallbackFunc g_assertCancelCallback = 0;
static void *g_assertCancelCallbackUserData = 0;
void SetAssertDialogParent(void *handle) {
#if PPSSPP_PLATFORM(WINDOWS)
g_dialogParent = (HWND)handle;

View file

@ -280,6 +280,7 @@ static const ConfigSetting generalSettings[] = {
// "default" means let emulator decide, "" means disable.
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default", CfgFlag::DEFAULT),
ConfigSetting("AutoSaveSymbolMap", &g_Config.bAutoSaveSymbolMap, false, CfgFlag::PER_GAME),
ConfigSetting("CompressSymbols", &g_Config.bCompressSymbols, true, CfgFlag::DEFAULT),
ConfigSetting("CacheFullIsoInRam", &g_Config.bCacheFullIsoInRam, false, CfgFlag::PER_GAME),
ConfigSetting("RemoteISOPort", &g_Config.iRemoteISOPort, 0, CfgFlag::DEFAULT),
ConfigSetting("LastRemoteISOServer", &g_Config.sLastRemoteISOServer, "", CfgFlag::DEFAULT),
@ -1212,11 +1213,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
// For iOS, issue #19211
TryUpdateSavedPath(&currentDirectory);
// This check is probably not really necessary here anyway, you can always
// press Home or Browse if you're in a bad directory.
if (!File::Exists(currentDirectory))
currentDirectory = defaultCurrentDirectory;
Section *log = iniFile.GetOrCreateSection(logSectionName);
bool debugDefaults = false;

View file

@ -122,6 +122,7 @@ public:
int iIOTimingMethod;
int iLockedCPUSpeed;
bool bAutoSaveSymbolMap;
bool bCompressSymbols;
bool bCacheFullIsoInRam;
int iRemoteISOPort;
std::string sLastRemoteISOServer;

View file

@ -309,17 +309,17 @@ bool SymbolMap::LoadNocashSym(const Path &filename) {
return true;
}
void SymbolMap::SaveNocashSym(const Path &filename) const {
bool SymbolMap::SaveNocashSym(const Path &filename) const {
std::lock_guard<std::recursive_mutex> guard(lock_);
// Don't bother writing a blank file.
if (!File::Exists(filename) && functions.empty() && data.empty()) {
return;
return false;
}
FILE *f = File::OpenCFile(filename, "w");
if (f == NULL)
return;
if (!f)
return false;
// only write functions, the rest isn't really interesting
for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
@ -328,6 +328,7 @@ void SymbolMap::SaveNocashSym(const Path &filename) const {
}
fclose(f);
return true;
}
SymbolType SymbolMap::GetSymbolType(u32 address) {

View file

@ -72,7 +72,7 @@ public:
bool LoadSymbolMap(const Path &filename);
bool SaveSymbolMap(const Path &filename) const;
bool LoadNocashSym(const Path &filename);
void SaveNocashSym(const Path &filename) const;
bool SaveNocashSym(const Path &filename) const;
SymbolType GetSymbolType(u32 address);
bool GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask = ST_FUNCTION);

View file

@ -455,7 +455,7 @@ void DrawFPS(UIContext *ctx, const Bounds &bounds) {
__DisplayGetFPS(&vps, &fps, &actual_fps);
char temp[256];
StringWriter w(temp, sizeof(temp));
StringWriter w(temp);
if ((g_Config.iShowStatusFlags & ((int)ShowStatusFlags::FPS_COUNTER | (int)ShowStatusFlags::SPEED_COUNTER)) == ((int)ShowStatusFlags::FPS_COUNTER | (int)ShowStatusFlags::SPEED_COUNTER)) {
// Both at the same time gets a shorter formulation.

View file

@ -1660,34 +1660,6 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
ImGui::MenuItem("Don't break on start", nullptr, &g_Config.bAutoRun); // should really invert this bool!
ImGui::MenuItem("Fast memory", nullptr, &g_Config.bFastMemory);
ImGui::Separator();
/*
// Symbol stuff. Move to separate menu?
// Doesn't quite seem to work yet.
if (ImGui::MenuItem("Load symbol map...")) {
System_BrowseForFile(reqToken_, "Load symbol map", BrowseFileType::SYMBOL_MAP, [&](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to load symbol map");
}
disasm_.DirtySymbolMap();
});
}
if (ImGui::MenuItem("Save symbol map...")) {
System_BrowseForFileSave(reqToken_, "Save symbol map", "symbols.map", BrowseFileType::SYMBOL_MAP, [](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to save symbol map");
}
});
}
*/
if (ImGui::MenuItem("Reset symbol map")) {
g_symbolMap->Clear();
disasm_.DirtySymbolMap();
// NotifyDebuggerMapLoaded();
}
ImGui::Separator();
if (ImGui::MenuItem("Take screenshot")) {
g_TakeScreenshot = true;
}
@ -1715,6 +1687,49 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
ImGui::MenuItem("Breakpoints", nullptr, &cfg_.breakpointsOpen);
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Symbols")) {
if (ImGui::MenuItem("Load .ppmap...")) {
System_BrowseForFile(reqToken_, "Load PPSSPP symbol map", BrowseFileType::SYMBOL_MAP, [&](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to load symbol map");
}
disasm_.DirtySymbolMap();
});
}
if (ImGui::MenuItem("Save .ppmap...")) {
System_BrowseForFileSave(reqToken_, "Save PPSSPP symbol map", "symbols.ppmap", BrowseFileType::SYMBOL_MAP, [](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveSymbolMap(path)) {
ERROR_LOG(Log::Common, "Failed to save symbol map");
}
});
}
if (ImGui::MenuItem("Load No$ .sym...")) {
System_BrowseForFile(reqToken_, "Load No$ symbol map", BrowseFileType::SYMBOL_MAP, [&](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->LoadNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to load No$ symbol map");
}
disasm_.DirtySymbolMap();
});
}
if (ImGui::MenuItem("Save No$ .sym...")) {
System_BrowseForFileSave(reqToken_, "Save No$ symbol map", "symbols.sym", BrowseFileType::SYMBOL_MAP, [](const char *responseString, int) {
Path path(responseString);
if (!g_symbolMap->SaveNocashSym(path)) {
ERROR_LOG(Log::Common, "Failed to save No$ symbol map");
}
});
}
ImGui::Separator();
if (ImGui::MenuItem("Reset symbol map")) {
g_symbolMap->Clear();
disasm_.DirtySymbolMap();
// NotifyDebuggerMapLoaded();
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Memory")) {
for (int i = 0; i < 4; i++) {
char title[64];
@ -1765,14 +1780,17 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Misc")) {
if (ImGui::MenuItem("Close Debugger")) {
g_Config.bShowImDebugger = false;
}
ImGui::MenuItem("PPSSPP Internals", nullptr, &cfg_.internalsOpen);
ImGui::MenuItem("Dear ImGui Demo", nullptr, &cfg_.demoOpen);
ImGui::MenuItem("Dear ImGui Style editor", nullptr, &cfg_.styleEditorOpen);
ImGui::EndMenu();
}
// Let's have this at the top level, to help anyone confused.
if (ImGui::BeginMenu("Close Debugger")) {
g_Config.bShowImDebugger = false;
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}

View file

@ -970,7 +970,8 @@ void GameBrowser::Refresh() {
bool GameBrowser::IsCurrentPathPinned() {
const auto paths = g_Config.vPinnedPaths;
return std::find(paths.begin(), paths.end(), File::ResolvePath(path_.GetPath().ToString())) != paths.end();
std::string resolved = File::ResolvePath(path_.GetPath().ToString());
return std::find(paths.begin(), paths.end(), resolved) != paths.end();
}
std::vector<Path> GameBrowser::GetPinnedPaths() const {