Files
ppsspp/Core/MIPS/MIPSDebugInterface.h
T
Henrik Rydgård c81bc5c212 Win32 debugger: stop cutting off register values in CtrlRegisterList
The name and value columns were hardcoded at x=17 and x=77. The control has
a fixed width in the dialog and can not be widened, so the 8 hex digits of a
GPR only just fit - and once the register list got a vertical scrollbar, the
~17px it takes off the client width pushed the last digits off the edge.

Derive the value column from the client width each paint instead, pulling it
in far enough for a whole value to fit and clipping anything longer rather
than letting it spill. Same for the category tab labels.

Float registers print with %g rather than %f: in a column that narrow, a
clipped %f of a large value is worse than useless (1e20 would read as
100000000), while %g keeps six significant digits and stays short for the
values you normally see.
2026-09-12 13:46:12 -06:00

131 lines
3.6 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;
// %g rather than %f - the register list column is narrow, and a truncated %f of a large
// value ("100000000" for 1e20) is worse than no value at all.
case 1: snprintf(out, outSize, "%g", cpu->f[index]); break;
case 2: snprintf(out, outSize, "%g", cpu->v[voffset[index]]); 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);