From 880be6d41dab6af5de5c5814d2b63f0d2cb3b9e5 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Mon, 27 Jan 2014 00:35:16 +0100 Subject: [PATCH] Module list in Windows debugger --- Core/Debugger/SymbolMap.cpp | 19 +++++++ Core/Debugger/SymbolMap.h | 8 +++ Windows/Debugger/Debugger_Disasm.cpp | 8 +++ Windows/Debugger/Debugger_Disasm.h | 1 + Windows/Debugger/Debugger_Lists.cpp | 79 ++++++++++++++++++++++++++++ Windows/Debugger/Debugger_Lists.h | 16 ++++++ Windows/ppsspp.rc | 1 + Windows/resource.h | 1 + 8 files changed, 133 insertions(+) diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index a5c4ada040..9af74a11e8 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -463,6 +463,25 @@ bool SymbolMap::IsModuleActive(int moduleIndex) const { return false; } +std::vector SymbolMap::getAllModules() const { + lock_guard guard(lock_); + + std::vector result; + for (size_t i = 0; i < modules.size(); i++) { + LoadedModuleInfo m; + m.name = modules[i].name; + m.address = modules[i].start; + m.size = modules[i].size; + + u32 key = modules[i].start + modules[i].size; + m.active = activeModuleEnds.find(key) != activeModuleEnds.end(); + + result.push_back(m); + } + + return result; +} + void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleIndex) { lock_guard guard(lock_); diff --git a/Core/Debugger/SymbolMap.h b/Core/Debugger/SymbolMap.h index 0b7825b356..71122a1bb6 100644 --- a/Core/Debugger/SymbolMap.h +++ b/Core/Debugger/SymbolMap.h @@ -45,6 +45,13 @@ struct SymbolEntry { u32 size; }; +struct LoadedModuleInfo { + std::string name; + u32 address; + u32 size; + bool active; +}; + enum DataType { DATATYPE_NONE, DATATYPE_BYTE, DATATYPE_HALFWORD, DATATYPE_WORD, DATATYPE_ASCII }; @@ -80,6 +87,7 @@ public: u32 GetModuleAbsoluteAddr(u32 relative, int moduleIndex) const; int GetModuleIndex(u32 address) const; bool IsModuleActive(int moduleIndex) const; + std::vector getAllModules() const; void AddFunction(const char* name, u32 address, u32 size, int moduleIndex = -1); u32 GetFunctionStart(u32 address) const; diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 949673ae57..20fa90c0ab 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -163,6 +163,10 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di stackTraceView->loadStackTrace(); bottomTabs->AddTab(stackTraceView->GetHandle(),L"Stack frames"); + moduleList = new CtrlModuleList(GetDlgItem(m_hDlg,IDC_MODULELIST),cpu); + moduleList->loadModules(); + bottomTabs->AddTab(moduleList->GetHandle(),L"Modules"); + bottomTabs->SetShowTabTitles(g_Config.bShowBottomTabTitles); bottomTabs->ShowTab(memHandle); @@ -367,6 +371,9 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_STACKFRAMES: stackTraceView->HandleNotify(lParam); break; + case IDC_MODULELIST: + moduleList->HandleNotify(lParam); + break; case IDC_DEBUG_BOTTOMTABS: bottomTabs->HandleNotify(lParam); break; @@ -775,6 +782,7 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC) breakpointList->reloadBreakpoints(); threadList->reloadThreads(); stackTraceView->loadStackTrace(); + moduleList->loadModules(); updateThreadLabel(false); SetDlgItemText(m_hDlg, IDC_STOPGO, L"Go"); diff --git a/Windows/Debugger/Debugger_Disasm.h b/Windows/Debugger/Debugger_Disasm.h index a013443953..647f583a59 100644 --- a/Windows/Debugger/Debugger_Disasm.h +++ b/Windows/Debugger/Debugger_Disasm.h @@ -26,6 +26,7 @@ private: CtrlBreakpointList* breakpointList; CtrlThreadList* threadList; CtrlStackTraceView* stackTraceView; + CtrlModuleList* moduleList; TabControl* leftTabs; TabControl* bottomTabs; std::vector displayedBreakPoints_; diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index f20279220b..9f5cb18e9d 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -15,6 +15,7 @@ static const int numCPUs = 1; enum { TL_NAME, TL_PROGRAMCOUNTER, TL_ENTRYPOINT, TL_PRIORITY, TL_STATE, TL_WAITTYPE, TL_COLUMNCOUNT }; enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_ENABLED, BPL_COLUMNCOUNT }; enum { SF_ENTRY, SF_ENTRYNAME, SF_CURPC, SF_CUROPCODE, SF_CURSP, SF_FRAMESIZE, SF_COLUMNCOUNT }; +enum { ML_NAME, ML_ADDRESS, ML_SIZE, ML_ACTIVE, ML_COLUMNCOUNT }; GenericListViewColumn threadColumns[TL_COLUMNCOUNT] = { { L"Name", 0.20f }, @@ -44,6 +45,13 @@ GenericListViewColumn stackTraceColumns[SF_COLUMNCOUNT] = { { L"Frame Size", 0.12f } }; +GenericListViewColumn moduleListColumns[ML_COLUMNCOUNT] = { + { L"Name", 0.25f }, + { L"Address", 0.25f }, + { L"Size", 0.25f }, + { L"Active", 0.25f }, +}; + const int POPUP_SUBMENU_ID_BREAKPOINTLIST = 5; const int POPUP_SUBMENU_ID_THREADLIST = 6; const int POPUP_SUBMENU_ID_NEWBREAKPOINT = 7; @@ -695,3 +703,74 @@ void CtrlStackTraceView::loadStackTrace() } Update(); } + +// +// CtrlModuleList +// + +CtrlModuleList::CtrlModuleList(HWND hwnd, DebugInterface* cpu) + : GenericListControl(hwnd,moduleListColumns,ML_COLUMNCOUNT),cpu(cpu) +{ + Update(); +} + +bool CtrlModuleList::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) +{ + switch(msg) + { + case WM_KEYDOWN: + if (wParam == VK_TAB) + { + returnValue = 0; + SendMessage(GetParent(GetHandle()),WM_DEB_TABPRESSED,0,0); + return true; + } + break; + case WM_GETDLGCODE: + if (lParam && ((MSG*)lParam)->message == WM_KEYDOWN) + { + if (wParam == VK_TAB || wParam == VK_RETURN) + { + returnValue = DLGC_WANTMESSAGE; + return true; + } + } + break; + } + + return false; +} + +void CtrlModuleList::GetColumnText(wchar_t* dest, int row, int col) +{ + if (row < 0 || row >= (int)modules.size()) { + return; + } + + switch (col) + { + case ML_NAME: + wcscpy(dest,ConvertUTF8ToWString(modules[row].name).c_str()); + break; + case ML_ADDRESS: + wsprintf(dest,L"%08X",modules[row].address); + break; + case ML_SIZE: + wsprintf(dest,L"%08X",modules[row].size); + break; + case ML_ACTIVE: + wcscpy(dest,modules[row].active ? L"true" : L"false"); + break; + } +} + +void CtrlModuleList::OnDoubleClick(int itemIndex, int column) +{ + SendMessage(GetParent(GetHandle()),WM_DEB_GOTOWPARAM,modules[itemIndex].address,0); +} + +void CtrlModuleList::loadModules() +{ + modules = symbolMap.getAllModules(); + Update(); +} diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h index 9b6ed5848b..3480e3b88b 100644 --- a/Windows/Debugger/Debugger_Lists.h +++ b/Windows/Debugger/Debugger_Lists.h @@ -3,6 +3,7 @@ #include "../../Core/Debugger/DebugInterface.h" #include "../../Core/HLE/sceKernelThread.h" #include "../../Core/Debugger/Breakpoints.h" +#include "../../Core/Debugger/SymbolMap.h" #include "../../Core/MIPS/MIPSStackWalk.h" #include "Windows/W32Util/Misc.h" @@ -67,4 +68,19 @@ private: std::vector frames; DebugInterface* cpu; CtrlDisAsmView* disasm; +}; + +class CtrlModuleList: public GenericListControl +{ +public: + CtrlModuleList(HWND hwnd, DebugInterface* cpu); + void loadModules(); +protected: + virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue); + virtual void GetColumnText(wchar_t* dest, int row, int col); + virtual int GetRowCount() { return (int)modules.size(); }; + virtual void OnDoubleClick(int itemIndex, int column); +private: + std::vector modules; + DebugInterface* cpu; }; \ No newline at end of file diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index c241147828..dc5756f8bb 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -162,6 +162,7 @@ BEGIN CONTROL "Custom2",IDC_DEBUGMEMVIEW,"CtrlMemView",WS_BORDER,1,338,513,93 CONTROL "",IDC_THREADLIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93 CONTROL "",IDC_STACKFRAMES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93 + CONTROL "",IDC_MODULELIST,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER,1,338,513,93 CONTROL "",IDC_DEBUG_BOTTOMTABS,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER,1,338,513,93 END diff --git a/Windows/resource.h b/Windows/resource.h index 6ac2a93f52..fbf7219045 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -300,6 +300,7 @@ #define ID_EMULATION_SWITCH_UMD 40144 #define ID_DEBUG_EXTRACTFILE 40145 #define ID_OPTIONS_IGNOREWINKEY 40146 +#define IDC_MODULELIST 40147 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500