mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-08-31 09:45:24 +02:00
SymbolMap: - Fix GetModuleIndex(): it only checked the end of an active module's range (via activeModuleEnds.upper_bound), never the start, so an address sitting in the gap before a module was silently misattributed to it. Added GetModuleIndexByName() as a companion lookup. - AddModule() gains an optional crc param, stored per ModuleEntry. Reactivating a module by name now also requires the crc to agree when both sides know it, so two unrelated binaries that happen to share a name no longer get merged into one symbol table (addresses the old TODO at the top of SymbolMap.h). - AddLabel()/AddFunction() gain an updateName param (default false, preserving existing "first writer wins" behavior) so a trusted source - like a loaded symbol file - can be allowed to overwrite a name that a lower-confidence automatic pass already assigned. - New SaveModuleSymbols()/LoadModuleSymbols()/GetModuleSymbolsPath(): save or restore one module's functions/data/labels to/from a small human-editable text file, addressed relative to the module (so the file stays valid however the module ends up positioned on a later run). Keyed by PSP/SYSTEM/SYMBOLS/<moduleName>_<crc>.ppsym - deliberately by module+crc rather than by game, so it's shared by every game/homebrew that loads the exact same module. A "# game <id> <title>" comment records who last saved it, informational only. WebSocket debugger: hle.module.saveSymbols/loadSymbols expose the above. sceKernelModule.cpp: auto-load a module's saved symbols right after it's registered with the symbol map (both the real ELF-load path and the savestate-load path), and auto-save on unload (before UnloadModule(), while its symbols are still active) - gated behind the new bAutoSaveLoadSymbols config setting (default off), with a matching Developer Tools checkbox and a --auto-save-load-symbols command-line override for headless use. Includes some in-progress cleanup already staged: DescribeAddress now calls g_symbolMap->GetDescription() directly instead of through the now-removed MIPSDebugInterface::getDescription() wrapper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
129 lines
3.4 KiB
C++
129 lines
3.4 KiB
C++
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
// Official git repository and contact information can be found at
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "Common/Math/expression_parser.h"
|
|
#include "Core/MIPS/MIPS.h"
|
|
#include "Core/Debugger/DebugInterface.h"
|
|
|
|
class MIPSDebugInterface : public DebugInterface {
|
|
private:
|
|
MIPSState *cpu;
|
|
public:
|
|
MIPSDebugInterface(MIPSState *_cpu) { cpu = _cpu; }
|
|
int getInstructionSize(int instruction) { return 4; }
|
|
bool isAlive();
|
|
bool isBreakpoint(unsigned int address);
|
|
void setBreakpoint(unsigned int address);
|
|
void clearBreakpoint(unsigned int address);
|
|
void clearAllBreakpoints();
|
|
void toggleBreakpoint(unsigned int address);
|
|
unsigned int readMemory(unsigned int address) const;
|
|
int getColor(unsigned int address, bool darkMode) const;
|
|
|
|
u32 GetGPR32Value(int reg) const override { return cpu->r[reg]; }
|
|
float GetFPR32Value(int reg) const { return cpu->f[reg]; }
|
|
void SetGPR32Value(int reg, u32 value) { cpu->r[reg] = value; }
|
|
|
|
u32 GetPC() const override { return cpu->pc; }
|
|
u32 GetRA() const override { return cpu->r[MIPS_REG_RA]; }
|
|
u32 GetFPCond() const override { return cpu->fpcond; }
|
|
void SetPC(u32 _pc) override { cpu->pc = _pc; }
|
|
|
|
static const char *GetCategoryName(int cat) {
|
|
static const char *const names[3] = { "GPR", "FPU", "VFPU" };
|
|
return names[cat];
|
|
}
|
|
static int GetNumCategories() { return 3; }
|
|
static constexpr int GetNumRegsInCategory(int cat) {
|
|
constexpr int r[3] = { 32, 32, 128 };
|
|
return r[cat];
|
|
}
|
|
static std::string GetRegName(int cat, int index);
|
|
|
|
void PrintRegValue(int cat, int index, char *out, size_t outSize) const override {
|
|
switch (cat) {
|
|
case 0: snprintf(out, outSize, "%08X", cpu->r[index]); break;
|
|
case 1: snprintf(out, outSize, "%f", cpu->f[index]); break;
|
|
case 2: snprintf(out, outSize, "N/A"); break;
|
|
}
|
|
}
|
|
|
|
u32 GetHi() const override {
|
|
return cpu->hi;
|
|
}
|
|
|
|
u32 GetLLBit() const override {
|
|
return cpu->llBit;
|
|
}
|
|
|
|
u32 GetLo() const override {
|
|
return cpu->lo;
|
|
}
|
|
|
|
void SetHi(u32 val) override {
|
|
cpu->hi = val;
|
|
}
|
|
|
|
void SetLo(u32 val) override {
|
|
cpu->lo = val;
|
|
}
|
|
|
|
u32 GetRegValue(int cat, int index) const override {
|
|
switch (cat) {
|
|
case 0:
|
|
return cpu->r[index];
|
|
|
|
case 1:
|
|
return cpu->fi[index];
|
|
|
|
case 2:
|
|
return cpu->vi[voffset[index]];
|
|
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
void SetRegValue(int cat, int index, u32 value) override {
|
|
switch (cat) {
|
|
case 0:
|
|
if (index != 0)
|
|
cpu->r[index] = value;
|
|
break;
|
|
|
|
case 1:
|
|
cpu->fi[index] = value;
|
|
break;
|
|
|
|
case 2:
|
|
cpu->vi[voffset[index]] = value;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
bool initExpression(const DebugInterface *debug, const char* exp, PostfixExpression& dest);
|
|
bool parseExpression(const DebugInterface *debug, PostfixExpression& exp, u32& dest);
|
|
void DisAsm(u32 pc, char *out, size_t outSize);
|