Browse Source

Removed the delegate-based persistence framework (will be replaced by expressions)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2778 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
1983b5e8b2
  1. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  2. 20
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  3. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  4. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  5. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Array.cs
  6. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs
  7. 110
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

@ -36,9 +36,7 @@ namespace Debugger @@ -36,9 +36,7 @@ namespace Debugger
this.thread = thread;
corValue = thread.CorThread.CurrentException;
exceptionType = thread.CurrentExceptionType;
Value runtimeValue = new Value(process,
string.Empty,
delegate { return corValue; } );
Value runtimeValue = new Value(process, corValue);
message = runtimeValue.GetMember("_message").AsString;
if (thread.LastFunctionWithLoadedSymbols != null) {

20
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -435,11 +435,7 @@ namespace Debugger @@ -435,11 +435,7 @@ namespace Debugger
get {
if (IsStatic) throw new DebuggerException("Static method does not have 'this'.");
if (thisValueCache == null) {
thisValueCache = new Value(
process,
"this",
delegate { return ThisCorValue; }
);
thisValueCache = new Value(process, "this", ThisCorValue);
}
return thisValueCache;
}
@ -500,13 +496,7 @@ namespace Debugger @@ -500,13 +496,7 @@ namespace Debugger
/// <param name="index"> Zero-based index </param>
public Value GetArgument(int index)
{
string name = GetParameterName(index);
return new Value(
process,
name,
delegate { return GetArgumentCorValue(index); }
);
return new Value(process, GetParameterName(index), GetArgumentCorValue(index));
}
ICorDebugValue GetArgumentCorValue(int index)
@ -591,11 +581,7 @@ namespace Debugger @@ -591,11 +581,7 @@ namespace Debugger
Value GetLocalVariable(ISymUnmanagedVariable symVar)
{
return new Value(
process,
symVar.Name,
delegate { return GetCorValueOfLocalVariable(symVar); }
);
return new Value(process, symVar.Name, GetCorValueOfLocalVariable(symVar));
}
ICorDebugValue GetCorValueOfLocalVariable(ISymUnmanagedVariable symVar)

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -164,11 +164,7 @@ namespace Debugger @@ -164,11 +164,7 @@ namespace Debugger
if (!HasBeenLoaded) throw new DebuggerException("Thread has not started jet");
process.AssertPaused();
return new Value(
process,
string.Empty,
delegate { return CorThread.Object;}
);
return new Value(process, CorThread.Object);
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -232,9 +232,7 @@ namespace Debugger @@ -232,9 +232,7 @@ namespace Debugger
} else {
state = EvalState.EvaluatedException;
}
result = new Value(process,
string.Empty,
delegate { return corEval.Result; });
result = new Value(process, corEval.Result);
}
}
}

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

@ -74,11 +74,7 @@ namespace Debugger @@ -74,11 +74,7 @@ namespace Debugger
{
uint[] indices = (uint[])elementIndices.Clone();
return new Value(
Process,
GetNameFromIndices(indices),
delegate { return GetCorValueOfArrayElement(indices); }
);
return new Value(Process, GetNameFromIndices(indices), GetCorValueOfArrayElement(indices));
}
static string GetNameFromIndices(uint[] indices)

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

@ -50,7 +50,7 @@ namespace Debugger @@ -50,7 +50,7 @@ namespace Debugger
return new Value(
objectInstance.Process,
fieldInfo.Name,
delegate { return GetFieldCorValue(objectInstance, fieldInfo); }
GetFieldCorValue(objectInstance, fieldInfo)
);
}
@ -112,7 +112,7 @@ namespace Debugger @@ -112,7 +112,7 @@ namespace Debugger
return new Value(
objectInstance.Process,
propertyInfo.Name,
delegate { return Value.InvokeMethod(objectInstance, propertyInfo.GetMethod, arguments).RawCorValue; }
Value.InvokeMethod(objectInstance, propertyInfo.GetMethod, arguments).RawCorValue
);
}

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

