| 45 | } |
| 46 | |
| 47 | LRESULT CCallStackDlg::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { |
| 48 | m_List.Attach(GetDlgItem(IDC_LIST)); |
| 49 | |
| 50 | CString num; |
| 51 | num.Format(L"Call Stack (Event #%u)", m_pData->GetIndex()); |
| 52 | SetWindowText(num); |
| 53 | |
| 54 | DlgResize_Init(true); |
| 55 | |
| 56 | auto stack = m_pData->GetStackEventData(); |
| 57 | ATLASSERT(stack); |
| 58 | if (stack == nullptr) { |
| 59 | EndDialog(IDCANCEL); |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | auto& symbols = SymbolManager::Get(); |
| 64 | auto pid = stack->GetProperty(L"StackProcess")->GetValue<DWORD>(); |
| 65 | auto tid = stack->GetProperty(L"StackThread")->GetValue<DWORD>(); |
| 66 | SetDlgItemInt(IDC_PROCESS, pid); |
| 67 | SetDlgItemInt(IDC_THREAD, tid); |
| 68 | |
| 69 | m_List.InsertColumn(0, L"#", LVCFMT_LEFT, 45); |
| 70 | m_List.InsertColumn(1, L"Address", LVCFMT_RIGHT, 140); |
| 71 | m_List.InsertColumn(2, L"Symbol", LVCFMT_LEFT, 280); |
| 72 | m_List.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP); |
| 73 | |
| 74 | CImageList images; |
| 75 | images.Create(16, 16, ILC_COLOR32, 2, 0); |
| 76 | images.AddIcon(AtlLoadIconImage(IDI_K, 0, 16, 16)); |
| 77 | images.AddIcon(AtlLoadIconImage(IDI_U, 0, 16, 16)); |
| 78 | m_List.SetImageList(images, LVSIL_SMALL); |
| 79 | |
| 80 | SetDlgItemText(IDC_MESSAGE, L"Loading symbols..."); |
| 81 | |
| 82 | for (int i = 1; i <= 192; i++) { |
| 83 | num.Format(L"Stack%d", i); |
| 84 | auto prop = stack->GetProperty(num); |
| 85 | if (prop == nullptr) |
| 86 | break; |
| 87 | |
| 88 | DWORD64 address; |
| 89 | if (prop->GetLength() == 4) |
| 90 | address = prop->GetValue<DWORD>(); |
| 91 | else |
| 92 | address = prop->GetValue<DWORD64>(); |
| 93 | num.Format(L"%2d", i); |
| 94 | int n = m_List.InsertItem(i - 1, num, (int64_t)address < 0 ? 0 : 1); |
| 95 | num.Format(L"0x%p", (PVOID)address); |
| 96 | m_List.SetItemText(n, 1, num); |
| 97 | } |
| 98 | |
| 99 | // create thread to load symbols |
| 100 | m_hThread.reset(::CreateThread(nullptr, 0, [](auto param) { |
| 101 | return ((CCallStackDlg*)param)->LoadSymbolsThread(); |
| 102 | }, this, 0, nullptr)); |
| 103 | ::SetThreadPriority(m_hThread.get(), THREAD_PRIORITY_LOWEST); |
| 104 | return 0; |
nothing calls this directly
no test coverage detected