From 4964163792db01699048e1489f0fe6ea25dbb8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Fri, 18 Jan 2008 22:11:42 +0000 Subject: [PATCH] Added StackOverflow test. Updated tests. Fixed null reference in Tread.SelectedStackFrame. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2877 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Threads/Thread.cs | 7 +- .../Project/Debugger.Tests.csproj | 1 + .../Project/Src/TestPrograms/ArrayValue.cs | 48 +++--- .../Project/Src/TestPrograms/Callstack.cs | 15 +- .../TestPrograms/FunctionArgumentVariables.cs | 112 ++++++------ .../Src/TestPrograms/FunctionLifetime.cs | 8 + .../TestPrograms/FunctionLocalVariables.cs | 40 ++--- .../TestPrograms/FunctionVariablesLifetime.cs | 160 +++++++++--------- .../Project/Src/TestPrograms/Generics.cs | 8 + .../Project/Src/TestPrograms/StackOverflow.cs | 67 ++++++++ .../Project/Src/TestPrograms/ValueType.cs | 8 +- 11 files changed, 281 insertions(+), 193 deletions(-) create mode 100644 src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs index bee4091067..5b3fceaebd 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs @@ -235,9 +235,10 @@ namespace Debugger } } - public IList Callstack { + public IEnumerable Callstack { get { - return new List(CallstackEnum).AsReadOnly(); + // This should be enum since callstacks can get big + return CallstackEnum; } } @@ -267,7 +268,7 @@ namespace Debugger public StackFrame SelectedStackFrame { get { // Forum-20456: Do not return expired StackFrame - if (selectedStackFrame.HasExpired) return null; + if (selectedStackFrame != null && selectedStackFrame.HasExpired) return null; return selectedStackFrame; } set { diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj index e2c32ce467..e2a8029935 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj @@ -63,6 +63,7 @@ + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs index a05d894110..cbda60ba7d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ArrayValue.cs @@ -56,15 +56,15 @@ namespace Debugger.Tests { 5 1 [5] - False - False - False - array False {System.Int32[]} False System.Int32[] + False + False + False + @@ -72,75 +72,75 @@ namespace Debugger.Tests { - False - True - True - 0 array[0] False 0 False System.Int32 + False + True + True + 0 False - False - True - True - 1 array[1] False 1 False System.Int32 + False + True + True + 1 False - False - True - True - 2 array[2] False 2 False System.Int32 + False + True + True + 2 False - False - True - True - 3 array[3] False 3 False System.Int32 + False + True + True + 3 False - False - True - True - 4 array[4] False 4 False System.Int32 + False + True + True + 4 diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.cs index d0b7f926e2..2d037c53e1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Callstack.cs @@ -63,10 +63,10 @@ namespace Debugger.Tests { mscorlib.dll Callstack.exe Break - - 3 + Sub2 + 0 True False Start=26,4 End=26,40 @@ -74,6 +74,7 @@ namespace Debugger.Tests { Sub1 + 1 True False Start=21,4 End=21,11 @@ -81,6 +82,7 @@ namespace Debugger.Tests { Main + 2 True False Start=16,4 End=16,11 @@ -88,10 +90,10 @@ namespace Debugger.Tests { StepComplete - - 2 + Sub1 + 0 True False Start=21,4 End=21,11 @@ -99,6 +101,7 @@ namespace Debugger.Tests { Main + 1 True False Start=16,4 End=16,11 @@ -106,10 +109,10 @@ namespace Debugger.Tests { StepComplete - - 1 + Main + 0 True False Start=16,4 End=16,11 diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs index 4ec765ba0a..86ea00f0ac 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionArgumentVariables.cs @@ -103,135 +103,135 @@ namespace Debugger.Tests { - False - True - True - 1 i False 1 False System.Int32 + False + True + True + 1 False - False - True - False - A s False A False System.String + False + True + False + A False - False - False - False - s_null True <null> False System.Object + False + False + False + False - False - True - True - 2 ref_i False 2 False System.Int32 + False + True + True + 2 False - False - True - True - 3 out_i False 3 False System.Int32 + False + True + True + 3 False - False - True - True - 0 out_i2 False 0 False System.Int32 + False + True + True + 0 False - False - True - False - B ref_s False B False System.String + False + True + False + B False - True - False - False - iNull False {System.Nullable<System.Int32>} False System.Nullable<System.Int32> + True + False + False + False - True - False - False - iNull_null False {System.Nullable<System.Int32>} False System.Nullable<System.Int32> + True + False + False + Break @@ -241,15 +241,15 @@ namespace Debugger.Tests { 0 1 [0] - False - False - False - args False {System.String[]} False System.String[] + False + False + False + Break @@ -259,15 +259,15 @@ namespace Debugger.Tests { 1 1 [1] - False - False - False - args False {System.String[]} False System.String[] + False + False + False + Break @@ -277,15 +277,15 @@ namespace Debugger.Tests { 2 1 [2] - False - False - False - args False {System.String[]} False System.String[] + False + False + False + Break @@ -295,30 +295,30 @@ namespace Debugger.Tests { - False - True - True - 1 i False 1 False System.Int32 + False + True + True + 1 False - False - True - False - A s False A False System.String + False + True + False + A diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs index 04cb750a19..cc795ac256 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLifetime.cs @@ -77,6 +77,7 @@ namespace Debugger.Tests { Break Function + 0 True False Start=22,4 End=22,40 @@ -85,6 +86,7 @@ namespace Debugger.Tests { Break Function + 0 True True @@ -92,6 +94,7 @@ namespace Debugger.Tests { SubFunction + 0 True False Start=29,4 End=29,40 @@ -100,6 +103,7 @@ namespace Debugger.Tests { Break Function + 0 True True @@ -107,6 +111,7 @@ namespace Debugger.Tests { Function + 0 True False Start=24,4 End=24,40 @@ -115,6 +120,7 @@ namespace Debugger.Tests { Break
Main + 0 True False Start=17,4 End=17,40 @@ -122,6 +128,7 @@ namespace Debugger.Tests {
Function + 0 True True @@ -129,6 +136,7 @@ namespace Debugger.Tests { Main + 0 True False Start=17,4 End=17,40 diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs index 0b2fc65638..ad4632769c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionLocalVariables.cs @@ -56,75 +56,75 @@ namespace Debugger.Tests { - False - True - True - 0 i False 0 False System.Int32 + False + True + True + 0 False - False - True - False - S s False S False System.String + False + True + False + S True 1 1 [1] - False - False - False - args False {System.String[]} False System.String[] + False + False + False + False - False - False - False - n True <null> False System.Object + False + False + False + False - True - False - False - o False {System.Object} False System.Object + True + False + False + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs index 2e0a10e9b0..1bec095bd1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs @@ -109,45 +109,45 @@ namespace Debugger.Tests { - False - True - True - 1 argument False 1 False System.Int32 + False + True + True + 1 False - False - True - True - 2 local False 2 False System.Int32 + False + True + True + 2 <_x0040_class Type="Value" ToString="this.class = 3"> False - False - True - True - 3 this.class False 3 False System.Int32 + False + True + True + 3 Break @@ -155,60 +155,60 @@ namespace Debugger.Tests { - - - - argument True System.Int32 + + + + - - - - local True System.Int32 + + + + <_x0040_class Type="Value" ToString_exception="Value has expired"> - - - - this.class True System.Int32 + + + + False - False - True - True - 4 localInSubFunction False 4 False System.Int32 + False + True + True + 4 Break @@ -216,60 +216,60 @@ namespace Debugger.Tests { - - - - argument True System.Int32 + + + + - - - - local True System.Int32 + + + + <_x0040_class Type="Value" ToString_exception="Value has expired"> - - - - this.class True System.Int32 + + + + - - - - localInSubFunction True System.Int32 + + + + Break @@ -277,75 +277,75 @@ namespace Debugger.Tests { - - - - argument True System.Int32 + + + + - - - - local True System.Int32 + + + + <_x0040_class Type="Value" ToString_exception="Value has expired"> - - - - this.class True System.Int32 + + + + - - - - localInSubFunction True System.Int32 + + + + False - False - True - True - 4 localInSubFunction False 4 False System.Int32 + False + True + True + 4 Break @@ -353,60 +353,60 @@ namespace Debugger.Tests { - - - - argument True System.Int32 + + + + - - - - local True System.Int32 + + + + <_x0040_class Type="Value" ToString_exception="Value has expired"> - - - - this.class True System.Int32 + + + + - - - - localInSubFunction True System.Int32 + + + + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs index 1c66282778..215979baed 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs @@ -159,6 +159,7 @@ namespace Debugger.Tests { System.Object + 0 True False Start=48,4 End=48,40 @@ -220,6 +221,7 @@ namespace Debugger.Tests { System.Object + 0 True False Start=54,4 End=54,40 @@ -281,6 +283,7 @@ namespace Debugger.Tests { System.Object + 0 True False Start=60,4 End=60,40 @@ -342,6 +345,7 @@ namespace Debugger.Tests { System.Object + 0 True False Start=66,4 End=66,40 @@ -403,6 +407,7 @@ namespace Debugger.Tests { System.ValueType + 0 True False Start=75,4 End=75,40 @@ -464,6 +469,7 @@ namespace Debugger.Tests { System.ValueType + 0 True False Start=81,4 End=81,40 @@ -525,6 +531,7 @@ namespace Debugger.Tests { System.ValueType + 0 True False Start=87,4 End=87,40 @@ -586,6 +593,7 @@ namespace Debugger.Tests { System.ValueType + 0 True False Start=93,4 End=93,40 diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs new file mode 100644 index 0000000000..4930b0c221 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/StackOverflow.cs @@ -0,0 +1,67 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Debugger.Tests.TestPrograms +{ + public class StackOverflow + { + public static void Main() + { + System.Diagnostics.Debugger.Break(); + new StackOverflow().Fun(0); + } + + public int Fun(int i) + { + return Fun(i + 1); + } + } +} + +#if TEST_CODE +namespace Debugger.Tests { + public partial class DebuggerTests + { + [NUnit.Framework.Test] + public void StackOverflow() + { + StartTest("StackOverflow.cs"); + WaitForPause(); + + process.Continue(); + WaitForPause(); + ObjectDump("LastStackFrame", process.SelectedThread.LastStackFrame); + + CheckXmlOutput(); + } + } +} +#endif + +#if EXPECTED_OUTPUT + + + + + mscorlib.dll + StackOverflow.exe + Break + Exception + <null> + + Fun + 0 + True + False + Start=21,3 End=21,4 + 1 + + + +#endif // EXPECTED_OUTPUT \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ValueType.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ValueType.cs index 8964e44331..a4a39f3305 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ValueType.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ValueType.cs @@ -59,10 +59,6 @@ namespace Debugger.Tests { - True - False - False - this False {Debugger.Tests.ValueType} @@ -104,6 +100,10 @@ namespace Debugger.Tests { + True + False + False +