Browse Source

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
pull/1/head
David Srbecký 16 years ago
parent
commit
58b7e7476a
  1. 3
      src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs
  2. 4
      src/AddIns/Debugger/Debugger.Core/Eval.cs
  3. 12
      src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs
  4. 10
      src/AddIns/Debugger/Debugger.Core/Process.cs
  5. 22
      src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs
  6. 39
      src/AddIns/Debugger/Debugger.Core/Thread.cs
  7. 12
      src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs
  8. 14
      src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs

3
src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs

@ -196,11 +196,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
item.SubItems.Add(thread.Name); item.SubItems.Add(thread.Name);
StackFrame location = null; StackFrame location = null;
if (thread.Process.IsPaused) { if (thread.Process.IsPaused) {
location = thread.MostRecentStackFrameWithLoadedSymbols;
if (location == null) {
location = thread.MostRecentStackFrame; location = thread.MostRecentStackFrame;
} }
}
if (location != null) { if (location != null) {
item.SubItems.Add(location.MethodInfo.Name); item.SubItems.Add(location.MethodInfo.Name);
} else { } else {

4
src/AddIns/Debugger/Debugger.Core/Eval.cs

@ -135,7 +135,7 @@ namespace Debugger
foreach(Thread t in appDomain.Process.Threads) { foreach(Thread t in appDomain.Process.Threads) {
if (t.CorThread.GetAppDomain().GetID() == appDomain.ID && if (t.CorThread.GetAppDomain().GetID() == appDomain.ID &&
!t.Suspended && !t.Suspended &&
!t.IsMostRecentStackFrameNative && !t.IsInNativeCode &&
t.IsAtSafePoint) t.IsAtSafePoint)
{ {
thread = t; thread = t;
@ -146,7 +146,7 @@ namespace Debugger
if (thread == null) if (thread == null)
throw new GetValueException("Can not evaluate because no thread is selected"); 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"); throw new GetValueException("Can not evaluate because native frame is on top of stack");
if (!thread.IsAtSafePoint) if (!thread.IsAtSafePoint)
throw new GetValueException("Can not evaluate because thread is not at a safe point"); throw new GetValueException("Can not evaluate because thread is not at a safe point");

12
src/AddIns/Debugger/Debugger.Core/MetaData/DebugMethodInfo.cs

@ -264,7 +264,7 @@ namespace Debugger.MetaData
if (this.SymMethod == null) return true; if (this.SymMethod == null) return true;
} }
if (opt.StepOverDebuggerAttributes) { if (opt.StepOverDebuggerAttributes) {
if (this.HasDebuggerAttribute) return true; if (this.IsNonUserCode) return true;
} }
if (opt.StepOverAllProperties) { if (opt.StepOverAllProperties) {
if (this.IsPropertyAccessor) return true; if (this.IsPropertyAccessor) return true;
@ -396,13 +396,13 @@ namespace Debugger.MetaData
} }
} }
bool? hasDebuggerAttribute; bool? isNonUserCode;
bool HasDebuggerAttribute { public bool IsNonUserCode {
get { get {
if (hasDebuggerAttribute.HasValue) return hasDebuggerAttribute.Value; if (isNonUserCode.HasValue) return isNonUserCode.Value;
hasDebuggerAttribute = isNonUserCode =
// Look on the method // Look on the method
DebugType.IsDefined( DebugType.IsDefined(
this, this,
@ -419,7 +419,7 @@ namespace Debugger.MetaData
typeof(System.Diagnostics.DebuggerNonUserCodeAttribute), typeof(System.Diagnostics.DebuggerNonUserCodeAttribute),
typeof(System.Diagnostics.DebuggerHiddenAttribute)); typeof(System.Diagnostics.DebuggerHiddenAttribute));
return hasDebuggerAttribute.Value; return isNonUserCode.Value;
} }
} }

10
src/AddIns/Debugger/Debugger.Core/Process.cs

@ -525,7 +525,15 @@ namespace Debugger
{ {
SelectSomeThread(); SelectSomeThread();
if (this.SelectedThread != null) { 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;
}
}
} }
} }

22
src/AddIns/Debugger/Debugger.Core/SourcecodeSegment.cs

