diff --git a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs
index 8a2a61b4f..2cb89915c 100644
--- a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs
+++ b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs
@@ -27,6 +27,11 @@ namespace Dalamud.Configuration.Internal
///
public static bool DalamudForceMinHook { get; } = GetEnvironmentVariable("DALAMUD_FORCE_MINHOOK");
+ ///
+ /// Gets a value indicating whether or not Dalamud should wait for a debugger to be attached when initializing.
+ ///
+ public static bool DalamudWaitForDebugger { get; } = GetEnvironmentVariable("DALAMUD_WAIT_DEBUGGER");
+
private static bool GetEnvironmentVariable(string name)
=> bool.Parse(Environment.GetEnvironmentVariable(name) ?? "false");
}
diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs
index e42df3fbd..efba9a7ff 100644
--- a/Dalamud/EntryPoint.cs
+++ b/Dalamud/EntryPoint.cs
@@ -52,6 +52,14 @@ namespace Dalamud
/// The containing information needed to initialize Dalamud.
private static void RunThread(DalamudStartInfo info)
{
+ if (EnvironmentConfiguration.DalamudWaitForDebugger)
+ {
+ while (!Debugger.IsAttached)
+ {
+ Thread.Sleep(100);
+ }
+ }
+
// Setup logger
var levelSwitch = InitLogging(info.WorkingDirectory);