Browse Source

Fixed SD2-505: Debugger freezes on StackOverflowException

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@667 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
d94907f1da
  1. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  3. 44
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

3
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs

@ -196,6 +196,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -196,6 +196,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
bool showArgumentValues = ShowArgumentValues;
bool showExternalMethods = ShowExternalMethods;
bool lastItemIsExternalMethod = false;
int callstackItems = 0;
callStackList.BeginUpdate();
callStackList.Items.Clear();
@ -253,6 +254,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -253,6 +254,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
item.Tag = f;
item.ForeColor = f.HasSymbols ? Color.Black : Color.Gray;
callStackList.Items.Add(item);
callstackItems++;
if (callstackItems >= 100) break;
}
}
callStackList.EndUpdate();

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

@ -54,13 +54,20 @@ namespace DebuggerLibrary @@ -54,13 +54,20 @@ namespace DebuggerLibrary
}
callstack = "";
int callstackItems = 0;
foreach(Function function in thread.Callstack) {
if (callstackItems >= 100) {
callstack += "...\n";
break;
}
SourcecodeSegment loc = function.NextStatement;
callstack += function.Name + "()";
if (loc != null) {
callstack += " - " + loc.SourceFullFilename + ":" + loc.StartLine + "," + loc.StartColumn;
}
callstack += "\n";
callstackItems++;
}
type = runtimeVariable.Type;

44
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -185,15 +185,13 @@ namespace DebuggerLibrary @@ -185,15 +185,13 @@ namespace DebuggerLibrary
}
}
public unsafe List<Function> Callstack {
public IEnumerable<Function> Callstack {
get {
List<Function> callstack = new List<Function>();
if (process.IsRunning) return callstack;
if (process.IsRunning) yield break;
ICorDebugChainEnum corChainEnum;
corThread.EnumerateChains(out corChainEnum);
while (true) {
uint chainsFetched;
ICorDebugChain[] corChains = new ICorDebugChain[1]; // One at time
@ -203,27 +201,27 @@ namespace DebuggerLibrary @@ -203,27 +201,27 @@ namespace DebuggerLibrary
int isManaged;
corChains[0].IsManaged(out isManaged);
if (isManaged == 0) continue; // Only managed ones
ICorDebugFrameEnum corFrameEnum;
corChains[0].EnumerateFrames(out corFrameEnum);
for(;;)
{
while (true) {
uint framesFetched;
ICorDebugFrame[] corFrames = new ICorDebugFrame[1]; // Only one at time
corFrameEnum.Next(1, corFrames, out framesFetched);
if (framesFetched == 0) break; // We are done
try {
Function function = null;
try {
if (corFrames[0] is ICorDebugILFrame) {
callstack.Add(new Function(debugger, (ICorDebugILFrame)corFrames[0]));
function = new Function(debugger, (ICorDebugILFrame)corFrames[0]);
}
} catch (COMException) {
} catch (COMException) {
// TODO
};
yield return function;
}
} // for(;;)
return callstack;
}
} // get
} // End of public FunctionCollection Callstack
@ -267,15 +265,17 @@ namespace DebuggerLibrary @@ -267,15 +265,17 @@ namespace DebuggerLibrary
return null;
}
}
/// <summary>
/// Returns the most recent function on callstack.
/// Returns null if callstack is empty.
/// </summary>
public Function LastFunction {
get {
List<Function> callstack = Callstack;
if (callstack.Count > 0) {
return Callstack[0];
} else {
return null;
foreach(Function function in Callstack) {
return function;
}
return null;
}
}
}

Loading…
Cancel
Save