Skip to content

Commit

Permalink
Add a sysprop for IsDebuggerPresent.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Oct 12, 2023
1 parent f1bc547 commit 6dbe497
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Common/GPU/Vulkan/VulkanDebug.cpp
Expand Up @@ -21,6 +21,7 @@
#include <mutex>

#include "Common/Log.h"
#include "Common/System/System.h"
#include "Common/GPU/Vulkan/VulkanContext.h"
#include "Common/GPU/Vulkan/VulkanDebug.h"

Expand Down Expand Up @@ -139,15 +140,15 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
#ifdef _WIN32
OutputDebugStringA(msg.c_str());
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
if (options->breakOnError && IsDebuggerPresent()) {
if (options->breakOnError && System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) {
DebugBreak();
}
if (options->msgBoxOnError) {
MessageBoxA(NULL, pMessage, "Alert", MB_OK);
}
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
// Don't break on perf warnings for now, even with a debugger. We log them at least.
if (options->breakOnWarning && IsDebuggerPresent() && 0 == (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)) {
if (options->breakOnWarning && System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT) && 0 == (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)) {
DebugBreak();
}
}
Expand Down
2 changes: 2 additions & 0 deletions Common/System/System.h
Expand Up @@ -139,6 +139,8 @@ enum SystemProperty {

SYSPROP_SUPPORTS_HTTPS,

SYSPROP_DEBUGGER_PRESENT,

// Available as Int:
SYSPROP_SYSTEMVERSION,
SYSPROP_DISPLAY_XRES,
Expand Down
4 changes: 1 addition & 3 deletions UI/DevScreens.cpp
Expand Up @@ -510,11 +510,9 @@ void SystemInfoScreen::CreateTabs() {
if (!board.empty())
systemInfo->Add(new InfoItem(si->T("Board"), board));
systemInfo->Add(new InfoItem(si->T("ABI"), GetCompilerABI()));
#ifdef _WIN32
if (IsDebuggerPresent()) {
if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) {
systemInfo->Add(new InfoItem(si->T("Debugger Present"), di->T("Yes")));
}
#endif

CollapsibleSection *cpuInfo = deviceSpecs->Add(new CollapsibleSection(si->T("CPU Information")));

Expand Down
2 changes: 2 additions & 0 deletions UWP/PPSSPP_UWPMain.cpp
Expand Up @@ -431,6 +431,8 @@ bool System_GetPropertyBool(SystemProperty prop) {
// I don't know any possible way to display input dialog in non-xaml apps
return isKeyboardAvailable() || isTouchAvailable();
}
case SYSPROP_DEBUGGER_PRESENT:
return IsDebuggerPresent();
default:
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Windows/MainWindowMenu.cpp
Expand Up @@ -418,7 +418,7 @@ namespace MainWindow {
}

static void RestartApp() {
if (IsDebuggerPresent()) {
if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) {
PostMessage(MainWindow::GetHWND(), WM_USER_RESTART_EMUTHREAD, 0, 0);
} else {
g_Config.bRestartRequired = true;
Expand Down
4 changes: 3 additions & 1 deletion Windows/main.cpp
Expand Up @@ -381,6 +381,8 @@ bool System_GetPropertyBool(SystemProperty prop) {
return true; // FileUtil.cpp: OpenFileInEditor
case SYSPROP_SUPPORTS_HTTPS:
return !g_Config.bDisableHTTPS;
case SYSPROP_DEBUGGER_PRESENT:
return IsDebuggerPresent();
default:
return false;
}
Expand Down Expand Up @@ -494,7 +496,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
restartArgs = param1;
if (!restartArgs.empty())
AddDebugRestartArgs();
if (IsDebuggerPresent()) {
if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) {
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_RESTART_EMUTHREAD, 0, 0);
} else {
g_Config.bRestartRequired = true;
Expand Down

0 comments on commit 6dbe497

Please sign in to comment.