From ea1e0efbef7069dd87bc5c15e5f87dae2014d252 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 10 Jan 2018 18:05:57 +1100 Subject: [PATCH] [Debugger] Detach Debugger from UI class --- Source/Project64-core/Debugger.h | 16 ++++++-- .../Debugger/Debugger-Commands.cpp | 2 +- .../Debugger/Debugger-Scripts.cpp | 2 +- .../Debugger/Debugger-ViewMemory.cpp | 6 +-- .../UserInterface/Debugger/Debugger.cpp | 24 ++++++------ .../UserInterface/Debugger/debugger.h | 37 ++++++++----------- Source/Project64/UserInterface/MainMenu.cpp | 20 +++++----- Source/Project64/UserInterface/MainWindow.h | 1 - Source/Project64/main.cpp | 3 +- 9 files changed, 58 insertions(+), 53 deletions(-) diff --git a/Source/Project64-core/Debugger.h b/Source/Project64-core/Debugger.h index ae46b457c..bd67ce9bc 100644 --- a/Source/Project64-core/Debugger.h +++ b/Source/Project64-core/Debugger.h @@ -12,8 +12,18 @@ __interface CDebugger { - virtual void TLBChanged(void) = 0; - virtual bool CPUStepStarted(void) = 0; - virtual void CPUStep(void) = 0; + virtual void OpenCommandWindow(void) = 0; + virtual void OpenMemoryWindow(void) = 0; + virtual void OpenMemoryDump(void) = 0; + virtual void OpenMemorySearch(void) = 0; + virtual void OpenTLBWindow(void) = 0; + virtual void OpenScriptsWindow(void) = 0; + virtual void OpenSymbolsWindow(void) = 0; + virtual void OpenDMALogWindow(void) = 0; + virtual void OpenStackTraceWindow(void) = 0; + virtual void OpenStackViewWindow(void) = 0; + virtual void TLBChanged(void) = 0; + virtual bool CPUStepStarted(void) = 0; + virtual void CPUStep(void) = 0; virtual void FrameDrawn(void) = 0; }; diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp index fcc3067a3..86e6ec3ea 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Commands.cpp @@ -1141,7 +1141,7 @@ LRESULT CDebugCommandsView::OnViewPCButton(WORD /*wNotifyCode*/, WORD /*wID*/, H LRESULT CDebugCommandsView::OnSymbolsButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hwnd*/, BOOL& /*bHandled*/) { - m_Debugger->Debug_ShowSymbolsWindow(); + m_Debugger->OpenSymbolsWindow(); return FALSE; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp index 19c240ae1..52c7c7718 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-Scripts.cpp @@ -85,7 +85,7 @@ void CDebugScripts::ConsolePrint(const char* text) void CDebugScripts::RefreshConsole() { - m_Debugger->Debug_ShowScriptsWindow(); + m_Debugger->OpenScriptsWindow(); CScriptSystem* scriptSystem = m_Debugger->ScriptSystem(); vector* logData = scriptSystem->LogData(); diff --git a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp index c37a385e2..d89a28916 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-ViewMemory.cpp @@ -193,13 +193,13 @@ LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& RefreshMemory(false); break; case IDC_DUMP_MEM: - m_Debugger->Debug_ShowMemoryDump(); + m_Debugger->OpenMemoryDump(); break; case IDC_SEARCH_MEM: - m_Debugger->Debug_ShowMemorySearch(); + m_Debugger->OpenMemorySearch(); break; case IDC_SYMBOLS_BTN: - m_Debugger->Debug_ShowSymbolsWindow(); + m_Debugger->OpenSymbolsWindow(); break; case IDCANCEL: EndDialog(0); diff --git a/Source/Project64/UserInterface/Debugger/Debugger.cpp b/Source/Project64/UserInterface/Debugger/Debugger.cpp index baa5709ce..e544b136d 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger.cpp @@ -157,7 +157,7 @@ void CDebuggerUI::Debug_Reset(void) } } -void CDebuggerUI::Debug_ShowMemoryDump() +void CDebuggerUI::OpenMemoryDump() { if (g_MMU == NULL) { @@ -173,7 +173,7 @@ void CDebuggerUI::Debug_ShowMemoryDump() } } -void CDebuggerUI::Debug_ShowMemoryWindow(void) +void CDebuggerUI::OpenMemoryWindow(void) { if (g_MMU == NULL) { @@ -191,14 +191,14 @@ void CDebuggerUI::Debug_ShowMemoryWindow(void) void CDebuggerUI::Debug_ShowMemoryLocation(uint32_t Address, bool VAddr) { - Debug_ShowMemoryWindow(); + OpenMemoryWindow(); if (m_MemoryView) { m_MemoryView->ShowAddress(Address, VAddr); } } -void CDebuggerUI::Debug_ShowTLBWindow(void) +void CDebuggerUI::OpenTLBWindow(void) { if (g_MMU == NULL) { @@ -222,7 +222,7 @@ void CDebuggerUI::Debug_RefreshTLBWindow(void) } } -void CDebuggerUI::Debug_ShowMemorySearch() +void CDebuggerUI::OpenMemorySearch() { if (m_MemorySearch == NULL) { @@ -234,7 +234,7 @@ void CDebuggerUI::Debug_ShowMemorySearch() } } -void CDebuggerUI::Debug_ShowCommandsWindow() +void CDebuggerUI::OpenCommandWindow() { if (m_CommandsView == NULL) { @@ -245,14 +245,14 @@ void CDebuggerUI::Debug_ShowCommandsWindow() void CDebuggerUI::Debug_ShowCommandsLocation(uint32_t address, bool top) { - Debug_ShowCommandsWindow(); + OpenCommandWindow(); if (m_CommandsView) { m_CommandsView->ShowAddress(address, top); } } -void CDebuggerUI::Debug_ShowScriptsWindow() +void CDebuggerUI::OpenScriptsWindow() { if (m_Scripts == NULL) { @@ -285,7 +285,7 @@ void CDebuggerUI::Debug_ClearScriptsWindow() } } -void CDebuggerUI::Debug_ShowSymbolsWindow() +void CDebuggerUI::OpenSymbolsWindow() { if (m_Symbols == NULL) { @@ -302,7 +302,7 @@ void CDebuggerUI::Debug_RefreshSymbolsWindow() } } -void CDebuggerUI::Debug_ShowDMALogWindow(void) +void CDebuggerUI::OpenDMALogWindow(void) { if (m_DMALogView == NULL) { @@ -311,7 +311,7 @@ void CDebuggerUI::Debug_ShowDMALogWindow(void) m_DMALogView->ShowWindow(); } -void CDebuggerUI::Debug_ShowStackTrace(void) +void CDebuggerUI::OpenStackTraceWindow(void) { if (m_StackTrace == NULL) { @@ -320,7 +320,7 @@ void CDebuggerUI::Debug_ShowStackTrace(void) m_StackTrace->ShowWindow(); } -void CDebuggerUI::Debug_ShowStackWindow(void) +void CDebuggerUI::OpenStackViewWindow(void) { if (m_StackView == NULL) { diff --git a/Source/Project64/UserInterface/Debugger/debugger.h b/Source/Project64/UserInterface/Debugger/debugger.h index d7b8b1fc9..7cc96c4cf 100644 --- a/Source/Project64/UserInterface/Debugger/debugger.h +++ b/Source/Project64/UserInterface/Debugger/debugger.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include class CDumpMemory; class CDebugMemoryView; @@ -25,17 +26,14 @@ class CDMALog; class CBreakpoints; class CScriptSystem; -__interface CDebugger -{ - virtual void TLBChanged(void) = 0; - virtual bool CPUStepStarted(void) = 0; - virtual void CPUStep(void) = 0; - virtual void FrameDrawn(void) = 0; -}; - class CDebuggerUI : public CDebugger { +public: + CDebuggerUI(); + ~CDebuggerUI(); + +private: CDumpMemory * m_MemoryDump; CDebugMemoryView * m_MemoryView; CDebugMemorySearch * m_MemorySearch; @@ -54,9 +52,6 @@ class CDebuggerUI : void BreakpointHit(void); protected: - CDebuggerUI(); - virtual ~CDebuggerUI(); - void TLBChanged(void); bool CPUStepStarted(void); void CPUStep(void); @@ -64,25 +59,25 @@ protected: public: void Debug_Reset(void); - void Debug_ShowMemoryDump(void); - void Debug_ShowMemoryWindow(void); + void OpenMemoryDump(void); + void OpenMemoryWindow(void); void Debug_ShowMemoryLocation(uint32_t Address, bool VAddr); - void Debug_ShowMemorySearch(void); - void Debug_ShowTLBWindow(void); + void OpenMemorySearch(void); + void OpenTLBWindow(void); void Debug_RefreshTLBWindow(void); - void Debug_ShowCommandsWindow(void); + void OpenCommandWindow(void); void Debug_ShowCommandsLocation(uint32_t address, bool top); - void Debug_ShowScriptsWindow(void); + void OpenScriptsWindow(void); void Debug_LogScriptsWindow(const char* text); void Debug_ClearScriptsWindow(void); void Debug_RefreshScriptsWindow(void); void Debug_RefreshSymbolsWindow(void); - void Debug_ShowSymbolsWindow(void); - void Debug_ShowStackTrace(void); - void Debug_ShowStackWindow(void); + void OpenSymbolsWindow(void); + void OpenStackTraceWindow(void); + void OpenStackViewWindow(void); void Debug_RefreshStackWindow(void); void Debug_RefreshStackTraceWindow(void); - void Debug_ShowDMALogWindow(void); + void OpenDMALogWindow(void); CBreakpoints* Breakpoints(); CDebugSymbols* Symbols(); diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index 7bbc57291..43d13c606 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -496,22 +496,22 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_GENERATELOG: g_Settings->SaveBool(Logging_GenerateLog, !g_Settings->LoadBool(Logging_GenerateLog)); break; - case ID_DEBUGGER_DUMPMEMORY: m_Gui->Debug_ShowMemoryDump(); break; - case ID_DEBUGGER_SEARCHMEMORY: m_Gui->Debug_ShowMemorySearch(); break; - case ID_DEBUGGER_MEMORY: m_Gui->Debug_ShowMemoryWindow(); break; - case ID_DEBUGGER_TLBENTRIES: m_Gui->Debug_ShowTLBWindow(); break; + case ID_DEBUGGER_DUMPMEMORY: g_Debugger->OpenMemoryDump(); break; + case ID_DEBUGGER_SEARCHMEMORY: g_Debugger->OpenMemorySearch(); break; + case ID_DEBUGGER_MEMORY: g_Debugger->OpenMemoryWindow(); break; + case ID_DEBUGGER_TLBENTRIES: g_Debugger->OpenTLBWindow(); break; case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; case ID_DEBUGGER_INTERRUPT_VI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_VI); break; case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; - case ID_DEBUGGER_BREAKPOINTS: m_Gui->Debug_ShowCommandsWindow(); break; - case ID_DEBUGGER_SCRIPTS: m_Gui->Debug_ShowScriptsWindow(); break; - case ID_DEBUGGER_SYMBOLS: m_Gui->Debug_ShowSymbolsWindow(); break; - case ID_DEBUGGER_DMALOG: m_Gui->Debug_ShowDMALogWindow(); break; - case ID_DEBUGGER_STACKTRACE: m_Gui->Debug_ShowStackTrace(); break; - case ID_DEBUGGER_STACKVIEW: m_Gui->Debug_ShowStackWindow(); break; + case ID_DEBUGGER_BREAKPOINTS: g_Debugger->OpenCommandWindow(); break; + case ID_DEBUGGER_SCRIPTS: g_Debugger->OpenScriptsWindow(); break; + case ID_DEBUGGER_SYMBOLS: g_Debugger->OpenSymbolsWindow(); break; + case ID_DEBUGGER_DMALOG: g_Debugger->OpenDMALogWindow(); break; + case ID_DEBUGGER_STACKTRACE: g_Debugger->OpenStackTraceWindow(); break; + case ID_DEBUGGER_STACKVIEW: g_Debugger->OpenStackViewWindow(); break; case ID_CURRENT_SAVE_DEFAULT: g_Notify->DisplayMessage(3, stdstr_f(GS(MENU_SLOT_SAVE), GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); diff --git a/Source/Project64/UserInterface/MainWindow.h b/Source/Project64/UserInterface/MainWindow.h index 48d00af0f..bef3f93ab 100644 --- a/Source/Project64/UserInterface/MainWindow.h +++ b/Source/Project64/UserInterface/MainWindow.h @@ -33,7 +33,6 @@ enum class CMainGui : public RenderWindow, public CRomBrowser, - public CDebuggerUI, private CGuiSettings { enum { StatusBarID = 400 }; diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index bce64d0e1..b9ab69ad7 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -18,7 +18,8 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / WriteTrace(TraceUserInterface, TraceDebug, "Create Main Window"); CMainGui MainWindow(true, stdstr_f("Project64 %s", VER_FILE_VERSION_STR).c_str()), HiddenWindow(false); CMainMenu MainMenu(&MainWindow); - g_Debugger = &MainWindow; + CDebuggerUI Debugger; + g_Debugger = &Debugger; g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow); Notify().SetMainWindow(&MainWindow); CSupportWindow SupportWindow;