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. 7
      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
public override string ToString() 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), Path.GetFileName(this.Filename ?? string.Empty),
this.StartLine, this.StartColumn, this.StartLine, this.StartColumn,
this.EndLine, this.EndColumn); this.EndLine, this.EndColumn,
string.Join(" ", this.ILRanges));
} }
} }
@ -45,6 +46,11 @@ namespace Debugger
this.From = from; this.From = from;
this.To = to; this.To = to;
} }
public override string ToString()
{
return string.Format("{0:X2}-{1:X2}", From, To);
}
} }
public class ILLocalVariable public class ILLocalVariable

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

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

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

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

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

@ -15,7 +15,8 @@ namespace ICSharpCode.ILSpyAddIn
{ {
public static MethodDebugSymbols GetSymbols(IMethod method) 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); var content = DecompiledViewContent.Get(method);
if (content != null && content.DebugSymbols.ContainsKey(id)) { if (content != null && content.DebugSymbols.ContainsKey(id)) {
return content.DebugSymbols[id]; return content.DebugSymbols[id];
@ -31,7 +32,11 @@ namespace ICSharpCode.ILSpyAddIn
var content = DecompiledViewContent.Get(method); var content = DecompiledViewContent.Get(method);
var seq = symbols.SequencePoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To)); var seq = symbols.SequencePoints.FirstOrDefault(p => p.ILRanges.Any(r => r.From <= iloffset && iloffset < r.To));
if (seq == null)
seq = symbols.SequencePoints.FirstOrDefault(p => iloffset <= p.ILOffset);
if (seq != null)
return seq.ToDebugger(symbols, content.VirtualFileName); return seq.ToDebugger(symbols, content.VirtualFileName);
return null;
} }
public Debugger.SequencePoint GetSequencePoint(Module module, string filename, int line, int column) 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;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast; using ICSharpCode.Decompiler.Ast;
using ICSharpCode.Decompiler.Disassembler;
using ICSharpCode.NRefactory.Documentation; using ICSharpCode.NRefactory.Documentation;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.ILSpyAddIn.LaunchILSpy; using ICSharpCode.ILSpyAddIn.LaunchILSpy;
@ -235,6 +236,9 @@ namespace ICSharpCode.ILSpyAddIn
astBuilder.AddType(typeDefinition); astBuilder.AddType(typeDefinition);
astBuilder.GenerateCode(textOutput); astBuilder.GenerateCode(textOutput);
// ReflectionDisassembler disasm = new ReflectionDisassembler(textOutput, true, cancellationToken);
// disasm.DisassembleType(typeDefinition);
// save decompilation data // save decompilation data
memberLocations = textOutput.MemberLocations; memberLocations = textOutput.MemberLocations;
this.DebugSymbols = textOutput.DebugSymbols; this.DebugSymbols = textOutput.DebugSymbols;

Loading…
Cancel
Save