mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-03 03:03:50 +01:00
Centralize a disassembly utility function between the debuggers
This commit is contained in:
1 parent
9396030f02
commit
4f8859d0ec
7 files changed
+125
-189
No files matched your search
@@ -888,90 +888,7 @@ void ImDisasmView::updateStatusBarText() {
|
||||
char text[512];
|
||||
DisassemblyLineInfo line;
|
||||
g_disassemblyManager.getLine(curAddress_, true, line, debugger_);
|
||||
|
||||
text[0] = 0;
|
||||
if (line.type == DISTYPE_OPCODE) {
|
||||
if (line.info.hasRelevantAddress && IsLikelyStringAt(line.info.relevantAddress)) {
|
||||
snprintf(text, sizeof(text), "[%08X] = \"%s\"", line.info.relevantAddress, Memory::GetCharPointer(line.info.relevantAddress));
|
||||
}
|
||||
|
||||
if (line.info.isDataAccess) {
|
||||
if (!Memory::IsValidRange(line.info.dataAddress, line.info.dataSize)) {
|
||||
snprintf(text, sizeof(text), "Invalid address range %08X (size %d)", line.info.dataAddress, line.info.dataSize);
|
||||
} else {
|
||||
bool isFloat = MIPSGetInfo(line.info.encodedOpcode) & (IS_FPU | IS_VFPU);
|
||||
switch (line.info.dataSize) {
|
||||
case 1:
|
||||
snprintf(text, sizeof(text), "[%08X] = %02X", line.info.dataAddress, Memory::ReadUnchecked_U8(line.info.dataAddress));
|
||||
break;
|
||||
case 2:
|
||||
snprintf(text, sizeof(text), "[%08X] = %04X", line.info.dataAddress, Memory::ReadUnchecked_U16(line.info.dataAddress));
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
u32 dataInt = Memory::ReadUnchecked_U32(line.info.dataAddress);
|
||||
u32 dataFloat = Memory::ReadUnchecked_Float(line.info.dataAddress);
|
||||
std::string dataString;
|
||||
if (isFloat)
|
||||
dataString = StringFromFormat("%08X / %f", dataInt, dataFloat);
|
||||
else
|
||||
dataString = StringFromFormat("%08X", dataInt);
|
||||
|
||||
const std::string addressSymbol = g_symbolMap->GetLabelString(dataInt);
|
||||
if (!addressSymbol.empty()) {
|
||||
snprintf(text, sizeof(text), "[%08X] = %s (%s)", line.info.dataAddress, addressSymbol.c_str(), dataString.c_str());
|
||||
} else {
|
||||
snprintf(text, sizeof(text), "[%08X] = %s", line.info.dataAddress, dataString.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
uint32_t dataInt[4];
|
||||
float dataFloat[4];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
dataInt[i] = Memory::ReadUnchecked_U32(line.info.dataAddress + i * 4);
|
||||
dataFloat[i] = Memory::ReadUnchecked_Float(line.info.dataAddress + i * 4);
|
||||
}
|
||||
std::string dataIntString = StringFromFormat("%08X,%08X,%08X,%08X", dataInt[0], dataInt[1], dataInt[2], dataInt[3]);
|
||||
std::string dataFloatString = StringFromFormat("%f,%f,%f,%f", dataFloat[0], dataFloat[1], dataFloat[2], dataFloat[3]);
|
||||
|
||||
snprintf(text, sizeof(text), "[%08X] = %s / %s", line.info.dataAddress, dataIntString.c_str(), dataFloatString.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.info.isBranch) {
|
||||
const std::string addressSymbol = g_symbolMap->GetLabelString(line.info.branchTarget);
|
||||
if (addressSymbol.empty()) {
|
||||
snprintf(text, sizeof(text), "%08X", line.info.branchTarget);
|
||||
} else {
|
||||
snprintf(text, sizeof(text), "%08X = %s", line.info.branchTarget, addressSymbol.c_str());
|
||||
}
|
||||
}
|
||||
} else if (line.type == DISTYPE_DATA) {
|
||||
u32 start = g_symbolMap->GetDataStart(curAddress_);
|
||||
if (start == -1)
|
||||
start = curAddress_;
|
||||
|
||||
u32 diff = curAddress_ - start;
|
||||
const std::string label = g_symbolMap->GetLabelString(start);
|
||||
|
||||
if (!label.empty()) {
|
||||
if (diff != 0)
|
||||
snprintf(text, sizeof(text), "%08X (%s) + %08X", start, label.c_str(), diff);
|
||||
else
|
||||
snprintf(text, sizeof(text), "%08X (%s)", start, label.c_str());
|
||||
} else {
|
||||
if (diff != 0)
|
||||
snprintf(text, sizeof(text), "%08X + %08X", start, diff);
|
||||
else
|
||||
snprintf(text, sizeof(text), "%08X", start);
|
||||
}
|
||||
}
|
||||
|
||||
line.ToString(text, sizeof(text), curAddress_);
|
||||
statusBarText_ = text;
|
||||
|
||||
const std::string label = g_symbolMap->GetLabelString(line.info.opcodeAddress);
|
||||
|
||||
Reference in new issue
Block a user