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

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

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

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

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

Loading…
Cancel
Save