From 24559491f00ab5786f56aa0b3005ba7dabe92816 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Tue, 2 Jul 2013 23:21:20 +0200 Subject: [PATCH] Thread list in disassembly window --- CMakeLists.txt | 2 + Windows/Debugger/DebuggerShared.h | 1 + Windows/Debugger/Debugger_Disasm.cpp | 32 ++++- Windows/Debugger/Debugger_Disasm.h | 3 + Windows/Debugger/Debugger_Lists.cpp | 170 +++++++++++++++++++++++++++ Windows/Debugger/Debugger_Lists.h | 18 +++ Windows/PPSSPP.vcxproj | 2 + Windows/PPSSPP.vcxproj.filters | 6 + Windows/ppsspp.rc | Bin 43512 -> 43766 bytes Windows/resource.h | Bin 24744 -> 24832 bytes 10 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 Windows/Debugger/Debugger_Lists.cpp create mode 100644 Windows/Debugger/Debugger_Lists.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 13eb3d71b4..46dcc70081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1023,6 +1023,8 @@ if(WIN32) Windows/Debugger/Debugger_Disasm.h Windows/Debugger/Debugger_MemoryDlg.cpp Windows/Debugger/Debugger_MemoryDlg.h + Windows/Debugger/Debugger_Lists.cpp + Windows/Debugger/Debugger_Lists.h Windows/Debugger/Debugger_Misc.cpp Windows/Debugger/Debugger_Misc.h # Windows/Debugger/Debugger_Profiler.cpp diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h index 2445dfc920..97ff067275 100644 --- a/Windows/Debugger/DebuggerShared.h +++ b/Windows/Debugger/DebuggerShared.h @@ -3,6 +3,7 @@ #include "..\..\Core\Debugger\DebugInterface.h" enum { WM_DEB_RUNTOWPARAM = WM_USER+2, + WM_DEB_GOTOWPARAM, WM_DEB_GOTOBREAKPOINT, WM_DEB_REMOVEBREAKPOINT, WM_DEB_GOTOADDRESSEDIT, diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 9b08644e5c..2d581eab66 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -16,6 +16,7 @@ #include "../main.h" #include "CtrlRegisterList.h" #include "CtrlMemView.h" +#include "Debugger_Lists.h" #include "../../Core/Core.h" #include "../../Core/CPU.h" @@ -193,9 +194,14 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); mem->setDebugger(_cpu); + threadList = new CtrlThreadList(); + threadList->setDialogItem(GetDlgItem(m_hDlg,IDC_THREADLIST)); + threadList->reloadThreads(); + // init memory/breakpoint "tab" - ShowWindow(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), SW_NORMAL); - ShowWindow(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW), SW_HIDE); + ShowWindow(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), SW_HIDE); + ShowWindow(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW), SW_NORMAL); + ShowWindow(GetDlgItem(m_hDlg, IDC_THREADLIST), SW_HIDE); // Actually resize the window to the proper size (after the above setup.) if (w != -1 && h != -1) @@ -475,6 +481,9 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_BREAKPOINTLIST: handleBreakpointNotify(lParam); break; + case IDC_THREADLIST: + threadList->handleNotify(lParam); + break; } break; case WM_COMMAND: @@ -744,6 +753,13 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) Core_EnableStepping(false); break; } + case WM_DEB_GOTOWPARAM: + { + CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); + ptr->gotoAddr(wParam); + SetFocus(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); + break; + } case WM_DEB_GOTOBREAKPOINT: gotoBreakpointAddress(wParam); break; @@ -775,15 +791,24 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { HWND bp = GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST); HWND mem = GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW); + HWND threads = GetDlgItem(m_hDlg, IDC_THREADLIST); if (IsWindowVisible(bp)) + { + ShowWindow(bp,SW_HIDE); + ShowWindow(mem,SW_HIDE); + ShowWindow(threads,SW_NORMAL); + SetFocus(threads); + } else if (IsWindowVisible(threads)) { ShowWindow(bp,SW_HIDE); ShowWindow(mem,SW_NORMAL); + ShowWindow(threads,SW_HIDE); SetFocus(mem); } else { ShowWindow(bp,SW_NORMAL); ShowWindow(mem,SW_HIDE); + ShowWindow(threads,SW_HIDE); SetFocus(bp); } } @@ -821,6 +846,7 @@ void CDisasm::UpdateSize(WORD width, WORD height) HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST); HWND breakpointList = GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST); HWND memView = GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW); + HWND threads = GetDlgItem(m_hDlg, IDC_THREADLIST); int defaultHeight = defaultRect.bottom - defaultRect.top; int breakpointHeight = defaultBreakpointRect.bottom - defaultBreakpointRect.top; @@ -838,6 +864,7 @@ void CDisasm::UpdateSize(WORD width, WORD height) MoveWindow(disasm,regWidth+15,disasmTop,disasmWidth-20,height-disasmTop-breakpointHeight-12,TRUE); MoveWindow(breakpointList,8,breakpointTop,width-16,breakpointHeight,TRUE); MoveWindow(memView,8,breakpointTop,width-16,breakpointHeight,TRUE); + MoveWindow(threads,8,breakpointTop,width-16,breakpointHeight,TRUE); GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST),®Rect); GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW),&disRect); @@ -872,6 +899,7 @@ void CDisasm::SetDebugMode(bool _bDebug) Core_WaitInactive(TEMP_BREAKPOINT_WAIT_MS); CBreakPoints::ClearTemporaryBreakPoints(); updateBreakpointList(); + threadList->reloadThreads(); EnableWindow( GetDlgItem(hDlg, IDC_GO), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEP), TRUE); diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index 5646c213a2..163af28f47 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -17,6 +17,8 @@ // Takes lParam for debug mode, zero or non zero. const int WM_DISASM_SETDEBUG = WM_APP + 0; +class CtrlThreadList; + class CDisasm : public Dialog { private: @@ -29,6 +31,7 @@ private: DebugInterface *cpu; u64 lastTicks; + CtrlThreadList* threadList; std::vector displayedBreakPoints_; std::vector displayedMemChecks_; diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp new file mode 100644 index 0000000000..09919fb9d5 --- /dev/null +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -0,0 +1,170 @@ +#include "Debugger_Lists.h" +#include +#include +#include +#include "DebuggerShared.h" + +enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_STATE, TL_COLUMNCOUNT }; + +char* threadColumns[] = { + "Name", "PC", "Entry Point", "State" +}; + +const float threadColumnSizes[] = { + 0.25f, 0.25f, 0.25f, 0.25f +}; + +void CtrlThreadList::setDialogItem(HWND hwnd) +{ + wnd = hwnd; + + SetWindowLongPtr(wnd,GWLP_USERDATA,(LONG_PTR)this); + oldProc = (WNDPROC) SetWindowLongPtr(wnd,GWLP_WNDPROC,(LONG_PTR)wndProc); + + SendMessage(wnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); + + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.iSubItem = 0; + lvc.fmt = LVCFMT_LEFT; + + RECT rect; + GetWindowRect(wnd,&rect); + + int totalListSize = (rect.right-rect.left-20); + for (int i = 0; i < TL_COLUMNCOUNT; i++) + { + lvc.cx = threadColumnSizes[i] * totalListSize; + lvc.pszText = threadColumns[i]; + ListView_InsertColumn(wnd, i, &lvc); + } +} + +LRESULT CALLBACK CtrlThreadList::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CtrlThreadList* tl = (CtrlThreadList*) GetWindowLongPtr(hwnd,GWLP_USERDATA); + + switch (msg) + { + case WM_SIZE: + { + int width = LOWORD(lParam); + RECT rect; + GetWindowRect(hwnd,&rect); + + int totalListSize = (rect.right-rect.left-20); + for (int i = 0; i < TL_COLUMNCOUNT; i++) + { + ListView_SetColumnWidth(hwnd,i,threadColumnSizes[i] * totalListSize); + } + } + break; + case WM_KEYDOWN: + if (wParam == VK_TAB) + { + SendMessage(GetParent(hwnd),WM_DEB_TABPRESSED,0,0); + return 0; + } + break; + case WM_GETDLGCODE: + if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN) + { + if (wParam == VK_TAB) return DLGC_WANTMESSAGE; + } + break; + } + return (LRESULT)CallWindowProc((WNDPROC)tl->oldProc,hwnd,msg,wParam,lParam); +} + +void CtrlThreadList::handleNotify(LPARAM lParam) +{ + LPNMHDR mhdr = (LPNMHDR) lParam; + + if (mhdr->code == NM_DBLCLK) + { + LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam; + SendMessage(GetParent(wnd),WM_DEB_GOTOWPARAM,threads[item->iItem].curPC,0); + return; + } + + if (mhdr->code == LVN_GETDISPINFO) + { + NMLVDISPINFO* dispInfo = (NMLVDISPINFO*)lParam; + int index = dispInfo->item.iItem; + + stringBuffer[0] = 0; + switch (dispInfo->item.iSubItem) + { + case TL_NAME: + strcpy(stringBuffer,threads[index].name); + break; + case TL_PROGRAMCOUNTER: + sprintf(stringBuffer,"0x%08X",threads[index].curPC); + break; + case TL_ENTRYPOINT: + sprintf(stringBuffer,"0x%08X",threads[index].entrypoint); + break; + case TL_STATE: + switch (threads[index].status) + { + case THREADSTATUS_RUNNING: + strcpy(stringBuffer,"Running"); + break; + case THREADSTATUS_READY: + strcpy(stringBuffer,"Ready"); + break; + case THREADSTATUS_WAIT: + strcpy(stringBuffer,"Waiting"); + break; + case THREADSTATUS_SUSPEND: + strcpy(stringBuffer,"Suspended"); + break; + case THREADSTATUS_DORMANT: + strcpy(stringBuffer,"Dormant"); + break; + case THREADSTATUS_DEAD: + strcpy(stringBuffer,"Dead"); + break; + case THREADSTATUS_WAITSUSPEND: + strcpy(stringBuffer,"Waiting/Suspended"); + break; + default: + strcpy(stringBuffer,"Invalid"); + break; + } + break; + } + + if (stringBuffer[0] == 0) strcat(stringBuffer,"Invalid"); + dispInfo->item.pszText = stringBuffer; + } +} + +void CtrlThreadList::reloadThreads() +{ + threads = GetThreadsInfo(); + + int items = ListView_GetItemCount(wnd); + while (items < threads.size()) + { + LVITEM lvI; + lvI.pszText = LPSTR_TEXTCALLBACK; // Sends an LVN_GETDISPINFO message. + lvI.mask = LVIF_TEXT | LVIF_IMAGE |LVIF_STATE; + lvI.stateMask = 0; + lvI.iSubItem = 0; + lvI.state = 0; + lvI.iItem = items; + lvI.iImage = items; + + ListView_InsertItem(wnd, &lvI); + items++; + } + + while (items > threads.size()) + { + ListView_DeleteItem(wnd,--items); + } + + InvalidateRect(wnd,NULL,true); + UpdateWindow(wnd); +} diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h new file mode 100644 index 0000000000..875959df5e --- /dev/null +++ b/Windows/Debugger/Debugger_Lists.h @@ -0,0 +1,18 @@ +#pragma once + +#include "../../Core/Debugger/DebugInterface.h" +#include "../../Core/HLE/sceKernelThread.h" + +class CtrlThreadList +{ + HWND wnd; + WNDPROC oldProc; + std::vector threads; + char stringBuffer[256]; + +public: + void setDialogItem(HWND hwnd); + void reloadThreads(); + void handleNotify(LPARAM lParam); + static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +}; \ No newline at end of file diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index 6c9f49467c..409ad6cee0 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -266,6 +266,7 @@ + @@ -306,6 +307,7 @@ + diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 17c8355afb..fd5b5103a7 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -107,6 +107,9 @@ Windows\Debugger + + Windows\Debugger + @@ -191,6 +194,9 @@ Windows\Debugger + + Windows\Debugger + diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index b123d2e19cf14ced1c719eebf51031a5f884a7ac..31e05eb94e1ccc7443d98c2bf0b04a3b28326e38 100644 GIT binary patch delta 36 scmexynd#eArVVp+Cx=CAP5$M~$LYZk#Nf){$lx;BRA=wzIl3`50365-(f|Me delta 14 Wcmex%mFdT2rVVp+H_y_GsQ~~z+6QL< diff --git a/Windows/resource.h b/Windows/resource.h index f1aa0bbc71e26c9f839c0336d0e4ccf8d49628a5..836aa27a9141f05b041a193bd3f5311bd4a11e77 100644 GIT binary patch delta 54 zcmZ2+kg?$q;|3wk$$x?+HtT6xuuR?&BEcQP;K2~Y;L700;4(R%QFCGg%j65JEX?K% K7Ml}w-Hie63lJ>; delta 37 pcmZoT#JJ)h;|3wkiDn{`4=`~|meZBk?4+r{0^zf4zNV{X3;_2j3{U_7