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. 7
      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;
namespace Debugger namespace Debugger
{ {
/// <summary> /// <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> /// </summary>
delegate ICorDebugValue CorValueGetter(); public partial class Value: DebuggerObject
/// <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
{ {
Process process; Process process;
Expression expression; Expression expression;
ICorDebugValue rawCorValue; ICorDebugValue rawCorValue;
PauseSession rawCorValue_pauseSession;
ICorDebugValue corValue; ICorDebugValue corValue;
PauseSession corValue_pauseSession; PauseSession corValue_pauseSession;
DebugType type; 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> /// <summary> Expression which can be used to reobtain this value. </summary>
public Expression Expression { public Expression Expression {
get { return expression; } get { return expression; }
@ -93,7 +72,8 @@ namespace Debugger
/// and can not be used anymore </summary> /// and can not be used anymore </summary>
public bool HasExpired { public bool HasExpired {
get { get {
return hasExpired; return rawCorValue_pauseSession != process.PauseSession &&
!rawCorValue.Is<ICorDebugHandleValue>();
} }
} }
@ -156,25 +136,13 @@ namespace Debugger
this.process = process; this.process = process;
this.expression = expression; this.expression = expression;
this.rawCorValue = rawCorValue; this.rawCorValue = rawCorValue;
this.rawCorValue_pauseSession = process.PauseSession;
if (this.CorValue == null) { if (this.CorValue == null) {
type = DebugType.GetType(this.Process, "System.Object"); type = DebugType.GetType(this.Process, "System.Object");
} else { } else {
type = DebugType.Create(process, this.CorValue.CastTo<ICorDebugValue2>().ExactType); 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> /// <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 @@
// <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;
}
}
}

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

@ -229,7 +229,12 @@ namespace Debugger.Tests
container.SetAttribute("Type", type.Name); container.SetAttribute("Type", type.Name);
container.SetAttribute("ToString", obj.ToString()); 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()) { foreach(System.Reflection.PropertyInfo property in type.GetProperties()) {
if (property.GetGetMethod() == null) continue; if (property.GetGetMethod() == null) continue;

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

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

Loading…
Cancel
Save