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
var decompilerService = GetDecompilerService(); var decompilerService = GetDecompilerService();
int token = memberReference.MetadataToken.ToInt32(); int token = memberReference.MetadataToken.ToInt32();
if (!DebuggerService.ExternalDebugInformation.ContainsKey(token)) if (!decompilerService.CheckMappings(token))
decompilerService.DecompileOnDemand(memberReference as TypeDefinition); decompilerService.DecompileOnDemand(memberReference as TypeDefinition);
int[] ilRanges; int[] ilRanges;

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) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Concurrent;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast; using ICSharpCode.Decompiler.Ast;
using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Debugging;
@ -13,10 +15,21 @@ namespace ICSharpCode.ILSpyAddIn
/// </summary> /// </summary>
public class DebuggerDecompilerService : IDebuggerDecompilerService 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; DecompileInformation data = null;
DebuggerService.ExternalDebugInformation.TryGetValue(typeToken, out data); DebugInformation.TryGetValue(typeToken, out data);
DecompileInformation information = data as DecompileInformation; DecompileInformation information = data as DecompileInformation;
if (information == null) if (information == null)
@ -50,7 +63,7 @@ namespace ICSharpCode.ILSpyAddIn
}; };
// save the data // save the data
DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info); DebugInformation.AddOrUpdate(token, info, (k, v) => info);
} catch { } catch {
return; return;
} }
@ -63,7 +76,7 @@ namespace ICSharpCode.ILSpyAddIn
if (!CheckMappings(typeToken)) if (!CheckMappings(typeToken))
return false; return false;
var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken]; var data = (DecompileInformation)DebugInformation[typeToken];
var mappings = data.CodeMappings; var mappings = data.CodeMappings;
foreach (var key in mappings.Keys) { foreach (var key in mappings.Keys) {
var list = mappings[key]; var list = mappings[key];
@ -88,8 +101,12 @@ namespace ICSharpCode.ILSpyAddIn
if (!CheckMappings(typeToken)) if (!CheckMappings(typeToken))
return false; return false;
var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken]; var data = (DecompileInformation)DebugInformation[typeToken];
var mappings = data.CodeMappings; var mappings = data.CodeMappings;
if (!mappings.ContainsKey(memberToken))
return false;
var map = mappings[memberToken].GetInstructionByTokenAndOffset(memberToken, ilOffset, out isMatch); var map = mappings[memberToken].GetInstructionByTokenAndOffset(memberToken, ilOffset, out isMatch);
if (map != null) { if (map != null) {
ilRange = map.ToArray(isMatch); ilRange = map.ToArray(isMatch);

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

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

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

Loading…
Cancel
Save