2017-08-18 05:08:22 +00:00
|
|
|
#include "stdafx.h"
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2017-08-18 05:08:22 +00:00
|
|
|
#include "DebuggerUI.h"
|
|
|
|
|
|
|
|
#include <Common/path.h>
|
2022-09-21 05:16:07 +00:00
|
|
|
#include <stdio.h>
|
2017-08-18 05:08:22 +00:00
|
|
|
|
|
|
|
#include "Symbols.h"
|
|
|
|
|
2020-02-11 02:36:30 +00:00
|
|
|
const CSetValueDlg::ComboItem CDebugSymbols::ModalChangeTypeItems[] = {
|
2022-09-21 05:16:07 +00:00
|
|
|
{"code", SYM_CODE},
|
|
|
|
{"data", SYM_DATA},
|
|
|
|
{"uint8", SYM_U8},
|
|
|
|
{"int8", SYM_S8},
|
|
|
|
{"uint16", SYM_U16},
|
|
|
|
{"int16", SYM_S16},
|
|
|
|
{"uint32", SYM_U32},
|
|
|
|
{"int32", SYM_S32},
|
|
|
|
{"uint64", SYM_U64},
|
|
|
|
{"int64", SYM_S64},
|
|
|
|
{"float", SYM_FLOAT},
|
|
|
|
{"double", SYM_DOUBLE},
|
|
|
|
{"v2", SYM_VECTOR2},
|
|
|
|
{"v3", SYM_VECTOR3},
|
|
|
|
{"v4", SYM_VECTOR4},
|
2021-04-12 11:35:39 +00:00
|
|
|
{ nullptr, 0 }
|
2020-02-11 02:36:30 +00:00
|
|
|
};
|
|
|
|
|
2017-08-18 05:08:22 +00:00
|
|
|
CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) :
|
2021-08-26 02:58:34 +00:00
|
|
|
CDebugDialog<CDebugSymbols>(debugger),
|
|
|
|
m_SymbolTable(debugger->SymbolTable()),
|
|
|
|
m_SymbolCacheStartIndex(0),
|
|
|
|
m_bFiltering(false)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
memset(m_FilterText, 0, sizeof(m_FilterText));
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugSymbols::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
DlgResize_Init(false, true);
|
2019-01-14 07:06:01 +00:00
|
|
|
DlgSavePos_Init(DebuggerUI_SymbolsPos);
|
2019-01-13 08:13:59 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
m_SymbolsListView.Attach(GetDlgItem(IDC_SYMBOLS_LIST));
|
|
|
|
m_SymbolsListView.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2020-05-12 12:19:05 +00:00
|
|
|
m_SymbolsListView.AddColumn(L"Address", 0);
|
|
|
|
m_SymbolsListView.AddColumn(L"Type", 1);
|
|
|
|
m_SymbolsListView.AddColumn(L"Name", 2);
|
|
|
|
m_SymbolsListView.AddColumn(L"Value", 3);
|
|
|
|
m_SymbolsListView.AddColumn(L"Description", 4);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
m_SymbolsListView.SetColumnWidth(0, 70);
|
|
|
|
m_SymbolsListView.SetColumnWidth(1, 40);
|
|
|
|
m_SymbolsListView.SetColumnWidth(2, 120);
|
|
|
|
m_SymbolsListView.SetColumnWidth(3, 100);
|
|
|
|
m_SymbolsListView.SetColumnWidth(4, 120);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
::SetWindowText(GetDlgItem(IDC_FILTER_EDIT), m_FilterText);
|
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
Refresh();
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
SetTimer(TIMER_ID_AUTO_REFRESH, 100, nullptr);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
LoadWindowPos();
|
|
|
|
WindowCreated();
|
2017-09-13 12:00:53 +00:00
|
|
|
return 0;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-01-14 05:55:19 +00:00
|
|
|
void CDebugSymbols::OnExitSizeMove(void)
|
|
|
|
{
|
2019-04-19 01:18:55 +00:00
|
|
|
SaveWindowPos(true);
|
2019-01-14 05:55:19 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 05:08:22 +00:00
|
|
|
LRESULT CDebugSymbols::OnDestroy(void)
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
KillTimer(TIMER_ID_AUTO_REFRESH);
|
2017-09-13 12:00:53 +00:00
|
|
|
m_SymbolsListView.Detach();
|
|
|
|
return 0;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
void CDebugSymbols::OnTimer(UINT_PTR nIDEvent)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
if (nIDEvent == TIMER_ID_AUTO_REFRESH)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
Refresh();
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
switch (wID)
|
|
|
|
{
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(0);
|
|
|
|
break;
|
|
|
|
case IDC_ADDSYMBOL_BTN:
|
|
|
|
m_AddSymbolDlg.DoModal(m_Debugger);
|
|
|
|
break;
|
|
|
|
case IDC_REMOVESYMBOL_BTN:
|
2022-09-21 05:16:07 +00:00
|
|
|
{
|
|
|
|
int nItem = m_SymbolsListView.GetSelectedIndex();
|
|
|
|
int id = -1;
|
|
|
|
if (m_bFiltering)
|
2019-12-25 00:41:20 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
id = m_FilteredSymbols[nItem].m_Id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CSymbol symbol;
|
|
|
|
m_SymbolTable->GetSymbolByIndex(nItem, &symbol);
|
|
|
|
id = symbol.m_Id;
|
|
|
|
}
|
2021-08-26 02:58:34 +00:00
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
if (id != -1)
|
|
|
|
{
|
|
|
|
m_SymbolTable->RemoveSymbolById(id);
|
|
|
|
m_SymbolTable->Save();
|
|
|
|
Refresh();
|
2019-12-25 00:41:20 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugSymbols::OnListDblClicked(NMHDR * pNMHDR)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
NMITEMACTIVATE * pIA = reinterpret_cast<NMITEMACTIVATE *>(pNMHDR);
|
2020-02-11 03:42:25 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
if (pIA->iItem == -1)
|
2020-02-11 03:42:25 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
return 0;
|
2020-02-11 03:42:25 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
int id = GetListItemSymbolId(pIA->iItem);
|
2020-02-11 03:42:25 +00:00
|
|
|
|
|
|
|
CSymbol symbol;
|
2021-08-26 02:58:34 +00:00
|
|
|
if (!m_SymbolTable->GetSymbolById(id, &symbol))
|
2020-02-11 03:42:25 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
POINT mousePt;
|
|
|
|
GetCursorPos(&mousePt);
|
|
|
|
int nSelectedCol = ColumnHitTest(mousePt);
|
|
|
|
|
2020-02-11 03:42:25 +00:00
|
|
|
switch (nSelectedCol)
|
|
|
|
{
|
|
|
|
case SymbolsListView_Col_Address:
|
|
|
|
// Open it in memory viewer/commands viewer
|
2021-03-18 03:40:52 +00:00
|
|
|
if (symbol.m_Type == SYM_CODE) // Code
|
2020-02-11 03:42:25 +00:00
|
|
|
{
|
|
|
|
m_Debugger->Debug_ShowCommandsLocation(symbol.m_Address, true);
|
|
|
|
}
|
2021-03-18 03:40:52 +00:00
|
|
|
else // Data/number
|
2020-02-11 03:42:25 +00:00
|
|
|
{
|
|
|
|
m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Type:
|
|
|
|
if (m_SetValueDlg.DoModal("Change type", "New type:", symbol.m_Type, ModalChangeTypeItems))
|
|
|
|
{
|
|
|
|
ValueType t = (ValueType)m_SetValueDlg.GetEnteredData();
|
|
|
|
|
2021-03-18 03:40:52 +00:00
|
|
|
// TODO: Is there a better way?
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolTable->RemoveSymbolById(id);
|
|
|
|
m_SymbolTable->AddSymbol(t, symbol.m_Address, symbol.m_Name, symbol.m_Description);
|
2020-02-11 03:42:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Name:
|
|
|
|
if (m_SetValueDlg.DoModal("Set name", "New name:", symbol.m_Name))
|
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolTable->RemoveSymbolById(id);
|
|
|
|
m_SymbolTable->AddSymbol(symbol.m_Type, symbol.m_Address, m_SetValueDlg.GetEnteredString().c_str(), symbol.m_Description);
|
2020-02-11 03:42:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Value:
|
2020-05-02 10:25:28 +00:00
|
|
|
char szValue[256];
|
2022-09-21 05:16:07 +00:00
|
|
|
const char * x;
|
|
|
|
const char * y;
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolTable->GetValueString(szValue, &symbol);
|
2020-02-11 02:36:30 +00:00
|
|
|
if (m_SetValueDlg.DoModal("Change value", "New value:", szValue))
|
|
|
|
{
|
2021-04-20 02:56:16 +00:00
|
|
|
const std::string & EnteredString = m_SetValueDlg.GetEnteredString();
|
2020-05-12 12:19:05 +00:00
|
|
|
|
2020-02-11 03:42:25 +00:00
|
|
|
switch (symbol.m_Type)
|
|
|
|
{
|
|
|
|
case SYM_U8:
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<uint8_t>(symbol.m_Address, (uint8_t)atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_U16:
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<uint16_t>(symbol.m_Address, (uint16_t)atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_U32:
|
2020-05-12 12:19:05 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<uint32_t>(symbol.m_Address, atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_U64:
|
2020-05-12 12:19:05 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<uint64_t>(symbol.m_Address, atoll(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_S8:
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<int8_t>(symbol.m_Address, (int8_t)atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_S16:
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<int16_t>(symbol.m_Address, (int16_t)atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_S32:
|
2020-05-12 12:19:05 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<int>(symbol.m_Address, atoi(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_S64:
|
2020-05-12 12:19:05 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<int64_t>(symbol.m_Address, atoll(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_FLOAT:
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address, (float)atof(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SYM_DOUBLE:
|
2020-05-12 12:19:05 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<double>(symbol.m_Address, atof(EnteredString.c_str()));
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
2020-05-02 10:25:28 +00:00
|
|
|
case SYM_VECTOR2:
|
2020-05-12 12:19:05 +00:00
|
|
|
x = EnteredString.c_str();
|
2020-05-02 10:25:28 +00:00
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address, (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
memcpy(szValue, x, strlen(x));
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + sizeof(float), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
break;
|
|
|
|
case SYM_VECTOR3:
|
2020-05-12 12:19:05 +00:00
|
|
|
x = EnteredString.c_str();
|
2020-05-02 10:25:28 +00:00
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address, (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + sizeof(float), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
memcpy(szValue, x, strlen(x));
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + (sizeof(float) * 2), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
break;
|
|
|
|
case SYM_VECTOR4:
|
2020-05-12 12:19:05 +00:00
|
|
|
x = EnteredString.c_str();
|
2020-05-02 10:25:28 +00:00
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address, (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + sizeof(float), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
y = strchr(x, ',');
|
|
|
|
memcpy(szValue, x, y - x);
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + (sizeof(float) * 2), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
|
|
|
|
x = x + (y - x) + 1;
|
|
|
|
memcpy(szValue, x, strlen(x));
|
2021-01-19 05:58:59 +00:00
|
|
|
m_Debugger->DebugStore_VAddr<float>(symbol.m_Address + (sizeof(float) * 3), (float)atof(szValue));
|
2020-05-02 10:25:28 +00:00
|
|
|
break;
|
2020-02-11 03:42:25 +00:00
|
|
|
}
|
2020-02-11 02:36:30 +00:00
|
|
|
}
|
2020-02-11 03:42:25 +00:00
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Description:
|
|
|
|
if (m_SetValueDlg.DoModal("Set description", "New description:", symbol.m_Description))
|
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolTable->RemoveSymbolById(id);
|
|
|
|
m_SymbolTable->AddSymbol(symbol.m_Type, symbol.m_Address, symbol.m_Name, m_SetValueDlg.GetEnteredString().c_str());
|
2020-02-11 03:42:25 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-09-21 05:16:07 +00:00
|
|
|
}
|
2020-02-11 03:42:25 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolTable->Save();
|
2020-02-11 03:42:25 +00:00
|
|
|
Refresh();
|
2017-09-13 12:00:53 +00:00
|
|
|
|
|
|
|
return 0;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugSymbols::OnListGetDispInfo(NMHDR * pNMHDR)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
NMLVDISPINFO * plvdi = (NMLVDISPINFO *)pNMHDR;
|
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
int index = plvdi->item.iItem;
|
|
|
|
|
|
|
|
if (index == -1)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
return TRUE;
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
std::vector<SymbolCacheItem> & cache = m_bFiltering ? m_FilteredSymbols : m_SymbolCache;
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
if (!m_bFiltering)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
index -= m_SymbolCacheStartIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (plvdi->item.iSubItem)
|
|
|
|
{
|
|
|
|
case SymbolsListView_Col_Address:
|
|
|
|
plvdi->item.pszText = cache[index].m_Address;
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Type:
|
|
|
|
plvdi->item.pszText = cache[index].m_Type;
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Name:
|
|
|
|
plvdi->item.pszText = cache[index].m_Name;
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Value:
|
|
|
|
plvdi->item.pszText = cache[index].m_Value;
|
|
|
|
break;
|
|
|
|
case SymbolsListView_Col_Description:
|
|
|
|
plvdi->item.pszText = cache[index].m_Description;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugSymbols::OnListCacheHint(NMHDR * pNMHDR)
|
|
|
|
{
|
2022-09-21 05:16:07 +00:00
|
|
|
NMLVCACHEHINT * plvch = (NMLVCACHEHINT *)pNMHDR;
|
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
if (m_bFiltering)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolCacheStartIndex = plvch->iFrom;
|
|
|
|
m_SymbolCache.clear();
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
for (int index = plvch->iFrom; index <= plvch->iTo; index++)
|
|
|
|
{
|
|
|
|
CSymbol symbol;
|
|
|
|
if (!m_SymbolTable->GetSymbolByIndex(index, &symbol))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
SymbolCacheItem item(symbol, m_SymbolTable);
|
|
|
|
m_SymbolCache.push_back(item);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
return 0;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugSymbols::OnFilterChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
if (::GetWindowTextLength(GetDlgItem(IDC_FILTER_EDIT)) == 0)
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
m_bFiltering = false;
|
|
|
|
Refresh();
|
|
|
|
return FALSE;
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
m_bFiltering = true;
|
|
|
|
::GetWindowText(GetDlgItem(IDC_FILTER_EDIT), m_FilterText, sizeof(m_FilterText) / sizeof(wchar_t));
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
UpdateFilteredSymbols();
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
m_SymbolsListView.SetItemCount(m_FilteredSymbols.size());
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
int CDebugSymbols::ColumnHitTest(POINT & pt)
|
2021-08-26 02:58:34 +00:00
|
|
|
{
|
|
|
|
int nHitCol = -1;
|
|
|
|
RECT listRect;
|
|
|
|
m_SymbolsListView.GetWindowRect(&listRect);
|
|
|
|
|
|
|
|
int mouseX = pt.x - listRect.left;
|
|
|
|
|
|
|
|
for (int nCol = 0, colX = 0; nCol < SymbolsListView_Num_Columns; nCol++)
|
|
|
|
{
|
|
|
|
int colWidth = m_SymbolsListView.GetColumnWidth(nCol);
|
|
|
|
if (mouseX >= colX && mouseX <= colX + colWidth)
|
|
|
|
{
|
|
|
|
nHitCol = nCol;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
colX += colWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nHitCol;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugSymbols::UpdateFilteredSymbols()
|
|
|
|
{
|
|
|
|
m_FilteredSymbols.clear();
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
CSymbol symbol;
|
2021-08-26 02:58:34 +00:00
|
|
|
size_t index = 0;
|
|
|
|
while (m_SymbolTable->GetSymbolByIndex(index++, &symbol))
|
|
|
|
{
|
|
|
|
std::wstring strName = stdstr(symbol.m_Name).ToUTF16();
|
|
|
|
std::wstring strDesc = stdstr(symbol.m_Description).ToUTF16();
|
|
|
|
|
|
|
|
if (strName.find(m_FilterText) != std::wstring::npos ||
|
|
|
|
strDesc.find(m_FilterText) != std::wstring::npos)
|
|
|
|
{
|
|
|
|
SymbolCacheItem item(symbol, m_SymbolTable);
|
|
|
|
m_FilteredSymbols.push_back(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugSymbols::Refresh()
|
|
|
|
{
|
|
|
|
if (g_Settings->LoadStringVal(Game_GameName) != "")
|
|
|
|
{
|
|
|
|
stdstr windowTitle = stdstr_f("Symbols - %s", g_Settings->LoadStringVal(Game_GameName).c_str());
|
|
|
|
SetWindowText(windowTitle.ToUTF16().c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetWindowText(L"Symbols");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_SymbolsListView.m_hWnd == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
int numSymbols = 0;
|
|
|
|
|
|
|
|
if (m_bFiltering)
|
|
|
|
{
|
|
|
|
UpdateFilteredSymbols();
|
|
|
|
numSymbols = m_FilteredSymbols.size();
|
|
|
|
}
|
|
|
|
else
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
numSymbols = m_SymbolTable->GetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_SymbolsListView.SetItemCountEx(numSymbols, LVSICF_NOSCROLL);
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
int CDebugSymbols::GetListItemSymbolId(int nItem)
|
|
|
|
{
|
|
|
|
if (m_bFiltering)
|
|
|
|
{
|
|
|
|
if (nItem >= m_FilteredSymbols.size())
|
2019-12-25 00:41:20 +00:00
|
|
|
{
|
2021-08-26 02:58:34 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
2019-12-25 00:41:20 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
return m_FilteredSymbols[nItem].m_Id;
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2021-08-26 02:58:34 +00:00
|
|
|
CSymbol symbol;
|
|
|
|
if (!m_SymbolTable->GetSymbolByIndex(nItem, &symbol))
|
|
|
|
{
|
|
|
|
g_Notify->BreakPoint(__FILE__, __LINE__);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2021-08-26 02:58:34 +00:00
|
|
|
|
|
|
|
return symbol.m_Id;
|
2019-12-25 00:41:20 +00:00
|
|
|
}
|