2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2017-12-10 19:58:10 +00:00
|
|
|
#include <cinttypes>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/grid.h>
|
2014-10-23 13:47:00 +00:00
|
|
|
#include <wx/menu.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2014-07-18 01:33:51 +00:00
|
|
|
#include "Common/GekkoDisassembler.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/StringUtil.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/HW/ProcessorInterface.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Core/PowerPC/Gekko.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/CodeWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/MemoryWindow.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/RegisterView.h"
|
2014-10-23 13:47:00 +00:00
|
|
|
#include "DolphinWX/Debugger/WatchWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
|
|
|
#include "DolphinWX/Globals.h"
|
2016-10-03 07:29:50 +00:00
|
|
|
#include "DolphinWX/Main.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:15:33 +00:00
|
|
|
// F-zero 80005e60 wtf??
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
namespace
|
|
|
|
{
|
2014-10-23 13:47:00 +00:00
|
|
|
enum
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IDM_WATCHADDRESS,
|
|
|
|
IDM_VIEWMEMORY,
|
2016-08-31 22:31:39 +00:00
|
|
|
IDM_VIEWCODE,
|
|
|
|
IDM_VIEW_HEX8,
|
|
|
|
IDM_VIEW_HEX16,
|
|
|
|
IDM_VIEW_FLOAT,
|
|
|
|
IDM_VIEW_DOUBLE,
|
|
|
|
IDM_VIEW_UINT,
|
|
|
|
IDM_VIEW_INT
|
2014-10-23 13:47:00 +00:00
|
|
|
};
|
|
|
|
|
2017-12-01 10:01:21 +00:00
|
|
|
constexpr const char* special_reg_names[] = {
|
|
|
|
"PC", "LR", "CTR", "CR", "XER", "FPSCR", "MSR", "SRR0",
|
|
|
|
"SRR1", "Exceptions", "Int Mask", "Int Cause", "DSISR", "DAR", "PT hashmask"};
|
2016-08-31 22:31:39 +00:00
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
wxString GetFormatString(CRegTable::FormatSpecifier specifier)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
switch (specifier)
|
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::Hex8:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%08x");
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::Hex16:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%016llx");
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::Float:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%g");
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::Double:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%g");
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::UInt:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%u");
|
2016-09-30 04:33:06 +00:00
|
|
|
case CRegTable::FormatSpecifier::Int:
|
2016-08-31 22:31:39 +00:00
|
|
|
return wxString("%i");
|
|
|
|
default:
|
|
|
|
return wxString("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
u32 GetSpecialRegValue(int reg)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
switch (reg)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
case 0:
|
|
|
|
return PowerPC::ppcState.pc;
|
|
|
|
case 1:
|
|
|
|
return PowerPC::ppcState.spr[SPR_LR];
|
|
|
|
case 2:
|
|
|
|
return PowerPC::ppcState.spr[SPR_CTR];
|
|
|
|
case 3:
|
2018-03-22 22:24:04 +00:00
|
|
|
return PowerPC::GetCR();
|
2016-09-30 04:33:06 +00:00
|
|
|
case 4:
|
2018-03-22 22:24:04 +00:00
|
|
|
return PowerPC::GetXER().Hex;
|
2016-09-30 04:33:06 +00:00
|
|
|
case 5:
|
2018-05-06 22:22:19 +00:00
|
|
|
return PowerPC::ppcState.fpscr.Hex;
|
2016-09-30 04:33:06 +00:00
|
|
|
case 6:
|
2018-05-05 21:02:58 +00:00
|
|
|
return PowerPC::ppcState.msr.Hex;
|
2016-09-30 04:33:06 +00:00
|
|
|
case 7:
|
2017-12-01 10:01:21 +00:00
|
|
|
return PowerPC::ppcState.spr[SPR_SRR0];
|
2016-09-30 04:33:06 +00:00
|
|
|
case 8:
|
2017-12-01 10:01:21 +00:00
|
|
|
return PowerPC::ppcState.spr[SPR_SRR1];
|
2016-09-30 04:33:06 +00:00
|
|
|
case 9:
|
2017-12-01 10:01:21 +00:00
|
|
|
return PowerPC::ppcState.Exceptions;
|
2016-09-30 04:33:06 +00:00
|
|
|
case 10:
|
2017-12-01 10:01:21 +00:00
|
|
|
return ProcessorInterface::GetMask();
|
2016-09-30 04:33:06 +00:00
|
|
|
case 11:
|
2017-12-01 10:01:21 +00:00
|
|
|
return ProcessorInterface::GetCause();
|
2016-09-30 04:33:06 +00:00
|
|
|
case 12:
|
2017-12-01 10:01:21 +00:00
|
|
|
return PowerPC::ppcState.spr[SPR_DSISR];
|
2016-09-30 04:33:06 +00:00
|
|
|
case 13:
|
2017-12-01 10:01:21 +00:00
|
|
|
return PowerPC::ppcState.spr[SPR_DAR];
|
|
|
|
case 14:
|
2016-09-30 04:33:06 +00:00
|
|
|
return (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
|
|
|
|
default:
|
|
|
|
return 0;
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetSpecialRegValue(int reg, u32 value)
|
|
|
|
{
|
|
|
|
switch (reg)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
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:
|
2018-03-22 22:24:04 +00:00
|
|
|
PowerPC::SetCR(value);
|
2016-09-30 04:33:06 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2018-03-22 22:24:04 +00:00
|
|
|
PowerPC::SetXER(UReg_XER(value));
|
2016-09-30 04:33:06 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2018-05-06 22:22:19 +00:00
|
|
|
PowerPC::ppcState.fpscr.Hex = value;
|
2016-09-30 04:33:06 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2018-05-05 21:02:58 +00:00
|
|
|
PowerPC::ppcState.msr.Hex = value;
|
2016-09-30 04:33:06 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
2017-12-01 10:01:21 +00:00
|
|
|
PowerPC::ppcState.spr[SPR_SRR0] = value;
|
2016-09-30 04:33:06 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
2017-12-01 10:01:21 +00:00
|
|
|
PowerPC::ppcState.spr[SPR_SRR1] = value;
|
|
|
|
break;
|
|
|
|
case 9:
|
2016-09-30 04:33:06 +00:00
|
|
|
PowerPC::ppcState.Exceptions = value;
|
|
|
|
break;
|
|
|
|
// Should we just change the value, or use ProcessorInterface::SetInterrupt() to make the system
|
|
|
|
// aware?
|
2017-12-01 10:01:21 +00:00
|
|
|
// case 10: return ProcessorInterface::GetMask();
|
|
|
|
// case 11: return ProcessorInterface::GetCause();
|
|
|
|
case 12:
|
2016-09-30 04:33:06 +00:00
|
|
|
PowerPC::ppcState.spr[SPR_DSISR] = value;
|
|
|
|
break;
|
2017-12-01 10:01:21 +00:00
|
|
|
case 13:
|
2016-09-30 04:33:06 +00:00
|
|
|
PowerPC::ppcState.spr[SPR_DAR] = value;
|
|
|
|
break;
|
2017-12-01 10:01:21 +00:00
|
|
|
// case 14: (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base;
|
2016-09-30 04:33:06 +00:00
|
|
|
default:
|
|
|
|
return;
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
bool TryParseFPR(wxString str, CRegTable::FormatSpecifier format, unsigned long long* value)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
if (format == CRegTable::FormatSpecifier::Hex16)
|
|
|
|
return str.ToULongLong(value, 16);
|
|
|
|
|
|
|
|
if (format == CRegTable::FormatSpecifier::Double)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
double double_val;
|
|
|
|
if (str.ToCDouble(&double_val))
|
|
|
|
{
|
|
|
|
std::memcpy(value, &double_val, sizeof(u64));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
|
|
|
|
return false;
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
2009-01-20 19:15:33 +00:00
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
bool TryParseGPR(wxString str, CRegTable::FormatSpecifier format, u32* value)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
if (format == CRegTable::FormatSpecifier::Hex8)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
unsigned long val;
|
|
|
|
if (str.ToCULong(&val, 16))
|
|
|
|
{
|
|
|
|
*value = static_cast<u32>(val);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
|
|
|
|
if (format == CRegTable::FormatSpecifier::Int)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
long signed_val;
|
|
|
|
if (str.ToCLong(&signed_val))
|
|
|
|
{
|
|
|
|
*value = static_cast<u32>(signed_val);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
|
|
|
|
if (format == CRegTable::FormatSpecifier::UInt)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
unsigned long val;
|
|
|
|
if (str.ToCULong(&val))
|
|
|
|
{
|
|
|
|
*value = static_cast<u32>(val);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
|
|
|
|
if (format == CRegTable::FormatSpecifier::Float)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
double double_val;
|
|
|
|
if (str.ToCDouble(&double_val))
|
|
|
|
{
|
|
|
|
float float_val = static_cast<float>(double_val);
|
|
|
|
std::memcpy(value, &float_val, sizeof(float));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-09-30 04:33:06 +00:00
|
|
|
} // Anonymous namespace
|
|
|
|
|
|
|
|
CRegTable::CRegTable()
|
|
|
|
{
|
|
|
|
for (auto& entry : m_formatFRegs)
|
|
|
|
entry.fill(FormatSpecifier::Hex16);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString CRegTable::FormatGPR(int reg_index)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
if (m_formatRegs[reg_index] == FormatSpecifier::Int)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
return wxString::Format(GetFormatString(m_formatRegs[reg_index]),
|
|
|
|
static_cast<s32>(GPR(reg_index)));
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
if (m_formatRegs[reg_index] == FormatSpecifier::Float)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
2016-09-30 04:33:06 +00:00
|
|
|
float value;
|
|
|
|
std::memcpy(&value, &GPR(reg_index), sizeof(float));
|
|
|
|
return wxString::Format(GetFormatString(m_formatRegs[reg_index]), value);
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
2016-09-30 04:33:06 +00:00
|
|
|
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);
|
2016-08-31 22:31:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRegTable::SetRegisterFormat(int col, int row, FormatSpecifier specifier)
|
|
|
|
{
|
|
|
|
if (row >= 32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (col)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
m_formatRegs[row] = specifier;
|
|
|
|
return;
|
|
|
|
case 3:
|
|
|
|
m_formatFRegs[row][0] = specifier;
|
|
|
|
return;
|
|
|
|
case 4:
|
|
|
|
m_formatFRegs[row][1] = specifier;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString CRegTable::GetValue(int row, int col)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (row < 32)
|
|
|
|
{
|
|
|
|
switch (col)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return StrToWxStr(GekkoDisassembler::GetGPRName(row));
|
|
|
|
case 1:
|
2016-08-31 22:31:39 +00:00
|
|
|
return FormatGPR(row);
|
2016-06-24 08:43:46 +00:00
|
|
|
case 2:
|
|
|
|
return StrToWxStr(GekkoDisassembler::GetFPRName(row));
|
|
|
|
case 3:
|
2016-08-31 22:31:39 +00:00
|
|
|
return FormatFPR(row, 0);
|
2016-06-24 08:43:46 +00:00
|
|
|
case 4:
|
2016-08-31 22:31:39 +00:00
|
|
|
return FormatFPR(row, 1);
|
2016-06-24 08:43:46 +00:00
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
if (row < 4)
|
|
|
|
return wxString::Format("DBAT%01d", row);
|
|
|
|
|
|
|
|
if (row < 8)
|
|
|
|
return wxString::Format("IBAT%01d", row - 4);
|
|
|
|
|
|
|
|
if (row < 12)
|
|
|
|
return wxString::Format("DBAT%01d", row - 4);
|
|
|
|
|
|
|
|
if (row < 16)
|
|
|
|
return wxString::Format("IBAT%01d", row - 8);
|
|
|
|
|
2017-12-10 19:58:10 +00:00
|
|
|
if (row == 16)
|
|
|
|
return wxString::Format("TB");
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
if (row < 4)
|
|
|
|
return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_DBAT0U + row * 2] << 32 |
|
|
|
|
PowerPC::ppcState.spr[SPR_DBAT0L + row * 2]);
|
|
|
|
|
|
|
|
if (row < 8)
|
2018-04-12 12:18:04 +00:00
|
|
|
return wxString::Format("%016llx",
|
|
|
|
(u64)PowerPC::ppcState.spr[SPR_IBAT0U + (row - 4) * 2] << 32 |
|
|
|
|
PowerPC::ppcState.spr[SPR_IBAT0L + (row - 4) * 2]);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (row < 12)
|
2018-04-12 12:18:04 +00:00
|
|
|
return wxString::Format("%016llx",
|
|
|
|
(u64)PowerPC::ppcState.spr[SPR_DBAT4U + (row - 12) * 2] << 32 |
|
|
|
|
PowerPC::ppcState.spr[SPR_DBAT4L + (row - 12) * 2]);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
if (row < 16)
|
2018-04-12 12:18:04 +00:00
|
|
|
return wxString::Format("%016llx",
|
|
|
|
(u64)PowerPC::ppcState.spr[SPR_IBAT4U + (row - 16) * 2] << 32 |
|
|
|
|
PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-12-10 19:58:10 +00:00
|
|
|
if (row == 16)
|
|
|
|
return wxString::Format("%016" PRIx64, static_cast<u64>(PowerPC::ppcState.spr[SPR_TU])
|
|
|
|
<< 32 |
|
|
|
|
PowerPC::ppcState.spr[SPR_TL]);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
if (row < 16)
|
|
|
|
return wxString::Format("SR%02d", row);
|
|
|
|
|
2017-12-10 19:58:10 +00:00
|
|
|
if (row < 24)
|
|
|
|
return wxString::Format("GQR%01d", row - 16);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
if (row < 16)
|
|
|
|
return wxString::Format("%08x", PowerPC::ppcState.sr[row]);
|
|
|
|
|
2017-12-10 19:58:10 +00:00
|
|
|
if (row < 24)
|
|
|
|
return wxString::Format("%08x", PowerPC::ppcState.spr[SPR_GQR0 + (row - 16)]);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-03 17:29:19 +00:00
|
|
|
if (static_cast<size_t>(row - 32) < NUM_SPECIALS)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
switch (col)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return StrToWxStr(special_reg_names[row - 32]);
|
|
|
|
case 1:
|
|
|
|
return wxString::Format("%08x", GetSpecialRegValue(row - 32));
|
|
|
|
default:
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return wxEmptyString;
|
2008-12-09 05:29:14 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-10-17 00:10:22 +00:00
|
|
|
void CRegTable::SetValue(int row, int col, const wxString& strNewVal)
|
2008-12-09 05:29:14 +00:00
|
|
|
{
|
2016-08-31 22:31:39 +00:00
|
|
|
if (row < 32)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-08-31 22:31:39 +00:00
|
|
|
if (col == 1)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-08-31 22:31:39 +00:00
|
|
|
u32 new_val = 0;
|
|
|
|
if (TryParseGPR(strNewVal, m_formatRegs[row], &new_val))
|
|
|
|
GPR(row) = new_val;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2016-08-31 22:31:39 +00:00
|
|
|
else if (col == 3)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
2016-08-31 22:31:39 +00:00
|
|
|
unsigned long long new_val = 0;
|
|
|
|
if (TryParseFPR(strNewVal, m_formatFRegs[row][0], &new_val))
|
|
|
|
riPS0(row) = new_val;
|
|
|
|
}
|
|
|
|
else if (col == 4)
|
|
|
|
{
|
|
|
|
unsigned long long new_val = 0;
|
|
|
|
if (TryParseFPR(strNewVal, m_formatFRegs[row][1], &new_val))
|
|
|
|
riPS1(row) = new_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-03 17:29:19 +00:00
|
|
|
if ((static_cast<size_t>(row - 32) < NUM_SPECIALS) && col == 1)
|
2016-08-31 22:31:39 +00:00
|
|
|
{
|
|
|
|
u32 new_val = 0;
|
|
|
|
if (TryParse("0x" + WxStrToStr(strNewVal), &new_val))
|
|
|
|
SetSpecialRegValue(row - 32, new_val);
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-09 05:29:14 +00:00
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2009-01-20 19:15:33 +00:00
|
|
|
void CRegTable::UpdateCachedRegs()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
for (int i = 0; i < 32; ++i)
|
|
|
|
{
|
|
|
|
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i));
|
|
|
|
m_CachedRegs[i] = GPR(i);
|
|
|
|
|
|
|
|
m_CachedFRegHasChanged[i][0] = (m_CachedFRegs[i][0] != riPS0(i));
|
|
|
|
m_CachedFRegs[i][0] = riPS0(i);
|
|
|
|
m_CachedFRegHasChanged[i][1] = (m_CachedFRegs[i][1] != riPS1(i));
|
|
|
|
m_CachedFRegs[i][1] = riPS1(i);
|
|
|
|
}
|
2016-10-03 17:29:19 +00:00
|
|
|
for (size_t i = 0; i < NUM_SPECIALS; ++i)
|
2016-06-24 08:43:46 +00:00
|
|
|
{
|
|
|
|
m_CachedSpecialRegHasChanged[i] = (m_CachedSpecialRegs[i] != GetSpecialRegValue(i));
|
|
|
|
m_CachedSpecialRegs[i] = GetSpecialRegValue(i);
|
|
|
|
}
|
2009-01-20 19:15:33 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
wxGridCellAttr* CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
|
2008-12-09 05:29:14 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxGridCellAttr* attr = new wxGridCellAttr();
|
|
|
|
|
|
|
|
attr->SetBackgroundColour(*wxWHITE);
|
|
|
|
attr->SetFont(DebuggerFont);
|
|
|
|
|
|
|
|
switch (col)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
attr->SetAlignment(wxALIGN_RIGHT, wxALIGN_CENTER);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool red = false;
|
|
|
|
switch (col)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
red = row < 32 ? m_CachedRegHasChanged[row] : m_CachedSpecialRegHasChanged[row - 32];
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
red = row < 32 ? m_CachedFRegHasChanged[row][col - 3] : false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
attr->SetTextColour(red ? *wxRED : *wxBLACK);
|
|
|
|
return attr;
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CRegisterView::CRegisterView(wxWindow* parent, wxWindowID id) : wxGrid(parent, id)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_register_table = new CRegTable();
|
2015-03-24 13:37:20 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
SetTable(m_register_table, true);
|
|
|
|
SetRowLabelSize(0);
|
|
|
|
SetColLabelSize(0);
|
|
|
|
DisableDragRowSize();
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
Bind(wxEVT_GRID_CELL_RIGHT_CLICK, &CRegisterView::OnMouseDownR, this);
|
|
|
|
Bind(wxEVT_MENU, &CRegisterView::OnPopupMenu, this);
|
2014-11-06 03:19:52 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
AutoSizeColumns();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
void CRegisterView::Repopulate()
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_register_table->UpdateCachedRegs();
|
|
|
|
ForceRefresh();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2014-10-23 13:47:00 +00:00
|
|
|
|
|
|
|
void CRegisterView::OnMouseDownR(wxGridEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// popup menu
|
2016-08-31 22:31:39 +00:00
|
|
|
m_selectedRow = event.GetRow();
|
|
|
|
m_selectedColumn = event.GetCol();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-08-31 22:31:39 +00:00
|
|
|
wxString strNewVal = m_register_table->GetValue(m_selectedRow, m_selectedColumn);
|
2016-06-24 08:43:46 +00:00
|
|
|
TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress);
|
|
|
|
|
|
|
|
wxMenu menu;
|
2016-10-31 14:06:27 +00:00
|
|
|
// i18n: This kind of "watch" is used for watching emulated memory.
|
|
|
|
// It's not related to timekeeping devices.
|
2016-06-24 08:43:46 +00:00
|
|
|
menu.Append(IDM_WATCHADDRESS, _("Add to &watch"));
|
|
|
|
menu.Append(IDM_VIEWMEMORY, _("View &memory"));
|
|
|
|
menu.Append(IDM_VIEWCODE, _("View &code"));
|
2016-08-31 22:31:39 +00:00
|
|
|
if (m_selectedRow < 32 &&
|
|
|
|
(m_selectedColumn == 1 || m_selectedColumn == 3 || m_selectedColumn == 4))
|
|
|
|
{
|
|
|
|
menu.AppendSeparator();
|
|
|
|
if (m_selectedColumn == 1)
|
|
|
|
{
|
|
|
|
menu.Append(IDM_VIEW_HEX8, _("View as hexadecimal"));
|
|
|
|
menu.Append(IDM_VIEW_INT, _("View as signed integer"));
|
|
|
|
menu.Append(IDM_VIEW_UINT, _("View as unsigned integer"));
|
2016-10-31 14:06:27 +00:00
|
|
|
// i18n: Float means floating point number
|
2016-08-31 22:31:39 +00:00
|
|
|
menu.Append(IDM_VIEW_FLOAT, _("View as float"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu.Append(IDM_VIEW_HEX16, _("View as hexadecimal"));
|
2016-10-31 14:06:27 +00:00
|
|
|
// i18n: Double means double-precision floating point number
|
2016-08-31 22:31:39 +00:00
|
|
|
menu.Append(IDM_VIEW_DOUBLE, _("View as double"));
|
|
|
|
}
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
PopupMenu(&menu);
|
2014-10-23 13:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CRegisterView::OnPopupMenu(wxCommandEvent& event)
|
|
|
|
{
|
2016-10-03 07:29:50 +00:00
|
|
|
// FIXME: This is terrible. Generate events instead.
|
|
|
|
CFrame* cframe = wxGetApp().GetCFrame();
|
2017-05-01 00:11:01 +00:00
|
|
|
CCodeWindow* code_window = cframe->m_code_window;
|
2016-10-03 07:29:50 +00:00
|
|
|
CWatchWindow* watch_window = code_window->GetPanel<CWatchWindow>();
|
|
|
|
CMemoryWindow* memory_window = code_window->GetPanel<CMemoryWindow>();
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_WATCHADDRESS:
|
2018-01-29 16:58:02 +00:00
|
|
|
PowerPC::debug_interface.SetWatch(m_selectedAddress);
|
2016-06-24 08:43:46 +00:00
|
|
|
if (watch_window)
|
|
|
|
watch_window->NotifyUpdate();
|
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEWMEMORY:
|
|
|
|
if (memory_window)
|
|
|
|
memory_window->JumpToAddress(m_selectedAddress);
|
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEWCODE:
|
|
|
|
code_window->JumpToAddress(m_selectedAddress);
|
|
|
|
Refresh();
|
|
|
|
break;
|
2016-08-31 22:31:39 +00:00
|
|
|
case IDM_VIEW_HEX8:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::Hex8);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEW_HEX16:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::Hex16);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEW_INT:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::Int);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEW_UINT:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::UInt);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEW_FLOAT:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::Float);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
|
|
|
case IDM_VIEW_DOUBLE:
|
2016-09-30 04:16:14 +00:00
|
|
|
m_register_table->SetRegisterFormat(m_selectedColumn, m_selectedRow,
|
|
|
|
CRegTable::FormatSpecifier::Double);
|
2016-08-31 22:31:39 +00:00
|
|
|
Refresh();
|
|
|
|
break;
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
|
|
|
event.Skip();
|
2014-10-23 13:47:00 +00:00
|
|
|
}
|