@ -311,6 +311,28 @@ namespace Debugger
segment.ilStart = ilStart; segment.ilStart = ilStart;
segment.ilEnd = ilEnd; segment.ilEnd = ilEnd;
segment.stepRanges = stepRanges.ToArray(); 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; return segment;
} }
} }

39
src/AddIns/Debugger/Debugger.Core/Thread.cs

@ -255,23 +255,24 @@ namespace Debugger
/// <summary> Gets the whole callstack of the Thread. </summary> /// <summary> Gets the whole callstack of the Thread. </summary>
/// <remarks> If the thread is in invalid state returns empty array </remarks> /// <remarks> If the thread is in invalid state returns empty array </remarks>
[Debugger.Tests.Ignore]
public StackFrame[] GetCallstack() public StackFrame[] GetCallstack()
{ {
return new List<StackFrame>(CallstackEnum).ToArray(); return new List<StackFrame>(Callstack).ToArray();
} }
/// <summary> Get given number of frames from the callstack </summary> /// <summary> Get given number of frames from the callstack </summary>
public StackFrame[] GetCallstack(int maxFrames) public StackFrame[] GetCallstack(int maxFrames)
{ {
List<StackFrame> frames = new List<StackFrame>(); List<StackFrame> frames = new List<StackFrame>();
foreach(StackFrame frame in CallstackEnum) { foreach(StackFrame frame in Callstack) {
frames.Add(frame); frames.Add(frame);
if (frames.Count == maxFrames) break; if (frames.Count == maxFrames) break;
} }
return frames.ToArray(); return frames.ToArray();
} }
IEnumerable<StackFrame> CallstackEnum { public IEnumerable<StackFrame> Callstack {
get { get {
process.AssertPaused(); 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;
}
}
/// <summary> /// <summary>
/// Returns the most recent stack frame (the one that is currently executing). /// Returns the most recent stack frame (the one that is currently executing).
/// Returns null if callstack is empty. /// Returns null if callstack is empty.
/// </summary> /// </summary>
public StackFrame MostRecentStackFrame { public StackFrame MostRecentStackFrame {
get { get {
foreach(StackFrame stackFrame in CallstackEnum) { foreach(StackFrame stackFrame in Callstack) {
return stackFrame; return stackFrame;
} }
return null; return null;
} }
} }
/// <summary> public bool IsInNativeCode {
/// Returns the first stack frame that was called on thread
/// </summary>
public StackFrame OldestStackFrame {
get {
StackFrame first = null;
foreach(StackFrame stackFrame in CallstackEnum) {
first = stackFrame;
}
return first;
}
}
#endregion
public bool IsMostRecentStackFrameNative {
get { get {
process.AssertPaused(); process.AssertPaused();
if (this.IsInValidState) { if (this.IsInValidState) {

12
src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs

@ -66,28 +66,24 @@ namespace Debugger.Tests {
Selected="Thread Name = Suspended = False"> Selected="Thread Name = Suspended = False">
<Item> <Item>
<Thread <Thread
Callstack="{static void Debugger.Tests.ControlFlow_MainThreadExit.Main()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{static void Debugger.Tests.ControlFlow_MainThreadExit.Main()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()" MostRecentStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()"
MostRecentStackFrameWithLoadedSymbols="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()"
Name="" Name=""
OldestStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()"
Priority="Normal" Priority="Normal"
RuntimeValue="{System.Threading.Thread}" RuntimeValue="{System.Threading.Thread}"
SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()" /> SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()" />
</Item> </Item>
<Item> <Item>
<Thread <Thread
Callstack="{static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)" MostRecentStackFrame="static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
MostRecentStackFrameWithLoadedSymbols="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()"
Name="Worker thread" Name="Worker thread"
OldestStackFrame="void System.Threading.ThreadHelper.ThreadStart()"
Priority="Normal" Priority="Normal"
RuntimeValue="{System.Threading.Thread}" /> RuntimeValue="{System.Threading.Thread}" />
</Item> </Item>
@ -105,14 +101,12 @@ namespace Debugger.Tests {
</Item> </Item>
<Item> <Item>
<Thread <Thread
Callstack="{static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), System.Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)" MostRecentStackFrame="static System.Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
MostRecentStackFrameWithLoadedSymbols="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()"
Name="Worker thread" Name="Worker thread"
OldestStackFrame="void System.Threading.ThreadHelper.ThreadStart()"
Priority="Normal" Priority="Normal"
RuntimeValue="{System.Threading.Thread}" RuntimeValue="{System.Threading.Thread}"
SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()" /> SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()" />

14
src/AddIns/Debugger/Debugger.Tests/Tests/Thread_Tests.cs

@ -56,13 +56,12 @@ namespace Debugger.Tests {
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded> <ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ThreadStartedEvent> <ThreadStartedEvent>
<Thread <Thread
Callstack="{void System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile)}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{void System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile)}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="void System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile)" MostRecentStackFrame="void System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile)"
Name="" Name=""
OldestStackFrame="void System.AppDomain.SetupDomain(Boolean allowRedirects, String path, String configFile)"
Priority="Normal" Priority="Normal"
RuntimeValue="null" /> RuntimeValue="null" />
</ThreadStartedEvent> </ThreadStartedEvent>
@ -70,14 +69,12 @@ namespace Debugger.Tests {
<DebuggingPaused>Break Thread_Tests.cs:17,4-17,40</DebuggingPaused> <DebuggingPaused>Break Thread_Tests.cs:17,4-17,40</DebuggingPaused>
<Thread> <Thread>
<Thread <Thread
Callstack="{static void Debugger.Tests.Thread_Tests.Main()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{static void Debugger.Tests.Thread_Tests.Main()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="static void Debugger.Tests.Thread_Tests.Main()" MostRecentStackFrame="static void Debugger.Tests.Thread_Tests.Main()"
MostRecentStackFrameWithLoadedSymbols="static void Debugger.Tests.Thread_Tests.Main()"
Name="" Name=""
OldestStackFrame="static void Debugger.Tests.Thread_Tests.Main()"
Priority="AboveNormal" Priority="AboveNormal"
RuntimeValue="{System.Threading.Thread}" RuntimeValue="{System.Threading.Thread}"
SelectedStackFrame="static void Debugger.Tests.Thread_Tests.Main()" /> SelectedStackFrame="static void Debugger.Tests.Thread_Tests.Main()" />
@ -85,27 +82,24 @@ namespace Debugger.Tests {
<DebuggingPaused>Break Thread_Tests.cs:19,4-19,40</DebuggingPaused> <DebuggingPaused>Break Thread_Tests.cs:19,4-19,40</DebuggingPaused>
<Thread> <Thread>
<Thread <Thread
Callstack="{static void Debugger.Tests.Thread_Tests.Main()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{static void Debugger.Tests.Thread_Tests.Main()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="static void Debugger.Tests.Thread_Tests.Main()" MostRecentStackFrame="static void Debugger.Tests.Thread_Tests.Main()"
MostRecentStackFrameWithLoadedSymbols="static void Debugger.Tests.Thread_Tests.Main()"
Name="ThreadName" Name="ThreadName"
OldestStackFrame="static void Debugger.Tests.Thread_Tests.Main()"
Priority="AboveNormal" Priority="AboveNormal"
RuntimeValue="{System.Threading.Thread}" RuntimeValue="{System.Threading.Thread}"
SelectedStackFrame="static void Debugger.Tests.Thread_Tests.Main()" /> SelectedStackFrame="static void Debugger.Tests.Thread_Tests.Main()" />
</Thread> </Thread>
<ThreadStartedEvent> <ThreadStartedEvent>
<Thread <Thread
Callstack="{void System.Threading.ReaderWriterLock.Finalize()}"
CurrentExceptionType="0" CurrentExceptionType="0"
GetCallstack="{void System.Threading.ReaderWriterLock.Finalize()}"
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
MostRecentStackFrame="void System.Threading.ReaderWriterLock.Finalize()" MostRecentStackFrame="void System.Threading.ReaderWriterLock.Finalize()"
Name="" Name=""
OldestStackFrame="void System.Threading.ReaderWriterLock.Finalize()"
Priority="Normal" Priority="Normal"
RuntimeValue="null" /> RuntimeValue="null" />
</ThreadStartedEvent> </ThreadStartedEvent>

Loading…
Cancel
Save