Browse Source

Show Sequence Points from CLI

When disassembling IL add a flag to enable showing sequence points. We
can already specify PDB loading; take advantage of that to provide
debug information for the decompiler.

When the `--il-sequence-points` flag is used the behavior is the same as
with `-il`, but sequence point information is aslo emitted. This leaves
things open to adding an `--il-metadata-tokens` flag too.
pull/2193/head
Will Speak 5 years ago
parent
commit
9f7bcc0dd9
  1. 11
      ICSharpCode.Decompiler.Console/IlspyCmdProgram.cs

11
ICSharpCode.Decompiler.Console/IlspyCmdProgram.cs

@ -47,6 +47,9 @@ Remarks: @@ -47,6 +47,9 @@ Remarks:
[Option("-il|--ilcode", "Show IL code.", CommandOptionType.NoValue)]
public bool ShowILCodeFlag { get; }
[Option("--il-sequence-points", "Show IL with sequence points. Implies -il.", CommandOptionType.NoValue)]
public bool ShowILSequencePointsFlag { get; }
[Option("-genpdb", "Generate PDB.", CommandOptionType.NoValue)]
public bool CreateDebugInfoFlag { get; }
@ -90,7 +93,7 @@ Remarks: @@ -90,7 +93,7 @@ Remarks:
}
return ListContent(InputAssemblyName, output, kinds);
} else if (ShowILCodeFlag) {
} else if (ShowILCodeFlag || ShowILSequencePointsFlag) {
if (outputDirectorySpecified) {
string outputName = Path.GetFileNameWithoutExtension(InputAssemblyName);
output = File.CreateText(Path.Combine(OutputDirectory, outputName) + ".il");
@ -169,7 +172,11 @@ Remarks: @@ -169,7 +172,11 @@ Remarks:
{
var module = new PEFile(assemblyFileName);
output.WriteLine($"// IL code: {module.Name}");
var disassembler = new ReflectionDisassembler(new PlainTextOutput(output), CancellationToken.None);
var disassembler = new ReflectionDisassembler(new PlainTextOutput(output), CancellationToken.None)
{
DebugInfo = TryLoadPDB(module),
ShowSequencePoints = ShowILSequencePointsFlag,
};
disassembler.WriteModuleContents(module);
return 0;
}

Loading…
Cancel
Save