Skip to content
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
15 changes: 15 additions & 0 deletions FlingEngine/Core/inc/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "World.h"
#include <nlohmann/json.hpp>
#include <entt/entity/registry.hpp>
#include <csignal>

#include "MovingAverage.hpp"
#include "Stats.h"
Expand All @@ -20,6 +21,20 @@

#endif // WITH_EDITOR

/**
* Triggers a breakpoint at the call site, halting execution if a debugger is attached.
* Works across compilers/platforms so callers don't need their own #ifdef ladder.
*/
#if defined( _MSC_VER )
#define F_DEBUG_BREAK() __debugbreak()
#elif defined( __clang__ )
#define F_DEBUG_BREAK() __builtin_debugtrap()
#elif defined( __GNUC__ )
#define F_DEBUG_BREAK() raise( SIGTRAP )
#else
#define F_DEBUG_BREAK()
#endif

namespace Fling
{
/**
Expand Down
6 changes: 6 additions & 0 deletions FlingEngine/Core/src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ namespace Fling

FlingConfig::Get().Init();

if (CommandLine::Get().GetValueAs<bool>("WaitForDebugger", false))
{
F_LOG_TRACE("-WaitForDebugger was set, breaking into the debugger now");
F_DEBUG_BREAK();
}

ResourceManager::Get().Init();
Timing::Get().Init();
Input::Init();
Expand Down
Loading