2016-01-27 09:11:59 +00:00
|
|
|
#include "stdafx.h"
|
2018-01-21 01:51:36 +00:00
|
|
|
#include <Project64-core/ExceptionHandler.h>
|
|
|
|
#include <Common/MemoryManagement.h>
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
#include <UserInterface/WTLControls/HexEditCtrl.h>
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
#include "DebuggerUI.h"
|
2017-08-18 05:08:22 +00:00
|
|
|
#include "Symbols.h"
|
|
|
|
#include "DMALog.h"
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
CDebugMemoryView::jump_item_t CDebugMemoryView::JumpItems[] = {
|
|
|
|
{ 0x80000000, 0x00000000, 0x0800000, "RDRAM" },
|
|
|
|
{ 0xA3F00000, 0x03F00000, 0x0000028, "RDRAM Registers" },
|
|
|
|
{ 0xA4000000, 0x04000000, 0x0001000, "SP DMEM" },
|
|
|
|
{ 0xA4001000, 0x04001000, 0x0001000, "SP IMEM" },
|
|
|
|
{ 0xA4040000, 0x04040000, 0x0000020, "SP Registers" },
|
|
|
|
{ 0xA4080000, 0x04080000, 0x0000004, "SP PC Register" },
|
|
|
|
{ 0xA4100000, 0x04100000, 0x0000020, "DP Control Registers" },
|
|
|
|
{ 0xA4300000, 0x04300000, 0x0000010, "MI Registers" },
|
|
|
|
{ 0xA4400000, 0x04400000, 0x0000038, "VI Registers" },
|
|
|
|
{ 0xA4500000, 0x04500000, 0x0000018, "AI Registers" },
|
|
|
|
{ 0xA4600000, 0x04600000, 0x0000034, "PI Registers" },
|
|
|
|
{ 0xA4700000, 0x04700000, 0x0000020, "RI Registers" },
|
|
|
|
{ 0xA4800000, 0x04800000, 0x0000010, "SI Registers" },
|
|
|
|
{ 0xA5000500, 0x05000500, 0x000004C, "DD Registers" },
|
2019-12-25 00:41:20 +00:00
|
|
|
{ 0xA8000000, 0x08000000, 0x1000000, "Cartridge Save Data" },
|
2019-11-30 17:48:46 +00:00
|
|
|
{ 0xB0000000, 0x10000000, 0xFC00000, "Cartridge ROM" },
|
|
|
|
{ 0xBFC00000, 0x1FC00000, 0x00007C0, "PIF ROM" },
|
|
|
|
{ 0xBFC007C0, 0x1FC007C0, 0x0000040, "PIF RAM" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) :
|
2017-09-13 12:00:53 +00:00
|
|
|
CDebugDialog<CDebugMemoryView>(debugger),
|
2019-11-30 17:48:46 +00:00
|
|
|
CDialogResize<CDebugMemoryView>(),
|
|
|
|
CToolTipDialog<CDebugMemoryView>(),
|
2021-04-12 11:35:39 +00:00
|
|
|
m_Breakpoints(nullptr),
|
2019-11-30 17:48:46 +00:00
|
|
|
m_WriteTargetColorStride(0),
|
|
|
|
m_ReadTargetColorStride(0),
|
|
|
|
m_SymbolColorStride(0),
|
|
|
|
m_SymbolColorPhase(0),
|
|
|
|
m_bIgnoreAddressInput(false),
|
|
|
|
m_HotAddress(0),
|
|
|
|
m_bVirtualMemory(true),
|
|
|
|
m_ContextMenuAddress(0),
|
|
|
|
m_bSafeEditMode(false)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
m_Breakpoints = m_Debugger->Breakpoints();
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CDebugMemoryView::~CDebugMemoryView()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::ShowAddress(uint32_t address, bool bVirtual)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (m_hWnd == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-01-14 07:06:01 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
SendMessage(WM_SHOWADDRESS, (WPARAM)address, (LPARAM)bVirtual);
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
bool CDebugMemoryView::GetByte(uint32_t address, uint8_t* value)
|
|
|
|
{
|
|
|
|
if (m_bVirtualMemory)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
return m_Debugger->DebugLoad_VAddr(address, *value);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
return m_Debugger->DebugLoad_PAddr(address, *value);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
bool CDebugMemoryView::SetByte(uint32_t address, uint8_t value)
|
|
|
|
{
|
|
|
|
if (m_bVirtualMemory)
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
return m_Debugger->DebugStore_VAddr(address, value);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
return m_Debugger->DebugStore_PAddr(address, value);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::CopyTextToClipboard(const char* text)
|
|
|
|
{
|
|
|
|
size_t length = strlen(text);
|
|
|
|
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, length + 1);
|
|
|
|
strcpy((char*)GlobalLock(hMem), text);
|
|
|
|
GlobalUnlock(hMem);
|
|
|
|
OpenClipboard();
|
|
|
|
EmptyClipboard();
|
|
|
|
SetClipboardData(CF_TEXT, hMem);
|
|
|
|
CloseClipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugMemoryView::CopyBytesToClipboard(uint32_t startAddress, uint32_t endAddress, bool bHex, bool bIncludeAddresses, bool bRowAddresses)
|
|
|
|
{
|
|
|
|
uint32_t baseAddress = m_HexEditCtrl.GetBaseAddress();
|
|
|
|
int groupSize = m_HexEditCtrl.GetNumBytesPerGroup();
|
|
|
|
int rowSize = m_HexEditCtrl.GetNumBytesPerRow();
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
stdstr str = "";
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
for (uint32_t address = startAddress; address <= endAddress; address++)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
int offsetFromBase = address - baseAddress;
|
|
|
|
int offsetFromSelStart = address - startAddress;
|
|
|
|
|
|
|
|
uint8_t value;
|
|
|
|
GetByte(address, &value);
|
|
|
|
|
|
|
|
if (bIncludeAddresses)
|
|
|
|
{
|
|
|
|
if ((bRowAddresses && offsetFromBase % rowSize == 0) ||
|
|
|
|
(!bRowAddresses && offsetFromBase % groupSize == 0) ||
|
|
|
|
(offsetFromSelStart == 0))
|
|
|
|
{
|
|
|
|
str += stdstr_f("%08X: ", address);
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (bHex)
|
|
|
|
{
|
|
|
|
str += stdstr_f("%02X", value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str += CHexEditCtrl::ByteAscii(value);
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if ((offsetFromBase + 1) % rowSize == 0 || (bIncludeAddresses && !bRowAddresses && (offsetFromBase + 1) % groupSize == 0))
|
|
|
|
{
|
|
|
|
str += "\r\n";
|
|
|
|
}
|
|
|
|
else if (bHex && (offsetFromBase + 1) % groupSize == 0)
|
|
|
|
{
|
|
|
|
str += " ";
|
|
|
|
}
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
CopyTextToClipboard(str.Trim(" \r\n").c_str());
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::CopyGameSharkCodeToClipboard(uint32_t startAddress, uint32_t endAddress)
|
|
|
|
{
|
|
|
|
stdstr str = "";
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (startAddress & 1)
|
|
|
|
{
|
|
|
|
uint8_t value = 0;
|
|
|
|
GetByte(startAddress, &value);
|
|
|
|
str += stdstr_f("%08X %04X\r\n", startAddress, value);
|
|
|
|
startAddress++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t address = startAddress; address < endAddress; address += 2)
|
|
|
|
{
|
|
|
|
uint8_t value0 = 0, value1 = 0;
|
|
|
|
GetByte(address + 0, &value0);
|
|
|
|
GetByte(address + 1, &value1);
|
|
|
|
str += stdstr_f("%08X %02X%02X\r\n", address | 0x01000000, value0, value1);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (!(endAddress & 1))
|
|
|
|
{
|
|
|
|
uint8_t value = 0;
|
|
|
|
GetByte(endAddress, &value);
|
|
|
|
str += stdstr_f("%08X %04X\r\n", endAddress, value);
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
CopyTextToClipboard(str.Trim("\n").c_str());
|
|
|
|
}
|
2018-12-08 12:45:52 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::FillRange(uint32_t startAddress, uint32_t endAddress, uint8_t value)
|
|
|
|
{
|
|
|
|
for (uint32_t address = startAddress; address <= endAddress; address++)
|
|
|
|
{
|
|
|
|
SetByte(address, value);
|
|
|
|
}
|
|
|
|
}
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::FollowPointer(bool bContextMenuAddress)
|
|
|
|
{
|
|
|
|
uint32_t address;
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (bContextMenuAddress)
|
|
|
|
{
|
2019-12-24 18:53:19 +00:00
|
|
|
address = m_ContextMenuAddress & (~3);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-24 18:53:19 +00:00
|
|
|
uint32_t selStartAddress, selEndAddress;
|
|
|
|
m_HexEditCtrl.GetSelectionRange(&selStartAddress, &selEndAddress);
|
|
|
|
address = selStartAddress & (~3);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
2019-12-25 00:41:20 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
uint32_t pointer;
|
2019-12-24 18:53:19 +00:00
|
|
|
bool bValid;
|
|
|
|
|
|
|
|
if (m_bVirtualMemory)
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
bValid = m_Debugger->DebugLoad_VAddr(address, pointer);
|
2019-12-24 18:53:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
bValid = m_Debugger->DebugLoad_VAddr(address, pointer);
|
2019-12-24 18:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bValid)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
OpenNewTab(pointer, m_bVirtualMemory, 4, true, true);
|
|
|
|
}
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::JumpToSelection(void)
|
|
|
|
{
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
bool bHaveSelection = m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
uint32_t targetAddress = bHaveSelection ? startAddress : m_HexEditCtrl.GetCaretAddress();
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(targetAddress, DisplayMode::ZeroExtend);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
bool CDebugMemoryView::GetSafeEditValue(uint32_t address, uint8_t* value)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
if (m_SafeEditQueue.size() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(size_t i = m_SafeEditQueue.size(); i-- > 0;)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
edit_t edit = m_SafeEditQueue[i];
|
|
|
|
if (address >= edit.startAddress && address <= edit.endAddress)
|
2018-12-08 12:45:52 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
*value = edit.value;
|
|
|
|
return true;
|
2018-12-08 12:45:52 +00:00
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
return false;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::ApplySafeEdits(void)
|
2019-01-14 04:03:02 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
for (size_t i = 0; i < m_SafeEditQueue.size(); i++)
|
|
|
|
{
|
|
|
|
edit_t edit = m_SafeEditQueue[i];
|
|
|
|
if (edit.type == SE_FILL)
|
|
|
|
{
|
|
|
|
FillRange(edit.startAddress, edit.endAddress, edit.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_SafeEditQueue.clear();
|
2019-01-14 04:03:02 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::SetupJumpMenu(bool bVirtual)
|
2017-08-30 06:15:28 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
m_CmbJump.SetRedraw(FALSE);
|
|
|
|
m_CmbJump.ResetContent();
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
for (int i = 0;; i++)
|
|
|
|
{
|
|
|
|
jump_item_t* item = &JumpItems[i];
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (item->caption == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2020-05-12 12:19:05 +00:00
|
|
|
m_CmbJump.AddString(stdstr_f("%08X %s", bVirtual ? item->vaddr : item->paddr, item->caption).ToUTF16().c_str());
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_CmbJump.SetRedraw(TRUE);
|
2017-08-30 06:15:28 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
int CDebugMemoryView::GetJumpItemIndex(uint32_t address, bool bVirtual)
|
2017-08-30 06:15:28 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
for (int nItem = 0;; nItem++)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (JumpItems[nItem].caption == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t start = bVirtual ? JumpItems[nItem].vaddr : JumpItems[nItem].paddr;
|
|
|
|
uint32_t end = start + JumpItems[nItem].size - 1;
|
|
|
|
|
|
|
|
if (address >= start && address <= end)
|
|
|
|
{
|
|
|
|
return nItem;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
|
|
|
{
|
|
|
|
DlgResize_Init(false, true);
|
|
|
|
DlgSavePos_Init(DebuggerUI_MemoryPos);
|
|
|
|
DlgToolTip_Init();
|
|
|
|
|
|
|
|
m_HexEditCtrl.Attach(GetDlgItem(IDC_HEXEDIT));
|
|
|
|
m_TabCtrl.Attach(GetDlgItem(IDC_MEMTABS));
|
|
|
|
m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
|
|
|
|
m_VirtualCheckbox.Attach(GetDlgItem(IDC_CHK_VADDR));
|
|
|
|
m_StatusBar.Attach(GetDlgItem(IDC_STATUSBAR));
|
|
|
|
m_CmbJump.Attach(GetDlgItem(IDC_CMB_JUMP));
|
|
|
|
|
|
|
|
m_SymbolColorStride = 0;
|
|
|
|
m_SymbolColorPhase = 0;
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
|
|
|
|
if (hScrlBar)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
SCROLLINFO si;
|
|
|
|
|
|
|
|
si.cbSize = sizeof(si);
|
|
|
|
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
|
|
|
|
si.nMin = 0;
|
|
|
|
si.nMax = 0xFFFF;
|
|
|
|
si.nPos = 0x8000;
|
|
|
|
si.nPage = 100;
|
|
|
|
::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2017-08-30 06:15:28 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
m_MemAddr.SetDisplayType(CEditNumber32::DisplayHex);
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(0x80000000, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
m_VirtualCheckbox.SetCheck(BST_CHECKED);
|
|
|
|
|
|
|
|
float dpiScale = CClientDC(m_hWnd).GetDeviceCaps(LOGPIXELSX) / 96.0f;
|
|
|
|
|
|
|
|
int statusPaneWidths[MEMSB_NUM_PANES] = {
|
|
|
|
(int)(MEMSB_HOTADDR_W * dpiScale),
|
|
|
|
(int)(MEMSB_BLOCK_W * dpiScale),
|
|
|
|
(int)(MEMSB_BLOCKLEN_W * dpiScale),
|
|
|
|
(int)(MEMSB_DMAINFO_W * dpiScale),
|
|
|
|
(int)(MEMSB_SAFEMODE_W * dpiScale)
|
|
|
|
};
|
|
|
|
|
|
|
|
m_StatusBar.SetParts(MEMSB_NUM_PANES, statusPaneWidths);
|
|
|
|
|
|
|
|
SetupJumpMenu(true);
|
|
|
|
m_CmbJump.SetCurSel(0);
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
m_TabData.clear();
|
2019-11-30 17:48:46 +00:00
|
|
|
AddTab(0x80000000, true, 4);
|
|
|
|
|
|
|
|
m_HexEditCtrl.Draw();
|
|
|
|
|
|
|
|
LoadWindowPos();
|
|
|
|
WindowCreated();
|
|
|
|
|
|
|
|
return TRUE;
|
2017-08-30 06:15:28 +00:00
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
LRESULT CDebugMemoryView::OnDestroy(void)
|
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
m_HexEditCtrl.Detach();
|
2019-08-04 22:50:52 +00:00
|
|
|
m_MemAddr.Detach();
|
2019-11-30 17:48:46 +00:00
|
|
|
m_VirtualCheckbox.Detach();
|
|
|
|
m_TabCtrl.Detach();
|
|
|
|
m_StatusBar.Detach();
|
|
|
|
m_CmbJump.Detach();
|
2016-01-27 09:11:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnShowAddress(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
|
|
|
|
{
|
|
|
|
uint32_t address = (uint32_t)wParam;
|
|
|
|
bool bVirtual = (lParam != 0);
|
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(address, bVirtual));
|
|
|
|
OpenNewTab(address, bVirtual, 4, true, true);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugMemoryView::OnExitSizeMove()
|
|
|
|
{
|
|
|
|
SaveWindowPos(true);
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
|
|
|
|
{
|
|
|
|
switch (wID)
|
|
|
|
{
|
|
|
|
case IDC_CHK_VADDR:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_bVirtualMemory = (m_VirtualCheckbox.GetCheck() == BST_CHECKED);
|
|
|
|
SetupJumpMenu(m_bVirtualMemory);
|
2019-12-24 18:53:19 +00:00
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(m_MemAddr.GetValue(), m_bVirtualMemory));
|
2016-01-27 09:11:59 +00:00
|
|
|
break;
|
2017-09-13 12:00:53 +00:00
|
|
|
case IDC_SYMBOLS_BTN:
|
2018-01-10 07:05:57 +00:00
|
|
|
m_Debugger->OpenSymbolsWindow();
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(0);
|
|
|
|
break;
|
2017-09-13 12:00:53 +00:00
|
|
|
case ID_POPUPMENU_TOGGLERBP:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Breakpoints->RBPToggle(m_ContextMenuAddress);
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_TOGGLEWBP:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Breakpoints->WBPToggle(m_ContextMenuAddress);
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_CLEARALLBPS:
|
|
|
|
m_Breakpoints->RBPClear();
|
|
|
|
m_Breakpoints->WBPClear();
|
|
|
|
break;
|
2018-03-18 01:14:52 +00:00
|
|
|
case ID_POPUPMENU_TOGGLELOCK:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Breakpoints->ToggleMemLock(m_ContextMenuAddress);
|
2018-03-18 01:14:52 +00:00
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_CLEARLOCKS:
|
|
|
|
m_Breakpoints->ClearMemLocks();
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_JUMPHERE:
|
|
|
|
JumpToSelection();
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_FOLLOWPOINTER:
|
|
|
|
FollowPointer();
|
2018-03-18 01:14:52 +00:00
|
|
|
break;
|
2017-09-13 12:00:53 +00:00
|
|
|
case ID_POPUPMENU_VIEWDISASM:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Debugger->Debug_ShowCommandsLocation(m_ContextMenuAddress, true);
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_ADDSYMBOL:
|
2019-11-30 17:48:46 +00:00
|
|
|
m_AddSymbolDlg.DoModal(m_Debugger, m_ContextMenuAddress);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_COPY:
|
|
|
|
m_HexEditCtrl.Copy();
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_COPYGAMESHARKCODE:
|
|
|
|
{
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
CopyGameSharkCodeToClipboard(startAddress, endAddress);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_COPYDATAWITHGROUPADDRESSES:
|
|
|
|
{
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
CopyBytesToClipboard(startAddress, endAddress, m_HexEditCtrl.GetFocusedColumn() == HX_COL_HEXDATA, true, false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_COPYDATAWITHROWADDRESSES:
|
|
|
|
{
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
CopyBytesToClipboard(startAddress, endAddress, m_HexEditCtrl.GetFocusedColumn() == HX_COL_HEXDATA, true, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_PASTE:
|
|
|
|
m_HexEditCtrl.Paste();
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_SAFEMODE:
|
|
|
|
m_HexEditCtrl.SendMessage(WM_KEYDOWN, VK_INSERT, 0);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_ZEROFILL:
|
|
|
|
m_HexEditCtrl.SendMessage(WM_KEYDOWN, VK_DELETE, 0);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_BYTEGROUPSIZE_1:
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(1);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_BYTEGROUPSIZE_2:
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(2);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_BYTEGROUPSIZE_4:
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(4);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_BYTEGROUPSIZE_8:
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(8);
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_DUMP:
|
|
|
|
m_Debugger->OpenMemoryDump();
|
|
|
|
break;
|
|
|
|
case ID_POPUPMENU_SEARCH:
|
|
|
|
m_Debugger->OpenMemorySearch();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/)
|
|
|
|
{
|
|
|
|
if (m_bIgnoreAddressInput)
|
|
|
|
{
|
|
|
|
m_bIgnoreAddressInput = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t address = m_MemAddr.GetValue();
|
|
|
|
m_HexEditCtrl.SetBaseAddress(address);
|
|
|
|
UpdateCurrentTab(address);
|
2019-12-24 18:53:19 +00:00
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(address, m_bVirtualMemory));
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugMemoryView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
|
|
|
|
{
|
|
|
|
if (pScrollBar != GetDlgItem(IDC_SCRL_BAR))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t address = m_MemAddr.GetValue();
|
|
|
|
int numBytesPerRow = m_HexEditCtrl.GetNumBytesPerRow();
|
|
|
|
int numVisibleBytes = m_HexEditCtrl.GetNumVisibleBytes();
|
|
|
|
|
|
|
|
switch (nSBCode)
|
|
|
|
{
|
|
|
|
case SB_LINEDOWN:
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address < 0xFFFFFFEF ? address + numBytesPerRow : 0xFFFFFFFF, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
case SB_LINEUP:
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address > (uint32_t)numBytesPerRow ? address - numBytesPerRow : 0, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
case SB_PAGEDOWN:
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address < 0xFFFFFEFF ? address + numVisibleBytes : 0xFFFFFFFF, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
case SB_PAGEUP:
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address >(uint32_t)numVisibleBytes ? address - numVisibleBytes : 0, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
case SB_THUMBPOSITION:
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue((DWORD)nPos << 0x10, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(address, m_bVirtualMemory));
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxCtrlKeyPressed(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMHXCTRLKEYPRESSED* nmck = reinterpret_cast<NMHXCTRLKEYPRESSED*>(lpNMHDR);
|
|
|
|
uint32_t address = m_HexEditCtrl.GetCaretAddress();
|
|
|
|
|
|
|
|
if (nmck->nChar >= '1' && nmck->nChar <= '9')
|
|
|
|
{
|
|
|
|
int nBytes = nmck->nChar - '0';
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(nBytes);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (nmck->nChar)
|
|
|
|
{
|
|
|
|
case 'G':
|
|
|
|
JumpToSelection();
|
|
|
|
break;
|
|
|
|
case 'W':
|
|
|
|
m_Breakpoints->WBPToggle(address);
|
|
|
|
break;
|
2020-02-14 13:48:51 +00:00
|
|
|
case 'N':
|
|
|
|
AddTab(0x80000000, true, 4);
|
|
|
|
break;
|
2019-11-30 17:48:46 +00:00
|
|
|
case 'R':
|
|
|
|
m_Breakpoints->RBPToggle(address);
|
|
|
|
break;
|
|
|
|
case 'E':
|
|
|
|
m_Breakpoints->ToggleMemLock(address);
|
|
|
|
break;
|
|
|
|
case 'Q':
|
|
|
|
m_Breakpoints->WBPClear();
|
|
|
|
m_Breakpoints->RBPClear();
|
|
|
|
m_Breakpoints->ClearMemLocks();
|
|
|
|
break;
|
|
|
|
case 'F':
|
2021-03-18 03:50:07 +00:00
|
|
|
// TODO: put selection in the textbox
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Debugger->OpenMemorySearch();
|
|
|
|
break;
|
|
|
|
case 'S':
|
2021-03-18 03:50:07 +00:00
|
|
|
// TODO: set start and end address to selection
|
2019-11-30 17:48:46 +00:00
|
|
|
m_Debugger->OpenMemoryDump();
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
OpenDuplicateTab();
|
|
|
|
break;
|
|
|
|
case 'Z':
|
|
|
|
if (m_SafeEditQueue.size() != 0)
|
|
|
|
{
|
|
|
|
m_SafeEditQueue.pop_back();
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
2019-11-30 17:48:46 +00:00
|
|
|
case VK_F4:
|
|
|
|
CloseCurrentTab();
|
2019-08-04 22:50:52 +00:00
|
|
|
break;
|
2019-11-30 17:48:46 +00:00
|
|
|
case VK_SPACE:
|
|
|
|
FollowPointer(false);
|
2019-08-04 22:50:52 +00:00
|
|
|
break;
|
2019-11-30 17:48:46 +00:00
|
|
|
case VK_TAB:
|
|
|
|
{
|
|
|
|
int curSel = m_TabCtrl.GetCurSel();
|
|
|
|
if (m_TabCtrl.SetCurSel(curSel + 1) == -1)
|
|
|
|
{
|
|
|
|
m_TabCtrl.SetCurSel(0);
|
|
|
|
}
|
|
|
|
TabSelChanged();
|
|
|
|
}
|
2019-08-04 22:50:52 +00:00
|
|
|
break;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxSetNibble(LPNMHDR lpNMHDR)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_MMU == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NMHXSETNIBBLE* nmsn = reinterpret_cast<NMHXSETNIBBLE*>(lpNMHDR);
|
|
|
|
|
|
|
|
uint8_t curValue;
|
|
|
|
bool bValid = GetByte(nmsn->address, &curValue);
|
|
|
|
|
|
|
|
if (!bValid)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t mask = (nmsn->bLoNibble ? 0xF0 : 0x0F);
|
|
|
|
uint8_t newValue = (curValue & mask) | (nmsn->value << (nmsn->bLoNibble ? 0 : 4));
|
|
|
|
|
|
|
|
if (nmsn->bInsert)
|
|
|
|
{
|
|
|
|
if (GetSafeEditValue(nmsn->address, &curValue))
|
|
|
|
{
|
|
|
|
newValue = (curValue & mask) | (nmsn->value << (nmsn->bLoNibble ? 0 : 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_SafeEditQueue.push_back({ SE_FILL, nmsn->address, nmsn->address, newValue });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetByte(nmsn->address, newValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxSetByte(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMHXSETBYTE* nmsb = reinterpret_cast<NMHXSETBYTE*>(lpNMHDR);
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_MMU == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nmsb->bInsert)
|
|
|
|
{
|
|
|
|
m_SafeEditQueue.push_back({ SE_FILL, nmsb->address, nmsb->address, nmsb->value });
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetByte(nmsb->address, nmsb->value);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxFillRange(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMHXFILLRANGE* nmfr = reinterpret_cast<NMHXFILLRANGE*>(lpNMHDR);
|
|
|
|
|
|
|
|
if (nmfr->bInsert)
|
|
|
|
{
|
|
|
|
m_SafeEditQueue.push_back({ SE_FILL, nmfr->startAddress, nmfr->endAddress, nmfr->value });
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
FillRange(nmfr->startAddress, nmfr->endAddress, nmfr->value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxInsertModeChanged(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
m_SafeEditQueue.clear();
|
|
|
|
m_bSafeEditMode = m_HexEditCtrl.GetInsertMode();
|
2020-05-12 12:19:05 +00:00
|
|
|
m_StatusBar.SetText(MEMSB_SAFEMODE, m_bSafeEditMode ? L"Safe mode" : L"");
|
2019-11-30 17:48:46 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxSelectionChanged(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
bool bHaveSelection = m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
|
|
|
|
stdstr strBlock, strLength;
|
|
|
|
|
|
|
|
if (bHaveSelection)
|
|
|
|
{
|
|
|
|
strBlock = stdstr_f("%08X:%08X", startAddress, endAddress);
|
|
|
|
strLength = stdstr_f("%X", endAddress - startAddress + 1);
|
2020-05-12 12:19:05 +00:00
|
|
|
m_StatusBar.SetText(MEMSB_BLOCK, strBlock.ToUTF16().c_str());
|
|
|
|
m_StatusBar.SetText(MEMSB_BLOCKLEN, strLength.ToUTF16().c_str());
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strBlock = stdstr_f("%08X", startAddress);
|
2020-05-12 12:19:05 +00:00
|
|
|
m_StatusBar.SetText(MEMSB_BLOCK, strBlock.ToUTF16().c_str());
|
|
|
|
m_StatusBar.SetText(MEMSB_BLOCKLEN, L"");
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t romAddr, offset;
|
|
|
|
DMALOGENTRY* entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddr, &offset);
|
2021-04-12 11:35:39 +00:00
|
|
|
m_StatusBar.SetText(MEMSB_DMAINFO, entry != nullptr ? L"Have DMA" : L"");
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxGroupSizeChanged(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
int groupSize = m_HexEditCtrl.GetNumBytesPerGroup();
|
|
|
|
|
|
|
|
int nItem = m_TabCtrl.GetCurSel();
|
|
|
|
|
|
|
|
if (nItem == -1)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_TabData[nItem].numBytesPerGroup = groupSize;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxEnterPressed(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
ApplySafeEdits();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxRedrawStarted(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
m_SymbolColorPhase = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnHxGetByteInfo(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMHXGETBYTEINFO *nmgbi = reinterpret_cast<NMHXGETBYTEINFO*>(lpNMHDR);
|
|
|
|
|
|
|
|
bool bHaveWriteTarget = false, bHaveReadTarget = false;
|
|
|
|
uint32_t cpuReadWriteAddress = 0;
|
|
|
|
int cpuReadWriteNumBytes = 0;
|
|
|
|
|
|
|
|
if (g_Settings->LoadBool(Debugger_SteppingOps))
|
|
|
|
{
|
|
|
|
COpInfo opInfo(R4300iOp::m_Opcode);
|
|
|
|
if (opInfo.IsStoreCommand())
|
|
|
|
{
|
|
|
|
cpuReadWriteAddress = opInfo.GetLoadStoreAddress();
|
|
|
|
cpuReadWriteNumBytes = opInfo.NumBytesToStore();
|
|
|
|
bHaveWriteTarget = true;
|
|
|
|
}
|
|
|
|
else if (opInfo.IsLoadCommand())
|
|
|
|
{
|
|
|
|
cpuReadWriteAddress = opInfo.GetLoadStoreAddress();
|
|
|
|
cpuReadWriteNumBytes = opInfo.NumBytesToLoad();
|
|
|
|
bHaveReadTarget = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < nmgbi->numBytes; i++)
|
|
|
|
{
|
|
|
|
uint32_t address = nmgbi->address + i;
|
|
|
|
uint32_t paddress = address;
|
|
|
|
HXBYTEINFO* oldByte = &nmgbi->oldBytes[i];
|
|
|
|
HXBYTEINFO* newByte = &nmgbi->newBytes[i];
|
|
|
|
|
|
|
|
newByte->bkColor = BKCOLOR_DEFAULT;
|
|
|
|
newByte->color = COLOR_DEFAULT;
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (m_bVirtualMemory && (g_MMU == nullptr || !g_MMU->TranslateVaddr(address, paddress)))
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
newByte->bValid = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
newByte->bValid = GetByte(address, &newByte->value);
|
|
|
|
|
|
|
|
if (!newByte->bValid)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-03-18 03:50:07 +00:00
|
|
|
// Always use virtual addresses for breakpoint and symbol info
|
|
|
|
// TODO: should be the other way around
|
2019-11-30 17:48:46 +00:00
|
|
|
uint32_t vaddress = m_bVirtualMemory ? address : address + 0x80000000;
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
CSymbol symbol;
|
|
|
|
if (m_Debugger->SymbolTable()->GetSymbolByAddress(vaddress, &symbol))
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
m_SymbolColorStride = symbol.TypeSize();
|
2019-11-30 17:48:46 +00:00
|
|
|
m_SymbolColorPhase = m_SymbolColorPhase ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bHaveWriteTarget && address == cpuReadWriteAddress)
|
|
|
|
{
|
|
|
|
m_WriteTargetColorStride = cpuReadWriteNumBytes;
|
|
|
|
}
|
|
|
|
else if (bHaveReadTarget && address == cpuReadWriteAddress)
|
|
|
|
{
|
|
|
|
m_ReadTargetColorStride = cpuReadWriteNumBytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bLocked = m_Breakpoints->MemLockExists(vaddress, 1);
|
|
|
|
bool bReadBP = m_Breakpoints->ReadBPExists8(vaddress) == CBreakpoints::BP_SET;
|
|
|
|
bool bWriteBP = m_Breakpoints->WriteBPExists8(vaddress) == CBreakpoints::BP_SET;
|
|
|
|
|
|
|
|
if (bLocked)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_LOCKED;
|
|
|
|
newByte->color = COLOR_BP;
|
|
|
|
}
|
|
|
|
else if (bReadBP && bWriteBP)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_RWBP;
|
|
|
|
newByte->color = COLOR_BP;
|
|
|
|
}
|
|
|
|
else if (bReadBP)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_RBP;
|
|
|
|
newByte->color = COLOR_BP;
|
|
|
|
}
|
|
|
|
else if (bWriteBP)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_WBP;
|
|
|
|
newByte->color = COLOR_BP;
|
|
|
|
}
|
|
|
|
else if (m_ReadTargetColorStride > 0)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_CPUREAD;
|
|
|
|
}
|
|
|
|
else if (m_WriteTargetColorStride > 0)
|
|
|
|
{
|
|
|
|
newByte->bkColor = BKCOLOR_CPUWRITE;
|
|
|
|
}
|
|
|
|
else if (m_SymbolColorStride > 0)
|
|
|
|
{
|
|
|
|
newByte->bkColor = m_SymbolColorPhase ? BKCOLOR_SYMBOL0 : BKCOLOR_SYMBOL1;
|
|
|
|
}
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_Rom != nullptr && paddress >= 0x10000000 && paddress < 0x10000000 + g_Rom->GetRomSize())
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
newByte->color = COLOR_READONLY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nmgbi->bIgnoreDiff && oldByte->value != newByte->value)
|
|
|
|
{
|
|
|
|
newByte->color = COLOR_CHANGED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SymbolColorStride > 0)
|
|
|
|
{
|
|
|
|
m_SymbolColorStride--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_ReadTargetColorStride > 0)
|
|
|
|
{
|
|
|
|
m_ReadTargetColorStride--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_WriteTargetColorStride > 0)
|
|
|
|
{
|
|
|
|
m_WriteTargetColorStride--;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t safeEditValue;
|
|
|
|
if (GetSafeEditValue(address, &safeEditValue))
|
|
|
|
{
|
|
|
|
newByte->bValid = true;
|
|
|
|
newByte->value = safeEditValue;
|
|
|
|
newByte->bkColor = RGB(0xFF, 0xCC, 0xFF);
|
|
|
|
newByte->color = RGB(0xFF, 0x00, 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
newByte->bHidden = false;
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:11:59 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnHxRightClick(LPNMHDR lpNMHDR)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
NMHXRCLICK *nmrc = reinterpret_cast<NMHXRCLICK*>(lpNMHDR);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
m_ContextMenuAddress = nmrc->address;
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
HMENU hMenu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDR_MEM_BP_POPUP));
|
2017-09-13 12:00:53 +00:00
|
|
|
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
bool bHaveLock = m_Breakpoints->MemLockExists(m_ContextMenuAddress, 1);
|
|
|
|
bool bHaveReadBP = (m_Breakpoints->ReadBPExists8(m_ContextMenuAddress) != CBreakpoints::BPSTATE::BP_NOT_SET);
|
|
|
|
bool bHaveWriteBP = (m_Breakpoints->WriteBPExists8(m_ContextMenuAddress) != CBreakpoints::BPSTATE::BP_NOT_SET);
|
|
|
|
|
2017-11-23 21:15:06 +00:00
|
|
|
if (m_Breakpoints->ReadMem().size() == 0 && m_Breakpoints->WriteMem().size() == 0)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
|
|
|
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARALLBPS, MF_DISABLED | MF_GRAYED);
|
|
|
|
}
|
2018-03-18 01:14:52 +00:00
|
|
|
if (m_Breakpoints->NumMemLocks() == 0)
|
|
|
|
{
|
|
|
|
EnableMenuItem(hPopupMenu, ID_POPUPMENU_CLEARLOCKS, MF_DISABLED | MF_GRAYED);
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
CheckMenuItem(hPopupMenu, ID_POPUPMENU_TOGGLELOCK, bHaveLock ? MF_CHECKED : MF_UNCHECKED);
|
|
|
|
CheckMenuItem(hPopupMenu, ID_POPUPMENU_TOGGLERBP, bHaveReadBP ? MF_CHECKED : MF_UNCHECKED);
|
|
|
|
CheckMenuItem(hPopupMenu, ID_POPUPMENU_TOGGLEWBP, bHaveWriteBP ? MF_CHECKED : MF_UNCHECKED);
|
|
|
|
CheckMenuItem(hPopupMenu, ID_POPUPMENU_SAFEMODE, m_bSafeEditMode ? MF_CHECKED : MF_UNCHECKED);
|
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
POINT mouse;
|
|
|
|
GetCursorPos(&mouse);
|
2021-04-12 11:35:39 +00:00
|
|
|
TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN, mouse.x, mouse.y, 0, m_hWnd, nullptr);
|
2017-09-13 12:00:53 +00:00
|
|
|
DestroyMenu(hMenu);
|
2019-11-30 17:48:46 +00:00
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnHxHotAddrChanged(LPNMHDR /*lpNMHDR*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
m_HotAddress = m_HexEditCtrl.GetHotAddress();
|
|
|
|
stdstr strAddrInfo = "";
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
CSymbol symbol;
|
|
|
|
if (m_Debugger->SymbolTable()->GetSymbolByOverlappedAddress(m_HotAddress, &symbol))
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
strAddrInfo += stdstr_f("%08X %s %s", symbol.m_Address, symbol.TypeName(), symbol.m_Name);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
strAddrInfo += stdstr_f("%08X\n", m_HotAddress);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2020-05-12 12:19:05 +00:00
|
|
|
m_StatusBar.SetText(MEMSB_HOTADDR, strAddrInfo.ToUTF16().c_str());
|
2019-11-30 17:48:46 +00:00
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnHxBaseAddrChanged(LPNMHDR /*lpNMHDR*/)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-18 03:50:07 +00:00
|
|
|
// Address was updated from the control
|
2019-11-30 17:48:46 +00:00
|
|
|
uint32_t address = m_HexEditCtrl.GetBaseAddress();
|
|
|
|
m_bIgnoreAddressInput = true;
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(address, m_bVirtualMemory));
|
|
|
|
UpdateCurrentTab(address);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnHxCopy(LPNMHDR /*lpNMHDR*/)
|
|
|
|
{
|
|
|
|
HXCOLUMN column = m_HexEditCtrl.GetFocusedColumn();
|
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
|
|
|
CopyBytesToClipboard(startAddress, endAddress, column == HX_COL_HEXDATA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnHxPaste(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMHXPASTE *nmp = reinterpret_cast<NMHXPASTE*>(lpNMHDR);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_MMU == nullptr)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
return FALSE;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
OpenClipboard();
|
|
|
|
HANDLE hData = GetClipboardData(CF_TEXT);
|
|
|
|
char* text = (char*)GlobalLock(hData);
|
|
|
|
int retDataLength = 0;
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (nmp->column == HX_COL_HEXDATA)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-18 03:50:07 +00:00
|
|
|
// TODO: move this function to some utility class
|
2021-04-12 11:35:39 +00:00
|
|
|
int length = CMemoryScanner::ParseHexString(nullptr, text);
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
if (length != 0)
|
2018-01-21 01:51:36 +00:00
|
|
|
{
|
2021-04-22 00:00:27 +00:00
|
|
|
std::unique_ptr<char> data = std::make_unique<char>(length);
|
|
|
|
CMemoryScanner::ParseHexString(data.get(), text);
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < length; i++)
|
2018-01-21 01:51:36 +00:00
|
|
|
{
|
2021-04-22 00:00:27 +00:00
|
|
|
SetByte(nmp->address + i, data.get()[i]);
|
2018-01-21 01:51:36 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
retDataLength = length;
|
2018-01-21 01:51:36 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else if (nmp->column == HX_COL_ASCII)
|
2018-01-21 01:51:36 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
size_t length = strlen(text);
|
|
|
|
for (size_t i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
SetByte(nmp->address + i, text[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
retDataLength = length;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
GlobalUnlock(hData);
|
|
|
|
CloseClipboard();
|
|
|
|
|
|
|
|
return retDataLength;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
LRESULT CDebugMemoryView::OnTabSelChange(LPNMHDR /*lpNMHDR*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
TabSelChanged();
|
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::TabSelChanged(void)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
TCITEM item = { 0 };
|
|
|
|
item.mask = TCIF_PARAM;
|
|
|
|
|
|
|
|
int nItem = m_TabCtrl.GetCurSel();
|
|
|
|
|
|
|
|
if (m_TabCtrl.GetItem(nItem, &item))
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
tab_info_t tabInfo = m_TabData[nItem];
|
|
|
|
uint32_t address = tabInfo.address;
|
|
|
|
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
if (m_bVirtualMemory != tabInfo.bVirtual)
|
|
|
|
{
|
|
|
|
m_bVirtualMemory = tabInfo.bVirtual;
|
|
|
|
m_VirtualCheckbox.SetCheck(m_bVirtualMemory ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
SetupJumpMenu(m_bVirtualMemory);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CmbJump.SetCurSel(GetJumpItemIndex(address, m_bVirtualMemory));
|
|
|
|
m_HexEditCtrl.SetByteGroupSize(tabInfo.numBytesPerGroup);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
int CDebugMemoryView::AddTab(uint32_t address, bool bVirtual, int numBytesPerGroup)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2020-05-12 12:19:05 +00:00
|
|
|
stdstr szAddress;
|
|
|
|
szAddress.Format("%08X", address);
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabData.push_back({ address, bVirtual, numBytesPerGroup });
|
2020-05-12 12:19:05 +00:00
|
|
|
return m_TabCtrl.AddItem(TCIF_TEXT | TCIF_PARAM, szAddress.ToUTF16().c_str(), 0, (LPARAM)address);
|
2019-11-30 17:48:46 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
int CDebugMemoryView::InsertTab(int nItem, uint32_t address, bool bVirtual, int numBytesPerGroup)
|
|
|
|
{
|
|
|
|
m_TabData.insert(m_TabData.begin() + nItem + 1, { address, bVirtual, numBytesPerGroup });
|
|
|
|
m_TabCtrl.SetRedraw(FALSE);
|
|
|
|
m_TabCtrl.DeleteAllItems();
|
|
|
|
for (size_t i = 0; i < m_TabData.size(); i++)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2020-05-12 12:19:05 +00:00
|
|
|
m_TabCtrl.AddItem(TCIF_TEXT, stdstr_f("%08X", m_TabData[i].address).ToUTF16().c_str(), 0, 0);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabCtrl.SetRedraw(TRUE);
|
|
|
|
return nItem + 1;
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::DeleteTab(int nItem)
|
|
|
|
{
|
|
|
|
m_TabData.erase(m_TabData.begin() + nItem);
|
|
|
|
m_TabCtrl.DeleteItem(nItem);
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::UpdateCurrentTab(uint32_t address)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2020-05-12 12:19:05 +00:00
|
|
|
std::wstring szAddress = stdstr_f("%08X", address).ToUTF16();
|
2019-11-30 17:48:46 +00:00
|
|
|
int nItem = m_TabCtrl.GetCurSel();
|
|
|
|
|
|
|
|
if (nItem == -1)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
TCITEM item = { 0 };
|
|
|
|
item.mask = TCIF_TEXT;
|
2020-05-12 12:19:05 +00:00
|
|
|
item.pszText = (LPWSTR)szAddress.c_str();
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
m_TabCtrl.SetRedraw(FALSE);
|
|
|
|
m_TabCtrl.SetItem(nItem, &item);
|
|
|
|
m_TabData[nItem].address = address;
|
|
|
|
m_TabData[nItem].bVirtual = m_bVirtualMemory;
|
|
|
|
m_TabCtrl.SetRedraw(TRUE);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::OpenNewTab(uint32_t address, bool bVirtual, int numBytesPerGroup, bool bInsert, bool bOpenExisting)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
int nItem;
|
|
|
|
|
|
|
|
if (bOpenExisting)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
for (size_t i = 0; i < m_TabData.size(); i++)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
if (m_TabData[i].address == address && m_TabData[i].bVirtual == bVirtual)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabCtrl.SetCurSel(i);
|
|
|
|
TabSelChanged();
|
|
|
|
return;
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
if (bInsert)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
int nCurSelItem = m_TabCtrl.GetCurSel();
|
|
|
|
nItem = InsertTab(nCurSelItem, address, bVirtual, numBytesPerGroup);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
nItem = AddTab(address, bVirtual, numBytesPerGroup);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabCtrl.SetCurSel(nItem);
|
|
|
|
TabSelChanged();
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::OpenDuplicateTab(void)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
int nItem = m_TabCtrl.GetCurSel();
|
|
|
|
tab_info_t tabInfo = m_TabData[nItem];
|
|
|
|
int nItemNew = InsertTab(nItem, tabInfo.address, tabInfo.bVirtual, tabInfo.numBytesPerGroup);
|
|
|
|
m_TabCtrl.SetCurSel(nItemNew);
|
|
|
|
TabSelChanged();
|
|
|
|
}
|
2016-01-27 09:11:59 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::CloseTab(int nItem)
|
|
|
|
{
|
|
|
|
int itemCount = m_TabCtrl.GetItemCount();
|
|
|
|
int nSelItem = m_TabCtrl.GetCurSel();
|
|
|
|
|
|
|
|
if (itemCount < 2 || nItem == -1)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
if (nItem == nSelItem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
if (nItem == m_TabCtrl.GetItemCount() - 1)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2021-03-18 03:50:07 +00:00
|
|
|
// Last tab
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabCtrl.SetCurSel(nItem - 1);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else if (nItem == nSelItem)
|
2016-01-27 09:11:59 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
m_TabCtrl.SetCurSel(nItem + 1);
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
TabSelChanged();
|
2016-01-27 09:11:59 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
DeleteTab(nItem);
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::CloseCurrentTab(void)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
CloseTab(m_TabCtrl.GetCurSel());
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnTabDblClick(LPNMHDR /*lpNMHDR*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
OpenDuplicateTab();
|
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnTabRClick(LPNMHDR lpNMHDR)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
NMMTRCLICK *nmrc = reinterpret_cast<NMMTRCLICK*>(lpNMHDR);
|
|
|
|
CloseTab(nmrc->nItem);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
LRESULT CDebugMemoryView::OnStatusBarClick(LPNMHDR lpNMHDR)
|
|
|
|
{
|
|
|
|
NMMOUSE *nmm = reinterpret_cast<NMMOUSE*>(lpNMHDR);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
uint32_t startAddress, endAddress;
|
|
|
|
bool bHaveSelection = m_HexEditCtrl.GetSelectionRange(&startAddress, &endAddress);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (nmm->dwItemSpec == MEMSB_DMAINFO)
|
|
|
|
{
|
|
|
|
uint32_t romAddress, blockOffset;
|
|
|
|
DMALOGENTRY* entry = m_Debugger->DMALog()->GetEntryByRamAddress(startAddress, &romAddress, &blockOffset);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
if (entry == nullptr)
|
2019-11-30 17:48:46 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
stdstr strDmaTitle = stdstr_f("DMA Information for 0x%08X", startAddress);
|
|
|
|
stdstr strDmaInfo = stdstr_f("Block:\nROM 0x%08X -> RAM 0x%08X ( 0x%X bytes )\n\nROM address of byte:\n0x%08X ( 0x%08X + 0x%08X )",
|
|
|
|
entry->romAddr, entry->ramAddr, entry->length, romAddress, entry->romAddr, blockOffset);
|
2020-05-12 12:19:05 +00:00
|
|
|
MessageBox(strDmaInfo.ToUTF16().c_str(), strDmaTitle.ToUTF16().c_str(), MB_OK);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else if (nmm->dwItemSpec == MEMSB_BLOCK)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
stdstr strAddrRange;
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (bHaveSelection)
|
|
|
|
{
|
|
|
|
strAddrRange = stdstr_f("%08X:%08X", startAddress, endAddress);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strAddrRange = stdstr_f("%08X", startAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyTextToClipboard(strAddrRange.c_str());
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
2019-08-04 22:50:52 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
void CDebugMemoryView::OnJumpComboSelChange(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wndCtl*/)
|
2019-08-04 22:50:52 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
int nItem = m_CmbJump.GetCurSel();
|
|
|
|
uint32_t address;
|
2019-08-04 22:50:52 +00:00
|
|
|
|
2019-11-30 17:48:46 +00:00
|
|
|
if (m_bVirtualMemory)
|
2019-08-04 22:50:52 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
address = JumpItems[nItem].vaddr;
|
2019-08-04 22:50:52 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
else
|
2019-08-04 22:50:52 +00:00
|
|
|
{
|
2019-11-30 17:48:46 +00:00
|
|
|
address = JumpItems[nItem].paddr;
|
2019-08-04 22:50:52 +00:00
|
|
|
}
|
2019-11-30 17:48:46 +00:00
|
|
|
|
2020-04-08 11:44:49 +00:00
|
|
|
m_MemAddr.SetValue(address, DisplayMode::ZeroExtend);
|
2019-11-30 17:48:46 +00:00
|
|
|
m_HexEditCtrl.SetFocus();
|
2019-08-04 22:50:52 +00:00
|
|
|
}
|