From 58b7e7476aab0157dd06d302c1f18b47c3793863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sat, 14 Nov 2009 13:13:43 +0000 Subject: [PATCH] Fixed SD2-1467 - "Can't load file 17d14f5c-a337-4978-8281-53493378c1071.vb under ." git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5257 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Debugger.AddIn/Pads/RunningThreadsPad.cs | 5 +-- src/AddIns/Debugger/Debugger.Core/Eval.cs | 4 +- .../Debugger.Core/MetaData/DebugMethodInfo.cs | 12 +++--- src/AddIns/Debugger/Debugger.Core/Process.cs | 10 ++++- .../Debugger.Core/SourcecodeSegment.cs | 22 +++++++++++ src/AddIns/Debugger/Debugger.Core/Thread.cs | 39 +++---------------- .../Tests/ControlFlow_MainThreadExit.cs | 12 ++---- .../Debugger.Tests/Tests/Thread_Tests.cs | 14 ++----- 8 files changed, 53 insertions(+), 65 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs index 499f8ddf71..0ba4203fb5 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs @@ -196,10 +196,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads item.SubItems.Add(thread.Name); StackFrame location = null; if (thread.Process.IsPaused) { - location = thread.MostRecentStackFrameWithLoadedSymbols; - if (location == null) { - location = thread.MostRecentStackFrame; - } + location = thread.MostRecentStackFrame; } if (location != null) { item.SubItems.Add(location.MethodInfo.Name); diff --git a/src/AddIns/Debugger/Debugger.Core/Eval.cs b/src/AddIns/Debugger/Debugger.Core/Eval.cs index ffccb279f9..97f8537b57 100644 --- a/src/AddIns/Debugger/Debugger.Core/Eval.cs +++ b/src/AddIns/Debugger/Debugger.Core/Eval.cs @@ -135,7 +135,7 @@ namespace Debugger foreach(Thread t in appDomain.Process.Threads) { if (t.CorThread.GetAppDomain().GetID() == appDomain.ID && !t.Suspended && - !t.IsMostRecentStackFrameNative && + !t.IsInNativeCode && t.IsAtSafePoint) { thread = t; @@ -146,7 +146,7 @@ namespace Debugger if (thread == null) throw new GetValueException("Can not evaluate because no thread is selected"); - if (thread.IsMostRecentStackFrameNative) + if (thread.IsInNativeCode) throw new GetValueException("Can not evaluate because native frame is on top of stack"); if (!thread.IsAtSafePoint) throw new GetValueException("Can not evaluate because thread is not at a safe point"); diff --git a/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs b/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs index 8f77c86ce6..ac61bdf34b 100644 --- a/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs +++ b/src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs @@ -264,7 +264,7 @@ namespace Debugger.MetaData if (this.SymMethod == null) return true; } if (opt.StepOverDebuggerAttributes) { - if (this.HasDebuggerAttribute) return true; + if (this.IsNonUserCode) return true; } if (opt.StepOverAllProperties) { if (this.IsPropertyAccessor) return true; @@ -396,13 +396,13 @@ namespace Debugger.MetaData } } - bool? hasDebuggerAttribute; + bool? isNonUserCode; - bool HasDebuggerAttribute { + public bool IsNonUserCode { get { - if (hasDebuggerAttribute.HasValue) return hasDebuggerAttribute.Value; + if (isNonUserCode.HasValue) return isNonUserCode.Value; - hasDebuggerAttribute = + isNonUserCode = // Look on the method DebugType.IsDefined( this, @@ -419,7 +419,7 @@ namespace Debugger.MetaData typeof(System.Diagnostics.DebuggerNonUserCodeAttribute), typeof(System.Diagnostics.DebuggerHiddenAttribute)); - return hasDebuggerAttribute.Value; + return isNonUserCode.Value; } } diff --git a/src/AddIns/Debugger/Debugger.Core/Process.cs b/src/AddIns/Debugger/Debugger.Core/Process.cs index 985b7774cd..9fc0d34543 100644 --- a/src/AddIns/Debugger/Debugger.Core/Process.cs +++ b/src/AddIns/Debugger/Debugger.Core/Process.cs @@ -525,7 +525,15 @@ namespace Debugger { SelectSomeThread(); if (this.SelectedThread != null) { - this.SelectedThread.SelectedStackFrame = this.SelectedThread.MostRecentStackFrameWithLoadedSymbols; + this.SelectedThread.SelectedStackFrame = null; + foreach (StackFrame stackFrame in this.SelectedThread.Callstack) { + if (stackFrame.HasSymbols) { + if (this.Options.StepOverDebuggerAttributes && stackFrame.MethodInfo.IsNonUserCode) + continue; + this.SelectedThread.SelectedStackFrame = stackFrame; + break; + } + } } } diff --git a/src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs b/src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs index 64c7af15e0..11ab364a20 100644 --- a/src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs +++ b/src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs @@ -311,6 +311,28 @@ namespace Debugger segment.ilStart = ilStart; segment.ilEnd = ilEnd; segment.stepRanges = stepRanges.ToArray(); + + // VB.NET sometimes produces temporary files which it then deletes + // (eg 17d14f5c-a337-4978-8281-53493378c1071.vb) + string filename = Path.GetFileName(segment.filename); + if (filename.Length == 40 && filename.EndsWith(".vb")) { + bool guidName = true; + foreach(char c in filename.Substring(0, filename.Length - 3)) { + if (('0' <= c && c <= '9') || + ('a' <= c && c <= 'f') || + ('A' <= c && c <= 'F') || + (c == '-')) + { + guidName = true; + } else { + guidName = false; + break; + } + } + if (guidName) + return null; + } + return segment; } } diff --git a/src/AddIns/Debugger/Debugger.Core/Thread.cs b/src/AddIns/Debugger/Debugger.Core/Thread.cs index db4ea38c65..16e964e271 100644 --- a/src/AddIns/Debugger/Debugger.Core/Thread.cs +++ b/src/AddIns/Debugger/Debugger.Core/Thread.cs @@ -255,23 +255,24 @@ namespace Debugger /// Gets the whole callstack of the Thread. /// If the thread is in invalid state returns empty array + [Debugger.Tests.Ignore] public StackFrame[] GetCallstack() { - return new List(CallstackEnum).ToArray(); + return new List(Callstack).ToArray(); } /// Get given number of frames from the callstack public StackFrame[] GetCallstack(int maxFrames) { List frames = new List(); - foreach(StackFrame frame in CallstackEnum) { + foreach(StackFrame frame in Callstack) { frames.Add(frame); if (frames.Count == maxFrames) break; } return frames.ToArray(); } - IEnumerable CallstackEnum { + public IEnumerable Callstack { get { process.AssertPaused(); @@ -358,48 +359,20 @@ namespace Debugger } } - #region Convenience methods - - public StackFrame MostRecentStackFrameWithLoadedSymbols { - get { - foreach (StackFrame stackFrame in CallstackEnum) { - if (stackFrame.HasSymbols) { - return stackFrame; - } - } - return null; - } - } - /// /// Returns the most recent stack frame (the one that is currently executing). /// Returns null if callstack is empty. /// public StackFrame MostRecentStackFrame { get { - foreach(StackFrame stackFrame in CallstackEnum) { + foreach(StackFrame stackFrame in Callstack) { return stackFrame; } return null; } } - /// - /// Returns the first stack frame that was called on thread - /// - public StackFrame OldestStackFrame { - get { - StackFrame first = null; - foreach(StackFrame stackFrame in CallstackEnum) { - first = stackFrame; - } - return first; - } - } - - #endregion - - public bool IsMostRecentStackFrameNative { + public bool IsInNativeCode { get { process.AssertPaused(); if (this.IsInValidState) { diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs index 11590d5aeb..d0e5bb47f2 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs @@ -66,28 +66,24 @@ namespace Debugger.Tests { Selected="Thread Name = Suspended = False"> @@ -105,14 +101,12 @@ namespace Debugger.Tests { diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs index b9134ad7c6..ccce3fb7f1 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs @@ -56,13 +56,12 @@ namespace Debugger.Tests { mscorlib.dll (No symbols) @@ -70,14 +69,12 @@ namespace Debugger.Tests { Break Thread_Tests.cs:17,4-17,40 @@ -85,27 +82,24 @@ namespace Debugger.Tests { Break Thread_Tests.cs:19,4-19,40