Browse Source

Fixed debugger tests

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4322 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
8c17432262
  1. 1
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs
  2. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
  3. 227
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs
  4. 15
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs
  5. 179
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ObjectValue.cs

1
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Thread.cs

@ -61,6 +61,7 @@ namespace Debugger
get { get {
try { try {
CorThread.UserState.ToString(); CorThread.UserState.ToString();
CorThread.EnumerateChains();
return true; return true;
} catch (COMException e) { } catch (COMException e) {
// The state of the thread is invalid. // The state of the thread is invalid.

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs

@ -288,7 +288,7 @@ namespace Debugger
} }
/// <summary> Get all fields and properties of an object. </summary> /// <summary> Get all fields and properties of an object. </summary>
public Value[] GetMemberValues() public IEnumerable<Value> GetMemberValues()
{ {
return GetMemberValues(BindingFlags.All); return GetMemberValues(BindingFlags.All);
} }
@ -298,10 +298,10 @@ namespace Debugger
/// </summary> /// </summary>
/// <param name="type"> Limit to type, null for all types </param> /// <param name="type"> Limit to type, null for all types </param>
/// <param name="bindingFlags"> Get only members with certain flags </param> /// <param name="bindingFlags"> Get only members with certain flags </param>
public Value[] GetMemberValues(BindingFlags bindingFlags) public IEnumerable<Value> GetMemberValues(BindingFlags bindingFlags)
{ {
if (this.Type.IsClass || this.Type.IsValueType) { if (this.Type.IsClass || this.Type.IsValueType) {
return new List<Value>(GetObjectMembersEnum(bindingFlags)).ToArray(); return this.GetPermanentReference().GetObjectMembersEnum(bindingFlags);
} else { } else {
return new Value[0]; return new Value[0];
} }
@ -313,6 +313,7 @@ namespace Debugger
yield return this.GetFieldValue(field); yield return this.GetFieldValue(field);
} }
foreach(PropertyInfo property in this.Type.GetProperties(bindingFlags)) { foreach(PropertyInfo property in this.Type.GetProperties(bindingFlags)) {
if (property.GetMethod.ParameterCount > 0) continue;
yield return this.GetPropertyValue(property); yield return this.GetPropertyValue(property);
} }
} }

227
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs

