blob: f3d13b8f9e9d28c0d36f3fe09c11b9e75b067db2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// ProfDetach.h
//
//
// Declaration of helper classes and structures used for Profiling API Detaching
//
// ======================================================================================
#ifndef __PROFDETACH_H__
#define __PROFDETACH_H__
#ifdef FEATURE_PROFAPI_ATTACH_DETACH
// The struct below is the medium by which RequestProfilerDetach communicates with
// the DetachThread about a profiler being detached. Initial core attach /
// detach feature crew will have only one global instance of this struct.
// When we allow re-attach with neutered profilers, there will likely be a
// linked list of these, one per profiler in the act of being detached.
struct ProfilerDetachInfo
{
ProfilerDetachInfo();
void Init();
// NULL if we're not trying to detach a profiler. Otherwise, this is the
// EEToProfInterfaceImpl instance we're detaching.
//
// FUTURE: Although m_pEEToProf, when non-NULL, is always the same as
// g_profControlBlock.pProfInterface, that will no longer be the case once we allow
// re-attach with neutered profilers.
EEToProfInterfaceImpl * m_pEEToProf;
// Time when profiler originally called RequestProfilerDetach()
ULONGLONG m_ui64DetachStartTime;
// # milliseconds hint profiler specified in RequestProfilerDetach()
DWORD m_dwExpectedCompletionMilliseconds;
};
//--------------------------------------------------------------------------
// Static-only class to coordinate initialization of the various profiling
// API detaching structures, plus other utility stuff.
//
class ProfilingAPIDetach
{
public:
static HRESULT Initialize();
static HRESULT RequestProfilerDetach(DWORD dwExpectedCompletionMilliseconds);
static HRESULT CreateDetachThread();
static DWORD WINAPI ProfilingAPIDetachThreadStart(LPVOID lpParameter);
static void ExecuteEvacuationLoop();
static BOOL IsProfilerEvacuated();
static EEToProfInterfaceImpl * GetEEToProfPtr();
private:
static ProfilerDetachInfo s_profilerDetachInfo;
// Signaled by RequestProfilerDetach() when there is detach work ready to be
// done by the DetachThread
static CLREvent s_eventDetachWorkAvailable;
static void SleepWhileProfilerEvacuates();
static void UnloadProfiler();
// Prevent instantiation of ProfilingAPIDetach objects (should be static-only)
ProfilingAPIDetach();
~ProfilingAPIDetach();
};
#endif // FEATURE_PROFAPI_ATTACH_DETACH
#endif //__PROFDETACH_H__
|