From 73944b26360b3f2125a2accc26d398a73c0eb429 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 18 Jan 2018 17:53:07 +1100 Subject: [PATCH] [Debugger] clean up warnings and code --- .../UserInterface/Debugger/DebugDialog.h | 10 ++-- .../Debugger/Debugger-AddSymbol.cpp | 2 +- .../Debugger/Debugger-Commands.cpp | 25 ++++----- .../Debugger/Debugger-Commands.h | 6 +-- .../Debugger/Debugger-DMALogView.cpp | 10 ++-- .../Debugger/Debugger-Scripts.cpp | 9 ++-- .../Debugger/Debugger-StackTrace.cpp | 2 +- .../UserInterface/Debugger/ScriptInstance.cpp | 7 ++- .../UserInterface/Debugger/Symbols.cpp | 8 +-- .../UserInterface/Debugger/debugger.h | 52 ++++++++++--------- 10 files changed, 63 insertions(+), 68 deletions(-) diff --git a/Source/Project64/UserInterface/Debugger/DebugDialog.h b/Source/Project64/UserInterface/Debugger/DebugDialog.h index 9a5330b5a..8db11d30a 100644 --- a/Source/Project64/UserInterface/Debugger/DebugDialog.h +++ b/Source/Project64/UserInterface/Debugger/DebugDialog.h @@ -60,11 +60,7 @@ public: void ShowWindow(void) { - if (m_hWnd) - { - SetForegroundWindow((HWND)m_hWnd); - } - else + if (m_hWnd == NULL) { DWORD ThreadID; ResetEvent(m_CreatedEvent); @@ -74,5 +70,9 @@ public: WriteTrace(TraceUserInterface, TraceError, "Failed to get window create notification"); } } + if (m_hWnd) + { + SetForegroundWindow((HWND)m_hWnd); + } } }; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp b/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp index c57fad400..798b7a64a 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-AddSymbol.cpp @@ -56,7 +56,7 @@ LRESULT CAddSymbolDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*l return FALSE; } -LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& bHandled) +LRESULT CAddSymbolDlg::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { switch (wID) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index fc48609f1..38ee9ced3 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -497,7 +497,7 @@ const char* CDebugCommandsView::GetCodeAddressNotes(uint32_t vAddr) return NULL; } -void CDebugCommandsView::ShowAddress(DWORD address, BOOL top) +void CDebugCommandsView::ShowAddress(uint32_t address, bool top) { if (top == TRUE) { @@ -710,25 +710,20 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) NMLVCUSTOMDRAW* pLVCD = reinterpret_cast(pNMHDR); DWORD drawStage = pLVCD->nmcd.dwDrawStage; - HDC hDC = pLVCD->nmcd.hdc; - switch (drawStage) { - case CDDS_PREPAINT: - return (CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT); + case CDDS_PREPAINT: return (CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT); + case CDDS_ITEMPREPAINT: return CDRF_NOTIFYSUBITEMDRAW; + case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): break; case CDDS_POSTPAINT: - DrawBranchArrows(hDC); + DrawBranchArrows(pLVCD->nmcd.hdc); return CDRF_DODEFAULT; - case CDDS_ITEMPREPAINT: - return CDRF_NOTIFYSUBITEMDRAW; - case (CDDS_ITEMPREPAINT | CDDS_SUBITEM): - break; default: return CDRF_DODEFAULT; } - DWORD nItem = pLVCD->nmcd.dwItemSpec; - DWORD nSubItem = pLVCD->iSubItem; + uint32_t nItem = (uint32_t)pLVCD->nmcd.dwItemSpec; + uint32_t nSubItem = pLVCD->iSubItem; uint32_t address = m_StartAddress + (nItem * 4); uint32_t pc = (g_Reg != NULL) ? g_Reg->m_PROGRAM_COUNTER : 0; @@ -756,7 +751,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) { // breakpoint pLVCD->clrTextBk = RGB(0x44, 0x00, 0x00); - pLVCD->clrText = (address == pc) ? + pLVCD->clrText = (address == pc && isDebugging()) ? RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xCC, 0xCC); } @@ -764,7 +759,7 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) { // breakpoint pLVCD->clrTextBk = RGB(0x66, 0x44, 0x00); - pLVCD->clrText = (address == pc) ? + pLVCD->clrText = (address == pc && isDebugging()) ? RGB(0xFF, 0xFF, 0x00) : // breakpoint & current pc RGB(0xFF, 0xEE, 0xCC); } @@ -780,7 +775,6 @@ LRESULT CDebugCommandsView::OnCustomDrawList(NMHDR* pNMHDR) pLVCD->clrTextBk = RGB(0xEE, 0xEE, 0xEE); pLVCD->clrText = RGB(0x44, 0x44, 0x44); } - return CDRF_DODEFAULT; } @@ -1562,7 +1556,6 @@ void CDebugCommandsView::SteppingOpsChanged(void) } } - void CDebugCommandsView::Reset() { ClearEditedOps(); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h index 9763a8f0d..bb465df20 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.h @@ -81,7 +81,7 @@ public: CDebugCommandsView(CDebuggerUI * debugger, SyncEvent &StepEvent); virtual ~CDebugCommandsView(void); - void ShowAddress(DWORD address, BOOL top); + void ShowAddress(uint32_t address, bool top); void ShowPIRegTab(); void Reset(); @@ -125,7 +125,7 @@ private: NOTIFY_HANDLER_EX(IDC_CMD_LIST, NM_CUSTOMDRAW, OnCustomDrawList) MSG_WM_DESTROY(OnDestroy) CHAIN_MSG_MAP(CDialogResize) - END_MSG_MAP() + END_MSG_MAP() BEGIN_DLGRESIZE_MAP(CDebugCommandsView) DLGRESIZE_CONTROL(IDC_GO_BTN, DLSZ_MOVE_X) @@ -246,7 +246,7 @@ private: CAddBreakpointDlg m_AddBreakpointDlg; CAddSymbolDlg m_AddSymbolDlg; - DWORD m_StartAddress; + uint32_t m_StartAddress; CRect m_DefaultWindowRect; CEditNumber32 m_PCEdit; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp index 4db1e664e..1c379d1e0 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-DMALogView.cpp @@ -62,7 +62,7 @@ void CDebugDMALogView::RefreshList() bool bScrolledDown = false; - if ((scroll.nPage + scroll.nPos) - 1 == scroll.nMax) + if ((scroll.nPage + scroll.nPos) - 1 == (uint32_t)scroll.nMax) { bScrolledDown = true; } @@ -136,13 +136,13 @@ DWORD WINAPI CDebugDMALogView::AutoRefreshProc(void* _this) } } -LRESULT CDebugDMALogView::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CDebugDMALogView::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { //RefreshList(); return FALSE; } -LRESULT CDebugDMALogView::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CDebugDMALogView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { DlgResize_Init(false, true); @@ -213,7 +213,7 @@ LRESULT CDebugDMALogView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& return FALSE; } -LRESULT CDebugDMALogView::OnRamAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +LRESULT CDebugDMALogView::OnRamAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (m_bConvertingAddress) { @@ -247,7 +247,7 @@ LRESULT CDebugDMALogView::OnRamAddrChanged(WORD wNotifyCode, WORD wID, HWND hWnd return FALSE; } -LRESULT CDebugDMALogView::OnRomAddrChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +LRESULT CDebugDMALogView::OnRomAddrChanged(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (m_bConvertingAddress) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp index 52c7c7718..9958c84c7 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp @@ -27,7 +27,7 @@ CDebugScripts::~CDebugScripts(void) free(m_SelectedScriptName); } -LRESULT CDebugScripts::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CDebugScripts::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { DlgResize_Init(false, true); @@ -63,7 +63,6 @@ LRESULT CDebugScripts::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOO void CDebugScripts::ConsolePrint(const char* text) { ::ShowWindow(*this, SW_SHOWNOACTIVATE); - int textPos = m_ConsoleEdit.GetWindowTextLengthA(); // Get scrollbar state SCROLLINFO scroll; @@ -77,7 +76,7 @@ void CDebugScripts::ConsolePrint(const char* text) m_ConsoleEdit.SetRedraw(TRUE); - if ((scroll.nPage + scroll.nPos) - 1 == scroll.nMax) + if ((scroll.nPage + scroll.nPos) - 1 == (uint32_t)scroll.nMax) { m_ConsoleEdit.ScrollCaret(); } @@ -119,7 +118,7 @@ void CDebugScripts::ConsoleCopy() m_ConsoleEdit.GetWindowTextA(memBuf, nChars); GlobalUnlock(hMem); - HANDLE hRes = SetClipboardData(CF_TEXT, hMem); + SetClipboardData(CF_TEXT, hMem); GlobalFree(hMem); CloseClipboard(); @@ -304,7 +303,7 @@ void CDebugScripts::EvaluateInSelectedInstance(char* code) } // Console input -LRESULT CEditEval::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CEditEval::OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if (wParam == VK_UP) { diff --git a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp index bacc9e33d..530f3fafe 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-StackTrace.cpp @@ -66,7 +66,7 @@ LRESULT CDebugStackTrace::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM return TRUE; } -LRESULT CDebugStackTrace::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +LRESULT CDebugStackTrace::OnActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { Refresh(); return FALSE; diff --git a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp index 2956d9bdc..2190e67e2 100644 --- a/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp +++ b/Source/Project64/UserInterface/Debugger/ScriptInstance.cpp @@ -36,6 +36,7 @@ CScriptInstance* CScriptInstance::FetchInstance(duk_context* ctx) return Cache[i]; } } + return NULL; } CScriptInstance::CScriptInstance(CDebuggerUI* debugger) @@ -1374,14 +1375,12 @@ duk_ret_t CScriptInstance::js_ConsolePrint(duk_context* ctx) duk_ret_t CScriptInstance::js_ConsoleClear(duk_context* ctx) { - CScriptInstance* _this = FetchInstance(ctx); - _this->m_Debugger->Debug_ClearScriptsWindow(); + FetchInstance(ctx)->m_Debugger->Debug_ClearScriptsWindow(); return 1; } -duk_ret_t CScriptInstance::js_Pause(duk_context* ctx) +duk_ret_t CScriptInstance::js_Pause(duk_context* /*ctx*/) { - CScriptInstance* _this = FetchInstance(ctx); g_System->Pause(); return 1; } diff --git a/Source/Project64/UserInterface/Debugger/Symbols.cpp b/Source/Project64/UserInterface/Debugger/Symbols.cpp index 024b550dd..a99c2e0fe 100644 --- a/Source/Project64/UserInterface/Debugger/Symbols.cpp +++ b/Source/Project64/UserInterface/Debugger/Symbols.cpp @@ -145,7 +145,7 @@ void CSymbols::Load() } char* endptr; - address = strtoull(m_ParserToken, &endptr, 16); + address = (uint32_t)strtoull(m_ParserToken, &endptr, 16); if (endptr == m_ParserToken) { @@ -304,7 +304,7 @@ void CSymbols::GetValueString(char* dest, CSymbolEntry* lpSymbol) break; case TYPE_U64: g_MMU->LD_VAddr(address, v64); - sprintf(dest, "%ull", v64); + sprintf(dest, "%I64u", v64); break; case TYPE_S8: g_MMU->LB_VAddr(address, v8); @@ -320,7 +320,7 @@ void CSymbols::GetValueString(char* dest, CSymbolEntry* lpSymbol) break; case TYPE_S64: g_MMU->LD_VAddr(address, v64); - sprintf(dest, "%ill", v64); + sprintf(dest, "%I64i", v64); break; case TYPE_FLOAT: g_MMU->LW_VAddr(address, *(uint32_t*)&vf); @@ -353,7 +353,7 @@ void CSymbols::Reset() const char* CSymbols::GetNameByAddress(uint32_t address) { - int len = GetCount(); + uint32_t len = GetCount(); for (uint32_t i = 0; i < len; i++) { if (m_Symbols[i]->m_Address == address) diff --git a/Source/Project64/UserInterface/Debugger/debugger.h b/Source/Project64/UserInterface/Debugger/debugger.h index 59438f8c5..730b7a901 100644 --- a/Source/Project64/UserInterface/Debugger/debugger.h +++ b/Source/Project64/UserInterface/Debugger/debugger.h @@ -36,30 +36,6 @@ public: CDebuggerUI(); ~CDebuggerUI(); -private: - CDumpMemory * m_MemoryDump; - CDebugMemoryView * m_MemoryView; - CDebugMemorySearch * m_MemorySearch; - CDebugTlb * m_DebugTLB; - CDebugCommandsView * m_CommandsView; - CDebugScripts * m_Scripts; - CDebugSymbols * m_Symbols; - CDebugDMALogView * m_DMALogView; - CDebugStackTrace * m_StackTrace; - CDebugStackView * m_StackView; - - CBreakpoints * m_Breakpoints; - CScriptSystem * m_ScriptSystem; - CDMALog * m_DMALog; - - SyncEvent m_StepEvent; - -protected: - void TLBChanged(void); - void CPUStepStarted(void); - void CPUStep(void); - void FrameDrawn(void); - public: void Debug_Reset(void); void OpenMemoryDump(void); @@ -92,4 +68,32 @@ public: CDMALog* DMALog(); static void GameReset(CDebuggerUI * _this); + +protected: + void TLBChanged(void); + void CPUStepStarted(void); + void CPUStep(void); + void FrameDrawn(void); + +private: + CDebuggerUI(const CDebuggerUI&); // Disable copy constructor + CDebuggerUI& operator=(const CDebuggerUI&); // Disable assignment + + CDumpMemory * m_MemoryDump; + CDebugMemoryView * m_MemoryView; + CDebugMemorySearch * m_MemorySearch; + CDebugTlb * m_DebugTLB; + CDebugCommandsView * m_CommandsView; + CDebugScripts * m_Scripts; + CDebugSymbols * m_Symbols; + CDebugDMALogView * m_DMALogView; + CDebugStackTrace * m_StackTrace; + CDebugStackView * m_StackView; + + CBreakpoints * m_Breakpoints; + CScriptSystem * m_ScriptSystem; + CDMALog * m_DMALog; + + SyncEvent m_StepEvent; + };