Browse Source

move external debug info in decompiler addin

pull/16/head
Eusebiu Marcu 14 years ago
parent
commit
de36dc4148
  1. 2
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  2. 29
      src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerDecompilerService.cs
  3. 9
      src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs
  4. 14
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

2
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

@ -753,7 +753,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -753,7 +753,7 @@ namespace ICSharpCode.SharpDevelop.Services
var decompilerService = GetDecompilerService();
int token = memberReference.MetadataToken.ToInt32();
if (!DebuggerService.ExternalDebugInformation.ContainsKey(token))
if (!decompilerService.CheckMappings(token))
decompilerService.DecompileOnDemand(memberReference as TypeDefinition);
int[] ilRanges;

29
src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerDecompilerService.cs

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Concurrent;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.SharpDevelop.Debugging;
@ -13,10 +15,21 @@ namespace ICSharpCode.ILSpyAddIn @@ -13,10 +15,21 @@ namespace ICSharpCode.ILSpyAddIn
/// </summary>
public class DebuggerDecompilerService : IDebuggerDecompilerService
{
private bool CheckMappings(int typeToken)
static DebuggerDecompilerService()
{
DebugInformation = new ConcurrentDictionary<int, DecompileInformation>();
}
/// <summary>
/// Gets or sets the external debug information.
/// <summary>This constains the code mappings and local variables.</summary>
/// </summary>
internal static ConcurrentDictionary<int, DecompileInformation> DebugInformation { get; private set; }
public bool CheckMappings(int typeToken)
{
object data = null;
DebuggerService.ExternalDebugInformation.TryGetValue(typeToken, out data);
DecompileInformation data = null;
DebugInformation.TryGetValue(typeToken, out data);
DecompileInformation information = data as DecompileInformation;
if (information == null)
@ -50,7 +63,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -50,7 +63,7 @@ namespace ICSharpCode.ILSpyAddIn
};
// save the data
DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info);
DebugInformation.AddOrUpdate(token, info, (k, v) => info);
} catch {
return;
}
@ -63,7 +76,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -63,7 +76,7 @@ namespace ICSharpCode.ILSpyAddIn
if (!CheckMappings(typeToken))
return false;
var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
var data = (DecompileInformation)DebugInformation[typeToken];
var mappings = data.CodeMappings;
foreach (var key in mappings.Keys) {
var list = mappings[key];
@ -88,8 +101,12 @@ namespace ICSharpCode.ILSpyAddIn @@ -88,8 +101,12 @@ namespace ICSharpCode.ILSpyAddIn
if (!CheckMappings(typeToken))
return false;
var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
var data = (DecompileInformation)DebugInformation[typeToken];
var mappings = data.CodeMappings;
if (!mappings.ContainsKey(memberToken))
return false;
var map = mappings[memberToken].GetInstructionByTokenAndOffset(memberToken, ilOffset, out isMatch);
if (map != null) {
ilRange = map.ToArray(isMatch);

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

@ -178,7 +178,7 @@ namespace ICSharpCode.ILSpyAddIn @@ -178,7 +178,7 @@ namespace ICSharpCode.ILSpyAddIn
};
// save the data
DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info);
DebuggerDecompilerService.DebugInformation.AddOrUpdate(token, info, (k, v) => info);
}
void OnDecompilationFinished(StringWriter output)
@ -216,16 +216,17 @@ namespace ICSharpCode.ILSpyAddIn @@ -216,16 +216,17 @@ namespace ICSharpCode.ILSpyAddIn
{
if (!DebuggerService.IsDebuggerStarted)
return;
if (MemberReference == null || MemberReference.MetadataToken == null)
return;
int typeToken = MemberReference.MetadataToken.ToInt32();
if (!DebuggerService.ExternalDebugInformation.ContainsKey(typeToken))
if (!DebuggerDecompilerService.DebugInformation.ContainsKey(typeToken))
return;
if (DebuggerService.DebugStepInformation == null)
return;
// get debugging information
DecompileInformation debugInformation = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
DecompileInformation debugInformation = (DecompileInformation)DebuggerDecompilerService.DebugInformation[typeToken];
int token = DebuggerService.DebugStepInformation.Item1;
int ilOffset = DebuggerService.DebugStepInformation.Item2;
int line;

14
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -35,8 +34,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -35,8 +34,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
BookmarkManager.Added += BookmarkAdded;
BookmarkManager.Removed += BookmarkRemoved;
ExternalDebugInformation = new ConcurrentDictionary<int, object>();
}
static void GetDescriptors()
@ -107,12 +104,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -107,12 +104,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
#region Debug third party code
/// <summary>
/// Gets or sets the external debug information.
/// <summary>This constains the code mappings and local variables.</summary>
/// </summary>
public static ConcurrentDictionary<int, object> ExternalDebugInformation { get; private set; }
/// <summary>
/// Gets or sets the current token and IL offset. Used for step in/out.
/// </summary>
@ -469,6 +460,11 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -469,6 +460,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
/// </summary>
public interface IDebuggerDecompilerService
{
/// <summary>
/// Checks the code mappings.
/// </summary>
bool CheckMappings(int typeToken);
/// <summary>
/// Decompiles on demand a type.
/// </summary>

Loading…
Cancel
Save