2017-08-18 05:08:22 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DebuggerUI.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <Common/path.h>
|
|
|
|
|
|
|
|
#include "Symbols.h"
|
|
|
|
|
|
|
|
CDebugSymbols::CDebugSymbols(CDebuggerUI * debugger) :
|
2017-09-13 12:00:53 +00:00
|
|
|
CDebugDialog<CDebugSymbols>(debugger)
|
|
|
|
{
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 12:00:53 +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
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
m_SymbolsListView.AddColumn("Address", 0);
|
|
|
|
m_SymbolsListView.AddColumn("Type", 1);
|
|
|
|
m_SymbolsListView.AddColumn("Name", 2);
|
|
|
|
m_SymbolsListView.AddColumn("Value", 3);
|
|
|
|
m_SymbolsListView.AddColumn("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
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
Refresh();
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
SetTimer(TIMER_ID_AUTO_REFRESH, 100, NULL);
|
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
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
RefreshValues();
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CDebugSymbols::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
|
|
|
|
{
|
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:
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
int nItem = m_SymbolsListView.GetSelectedIndex();
|
|
|
|
if (nItem != -1)
|
|
|
|
{
|
|
|
|
int id = m_SymbolsListView.GetItemData(nItem);
|
|
|
|
m_Debugger->SymbolTable()->RemoveSymbolById(id);
|
|
|
|
m_Debugger->SymbolTable()->Save();
|
|
|
|
Refresh();
|
|
|
|
}
|
2017-09-13 12:00:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
LRESULT CDebugSymbols::OnListDblClicked(NMHDR* pNMHDR)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
// Open it in memory viewer/commands viewer
|
|
|
|
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
|
|
|
|
int nItem = pIA->iItem;
|
|
|
|
|
|
|
|
int id = m_SymbolsListView.GetItemData(nItem);
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
CSymbol symbol;
|
|
|
|
if (!m_Debugger->SymbolTable()->GetSymbolById(id, &symbol))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (symbol.m_Type == SYM_CODE) // code
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
m_Debugger->Debug_ShowCommandsLocation(symbol.m_Address, true);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
else // data/number
|
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
m_Debugger->Debug_ShowMemoryLocation(symbol.m_Address, true);
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugSymbols::Refresh()
|
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
if (m_SymbolsListView.m_hWnd == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_SymbolsListView.SetRedraw(FALSE);
|
|
|
|
m_SymbolsListView.DeleteAllItems();
|
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
CSymbol symbol;
|
|
|
|
int nItem = 0;
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
while (m_Debugger->SymbolTable()->GetSymbolByIndex(nItem, &symbol))
|
2017-09-13 12:00:53 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
char szValue[64];
|
|
|
|
m_Debugger->SymbolTable()->GetValueString(szValue, &symbol);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
stdstr strAddr = stdstr_f("%08X", symbol.m_Address);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
m_SymbolsListView.AddItem(nItem, 0, strAddr.c_str());
|
|
|
|
m_SymbolsListView.AddItem(nItem, 1, symbol.TypeName());
|
|
|
|
m_SymbolsListView.AddItem(nItem, 2, symbol.m_Name);
|
|
|
|
m_SymbolsListView.AddItem(nItem, 4, symbol.m_Description);
|
|
|
|
m_SymbolsListView.AddItem(nItem, 5, szValue);
|
2017-09-13 12:00:53 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
m_SymbolsListView.SetItemData(nItem, symbol.m_Id);
|
|
|
|
nItem++;
|
2017-09-13 12:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_SymbolsListView.SetRedraw(TRUE);
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CDebugSymbols::RefreshValues()
|
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
if (g_MMU == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
int count = m_SymbolsListView.GetItemCount();
|
2019-12-25 00:41:20 +00:00
|
|
|
|
|
|
|
CSymbol symbol;
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
int symbolId = m_SymbolsListView.GetItemData(i);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
if (!m_Debugger->SymbolTable()->GetSymbolById(symbolId, &symbol))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
char szValue[64];
|
2019-12-25 00:41:20 +00:00
|
|
|
m_Debugger->SymbolTable()->GetValueString(szValue, &symbol);
|
2017-08-18 05:08:22 +00:00
|
|
|
|
2017-09-13 12:00:53 +00:00
|
|
|
m_SymbolsListView.SetItemText(i, 3, szValue);
|
|
|
|
}
|
2019-12-25 00:41:20 +00:00
|
|
|
}
|