project64/Source/Project64/UserInterface/Debugger/Debugger-TLB.cpp

284 lines
7.5 KiB
C++
Raw Normal View History

2016-01-27 09:11:59 +00:00
#include "stdafx.h"
#include "DebuggerUI.h"
CDebugTlb::CDebugTlb(CDebuggerUI * debugger) :
CDebugDialog<CDebugTlb>(debugger)
{
}
CDebugTlb::~CDebugTlb()
{
}
2019-12-25 00:41:20 +00:00
LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
2016-01-27 09:11:59 +00:00
{
DlgSavePos_Init(DebuggerUI_TLBPos);
2020-05-12 12:19:05 +00:00
LV_COLUMN col;
float DPIScale = CClientDC(m_hWnd).GetDeviceCaps(LOGPIXELSX) / 96.0f;
2016-01-27 09:11:59 +00:00
col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
col.fmt = LVCFMT_LEFT;
2020-05-12 12:19:05 +00:00
col.pszText = L"Index";
2020-01-22 06:34:27 +00:00
col.cx = (int)(40 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 0;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col);
col.pszText = L"Page mask";
2020-01-22 06:34:27 +00:00
col.cx = (int)(90 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 1;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Entry Hi";
2020-01-22 06:34:27 +00:00
col.cx = (int)(90 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 2;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 2, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Entry Lo0";
2020-01-22 06:34:27 +00:00
col.cx = (int)(90 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 3;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 3, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Entry Lo1";
2020-01-22 06:34:27 +00:00
col.cx = (int)(90 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 4;
ListView_InsertColumn(GetDlgItem(IDC_LIST), 4, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Index";
2020-01-22 06:34:27 +00:00
col.cx = (int)(40 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 0;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 0, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Valid";
2020-01-22 06:34:27 +00:00
col.cx = (int)(40 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 1;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 1, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Dirty";
2020-01-22 06:34:27 +00:00
col.cx = (int)(40 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 2;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 2, &col);
2020-05-12 12:19:05 +00:00
col.pszText = L"Rule";
2020-01-22 06:34:27 +00:00
col.cx = (int)(270 * DPIScale);
2016-01-27 09:11:59 +00:00
col.iSubItem = 3;
ListView_InsertColumn(GetDlgItem(IDC_LIST2), 3, &col);
RefreshTLBWindow();
SendMessage(GetDlgItem(IDC_TLB_ENTRIES), BM_SETCHECK, BST_CHECKED, 0);
2019-12-25 00:41:20 +00:00
LoadWindowPos();
WindowCreated();
2016-01-27 09:11:59 +00:00
return TRUE;
}
2019-01-14 04:03:02 +00:00
void CDebugTlb::OnExitSizeMove(void)
{
2019-12-25 00:41:20 +00:00
SaveWindowPos(0);
2019-01-14 04:03:02 +00:00
}
2016-01-27 09:11:59 +00:00
LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
case IDC_TLB_ENTRIES:
::ShowWindow(GetDlgItem(IDC_LIST), SW_SHOW);
::ShowWindow(GetDlgItem(IDC_LIST2), SW_HIDE);
break;
case IDC_TLB_RULES:
::ShowWindow(GetDlgItem(IDC_LIST), SW_HIDE);
::ShowWindow(GetDlgItem(IDC_LIST2), SW_SHOW);
break;
}
return FALSE;
}
void CDebugTlb::RefreshTLBWindow(void)
{
2021-04-12 11:35:39 +00:00
if (m_hWnd == nullptr)
2016-01-27 09:11:59 +00:00
{
return;
}
HWND hList = GetDlgItem(IDC_LIST);
2020-05-12 12:19:05 +00:00
wchar_t Output[100], OldText[100];
2016-01-27 09:11:59 +00:00
LV_ITEM item, OldItem;
int count;
CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;
for (count = 0; count < 32; count++)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%02X", count);
2016-01-27 09:11:59 +00:00
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count)
{
ListView_InsertItem(hList, &item);
}
else
{
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
}
if (tlb[count].EntryDefined)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%08X", tlb[count].PageMask.Value);
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%08X", tlb[count].EntryHi.Value);
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%08X", tlb[count].EntryLo0.Value);
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
if (tlb[count].EntryDefined)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%08X", tlb[count].EntryLo1.Value);
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 4;
OldItem.iSubItem = 4;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
}
CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb;
hList = GetDlgItem(IDC_LIST2);
for (count = 0; count < 64; count++)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"0x%02X", count);
2016-01-27 09:11:59 +00:00
item.mask = LVIF_TEXT;
item.iItem = count;
item.pszText = Output;
item.iSubItem = 0;
OldItem.mask = LVIF_TEXT;
OldItem.iItem = count;
OldItem.pszText = OldText;
OldItem.cchTextMax = sizeof(OldText) - 1;
OldItem.iSubItem = 0;
if (ListView_GetItemCount(hList) <= count)
{
item.iItem = ListView_InsertItem(hList, &item);
}
else
{
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
}
if (FastTlb[count].ValidEntry)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"%s", FastTlb[count].VALID ? L"Yes" : L"No");
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 1;
OldItem.iSubItem = 1;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"%s", FastTlb[count].DIRTY ? L"Yes" : L"No");
2016-01-27 09:11:59 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 2;
OldItem.iSubItem = 2;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
{
2020-05-12 12:19:05 +00:00
swprintf(Output, sizeof(Output), L"%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND,
2016-01-27 09:11:59 +00:00
FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND);
}
else
{
2020-05-12 12:19:05 +00:00
wcscpy(Output, L"................");
2016-01-27 09:11:59 +00:00
}
item.iSubItem = 3;
OldItem.iSubItem = 3;
ListView_GetItem(hList, &OldItem);
2020-05-12 12:19:05 +00:00
if (wcscmp(item.pszText, OldItem.pszText) != 0)
2016-01-27 09:11:59 +00:00
{
ListView_SetItem(hList, &item);
}
}
}