Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StackFrameHelper.cs
Go to the documentation of this file.
3
4namespace System.Diagnostics;
5
6internal sealed class StackFrameHelper
7{
8 private delegate void GetSourceLineInfoDelegate(Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, bool isFileLayout, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string sourceFile, out int sourceLine, out int sourceColumn);
9
11
12 private int[] rgiOffset;
13
14 private int[] rgiILOffset;
15
16 private object dynamicMethods;
17
19
20 private string[] rgAssemblyPath;
21
23
25
26 private int[] rgiLoadedPeSize;
27
28 private bool[] rgiIsFileLayout;
29
31
32 private int[] rgiInMemoryPdbSize;
33
34 private int[] rgiMethodToken;
35
36 private string[] rgFilename;
37
38 private int[] rgiLineNumber;
39
40 private int[] rgiColumnNumber;
41
43
44 private int iFrameCount;
45
47
48 [ThreadStatic]
49 private static int t_reentrancy;
50
51 public StackFrameHelper(Thread target)
52 {
53 targetThread = target;
54 rgMethodHandle = null;
55 rgiMethodToken = null;
56 rgiOffset = null;
57 rgiILOffset = null;
58 rgAssemblyPath = null;
59 rgAssembly = null;
60 rgLoadedPeAddress = null;
61 rgiLoadedPeSize = null;
62 rgiIsFileLayout = null;
64 rgiInMemoryPdbSize = null;
65 dynamicMethods = null;
66 rgFilename = null;
67 rgiLineNumber = null;
68 rgiColumnNumber = null;
70 iFrameCount = 0;
71 }
72
73 internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception exception)
74 {
75 StackTrace.GetStackFramesInternal(this, iSkip, fNeedFileInfo, exception);
76 if (!fNeedFileInfo || t_reentrancy > 0)
77 {
78 return;
79 }
81 try
82 {
83 if (s_getSourceLineInfo == null)
84 {
85 Type type = Type.GetType("System.Diagnostics.StackTraceSymbols, System.Diagnostics.StackTrace, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
86 if (type == null)
87 {
88 return;
89 }
90 Type[] types = new Type[12]
91 {
92 typeof(Assembly),
93 typeof(string),
94 typeof(IntPtr),
95 typeof(int),
96 typeof(bool),
97 typeof(IntPtr),
98 typeof(int),
99 typeof(int),
100 typeof(int),
101 typeof(string).MakeByRefType(),
102 typeof(int).MakeByRefType(),
103 typeof(int).MakeByRefType()
104 };
105 MethodInfo method = type.GetMethod("GetSourceLineInfo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, types, null);
106 if (method == null)
107 {
108 return;
109 }
110 object target = Activator.CreateInstance(type);
113 }
114 for (int i = 0; i < iFrameCount; i++)
115 {
116 if (rgiMethodToken[i] != 0)
117 {
119 }
120 }
121 }
122 catch
123 {
124 }
125 finally
126 {
127 t_reentrancy--;
128 }
129 }
130
132 {
133 IntPtr intPtr = rgMethodHandle[i];
134 if (intPtr == IntPtr.Zero)
135 {
136 return null;
137 }
139 return RuntimeType.GetMethodBase(typicalMethodDefinition);
140 }
141
142 public int GetOffset(int i)
143 {
144 return rgiOffset[i];
145 }
146
147 public int GetILOffset(int i)
148 {
149 return rgiILOffset[i];
150 }
151
152 public string GetFilename(int i)
153 {
154 string[] array = rgFilename;
155 if (array == null)
156 {
157 return null;
158 }
159 return array[i];
160 }
161
162 public int GetLineNumber(int i)
163 {
164 if (rgiLineNumber != null)
165 {
166 return rgiLineNumber[i];
167 }
168 return 0;
169 }
170
171 public int GetColumnNumber(int i)
172 {
173 if (rgiColumnNumber != null)
174 {
175 return rgiColumnNumber[i];
176 }
177 return 0;
178 }
179
181 {
183 {
185 }
186 return false;
187 }
188
189 public int GetNumberOfFrames()
190 {
191 return iFrameCount;
192 }
193}
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
static GetSourceLineInfoDelegate s_getSourceLineInfo
void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception exception)
delegate void GetSourceLineInfoDelegate(Assembly assembly, string assemblyPath, IntPtr loadedPeAddress, int loadedPeSize, bool isFileLayout, IntPtr inMemoryPdbAddress, int inMemoryPdbSize, int methodToken, int ilOffset, out string sourceFile, out int sourceLine, out int sourceColumn)
static void GetStackFramesInternal(StackFrameHelper sfh, int iSkip, bool fNeedFileInfo, Exception e)
virtual Delegate CreateDelegate(Type delegateType)
Definition MethodInfo.cs:48
static MethodBase GetMethodBase(RuntimeModule scope, int typeMetadataToken)
static int CompareExchange(ref int location1, int value, int comparand)
static ? Type GetType(string typeName, bool throwOnError, bool ignoreCase)
Definition Type.cs:408
virtual Type MakeByRefType()
Definition Type.cs:1068
static readonly IntPtr Zero
Definition IntPtr.cs:18
static void GetTypicalMethodDefinition(RuntimeMethodHandleInternal method, ObjectHandleOnStack outMethod)