mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Debugger: Make reg names safer, stop using v000.
Better to use S000, etc. as that's more clear throughout.
This commit is contained in:
parent
3a21941f0b
commit
6da10463f9
@ -61,7 +61,7 @@ public:
|
||||
virtual int GetNumCategories() {return 0;}
|
||||
virtual int GetNumRegsInCategory(int cat) {return 0;}
|
||||
virtual const char *GetCategoryName(int cat) {return 0;}
|
||||
virtual const char *GetRegName(int cat, int index) {return 0;}
|
||||
virtual std::string GetRegName(int cat, int index) { return ""; }
|
||||
virtual void PrintRegValue(int cat, int index, char *out, size_t outSize) {
|
||||
snprintf(out, outSize, "%08X", GetGPR32Value(index));
|
||||
}
|
||||
|
@ -847,9 +847,9 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo &dest, bool
|
||||
|
||||
addressSymbol = g_symbolMap->GetLabelString(immediate);
|
||||
if (!addressSymbol.empty() && insertSymbols) {
|
||||
snprintf(buffer, sizeof(buffer), "%s,%s", cpuDebug->GetRegName(0, rt), addressSymbol.c_str());
|
||||
snprintf(buffer, sizeof(buffer), "%s,%s", cpuDebug->GetRegName(0, rt).c_str(), addressSymbol.c_str());
|
||||
} else {
|
||||
snprintf(buffer, sizeof(buffer), "%s,0x%08X", cpuDebug->GetRegName(0, rt), immediate);
|
||||
snprintf(buffer, sizeof(buffer), "%s,0x%08X", cpuDebug->GetRegName(0, rt).c_str(), immediate);
|
||||
}
|
||||
|
||||
dest.params = buffer;
|
||||
@ -862,9 +862,9 @@ bool DisassemblyMacro::disassemble(u32 address, DisassemblyLineInfo &dest, bool
|
||||
|
||||
addressSymbol = g_symbolMap->GetLabelString(immediate);
|
||||
if (!addressSymbol.empty() && insertSymbols) {
|
||||
snprintf(buffer, sizeof(buffer), "%s,%s", cpuDebug->GetRegName(0, rt), addressSymbol.c_str());
|
||||
snprintf(buffer, sizeof(buffer), "%s,%s", cpuDebug->GetRegName(0, rt).c_str(), addressSymbol.c_str());
|
||||
} else {
|
||||
snprintf(buffer, sizeof(buffer), "%s,0x%08X", cpuDebug->GetRegName(0, rt), immediate);
|
||||
snprintf(buffer, sizeof(buffer), "%s,0x%08X", cpuDebug->GetRegName(0, rt).c_str(), immediate);
|
||||
}
|
||||
|
||||
dest.params = buffer;
|
||||
|
@ -618,7 +618,7 @@ void ArmRegCacheFPU::QFlush(int quad) {
|
||||
}
|
||||
|
||||
if (qr[quad].isDirty && !qr[quad].isTemp) {
|
||||
INFO_LOG(JIT, "Flushing Q%i (%s)", quad, GetVectorNotation(qr[quad].mipsVec, qr[quad].sz));
|
||||
INFO_LOG(JIT, "Flushing Q%i (%s)", quad, GetVectorNotation(qr[quad].mipsVec, qr[quad].sz).c_str());
|
||||
|
||||
ARMReg q = QuadAsQ(quad);
|
||||
// Unlike reads, when writing to the register file we need to be careful to write the correct
|
||||
@ -881,7 +881,7 @@ ARMReg ArmRegCacheFPU::QMapReg(int vreg, VectorSize sz, int flags) {
|
||||
// We didn't find the extra register, but we got a list of regs to flush. Flush 'em.
|
||||
// Here we can check for opportunities to do a "transpose-flush" of row vectors, etc.
|
||||
if (!quadsToFlush.empty()) {
|
||||
INFO_LOG(JIT, "New mapping %s collided with %d quads, flushing them.", GetVectorNotation(vreg, sz), (int)quadsToFlush.size());
|
||||
INFO_LOG(JIT, "New mapping %s collided with %d quads, flushing them.", GetVectorNotation(vreg, sz).c_str(), (int)quadsToFlush.size());
|
||||
}
|
||||
for (size_t i = 0; i < quadsToFlush.size(); i++) {
|
||||
QFlush(quadsToFlush[i]);
|
||||
@ -973,7 +973,7 @@ ARMReg ArmRegCacheFPU::QMapReg(int vreg, VectorSize sz, int flags) {
|
||||
qr[quad].isDirty = (flags & MAP_DIRTY) != 0;
|
||||
qr[quad].spillLock = true;
|
||||
|
||||
INFO_LOG(JIT, "Mapped Q%i to vfpu %i (%s), sz=%i, dirty=%i", quad, vreg, GetVectorNotation(vreg, sz), (int)sz, qr[quad].isDirty);
|
||||
INFO_LOG(JIT, "Mapped Q%i to vfpu %i (%s), sz=%i, dirty=%i", quad, vreg, GetVectorNotation(vreg, sz).c_str(), (int)sz, qr[quad].isDirty);
|
||||
if (sz == V_Single || sz == V_Pair) {
|
||||
return D_0(QuadAsQ(quad));
|
||||
} else {
|
||||
|
@ -208,7 +208,7 @@ int IRWriter::AddConstantFloat(float value) {
|
||||
return AddConstant(val);
|
||||
}
|
||||
|
||||
const char *GetGPRName(int r) {
|
||||
static std::string GetGPRName(int r) {
|
||||
if (r < 32) {
|
||||
return currentDebugMIPS->GetRegName(0, r);
|
||||
}
|
||||
@ -259,7 +259,7 @@ void DisassembleParam(char *buf, int bufSize, u8 param, char type, u32 constant)
|
||||
|
||||
switch (type) {
|
||||
case 'G':
|
||||
snprintf(buf, bufSize, "%s", GetGPRName(param));
|
||||
snprintf(buf, bufSize, "%s", GetGPRName(param).c_str());
|
||||
break;
|
||||
case 'F':
|
||||
if (param >= 32) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
#include "Core/Debugger/DebugInterface.h"
|
||||
#include "Core/MIPS/MIPSDebugInterface.h"
|
||||
#include "Core/MIPS/MIPSVFPUUtils.h"
|
||||
#include "Core/HLE/sceKernelThread.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/MIPS/MIPSTables.h"
|
||||
@ -60,12 +61,12 @@ public:
|
||||
char reg[8];
|
||||
snprintf(reg, sizeof(reg), "r%d", i);
|
||||
|
||||
if (strcasecmp(str, reg) == 0 || strcasecmp(str, cpu->GetRegName(0, i)) == 0)
|
||||
if (strcasecmp(str, reg) == 0 || strcasecmp(str, cpu->GetRegName(0, i).c_str()) == 0)
|
||||
{
|
||||
referenceIndex = i;
|
||||
return true;
|
||||
}
|
||||
else if (strcasecmp(str, cpu->GetRegName(1, i)) == 0)
|
||||
else if (strcasecmp(str, cpu->GetRegName(1, i).c_str()) == 0)
|
||||
{
|
||||
referenceIndex = REF_INDEX_FPU | i;
|
||||
return true;
|
||||
@ -81,7 +82,7 @@ public:
|
||||
|
||||
for (int i = 0; i < 128; i++)
|
||||
{
|
||||
if (strcasecmp(str, cpu->GetRegName(2, i)) == 0)
|
||||
if (strcasecmp(str, cpu->GetRegName(2, i).c_str()) == 0)
|
||||
{
|
||||
referenceIndex = REF_INDEX_VFPU | i;
|
||||
return true;
|
||||
@ -261,9 +262,7 @@ const char *MIPSDebugInterface::GetName()
|
||||
return ("R4");
|
||||
}
|
||||
|
||||
// NOT threadsafe.
|
||||
const char *MIPSDebugInterface::GetRegName(int cat, int index)
|
||||
{
|
||||
std::string MIPSDebugInterface::GetRegName(int cat, int index) {
|
||||
static const char *regName[32] = {
|
||||
"zero", "at", "v0", "v1",
|
||||
"a0", "a1", "a2", "a3",
|
||||
@ -274,23 +273,20 @@ const char *MIPSDebugInterface::GetRegName(int cat, int index)
|
||||
"t8", "t9", "k0", "k1",
|
||||
"gp", "sp", "fp", "ra"
|
||||
};
|
||||
static const char *fpRegName[32] = {
|
||||
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
|
||||
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
|
||||
"f16", "f16", "f18", "f19", "f20", "f21", "f22", "f23",
|
||||
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
|
||||
};
|
||||
|
||||
// really nasty hack so that this function can be called several times on one line of c++.
|
||||
static int access = 0;
|
||||
access++;
|
||||
access &= 3;
|
||||
static char temp[4][16];
|
||||
|
||||
if (cat == 0) {
|
||||
if (cat == 0 && (unsigned)index < sizeof(regName)) {
|
||||
return regName[index];
|
||||
} else if (cat == 1) {
|
||||
snprintf(temp[access], sizeof(temp[access]), "f%d", index);
|
||||
return temp[access];
|
||||
} else if (cat == 1 && (unsigned)index < sizeof(fpRegName)) {
|
||||
return fpRegName[index];
|
||||
} else if (cat == 2) {
|
||||
snprintf(temp[access], sizeof(temp[access]), "v%03x", index);
|
||||
return temp[access];
|
||||
} else {
|
||||
return "???";
|
||||
return GetVectorNotation(index, V_Single);
|
||||
}
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
static int r[3] = { 32, 32, 128 };
|
||||
return r[cat];
|
||||
}
|
||||
const char *GetRegName(int cat, int index) override;
|
||||
std::string GetRegName(int cat, int index) override;
|
||||
|
||||
void PrintRegValue(int cat, int index, char *out, size_t outSize) override {
|
||||
switch (cat) {
|
||||
|
@ -34,9 +34,9 @@
|
||||
#define _POS ((op>>6 ) & 0x1F)
|
||||
#define _SIZE ((op>>11) & 0x1F)
|
||||
|
||||
#define RN(i) currentDebugMIPS->GetRegName(0,i)
|
||||
#define FN(i) currentDebugMIPS->GetRegName(1,i)
|
||||
//#define VN(i) currentMIPS->GetRegName(2,i)
|
||||
#define RN(i) (currentDebugMIPS->GetRegName(0, i).c_str())
|
||||
#define FN(i) (currentDebugMIPS->GetRegName(1, i).c_str())
|
||||
//#define VN(i) (currentDebugMIPS->GetRegName(2, i).c_str())
|
||||
|
||||
namespace MIPSDis
|
||||
{
|
||||
|
@ -34,9 +34,9 @@
|
||||
#define _SIZE ((op>>11) & 0x1F)
|
||||
|
||||
|
||||
#define RN(i) currentDebugMIPS->GetRegName(0,i)
|
||||
#define FN(i) currentDebugMIPS->GetRegName(1,i)
|
||||
//#define VN(i) currentDebugMIPS->GetRegName(2,i)
|
||||
#define RN(i) (currentDebugMIPS->GetRegName(0, i).c_str())
|
||||
#define FN(i) (currentDebugMIPS->GetRegName(1, i).c_str())
|
||||
//#define VN(i) (currentDebugMIPS->GetRegName(2, i).c_str())
|
||||
|
||||
|
||||
#define S_not(a,b,c) (a<<2)|(b)|(c<<5)
|
||||
@ -48,8 +48,7 @@
|
||||
#define VertOff 1
|
||||
#define MtxOff 4
|
||||
|
||||
inline const char *VN(int v, VectorSize size)
|
||||
{
|
||||
inline std::string VNStr(int v, VectorSize size) {
|
||||
static const char *vfpuCtrlNames[VFPU_CTRL_MAX] = {
|
||||
"SPFX",
|
||||
"TPFX",
|
||||
@ -77,11 +76,13 @@ inline const char *VN(int v, VectorSize size)
|
||||
return GetVectorNotation(v, size);
|
||||
}
|
||||
|
||||
inline const char *MN(int v, MatrixSize size)
|
||||
{
|
||||
inline std::string MNStr(int v, MatrixSize size) {
|
||||
return GetMatrixNotation(v, size);
|
||||
}
|
||||
|
||||
#define VN(v, s) (VNStr(v, s).c_str())
|
||||
#define MN(v, s) (MNStr(v, s).c_str())
|
||||
|
||||
inline const char *VSuff(MIPSOpcode op)
|
||||
{
|
||||
int a = (op>>7)&1;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "Common/BitScan.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/MIPS/MIPSVFPUUtils.h"
|
||||
@ -538,11 +539,7 @@ MatrixOverlapType GetMatrixOverlap(int mtx1, int mtx2, MatrixSize msize) {
|
||||
return OVERLAP_NONE;
|
||||
}
|
||||
|
||||
const char *GetVectorNotation(int reg, VectorSize size)
|
||||
{
|
||||
static char temp[4][16];
|
||||
static int yo = 0; yo++; yo &= 3;
|
||||
|
||||
std::string GetVectorNotation(int reg, VectorSize size) {
|
||||
int mtx = (reg>>2)&7;
|
||||
int col = reg&3;
|
||||
int row = 0;
|
||||
@ -557,34 +554,27 @@ const char *GetVectorNotation(int reg, VectorSize size)
|
||||
}
|
||||
if (transpose && c == 'C') c='R';
|
||||
if (transpose)
|
||||
snprintf(temp[yo], sizeof(temp[yo]), "%c%i%i%i",c,mtx,row,col);
|
||||
else
|
||||
snprintf(temp[yo], sizeof(temp[yo]), "%c%i%i%i",c,mtx,col,row);
|
||||
return temp[yo];
|
||||
return StringFromFormat("%c%i%i%i", c, mtx, row, col);
|
||||
return StringFromFormat("%c%i%i%i", c, mtx, col, row);
|
||||
}
|
||||
|
||||
const char *GetMatrixNotation(int reg, MatrixSize size)
|
||||
{
|
||||
static char temp[4][16];
|
||||
static int yo=0;yo++;yo&=3;
|
||||
int mtx = (reg>>2)&7;
|
||||
int col = reg&3;
|
||||
int row = 0;
|
||||
int transpose = (reg>>5)&1;
|
||||
char c;
|
||||
switch (size)
|
||||
{
|
||||
case M_2x2: c='M'; row=(reg>>5)&2; break;
|
||||
case M_3x3: c='M'; row=(reg>>6)&1; break;
|
||||
case M_4x4: c='M'; row=(reg>>5)&2; break;
|
||||
default: c='?'; break;
|
||||
}
|
||||
if (transpose && c=='M') c='E';
|
||||
if (transpose)
|
||||
snprintf(temp[yo], sizeof(temp[yo]), "%c%i%i%i",c,mtx,row,col);
|
||||
else
|
||||
snprintf(temp[yo], sizeof(temp[yo]), "%c%i%i%i",c,mtx,col,row);
|
||||
return temp[yo];
|
||||
std::string GetMatrixNotation(int reg, MatrixSize size) {
|
||||
int mtx = (reg>>2)&7;
|
||||
int col = reg&3;
|
||||
int row = 0;
|
||||
int transpose = (reg>>5)&1;
|
||||
char c;
|
||||
switch (size)
|
||||
{
|
||||
case M_2x2: c='M'; row=(reg>>5)&2; break;
|
||||
case M_3x3: c='M'; row=(reg>>6)&1; break;
|
||||
case M_4x4: c='M'; row=(reg>>5)&2; break;
|
||||
default: c='?'; break;
|
||||
}
|
||||
if (transpose && c=='M') c='E';
|
||||
if (transpose)
|
||||
return StringFromFormat("%c%i%i%i", c, mtx, row, col);
|
||||
return StringFromFormat("%c%i%i%i", c, mtx, col, row);
|
||||
}
|
||||
|
||||
bool GetVFPUCtrlMask(int reg, u32 *mask) {
|
||||
|
@ -16,8 +16,9 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#pragma once
|
||||
#include <cmath>
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
@ -216,8 +217,8 @@ VectorSize MatrixVectorSize(MatrixSize sz);
|
||||
int GetNumVectorElements(VectorSize sz);
|
||||
int GetMatrixSideSafe(MatrixSize sz);
|
||||
int GetMatrixSide(MatrixSize sz);
|
||||
const char *GetVectorNotation(int reg, VectorSize size);
|
||||
const char *GetMatrixNotation(int reg, MatrixSize size);
|
||||
std::string GetVectorNotation(int reg, VectorSize size);
|
||||
std::string GetMatrixNotation(int reg, MatrixSize size);
|
||||
inline bool IsMatrixTransposed(int matrixReg) {
|
||||
return (matrixReg >> 5) & 1;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
|
||||
{
|
||||
for (int reg = 0; reg < debugger->GetNumRegsInCategory(cat); reg++)
|
||||
{
|
||||
if (strcasecmp(debugger->GetRegName(cat,reg),registerName.c_str()) == 0)
|
||||
if (strcasecmp(debugger->GetRegName(cat,reg).c_str(), registerName.c_str()) == 0)
|
||||
{
|
||||
debugger->SetRegValue(cat,reg,value);
|
||||
Reporting::NotifyDebugger();
|
||||
|
@ -251,7 +251,7 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam)
|
||||
if (i<cpu->GetNumRegsInCategory(category))
|
||||
{
|
||||
char temp[256];
|
||||
int temp_len = snprintf(temp, sizeof(temp), "%s", cpu->GetRegName(category, i));
|
||||
int temp_len = snprintf(temp, sizeof(temp), "%s", cpu->GetRegName(category, i).c_str());
|
||||
SetTextColor(hdc,0x600000);
|
||||
TextOutA(hdc,17,rowY1,temp,temp_len);
|
||||
SetTextColor(hdc,0x000000);
|
||||
|
@ -243,8 +243,8 @@ bool TestArmEmitter() {
|
||||
int R001 = GetRowName(0, M_4x4, 1, 0);
|
||||
int R002 = GetRowName(0, M_4x4, 2, 0);
|
||||
int R003 = GetRowName(0, M_4x4, 3, 0);
|
||||
printf("Col 010: %s\n", GetVectorNotation(C010, V_Quad));
|
||||
printf("Row 003: %s\n", GetVectorNotation(R003, V_Quad));
|
||||
printf("Col 010: %s\n", GetVectorNotation(C010, V_Quad).c_str());
|
||||
printf("Row 003: %s\n", GetVectorNotation(R003, V_Quad).c_str());
|
||||
|
||||
MIPSAnalyst::AnalysisResults results;
|
||||
memset(&results, 0, sizeof(results));
|
||||
|
@ -431,7 +431,7 @@ bool TestMatrixTranspose() {
|
||||
}
|
||||
|
||||
void TestGetMatrix(int matrix, MatrixSize sz) {
|
||||
INFO_LOG(SYSTEM, "Testing matrix %s", GetMatrixNotation(matrix, sz));
|
||||
INFO_LOG(SYSTEM, "Testing matrix %s", GetMatrixNotation(matrix, sz).c_str());
|
||||
u8 fullMatrix[16];
|
||||
|
||||
u8 cols[4];
|
||||
@ -449,8 +449,8 @@ void TestGetMatrix(int matrix, MatrixSize sz) {
|
||||
// int rowName = GetRowName(matrix, sz, i, 0);
|
||||
int colName = cols[i];
|
||||
int rowName = rows[i];
|
||||
INFO_LOG(SYSTEM, "Column %i: %s", i, GetVectorNotation(colName, vsz));
|
||||
INFO_LOG(SYSTEM, "Row %i: %s", i, GetVectorNotation(rowName, vsz));
|
||||
INFO_LOG(SYSTEM, "Column %i: %s", i, GetVectorNotation(colName, vsz).c_str());
|
||||
INFO_LOG(SYSTEM, "Row %i: %s", i, GetVectorNotation(rowName, vsz).c_str());
|
||||
|
||||
u8 colRegs[4];
|
||||
u8 rowRegs[4];
|
||||
|
Loading…
Reference in New Issue
Block a user