Browse Source

Remove IExpirable from Value.

Tests: catch ToString exceptions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2859 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
41386ade75
  1. 50
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs
  2. 33
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs
  3. 5
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs
  4. 80
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs

50
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs

@ -14,42 +14,21 @@ using Debugger.Wrappers.CorDebug; @@ -14,42 +14,21 @@ using Debugger.Wrappers.CorDebug;
namespace Debugger
{
/// <summary>
/// Delegate that is used to get value. This delegate may be called at any time and should never return null.
/// Value class provides functions to examine value in the debuggee.
/// It has very life-time. In general, value dies whenever debugger is
/// resumed (this includes method invocation and property evaluation).
/// You can use Expressions to reobtain the value.
/// </summary>
delegate ICorDebugValue CorValueGetter();
/// <summary>
/// Value class holds data necessaty to obtain the value of a given object
/// even after continue. It provides functions to examine the object.
/// </summary>
/// <remarks>
/// <para>
/// Expiration: Once value expires it can not be used anymore.
/// Expiration is permanet - once value expires it stays expired.
/// Value expires when any object specified in constructor expires
/// or when process exits.
/// </para>
/// <para>
/// Mutation: As long as any dependecy does not mutate the last
/// obteined value is still considered up to date. (If continue is
/// called and internal value is neutred, new copy will be obatined)
/// </para>
/// </remarks>
public partial class Value: DebuggerObject, IExpirable
public partial class Value: DebuggerObject
{
Process process;
Expression expression;
ICorDebugValue rawCorValue;
PauseSession rawCorValue_pauseSession;
ICorDebugValue corValue;
PauseSession corValue_pauseSession;
DebugType type;
/// <summary> Occurs when the Value can not be used </summary>
public event EventHandler Expired;
bool hasExpired = false;
/// <summary> Expression which can be used to reobtain this value. </summary>
public Expression Expression {
get { return expression; }
@ -93,7 +72,8 @@ namespace Debugger @@ -93,7 +72,8 @@ namespace Debugger
/// and can not be used anymore </summary>
public bool HasExpired {
get {
return hasExpired;
return rawCorValue_pauseSession != process.PauseSession &&
!rawCorValue.Is<ICorDebugHandleValue>();
}
}
@ -156,25 +136,13 @@ namespace Debugger @@ -156,25 +136,13 @@ namespace Debugger
this.process = process;
this.expression = expression;
this.rawCorValue = rawCorValue;
this.rawCorValue_pauseSession = process.PauseSession;
if (this.CorValue == null) {
type = DebugType.GetType(this.Process, "System.Object");
} else {
type = DebugType.Create(process, this.CorValue.CastTo<ICorDebugValue2>().ExactType);
}
if (!rawCorValue.Is<ICorDebugHandleValue>()) {
process.DebuggingResumed += Process_DebuggingResumed;
}
}
void Process_DebuggingResumed(object sender, ProcessEventArgs args)
{
process.DebuggingResumed -= Process_DebuggingResumed;
this.hasExpired = true;
if (Expired != null) {
Expired(this, EventArgs.Empty);
}
}
/// <summary> Returns the <see cref="Debugger.DebugType"/> of the value </summary>

33
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
/// <summary>
/// Provides data for events related to <see cref="Debugger.Value"/> class
/// </summary>
[Serializable]
public class ValueEventArgs : ProcessEventArgs
{
Value val;
/// <summary> The value that caused the event </summary>
public Value Value {
get {
return val;
}
}
/// <summary> Initializes a new instance of the class </summary>
public ValueEventArgs(Value val): base(val.Process)
{
this.val = val;
}
}
}

5
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs

@ -229,7 +229,12 @@ namespace Debugger.Tests @@ -229,7 +229,12 @@ namespace Debugger.Tests
container.SetAttribute("Type", type.Name);
try {
container.SetAttribute("ToString", obj.ToString());
} catch (System.Exception e) {
while(e.InnerException != null) e = e.InnerException;
container.SetAttribute("ToString_exception", e.Message);
}
foreach(System.Reflection.PropertyInfo property in type.GetProperties()) {
if (property.GetGetMethod() == null) continue;

80
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/FunctionVariablesLifetime.cs

@ -104,7 +104,7 @@ namespace Debugger.Tests { @@ -104,7 +104,7 @@ namespace Debugger.Tests {
<ModuleLoaded symbols="False">mscorlib.dll</ModuleLoaded>
<ModuleLoaded symbols="True">FunctionVariablesLifetime.exe</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<ObjectDump name="argument" Type="Value">
<argument Type="Value" ToString="argument = 1">
<IsArray>False</IsArray>
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
@ -119,8 +119,8 @@ namespace Debugger.Tests { @@ -119,8 +119,8 @@ namespace Debugger.Tests {
<AsString>1</AsString>
<HasExpired>False</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="local" Type="Value">
</argument>
<local Type="Value" ToString="local = 2">
<IsArray>False</IsArray>
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
@ -135,8 +135,8 @@ namespace Debugger.Tests { @@ -135,8 +135,8 @@ namespace Debugger.Tests {
<AsString>2</AsString>
<HasExpired>False</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="@class" Type="Value">
</local>
<_x0040_class Type="Value" ToString="this.class = 3">
<IsArray>False</IsArray>
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
@ -151,9 +151,9 @@ namespace Debugger.Tests { @@ -151,9 +151,9 @@ namespace Debugger.Tests {
<AsString>3</AsString>
<HasExpired>False</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
</_x0040_class>
<DebuggingPaused>Break</DebuggingPaused>
<ObjectDump name="argument" Type="Value">
<argument Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -168,8 +168,8 @@ namespace Debugger.Tests { @@ -168,8 +168,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="local" Type="Value">
</argument>
<local Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -184,8 +184,8 @@ namespace Debugger.Tests { @@ -184,8 +184,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="@class" Type="Value">
</local>
<_x0040_class Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -200,8 +200,8 @@ namespace Debugger.Tests { @@ -200,8 +200,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="localInSubFunction" Type="Value">
</_x0040_class>
<localInSubFunction Type="Value" ToString="localInSubFunction = 4">
<IsArray>False</IsArray>
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
@ -216,9 +216,9 @@ namespace Debugger.Tests { @@ -216,9 +216,9 @@ namespace Debugger.Tests {
<AsString>4</AsString>
<HasExpired>False</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
</localInSubFunction>
<DebuggingPaused>Break</DebuggingPaused>
<ObjectDump name="argument" Type="Value">
<argument Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -233,8 +233,8 @@ namespace Debugger.Tests { @@ -233,8 +233,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="local" Type="Value">
</argument>
<local Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -249,8 +249,8 @@ namespace Debugger.Tests { @@ -249,8 +249,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="@class" Type="Value">
</local>
<_x0040_class Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -265,8 +265,8 @@ namespace Debugger.Tests { @@ -265,8 +265,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="localInSubFunction" Type="Value">
</_x0040_class>
<localInSubFunction Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -281,9 +281,9 @@ namespace Debugger.Tests { @@ -281,9 +281,9 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
</localInSubFunction>
<DebuggingPaused>Break</DebuggingPaused>
<ObjectDump name="argument" Type="Value">
<argument Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -298,8 +298,8 @@ namespace Debugger.Tests { @@ -298,8 +298,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="local" Type="Value">
</argument>
<local Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -314,8 +314,8 @@ namespace Debugger.Tests { @@ -314,8 +314,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="@class" Type="Value">
</local>
<_x0040_class Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -330,8 +330,8 @@ namespace Debugger.Tests { @@ -330,8 +330,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="localInSubFunction" Type="Value">
</_x0040_class>
<localInSubFunction Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -346,8 +346,8 @@ namespace Debugger.Tests { @@ -346,8 +346,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="localInSubFunction(new)" Type="Value">
</localInSubFunction>
<localInSubFunction_x0028_new_x0029_ Type="Value" ToString="localInSubFunction = 4">
<IsArray>False</IsArray>
<ArrayLenght exception="Value is not an array" />
<ArrayRank exception="Value is not an array" />
@ -362,9 +362,9 @@ namespace Debugger.Tests { @@ -362,9 +362,9 @@ namespace Debugger.Tests {
<AsString>4</AsString>
<HasExpired>False</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
</localInSubFunction_x0028_new_x0029_>
<DebuggingPaused>Break</DebuggingPaused>
<ObjectDump name="argument" Type="Value">
<argument Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -379,8 +379,8 @@ namespace Debugger.Tests { @@ -379,8 +379,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="local" Type="Value">
</argument>
<local Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -395,8 +395,8 @@ namespace Debugger.Tests { @@ -395,8 +395,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="@class" Type="Value">
</local>
<_x0040_class Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -411,8 +411,8 @@ namespace Debugger.Tests { @@ -411,8 +411,8 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
<ObjectDump name="localInSubFunction" Type="Value">
</_x0040_class>
<localInSubFunction Type="Value" ToString_exception="Value has expired">
<IsArray exception="Value has expired" />
<ArrayLenght exception="Value has expired" />
<ArrayRank exception="Value has expired" />
@ -427,7 +427,7 @@ namespace Debugger.Tests { @@ -427,7 +427,7 @@ namespace Debugger.Tests {
<AsString exception="Value has expired" />
<HasExpired>True</HasExpired>
<Type>System.Int32</Type>
</ObjectDump>
</localInSubFunction>
<ProcessExited />
</Test>
</DebuggerTests>

Loading…
Cancel
Save