Browse Source

merging

pull/2043/head
plupiman 5 years ago
parent
commit
7970c2f1b3
  1. 84
      ILSpy.ReadyToRun/ReadyToRunLanguage.cs
  2. 5
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml
  3. 15
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
  4. 21
      ILSpy.ReadyToRun/ReadyToRunOptions.cs

84
ILSpy.ReadyToRun/ReadyToRunLanguage.cs

@ -103,7 +103,88 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -103,7 +103,88 @@ namespace ICSharpCode.ILSpy.ReadyToRun
output.WriteLine("; " + comment);
}
private void WriteDebugInfo(ReadyToRunMethod readyToRunMethod, ITextOutput output)
{
IReadOnlyList<RuntimeFunction> runTimeList = readyToRunMethod.RuntimeFunctions;
foreach (RuntimeFunction runtimeFunction in runTimeList) {
DebugInfo debugInfo = runtimeFunction.DebugInfo;
if (debugInfo.BoundsList.Count > 0)
output.WriteLine("Debug Info");
output.WriteLine(" Bounds:");
for (int i = 0; i < debugInfo.BoundsList.Count; ++i) {
output.Write(" ");
output.Write($"Native Offset: 0x{debugInfo.BoundsList[i].NativeOffset:X}, ");
if (debugInfo.BoundsList[i].ILOffset == (uint)DebugInfoBoundsType.NoMapping) {
output.Write("NoMapping");
} else if (debugInfo.BoundsList[i].ILOffset == (uint)DebugInfoBoundsType.Prolog) {
output.Write("Prolog");
} else if (debugInfo.BoundsList[i].ILOffset == (uint)DebugInfoBoundsType.Epilog) {
output.Write("Epilog");
} else {
output.WriteLine($"IL Offset: 0x{debugInfo.BoundsList[i].ILOffset:x4}");
}
output.Write($", Srouce Types: {debugInfo.BoundsList[i].SourceTypes}");
output.WriteLine();
}
output.WriteLine("");
if (debugInfo.VariablesList.Count > 0)
output.WriteLine(" Variable Locations:");
for (int i = 0; i < debugInfo.VariablesList.Count; ++i) {
var varLoc = debugInfo.VariablesList[i];
output.WriteLine($" Variable Number: {varLoc.VariableNumber}");
output.WriteLine($" Start Offset: 0x{varLoc.StartOffset:X}");
output.WriteLine($" End Offset: 0x{varLoc.EndOffset:X}");
output.WriteLine($" Loc Type: {varLoc.VariableLocation.VarLocType}");
switch (varLoc.VariableLocation.VarLocType) {
case VarLocType.VLT_REG:
case VarLocType.VLT_REG_FP:
case VarLocType.VLT_REG_BYREF:
output.WriteLine($" Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
break;
case VarLocType.VLT_STK:
case VarLocType.VLT_STK_BYREF:
output.WriteLine($" Base Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
output.WriteLine($" Stack Offset: {varLoc.VariableLocation.Data2}");
break;
case VarLocType.VLT_REG_REG:
output.WriteLine($" Register 1: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
output.WriteLine($" Register 2: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data2)}");
break;
case VarLocType.VLT_REG_STK:
output.WriteLine($" Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
output.WriteLine($" Base Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data2)}");
output.WriteLine($" Stack Offset: {varLoc.VariableLocation.Data3}");
break;
case VarLocType.VLT_STK_REG:
output.WriteLine($" Stack Offset: {varLoc.VariableLocation.Data1}");
output.WriteLine($" Base Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data2)}");
output.WriteLine($" Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data3)}");
break;
case VarLocType.VLT_STK2:
output.WriteLine($" Base Register: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
output.WriteLine($" Stack Offset: {varLoc.VariableLocation.Data2}");
break;
case VarLocType.VLT_FPSTK:
output.WriteLine($" Offset: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
break;
case VarLocType.VLT_FIXED_VA:
output.WriteLine($" Offset: {DebugInfo.GetPlatformSpecificRegister(debugInfo.Machine, varLoc.VariableLocation.Data1)}");
break;
default:
throw new BadImageFormatException("Unexpected var loc type");
}
output.WriteLine("");
}
}
}
private Dictionary<ulong, UnwindCode> WriteUnwindInfo(ReadyToRunMethod readyToRunMethod, ITextOutput output)
{
IReadOnlyList<RuntimeFunction> runTimeList = readyToRunMethod.RuntimeFunctions;
Dictionary<ulong, UnwindCode> unwindCodes = new Dictionary<ulong, UnwindCode>();
@ -143,6 +224,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -143,6 +224,9 @@ namespace ICSharpCode.ILSpy.ReadyToRun
unwindInfo = WriteUnwindInfo(readyToRunMethod, output);
}
if (ReadyToRunOptions.GetIsShowDebugInfo(null)) {
WriteDebugInfo(readyToRunMethod, output);
}
byte[] codeBytes = new byte[runtimeFunction.Size];
for (int i = 0; i < runtimeFunction.Size; i++) {
codeBytes[i] = reader.Image[reader.GetOffset(runtimeFunction.StartAddress) + i];

5
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml

@ -10,11 +10,14 @@ @@ -10,11 +10,14 @@
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0">Disassembly Format</TextBlock>
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding DisassemblyFormats}" SelectedItem="{Binding DisassemblyFormat}"/>
<TextBlock Grid.Row="1" Grid.Column="0">Show Unwind Info</TextBlock>
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding IsShowUnwindInfo}"></CheckBox>
</Grid>
<TextBlock Grid.Row="2" Grid.Column="0">Show Debug Info</TextBlock>
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding DebugIsChecked}"></CheckBox>
</Grid>
</StackPanel>
</UserControl>

15
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs

@ -36,6 +36,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -36,6 +36,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
Options s = new Options();
s.DisassemblyFormat = ReadyToRunOptions.GetDisassemblyFormat(settings);
s.IsShowUnwindInfo = ReadyToRunOptions.GetIsShowUnwindInfo(settings);
s.IsShowDebugInfo = ReadyToRunOptions.GetIsShowDebugInfo(settings);
this.DataContext = s;
}
@ -48,7 +49,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -48,7 +49,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
public void Save(XElement root)
{
Options s = (Options)this.DataContext;
ReadyToRunOptions.SetDisassemblyOptions(root, s.DisassemblyFormat, s.IsShowUnwindInfo);
ReadyToRunOptions.SetDisassemblyOptions(root, s.DisassemblyFormat, s.IsShowUnwindInfo, s.IsShowDebugInfo);
}
}
@ -71,6 +72,18 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -71,6 +72,18 @@ namespace ICSharpCode.ILSpy.ReadyToRun
}
}
private bool isShowDebugInfo;
public bool IsShowDebugInfo {
get {
return isShowDebugInfo;
}
set {
isShowDebugInfo = value;
OnPropertyChanged(nameof(isShowDebugInfo));
}
}
private string disassemblyFormat;
public string DisassemblyFormat {

21
ILSpy.ReadyToRun/ReadyToRunOptions.cs

@ -43,12 +43,14 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -43,12 +43,14 @@ namespace ICSharpCode.ILSpy.ReadyToRun
}
public static bool GetIsShowUnwindInfo(ILSpySettings settings)
{
if (settings == null) {
settings = ILSpySettings.Load();
}
XElement e = settings[ns + "ReadyToRunOptions"];
XAttribute a = e.Attribute("IsShowUnwindInfo");
if (a == null) {
return false;
} else {
@ -56,12 +58,12 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -56,12 +58,12 @@ namespace ICSharpCode.ILSpy.ReadyToRun
}
}
public static void SetDisassemblyOptions(XElement root, string disassemblyFormat, bool IsShowUnwindInfo)
public static void SetDisassemblyOptions(XElement root, string disassemblyFormat, bool IsShowUnwindInfo, bool IsShowDebugInfo)
{
XElement section = new XElement(ns + "ReadyToRunOptions");
section.SetAttributeValue("DisassemblyFormat", disassemblyFormat);
section.SetAttributeValue("IsShowUnwindInfo", IsShowUnwindInfo);
section.SetAttributeValue("IsShowDebugInfo", IsShowDebugInfo);
XElement existingElement = root.Element(ns + "ReadyToRunOptions");
if (existingElement != null) {
existingElement.ReplaceWith(section);
@ -70,5 +72,20 @@ namespace ICSharpCode.ILSpy.ReadyToRun @@ -70,5 +72,20 @@ namespace ICSharpCode.ILSpy.ReadyToRun
}
}
public static bool GetIsShowDebugInfo(ILSpySettings settings)
{
if (settings == null) {
settings = ILSpySettings.Load();
}
XElement e = settings[ns + "ReadyToRunOptions"];
XAttribute a = e.Attribute("IsShowDebugInfo");
if (a == null) {
return false;
} else {
return (bool)a;
}
}
}
}

Loading…
Cancel
Save