@@ -4,11 +4,13 @@
#include " Core/HW/DSPLLE/DSPDebugInterface.h"
#include < array>
#include < cstddef>
#include < string>
#include < fmt/format.h>
#include " Common/MsgHandler.h"
#include " Common/StringUtil.h"
#include " Core/DSP/DSPCore.h"
#include " Core/DSP/DSPMemoryMap.h"
#include " Core/HW/DSPLLE/DSPSymbols.h"
@@ -20,9 +22,12 @@ void DSPPatches::Patch(std::size_t index)
PanicAlert (" Patch functionality not supported in DSP module." );
}
std::size_t DSPDebugInterface::SetWatch (u32 address, const std::string& name)
DSPDebugInterface::DSPDebugInterface () = default ;
DSPDebugInterface::~DSPDebugInterface () = default ;
std::size_t DSPDebugInterface::SetWatch (u32 address, std::string name)
{
return m_watches.SetWatch (address, name);
return m_watches.SetWatch (address, std::move ( name) );
}
const Common::Debug::Watch& DSPDebugInterface::GetWatch (std::size_t index) const
@@ -40,19 +45,19 @@ void DSPDebugInterface::UnsetWatch(u32 address)
m_watches.UnsetWatch (address);
}
void DSPDebugInterface::UpdateWatch (std::size_t index, u32 address, const std::string& name)
void DSPDebugInterface::UpdateWatch (std::size_t index, u32 address, std::string name)
{
return m_watches.UpdateWatch (index , address, name);
return m_watches.UpdateWatch (index , address, std::move ( name) );
}
void DSPDebugInterface::UpdateWatchAddress (std::size_t index, u32 address)
{
return m_watches.UpdateWatchAddress (index , address);
}
void DSPDebugInterface::UpdateWatchName (std::size_t index, const std::string& name)
void DSPDebugInterface::UpdateWatchName (std::size_t index, std::string name)
{
return m_watches.UpdateWatchName (index , name);
return m_watches.UpdateWatchName (index , std::move ( name) );
}
void DSPDebugInterface::EnableWatch (std::size_t index)
@@ -97,7 +102,7 @@ void DSPDebugInterface::SetPatch(u32 address, u32 value)
void DSPDebugInterface::SetPatch (u32 address, std::vector<u8> value)
{
m_patches.SetPatch (address, value);
m_patches.SetPatch (address, std::move ( value) );
}
const std::vector<Common::Debug::MemoryPatch>& DSPDebugInterface::GetPatches () const
@@ -135,13 +140,13 @@ void DSPDebugInterface::ClearPatches()
m_patches.ClearPatches ();
}
std::string DSPDebugInterface::Disassemble (unsigned int address)
std::string DSPDebugInterface::Disassemble (u32 address) const
{
// we'll treat addresses as line numbers.
return Symbols::GetLineText (address);
}
std::string DSPDebugInterface::GetRawMemoryString (int memory, unsigned int address)
std::string DSPDebugInterface::GetRawMemoryString (int memory, u32 address) const
{
if (DSPCore_GetState () == State::Stopped)
return " " ;
@@ -153,7 +158,7 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int addre
{
case 0 :
case 0x8 :
return StringFromFormat ( " % 04x" , dsp_imem_read (address));
return fmt::format ( " {: 04x} " , dsp_imem_read (address));
default :
return " --IMEM--" ;
}
@@ -163,9 +168,9 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int addre
{
case 0 :
case 1 :
return StringFromFormat ( " % 04x (DMEM)" , dsp_dmem_read (address));
return fmt::format ( " {: 04x} (DMEM)" , dsp_dmem_read (address));
case 0xf :
return StringFromFormat ( " % 04x (MMIO)" , g_dsp.ifx_regs [address & 0xFF ]);
return fmt::format ( " {: 04x} (MMIO)" , g_dsp.ifx_regs [address & 0xFF ]);
default :
return " --DMEM--" ;
}
@@ -174,22 +179,22 @@ std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int addre
return " " ;
}
unsigned int DSPDebugInterface::ReadMemory (unsigned int address)
u32 DSPDebugInterface::ReadMemory (u32 address) const
{
return 0 ;
}
unsigned int DSPDebugInterface::ReadInstruction (unsigned int address)
u32 DSPDebugInterface::ReadInstruction (u32 address) const
{
return 0 ;
}
bool DSPDebugInterface::IsAlive ()
bool DSPDebugInterface::IsAlive () const
{
return true ;
}
bool DSPDebugInterface::IsBreakpoint (unsigned int address)
bool DSPDebugInterface::IsBreakpoint (u32 address) const
{
int real_addr = Symbols::Line2Addr (address);
if (real_addr >= 0 )
@@ -198,7 +203,7 @@ bool DSPDebugInterface::IsBreakpoint(unsigned int address)
return false ;
}
void DSPDebugInterface::SetBreakpoint (unsigned int address)
void DSPDebugInterface::SetBreakpoint (u32 address)
{
int real_addr = Symbols::Line2Addr (address);
@@ -208,7 +213,7 @@ void DSPDebugInterface::SetBreakpoint(unsigned int address)
}
}
void DSPDebugInterface::ClearBreakpoint (unsigned int address)
void DSPDebugInterface::ClearBreakpoint (u32 address)
{
int real_addr = Symbols::Line2Addr (address);
@@ -223,7 +228,7 @@ void DSPDebugInterface::ClearAllBreakpoints()
g_dsp_breakpoints.Clear ();
}
void DSPDebugInterface::ToggleBreakpoint (unsigned int address)
void DSPDebugInterface::ToggleBreakpoint (u32 address)
{
int real_addr = Symbols::Line2Addr (address);
if (real_addr >= 0 )
@@ -235,7 +240,7 @@ void DSPDebugInterface::ToggleBreakpoint(unsigned int address)
}
}
bool DSPDebugInterface::IsMemCheck (unsigned int address, size_t size)
bool DSPDebugInterface::IsMemCheck (u32 address, size_t size) const
{
return false ;
}
@@ -245,25 +250,16 @@ void DSPDebugInterface::ClearAllMemChecks()
PanicAlert (" MemCheck functionality not supported in DSP module." );
}
void DSPDebugInterface::ToggleMemCheck (unsigned int address, bool read, bool write, bool log)
void DSPDebugInterface::ToggleMemCheck (u32 address, bool read, bool write, bool log)
{
PanicAlert (" MemCheck functionality not supported in DSP module." );
}
// =======================================================
// Separate the blocks with colors.
// -------------
int DSPDebugInterface::GetColor (unsigned int address)
u32 DSPDebugInterface::GetColor (u32 address) const
{
static const int colors[6 ] = {
0xd0FFFF , // light cyan
0xFFd0d0 , // light red
0xd8d8FF , // light blue
0xFFd0FF , // light purple
0xd0FFd0 , // light green
0xFFFFd0 , // light yellow
};
// Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good.
int addr = -1 ;
for (int i = 0 ; i < 1 ; i++)
@@ -280,21 +276,30 @@ int DSPDebugInterface::GetColor(unsigned int address)
return 0xFFFFFF ;
if (symbol->type != Common::Symbol::Type::Function)
return 0xEEEEFF ;
return colors[symbol->index % 6 ];
static constexpr std::array<u32, 6 > colors{
0xd0FFFF , // light cyan
0xFFd0d0 , // light red
0xd8d8FF , // light blue
0xFFd0FF , // light purple
0xd0FFd0 , // light green
0xFFFFd0 , // light yellow
};
return colors[symbol->index % colors.size ()];
}
// =============
std::string DSPDebugInterface::GetDescription (unsigned int address)
std::string DSPDebugInterface::GetDescription (u32 address) const
{
return " " ; // g_symbolDB.GetDescription(address);
}
unsigned int DSPDebugInterface::GetPC ()
u32 DSPDebugInterface::GetPC () const
{
return Symbols::Addr2Line (DSP::g_dsp.pc );
}
void DSPDebugInterface::SetPC (unsigned int address)
void DSPDebugInterface::SetPC (u32 address)
{
int new_pc = Symbols::Line2Addr (address);
if (new_pc > 0 )