diff --git a/src/coreclr/inc/clrconfig.h b/src/coreclr/inc/clrconfig.h index 549f372f4e7a97..66bb62e59f4d7b 100644 --- a/src/coreclr/inc/clrconfig.h +++ b/src/coreclr/inc/clrconfig.h @@ -36,6 +36,9 @@ class CLRConfig // The configuration should be parsed using a 10 radix as opposed to the // default of 16. ParseIntegerAsBase10 = 0x4, + + // The configuration value is valid for the DAC. + ValidForDacBuild = 0x8, }; // Struct used to store information about where/how to find a Config DWORD. diff --git a/src/coreclr/inc/clrconfigvalues.h b/src/coreclr/inc/clrconfigvalues.h index 2845790e2b71cd..c365165848c7f4 100644 --- a/src/coreclr/inc/clrconfigvalues.h +++ b/src/coreclr/inc/clrconfigvalues.h @@ -177,9 +177,9 @@ CONFIG_DWORD_INFO(INTERNAL_DbgBreakOnRawInt3, W("DbgBreakOnRawInt3"), 0, "Allows CONFIG_DWORD_INFO(INTERNAL_DbgBreakOnSendBreakpoint, W("DbgBreakOnSendBreakpoint"), 0, "Allows an assert when sending a breakpoint to the right side") CONFIG_DWORD_INFO(INTERNAL_DbgBreakOnSetIP, W("DbgBreakOnSetIP"), 0, "Allows an assert when setting the IP") CONFIG_DWORD_INFO(INTERNAL_DbgCheckInt3, W("DbgCheckInt3"), 0, "Asserts if the debugger explicitly writes int3 instead of calling SetUnmanagedBreakpoint") -CONFIG_DWORD_INFO(INTERNAL_DbgDACAssertOnMismatch, W("DbgDACAssertOnMismatch"), 0, "Allows an assert when the mscordacwks and mscorwks dll versions don't match") -CONFIG_DWORD_INFO(INTERNAL_DbgDACEnableAssert, W("DbgDACEnableAssert"), 0, "Enables extra validity checking in DAC - assumes target isn't corrupt") -RETAIL_CONFIG_DWORD_INFO(INTERNAL_DbgDACSkipVerifyDlls, W("DbgDACSkipVerifyDlls"), 0, "Allows disabling the check to ensure mscordacwks and mscorwks dll versions match") +#ifdef DACCESS_COMPILE +CONFIG_DWORD_INFO_EX(INTERNAL_DbgDACEnableAssert, W("DbgDACEnableAssert"), 0, "Enables extra validity checking in DAC - assumes target isn't corrupt", CLRConfig::LookupOptions::ValidForDacBuild) +#endif // DACCESS_COMPILE CONFIG_DWORD_INFO(INTERNAL_DbgDelayHelper, W("DbgDelayHelper"), 0, "Varies the wait in the helper thread startup for testing race between threads") RETAIL_CONFIG_DWORD_INFO(INTERNAL_DbgDisableDynamicSymsCompat, W("DbgDisableDynamicSymsCompat"), 0, "") CONFIG_DWORD_INFO(INTERNAL_DbgDisableTargetConsistencyAsserts, W("DbgDisableTargetConsistencyAsserts"), 0, "Allows explicitly testing with corrupt targets") @@ -224,8 +224,8 @@ CONFIG_DWORD_INFO(INTERNAL_DbgAssertOnDebuggeeDebugBreak, W("DbgAssertOnDebuggee RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_DbgDontResumeThreadsOnUnhandledException, W("UNSUPPORTED_DbgDontResumeThreadsOnUnhandledException"), 0, "If non-zero, then don't try to unsuspend threads after continuing a 2nd-chance native exception") RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_DbgSkipStackCheck, W("DbgSkipStackCheck"), 0, "Skip the stack pointer check during stackwalking") #ifdef DACCESS_COMPILE -CONFIG_DWORD_INFO(INTERNAL_DumpGeneration_IntentionallyCorruptDataFromTarget, W("IntentionallyCorruptDataFromTarget"), 0, "Intentionally fakes bad data retrieved from target to try and break dump generation.") -#endif +CONFIG_DWORD_INFO_EX(INTERNAL_DumpGeneration_IntentionallyCorruptDataFromTarget, W("IntentionallyCorruptDataFromTarget"), 0, "Intentionally fakes bad data retrieved from target to try and break dump generation.", CLRConfig::LookupOptions::ValidForDacBuild) +#endif // DACCESS_COMPILE // Note that Debugging_RequiredVersion is sometimes an 'INTERNAL' knob and sometimes an 'UNSUPPORTED' knob, but we don't change it's name. CONFIG_DWORD_INFO(UNSUPPORTED_Debugging_RequiredVersion, W("UNSUPPORTED_Debugging_RequiredVersion"), 0, "The lowest ICorDebug version we should attempt to emulate, or 0 for default policy. Use 2 for CLRv2, 4 for CLRv4, etc.") diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index 0221afafe08c9b..5d98679ebab0db 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -2941,18 +2941,14 @@ class MethodNamesList : public MethodNamesListBase /* simple wrappers around the CLRConfig and MethodNameList routines that make the lookup lazy */ -/* to be used as static variable - no constructor/destructor, assumes zero - initialized memory */ - -class ConfigDWORD +class ConfigDWORD final { public: - inline DWORD val(const CLRConfig::ConfigDWORDInfo & info) + ConfigDWORD() : m_value{ 0 }, m_inited{ false } { WRAPPER_NO_CONTRACT; } + + DWORD val(const CLRConfig::ConfigDWORDInfo & info) { WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - if (!m_inited) init(info); return m_value; } @@ -2962,19 +2958,18 @@ class ConfigDWORD private: DWORD m_value; - BYTE m_inited; + bool m_inited; }; /**************************************************************************/ -class ConfigString +class ConfigString final { public: - inline LPWSTR val(const CLRConfig::ConfigStringInfo & info) + ConfigString() : m_value{ NULL }, m_inited{ false } { WRAPPER_NO_CONTRACT; } + + LPWSTR val(const CLRConfig::ConfigStringInfo & info) { WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - if (!m_inited) init(info); return m_value; } @@ -2982,11 +2977,7 @@ class ConfigString bool isInitialized() { WRAPPER_NO_CONTRACT; - - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - return m_inited == 1; + return m_inited; } private: @@ -2994,39 +2985,7 @@ class ConfigString private: LPWSTR m_value; - BYTE m_inited; -}; - -/**************************************************************************/ -class ConfigMethodSet -{ -public: - bool isEmpty() - { - WRAPPER_NO_CONTRACT; - _ASSERTE(m_inited == 1); - return m_list.IsEmpty(); - } - - bool contains(LPCUTF8 methodName, LPCUTF8 className, int argCount = -1); - bool contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo); - - inline void ensureInit(const CLRConfig::ConfigStringInfo & info) - { - WRAPPER_NO_CONTRACT; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - if (!m_inited) init(info); - } - -private: - void init(const CLRConfig::ConfigStringInfo & info); - -private: - MethodNamesListBase m_list; - - BYTE m_inited; + bool m_inited; }; //***************************************************************************** diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index b531018eb08ae1..e1a92159dc461e 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -240,7 +240,14 @@ namespace } CONTRACTL_END; - SUPPORTS_DAC_HOST_ONLY; +#ifdef DACCESS_COMPILE + if (!CheckLookupOption(options, LookupOptions::ValidForDacBuild)) + { + LOG((LF_CORDB, LL_ALWAYS, "ConfigDWORD, '%s', is not valid for DAC. Mark it with LookupOptions::ValidForDacBuild to enable.\n", name)); + *result = defValue; + return S_OK; + } +#endif // DACCESS_COMPILE FAULT_NOT_FATAL(); // We don't report OOM errors here, we return a default value. @@ -278,6 +285,14 @@ namespace } CONTRACTL_END; +#ifdef DACCESS_COMPILE + if (!CheckLookupOption(options, LookupOptions::ValidForDacBuild)) + { + LOG((LF_CORDB, LL_ALWAYS, "ConfigString, '%s', is not valid for DAC. Mark it with LookupOptions::ValidForDacBuild to enable.\n", name)); + return NULL; + } +#endif // DACCESS_COMPILE + NewArrayHolder ret(NULL); FAULT_NOT_FATAL(); // We don't report OOM errors here, we return a default value. diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 8a9c78fbee76b6..82835ba6d39e7f 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -1144,76 +1144,6 @@ uint32_t GetOsPageSize() /**************************************************************************/ -/**************************************************************************/ -void ConfigMethodSet::init(const CLRConfig::ConfigStringInfo & info) -{ - CONTRACTL - { - THROWS; - } - CONTRACTL_END; - - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - LPWSTR str = CLRConfig::GetConfigValue(info); - if (str) - { - m_list.Insert(str); - delete[] str; - } - m_inited = 1; -} - -/**************************************************************************/ -bool ConfigMethodSet::contains(LPCUTF8 methodName, LPCUTF8 className, int argCount) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - _ASSERTE(m_inited == 1); - - if (m_list.IsEmpty()) - return false; - return(m_list.IsInList(methodName, className, argCount)); -} - -/**************************************************************************/ -bool ConfigMethodSet::contains(LPCUTF8 methodName, LPCUTF8 className, CORINFO_SIG_INFO* pSigInfo) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - _ASSERTE(m_inited == 1); - - if (m_list.IsEmpty()) - return false; - return(m_list.IsInList(methodName, className, pSigInfo)); -} - -/**************************************************************************/ -void ConfigString::init(const CLRConfig::ConfigStringInfo & info) -{ - CONTRACTL - { - NOTHROW; - } - CONTRACTL_END; - - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); - - // Note: m_value will be leaking - m_value = CLRConfig::GetConfigValue(info); - m_inited = 1; -} - //============================================================================= // AssemblyNamesList //============================================================================= diff --git a/src/coreclr/utilcode/util_nodependencies.cpp b/src/coreclr/utilcode/util_nodependencies.cpp index dbb40efb3555c7..fc570d5a3c7636 100644 --- a/src/coreclr/utilcode/util_nodependencies.cpp +++ b/src/coreclr/utilcode/util_nodependencies.cpp @@ -650,11 +650,22 @@ void ConfigDWORD::init(const CLRConfig::ConfigDWORDInfo & info) } CONTRACTL_END; - // make sure that the memory was zero initialized - _ASSERTE(m_inited == 0 || m_inited == 1); + m_value = CLRConfig::GetConfigValue(info); + m_inited = true; +} + +/**************************************************************************/ +void ConfigString::init(const CLRConfig::ConfigStringInfo & info) +{ + CONTRACTL + { + NOTHROW; + } + CONTRACTL_END; + // Note: m_value will be leaking m_value = CLRConfig::GetConfigValue(info); - m_inited = 1; + m_inited = true; } //---------------------------------------------------------------------------------------