Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 3752197

Browse files
fix #364: Stack Pad is horribly slow with "Show argument values" option active
1 parent f84804f commit 3752197

4 files changed

Lines changed: 25 additions & 23 deletions

File tree

src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ CallStackItem CreateItem(StackFrame frame, ref bool previousItemIsExternalMethod
157157
return new CallStackItem() {
158158
Frame = frame,
159159
ImageSource = SD.ResourceService.GetImageSource("Icons.16x16.Method"),
160-
Name = GetFullName(frame),
160+
Name = GetFullName(frame, hasSymbols),
161161
HasSymbols = hasSymbols,
162162
};
163163
} else {
@@ -172,7 +172,7 @@ CallStackItem CreateItem(StackFrame frame, ref bool previousItemIsExternalMethod
172172
}
173173
}
174174

175-
internal static string GetFullName(StackFrame frame)
175+
static string GetFullName(StackFrame frame, bool hasSymbols)
176176
{
177177
StringBuilder name = new StringBuilder(64);
178178
if (DebuggingOptions.Instance.ShowModuleNames) {
@@ -193,7 +193,7 @@ internal static string GetFullName(StackFrame frame)
193193
}
194194
if (DebuggingOptions.Instance.ShowArgumentValues) {
195195
try {
196-
name.Append(frame.GetArgumentValue(i).AsString(100));
196+
name.Append(frame.GetArgumentValue(i, hasSymbols).AsString(100));
197197
} catch (GetValueException) {
198198
name.Append(ResourceService.GetString("Global.NA"));
199199
}

src/AddIns/Debugger/Debugger.Core/StackFrame.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void AsyncStep(bool stepIn)
178178
fromToList.Add(range.To);
179179
}
180180
}
181-
181+
182182
if (stepIn) {
183183
Stepper stepInStepper = Stepper.StepIn(this, fromToList.ToArray(), "normal");
184184
this.Thread.CurrentStepIn = stepInStepper;
@@ -282,13 +282,15 @@ public int ArgumentCount {
282282
}
283283

284284
/// <summary> Gets argument with a given name </summary>
285-
public Value GetArgumentValue(string name)
285+
public Value GetArgumentValue(string name, bool checkCapturedVariables = true)
286286
{
287+
if (checkCapturedVariables) {
288+
LocalVariable capturedVar;
289+
if (HasCapturedVariable(name, out capturedVar))
290+
return capturedVar.GetValue(this);
291+
}
287292
for (int i = 0; i < this.MethodInfo.Parameters.Count; i++) {
288293
if (this.MethodInfo.Parameters[i].Name == name) {
289-
LocalVariable capturedVar;
290-
if (HasCapturedVariable(name, out capturedVar))
291-
return capturedVar.GetValue(this);
292294
return GetArgumentValue(i);
293295
}
294296
}
@@ -297,12 +299,14 @@ public Value GetArgumentValue(string name)
297299

298300
/// <summary> Gets argument with a given index </summary>
299301
/// <param name="index"> Zero-based index </param>
300-
public Value GetArgumentValue(int index)
302+
public Value GetArgumentValue(int index, bool checkCapturedVariables = true)
301303
{
302304
var param = this.MethodInfo.Parameters[index];
303-
LocalVariable capturedVariable;
304-
if (HasCapturedVariable(param.Name, out capturedVariable))
305-
return capturedVariable.GetValue(this);
305+
if (checkCapturedVariables) {
306+
LocalVariable capturedVariable;
307+
if (HasCapturedVariable(param.Name, out capturedVariable))
308+
return capturedVariable.GetValue(this);
309+
}
306310
return new Value(this.AppDomain, GetArgumentCorValue(index));
307311
}
308312

src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ILSpyAssemblyResolver : DefaultAssemblySearcher, IAssemblyResolver
8888
public ISet<AssemblyDefinition> ResolvedAssemblies {
8989
get { return resolvedAssemblies; }
9090
}
91-
91+
9292
public ILSpyAssemblyResolver(FileName fileName)
9393
: base(fileName)
9494
{
@@ -134,8 +134,10 @@ public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
134134
{
135135
if (name == null)
136136
throw new ArgumentNullException("name");
137-
var astBuilder = CreateAstBuilder(name, cancellationToken);
138-
return new ILSpyFullParseInformation(ILSpyUnresolvedFile.Create(name, astBuilder), null, astBuilder.SyntaxTree);
137+
using (DebugTimer.Time("DecompileType: " + name.ToFileName())) {
138+
var astBuilder = CreateAstBuilder(name, cancellationToken);
139+
return new ILSpyFullParseInformation(ILSpyUnresolvedFile.Create(name, astBuilder), null, astBuilder.SyntaxTree);
140+
}
139141
}
140142

141143
static AstBuilder CreateAstBuilder(DecompiledTypeReference name, CancellationToken cancellationToken = default(CancellationToken))
@@ -152,11 +154,6 @@ public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
152154
astBuilder.AddType(typeDefinition);
153155
return astBuilder;
154156
}
155-
156-
static ILSpyUnresolvedFile DoDecompile(DecompiledTypeReference name, CancellationToken cancellationToken = default(CancellationToken))
157-
{
158-
return ILSpyUnresolvedFile.Create(name, CreateAstBuilder(name, cancellationToken));
159-
}
160157
}
161158

162159
public class DecompiledTypeReference : IEquatable<DecompiledTypeReference>
@@ -231,7 +228,7 @@ public bool Equals(DecompiledTypeReference other)
231228
{
232229
return object.Equals(this.AssemblyFile, other.AssemblyFile) && this.Type == other.Type;
233230
}
234-
231+
235232
public override int GetHashCode()
236233
{
237234
int hashCode = 0;
@@ -242,15 +239,15 @@ public override int GetHashCode()
242239
}
243240
return hashCode;
244241
}
245-
242+
246243
public static bool operator ==(DecompiledTypeReference lhs, DecompiledTypeReference rhs) {
247244
if (ReferenceEquals(lhs, rhs))
248245
return true;
249246
if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
250247
return false;
251248
return lhs.Equals(rhs);
252249
}
253-
250+
254251
public static bool operator !=(DecompiledTypeReference lhs, DecompiledTypeReference rhs) {
255252
return !(lhs == rhs);
256253
}

src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static ILSpyUnresolvedFile GetSymbols(IMethod method)
2828
{
2929
var typeName = DecompiledTypeReference.FromTypeDefinition(method.DeclaringTypeDefinition);
3030
if (typeName == null) return null;
31+
SD.Log.DebugFormatted("GetSymbols for: {0}", typeName.ToFileName());
3132
return SD.ParserService.ParseFile(typeName.ToFileName()) as ILSpyUnresolvedFile;
3233
}
3334

0 commit comments

Comments
 (0)