Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add environment variable (COMPlus_EnableDiagnostics) to disable debugging and profiling #15878

Merged
merged 1 commit into from
Jan 18, 2018

Conversation

mikem8361
Copy link
Member

To disable the named pipes and semaphores created on linux execute "export COMPlus_EnableDiagnostics=0" before start the .NET Core program.

On Windows execute "set COMPlus_EnableDiagnostics=0". On Linux/OS X "export COMPlus_EnableDiagnostics=0".

The approach is to still create the DebugInterface so g_pDebugInterface != NULL but the debugger transport (g_pDbgTransport == NULL) and RC thread (m_pRCThread == NULL) are not created. This approach was used instead of not creating the DebugInterface because some of the function is used to get line number/source file info for stack traces when not debugging.

There are also some changes where g_pDebugInterface wasn't being checked for NULL that are included in the PR left over from a initial implementation. I included them to be complete because there are still some obscure cases that g_pDebugInterface == NULL like when the "debug package" isn't installed on Windows.

For issues #11769 and #8844.

@mikem8361 mikem8361 added this to the 2.1.0 milestone Jan 16, 2018
@mikem8361 mikem8361 self-assigned this Jan 16, 2018
@mikem8361 mikem8361 requested a review from noahfalk January 16, 2018 19:56
@jkotas
Copy link
Member

jkotas commented Jan 16, 2018

because some of the function is used to get line number/source file info for stack traces when not debugging.

These functions get the data from the VM (the actual information is managed by code manager), re-encoded it a little bit and pass it along. They should not depend on anything from the debugger stack. It should not be hard to factor them out.

I included them to be complete because there are still some obscure cases that g_pDebugInterface == NULL

What are these obscure cases? It sounds like a left over from Silverlight that can deleted. (Unless we want to make the g_pDebugInterface == NULL case work.)

@mikem8361
Copy link
Member Author

mikem8361 commented Jan 16, 2018 via email

@jkotas
Copy link
Member

jkotas commented Jan 16, 2018

IsWatsonEnabled()

IsWatsonEnabled() is always true in CoreCLR, so this is just a dead/unrechable code in CoreCLR.

maybe even perf of the lookup

I think it would be the opposite. To get the IL->native mapping e.g. to print a stacktrace, we need to create DebuggerJitInfo today that is a completely unnecessary.

@noahfalk
Copy link
Member

I think it would be the opposite. To get the IL->native mapping e.g. to print a stacktrace, we need to create DebuggerJitInfo today that is a completely unnecessary.

Our concern was in the case where you repeatedly get the same stack similar to this:
microsoft/dotnet#529
Creating the DebuggerJitInfo adds some overhead to the first request, but from then on it provides a cache of uncompressed native->IL mapping info that probably improves performance (nobody has created the alternative to benchmark it so we don't know for sure). No argument that factoring this out and creating a new cache if necessary is the architecturally cleaner solution, Mike just didn't expect it to fit within his time constraints.

// RegCloseKey called by holder
return debugPackInstalled;
}

#define StartupNotifyEventNamePrefix W("TelestoStartupEvent_")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is odd that this event has Telesto in the name. Does the VS debugger still depend on this event? If yes, comment maybe useful. If not, delete it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is still used by dbgshim.dll which VS in turn uses.
https://github.com/dotnet/coreclr/blob/master/src/dlls/dbgshim/dbgshim.cpp#L724

@@ -190,7 +190,8 @@ CONFIG_DWORD_INFO_EX(INTERNAL_D__FCE, W("D::FCE"), 0, "allows an assert when cra
//
// Debugger
//
CONFIG_DWORD_INFO_EX(INTERNAL_DbgBreakIfLocksUnavailable, W("DbgBreakIfLocksUnavailable"), 0, "allows an assert when the debugger can't take a lock ", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO_EX(INTERNAL_EnableDiagnostics, W("EnableDiagnostics"), 1, "allows the debugger and profiler diagnostics to be disabled", CLRConfig::REGUTIL_default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the naming guidelines this should be EXTERNAL_EnableDiagnostics

}

if (m_pFaultingMD)
if (g_pDebugInterface != NULL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment that you aren't aware of any current scenario where g_pDebugInterface is NULL, but that we might do so in the future?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think there should be an assert that g_pDebugInterface != NULL, or simply revert the code. As-is this feels like a partial implementation. Anyone who enables g_pDebugInterface = NULL in the future needs to explicitly reconsider this code. Without more changes all the IL mappings will have been needlessly lost and that probably isn't what the future implementer will want to occur.

@@ -5247,13 +5247,12 @@ VOID ETW::MethodLog::MethodJitted(MethodDesc *pMethodDesc, SString *namespaceOrC
{
// The call to SendMethodILToNativeMapEvent assumes that the debugger's lazy
// data has already been initialized.
if (g_pDebugInterface != NULL)
{
g_pDebugInterface->InitializeLazyDataIfNecessary();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, a future implementor should be forced to explicitly consider what happens if they set g_pDebugInterface = NULL. Losing the ILToNative events implicitly seems bad.

@@ -6680,16 +6679,15 @@ VOID ETW::MethodLog::SendMethodILToNativeMapEvent(MethodDesc * pMethodDesc, DWOR
// of 64K
const USHORT kMapEntriesMax = 7000;

if (g_pDebugInterface == NULL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same thing as above, this deserves an assert or a revert to prevent accidental loss of functionality. I'll stop calling it out)

if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EnableDiagnostics) == 0)
{
return S_OK;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the jit attach cases already plumbed up to handle a missing transport? I didn't notice any changes in those code paths.

@mikem8361
Copy link
Member Author

mikem8361 commented Jan 17, 2018 via email

…ging and profiling.

To disable the named pipes and semaphores created on linux execute "export COMPlus_EnableDiagnostics=0" before start the .NET Core program.

On Windows execute "set COMPlus_EnableDiagnostics=0" and on Linux execute "export "COMPlus_EnableDiagnostics=0"

Removed the "Telesto" registry entry (old unnecessary Silverlight code) and Watson (always true) checks.

For issues #11769 and #8844.
@mikem8361
Copy link
Member Author

@jkotas, @noahfalk, I think I have addressed all the code review feedback. Sorry I squashed all the commits.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants