Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
bingbingbingbing
mono
提交
4e29e54e
M
mono
项目概览
bingbingbingbing
/
mono
与 Fork 源项目一致
从无法访问的项目Fork
通知
35
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mono
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4e29e54e
编写于
7月 12, 2019
作者:
T
Tautvydas Žilys
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make ETW event registering AOT friendly.
上级
92839420
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
17 deletion
+46
-17
mcs/class/corlib/corlib-net_4_x.csproj
mcs/class/corlib/corlib-net_4_x.csproj
+2
-1
mcs/class/referencesource/mscorlib/system/diagnostics/eventing/eventprovider.cs
...rce/mscorlib/system/diagnostics/eventing/eventprovider.cs
+44
-16
未找到文件。
mcs/class/corlib/corlib-net_4_x.csproj
浏览文件 @
4e29e54e
...
...
@@ -292,7 +292,8 @@
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\conditionalattribute.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\contracts\contracts.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\contracts\contractsbcl.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\debuggerattributes.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\eventing\activitytracker.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\debuggerattributes.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\eventing\activitytracker.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\eventing\eventactivityoptions.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\eventing\eventdescriptor.cs"
/>
<Compile
Include=
"..\referencesource\mscorlib\system\diagnostics\eventing\eventprovider.cs"
/>
...
...
mcs/class/referencesource/mscorlib/system/diagnostics/eventing/eventprovider.cs
浏览文件 @
4e29e54e
...
...
@@ -78,6 +78,7 @@ namespace System.Diagnostics.Tracing
[
SecurityCritical
]
UnsafeNativeMethods
.
ManifestEtw
.
EtwEnableCallback
m_etwCallback
;
// Trace Callback function
GCHandle
m_thisGCHandle
;
private
long
m_regHandle
;
// Trace Registration Handle
private
byte
m_level
;
// Tracing Level
private
long
m_anyKeywordMask
;
// Trace Enable Flags
...
...
@@ -149,13 +150,25 @@ namespace System.Diagnostics.Tracing
internal
unsafe
void
Register
(
Guid
providerGuid
)
{
m_providerId
=
providerGuid
;
uint
status
;
m_etwCallback
=
new
UnsafeNativeMethods
.
ManifestEtw
.
EtwEnableCallback
(
EtwEnableCallBack
);
status
=
EventRegister
(
ref
m_providerId
,
m_etwCallback
);
if
(
status
!=
0
)
if
(
m_thisGCHandle
.
IsAllocated
)
m_thisGCHandle
.
Free
();
m_thisGCHandle
=
GCHandle
.
Alloc
(
this
);
try
{
var
status
=
UnsafeNativeMethods
.
ManifestEtw
.
EventRegister
(
ref
providerGuid
,
m_etwCallback
,
GCHandle
.
ToIntPtr
(
m_thisGCHandle
).
ToPointer
(),
ref
m_regHandle
);
if
(
status
!=
0
)
{
throw
new
ArgumentException
(
Win32Native
.
GetMessage
(
unchecked
((
int
)
status
)));
}
}
catch
{
throw
new
ArgumentException
(
Win32Native
.
GetMessage
(
unchecked
((
int
)
status
)));
m_thisGCHandle
.
Free
();
throw
;
}
}
...
...
@@ -264,22 +277,44 @@ namespace System.Diagnostics.Tracing
{
EventUnregister
();
m_regHandle
=
0
;
m_thisGCHandle
.
Free
();
}
}
[
AttributeUsage
(
AttributeTargets
.
Method
)]
private
sealed
class
MonoPInvokeCallbackAttribute
:
Attribute
{
public
MonoPInvokeCallbackAttribute
(
Type
t
)
{
}
}
[
MonoPInvokeCallback
(
typeof
(
UnsafeNativeMethods
.
ManifestEtw
.
EtwEnableCallback
))]
unsafe
static
void
EtwEnableCallBack
(
[
In
]
ref
System
.
Guid
sourceId
,
[
In
]
int
controlCode
,
[
In
]
byte
setLevel
,
[
In
]
long
anyKeyword
,
[
In
]
long
allKeyword
,
[
In
]
UnsafeNativeMethods
.
ManifestEtw
.
EVENT_FILTER_DESCRIPTOR
*
filterData
,
[
In
]
void
*
callbackContext
)
{
var
_this
=
(
EventProvider
)
GCHandle
.
FromIntPtr
(
new
IntPtr
(
callbackContext
)).
Target
;
_this
.
EtwEnableCallBackImpl
(
controlCode
,
setLevel
,
anyKeyword
,
allKeyword
,
filterData
);
}
// <SecurityKernel Critical="True" Ring="0">
// <UsesUnsafeCode Name="Parameter filterData of type: Void*" />
// <UsesUnsafeCode Name="Parameter callbackContext of type: Void*" />
// </SecurityKernel>
[
System
.
Security
.
SecurityCritical
]
unsafe
void
EtwEnableCallBack
(
[
In
]
ref
System
.
Guid
sourceId
,
unsafe
void
EtwEnableCallBackImpl
(
[
In
]
int
controlCode
,
[
In
]
byte
setLevel
,
[
In
]
long
anyKeyword
,
[
In
]
long
allKeyword
,
[
In
]
UnsafeNativeMethods
.
ManifestEtw
.
EVENT_FILTER_DESCRIPTOR
*
filterData
,
[
In
]
void
*
callbackContext
[
In
]
UnsafeNativeMethods
.
ManifestEtw
.
EVENT_FILTER_DESCRIPTOR
*
filterData
)
{
// This is an optional callback API. We will therefore ignore any failures that happen as a
...
...
@@ -539,7 +574,7 @@ namespace System.Diagnostics.Tracing
dataStart
=
0
;
if
(
filterData
==
null
)
{
#if !ES_BUILD_PCL
#if !ES_BUILD_PCL
&& !MONO
string
regKey
=
@"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{"
+
m_providerId
+
"}"
;
if
(
System
.
Runtime
.
InteropServices
.
Marshal
.
SizeOf
(
typeof
(
IntPtr
))
==
8
)
regKey
=
@"HKEY_LOCAL_MACHINE\Software"
+
@"\Wow6432Node"
+
regKey
;
...
...
@@ -1161,13 +1196,6 @@ namespace System.Diagnostics.Tracing
// These are look-alikes to the Manifest based ETW OS APIs that have been shimmed to work
// either with Manifest ETW or Classic ETW (if Manifest based ETW is not available).
[
SecurityCritical
]
private
unsafe
uint
EventRegister
(
ref
Guid
providerId
,
UnsafeNativeMethods
.
ManifestEtw
.
EtwEnableCallback
enableCallback
)
{
m_providerId
=
providerId
;
m_etwCallback
=
enableCallback
;
return
UnsafeNativeMethods
.
ManifestEtw
.
EventRegister
(
ref
providerId
,
enableCallback
,
null
,
ref
m_regHandle
);
}
[
SecurityCritical
]
private
uint
EventUnregister
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录