Added better debug

Now triggers a breakpoint when a function fails
This commit is contained in:
Pasha Bibko
2025-07-20 14:18:31 +01:00
parent 8f75e52a07
commit ac656b7b0f
5 changed files with 36 additions and 52 deletions

View File

@@ -1,44 +0,0 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}

15
CMakeSettings.json Normal file
View File

@@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}

View File

@@ -1,13 +1,6 @@
#pragma once
// Platform specific includes //
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#error "Code is currently only supported on Win32"
#endif // _WIN32
#include <OS.h>
#include <iostream>
#include <ostream>

10
Common/OS.h Normal file
View File

@@ -0,0 +1,10 @@
#pragma once
// Platform specific includes //
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#else
#error "Code is currently only supported on Win32"
#endif // _WIN32

View File

@@ -1,5 +1,7 @@
#pragma once
#include <OS.h>
#include <type_traits>
#include <cstdlib>
@@ -11,6 +13,14 @@ namespace LXC::Util
explicit FunctionFail(ErrorType _err)
: error(_err)
{
// Only checks for a debugger when compiled in Debug mode //
#ifdef _DEBUG
// Triggers a breakpoint when a debugger is attached as a function has failed //
if (IsDebuggerPresent())
DebugBreak();
#endif
}
ErrorType error;