@ -1,7 +1,7 @@
// <file> // <file>
// <copyright see="prj:///doc/copyright.txt"/> // <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/> // <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/> // <owner name="David Srbeck<EFBFBD>" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
@ -29,7 +29,7 @@ namespace Debugger.Tests {
public partial class DebuggerTests public partial class DebuggerTests
{ {
[NUnit.Framework.Test, NUnit.Framework.Ignore] [NUnit.Framework.Test]
public void GenericDictionary() public void GenericDictionary()
{ {
StartTest("GenericDictionary.cs"); StartTest("GenericDictionary.cs");
@ -44,4 +44,225 @@ namespace Debugger.Tests {
#endif #endif
#if EXPECTED_OUTPUT #if EXPECTED_OUTPUT
<?xml version="1.0" encoding="utf-8"?>
<DebuggerTests>
<Test
name="GenericDictionary.cs">
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>GenericDictionary.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break GenericDictionary.cs:21,4-21,40</DebuggingPaused>
<dict>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{System.Collections.Generic.Dictionary&lt;System.String,System.Int32&gt;}"
Expression="dict"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Collections.Generic.Dictionary&lt;System.String,System.Int32&gt;" />
</dict>
<dict_members>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLength="3"
ArrayRank="1"
AsString="{System.Int32[]}"
Expression="dict.buckets"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Int32[]" />
</Item>
<Item>
<Value
ArrayDimensions="{3}"
ArrayLength="3"
ArrayRank="1"
AsString="{Entry&lt;System.String,System.Int32&gt;[]}"
Expression="dict.entries"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="Entry&lt;System.String,System.Int32&gt;[]" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="3"
Expression="dict.count"
IsInvalid="False"
IsNull="False"
IsReference="False"
PrimitiveValue="3"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="3"
Expression="dict.version"
IsInvalid="False"
IsNull="False"
IsReference="False"
PrimitiveValue="3"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="-1"
Expression="dict.freeList"
IsInvalid="False"
IsNull="False"
IsReference="False"
PrimitiveValue="-1"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="0"
Expression="dict.freeCount"
IsInvalid="False"
IsNull="False"
IsReference="False"
PrimitiveValue="0"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{System.Collections.Generic.GenericEqualityComparer&lt;System.String&gt;}"
Expression="dict.comparer"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Collections.Generic.GenericEqualityComparer&lt;System.String&gt;" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is null}"
ArrayLength="{Exception: Value is null}"
ArrayRank="{Exception: Value is null}"
AsString="null"
Expression="dict.keys"
IsInvalid="False"
IsNull="True"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="KeyCollection&lt;System.String,System.Int32&gt;" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is null}"
ArrayLength="{Exception: Value is null}"
ArrayRank="{Exception: Value is null}"
AsString="null"
Expression="dict.values"
IsInvalid="False"
IsNull="True"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="ValueCollection&lt;System.String,System.Int32&gt;" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is null}"
ArrayLength="{Exception: Value is null}"
ArrayRank="{Exception: Value is null}"
AsString="null"
Expression="dict._syncRoot"
IsInvalid="False"
IsNull="True"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Object" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is null}"
ArrayLength="{Exception: Value is null}"
ArrayRank="{Exception: Value is null}"
AsString="null"
Expression="dict.m_siInfo"
IsInvalid="False"
IsNull="True"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Runtime.Serialization.SerializationInfo" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{System.Collections.Generic.GenericEqualityComparer&lt;System.String&gt;}"
Expression="dict.Comparer"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="System.Collections.Generic.GenericEqualityComparer&lt;System.String&gt;" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="3"
Expression="dict.Count"
IsInvalid="False"
IsNull="False"
IsReference="False"
PrimitiveValue="3"
Type="System.Int32" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{KeyCollection&lt;System.String,System.Int32&gt;}"
Expression="dict.Keys"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="KeyCollection&lt;System.String,System.Int32&gt;" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{ValueCollection&lt;System.String,System.Int32&gt;}"
Expression="dict.Values"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="ValueCollection&lt;System.String,System.Int32&gt;" />
</Item>
</dict_members>
<ProcessExited />
</Test>
</DebuggerTests>
#endif // EXPECTED_OUTPUT #endif // EXPECTED_OUTPUT

15
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs

@ -19,7 +19,8 @@ namespace Debugger.Tests.TestPrograms
System.Threading.Thread t = new System.Threading.Thread(WaitForALongTime); System.Threading.Thread t = new System.Threading.Thread(WaitForALongTime);
t.Name = "Worker thread"; t.Name = "Worker thread";
t.Start(); t.Start();
System.Threading.Thread.Sleep(0); // Wait for the thread to start
System.Threading.Thread.Sleep(500);
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
} }
@ -35,13 +36,13 @@ namespace Debugger.Tests {
public partial class DebuggerTests public partial class DebuggerTests
{ {
[NUnit.Framework.Test] [NUnit.Framework.Test]
[NUnit.Framework.Ignore("Fails on .NET 4.0")]
public void MainThreadExit() public void MainThreadExit()
{ {
StartTest("MainThreadExit.cs"); StartTest("MainThreadExit.cs");
ObjectDump("ThreadsBeforeExit", process.Threads); ObjectDump("ThreadsBeforeExit", process.Threads);
process.AsyncContinue(); process.AsyncContinue();
System.Threading.Thread.Sleep(250); // Wait for the main thread to exit
System.Threading.Thread.Sleep(500);
process.Break(); process.Break();
ObjectDump("ThreadsAfterExit", process.Threads); ObjectDump("ThreadsAfterExit", process.Threads);
process.Terminate(); process.Terminate();
@ -59,7 +60,7 @@ namespace Debugger.Tests {
<ProcessStarted /> <ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded> <ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>MainThreadExit.exe (Has symbols)</ModuleLoaded> <ModuleLoaded>MainThreadExit.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break MainThreadExit.cs:23,4-23,40</DebuggingPaused> <DebuggingPaused>Break MainThreadExit.cs:24,4-24,40</DebuggingPaused>
<ThreadsBeforeExit <ThreadsBeforeExit
Count="2"> Count="2">
<Item> <Item>
@ -89,7 +90,7 @@ namespace Debugger.Tests {
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
IsMostRecentStackFrameNative="False" IsMostRecentStackFrameNative="False"
MostRecentStackFrame="System.Threading.WaitHandle.WaitOne" MostRecentStackFrame="System.Threading.WaitHandle.InternalWaitOne"
MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.MainThreadExit.WaitForALongTime" MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.MainThreadExit.WaitForALongTime"
Name="Worker thread" Name="Worker thread"
OldestStackFrame="System.Threading.ThreadHelper.ThreadStart" OldestStackFrame="System.Threading.ThreadHelper.ThreadStart"
@ -99,7 +100,7 @@ namespace Debugger.Tests {
Suspended="False" /> Suspended="False" />
</Item> </Item>
</ThreadsBeforeExit> </ThreadsBeforeExit>
<DebuggingPaused>ForcedBreak MainThreadExit.cs:28,4-28,26</DebuggingPaused> <DebuggingPaused>ForcedBreak MainThreadExit.cs:29,4-29,26</DebuggingPaused>
<ThreadsAfterExit <ThreadsAfterExit
Count="2"> Count="2">
<Item> <Item>
@ -129,7 +130,7 @@ namespace Debugger.Tests {
IsAtSafePoint="True" IsAtSafePoint="True"
IsInValidState="True" IsInValidState="True"
IsMostRecentStackFrameNative="False" IsMostRecentStackFrameNative="False"
MostRecentStackFrame="System.Threading.WaitHandle.WaitOne" MostRecentStackFrame="System.Threading.WaitHandle.InternalWaitOne"
MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.MainThreadExit.WaitForALongTime" MostRecentStackFrameWithLoadedSymbols="Debugger.Tests.TestPrograms.MainThreadExit.WaitForALongTime"
Name="Worker thread" Name="Worker thread"
OldestStackFrame="System.Threading.ThreadHelper.ThreadStart" OldestStackFrame="System.Threading.ThreadHelper.ThreadStart"

179
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ObjectValue.cs

@ -17,8 +17,8 @@ namespace Debugger.Tests.TestPrograms
public class ObjectValue: BaseClass2 public class ObjectValue: BaseClass2
{ {
string privateField = "private"; string privateField = "c";
public string publicFiled = "public"; public string publicFiled = "d";
public string PublicProperty { public string PublicProperty {
get { get {
@ -42,7 +42,7 @@ namespace Debugger.Tests {
public partial class DebuggerTests public partial class DebuggerTests
{ {
[NUnit.Framework.Test, NUnit.Framework.Ignore] [NUnit.Framework.Test]
public void ObjectValue() public void ObjectValue()
{ {
Value val = null; Value val = null;
@ -54,6 +54,7 @@ namespace Debugger.Tests {
ObjectDump("val members", val.GetMemberValues()); ObjectDump("val members", val.GetMemberValues());
process.Continue(); process.Continue();
val = process.SelectedStackFrame.GetLocalVariableValue("val");
ObjectDump("val", val); ObjectDump("val", val);
ObjectDump("val members", val.GetMemberValues()); ObjectDump("val members", val.GetMemberValues());
@ -64,4 +65,176 @@ namespace Debugger.Tests {
#endif #endif
#if EXPECTED_OUTPUT #if EXPECTED_OUTPUT
<?xml version="1.0" encoding="utf-8"?>
<DebuggerTests>
<Test
name="ObjectValue.cs">
<ProcessStarted />
<ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
<ModuleLoaded>ObjectValue.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break ObjectValue.cs:32,4-32,40</DebuggingPaused>
<val>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{Debugger.Tests.TestPrograms.ObjectValue}"
Expression="val"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="Debugger.Tests.TestPrograms.ObjectValue" />
</val>
<val_members>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="c"
Expression="val.privateField"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="c"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="d"
Expression="val.publicFiled"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="d"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="a"
Expression="val.basePublic"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="a"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="b"
Expression="val.basePrivate"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="b"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="c"
Expression="val.PublicProperty"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="c"
Type="System.String" />
</Item>
</val_members>
<DebuggingPaused>Break ObjectValue.cs:34,4-34,40</DebuggingPaused>
<val>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="{Debugger.Tests.TestPrograms.ObjectValue}"
Expression="val"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="{Exception: Value is not a primitive type}"
Type="Debugger.Tests.TestPrograms.ObjectValue" />
</val>
<val_members>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="new private"
Expression="val.privateField"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="new private"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="d"
Expression="val.publicFiled"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="d"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="a"
Expression="val.basePublic"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="a"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="b"
Expression="val.basePrivate"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="b"
Type="System.String" />
</Item>
<Item>
<Value
ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}"
AsString="new private"
Expression="val.PublicProperty"
IsInvalid="False"
IsNull="False"
IsReference="True"
PrimitiveValue="new private"
Type="System.String" />
</Item>
</val_members>
<ProcessExited />
</Test>
</DebuggerTests>
#endif // EXPECTED_OUTPUT #endif // EXPECTED_OUTPUT
Loading…
Cancel
Save