Skip to content
This repository
Browse code

move external debug info in decompiler addin

  • Loading branch information...
commit de36dc41482a7a255678b6045153b130b1782a48 1 parent abdeeb5
Eusebiu Marcu eusebiu authored
2  src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
@@ -753,7 +753,7 @@ void AddBreakpoint(BreakpointBookmark bookmark)
753 753 var decompilerService = GetDecompilerService();
754 754 int token = memberReference.MetadataToken.ToInt32();
755 755
756   - if (!DebuggerService.ExternalDebugInformation.ContainsKey(token))
  756 + if (!decompilerService.CheckMappings(token))
757 757 decompilerService.DecompileOnDemand(memberReference as TypeDefinition);
758 758
759 759 int[] ilRanges;
29 src/AddIns/DisplayBindings/ILSpyAddIn/DebuggerDecompilerService.cs
... ... @@ -1,6 +1,8 @@
1 1 // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2 2 // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
3 3 using System;
  4 +using System.Collections.Concurrent;
  5 +
4 6 using ICSharpCode.Decompiler;
5 7 using ICSharpCode.Decompiler.Ast;
6 8 using ICSharpCode.SharpDevelop.Debugging;
@@ -13,10 +15,21 @@ namespace ICSharpCode.ILSpyAddIn
13 15 /// </summary>
14 16 public class DebuggerDecompilerService : IDebuggerDecompilerService
15 17 {
16   - private bool CheckMappings(int typeToken)
  18 + static DebuggerDecompilerService()
  19 + {
  20 + DebugInformation = new ConcurrentDictionary<int, DecompileInformation>();
  21 + }
  22 +
  23 + /// <summary>
  24 + /// Gets or sets the external debug information.
  25 + /// <summary>This constains the code mappings and local variables.</summary>
  26 + /// </summary>
  27 + internal static ConcurrentDictionary<int, DecompileInformation> DebugInformation { get; private set; }
  28 +
  29 + public bool CheckMappings(int typeToken)
17 30 {
18   - object data = null;
19   - DebuggerService.ExternalDebugInformation.TryGetValue(typeToken, out data);
  31 + DecompileInformation data = null;
  32 + DebugInformation.TryGetValue(typeToken, out data);
20 33 DecompileInformation information = data as DecompileInformation;
21 34
22 35 if (information == null)
@@ -50,7 +63,7 @@ public void DecompileOnDemand(TypeDefinition type)
50 63 };
51 64
52 65 // save the data
53   - DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info);
  66 + DebugInformation.AddOrUpdate(token, info, (k, v) => info);
54 67 } catch {
55 68 return;
56 69 }
@@ -63,7 +76,7 @@ public bool GetILAndTokenByLineNumber(int typeToken, int lineNumber, out int[] i
63 76 if (!CheckMappings(typeToken))
64 77 return false;
65 78
66   - var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
  79 + var data = (DecompileInformation)DebugInformation[typeToken];
67 80 var mappings = data.CodeMappings;
68 81 foreach (var key in mappings.Keys) {
69 82 var list = mappings[key];
@@ -88,8 +101,12 @@ public bool GetILAndLineNumber(int typeToken, int memberToken, int ilOffset, out
88 101 if (!CheckMappings(typeToken))
89 102 return false;
90 103
91   - var data = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
  104 + var data = (DecompileInformation)DebugInformation[typeToken];
92 105 var mappings = data.CodeMappings;
  106 +
  107 + if (!mappings.ContainsKey(memberToken))
  108 + return false;
  109 +
93 110 var map = mappings[memberToken].GetInstructionByTokenAndOffset(memberToken, ilOffset, out isMatch);
94 111 if (map != null) {
95 112 ilRange = map.ToArray(isMatch);
9 src/AddIns/DisplayBindings/ILSpyAddIn/ViewContent/DecompiledViewContent.cs
@@ -178,7 +178,7 @@ void RunDecompiler(string assemblyFile, string fullTypeName, ITextOutput textOut
178 178 };
179 179
180 180 // save the data
181   - DebuggerService.ExternalDebugInformation.AddOrUpdate(token, info, (k, v) => info);
  181 + DebuggerDecompilerService.DebugInformation.AddOrUpdate(token, info, (k, v) => info);
182 182 }
183 183
184 184 void OnDecompilationFinished(StringWriter output)
@@ -216,16 +216,17 @@ void UpdateDebuggingUI()
216 216 {
217 217 if (!DebuggerService.IsDebuggerStarted)
218 218 return;
219   -
220 219 if (MemberReference == null || MemberReference.MetadataToken == null)
221 220 return;
222 221
223 222 int typeToken = MemberReference.MetadataToken.ToInt32();
224   - if (!DebuggerService.ExternalDebugInformation.ContainsKey(typeToken))
  223 + if (!DebuggerDecompilerService.DebugInformation.ContainsKey(typeToken))
  224 + return;
  225 + if (DebuggerService.DebugStepInformation == null)
225 226 return;
226 227
227 228 // get debugging information
228   - DecompileInformation debugInformation = (DecompileInformation)DebuggerService.ExternalDebugInformation[typeToken];
  229 + DecompileInformation debugInformation = (DecompileInformation)DebuggerDecompilerService.DebugInformation[typeToken];
229 230 int token = DebuggerService.DebugStepInformation.Item1;
230 231 int ilOffset = DebuggerService.DebugStepInformation.Item2;
231 232 int line;
14 src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs
@@ -2,7 +2,6 @@
2 2 // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
3 3
4 4 using System;
5   -using System.Collections.Concurrent;
6 5 using System.Collections.Generic;
7 6 using System.IO;
8 7 using System.Text;
@@ -35,8 +34,6 @@ static DebuggerService()
35 34
36 35 BookmarkManager.Added += BookmarkAdded;
37 36 BookmarkManager.Removed += BookmarkRemoved;
38   -
39   - ExternalDebugInformation = new ConcurrentDictionary<int, object>();
40 37 }
41 38
42 39 static void GetDescriptors()
@@ -108,12 +105,6 @@ static IDebugger GetCompatibleDebugger()
108 105 #region Debug third party code
109 106
110 107 /// <summary>
111   - /// Gets or sets the external debug information.
112   - /// <summary>This constains the code mappings and local variables.</summary>
113   - /// </summary>
114   - public static ConcurrentDictionary<int, object> ExternalDebugInformation { get; private set; }
115   -
116   - /// <summary>
117 108 /// Gets or sets the current token and IL offset. Used for step in/out.
118 109 /// </summary>
119 110 public static Tuple<int, int> DebugStepInformation { get; set; }
@@ -470,6 +461,11 @@ public void HandleToolTipRequest(ToolTipRequestEventArgs e)
470 461 public interface IDebuggerDecompilerService
471 462 {
472 463 /// <summary>
  464 + /// Checks the code mappings.
  465 + /// </summary>
  466 + bool CheckMappings(int typeToken);
  467 +
  468 + /// <summary>
473 469 /// Decompiles on demand a type.
474 470 /// </summary>
475 471 void DecompileOnDemand(TypeDefinition type);

Git Notes

build

Build 4.2.0.7708 on master successful

0 comments on commit de36dc4

Please sign in to comment.
Something went wrong with that request. Please try again.