Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ce65fbb8
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,发现更多精彩内容 >>
提交
ce65fbb8
编写于
1月 14, 2016
作者:
T
Tomáš Matoušek
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7818 from tmat/SymWriterCleanup
ISymUnmanagedWriter cleanup
上级
4f7ee0f0
d629b535
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
113 addition
and
77 deletion
+113
-77
src/Compilers/Core/Portable/NativePdbWriter/ISymUnmanagedWriter.cs
...lers/Core/Portable/NativePdbWriter/ISymUnmanagedWriter.cs
+69
-58
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
+13
-18
src/Test/Utilities/Shared/Pdb/MockSymWriter.cs
src/Test/Utilities/Shared/Pdb/MockSymWriter.cs
+31
-1
未找到文件。
src/Compilers/Core/Portable/NativePdbWriter/ISymUnmanagedWriter.cs
浏览文件 @
ce65fbb8
...
...
@@ -14,12 +14,17 @@ internal interface ISymUnmanagedDocumentWriter
void
SetCheckSum
(
Guid
algorithmId
,
uint
checkSumSize
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
byte
[]
checkSum
);
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"0B97726E-9E6D-4f05-9A26-424022093CAA"
),
SuppressUnmanagedCodeSecurity
]
internal
interface
ISymUnmanagedWriter2
/// <summary>
/// The highest version of the interface available on Desktop FX 4.0+.
/// </summary>
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"DCF7780D-BDE9-45DF-ACFE-21731A32000C"
),
SuppressUnmanagedCodeSecurity
]
internal
interface
ISymUnmanagedWriter5
{
#
region
ISymUnmanagedWriter
ISymUnmanagedDocumentWriter
DefineDocument
(
string
url
,
ref
Guid
language
,
ref
Guid
languageVendor
,
ref
Guid
documentType
);
void
SetUserEntryPoint
(
uint
entryMethod
);
void
OpenMethod
(
uint
method
);
void
SetUserEntryPoint
(
uint
entryMethod
Token
);
void
OpenMethod
(
uint
method
Token
);
void
CloseMethod
();
uint
OpenScope
(
uint
startOffset
);
void
CloseScope
(
uint
endOffset
);
...
...
@@ -35,7 +40,7 @@ internal interface ISymUnmanagedWriter2
void
UsingNamespace
(
string
fullName
);
void
SetMethodSourceRange
(
ISymUnmanagedDocumentWriter
startDoc
,
uint
startLine
,
uint
startColumn
,
object
endDoc
,
uint
endLine
,
uint
endColumn
);
void
Initialize
([
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
emitter
,
string
filename
,
[
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
ptrIStream
,
bool
fullBuild
);
void
GetDebugInfo
(
ref
ImageDebugDirectory
ptrIDD
,
uint
dataCount
,
out
uint
dataCountPtr
,
IntPtr
data
);
void
GetDebugInfo
(
ref
ImageDebugDirectory
debugDirectory
,
uint
dataCount
,
out
uint
dataCountPtr
,
IntPtr
data
);
void
DefineSequencePoints
(
ISymUnmanagedDocumentWriter
document
,
uint
count
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
uint
[]
offsets
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
uint
[]
lines
,
...
...
@@ -46,6 +51,11 @@ internal interface ISymUnmanagedWriter2
void
Initialize2
([
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
emitter
,
string
tempfilename
,
[
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
ptrIStream
,
bool
fullBuild
,
string
finalfilename
);
void
DefineConstant
(
string
name
,
object
value
,
uint
sig
,
IntPtr
signature
);
void
Abort
();
#
endregion
#
region
ISymUnmanagedWriter2
void
DefineLocalVariable2
(
string
name
,
uint
attributes
,
uint
sigToken
,
uint
addrKind
,
uint
addr1
,
uint
addr2
,
uint
addr3
,
uint
startOffset
,
uint
endOffset
);
void
DefineGlobalVariable2
(
string
name
,
uint
attributes
,
uint
sigToken
,
uint
addrKind
,
uint
addr1
,
uint
addr2
,
uint
addr3
);
...
...
@@ -56,6 +66,59 @@ internal interface ISymUnmanagedWriter2
/// marshalled them as the number of ticks since the Unix epoch (i.e. a much, much larger number).
/// </remarks>
void
DefineConstant2
([
MarshalAs
(
UnmanagedType
.
LPWStr
)]
string
name
,
VariantStructure
value
,
uint
sigToken
);
#
endregion
#
region
ISymUnmanagedWriter3
void
OpenMethod2
(
uint
methodToken
,
int
sectionIndex
,
int
offsetRelativeOffset
);
void
Commit
();
#
endregion
#
region
ISymUnmanagedWriter4
void
GetDebugInfoWithPadding
(
ref
ImageDebugDirectory
debugDirectory
,
uint
dataCount
,
out
uint
dataCountPtr
,
IntPtr
data
);
#
endregion
#
region
ISymUnmanagedWriter5
/// <summary>
/// Open a special custom data section to emit token to source span mapping information into.
/// Opening this section while a method is already open or vice versa is an error.
/// </summary>
void
OpenMapTokensToSourceSpans
();
/// <summary>
/// Close the special custom data section for token to source span mapping
/// information. Once it is closed no more mapping information can be added.
/// </summary>
void
CloseMapTokensToSourceSpans
();
/// <summary>
/// Maps the given metadata token to the given source line span in the specified source file.
/// Must be called between calls to <see cref="OpenMapTokensToSourceSpans"/> and <see cref="CloseMapTokensToSourceSpans"/>.
/// </summary>
void
MapTokenToSourceSpan
(
uint
token
,
ISymUnmanagedDocumentWriter
document
,
uint
startLine
,
uint
startColumn
,
uint
endLine
,
uint
endColumn
);
#
endregion
}
/// <summary>
/// The highest version of the interface available in Microsoft.DiaSymReader.Native.
/// </summary>
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"22DAEAF2-70F6-4EF1-B0C3-984F0BF27BFD"
),
SuppressUnmanagedCodeSecurity
]
interface
ISymUnmanagedWriter7
:
ISymUnmanagedWriter5
{
// ISymUnmanagedWriter, ISymUnmanagedWriter2, ISymUnmanagedWriter3, ISymUnmanagedWriter4, ISymUnmanagedWriter5
void
_VtblGap1_33
();
// ISymUnmanagedWriter6
void
InitializeDeterministic
([
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
emitter
,
[
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
stream
);
// ISymUnmanagedWriter7
unsafe
void
UpdateSignatureByHashingContent
([
In
]
byte
*
buffer
,
int
size
);
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"98ECEE1E-752D-11d3-8D56-00C04F680B2B"
),
SuppressUnmanagedCodeSecurity
]
...
...
@@ -68,17 +131,7 @@ internal interface IPdbWriter
void
GetSignatureAge
(
out
uint
sig
,
out
uint
age
);
}
internal
static
class
ISymUnmanagedWriter2Helper
{
public
static
unsafe
void
DefineConstant2
(
this
ISymUnmanagedWriter2
writer
,
string
name
,
object
value
,
uint
sigToken
)
{
VariantStructure
variant
=
new
VariantStructure
();
Marshal
.
GetNativeVariantForObject
(
value
,
new
IntPtr
(&
variant
));
writer
.
DefineConstant2
(
name
,
variant
,
sigToken
);
}
}
/// <summary>
/// A struct with the same size and layout as the native VARIANT type:
/// 2 bytes for a discriminator (i.e. which type of variant it is).
...
...
@@ -132,48 +185,6 @@ internal struct VariantPadding
public
readonly
IntPtr
Data3
;
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"DCF7780D-BDE9-45DF-ACFE-21731A32000C"
),
SuppressUnmanagedCodeSecurity
]
internal
interface
ISymUnmanagedWriter5
:
ISymUnmanagedWriter2
{
// ISymUnmanagedWriter, ISymUnmanagedWriter2, ISymUnmanagedWriter3, ISymUnmanagedWriter4
void
_VtblGap1_30
();
// ISymUnmanagedWriter5
void
OpenMapTokensToSourceSpans
();
void
CloseMapTokensToSourceSpans
();
void
MapTokenToSourceSpan
(
uint
token
,
ISymUnmanagedDocumentWriter
document
,
uint
startLine
,
uint
startColumn
,
uint
endLine
,
uint
endColumn
);
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"CA6C2ED9-103D-46A9-B03B-05446485848B"
),
SuppressUnmanagedCodeSecurity
]
internal
interface
ISymUnmanagedWriter6
:
ISymUnmanagedWriter5
{
// ISymUnmanagedWriter, ISymUnmanagedWriter2, ISymUnmanagedWriter3, ISymUnmanagedWriter4, ISymUnmanagedWriter5
void
_VtblGap1_33
();
// ISymUnmanagedWriter6
void
InitializeDeterministic
([
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
emitter
,
[
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
stream
);
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"22DAEAF2-70F6-4EF1-B0C3-984F0BF27BFD"
),
SuppressUnmanagedCodeSecurity
]
interface
ISymUnmanagedWriter7
:
ISymUnmanagedWriter6
{
// ISymUnmanagedWriter, ISymUnmanagedWriter2, ISymUnmanagedWriter3, ISymUnmanagedWriter4, ISymUnmanagedWriter5, ISymUnmanagedWriter6
void
_VtblGap1_34
();
// ISymUnmanagedWriter7
unsafe
void
UpdateSignatureByHashingContent
([
In
]
byte
*
buffer
,
int
size
);
}
[
ComImport
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
),
Guid
(
"B473C610-C958-4C3D-99A0-F2BA0A38807C"
),
SuppressUnmanagedCodeSecurity
]
interface
ISymUnmanagedWriter100
:
ISymUnmanagedWriter6
{
// ISymUnmanagedWriter, ISymUnmanagedWriter2, ISymUnmanagedWriter3, ISymUnmanagedWriter4, ISymUnmanagedWriter5, ISymUnmanagedWriter6
void
_VtblGap1_34
();
// ISymUnmanagedWriter100
void
SetSignature
(
uint
sig
,
Guid
sig70
);
}
[
StructLayout
(
LayoutKind
.
Sequential
,
Pack
=
1
)]
internal
struct
ImageDebugDirectory
{
...
...
src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs
浏览文件 @
ce65fbb8
...
...
@@ -232,7 +232,7 @@ internal sealed class PdbWriter : IDisposable
private
readonly
Func
<
object
>
_symWriterFactory
;
private
ComMemoryStream
_pdbStream
;
private
MetadataWriter
_metadataWriter
;
private
ISymUnmanagedWriter
2
_symWriter
;
private
ISymUnmanagedWriter
5
_symWriter
;
private
readonly
Dictionary
<
DebugSourceDocument
,
ISymUnmanagedDocumentWriter
>
_documentMap
=
new
Dictionary
<
DebugSourceDocument
,
ISymUnmanagedDocumentWriter
>();
...
...
@@ -805,7 +805,7 @@ public void SetMetadataEmitter(MetadataWriter metadataWriter)
{
try
{
var
symWriter
=
(
ISymUnmanagedWriter
2
)(
_symWriterFactory
!=
null
?
_symWriterFactory
()
:
CreateSymWriterWorker
());
var
symWriter
=
(
ISymUnmanagedWriter
5
)(
_symWriterFactory
!=
null
?
_symWriterFactory
()
:
CreateSymWriterWorker
());
// Correctness: If the stream is not specified or if it is non-empty the SymWriter appends data to it (provided it contains valid PDB)
// and the resulting PDB has Age = existing_age + 1.
...
...
@@ -813,12 +813,12 @@ public void SetMetadataEmitter(MetadataWriter metadataWriter)
if
(
_deterministic
)
{
if
(!(
symWriter
is
ISymUnmanagedWriter7
||
symWriter
is
ISymUnmanagedWriter100
))
if
(!(
symWriter
is
ISymUnmanagedWriter7
))
{
throw
new
NotSupportedException
(
CodeAnalysisResources
.
SymWriterNotDeterministic
);
}
((
ISymUnmanagedWriter
6
)
symWriter
).
InitializeDeterministic
(
new
PdbMetadataWrapper
(
metadataWriter
),
_pdbStream
);
((
ISymUnmanagedWriter
7
)
symWriter
).
InitializeDeterministic
(
new
PdbMetadataWrapper
(
metadataWriter
),
_pdbStream
);
}
else
{
...
...
@@ -843,18 +843,6 @@ public unsafe ContentId GetContentId()
try
{
// TODO: remove once we can rely on the presence of ISymUnmanagedWriter7
var
writer100
=
_symWriter
as
ISymUnmanagedWriter100
;
if
(
writer100
!=
null
)
{
var
id
=
ContentId
.
FromHash
(
ImmutableArray
.
CreateRange
(
hash
));
Debug
.
Assert
(
BitConverter
.
IsLittleEndian
);
writer100
.
SetSignature
(
BitConverter
.
ToUInt32
(
id
.
Stamp
,
0
),
new
Guid
(
id
.
Guid
));
return
id
;
}
fixed
(
byte
*
hashPtr
=
&
hash
[
0
])
{
((
ISymUnmanagedWriter7
)
_symWriter
).
UpdateSignatureByHashingContent
(
hashPtr
,
hash
.
Length
);
...
...
@@ -1235,7 +1223,7 @@ private void DefineLocalConstant(string name, object value, PrimitiveTypeCode ty
{
try
{
_symWriter
.
DefineConstant2
(
name
,
value
,
constantSignatureToken
);
DefineLocalConstantImpl
(
name
,
value
,
constantSignatureToken
);
if
(
_callLogger
.
LogOperation
(
OP
.
DefineConstant2
))
{
_callLogger
.
LogArgument
(
name
);
...
...
@@ -1250,6 +1238,13 @@ private void DefineLocalConstant(string name, object value, PrimitiveTypeCode ty
}
}
private
unsafe
void
DefineLocalConstantImpl
(
string
name
,
object
value
,
uint
sigToken
)
{
VariantStructure
variant
=
new
VariantStructure
();
Marshal
.
GetNativeVariantForObject
(
value
,
new
IntPtr
(&
variant
));
_symWriter
.
DefineConstant2
(
name
,
variant
,
sigToken
);
}
private
void
DefineLocalStringConstant
(
string
name
,
string
value
,
uint
constantSignatureToken
)
{
Debug
.
Assert
(
value
!=
null
);
...
...
@@ -1268,7 +1263,7 @@ private void DefineLocalStringConstant(string name, string value, uint constantS
try
{
_symWriter
.
DefineConstant2
(
name
,
value
,
constantSignatureToken
);
DefineLocalConstantImpl
(
name
,
value
,
constantSignatureToken
);
if
(
_callLogger
.
LogOperation
(
OP
.
DefineConstant2
))
{
_callLogger
.
LogArgument
(
name
);
...
...
src/Test/Utilities/Shared/Pdb/MockSymWriter.cs
浏览文件 @
ce65fbb8
...
...
@@ -6,7 +6,7 @@
namespace
Roslyn.Test.Utilities
{
internal
class
MockSymUnmanagedWriter
:
ISymUnmanagedWriter
2
internal
class
MockSymUnmanagedWriter
:
ISymUnmanagedWriter
5
{
public
virtual
void
Abort
()
{
...
...
@@ -18,6 +18,11 @@ public virtual void Close()
throw
new
NotImplementedException
();
}
public
void
CloseMapTokensToSourceSpans
()
{
throw
new
NotImplementedException
();
}
public
virtual
void
CloseMethod
()
{
throw
new
NotImplementedException
();
...
...
@@ -33,6 +38,11 @@ public virtual void CloseScope(uint endOffset)
throw
new
NotImplementedException
();
}
public
void
Commit
()
{
throw
new
NotImplementedException
();
}
public
virtual
void
DefineConstant
(
string
name
,
object
value
,
uint
sig
,
IntPtr
signature
)
{
throw
new
NotImplementedException
();
...
...
@@ -88,6 +98,11 @@ public virtual void GetDebugInfo(ref ImageDebugDirectory ptrIDD, uint dataCount,
throw
new
NotImplementedException
();
}
public
void
GetDebugInfoWithPadding
(
ref
ImageDebugDirectory
debugDirectory
,
uint
dataCount
,
out
uint
dataCountPtr
,
IntPtr
data
)
{
throw
new
NotImplementedException
();
}
public
virtual
void
Initialize
([
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
emitter
,
string
filename
,
[
MarshalAs
(
UnmanagedType
.
IUnknown
)]
object
ptrIStream
,
bool
fullBuild
)
{
throw
new
NotImplementedException
();
...
...
@@ -98,11 +113,26 @@ public virtual void Initialize2([MarshalAs(UnmanagedType.IUnknown)]object emitte
throw
new
NotImplementedException
();
}
public
void
MapTokenToSourceSpan
(
uint
token
,
ISymUnmanagedDocumentWriter
document
,
uint
startLine
,
uint
startColumn
,
uint
endLine
,
uint
endColumn
)
{
throw
new
NotImplementedException
();
}
public
void
OpenMapTokensToSourceSpans
()
{
throw
new
NotImplementedException
();
}
public
virtual
void
OpenMethod
(
uint
method
)
{
throw
new
NotImplementedException
();
}
public
void
OpenMethod2
(
uint
methodToken
,
int
sectionIndex
,
int
offsetRelativeOffset
)
{
throw
new
NotImplementedException
();
}
public
virtual
void
OpenNamespace
(
string
name
)
{
throw
new
NotImplementedException
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录