diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2016-10-02 20:34:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-02 20:34:10 -0700 |
| commit | 53cb04f07e3f2a8ada4e2386acc0676ac26ff70b (patch) | |
| tree | 5d0a8ebfabe571c408cd3dbf796c48e58a184ae2 /Source/Core | |
| parent | 17aef319e868ff04356826722f5f35a7a1f386ae (diff) | |
| parent | 567d0204dd0406612143c140bb48e634dfbcb226 (diff) | |
Merge pull request #4260 from lioncash/debugger
RegisterView: Minor changes
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinWX/Debugger/RegisterView.cpp | 303 | ||||
| -rw-r--r-- | Source/Core/DolphinWX/Debugger/RegisterView.h | 36 |
2 files changed, 169 insertions, 170 deletions
diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp index 5c0a7e105c..f7145fd577 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, @@ -36,86 +38,138 @@ enum IDM_VIEW_INT }; -enum class FormatSpecifier -{ - Hex8, - Hex16, - Float, - Double, - UInt, - Int -}; - constexpr const char* special_reg_names[] = {"PC", "LR", "CTR", "CR", "FPSCR", "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)) @@ -125,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)) @@ -135,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)) @@ -145,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)) @@ -159,23 +216,39 @@ 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() +{ + for (auto& entry : m_formatFRegs) + entry.fill(FormatSpecifier::Hex16); +} + +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) @@ -197,43 +270,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) @@ -325,53 +361,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) @@ -541,27 +530,33 @@ void CRegisterView::OnPopupMenu(wxCommandEvent& event) Refresh(); break; case IDM_VIEW_HEX8: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::Hex8); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::Hex8); Refresh(); break; case IDM_VIEW_HEX16: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::Hex16); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::Hex16); Refresh(); break; case IDM_VIEW_INT: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::Int); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::Int); Refresh(); break; case IDM_VIEW_UINT: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::UInt); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::UInt); Refresh(); break; case IDM_VIEW_FLOAT: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::Float); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::Float); Refresh(); break; case IDM_VIEW_DOUBLE: - m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, FormatSpecifier::Double); + m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow, + CRegTable::FormatSpecifier::Double); Refresh(); break; } diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.h b/Source/Core/DolphinWX/Debugger/RegisterView.h index 886a745b80..5da6c206fe 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.h +++ b/Source/Core/DolphinWX/Debugger/RegisterView.h @@ -5,6 +5,7 @@ #pragma once #include <array> +#include <cstddef> #include <cstring> #include <wx/grid.h> @@ -26,13 +27,19 @@ // Interrupt Mask (PI) // Interrupt Cause(PI) -#define NUM_SPECIALS 14 - -enum class FormatSpecifier; - class CRegTable : public wxGridTableBase { public: + enum class FormatSpecifier + { + Hex8, + Hex16, + Float, + Double, + UInt, + Int + }; + CRegTable(); int GetNumberCols() override { return 9; } int GetNumberRows() override { return 32 + NUM_SPECIALS; } @@ -44,22 +51,19 @@ public: void UpdateCachedRegs(); private: - u32 m_CachedRegs[32]; - u32 m_CachedSpecialRegs[NUM_SPECIALS]; - u64 m_CachedFRegs[32][2]; - bool m_CachedRegHasChanged[32]; - bool m_CachedSpecialRegHasChanged[NUM_SPECIALS]; - bool m_CachedFRegHasChanged[32][2]; - std::array<FormatSpecifier, 32> m_formatRegs; + static constexpr size_t NUM_SPECIALS = 14; + + std::array<u32, 32> m_CachedRegs{}; + std::array<u32, NUM_SPECIALS> m_CachedSpecialRegs{}; + std::array<std::array<u64, 2>, 32> m_CachedFRegs{}; + std::array<bool, 32> m_CachedRegHasChanged{}; + std::array<bool, NUM_SPECIALS> m_CachedSpecialRegHasChanged{}; + std::array<std::array<bool, 2>, 32> m_CachedFRegHasChanged{}; + std::array<FormatSpecifier, 32> m_formatRegs{}; std::array<std::array<FormatSpecifier, 2>, 32> m_formatFRegs; - u32 GetSpecialRegValue(int reg); - void SetSpecialRegValue(int reg, u32 value); - wxString GetFormatString(FormatSpecifier specifier); wxString FormatGPR(int reg_index); wxString FormatFPR(int reg_index, int reg_part); - bool TryParseGPR(wxString str, FormatSpecifier format, u32* value); - bool TryParseFPR(wxString str, FormatSpecifier format, unsigned long long int* value); DECLARE_NO_COPY_CLASS(CRegTable); }; |
