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

1
ICSharpCode.Decompiler/DebugInfo/IDebugInfoProvider.cs

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

2
ILSpy/DebugInfo/DiaSymNativeDebugInfoProvider.cs

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

2
ILSpy/DebugInfo/PortableDebugInfoProvider.cs

@ -35,6 +35,8 @@ namespace ICSharpCode.ILSpy.DebugInfo
this.provider = provider; 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) public IList<Decompiler.DebugInfo.SequencePoint> GetSequencePoints(MethodDefinitionHandle method)
{ {
var metadata = provider.GetMetadataReader(); var metadata = provider.GetMetadataReader();

Loading…
Cancel
Save