From 41ed77f66a2c7ce773a257406f8745b4fc953c96 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Sun, 30 Jun 2013 13:42:19 +0200 Subject: [PATCH] Add a memory view control to the disassembly window --- CMakeLists.txt | 1 + Windows/Debugger/CtrlDisAsmView.cpp | 5 +- Windows/Debugger/CtrlMemView.cpp | 9 ++-- Windows/Debugger/DebuggerShared.h | 10 ++++ Windows/Debugger/Debugger_Disasm.cpp | 66 ++++++++++++++++++------ Windows/Debugger/Debugger_MemoryDlg.cpp | 7 +-- Windows/PPSSPP.vcxproj | 1 + Windows/PPSSPP.vcxproj.filters | 3 ++ Windows/ppsspp.rc | Bin 40462 -> 40606 bytes Windows/resource.h | Bin 23360 -> 23452 bytes 10 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 Windows/Debugger/DebuggerShared.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a8fecb0392..b5b92f7e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1011,6 +1011,7 @@ if(WIN32) Windows/Debugger/CtrlRegisterList.cpp Windows/Debugger/CtrlRegisterList.h Windows/Debugger/Debugger.h + Windows/Debugger/DebuggerShared.h Windows/Debugger/Debugger_Disasm.cpp Windows/Debugger/Debugger_Disasm.h Windows/Debugger/Debugger_MemoryDlg.cpp diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 988b622686..a8d4ba2b88 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -10,6 +10,7 @@ #include "CtrlDisAsmView.h" #include "Debugger_MemoryDlg.h" #include "ExpressionParser.h" +#include "DebuggerShared.h" #include "../../Core/Debugger/SymbolMap.h" #include "../../globals.h" #include "../main.h" @@ -562,7 +563,7 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam) case VK_F9: if (debugger->GetPC() != curAddress) { - SendMessage(GetParent(wnd),WM_USER+3,curAddress,0); + SendMessage(GetParent(wnd),WM_DEB_RUNTOWPARAM,curAddress,0); } break; case VK_F10: @@ -692,7 +693,7 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) { symbolMap.SetSymbolName(sym,newname); redraw(); - SendMessage(GetParent(wnd),WM_USER+1,0,0); + SendMessage(GetParent(wnd),WM_DEB_MAPLOADED,0,0); } } else diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 11c1be5489..06e4048921 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -13,7 +13,7 @@ #include "Debugger_Disasm.h" #include "ExpressionParser.h" - +#include "DebuggerShared.h" #include "CtrlMemView.h" TCHAR CtrlMemView::szClassName[] = _T("CtrlMemView"); @@ -143,7 +143,7 @@ LRESULT CALLBACK CtrlMemView::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ccp->redraw(); break; case WM_GETDLGCODE: // we want to process the arrow keys and all characters ourselves - return DLGC_WANTARROWS|DLGC_WANTCHARS; + return DLGC_WANTARROWS|DLGC_WANTCHARS|DLGC_WANTTAB; break; default: break; @@ -377,6 +377,9 @@ void CtrlMemView::onKeyDown(WPARAM wParam, LPARAM lParam) case VK_CONTROL: ctrlDown = true; break; + case VK_TAB: + SendMessage(GetParent(wnd),WM_DEB_TABPRESSED,0,0); + break; default: return; } @@ -384,7 +387,7 @@ void CtrlMemView::onKeyDown(WPARAM wParam, LPARAM lParam) void CtrlMemView::onChar(WPARAM wParam, LPARAM lParam) { - if (ctrlDown) return; + if (ctrlDown || wParam == VK_TAB) return; if (!Memory::IsValidAddress(curAddress)) { diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h new file mode 100644 index 0000000000..ae15ae024a --- /dev/null +++ b/Windows/Debugger/DebuggerShared.h @@ -0,0 +1,10 @@ +#pragma once +#include + +enum { WM_DEB_RUNTOWPARAM = WM_USER+2, + WM_DEB_GOTOBREAKPOINT, + WM_DEB_REMOVEBREAKPOINT, + WM_DEB_GOTOADDRESSEDIT, + WM_DEB_MAPLOADED, + WM_DEB_TABPRESSED +}; \ No newline at end of file diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 769ca7cbd0..21a8a61243 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -11,9 +11,11 @@ #include "Debugger_Disasm.h" #include "Debugger_VFPUDlg.h" #include "ExpressionParser.h" +#include "DebuggerShared.h" #include "../main.h" #include "CtrlRegisterList.h" +#include "CtrlMemView.h" #include "../../Core/Core.h" #include "../../Core/CPU.h" @@ -53,19 +55,28 @@ static LRESULT CALLBACK BreakpointListProc(HWND hDlg, UINT message, WPARAM wPara if(wParam == VK_RETURN) { int index = ListView_GetSelectionMark(hDlg); - SendMessage(GetParent(hDlg),WM_USER+4,index,0); + SendMessage(GetParent(hDlg),WM_DEB_GOTOBREAKPOINT,index,0); return 0; } else if (wParam == VK_DELETE) { int index = ListView_GetSelectionMark(hDlg); - SendMessage(GetParent(hDlg),WM_USER+5,index,0); + SendMessage(GetParent(hDlg),WM_DEB_REMOVEBREAKPOINT,index,0); + return 0; + } else if (wParam == VK_TAB) + { + SendMessage(GetParent(hDlg),WM_DEB_TABPRESSED,0,0); return 0; } - default: - return (LRESULT)CallWindowProc((WNDPROC)DefBreakpointListProc,hDlg,message,wParam,lParam); + break; + case WM_GETDLGCODE: + if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN) + { + if (wParam == VK_TAB) return DLGC_WANTMESSAGE; + } + break; }; - return 0; + return (LRESULT)CallWindowProc((WNDPROC)DefBreakpointListProc,hDlg,message,wParam,lParam);; } @@ -79,7 +90,7 @@ LRESULT CALLBACK GotoEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa case WM_KEYDOWN: if( wParam == VK_RETURN ) { - SendMessage(GetParent(hDlg),WM_USER+6,0,0); + SendMessage(GetParent(hDlg),WM_DEB_GOTOADDRESSEDIT,0,0); return 0; } break; @@ -178,6 +189,14 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di ListView_InsertColumn(breakpointHwnd, i, &lvc); } + // init memory viewer + CtrlMemView *mem = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_DEBUGMEMVIEW)); + mem->setDebugger(_cpu); + + // init memory/breakpoint "tab" + ShowWindow(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST), SW_NORMAL); + ShowWindow(GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW), SW_HIDE); + // Actually resize the window to the proper size (after the above setup.) if (w != -1 && h != -1) { @@ -713,10 +732,10 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) return TRUE; } - case WM_USER+1: + case WM_DEB_MAPLOADED: NotifyMapLoaded(); break; - case WM_USER+3: // run to wparam + case WM_DEB_RUNTOWPARAM: { lastTicks = CoreTiming::GetTicks(); CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); @@ -727,13 +746,13 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) Core_EnableStepping(false); break; } - case WM_USER+4: + case WM_DEB_GOTOBREAKPOINT: gotoBreakpointAddress(wParam); break; - case WM_USER+5: + case WM_DEB_REMOVEBREAKPOINT: removeBreakpoint(wParam); break; - case WM_USER+6: // goto edit + case WM_DEB_GOTOADDRESSEDIT: { char szBuffer[256]; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); @@ -754,7 +773,23 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_DISASM_SETDEBUG: SetDebugMode(lParam != 0); return TRUE; - + case WM_DEB_TABPRESSED: + { + HWND bp = GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST); + HWND mem = GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW); + + if (IsWindowVisible(bp)) + { + ShowWindow(bp,SW_HIDE); + ShowWindow(mem,SW_NORMAL); + SetFocus(mem); + } else { + ShowWindow(bp,SW_NORMAL); + ShowWindow(mem,SW_HIDE); + SetFocus(bp); + } + } + break; case WM_SIZE: { UpdateSize(LOWORD(lParam), HIWORD(lParam)); @@ -765,7 +800,6 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_MOVE: SavePosition(); break; - case WM_GETMINMAXINFO: { MINMAXINFO *m = (MINMAXINFO *)lParam; @@ -788,7 +822,8 @@ void CDisasm::UpdateSize(WORD width, WORD height) HWND funclist = GetDlgItem(m_hDlg, IDC_FUNCTIONLIST); HWND regList = GetDlgItem(m_hDlg, IDC_REGLIST); HWND breakpointList = GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST); - + HWND memView = GetDlgItem(m_hDlg, IDC_DEBUGMEMVIEW); + int defaultHeight = defaultRect.bottom - defaultRect.top; int breakpointHeight = defaultBreakpointRect.bottom - defaultBreakpointRect.top; if (height < defaultHeight) @@ -804,7 +839,8 @@ void CDisasm::UpdateSize(WORD width, WORD height) MoveWindow(funclist, 8, regTop, regWidth, height-regTop-breakpointHeight-12, TRUE); 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); + GetWindowRect(GetDlgItem(m_hDlg, IDC_REGLIST),®Rect); GetWindowRect(GetDlgItem(m_hDlg, IDC_DISASMVIEW),&disRect); GetWindowRect(GetDlgItem(m_hDlg, IDC_BREAKPOINTLIST),&breakpointRect); diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index 87a24bacc7..2152dc593b 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -9,6 +9,7 @@ #include "CtrlMemView.h" #include "ExpressionParser.h" +#include "DebuggerShared.h" #include "../../Core/MIPS/MIPSDebugInterface.h" // BAD @@ -24,7 +25,7 @@ LRESULT CALLBACK AddressEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM case WM_KEYDOWN: if( wParam == VK_RETURN ) { - SendMessage(AddressEditParentHwnd,WM_USER+2,0,0); + SendMessage(AddressEditParentHwnd,WM_DEB_GOTOADDRESSEDIT,0,0); return 0; } case WM_KEYUP: @@ -158,10 +159,10 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) } } break; - case WM_USER+1: + case WM_DEB_MAPLOADED: NotifyMapLoaded(); break; - case WM_USER+2: // enter hit on address edit + case WM_DEB_GOTOADDRESSEDIT: { CtrlMemView *mv = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_MEMVIEW)); char temp[256]; diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index 4bd085fae5..10a5e5b035 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -302,6 +302,7 @@ + diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 2476f41936..e04ddd1a69 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -185,6 +185,9 @@ Windows\Debugger + + Windows\Debugger + diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 6959deb398e796dc6c0fb76e1657356bba6ccf9e..f93f00d2b1d7b0780ead910fbee56b68ac71b22b 100644 GIT binary patch delta 54 zcmeC%!!&O%(}oK=lV9n`O@5-OHQ7s(N8E@(i9v_Klfi|-nIRrXx-vL1gfh5KF0`=U J{7Ofq5CH1b5B~rF delta 22 ecmbQYm#J?L(}oK=lN~JOCSTE!+B`#-tq=flV+kAp diff --git a/Windows/resource.h b/Windows/resource.h index 2fec8b9738317c2bc69bfc9e9ba53f8b69e52565..2c9258efa24821074c66391d3a7fd58a8c962b15 100644 GIT binary patch delta 39 xcmV+?0NDS)wgH^C0kBvolL#ajlQ0(wlVBb$lh6eQ0X2~^8I!;Q1ha4`&@vDb4I2Oe delta 21 dcmbQUo$A7EnHd`9Df5ddU92-yGt