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
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
CDebugStackTrace::CDebugStackTrace(CDebuggerUI * debugger) :
|
|
|
|
CDebugDialog<CDebugStackTrace>(debugger),
|
|
|
|
m_EntriesIndex(0)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CDebugStackTrace::~CDebugStackTrace()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugStackTrace::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL & /*bHandled*/)
|
2017-08-30 04:54:06 +00:00
|
|
|
{
|
2019-12-25 00:41:20 +00:00
|
|
|
DlgResize_Init();
|
2019-01-14 07:06:01 +00:00
|
|
|
DlgSavePos_Init(DebuggerUI_StackTracePos);
|
2022-09-21 05:16:07 +00:00
|
|
|
|
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);
|
2022-09-21 05:16:07 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-01-14 06:02:05 +00:00
|
|
|
void CDebugStackTrace::OnExitSizeMove(void)
|
|
|
|
{
|
2019-04-19 01:18:55 +00:00
|
|
|
SaveWindowPos(true);
|
2019-01-14 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16: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)
|
|
|
|
{
|
2017-09-13 12:00:53 +00:00
|
|
|
m_List.Detach();
|
2019-12-25 00:41:20 +00:00
|
|
|
return FALSE;
|
2017-08-18 05:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugStackTrace::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL & /*bHandled*/)
|
2017-08-18 05:08:22 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2022-09-21 05:16:07 +00:00
|
|
|
LRESULT CDebugStackTrace::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);
|
2019-12-25 00:41:20 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-03-18 03:34:08 +00:00
|
|
|
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;
|
2022-09-21 05:16:07 +00:00
|
|
|
|
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
|
|
|
}
|
2022-09-21 05:16:07 +00:00
|
|
|
|
2019-12-25 00:41:20 +00:00
|
|
|
m_List.SetItemData(i, routineAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_List.SetRedraw(TRUE);
|
2021-03-18 03:34:08 +00:00
|
|
|
}
|