Browse Source

Slightly improve mapping from IL to source code

pull/32/merge
David Srbecký 13 years ago
parent
commit
333e3644b7
  1. 10
      src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs
  2. 1
      src/AddIns/Debugger/Debugger.Core/StackFrame.cs
  3. 2
      src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerTextOutput.cs
  4. 9
      src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs
  5. 4
      src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs

10
src/AddIns/Debugger/Debugger.Core/PdbSymbolSource.cs

@ -28,10 +28,11 @@ namespace Debugger @@ -28,10 +28,11 @@ namespace Debugger
public override string ToString()
{
return string.Format("{0}:{1},{2}-{3},{4}",
return string.Format("{0}:{1},{2}-{3},{4} IL:{5}",
Path.GetFileName(this.Filename ?? string.Empty),
this.StartLine, this.StartColumn,
this.EndLine, this.EndColumn);
this.EndLine, this.EndColumn,
string.Join(" ", this.ILRanges));
}
}
@ -45,6 +46,11 @@ namespace Debugger @@ -45,6 +46,11 @@ namespace Debugger
this.From = from;
this.To = to;
}
public override string ToString()
{
return string.Format("{0:X2}-{1:X2}", From, To);
}
}
public class ILLocalVariable

1
src/AddIns/Debugger/Debugger.Core/StackFrame.cs

@ -156,6 +156,7 @@ namespace Debugger @@ -156,6 +156,7 @@ namespace Debugger
List<ILRange> stepRanges = new List<ILRange>();
var seq = this.Module.SymbolSource.GetSequencePoint(this.MethodInfo, this.IP);
if (seq != null) {
Process.TraceMessage("Step over: {0}", seq);
stepRanges.AddRange(seq.ILRanges);
stepRanges.AddRange(this.Module.SymbolSource.GetIgnoredILRanges(this.MethodInfo));
}

2
src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerTextOutput.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.Decompiler;
using Mono.Cecil;
@ -66,6 +67,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -66,6 +67,7 @@ namespace ICSharpCode.ILSpyAddIn
public void AddDebugSymbols(MethodDebugSymbols methodDebugSymbols)
{
var id = XmlDocKeyProvider.GetKey(methodDebugSymbols.CecilMethod);
methodDebugSymbols.SequencePoints = methodDebugSymbols.SequencePoints.OrderBy(s => s.ILOffset).ToList();
this.DebugSymbols.Add(id, methodDebugSymbols);
output.AddDebugSymbols(methodDebugSymbols);
}

9
src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs

@ -15,7 +15,8 @@ namespace ICSharpCode.ILSpyAddIn @@ -15,7 +15,8 @@ namespace ICSharpCode.ILSpyAddIn
{
public static MethodDebugSymbols GetSymbols(IMethod method)
{
var id = IdStringProvider.GetIdString(method);
// Use the non-specialised method definition to look up decompiled symbols
var id = IdStringProvider.GetIdString(method.MemberDefinition);
var content = DecompiledViewContent.Get(method);
if (content != null && content.DebugSymbols.ContainsKey(id)) {
return content.DebugSymbols[id];
@ -31,7 +32,11 @@ namespace ICSharpCode.ILSpyAddIn @@ -31,7 +32,11 @@ namespace ICSharpCode.ILSpyAddIn
var content = DecompiledViewContent.Get(method);
var seq = symbols.SequencePoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To));
return seq.ToDebugger(symbols, content.VirtualFileName);
if (seq == null)
seq = symbols.SequencePoints.FirstOrDefault(p => iloffset <= p.ILOffset);
if (seq != null)
return seq.ToDebugger(symbols, content.VirtualFileName);
return null;
}
public Debugger.SequencePoint GetSequencePoint(Module module, string filename, int line, int column)

4
src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs

@ -13,6 +13,7 @@ using ICSharpCode.AvalonEdit.Highlighting; @@ -13,6 +13,7 @@ using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.Core;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.NRefactory.Documentation;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.ILSpyAddIn.LaunchILSpy;
@ -235,6 +236,9 @@ namespace ICSharpCode.ILSpyAddIn @@ -235,6 +236,9 @@ namespace ICSharpCode.ILSpyAddIn
astBuilder.AddType(typeDefinition);
astBuilder.GenerateCode(textOutput);
// ReflectionDisassembler disasm = new ReflectionDisassembler(textOutput, true, cancellationToken);
// disasm.DisassembleType(typeDefinition);
// save decompilation data
memberLocations = textOutput.MemberLocations;
this.DebugSymbols = textOutput.DebugSymbols;

Loading…
Cancel
Save