Browse Source

backup

pull/2067/head
Edward Carlson 5 years ago
parent
commit
8b49cc0f54
  1. 36
      ILSpy.ReadyToRun/ReadyToRunLanguage.cs

36
ILSpy.ReadyToRun/ReadyToRunLanguage.cs

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

Loading…
Cancel
Save