Browse Source

Extend the lifetime of StackFrame

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3233 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
bf9683cd0f
  1. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Utils.cs
  2. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs
  3. 25
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs
  4. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs
  5. 16
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs

6
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/Utils.cs

@ -31,12 +31,6 @@ namespace Debugger.AddIn.TreeModel @@ -31,12 +31,6 @@ namespace Debugger.AddIn.TreeModel
throw new AbortedBecauseDebuggeeResumedException();
}
}
public static WindowsDebugger WindowsDebugger {
get {
return (WindowsDebugger)DebuggerService.CurrentDebugger;
}
}
}
public class AbortedBecauseDebuggeeResumedException: System.Exception

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs

@ -101,6 +101,7 @@ namespace Debugger @@ -101,6 +101,7 @@ namespace Debugger
internal void RaisePausedEvents()
{
DisableAllSteppers();
CheckSelectedStackFrames();
SelectMostRecentStackFrameWithLoadedSymbols();
if (this.PauseSession.PausedReason == PausedReason.Exception) {
@ -262,6 +263,19 @@ namespace Debugger @@ -262,6 +263,19 @@ namespace Debugger
}
}
internal void CheckSelectedStackFrames()
{
foreach(Thread thread in this.Threads) {
if (thread.IsInValidState) {
if (thread.SelectedStackFrame != null && thread.SelectedStackFrame.IsInvalid) {
thread.SelectedStackFrame = null;
}
} else {
thread.SelectedStackFrame = null;
}
}
}
internal void SelectMostRecentStackFrameWithLoadedSymbols()
{
SelectSomeThread();

25
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs

@ -74,11 +74,15 @@ namespace Debugger @@ -74,11 +74,15 @@ namespace Debugger
}
}
/// <summary> Returns true is this incance can not be used any more.
/// Stack frame is valid only until the debugee is resumed. </summary>
/// <summary> Returns true is this incance can not be used any more. </summary>
public bool IsInvalid {
get {
return this.corILFramePauseSession != process.PauseSession;
try {
object frame = this.CorILFrame;
return false;
} catch (DebuggerException) {
return true;
}
}
}
@ -108,7 +112,13 @@ namespace Debugger @@ -108,7 +112,13 @@ namespace Debugger
internal ICorDebugILFrame CorILFrame {
get {
if (this.IsInvalid) throw new DebuggerException("StackFrame is not valid anymore");
if (corILFramePauseSession != this.Process.PauseSession) {
// Reobtain the stackframe
StackFrame stackFrame = this.Thread.GetStackFrameAt(chainIndex, frameIndex);
if (stackFrame.MethodInfo != this.MethodInfo) throw new DebuggerException("The stack frame on the thread does not represent the same method anymore");
corILFrame = stackFrame.corILFrame;
corILFramePauseSession = stackFrame.corILFramePauseSession;
}
return corILFrame;
}
}
@ -121,13 +131,6 @@ namespace Debugger @@ -121,13 +131,6 @@ namespace Debugger
}
}
internal StackFrame Reobtain()
{
StackFrame stackFrame = this.Thread.GetStackFrameAt(chainIndex, frameIndex);
if (stackFrame.MethodInfo != this.MethodInfo) throw new DebuggerException("The stack frame on the thread does not represent the same method anymore");
return stackFrame;
}
SourcecodeSegment GetSegmentForOffet(uint offset)
{
return SourcecodeSegment.Resolve(this.MethodInfo.Module, corFunction, offset);

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs

@ -107,8 +107,9 @@ namespace Debugger @@ -107,8 +107,9 @@ namespace Debugger
{
if (process.PauseSession.PausedReason == PausedReason.EvalComplete ||
process.PauseSession.PausedReason == PausedReason.ExceptionIntercepted) {
process.SelectMostRecentStackFrameWithLoadedSymbols();
process.DisableAllSteppers();
process.CheckSelectedStackFrames();
// Do not set selected stack frame
// Do not raise events
} else {
// Raise the pause event outside the callback

16
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs

@ -84,13 +84,13 @@ namespace Debugger.Tests { @@ -84,13 +84,13 @@ namespace Debugger.Tests {
<DebuggingPaused>Break FunctionLifetime.cs:29,4-29,40</DebuggingPaused>
<Old_StackFrame>
<StackFrame
ArgumentCount="{Exception: StackFrame is not valid anymore}"
ArgumentCount="1"
ChainIndex="1"
FrameIndex="1"
HasSymbols="True"
IsInvalid="True"
IsInvalid="False"
MethodInfo="Function"
NextStatement="{Exception: StackFrame is not valid anymore}" />
NextStatement="FunctionLifetime.cs:23,4-23,18" />
</Old_StackFrame>
<SelectedStackFrame>
<StackFrame
@ -105,13 +105,13 @@ namespace Debugger.Tests { @@ -105,13 +105,13 @@ namespace Debugger.Tests {
<DebuggingPaused>Break FunctionLifetime.cs:24,4-24,40</DebuggingPaused>
<Old_StackFrame>
<StackFrame
ArgumentCount="{Exception: StackFrame is not valid anymore}"
ArgumentCount="1"
ChainIndex="1"
FrameIndex="1"
HasSymbols="True"
IsInvalid="True"
IsInvalid="False"
MethodInfo="Function"
NextStatement="{Exception: StackFrame is not valid anymore}" />
NextStatement="FunctionLifetime.cs:24,4-24,40" />
</Old_StackFrame>
<SelectedStackFrame>
<StackFrame
@ -136,13 +136,13 @@ namespace Debugger.Tests { @@ -136,13 +136,13 @@ namespace Debugger.Tests {
</Main>
<Old_StackFrame>
<StackFrame
ArgumentCount="{Exception: StackFrame is not valid anymore}"
ArgumentCount="{Exception: The requested frame index is too big}"
ChainIndex="1"
FrameIndex="1"
HasSymbols="True"
IsInvalid="True"
MethodInfo="Function"
NextStatement="{Exception: StackFrame is not valid anymore}" />
NextStatement="{Exception: The requested frame index is too big}" />
</Old_StackFrame>
<SelectedStackFrame>
<StackFrame

Loading…
Cancel
Save