mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-18 20:04:31 +01:00
Merge pull request #14399 from unknownbrackets/debugger
Debugger: Show string in status bar for li, etc.
This commit is contained in:
4 files changed
+43
No files matched your search
@@ -23,6 +23,7 @@
|
||||
#include "ext/xxhash.h"
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/MIPS/MIPSCodeUtils.h"
|
||||
@@ -41,6 +42,39 @@ bool isInInterval(u32 start, u32 size, u32 value)
|
||||
return start <= value && value <= (start+size-1);
|
||||
}
|
||||
|
||||
bool IsLikelyStringAt(uint32_t addr) {
|
||||
uint32_t maxLen = Memory::ValidSize(addr, 128);
|
||||
if (maxLen <= 1)
|
||||
return false;
|
||||
const char *p = Memory::GetCharPointer(addr);
|
||||
// If there's no terminator nearby, let's say no.
|
||||
if (memchr(p, 0, maxLen) == nullptr)
|
||||
return false;
|
||||
|
||||
// Allow tabs and newlines.
|
||||
static constexpr bool validControl[] = {
|
||||
false, false, false, false, false, false, false, false,
|
||||
false, true, true, true, false, true, false, false,
|
||||
false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false,
|
||||
};
|
||||
|
||||
// Check that there's some bytes before the terminator that look like a string.
|
||||
UTF8 utf(p);
|
||||
if (utf.end())
|
||||
return false;
|
||||
|
||||
while (!utf.end()) {
|
||||
if (utf.invalid())
|
||||
return false;
|
||||
|
||||
uint32_t c = utf.next();
|
||||
if (c < ARRAY_SIZE(validControl) && !validControl[c])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static HashType computeHash(u32 address, u32 size)
|
||||
{
|
||||
|
||||
@@ -224,3 +224,4 @@ private:
|
||||
};
|
||||
|
||||
bool isInInterval(u32 start, u32 size, u32 value);
|
||||
bool IsLikelyStringAt(uint32_t addr);
|
||||
@@ -188,6 +188,10 @@ void WebSocketDisasmState::WriteDisasmLine(JsonWriter &json, const DisassemblyLi
|
||||
json.writeUint("uintValue", Memory::ReadUnchecked_U32(l.info.relevantAddress));
|
||||
else
|
||||
json.writeNull("uintValue");
|
||||
if (IsLikelyStringAt(l.info.relevantAddress))
|
||||
json.writeString("stringValue", Memory::GetCharPointer(l.info.relevantAddress));
|
||||
else
|
||||
json.writeNull("stringValue");
|
||||
json.pop();
|
||||
} else {
|
||||
json.writeNull("relevantData");
|
||||
|
||||
@@ -1094,6 +1094,10 @@ void CtrlDisAsmView::updateStatusBarText()
|
||||
text[0] = 0;
|
||||
if (line.type == DISTYPE_OPCODE || line.type == DISTYPE_MACRO)
|
||||
{
|
||||
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::IsValidAddress(line.info.dataAddress))
|
||||
|
||||
Reference in new issue
Block a user