Add a sysprop for IsDebuggerPresent.

This commit is contained in:
Henrik Rydgård 2023-10-11 23:40:07 +02:00
parent f1bc547e94
commit 6dbe49775c
6 changed files with 12 additions and 7 deletions

View File

@ -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"
@ -139,7 +140,7 @@ 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) {
@ -147,7 +148,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
}
} 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();
}
}

View File

@ -139,6 +139,8 @@ enum SystemProperty {
SYSPROP_SUPPORTS_HTTPS,
SYSPROP_DEBUGGER_PRESENT,
// Available as Int:
SYSPROP_SYSTEMVERSION,
SYSPROP_DISPLAY_XRES,

View File

@ -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")));

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}
@ -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;