Browse Source

Fix steping for statements.

pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
620524d2c7
  1. 5
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  2. 14
      ICSharpCode.Decompiler/CodeMappings.cs

5
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -308,7 +308,7 @@ namespace ILSpy.Debugger.Services
return null; return null;
} else { } else {
var frame = debuggedProcess.SelectedThread.MostRecentStackFrame; var frame = debuggedProcess.SelectedThread.MostRecentStackFrame;
frame.SourceCodeLine = CurrentLineBookmark.Instance.LineNumber; frame.SourceCodeLine = map.SourceCodeLine;
frame.ILRanges = map.ToArray(); frame.ILRanges = map.ToArray();
return frame; return frame;
} }
@ -833,8 +833,7 @@ namespace ILSpy.Debugger.Services
int ilOffset = frame.IP; int ilOffset = frame.IP;
int line; int line;
string typeName; string typeName;
CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out typeName, out line); if (CodeMappingsStorage.GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out typeName, out line))
if (typeName != null)
DebuggerService.JumpToCurrentLine(typeName, line, 0, line, 0); DebuggerService.JumpToCurrentLine(typeName, line, 0, line, 0);
} }
} }

14
ICSharpCode.Decompiler/CodeMappings.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Decompiler; using Decompiler;
using ICSharpCode.Decompiler.Disassembler; using ICSharpCode.Decompiler.Disassembler;
@ -30,7 +31,7 @@ namespace ICSharpCode.Decompiler
{ {
int[] result = new int[2]; int[] result = new int[2];
result[0] = ILInstructionOffset.From; result[0] = ILInstructionOffset.From;
result[1] = ILInstructionOffset.To; result[1] = ILInstructionOffset.To + 1;
return result; return result;
} }
@ -92,7 +93,7 @@ namespace ICSharpCode.Decompiler
this MethodDefinition method, this MethodDefinition method,
ConcurrentDictionary<string, List<MethodMapping>> sourceCodeMappings) ConcurrentDictionary<string, List<MethodMapping>> sourceCodeMappings)
{ {
// create IL code mappings - used in debugger // create IL/CSharp code mappings - used in debugger
MethodMapping currentMethodMapping = null; MethodMapping currentMethodMapping = null;
if (sourceCodeMappings.ContainsKey(method.DeclaringType.FullName)) { if (sourceCodeMappings.ContainsKey(method.DeclaringType.FullName)) {
var mapping = sourceCodeMappings[method.DeclaringType.FullName]; var mapping = sourceCodeMappings[method.DeclaringType.FullName];
@ -154,7 +155,7 @@ namespace ICSharpCode.Decompiler
/// <param name="ilOffset">IL offset.</param> /// <param name="ilOffset">IL offset.</param>
/// <param name="typeName">Type name.</param> /// <param name="typeName">Type name.</param>
/// <param name="line">Line number.</param> /// <param name="line">Line number.</param>
public static void GetSourceCodeFromMetadataTokenAndOffset( public static bool GetSourceCodeFromMetadataTokenAndOffset(
this ConcurrentDictionary<string, List<MethodMapping>> codeMappings, this ConcurrentDictionary<string, List<MethodMapping>> codeMappings,
uint token, uint token,
int ilOffset, int ilOffset,
@ -174,15 +175,20 @@ namespace ICSharpCode.Decompiler
(cm.ILInstructionOffset.From == ilOffset && ilOffset == cm.ILInstructionOffset.To)); // for IL (cm.ILInstructionOffset.From == ilOffset && ilOffset == cm.ILInstructionOffset.To)); // for IL
if (codeMapping == null) { if (codeMapping == null) {
codeMapping = mapping.MethodCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset)); codeMapping = mapping.MethodCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset));
if (codeMapping == null) {
codeMapping = mapping.MethodCodeMappings.LastOrDefault();
if (codeMapping == null) if (codeMapping == null)
continue; continue;
} }
}
typeName = typename; typeName = typename;
line = codeMapping.SourceCodeLine; line = codeMapping.SourceCodeLine;
break; return true;
} }
return false;
} }
} }
} }

Loading…
Cancel
Save