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

128 lines
3.3 KiB
C++
Raw Normal View History

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"
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));
m_List.AddColumn("Caller", 0);
m_List.AddColumn("Routine", 1);
m_List.AddColumn("Name", 2);
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).c_str());
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;
char szAddress[9];
sprintf(szAddress, "%08X", callingAddress);
m_List.AddItem(i, 0, szAddress);
sprintf(szAddress, "%08X", routineAddress);
m_List.AddItem(i, 1, szAddress);
CSymbol symbol;
if (m_Debugger->SymbolTable()->GetSymbolByAddress(routineAddress, &symbol))
{
m_List.AddItem(i, 2, symbol.m_Name);
}
else
{
m_List.AddItem(i, 2, "");
}
m_List.SetItemData(i, routineAddress);
}
m_List.SetRedraw(TRUE);
2017-08-18 05:08:22 +00:00
}