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

112 lines
2.5 KiB
C++
Raw Normal View History

2017-08-18 05:08:22 +00:00
#include "stdafx.h"
#include "DebuggerUI.h"
2017-08-30 04:54:06 +00:00
#include "Symbols.h"
2017-08-18 05:08:22 +00:00
CDebugStackTrace::CDebugStackTrace(CDebuggerUI* debugger) :
2017-08-30 04:54:06 +00:00
CDebugDialog<CDebugStackTrace>(debugger),
m_EntriesIndex(0)
2017-08-18 05:08:22 +00:00
{
}
CDebugStackTrace::~CDebugStackTrace()
{
}
2017-08-30 04:54:06 +00:00
LRESULT CDebugStackTrace::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
2019-12-25 00:41:20 +00:00
DlgResize_Init();
DlgSavePos_Init(DebuggerUI_StackTracePos);
2019-12-25 00:41:20 +00:00
m_List.Attach(GetDlgItem(IDC_STACKTRACE_LIST));
2020-05-12 12:19:05 +00:00
m_List.AddColumn(L"Caller", 0);
m_List.AddColumn(L"Routine", 1);
m_List.AddColumn(L"Name", 2);
2019-12-25 00:41:20 +00:00
m_List.SetColumnWidth(0, 70);
m_List.SetColumnWidth(1, 70);
m_List.SetColumnWidth(2, 160);
m_List.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
LoadWindowPos();
WindowCreated();
return TRUE;
2017-08-18 05:08:22 +00:00
}
void CDebugStackTrace::OnExitSizeMove(void)
{
SaveWindowPos(true);
}
2018-01-18 06:53:07 +00:00
LRESULT CDebugStackTrace::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
2017-08-18 05:08:22 +00:00
{
2019-12-25 00:41:20 +00:00
Refresh();
return FALSE;
2017-08-18 05:08:22 +00:00
}
LRESULT CDebugStackTrace::OnDestroy(void)
{
m_List.Detach();
2019-12-25 00:41:20 +00:00
return FALSE;
2017-08-18 05:08:22 +00:00
}
LRESULT CDebugStackTrace::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
2019-12-25 00:41:20 +00:00
switch (wID)
{
case IDCANCEL:
EndDialog(0);
break;
}
return FALSE;
2017-08-18 05:08:22 +00:00
}
LRESULT CDebugStackTrace::OnListDblClicked(NMHDR* pNMHDR)
{
2019-12-25 00:41:20 +00:00
NMITEMACTIVATE* pIA = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
int nItem = pIA->iItem;
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
uint32_t address = m_List.GetItemData(nItem);
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
m_Debugger->Debug_ShowCommandsLocation(address, true);
2017-08-18 05:08:22 +00:00
2019-12-25 00:41:20 +00:00
return 0;
2017-08-18 05:08:22 +00:00
}
2017-08-30 04:54:06 +00:00
void CDebugStackTrace::Refresh()
2017-08-18 05:08:22 +00:00
{
2019-12-25 00:41:20 +00:00
if (!isStepping())
{
return;
}
SetWindowText(stdstr_f("Stack trace (%d)", m_EntriesIndex).ToUTF16().c_str());
2019-12-25 00:41:20 +00:00
m_List.SetRedraw(FALSE);
m_List.DeleteAllItems();
for (int i = 0; i < m_EntriesIndex; i++)
{
uint32_t routineAddress = m_Entries[i].routineAddress;
uint32_t callingAddress = m_Entries[i].callingAddress;
2020-05-12 12:19:05 +00:00
m_List.AddItem(i, 0, stdstr_f("%08X", callingAddress).ToUTF16().c_str());
m_List.AddItem(i, 1, stdstr_f("%08X", routineAddress).ToUTF16().c_str());
2019-12-25 00:41:20 +00:00
CSymbol symbol;
if (m_Debugger->SymbolTable()->GetSymbolByAddress(routineAddress, &symbol))
{
2020-05-12 12:19:05 +00:00
m_List.AddItem(i, 2, stdstr(symbol.m_Name).ToUTF16().c_str());
2019-12-25 00:41:20 +00:00
}
else
{
2020-05-12 12:19:05 +00:00
m_List.AddItem(i, 2, L"");
2019-12-25 00:41:20 +00:00
}
m_List.SetItemData(i, routineAddress);
}
m_List.SetRedraw(TRUE);
}