Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows debugger: Load the dialogs on demand. #15138

Merged
merged 3 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "Common/Net/URL.h"

#include "Common/Log.h"
#include "Common/TimeUtil.h"
#include "Common/Data/Format/IniFile.h"
#include "Common/Data/Format/JSONReader.h"
#include "Common/Data/Text/I18n.h"
Expand Down Expand Up @@ -1643,18 +1644,34 @@ void Config::RemoveRecent(const std::string &file) {
}

void Config::CleanRecent() {
double startTime = time_now_d();

std::vector<std::string> cleanedRecent;
for (size_t i = 0; i < recentIsos.size(); i++) {
FileLoader *loader = ConstructFileLoader(Path(recentIsos[i]));
if (loader->ExistsFast()) {
bool exists = false;
Path path = Path(recentIsos[i]);
switch (path.Type()) {
case PathType::CONTENT_URI:
case PathType::NATIVE:
exists = File::Exists(path);
break;
default:
FileLoader *loader = ConstructFileLoader(path);
exists = loader->ExistsFast();
delete loader;
break;
}

if (exists) {
// Make sure we don't have any redundant items.
auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]);
if (duplicate == cleanedRecent.end()) {
cleanedRecent.push_back(recentIsos[i]);
}
}
delete loader;
}

INFO_LOG(SYSTEM, "CleanRecent took %0.2f", time_now_d() - startTime);
recentIsos = cleanedRecent;
}

Expand Down
4 changes: 3 additions & 1 deletion Windows/Debugger/Debugger_Disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
break;

case IDC_SHOWVFPU:
MainWindow::CreateVFPUWindow();
vfpudlg->Show(true);
break;

Expand Down Expand Up @@ -899,7 +900,8 @@ void CDisasm::UpdateDialog(bool _bComplete)
_snwprintf(tempTicks, 24, L"%lld", CoreTiming::GetTicks() - lastTicks);
SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks);
}
// Update Register Dialog

// Update memory window
if (memoryWindow)
memoryWindow->Update();

Expand Down
3 changes: 3 additions & 0 deletions Windows/Debugger/Debugger_Lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Windows/Debugger/DebuggerShared.h"
#include "Windows/Debugger/CtrlDisAsmView.h"
#include "Windows/W32Util/ContextMenu.h"
#include "Windows/MainWindow.h"
#include "Windows/resource.h"
#include "Windows/main.h"
#include "Common/Data/Encoding/Utf8.h"
Expand Down Expand Up @@ -373,10 +374,12 @@ void CtrlBreakpointList::gotoBreakpointAddress(int itemIndex)

if (isMemory) {
u32 address = displayedMemChecks_[index].start;
MainWindow::CreateMemoryWindow();
if (memoryWindow)
memoryWindow->Goto(address);
} else {
u32 address = displayedBreakPoints_[index].addr;
MainWindow::CreateDisasmWindow();
if (disasmWindow)
disasmWindow->Goto(address);
}
Expand Down
2 changes: 0 additions & 2 deletions Windows/Debugger/Debugger_VFPUDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include "Core/MIPS/MIPS.h" // BAD

CVFPUDlg *vfpudlg;

CVFPUDlg::CVFPUDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu_) : Dialog((LPCSTR)IDD_VFPU, _hInstance,_hParent)
{
cpu = cpu_;
Expand Down
3 changes: 0 additions & 3 deletions Windows/Debugger/Debugger_VFPUDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ class CVFPUDlg : public Dialog {
int mode;
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};


extern CVFPUDlg *vfpudlg;
45 changes: 33 additions & 12 deletions Windows/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,36 +533,58 @@ namespace MainWindow
return TRUE;
}

void CreateDebugWindows() {
disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(disasmWindow);
disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false);
void CreateDisasmWindow() {
if (!disasmWindow) {
disasmWindow = new CDisasm(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(disasmWindow);
}
}

void CreateGeDebuggerWindow() {
#if PPSSPP_API(ANY_GL)
geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND());
DialogManager::AddDlg(geDebuggerWindow);
if (!geDebuggerWindow) {
geDebuggerWindow = new CGEDebugger(MainWindow::GetHInstance(), MainWindow::GetHWND());
DialogManager::AddDlg(geDebuggerWindow);
}
#endif
memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(memoryWindow);
}

void CreateMemoryWindow() {
if (!memoryWindow) {
memoryWindow = new CMemoryDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(memoryWindow);
}
}

