@@ -44,8 +44,11 @@ STDMETHODIMP MainProfiler::Shutdown()
44
44
m_pLogger.reset ();
45
45
m_pEnvironment.reset ();
46
46
47
- m_pProbeInstrumentation->ShutdownBackgroundService ();
48
- m_pProbeInstrumentation.reset ();
47
+ if (m_pProbeInstrumentation)
48
+ {
49
+ m_pProbeInstrumentation->ShutdownBackgroundService ();
50
+ m_pProbeInstrumentation.reset ();
51
+ }
49
52
50
53
_commandServer->Shutdown ();
51
54
_commandServer.reset ();
@@ -169,9 +172,6 @@ HRESULT MainProfiler::InitializeCommon()
169
172
IfNullRet (_exceptionTracker);
170
173
#endif // DOTNETMONITOR_FEATURE_EXCEPTIONS
171
174
172
- m_pProbeInstrumentation.reset (new (nothrow) ProbeInstrumentation (m_pLogger, m_pCorProfilerInfo));
173
- IfNullRet (m_pProbeInstrumentation);
174
-
175
175
// Set product version environment variable to allow discovery of if the profiler
176
176
// as been applied to a target process. Diagnostic tools must use the diagnostic
177
177
// communication channel's GetProcessEnvironment command to get this value.
@@ -184,15 +184,29 @@ HRESULT MainProfiler::InitializeCommon()
184
184
#endif // DOTNETMONITOR_FEATURE_EXCEPTIONS
185
185
StackSampler::AddProfilerEventMask (eventsLow);
186
186
187
- m_pProbeInstrumentation->AddProfilerEventMask (eventsLow);
188
-
189
187
_threadNameCache = make_shared<ThreadNameCache>();
190
188
189
+ bool enableParameterCapturing;
190
+ IfFailLogRet (_environmentHelper->GetIsParameterCapturingEnabled (enableParameterCapturing));
191
+ if (enableParameterCapturing)
192
+ {
193
+ m_pProbeInstrumentation.reset (new (nothrow) ProbeInstrumentation (m_pLogger, m_pCorProfilerInfo));
194
+ IfNullRet (m_pProbeInstrumentation);
195
+ m_pProbeInstrumentation->AddProfilerEventMask (eventsLow);
196
+ }
197
+ else
198
+ {
199
+ ProbeInstrumentation::DisableIncomingRequests ();
200
+ }
201
+
191
202
IfFailRet (m_pCorProfilerInfo->SetEventMask2 (
192
203
eventsLow,
193
204
COR_PRF_HIGH_MONITOR::COR_PRF_HIGH_MONITOR_NONE));
194
205
195
- IfFailLogRet (m_pProbeInstrumentation->InitBackgroundService ());
206
+ if (enableParameterCapturing)
207
+ {
208
+ IfFailLogRet (m_pProbeInstrumentation->InitBackgroundService ());
209
+ }
196
210
197
211
// Initialize this last. The CommandServer creates secondary threads, which will be difficult to cleanup if profiler initialization fails.
198
212
IfFailLogRet (InitializeCommandServer ());
@@ -330,5 +344,10 @@ HRESULT MainProfiler::ProcessCallstackMessage()
330
344
331
345
HRESULT STDMETHODCALLTYPE MainProfiler::GetReJITParameters (ModuleID moduleId, mdMethodDef methodId, ICorProfilerFunctionControl* pFunctionControl)
332
346
{
333
- return m_pProbeInstrumentation->GetReJITParameters (moduleId, methodId, pFunctionControl);
347
+ if (m_pProbeInstrumentation)
348
+ {
349
+ return m_pProbeInstrumentation->GetReJITParameters (moduleId, methodId, pFunctionControl);
350
+ }
351
+
352
+ return S_OK;
334
353
}
0 commit comments