public MethodDescInfo(long id, TraceMethodData methodIDDetailsTraceData) { ID = id; MethodDetailsTraceData = methodIDDetailsTraceData; }
public TraceRuntimeDescToTypeSystemDesc(TraceProcess traceProcess, TypeSystemContext context, int clrInstanceID) { _traceProcess = traceProcess; _context = context; _clrInstanceID = clrInstanceID; foreach (var methodIDDetailsData in traceProcess.EventsInProcess.ByEventType <MethodDetailsTraceData>()) { MethodDescInfo currentInfo; if (_methods.TryGetValue(methodIDDetailsData.MethodID, out currentInfo)) { if (currentInfo.MethodDetailsTraceData.LoaderModuleID != methodIDDetailsData.LoaderModuleID) { throw new Exception("Re-use of MethodID with different data. Unload scenario?)"); } if (currentInfo.MethodDetailsTraceData.MethodToken != methodIDDetailsData.MethodToken) { throw new Exception("Re-use of MethodID with different data. Unload scenario?)"); } if (currentInfo.MethodDetailsTraceData.TypeID != methodIDDetailsData.TypeID) { throw new Exception("Re-use of MethodID with different data. Unload scenario?)"); } if (currentInfo.MethodDetailsTraceData.TypeParameters.Length != methodIDDetailsData.TypeParameterCount) { throw new Exception("Re-use of MethodID with different data. Unload scenario?)"); } for (int ix = 0; ix < methodIDDetailsData.TypeParameterCount; ix++) { if (currentInfo.MethodDetailsTraceData.TypeParameters[ix] != (long)methodIDDetailsData.TypeParameters(ix)) { throw new Exception("Re-use of MethodID with different data. Unload scenario?)"); } } continue; } long[] typeParameters = Array.Empty <long>(); if (methodIDDetailsData.TypeParameterCount != 0) { typeParameters = new long[methodIDDetailsData.TypeParameterCount]; for (int ix = 0; ix < typeParameters.Length; ix++) { typeParameters[ix] = (long)methodIDDetailsData.TypeParameters(ix); } } else { typeParameters = Array.Empty <long>(); } TraceMethodData traceMethodData = new TraceMethodData(typeID: (long)methodIDDetailsData.TypeID, loaderModuleID: methodIDDetailsData.LoaderModuleID, methodToken: methodIDDetailsData.MethodToken, typeParameters: typeParameters); currentInfo = new MethodDescInfo(methodIDDetailsData.MethodID, traceMethodData); _methods.Add(methodIDDetailsData.MethodID, currentInfo); } foreach (var bulkTypeTrace in traceProcess.EventsInProcess.ByEventType <GCBulkTypeTraceData>()) { s_bulkTypeEvents++; if (bulkTypeTrace.ClrInstanceID != _clrInstanceID) { continue; } for (int i = 0; i < bulkTypeTrace.Count; i++) { TypeHandleInfo currentInfo; var typeTrace = bulkTypeTrace.Values(i); s_bulkTypeTypes++; if (_types.TryGetValue((long)typeTrace.TypeID, out currentInfo)) { if (currentInfo.TypeValue.ModuleID != (long)typeTrace.ModuleID) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } if (currentInfo.TypeValue.TypeNameID != typeTrace.TypeNameID) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } if (currentInfo.TypeValue.Flags != typeTrace.Flags) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } if (currentInfo.TypeValue.CorElementType != typeTrace.CorElementType) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } if (currentInfo.TypeValue.TypeParameters.Length != typeTrace.TypeParameterCount) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } for (int ix = 0; ix < typeTrace.TypeParameterCount; ix++) { if (currentInfo.TypeValue.TypeParameters[ix] != (long)typeTrace.TypeParameterID(ix)) { throw new Exception("Re-use of TypeID with different data. Unload scenario?)"); } } continue; } long[] typeParameters = Array.Empty <long>(); if (typeTrace.TypeParameterCount != 0) { typeParameters = new long[typeTrace.TypeParameterCount]; for (int ix = 0; ix < typeParameters.Length; ix++) { typeParameters[ix] = (long)typeTrace.TypeParameterID(ix); } } else { typeParameters = Array.Empty <long>(); } TraceTypeData traceTypeData = new TraceTypeData(moduleID: (long)typeTrace.ModuleID, typeNameID: typeTrace.TypeNameID, flags: typeTrace.Flags, corElementType: typeTrace.CorElementType, typeParameters: typeParameters, name: typeTrace.TypeName); currentInfo = new TypeHandleInfo((long)typeTrace.TypeID, traceTypeData); _types.Add((long)typeTrace.TypeID, currentInfo); } } Dictionary <long, int> assemblyToCLRInstanceIDMap = new Dictionary <long, int>(); Dictionary <long, string> assemblyToFullyQualifiedAssemblyName = new Dictionary <long, string>(); Dictionary <long, bool> assemblyToIsDynamic = new Dictionary <long, bool>(); foreach (var assemblyLoadTrace in _traceProcess.EventsInProcess.ByEventType <AssemblyLoadUnloadTraceData>()) { assemblyToCLRInstanceIDMap[assemblyLoadTrace.AssemblyID] = assemblyLoadTrace.ClrInstanceID; assemblyToFullyQualifiedAssemblyName[assemblyLoadTrace.AssemblyID] = assemblyLoadTrace.FullyQualifiedAssemblyName; assemblyToIsDynamic[assemblyLoadTrace.AssemblyID] = ((assemblyLoadTrace.AssemblyFlags & Tracing.Parsers.Clr.AssemblyFlags.Dynamic) == Tracing.Parsers.Clr.AssemblyFlags.Dynamic); } foreach (var moduleFile in _traceProcess.LoadedModules) { if (moduleFile is TraceManagedModule) { var managedModule = moduleFile as TraceManagedModule; int clrInstanceIDModule; if (!assemblyToCLRInstanceIDMap.TryGetValue(managedModule.AssemblyID, out clrInstanceIDModule)) { continue; } if (clrInstanceIDModule != _clrInstanceID) { continue; } var currentInfo = new ModuleDescInfo(managedModule.ModuleID, assemblyToFullyQualifiedAssemblyName[managedModule.AssemblyID], assemblyToIsDynamic[managedModule.AssemblyID]); if (!_modules.ContainsKey(managedModule.ModuleID)) { _modules.Add(managedModule.ModuleID, currentInfo); } } } }