summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Debugger/RegisterView.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2016-09-30 00:33:06 -0400
committerLioncash <mathew1800@gmail.com>2016-09-30 01:28:47 -0400
commitd080b0e8a564c47c1de15fa760bc0e68850efeb8 (patch)
tree7a111a12a8bdb00684d1ae90ef8f7cf893a45a2e /Source/Core/DolphinWX/Debugger/RegisterView.cpp
parent3ef6b51848a977157b882c5180e5ac799b52674a (diff)
RegisterView: Move CRegTable implementation details into the cpp file
Diffstat (limited to 'Source/Core/DolphinWX/Debugger/RegisterView.cpp')
-rw-r--r--Source/Core/DolphinWX/Debugger/RegisterView.cpp284
1 files changed, 146 insertions, 138 deletions
diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp
index 356b30279e..ff5593ee83 100644
--- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp
+++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp
@@ -23,6 +23,8 @@
// F-zero 80005e60 wtf??
+namespace
+{
enum
{
IDM_WATCHADDRESS,
@@ -40,72 +42,134 @@ constexpr const char* special_reg_names[] = {"PC", "LR", "CTR", "CR",
"MSR", "SRR0", "SRR1", "Exceptions", "Int Mask",
"Int Cause", "DSISR", "DAR", "PT hashmask"};
-CRegTable::CRegTable()
-{
- m_formatRegs.fill(FormatSpecifier::Hex8);
-
- for (auto& entry : m_formatFRegs)
- entry.fill(FormatSpecifier::Hex16);
-
- memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
- memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs));
- memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs));
- memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
- memset(m_CachedSpecialRegHasChanged, 0, sizeof(m_CachedSpecialRegHasChanged));
- memset(m_CachedFRegHasChanged, 0, sizeof(m_CachedFRegHasChanged));
-}
-
-wxString CRegTable::GetFormatString(FormatSpecifier specifier)
+wxString GetFormatString(CRegTable::FormatSpecifier specifier)
{
switch (specifier)
{
- case FormatSpecifier::Hex8:
+ case CRegTable::FormatSpecifier::Hex8:
return wxString("%08x");
- case FormatSpecifier::Hex16:
+ case CRegTable::FormatSpecifier::Hex16:
return wxString("%016llx");
- case FormatSpecifier::Float:
+ case CRegTable::FormatSpecifier::Float:
return wxString("%g");
- case FormatSpecifier::Double:
+ case CRegTable::FormatSpecifier::Double:
return wxString("%g");
- case FormatSpecifier::UInt:
+ case CRegTable::FormatSpecifier::UInt:
return wxString("%u");
- case FormatSpecifier::Int:
+ case CRegTable::FormatSpecifier::Int:
return wxString("%i");
default:
return wxString("");
}
}
-wxString CRegTable::FormatGPR(int reg_index)
+u32 GetSpecialRegValue(int reg)
{
- if (m_formatRegs[reg_index] == FormatSpecifier::Int)
+ switch (reg)
{
- return wxString::Format(GetFormatString(m_formatRegs[reg_index]),
- static_cast<s32>(GPR(reg_index)));
+ case 0:
+ return PowerPC::ppcState.pc;
+ case 1:
+ return PowerPC::ppcState.spr[SPR_LR];
+ case 2:
+ return PowerPC::ppcState.spr[SPR_CTR];
+ case 3:
+ return GetCR();
+ case 4:
+ return PowerPC::ppcState.fpscr;
+ case 5:
+ return PowerPC::ppcState.msr;
+ case 6:
+ return PowerPC::ppcState.spr[SPR_SRR0];
+ case 7:
+ return PowerPC::ppcState.spr[SPR_SRR1];
+ case 8:
+ return PowerPC::ppcState.Exceptions;
+ case 9:
+ return ProcessorInterface::GetMask();
+ case 10:
+ return ProcessorInterface::GetCause();
+ case 11:
+ return PowerPC::ppcState.spr[SPR_DSISR];
+ case 12:
+ return PowerPC::ppcState.spr[SPR_DAR];
+ case 13:
+ return (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
+ default:
+ return 0;
}
- if (m_formatRegs[reg_index] == FormatSpecifier::Float)
+}
+
+void SetSpecialRegValue(int reg, u32 value)
+{
+ switch (reg)
{
- float value;
- std::memcpy(&value, &GPR(reg_index), sizeof(float));
- return wxString::Format(GetFormatString(m_formatRegs[reg_index]), value);
+ case 0:
+ PowerPC::ppcState.pc = value;
+ break;
+ case 1:
+ PowerPC::ppcState.spr[SPR_LR] = value;
+ break;
+ case 2:
+ PowerPC::ppcState.spr[SPR_CTR] = value;
+ break;
+ case 3:
+ SetCR(value);
+ break;
+ case 4:
+ PowerPC::ppcState.fpscr = value;
+ break;
+ case 5:
+ PowerPC::ppcState.msr = value;
+ break;
+ case 6:
+ PowerPC::ppcState.spr[SPR_SRR0] = value;
+ break;
+ case 7:
+ PowerPC::ppcState.spr[SPR_SRR1] = value;
+ break;
+ case 8:
+ PowerPC::ppcState.Exceptions = value;
+ break;
+ // Should we just change the value, or use ProcessorInterface::SetInterrupt() to make the system
+ // aware?
+ // case 9: return ProcessorInterface::GetMask();
+ // case 10: return ProcessorInterface::GetCause();
+ case 11:
+ PowerPC::ppcState.spr[SPR_DSISR] = value;
+ break;
+ case 12:
+ PowerPC::ppcState.spr[SPR_DAR] = value;
+ break;
+ // case 13: (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
+ default:
+ return;
}
- return wxString::Format(GetFormatString(m_formatRegs[reg_index]), GPR(reg_index));
}
-wxString CRegTable::FormatFPR(int reg_index, int reg_part)
+bool TryParseFPR(wxString str, CRegTable::FormatSpecifier format, unsigned long long* value)
{
- if (m_formatFRegs[reg_index][reg_part] == FormatSpecifier::Double)
+ if (format == CRegTable::FormatSpecifier::Hex16)
+ return str.ToULongLong(value, 16);
+
+ if (format == CRegTable::FormatSpecifier::Double)
{
- double reg = (reg_part == 0) ? rPS0(reg_index) : rPS1(reg_index);
- return wxString::Format(GetFormatString(m_formatFRegs[reg_index][reg_part]), reg);
+ double double_val;
+ if (str.ToCDouble(&double_val))
+ {
+ std::memcpy(value, &double_val, sizeof(u64));
+ return true;
+ }
+
+ return false;
}
- u64 reg = (reg_part == 0) ? riPS0(reg_index) : riPS1(reg_index);
- return wxString::Format(GetFormatString(m_formatFRegs[reg_index][reg_part]), reg);
+
+ return false;
}
-bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
+bool TryParseGPR(wxString str, CRegTable::FormatSpecifier format, u32* value)
{
- if (format == FormatSpecifier::Hex8)
+ if (format == CRegTable::FormatSpecifier::Hex8)
{
unsigned long val;
if (str.ToCULong(&val, 16))
@@ -115,7 +179,8 @@ bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
}
return false;
}
- if (format == FormatSpecifier::Int)
+
+ if (format == CRegTable::FormatSpecifier::Int)
{
long signed_val;
if (str.ToCLong(&signed_val))
@@ -125,7 +190,8 @@ bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
}
return false;
}
- if (format == FormatSpecifier::UInt)
+
+ if (format == CRegTable::FormatSpecifier::UInt)
{
unsigned long val;
if (str.ToCULong(&val))
@@ -135,7 +201,8 @@ bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
}
return false;
}
- if (format == FormatSpecifier::Float)
+
+ if (format == CRegTable::FormatSpecifier::Float)
{
double double_val;
if (str.ToCDouble(&double_val))
@@ -149,23 +216,48 @@ bool CRegTable::TryParseGPR(wxString str, FormatSpecifier format, u32* value)
return false;
}
-bool CRegTable::TryParseFPR(wxString str, FormatSpecifier format, unsigned long long* value)
+} // Anonymous namespace
+
+CRegTable::CRegTable()
+{
+ m_formatRegs.fill(FormatSpecifier::Hex8);
+
+ for (auto& entry : m_formatFRegs)
+ entry.fill(FormatSpecifier::Hex16);
+
+ memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
+ memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs));
+ memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs));
+ memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
+ memset(m_CachedSpecialRegHasChanged, 0, sizeof(m_CachedSpecialRegHasChanged));
+ memset(m_CachedFRegHasChanged, 0, sizeof(m_CachedFRegHasChanged));
+}
+
+wxString CRegTable::FormatGPR(int reg_index)
{
- if (format == FormatSpecifier::Hex16)
+ if (m_formatRegs[reg_index] == FormatSpecifier::Int)
{
- return str.ToULongLong(value, 16);
+ return wxString::Format(GetFormatString(m_formatRegs[reg_index]),
+ static_cast<s32>(GPR(reg_index)));
}
- if (format == FormatSpecifier::Double)
+ if (m_formatRegs[reg_index] == FormatSpecifier::Float)
{
- double double_val;
- if (str.ToCDouble(&double_val))
- {
- std::memcpy(value, &double_val, sizeof(u64));
- return true;
- }
- return false;
+ float value;
+ std::memcpy(&value, &GPR(reg_index), sizeof(float));
+ return wxString::Format(GetFormatString(m_formatRegs[reg_index]), value);
}
- return false;
+ return wxString::Format(GetFormatString(m_formatRegs[reg_index]), GPR(reg_index));
+}
+
+wxString CRegTable::FormatFPR(int reg_index, int reg_part)
+{
+ if (m_formatFRegs[reg_index][reg_part] == FormatSpecifier::Double)
+ {
+ double reg = (reg_part == 0) ? rPS0(reg_index) : rPS1(reg_index);
+ return wxString::Format(GetFormatString(m_formatFRegs[reg_index][reg_part]), reg);
+ }
+ u64 reg = (reg_part == 0) ? riPS0(reg_index) : riPS1(reg_index);
+ return wxString::Format(GetFormatString(m_formatFRegs[reg_index][reg_part]), reg);
}
void CRegTable::SetRegisterFormat(int col, int row, FormatSpecifier specifier)
@@ -187,43 +279,6 @@ void CRegTable::SetRegisterFormat(int col, int row, FormatSpecifier specifier)
}
}
-u32 CRegTable::GetSpecialRegValue(int reg)
-{
- switch (reg)
- {
- case 0:
- return PowerPC::ppcState.pc;
- case 1:
- return PowerPC::ppcState.spr[SPR_LR];
- case 2:
- return PowerPC::ppcState.spr[SPR_CTR];
- case 3:
- return GetCR();
- case 4:
- return PowerPC::ppcState.fpscr;
- case 5:
- return PowerPC::ppcState.msr;
- case 6:
- return PowerPC::ppcState.spr[SPR_SRR0];
- case 7:
- return PowerPC::ppcState.spr[SPR_SRR1];
- case 8:
- return PowerPC::ppcState.Exceptions;
- case 9:
- return ProcessorInterface::GetMask();
- case 10:
- return ProcessorInterface::GetCause();
- case 11:
- return PowerPC::ppcState.spr[SPR_DSISR];
- case 12:
- return PowerPC::ppcState.spr[SPR_DAR];
- case 13:
- return (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
- default:
- return 0;
- }
-}
-
wxString CRegTable::GetValue(int row, int col)
{
if (row < 32)
@@ -315,53 +370,6 @@ wxString CRegTable::GetValue(int row, int col)
return wxEmptyString;
}
-void CRegTable::SetSpecialRegValue(int reg, u32 value)
-{
- switch (reg)
- {
- case 0:
- PowerPC::ppcState.pc = value;
- break;
- case 1:
- PowerPC::ppcState.spr[SPR_LR] = value;
- break;
- case 2:
- PowerPC::ppcState.spr[SPR_CTR] = value;
- break;
- case 3:
- SetCR(value);
- break;
- case 4:
- PowerPC::ppcState.fpscr = value;
- break;
- case 5:
- PowerPC::ppcState.msr = value;
- break;
- case 6:
- PowerPC::ppcState.spr[SPR_SRR0] = value;
- break;
- case 7:
- PowerPC::ppcState.spr[SPR_SRR1] = value;
- break;
- case 8:
- PowerPC::ppcState.Exceptions = value;
- break;
- // Should we just change the value, or use ProcessorInterface::SetInterrupt() to make the system
- // aware?
- // case 9: return ProcessorInterface::GetMask();
- // case 10: return ProcessorInterface::GetCause();
- case 11:
- PowerPC::ppcState.spr[SPR_DSISR] = value;
- break;
- case 12:
- PowerPC::ppcState.spr[SPR_DAR] = value;
- break;
- // case 13: (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
- default:
- return;
- }
-}
-
void CRegTable::SetValue(int row, int col, const wxString& strNewVal)
{
if (row < 32)