void CreateVFPUWindow() {
if (!vfpudlg) {
vfpudlg = new CVFPUDlg(MainWindow::GetHInstance(), MainWindow::GetHWND(), currentDebugMIPS);
DialogManager::AddDlg(vfpudlg);
}
}

void DestroyDebugWindows() {
DialogManager::RemoveDlg(disasmWindow);
if (disasmWindow)
delete disasmWindow;
disasmWindow = 0;
disasmWindow = nullptr;

#if PPSSPP_API(ANY_GL)
DialogManager::RemoveDlg(geDebuggerWindow);
if (geDebuggerWindow)
delete geDebuggerWindow;
geDebuggerWindow = 0;
geDebuggerWindow = nullptr;
#endif

DialogManager::RemoveDlg(memoryWindow);
if (memoryWindow)
delete memoryWindow;
memoryWindow = 0;
memoryWindow = nullptr;

DialogManager::RemoveDlg(vfpudlg);
if (vfpudlg)
delete vfpudlg;
vfpudlg = nullptr;
}

LRESULT CALLBACK DisplayProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
Expand Down Expand Up @@ -928,7 +950,6 @@ namespace MainWindow
disasmWindow->NotifyMapLoaded();
if (memoryWindow)
memoryWindow->NotifyMapLoaded();

if (disasmWindow)
disasmWindow->UpdateDialog();
break;
Expand Down
6 changes: 4 additions & 2 deletions Windows/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ namespace MainWindow

void Init(HINSTANCE hInstance);
BOOL Show(HINSTANCE hInstance);
void CreateDebugWindows();
void CreateDisasmWindow();
void CreateGeDebuggerWindow();
void CreateMemoryWindow();
void CreateVFPUWindow();
void DestroyDebugWindows();
void Close();
void UpdateMenus(bool isMenuSelect = false);
void UpdateCommands();
void UpdateSwitchUMD();
Expand Down
3 changes: 3 additions & 0 deletions Windows/MainWindowMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,18 +896,21 @@ namespace MainWindow {
break;

case ID_DEBUG_DISASSEMBLY:
CreateDisasmWindow();
if (disasmWindow)
disasmWindow->Show(true);
break;

case ID_DEBUG_GEDEBUGGER:
#if PPSSPP_API(ANY_GL)
CreateGeDebuggerWindow();
if (geDebuggerWindow)
geDebuggerWindow->Show(true);
#endif
break;

case ID_DEBUG_MEMORYVIEW:
CreateMemoryWindow();
if (memoryWindow)
memoryWindow->Show(true);
break;
Expand Down
3 changes: 3 additions & 0 deletions Windows/W32Util/DialogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ void DialogManager::AddDlg(Dialog *dialog)

void DialogManager::RemoveDlg(Dialog *dialog)
{
if (!dialog) {
return;
}
dialogs.erase(std::remove(dialogs.begin(), dialogs.end(), dialog), dialogs.end());
}

Expand Down
7 changes: 5 additions & 2 deletions Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ CGEDebugger* geDebuggerWindow = nullptr;

CDisasm *disasmWindow = nullptr;
CMemoryDlg *memoryWindow = nullptr;
CVFPUDlg *vfpudlg = nullptr;

static std::string langRegion;
static std::string osName;
Expand Down Expand Up @@ -684,9 +685,11 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
#if PPSSPP_API(ANY_GL)
CGEDebugger::Init();
#endif
DialogManager::AddDlg(vfpudlg = new CVFPUDlg(_hInstance, hwndMain, currentDebugMIPS));

MainWindow::CreateDebugWindows();
if (g_Config.bShowDebuggerOnLoad) {
MainWindow::CreateDisasmWindow();
disasmWindow->Show(g_Config.bShowDebuggerOnLoad, false);
}

const bool minimized = iCmdShow == SW_MINIMIZE || iCmdShow == SW_SHOWMINIMIZED || iCmdShow == SW_SHOWMINNOACTIVE;
if (minimized) {
Expand Down
4 changes: 4 additions & 0 deletions Windows/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
#pragma once

#include "ppsspp_config.h"

#include "Debugger/Debugger_Disasm.h"
#include "Debugger/Debugger_MemoryDlg.h"
#include "Debugger/Debugger_VFPUDlg.h"

#include "Common/CommonWindows.h"

extern CDisasm *disasmWindow;
extern CMemoryDlg *memoryWindow;
extern CVFPUDlg *vfpudlg;

#if PPSSPP_API(ANY_GL)
#include "Windows/GEDebugger/GEDebugger.h"
Expand Down