Do not create diagnostics server thread and pipe if EnableDiagnostics is set to 0...
authorSung Yoon Whang <suwhang@microsoft.com>
Fri, 11 Oct 2019 03:42:06 +0000 (20:42 -0700)
committerGitHub <noreply@github.com>
Fri, 11 Oct 2019 03:42:06 +0000 (20:42 -0700)
* Do not create diagnostics server thread and pipe if EnableDiagnostics is set to 0

* Remove unnecessary check for config var in DiagnosticServer::Shutdown

Commit migrated from https://github.com/dotnet/coreclr/commit/c2afcec36eeaad7288842bb517e034ef57164238

src/coreclr/src/inc/clrconfigvalues.h
src/coreclr/src/vm/diagnosticserver.cpp

index a2a903b..0c57a3f 100644 (file)
@@ -158,7 +158,7 @@ CONFIG_DWORD_INFO_EX(INTERNAL_BreakOnUncaughtException, W("BreakOnUncaughtExcept
 
 /// Debugger
 ///
-RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "Allows the debugger and profiler diagnostics to be disabled", CLRConfig::REGUTIL_default)
+RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "Allows the debugger, profiler, and EventPipe diagnostics to be disabled", CLRConfig::REGUTIL_default)
 CONFIG_DWORD_INFO_EX(INTERNAL_D__FCE, W("D::FCE"), 0, "Allows an assert when crawling the managed stack for an exception handler", CLRConfig::REGUTIL_default)
 CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakIfLocksUnavailable, W("DbgBreakIfLocksUnavailable"), 0, "Allows an assert when the debugger can't take a lock ", CLRConfig::REGUTIL_default)
 CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakOnErr, W("DbgBreakOnErr"), 0, "Allows an assert when we get a failing hresult", CLRConfig::REGUTIL_default)
index bc48991..53bc860 100644 (file)
@@ -117,6 +117,12 @@ bool DiagnosticServer::Initialize()
     }
     CONTRACTL_END;
 
+    // COMPlus_EnableDiagnostics==0 disables diagnostics so we don't create the diagnostics pipe/socket or diagnostics server thread
+    if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableDiagnostics) == 0)
+    {
+        return true;
+    }
+
     bool fSuccess = false;
 
     EX_TRY