diff --git a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs index 18355d985..7b8b62a8b 100644 --- a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs +++ b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs @@ -103,9 +103,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun output.WriteLine("; " + comment); } - private Dictionary>> WriteDebugInfo(ReadyToRunMethod readyToRunMethod, ITextOutput output) + private Dictionary> WriteDebugInfo(ReadyToRunMethod readyToRunMethod, ITextOutput output) { - Dictionary>> debugInfoDict = new Dictionary>>(); + Dictionary> debugInfoDict = new Dictionary>(); IReadOnlyList runTimeList = readyToRunMethod.RuntimeFunctions; foreach (RuntimeFunction runtimeFunction in runTimeList) { DebugInfo debugInfo = runtimeFunction.DebugInfo; @@ -113,14 +113,16 @@ namespace ICSharpCode.ILSpy.ReadyToRun for (int i = 0; i < debugInfo.VariablesList.Count; ++i) { var varLoc = debugInfo.VariablesList[i]; try { - HashSet> typeSet = new HashSet>(); + var typeSet = new HashSet>(); bool found = debugInfoDict.TryGetValue(varLoc.VariableLocation.VarLocType, out typeSet); if (found) { - typeSet.Add(new Tuple(debugInfo, varLoc)); + (DebugInfo debugInfo, NativeVarInfo varLoc) newTuple = (debugInfo, varLoc); + typeSet.Add(newTuple); } else { - typeSet = new HashSet>(); + typeSet = new HashSet>(); debugInfoDict.Add(varLoc.VariableLocation.VarLocType, typeSet); - typeSet.Add(new Tuple(debugInfo, varLoc)); + (DebugInfo debugInfo, NativeVarInfo varLoc) newTuple = (debugInfo, varLoc); + typeSet.Add(newTuple); } } catch (ArgumentNullException) { output.WriteLine("Failed to find hash set of Debug info type"); @@ -168,7 +170,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun output.WriteLine($" Offset: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}"); break; default: - throw new BadImageFormatException("Unexpected var loc type"); + throw new BadImageFormatException("Unexpected variable type"); } output.WriteLine(""); } @@ -216,7 +218,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun } bool isShowDebugInfo = ReadyToRunOptions.GetIsShowDebugInfo(null); - Dictionary>> debugInfo = null; + Dictionary>> debugInfo = null; if (isShowDebugInfo) { debugInfo = WriteDebugInfo(readyToRunMethod, output); } @@ -293,12 +295,12 @@ namespace ICSharpCode.ILSpy.ReadyToRun } } - private static void DecorateDebugInfo(ITextOutput output, Instruction instr, Dictionary>> debugInfoDict, ulong baseInstrIP) + private static void DecorateDebugInfo(ITextOutput output, Instruction instr, Dictionary> debugInfoDict, ulong baseInstrIP) { if (debugInfoDict != null) { InstructionInfoFactory factory = new InstructionInfoFactory(); InstructionInfo info = factory.GetInfo(instr); - HashSet> stkSet = new HashSet>(); + HashSet> stkSet = new HashSet>(); if (debugInfoDict.ContainsKey(VarLocType.VLT_STK)) { stkSet.UnionWith(debugInfoDict[VarLocType.VLT_STK]); } @@ -307,9 +309,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun } if (stkSet != null) { foreach (UsedMemory usedMemInfo in info.GetUsedMemory()) { //for each time a [register +- value] is used - foreach (Tuple tuple in stkSet) { //for each VLT_STK variable - var debugInfo = tuple.Item1; - var varInfo = tuple.Item2; + foreach ((DebugInfo debugInfo, NativeVarInfo varLoc) tuple in stkSet) { //for each VLT_STK variable + var debugInfo = tuple.debugInfo; + var varInfo = tuple.varLoc; int stackOffset = varInfo.VariableLocation.Data2; ulong adjOffset; bool negativeOffset; @@ -329,7 +331,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun } } } - HashSet> regSet = new HashSet>(); + HashSet> regSet = new HashSet>(); if (debugInfoDict.ContainsKey(VarLocType.VLT_REG)) { regSet.UnionWith(debugInfoDict[VarLocType.VLT_REG]); } @@ -341,9 +343,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun } if (regSet != null) { foreach (UsedRegister usedMemInfo in info.GetUsedRegisters()) { - foreach (Tuple tuple in regSet) { - var debugInfo = tuple.Item1; - var varInfo = tuple.Item2; + foreach ((DebugInfo debugInfo, NativeVarInfo varLoc) tuple in regSet) { + var debugInfo = tuple.debugInfo; + var varInfo = tuple.varLoc; if (varInfo.StartOffset < instr.IP - baseInstrIP && varInfo.EndOffset > instr.IP - baseInstrIP && DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varInfo.VariableLocation.Data1) == usedMemInfo.Register.ToString()) { output.Write($"; {usedMemInfo.Register.ToString()} = {varInfo.Variable.Type} {varInfo.Variable.Index}");