@ -36,58 +36,18 @@ namespace Debugger @@ -36,58 +36,18 @@ namespace Debugger
/// </remarks>
public partial class Value: DebuggerObject, IExpirable
{
string name;
Process process;
Process process;
string name;
ICorDebugValue rawCorValue;
CorValueGetter corValueGetter;
ICorDebugValue corValue;
PauseSession corValue_pauseSession;
DebugType type;
/// <summary> Occurs when the Value can not be used </summary>
public event EventHandler Expired;
bool isExpired = false;
ValueCache cache;
private class ValueCache
{
public PauseSession PauseSession;
public ICorDebugValue RawCorValue;
public ICorDebugValue CorValue;
public DebugType Type;
public string AsString = String.Empty;
}
/// <summary>
/// Cache stores expensive or commonly used information about the value
/// </summary>
ValueCache Cache {
get {
if (this.HasExpired) throw new CannotGetValueException("Value has expired");
if (cache == null || (cache.PauseSession != process.PauseSession && !cache.RawCorValue.Is<ICorDebugHandleValue>())) {
DateTime startTime = Util.HighPrecisionTimer.Now;
ValueCache newCache = new ValueCache();
newCache.RawCorValue = corValueGetter();
newCache.PauseSession = process.PauseSession;
newCache.CorValue = DereferenceUnbox(newCache.RawCorValue);
newCache.Type = DebugType.Create(process, newCache.RawCorValue.As<ICorDebugValue2>().ExactType);
cache = newCache;
// AsString representation
if (IsNull) cache.AsString = "<null>";
if (IsArray) cache.AsString = "{" + this.Type.FullName + "}";
if (IsObject) cache.AsString = "{" + this.Type.FullName + "}";
//if (IsObject) cache.AsString = Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
if (IsPrimitive) cache.AsString = PrimitiveValue != null ? PrimitiveValue.ToString() : String.Empty;
TimeSpan totalTime = Util.HighPrecisionTimer.Now - startTime;
string name = this is Value ? ((Value)this).Name + " = " : String.Empty;
process.TraceMessage("Obtained value: " + name + cache.AsString + " (" + totalTime.TotalMilliseconds + " ms)");
}
return cache;
}
}
bool hasExpired = false;
/// <summary> Gets the name associated with the value </summary>
public string Name {
@ -106,7 +66,12 @@ namespace Debugger @@ -106,7 +66,12 @@ namespace Debugger
/// <summary> Gets a string representation of the value </summary>
public string AsString {
get {
return Cache.AsString;
if (IsNull) return "<null>";
if (IsArray) return "{" + this.Type.FullName + "}";
if (IsObject) return "{" + this.Type.FullName + "}";
//if (IsObject) return Eval.InvokeMethod(Process, typeof(object), "ToString", this, new Value[] {}).AsString;
if (IsPrimitive) return PrimitiveValue != null ? PrimitiveValue.ToString() : String.Empty;
throw new DebuggerException("Unknown value type");
}
}
@ -118,23 +83,31 @@ namespace Debugger @@ -118,23 +83,31 @@ namespace Debugger
}
}
/// <summary> Returns true if the Value have expired
/// <summary> Returns true if the Value has expired
/// and can not be used anymore </summary>
public bool HasExpired {
get {
return isExpired;
return hasExpired;
}
}
internal ICorDebugValue RawCorValue {
get {
return Cache.RawCorValue;
if (this.HasExpired) throw new CannotGetValueException("Value has expired");
return rawCorValue;
}
}
internal ICorDebugValue CorValue {
get {
return Cache.CorValue;
if (this.HasExpired) throw new CannotGetValueException("Value has expired");
if (corValue_pauseSession != process.PauseSession) {
corValue = DereferenceUnbox(rawCorValue);
corValue_pauseSession = process.PauseSession;
}
return corValue;
}
}
@ -150,9 +123,7 @@ namespace Debugger @@ -150,9 +123,7 @@ namespace Debugger
internal ICorDebugValue SoftReference {
get {
if (this.HasExpired) throw new DebuggerException("CorValue has expired");
ICorDebugValue corValue = RawCorValue;
ICorDebugValue corValue = this.RawCorValue;
if (corValue != null && corValue.Is<ICorDebugHandleValue>()) {
return corValue;
}
@ -165,13 +136,20 @@ namespace Debugger @@ -165,13 +136,20 @@ namespace Debugger
}
}
internal Value(Process process,
ICorDebugValue rawCorValue)
:this (process, string.Empty, rawCorValue)
{
}
internal Value(Process process,
string name,
CorValueGetter corValueGetter)
ICorDebugValue rawCorValue)
{
this.process = process;
this.name = name;
this.corValueGetter = corValueGetter;
this.rawCorValue = rawCorValue;
// TODO: clean up
if (name.StartsWith("<") && name.Contains(">") && name != "<Base class>") {
@ -181,17 +159,19 @@ namespace Debugger @@ -181,17 +159,19 @@ namespace Debugger
}
}
process.DebuggingResumed += delegate {
this.isExpired = true;
OnExpired(EventArgs.Empty);
};
type = DebugType.Create(process, rawCorValue.As<ICorDebugValue2>().ExactType);
if (!rawCorValue.Is<ICorDebugHandleValue>()) {
process.DebuggingResumed += Process_DebuggingResumed;
}
}
/// <summary> Is called when the value expires and can not be used </summary>
protected virtual void OnExpired(EventArgs e)
void Process_DebuggingResumed(object sender, ProcessEventArgs args)
{
process.DebuggingResumed -= Process_DebuggingResumed;
this.hasExpired = true;
if (Expired != null) {
Expired(this, e);
Expired(this, EventArgs.Empty);
}
}
@ -199,7 +179,7 @@ namespace Debugger @@ -199,7 +179,7 @@ namespace Debugger
[Debugger.Tests.ToStringOnly]
public DebugType Type {
get {
return Cache.Type;
return type;
}
}

Loading…
Cancel
Save