Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
65bacf87
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
65bacf87
编写于
9月 25, 2015
作者:
C
Charles Stoner
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5453 from cston/pfn
Fix function pointer representation
上级
4c98b4b9
1882b7f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
70 addition
and
32 deletion
+70
-32
src/ExpressionEvaluator/CSharp/Test/ResultProvider/FunctionPointerTests.cs
...luator/CSharp/Test/ResultProvider/FunctionPointerTests.cs
+54
-21
src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs
...r/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs
+16
-11
未找到文件。
src/ExpressionEvaluator/CSharp/Test/ResultProvider/FunctionPointerTests.cs
浏览文件 @
65bacf87
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
using
Microsoft.CodeAnalysis.ExpressionEvaluator
;
using
Microsoft.CodeAnalysis.ExpressionEvaluator
;
using
Microsoft.VisualStudio.Debugger.Clr
;
using
Microsoft.VisualStudio.Debugger.Clr
;
using
Microsoft.VisualStudio.Debugger.Evaluation
;
using
Microsoft.VisualStudio.Debugger.Evaluation
;
using
Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation
;
using
Microsoft.VisualStudio.Debugger.Metadata
;
using
System
;
using
System
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
Xunit
;
using
Xunit
;
...
@@ -12,40 +14,71 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
...
@@ -12,40 +14,71 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
{
public
class
FunctionPointerTests
:
CSharpResultProviderTestBase
public
class
FunctionPointerTests
:
CSharpResultProviderTestBase
{
{
[
Fact
(
Skip
=
"Tests are failing in Jenkins queues"
)
]
[
Fact
]
public
void
Root
()
public
void
Root
()
{
{
const
int
ptr
=
0x1234
;
var
source
=
var
value
=
CreateDkmClrValue
(
ptr
,
type
:
new
DkmClrType
(
FunctionPointerType
.
Instance
));
@"unsafe class C
var
evalResult
=
FormatResult
(
"pfn"
,
value
);
{
Verify
(
evalResult
,
internal C(long p)
EvalResult
(
"pfn"
,
PointerToString
(
new
IntPtr
(
ptr
)),
"System.Object*"
,
"pfn"
,
DkmEvaluationResultFlags
.
None
,
DkmEvaluationResultCategory
.
Other
));
{
this.pfn = (int*)p;
}
int* pfn;
}"
;
var
assembly
=
GetUnsafeAssembly
(
source
);
unsafe
{
int
i
=
0x1234
;
long
ptr
=
(
long
)&
i
;
var
type
=
assembly
.
GetType
(
"C"
);
var
value
=
GetFunctionPointerField
(
CreateDkmClrValue
(
type
.
Instantiate
(
ptr
)),
"pfn"
);
var
evalResult
=
FormatResult
(
"pfn"
,
value
);
Verify
(
evalResult
,
EvalResult
(
"pfn"
,
PointerToString
(
new
IntPtr
(
ptr
)),
"System.Object*"
,
"pfn"
,
DkmEvaluationResultFlags
.
None
,
DkmEvaluationResultCategory
.
Other
));
}
}
}
[
Fact
(
Skip
=
"Tests are failing in Jenkins queues"
)
]
[
Fact
]
public
void
Member
()
public
void
Member
()
{
{
var
source
=
var
source
=
@"class C
@"
unsafe
class C
{
{
object pfn;
internal C(long p)
{
this.pfn = (int*)p;
}
int* pfn;
}"
;
}"
;
const
int
ptr
=
0x0
;
var
assembly
=
GetUnsafeAssembly
(
source
);
GetMemberValueDelegate
getMemberValue
=
(
v
,
m
)
=>
(
m
==
"pfn"
)
?
CreateDkmClrValue
(
ptr
,
type
:
new
DkmClrType
(
FunctionPointerType
.
Instance
))
:
null
;
unsafe
var
runtime
=
new
DkmClrRuntimeInstance
(
ReflectionUtilities
.
GetMscorlibAndSystemCore
(
GetAssembly
(
source
)),
getMemberValue
:
getMemberValue
);
using
(
runtime
.
Load
())
{
{
var
type
=
runtime
.
GetType
(
"C"
);
const
long
ptr
=
0x0
;
var
value
=
CreateDkmClrValue
(
type
.
Instantiate
(),
type
:
type
);
GetMemberValueDelegate
getMemberValue
=
(
v
,
m
)
=>
(
m
==
"pfn"
)
?
GetFunctionPointerField
(
v
,
m
)
:
null
;
var
evalResult
=
FormatResult
(
"o"
,
value
);
var
runtime
=
new
DkmClrRuntimeInstance
(
ReflectionUtilities
.
GetMscorlibAndSystemCore
(
assembly
),
getMemberValue
:
getMemberValue
);
Verify
(
evalResult
,
using
(
runtime
.
Load
())
EvalResult
(
"o"
,
"{C}"
,
"C"
,
"o"
,
DkmEvaluationResultFlags
.
Expandable
,
DkmEvaluationResultCategory
.
Other
));
{
var
children
=
GetChildren
(
evalResult
);
var
type
=
runtime
.
GetType
(
"C"
);
Verify
(
children
,
var
value
=
CreateDkmClrValue
(
type
.
Instantiate
(
ptr
),
type
);
EvalResult
(
"pfn"
,
PointerToString
(
new
IntPtr
(
ptr
)),
"object {System.Object*}"
,
"o.pfn"
,
DkmEvaluationResultFlags
.
None
,
DkmEvaluationResultCategory
.
Other
));
var
evalResult
=
FormatResult
(
"o"
,
value
);
Verify
(
evalResult
,
EvalResult
(
"o"
,
"{C}"
,
"C"
,
"o"
,
DkmEvaluationResultFlags
.
Expandable
,
DkmEvaluationResultCategory
.
Other
));
var
children
=
GetChildren
(
evalResult
);
Verify
(
children
,
EvalResult
(
"pfn"
,
PointerToString
(
new
IntPtr
(
ptr
)),
"int*"
,
"o.pfn"
,
DkmEvaluationResultFlags
.
None
,
DkmEvaluationResultCategory
.
Other
));
}
}
}
}
}
private
DkmClrValue
GetFunctionPointerField
(
DkmClrValue
value
,
string
fieldName
)
{
var
valueType
=
value
.
Type
.
GetLmrType
();
var
fieldInfo
=
valueType
.
GetField
(
fieldName
,
BindingFlags
.
Instance
|
BindingFlags
.
Public
|
BindingFlags
.
NonPublic
);
var
fieldValue
=
fieldInfo
.
GetValue
(
value
.
RawValue
);
return
CreateDkmClrValue
(
DkmClrValue
.
UnboxPointer
(
fieldValue
),
new
DkmClrType
(
FunctionPointerType
.
Instance
));
}
// Function pointer type has IsPointer == true and GetElementType() == null.
// Function pointer type has IsPointer == true and GetElementType() == null.
private
sealed
class
FunctionPointerType
:
TypeImpl
private
sealed
class
FunctionPointerType
:
TypeImpl
{
{
...
...
src/ExpressionEvaluator/Core/Test/ResultProvider/Debugger/Engine/DkmClrValue.cs
浏览文件 @
65bacf87
...
@@ -501,17 +501,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare
...
@@ -501,17 +501,7 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare
Type
type
;
Type
type
;
if
(
value
is
System
.
Reflection
.
Pointer
)
if
(
value
is
System
.
Reflection
.
Pointer
)
{
{
unsafe
value
=
UnboxPointer
(
value
);
{
if
(
Environment
.
Is64BitProcess
)
{
value
=
(
long
)
System
.
Reflection
.
Pointer
.
Unbox
(
value
);
}
else
{
value
=
(
int
)
System
.
Reflection
.
Pointer
.
Unbox
(
value
);
}
}
type
=
declaredType
;
type
=
declaredType
;
}
}
else
if
(
value
==
null
||
declaredType
.
IsNullable
())
else
if
(
value
==
null
||
declaredType
.
IsNullable
())
...
@@ -535,6 +525,21 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare
...
@@ -535,6 +525,21 @@ public DkmClrValue GetMemberValue(string MemberName, int MemberType, string Pare
access
:
access
);
access
:
access
);
}
}
internal
static
unsafe
object
UnboxPointer
(
object
value
)
{
unsafe
{
if
(
Environment
.
Is64BitProcess
)
{
return
(
long
)
System
.
Reflection
.
Pointer
.
Unbox
(
value
);
}
else
{
return
(
int
)
System
.
Reflection
.
Pointer
.
Unbox
(
value
);
}
}
}
public
DkmClrValue
GetArrayElement
(
int
[]
indices
,
DkmInspectionContext
inspectionContext
)
public
DkmClrValue
GetArrayElement
(
int
[]
indices
,
DkmInspectionContext
inspectionContext
)
{
{
if
(
inspectionContext
==
null
)
if
(
inspectionContext
==
null
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录