Browse Source

Add IDebugInfoProvider.Description property

pull/1030/head
Siegfried Pammer 7 years ago
parent
commit
8335615842
  1. 13
      ICSharpCode.Decompiler.PdbProvider.Cecil/MonoCecilDebugInfoProvider.cs
  2. 1
      ICSharpCode.Decompiler/DebugInfo/IDebugInfoProvider.cs
  3. 2
      ILSpy/DebugInfo/DiaSymNativeDebugInfoProvider.cs
  4. 2
      ILSpy/DebugInfo/PortableDebugInfoProvider.cs

13
ICSharpCode.Decompiler.PdbProvider.Cecil/MonoCecilDebugInfoProvider.cs

@ -31,16 +31,19 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil @@ -31,16 +31,19 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil
{
public class MonoCecilDebugInfoProvider : IDebugInfoProvider
{
ModuleDefinition module;
readonly ModuleDefinition module;
public MonoCecilDebugInfoProvider(ModuleDefinition module)
public MonoCecilDebugInfoProvider(ModuleDefinition module, string description = null)
{
this.module = module;
this.Description = description ?? "none";
}
public string Description { get; }
public IList<SequencePoint> GetSequencePoints(SRM.MethodDefinitionHandle handle)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as Mono.Cecil.MethodDefinition;
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
if (method?.DebugInformation == null || !method.DebugInformation.HasSequencePoints)
return EmptyList<SequencePoint>.Instance;
return method.DebugInformation.SequencePoints.Select(point => new SequencePoint {
@ -55,7 +58,7 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil @@ -55,7 +58,7 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil
public IList<Variable> GetVariables(SRM.MethodDefinitionHandle handle)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as Mono.Cecil.MethodDefinition;
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
if (method?.DebugInformation == null)
return EmptyList<Variable>.Instance;
return method.DebugInformation.GetScopes()
@ -65,7 +68,7 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil @@ -65,7 +68,7 @@ namespace ICSharpCode.Decompiler.PdbProvider.Cecil
public bool TryGetName(SRM.MethodDefinitionHandle handle, int index, out string name)
{
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as Mono.Cecil.MethodDefinition;
var method = this.module.LookupToken(MetadataTokens.GetToken(handle)) as MethodDefinition;
name = null;
if (method?.DebugInformation == null || !method.HasBody)
return false;

1
ICSharpCode.Decompiler/DebugInfo/IDebugInfoProvider.cs

@ -12,6 +12,7 @@ namespace ICSharpCode.Decompiler.DebugInfo @@ -12,6 +12,7 @@ namespace ICSharpCode.Decompiler.DebugInfo
public interface IDebugInfoProvider
{
string Description { get; }
IList<SequencePoint> GetSequencePoints(MethodDefinitionHandle method);
IList<Variable> GetVariables(MethodDefinitionHandle method);
bool TryGetName(MethodDefinitionHandle method, int index, out string name);

2
ILSpy/DebugInfo/DiaSymNativeDebugInfoProvider.cs

@ -49,6 +49,8 @@ namespace ICSharpCode.ILSpy.DebugInfo @@ -49,6 +49,8 @@ namespace ICSharpCode.ILSpy.DebugInfo
this.reader = SymUnmanagedReaderFactory.CreateReader<ISymUnmanagedReader5>(stream, this);
}
public string Description => $"Loaded from PDB file: {pdbFileName}";
public IList<Decompiler.DebugInfo.SequencePoint> GetSequencePoints(MethodDefinitionHandle handle)
{
var method = reader.GetMethod(MetadataTokens.GetToken(handle));

2
ILSpy/DebugInfo/PortableDebugInfoProvider.cs

@ -35,6 +35,8 @@ namespace ICSharpCode.ILSpy.DebugInfo @@ -35,6 +35,8 @@ namespace ICSharpCode.ILSpy.DebugInfo
this.provider = provider;
}
public string Description => pdbFileName == null ? "Embedded in this assembly" : $"Loaded from portable PDB: {pdbFileName}";
public IList<Decompiler.DebugInfo.SequencePoint> GetSequencePoints(MethodDefinitionHandle method)
{
var metadata = provider.GetMetadataReader();

Loading…
Cancel
Save