summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2016-10-07 09:56:02 -0400
committerLioncash <mathew1800@gmail.com>2016-10-07 10:26:26 -0400
commitee71d707388e4ce2103a0f513bdb181b23d166bc (patch)
tree1bea91e5da32e31733588eebfe12328a34141b90 /Source/Core
parent3245ca236ae076f5fa08ce6ce72b06d9c30a6ece (diff)
DebugInterface: Make GetRawMemoryString return a std::string
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/DebugInterface.h5
-rw-r--r--Source/Core/Core/Debugger/PPCDebugInterface.cpp30
-rw-r--r--Source/Core/Core/Debugger/PPCDebugInterface.h2
-rw-r--r--Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp32
-rw-r--r--Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h2
-rw-r--r--Source/Core/DolphinWX/Debugger/MemoryView.cpp3
6 files changed, 30 insertions, 44 deletions
diff --git a/Source/Core/Common/DebugInterface.h b/Source/Core/Common/DebugInterface.h
index 3aa8faec8f..df9944ef23 100644
--- a/Source/Core/Common/DebugInterface.h
+++ b/Source/Core/Common/DebugInterface.h
@@ -13,10 +13,9 @@ protected:
virtual ~DebugInterface() {}
public:
virtual std::string Disassemble(unsigned int /*address*/) { return "NODEBUGGER"; }
- virtual void GetRawMemoryString(int /*memory*/, unsigned int /*address*/, char* dest,
- int /*max_size*/)
+ virtual std::string GetRawMemoryString(int /*memory*/, unsigned int /*address*/)
{
- strcpy(dest, "NODEBUGGER");
+ return "NODEBUGGER";
}
virtual int GetInstructionSize(int /*instruction*/) { return 1; }
virtual bool IsAlive() { return true; }
diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp
index 3073178d23..b64d3c380b 100644
--- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp
+++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp
@@ -2,16 +2,15 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "Core/Debugger/PPCDebugInterface.h"
+
#include <string>
#include "Common/GekkoDisassembler.h"
+#include "Common/StringUtil.h"
#include "Core/Core.h"
-#include "Core/Debugger/Debugger_SymbolMap.h"
-#include "Core/Debugger/PPCDebugInterface.h"
#include "Core/HW/DSP.h"
-#include "Core/HW/Memmap.h"
-#include "Core/Host.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h"
@@ -48,24 +47,19 @@ std::string PPCDebugInterface::Disassemble(unsigned int address)
}
}
-void PPCDebugInterface::GetRawMemoryString(int memory, unsigned int address, char* dest,
- int max_size)
+std::string PPCDebugInterface::GetRawMemoryString(int memory, unsigned int address)
{
if (IsAlive())
{
- if (memory || PowerPC::HostIsRAMAddress(address))
- {
- snprintf(dest, max_size, "%08X%s", ReadExtraMemory(memory, address), memory ? " (ARAM)" : "");
- }
- else
- {
- strcpy(dest, memory ? "--ARAM--" : "--------");
- }
- }
- else
- {
- strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
+ const bool is_aram = memory != 0;
+
+ if (is_aram || PowerPC::HostIsRAMAddress(address))
+ return StringFromFormat("%08X%s", ReadExtraMemory(memory, address), is_aram ? " (ARAM)" : "");
+
+ return is_aram ? "--ARAM--" : "--------";
}
+
+ return "<unknwn>"; // bad spelling - 8 chars
}
unsigned int PPCDebugInterface::ReadMemory(unsigned int address)
diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.h b/Source/Core/Core/Debugger/PPCDebugInterface.h
index 21777089de..1d37de630e 100644
--- a/Source/Core/Core/Debugger/PPCDebugInterface.h
+++ b/Source/Core/Core/Debugger/PPCDebugInterface.h
@@ -15,7 +15,7 @@ class PPCDebugInterface final : public DebugInterface
public:
PPCDebugInterface() {}
std::string Disassemble(unsigned int address) override;
- void GetRawMemoryString(int memory, unsigned int address, char* dest, int max_size) override;
+ std::string GetRawMemoryString(int memory, unsigned int address) override;
int GetInstructionSize(int /*instruction*/) override { return 4; }
bool IsAlive() override;
bool IsBreakpoint(unsigned int address) override;
diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp
index a97077346b..5c3982a07c 100644
--- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp
+++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp
@@ -2,12 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "Core/HW/DSPLLE/DSPDebugInterface.h"
+
#include <string>
#include "Common/MsgHandler.h"
+#include "Common/StringUtil.h"
#include "Core/DSP/DSPCore.h"
#include "Core/DSP/DSPMemoryMap.h"
-#include "Core/HW/DSPLLE/DSPDebugInterface.h"
#include "Core/HW/DSPLLE/DSPSymbols.h"
std::string DSPDebugInterface::Disassemble(unsigned int address)
@@ -16,14 +18,10 @@ std::string DSPDebugInterface::Disassemble(unsigned int address)
return DSPSymbols::GetLineText(address);
}
-void DSPDebugInterface::GetRawMemoryString(int memory, unsigned int address, char* dest,
- int max_size)
+std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int address)
{
if (DSPCore_GetState() == DSPCORE_STOP)
- {
- dest[0] = 0;
- return;
- }
+ return "";
switch (memory)
{
@@ -32,29 +30,25 @@ void DSPDebugInterface::GetRawMemoryString(int memory, unsigned int address, cha
{
case 0:
case 0x8:
- sprintf(dest, "%04x", dsp_imem_read(address));
- break;
+ return StringFromFormat("%04x", dsp_imem_read(address));
default:
- sprintf(dest, "--IMEM--");
- break;
+ return "--IMEM--";
}
- break;
+
case 1: // DMEM
switch (address >> 12)
{
case 0:
case 1:
- sprintf(dest, "%04x (DMEM)", dsp_dmem_read(address));
- break;
+ return StringFromFormat("%04x (DMEM)", dsp_dmem_read(address));
case 0xf:
- sprintf(dest, "%04x (MMIO)", g_dsp.ifx_regs[address & 0xFF]);
- break;
+ return StringFromFormat("%04x (MMIO)", g_dsp.ifx_regs[address & 0xFF]);
default:
- sprintf(dest, "--DMEM--");
- break;
+ return "--DMEM--";
}
- break;
}
+
+ return "";
}
unsigned int DSPDebugInterface::ReadMemory(unsigned int address)
diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h
index c492c8946f..15147cbd7a 100644
--- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h
+++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.h
@@ -14,7 +14,7 @@ class DSPDebugInterface final : public DebugInterface
public:
DSPDebugInterface() {}
std::string Disassemble(unsigned int address) override;
- void GetRawMemoryString(int memory, unsigned int address, char* dest, int max_size) override;
+ std::string GetRawMemoryString(int memory, unsigned int address) override;
int GetInstructionSize(int instruction) override { return 1; }
bool IsAlive() override;
bool IsBreakpoint(unsigned int address) override;
diff --git a/Source/Core/DolphinWX/Debugger/MemoryView.cpp b/Source/Core/DolphinWX/Debugger/MemoryView.cpp
index 67a38aa0b5..e847e0e855 100644
--- a/Source/Core/DolphinWX/Debugger/MemoryView.cpp
+++ b/Source/Core/DolphinWX/Debugger/MemoryView.cpp
@@ -332,8 +332,7 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
if (!IsHexMode())
{
- char mem[256];
- debugger->GetRawMemoryString(memory, address, mem, 256);
+ const std::string mem = debugger->GetRawMemoryString(memory, address);
dc.SetTextForeground(navy_color);
draw_text(StrToWxStr(mem), 2);
}