Browse files

move external debug info in decompiler addin

  • Loading branch information...
1 parent abdeeb5 commit de36dc41482a7a255678b6045153b130b1782a48 @eusebiu eusebiu committed Jul 27, 2011
View
2 src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
@@ -753,7 +753,7 @@ void AddBreakpoint(BreakpointBookmark bookmark)
var decompilerService = GetDecompilerService();
int token = memberReference.MetadataToken.ToInt32();
- if (!DebuggerService.ExternalDebugInformation.ContainsKey(token))
+ if (!decompilerService.CheckMappings(token))
decompilerService.DecompileOnDemand(memberReference as TypeDefinition);
int[] ilRanges;
View
29 src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerDecompilerService.cs
@@ -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
/// </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 @@ public void DecompileOnDemand(TypeDefinition type)
};
// save the data
- DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info);
+ DebugInformation.AddOrUpdate(token, info, (k, v) => info);
} catch {
return;
}
@@ -63,7 +76,7 @@ public bool GetILAndTokenByLineNumber(int typeToken, int lineNumber, out int[] i
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 @@ public bool GetILAndLineNumber(int typeToken, int memberToken, int ilOffset, out
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);
View
9 src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs
@@ -178,7 +178,7 @@ void RunDecompiler(string assemblyFile, string fullTypeName, ITextOutput textOut
};
// 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 @@ void UpdateDebuggingUI()
{
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;
View
14 src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
@@ -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 @@ static DebuggerService()
BookmarkManager.Added += BookmarkAdded;
BookmarkManager.Removed += BookmarkRemoved;
-
- ExternalDebugInformation = new ConcurrentDictionary<int, object>();
}
static void GetDescriptors()
@@ -108,12 +105,6 @@ static IDebugger GetCompatibleDebugger()
#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>
public static Tuple<int, int> DebugStepInformation { get; set; }
@@ -470,6 +461,11 @@ public void HandleToolTipRequest(ToolTipRequestEventArgs e)
public interface IDebuggerDecompilerService
{
/// <summary>
+ /// Checks the code mappings.
+ /// </summary>
+ bool CheckMappings(int typeToken);
+
+ /// <summary>
/// Decompiles on demand a type.
/// </summary>
void DecompileOnDemand(TypeDefinition type);

0 comments on commit de36dc4

Please sign in to comment.