From d6d19ad1a5fe1531b8e31ec93bef0f787b43023d Mon Sep 17 00:00:00 2001 From: Tom McDonald Date: Tue, 8 Aug 2023 17:48:58 -0400 Subject: [PATCH] Add EnableDiagnostics sub-configs for IPC, debugger, and profiler (#90159) --- src/coreclr/debug/ee/debugger.cpp | 8 ++++++++ src/coreclr/inc/clrconfigvalues.h | 8 ++++++-- src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h | 6 +++++- src/coreclr/vm/profilinghelper.cpp | 14 ++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 7581c0c..0372768 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -1920,6 +1920,14 @@ HRESULT Debugger::Startup(void) // the named pipes and semaphores are not created. if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableDiagnostics) == 0) { + LOG((LF_CORDB, LL_INFO10, "Debugging disabled via EnableDiagnostics config.\n")); + + return S_OK; + } + if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableDiagnostics_Debugger) == 0) + { + LOG((LF_CORDB, LL_INFO10, "Debugging disabled via EnableDiagnostics_Debugger config.\n")); + return S_OK; } diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index 401a4f9..ed61a56 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -162,9 +162,13 @@ CONFIG_DWORD_INFO(INTERNAL_BreakOnUEF, W("BreakOnUEF"), 0, "") CONFIG_DWORD_INFO(INTERNAL_BreakOnUncaughtException, W("BreakOnUncaughtException"), 0, "") /// -/// Debugger +/// Debugger, Profiler, Diagnostics IPC Ports /// -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "Allows the debugger, profiler, and EventPipe diagnostics to be disabled") +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "Allows the debugger, profiler, and diagnostic IPC service ports to be disabled") +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableDiagnostics_IPC, W("EnableDiagnostics_IPC"), 1, "Allows the diagnostic IPC service ports to be disabled") +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableDiagnostics_Debugger, W("EnableDiagnostics_Debugger"), 1, "Allows the debugger to be disabled") +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableDiagnostics_Profiler, W("EnableDiagnostics_Profiler"), 1, "Allows the profiler to be disabled") + CONFIG_DWORD_INFO(INTERNAL_D__FCE, W("D::FCE"), 0, "Allows an assert when crawling the managed stack for an exception handler") CONFIG_DWORD_INFO(INTERNAL_DbgBreakIfLocksUnavailable, W("DbgBreakIfLocksUnavailable"), 0, "Allows an assert when the debugger can't take a lock ") CONFIG_DWORD_INFO(INTERNAL_DbgBreakOnErr, W("DbgBreakOnErr"), 0, "Allows an assert when we get a failing hresult") diff --git a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h index b239592..57f5c12 100644 --- a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h @@ -151,7 +151,11 @@ bool ds_rt_config_value_get_enable (void) { STATIC_CONTRACT_NOTHROW; - return CLRConfig::GetConfigValue (CLRConfig::EXTERNAL_EnableDiagnostics) != 0; + if (CLRConfig::GetConfigValue (CLRConfig::EXTERNAL_EnableDiagnostics) == 0) + { + return false; + } + return CLRConfig::GetConfigValue (CLRConfig::EXTERNAL_EnableDiagnostics_IPC) != 0; } static diff --git a/src/coreclr/vm/profilinghelper.cpp b/src/coreclr/vm/profilinghelper.cpp index 72a713e..7d615f0 100644 --- a/src/coreclr/vm/profilinghelper.cpp +++ b/src/coreclr/vm/profilinghelper.cpp @@ -436,6 +436,20 @@ HRESULT ProfilingAPIUtility::InitializeProfiling() // NULL out / initialize members of the global profapi structure g_profControlBlock.Init(); + if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableDiagnostics) == 0) + { + LOG((LF_CORPROF, LL_INFO10, "**PROF: Profiling disabled via EnableDiagnostics config.\n")); + + return S_OK; + } + if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableDiagnostics_Profiler) == 0) + { + LOG((LF_CORPROF, LL_INFO10, "**PROF: Profiling disabled via EnableDiagnostics_Profiler config.\n")); + + return S_OK; + } + + AttemptLoadProfilerForStartup(); AttemptLoadDelayedStartupProfilers(); AttemptLoadProfilerList(); -- 2.7.4