From 41386ade755f4cf54e5fa661a7e4f7124ce56d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Wed, 16 Jan 2008 13:03:39 +0000 Subject: [PATCH] Remove IExpirable from Value. Tests: catch ToString exceptions. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2859 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Variables/Values/Value.cs | 50 +++--------- .../Src/Variables/Values/ValueEventArgs.cs | 33 -------- .../Project/Src/DebuggerTestsBase.cs | 7 +- .../TestPrograms/FunctionVariablesLifetime.cs | 80 +++++++++---------- 4 files changed, 55 insertions(+), 115 deletions(-) delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs index 2a5f82c329..2cd0909577 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs @@ -14,42 +14,21 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { /// - /// 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. /// - delegate ICorDebugValue CorValueGetter(); - - /// - /// Value class holds data necessaty to obtain the value of a given object - /// even after continue. It provides functions to examine the object. - /// - /// - /// - /// 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. - /// - /// - /// 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) - /// - /// - 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; - /// Occurs when the Value can not be used - public event EventHandler Expired; - - bool hasExpired = false; - /// Expression which can be used to reobtain this value. public Expression Expression { get { return expression; } @@ -93,7 +72,8 @@ namespace Debugger /// and can not be used anymore public bool HasExpired { get { - return hasExpired; + return rawCorValue_pauseSession != process.PauseSession && + !rawCorValue.Is(); } } @@ -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().ExactType); } - - if (!rawCorValue.Is()) { - 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); - } } /// Returns the of the value diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs deleted file mode 100644 index d08c77767c..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/ValueEventArgs.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger -{ - /// - /// Provides data for events related to class - /// - [Serializable] - public class ValueEventArgs : ProcessEventArgs - { - Value val; - - /// The value that caused the event - public Value Value { - get { - return val; - } - } - - /// Initializes a new instance of the class - public ValueEventArgs(Value val): base(val.Process) - { - this.val = val; - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs index 478777ded5..1f147d2834 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/DebuggerTestsBase.cs @@ -229,7 +229,12 @@ namespace Debugger.Tests 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()) { if (property.GetGetMethod() == null) continue; 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 e74edd001e..ade752ca8b 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 @@ -104,7 +104,7 @@ namespace Debugger.Tests { mscorlib.dll FunctionVariablesLifetime.exe Break - + False @@ -119,8 +119,8 @@ namespace Debugger.Tests { 1 False System.Int32 - - + + False @@ -135,8 +135,8 @@ namespace Debugger.Tests { 2 False System.Int32 - - + + <_x0040_class Type="Value" ToString="this.class = 3"> False @@ -151,9 +151,9 @@ namespace Debugger.Tests { 3 False System.Int32 - + Break - + @@ -168,8 +168,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -184,8 +184,8 @@ namespace Debugger.Tests { True System.Int32 - - + + <_x0040_class Type="Value" ToString_exception="Value has expired"> @@ -200,8 +200,8 @@ namespace Debugger.Tests { True System.Int32 - - + + False @@ -216,9 +216,9 @@ namespace Debugger.Tests { 4 False System.Int32 - + Break - + @@ -233,8 +233,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -249,8 +249,8 @@ namespace Debugger.Tests { True System.Int32 - - + + <_x0040_class Type="Value" ToString_exception="Value has expired"> @@ -265,8 +265,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -281,9 +281,9 @@ namespace Debugger.Tests { True System.Int32 - + Break - + @@ -298,8 +298,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -314,8 +314,8 @@ namespace Debugger.Tests { True System.Int32 - - + + <_x0040_class Type="Value" ToString_exception="Value has expired"> @@ -330,8 +330,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -346,8 +346,8 @@ namespace Debugger.Tests { True System.Int32 - - + + False @@ -362,9 +362,9 @@ namespace Debugger.Tests { 4 False System.Int32 - + Break - + @@ -379,8 +379,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -395,8 +395,8 @@ namespace Debugger.Tests { True System.Int32 - - + + <_x0040_class Type="Value" ToString_exception="Value has expired"> @@ -411,8 +411,8 @@ namespace Debugger.Tests { True System.Int32 - - + + @@ -427,7 +427,7 @@ namespace Debugger.Tests { True System.Int32 - +