From 3752197b37892efe19ee8d0f2531a052b0a3d349 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 18 Mar 2014 16:28:12 +0100 Subject: [PATCH] fix #364: Stack Pad is horribly slow with "Show argument values" option active --- .../Debugger.AddIn/Pads/CallStackPad.cs | 6 ++--- .../Debugger/Debugger.Core/StackFrame.cs | 22 +++++++++++-------- .../ILSpyAddIn/ILSpyDecompilerService.cs | 19 +++++++--------- .../ILSpyAddIn/ILSpySymbolSource.cs | 1 + 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs index b072de3362..4e0006a4d2 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.cs @@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads return new CallStackItem() { Frame = frame, ImageSource = SD.ResourceService.GetImageSource("Icons.16x16.Method"), - Name = GetFullName(frame), + Name = GetFullName(frame, hasSymbols), HasSymbols = hasSymbols, }; } else { @@ -172,7 +172,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } } - internal static string GetFullName(StackFrame frame) + static string GetFullName(StackFrame frame, bool hasSymbols) { StringBuilder name = new StringBuilder(64); if (DebuggingOptions.Instance.ShowModuleNames) { @@ -193,7 +193,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } if (DebuggingOptions.Instance.ShowArgumentValues) { try { - name.Append(frame.GetArgumentValue(i).AsString(100)); + name.Append(frame.GetArgumentValue(i, hasSymbols).AsString(100)); } catch (GetValueException) { name.Append(ResourceService.GetString("Global.NA")); } diff --git a/src/AddIns/Debugger/Debugger.Core/StackFrame.cs b/src/AddIns/Debugger/Debugger.Core/StackFrame.cs index b871fe6604..2625cc8872 100644 --- a/src/AddIns/Debugger/Debugger.Core/StackFrame.cs +++ b/src/AddIns/Debugger/Debugger.Core/StackFrame.cs @@ -178,7 +178,7 @@ namespace Debugger fromToList.Add(range.To); } } - + if (stepIn) { Stepper stepInStepper = Stepper.StepIn(this, fromToList.ToArray(), "normal"); this.Thread.CurrentStepIn = stepInStepper; @@ -282,13 +282,15 @@ namespace Debugger } /// Gets argument with a given name - public Value GetArgumentValue(string name) + public Value GetArgumentValue(string name, bool checkCapturedVariables = true) { + if (checkCapturedVariables) { + LocalVariable capturedVar; + if (HasCapturedVariable(name, out capturedVar)) + return capturedVar.GetValue(this); + } for (int i = 0; i < this.MethodInfo.Parameters.Count; i++) { if (this.MethodInfo.Parameters[i].Name == name) { - LocalVariable capturedVar; - if (HasCapturedVariable(name, out capturedVar)) - return capturedVar.GetValue(this); return GetArgumentValue(i); } } @@ -297,12 +299,14 @@ namespace Debugger /// Gets argument with a given index /// Zero-based index - public Value GetArgumentValue(int index) + public Value GetArgumentValue(int index, bool checkCapturedVariables = true) { var param = this.MethodInfo.Parameters[index]; - LocalVariable capturedVariable; - if (HasCapturedVariable(param.Name, out capturedVariable)) - return capturedVariable.GetValue(this); + if (checkCapturedVariables) { + LocalVariable capturedVariable; + if (HasCapturedVariable(param.Name, out capturedVariable)) + return capturedVariable.GetValue(this); + } return new Value(this.AppDomain, GetArgumentCorValue(index)); } diff --git a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs index 72d87bee28..347678040e 100644 --- a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs +++ b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpyDecompilerService.cs @@ -88,7 +88,7 @@ namespace ICSharpCode.ILSpyAddIn public ISet ResolvedAssemblies { get { return resolvedAssemblies; } } - + public ILSpyAssemblyResolver(FileName fileName) : base(fileName) { @@ -134,8 +134,10 @@ namespace ICSharpCode.ILSpyAddIn { if (name == null) throw new ArgumentNullException("name"); - var astBuilder = CreateAstBuilder(name, cancellationToken); - return new ILSpyFullParseInformation(ILSpyUnresolvedFile.Create(name, astBuilder), null, astBuilder.SyntaxTree); + using (DebugTimer.Time("DecompileType: " + name.ToFileName())) { + var astBuilder = CreateAstBuilder(name, cancellationToken); + return new ILSpyFullParseInformation(ILSpyUnresolvedFile.Create(name, astBuilder), null, astBuilder.SyntaxTree); + } } static AstBuilder CreateAstBuilder(DecompiledTypeReference name, CancellationToken cancellationToken = default(CancellationToken)) @@ -152,11 +154,6 @@ namespace ICSharpCode.ILSpyAddIn astBuilder.AddType(typeDefinition); return astBuilder; } - - static ILSpyUnresolvedFile DoDecompile(DecompiledTypeReference name, CancellationToken cancellationToken = default(CancellationToken)) - { - return ILSpyUnresolvedFile.Create(name, CreateAstBuilder(name, cancellationToken)); - } } public class DecompiledTypeReference : IEquatable @@ -231,7 +228,7 @@ namespace ICSharpCode.ILSpyAddIn { return object.Equals(this.AssemblyFile, other.AssemblyFile) && this.Type == other.Type; } - + public override int GetHashCode() { int hashCode = 0; @@ -242,7 +239,7 @@ namespace ICSharpCode.ILSpyAddIn } return hashCode; } - + public static bool operator ==(DecompiledTypeReference lhs, DecompiledTypeReference rhs) { if (ReferenceEquals(lhs, rhs)) return true; @@ -250,7 +247,7 @@ namespace ICSharpCode.ILSpyAddIn return false; return lhs.Equals(rhs); } - + public static bool operator !=(DecompiledTypeReference lhs, DecompiledTypeReference rhs) { return !(lhs == rhs); } diff --git a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs index 1722f83776..990ccb1a1c 100644 --- a/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs +++ b/src/AddIns/DisplayBindings/ILSpyAddIn/ILSpySymbolSource.cs @@ -28,6 +28,7 @@ namespace ICSharpCode.ILSpyAddIn { var typeName = DecompiledTypeReference.FromTypeDefinition(method.DeclaringTypeDefinition); if (typeName == null) return null; + SD.Log.DebugFormatted("GetSymbols for: {0}", typeName.ToFileName()); return SD.ParserService.ParseFile(typeName.ToFileName()) as ILSpyUnresolvedFile; }