From 9d50579aa9ff09e7cca2936fa8b0a3cd51db0f31 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 7 Jul 2013 23:47:22 -0700 Subject: [PATCH] Add a context menu to play with threads. --- Windows/Debugger/DebuggerShared.h | 2 + Windows/Debugger/Debugger_Disasm.cpp | 4 +- Windows/Debugger/Debugger_Lists.cpp | 58 ++++++++++++++++++++++++++- Windows/Debugger/Debugger_Lists.h | 1 + Windows/ppsspp.rc | Bin 38588 -> 38926 bytes Windows/resource.h | Bin 25018 -> 25206 bytes 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h index be55ec8eb8..b0d1ba6b36 100644 --- a/Windows/Debugger/DebuggerShared.h +++ b/Windows/Debugger/DebuggerShared.h @@ -2,6 +2,8 @@ #include #include "..\..\Core\Debugger\DebugInterface.h" +extern HMENU g_hPopupMenus; + enum { WM_DEB_RUNTOWPARAM = WM_USER+2, WM_DEB_GOTOWPARAM, WM_DEB_GOTOBREAKPOINT, diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index a8952c3906..054f433c7e 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -354,9 +354,9 @@ void CDisasm::showBreakpointMenu(int itemIndex, const POINT &pt) HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_BREAKPOINTLIST); if (isMemory) { - CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED)); } else { - CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED)); } switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index b328353b37..cc1d1f649c 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -3,6 +3,7 @@ #include #include #include "DebuggerShared.h" +#include "Windows/resource.h" enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT }; @@ -14,6 +15,8 @@ const float threadColumnSizes[] = { 0.20f, 0.15f, 0.15f, 0.15f, 0.15f, 0.20f }; +const int POPUP_SUBMENU_ID_THREADLIST = 6; + void CtrlThreadList::setDialogItem(HWND hwnd) { wnd = hwnd; @@ -76,6 +79,51 @@ LRESULT CALLBACK CtrlThreadList::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA return (LRESULT)CallWindowProc((WNDPROC)tl->oldProc,hwnd,msg,wParam,lParam); } +void CtrlThreadList::showMenu(int itemIndex, const POINT &pt) +{ + auto threadInfo = threads[itemIndex]; + + // Can't do it, sorry. Needs to not be running. + if (Core_IsActive()) + return; + + POINT screenPt(pt); + ClientToScreen(wnd, &screenPt); + + HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_THREADLIST); + switch (threadInfo.status) { + case THREADSTATUS_DEAD: + case THREADSTATUS_DORMANT: + case THREADSTATUS_RUNNING: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_DISABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_DISABLED); + break; + case THREADSTATUS_READY: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_DISABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_ENABLED); + break; + case THREADSTATUS_SUSPEND: + case THREADSTATUS_WAIT: + case THREADSTATUS_WAITSUSPEND: + default: + EnableMenuItem(subMenu, ID_DISASM_THREAD_FORCERUN, MF_BYCOMMAND | MF_ENABLED); + EnableMenuItem(subMenu, ID_DISASM_THREAD_KILL, MF_BYCOMMAND | MF_ENABLED); + break; + } + + switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) + { + case ID_DISASM_THREAD_FORCERUN: + __KernelResumeThreadFromWait(threadInfo.id, 0); + reloadThreads(); + break; + case ID_DISASM_THREAD_KILL: + sceKernelTerminateThread(threadInfo.id); + reloadThreads(); + break; + } +} + void CtrlThreadList::handleNotify(LPARAM lParam) { LPNMHDR mhdr = (LPNMHDR) lParam; @@ -99,6 +147,12 @@ void CtrlThreadList::handleNotify(LPARAM lParam) SendMessage(GetParent(wnd),WM_DEB_GOTOWPARAM,address,0); return; } + if (mhdr->code == NM_RCLICK) + { + const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam; + showMenu(item->iItem, item->ptAction); + return; + } if (mhdr->code == LVN_GETDISPINFO) { @@ -188,7 +242,7 @@ void CtrlThreadList::reloadThreads() items++; } - while (items > threads.size()) + while (items > (int)threads.size()) { ListView_DeleteItem(wnd,--items); } @@ -199,7 +253,7 @@ void CtrlThreadList::reloadThreads() const char* CtrlThreadList::getCurrentThreadName() { - for (int i = 0; i < threads.size(); i++) + for (size_t i = 0; i < threads.size(); i++) { if (threads[i].isCurrent) return threads[i].name; } diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h index ac8ffd5afb..b9260604c9 100644 --- a/Windows/Debugger/Debugger_Lists.h +++ b/Windows/Debugger/Debugger_Lists.h @@ -14,6 +14,7 @@ public: void setDialogItem(HWND hwnd); void reloadThreads(); void handleNotify(LPARAM lParam); + void showMenu(int itemIndex, const POINT &pt); static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); const char* getCurrentThreadName(); }; \ No newline at end of file diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 28e751a457f945a0b7df57ea69f019b70b23c8c1..359fa3106b569ca56ab875c5bdd1de30f3d88568 100644 GIT binary patch delta 174 zcmdn9mZ@(8(}t4ClV?m4;4WdvU?^fpWk_U5nY??FxwsocK9HXb6j5MMV+aD$#SEnk zxsx9jYERDV;ZqD@@BoUsGB`50FvK&sG57;{&Om+;LnwnE11|&Don4Gk8vBl$8d_Gg~s4PBfI9e1M5#vsnBIMn<#AjS0Gwc@ozF0IIMa AnE(I) delta 22 ecmex%gmKql#tpyXHgAi6!Z>*or`Y5TiN^qrWDC6j