-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathSymUnmanagedExtensions.Method.cs
More file actions
184 lines (155 loc) · 6.17 KB
/
Copy pathSymUnmanagedExtensions.Method.cs
File metadata and controls
184 lines (155 loc) · 6.17 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// 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.txt file in the project root for more information.
using System;
using System.Collections.Generic;
namespace Microsoft.DiaSymReader
{
using static InteropUtilities;
partial class SymUnmanagedExtensions
{
public static ISymUnmanagedDocument[] GetDocumentsForMethod(this ISymUnmanagedMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
return NullToEmpty(GetItems((ISymEncUnmanagedMethod)method,
(ISymEncUnmanagedMethod a, out int b) => a.GetDocumentsForMethodCount(out b),
(ISymEncUnmanagedMethod a, int b, out int c, ISymUnmanagedDocument[] d) => a.GetDocumentsForMethod(b, out c, d)));
}
public static void GetSourceExtentInDocument(this ISymEncUnmanagedMethod method, ISymUnmanagedDocument document, out int startLine, out int endLine)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ThrowExceptionForHR(method.GetSourceExtentInDocument(document, out startLine, out endLine));
}
public static int GetToken(this ISymUnmanagedMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ThrowExceptionForHR(method.GetToken(out int token));
return token;
}
public static int GetLocalSignatureToken(this ISymUnmanagedMethod2 method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ThrowExceptionForHR(method.GetLocalSignatureToken(out int token));
return token;
}
public static ISymUnmanagedScope GetRootScope(this ISymUnmanagedMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
ThrowExceptionForHR(method.GetRootScope(out var scope));
return scope;
}
public static IEnumerable<SymUnmanagedSequencePoint> GetSequencePoints(this ISymUnmanagedMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
// NB: method.GetSequencePoints(0, out numAvailable, ...) always returns 0.
int numAvailable;
ThrowExceptionForHR(method.GetSequencePointCount(out numAvailable));
if (numAvailable == 0)
{
yield break;
}
int[] offsets = new int[numAvailable];
ISymUnmanagedDocument[] documents = new ISymUnmanagedDocument[numAvailable];
int[] startLines = new int[numAvailable];
int[] startColumns = new int[numAvailable];
int[] endLines = new int[numAvailable];
int[] endColumns = new int[numAvailable];
int numRead;
ThrowExceptionForHR(method.GetSequencePoints(numAvailable, out numRead, offsets, documents, startLines, startColumns, endLines, endColumns));
ValidateItems(numRead, offsets.Length);
for (int i = 0; i < numRead; i++)
{
yield return new SymUnmanagedSequencePoint(
offsets[i],
documents[i],
startLines[i],
startColumns[i],
endLines[i],
endColumns[i]);
}
}
public static ISymUnmanagedAsyncMethod? AsAsyncMethod(this ISymUnmanagedMethod method)
{
var asyncMethod = method as ISymUnmanagedAsyncMethod;
if (asyncMethod == null)
{
return null;
}
bool isAsyncMethod;
ThrowExceptionForHR(asyncMethod.IsAsyncMethod(out isAsyncMethod));
if (!isAsyncMethod)
{
return null;
}
return asyncMethod;
}
public static int GetCatchHandlerILOffset(this ISymUnmanagedAsyncMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
bool hasCatchHandler;
ThrowExceptionForHR(method.HasCatchHandlerILOffset(out hasCatchHandler));
if (!hasCatchHandler)
{
return -1;
}
int result;
ThrowExceptionForHR(method.GetCatchHandlerILOffset(out result));
return result;
}
public static int GetKickoffMethod(this ISymUnmanagedAsyncMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
int result;
ThrowExceptionForHR(method.GetKickoffMethod(out result));
return result;
}
public static IEnumerable<SymUnmanagedAsyncStepInfo> GetAsyncStepInfos(this ISymUnmanagedAsyncMethod method)
{
if (method == null)
{
throw new ArgumentNullException(nameof(method));
}
int count;
ThrowExceptionForHR(method.GetAsyncStepInfoCount(out count));
if (count == 0)
{
yield break;
}
var yieldOffsets = new int[count];
var breakpointOffsets = new int[count];
var breakpointMethods = new int[count];
ThrowExceptionForHR(method.GetAsyncStepInfo(count, out count, yieldOffsets, breakpointOffsets, breakpointMethods));
ValidateItems(count, yieldOffsets.Length);
ValidateItems(count, breakpointOffsets.Length);
ValidateItems(count, breakpointMethods.Length);
for (int i = 0; i < count; i++)
{
yield return new SymUnmanagedAsyncStepInfo(yieldOffsets[i], breakpointOffsets[i], breakpointMethods[i]);
}
}
}
}