|
|
@ -91,8 +91,8 @@ namespace Debugger |
|
|
|
this.process = appDomain.Process; |
|
|
|
this.process = appDomain.Process; |
|
|
|
this.description = description; |
|
|
|
this.description = description; |
|
|
|
this.state = EvalState.Evaluating; |
|
|
|
this.state = EvalState.Evaluating; |
|
|
|
|
|
|
|
this.thread = GetEvaluationThread(appDomain); |
|
|
|
this.corEval = CreateCorEval(appDomain, out this.thread); |
|
|
|
this.corEval = thread.CorThread.CreateEval(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
evalStarter(this); |
|
|
|
evalStarter(this); |
|
|
@ -133,35 +133,22 @@ namespace Debugger |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static ICorDebugEval CreateCorEval(AppDomain appDomain, out Thread thread) |
|
|
|
static Thread GetEvaluationThread(AppDomain appDomain) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appDomain.Process.AssertPaused(); |
|
|
|
appDomain.Process.AssertPaused(); |
|
|
|
|
|
|
|
|
|
|
|
thread = appDomain.Process.SelectedThread; |
|
|
|
Thread st = appDomain.Process.SelectedThread; |
|
|
|
|
|
|
|
if (st != null && !st.Suspended && !st.IsInNativeCode && st.IsAtSafePoint && st.CorThread.GetAppDomain().GetID() == appDomain.ID) { |
|
|
|
|
|
|
|
return st; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (thread.CorThread.GetAppDomain().GetID() != appDomain.ID) { |
|
|
|
|
|
|
|
foreach(Thread t in appDomain.Process.Threads) { |
|
|
|
foreach(Thread t in appDomain.Process.Threads) { |
|
|
|
if (t.CorThread.GetAppDomain().GetID() == appDomain.ID && |
|
|
|
if (!t.Suspended && !t.IsInNativeCode && t.IsAtSafePoint && t.CorThread.GetAppDomain().GetID() == appDomain.ID) { |
|
|
|
!t.Suspended && |
|
|
|
return t; |
|
|
|
!t.IsInNativeCode && |
|
|
|
|
|
|
|
t.IsAtSafePoint) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
thread = t; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (thread == null) |
|
|
|
|
|
|
|
throw new GetValueException("Can not evaluate because no thread is selected"); |
|
|
|
|
|
|
|
if (thread.IsInNativeCode) |
|
|
|
|
|
|
|
throw new GetValueException("Can not evaluate because native frame is on top of stack"); |
|
|
|
|
|
|
|
if (!thread.IsAtSafePoint) |
|
|
|
|
|
|
|
throw new GetValueException("Can not evaluate because thread is not at a safe point"); |
|
|
|
|
|
|
|
if (thread.Suspended) |
|
|
|
|
|
|
|
throw new GetValueException("Can not evaluate on suspended thread"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return thread.CorThread.CreateEval(); |
|
|
|
throw new GetValueException("No suitable thread for evaluation"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
internal bool IsCorEval(ICorDebugEval corEval) |
|
|
|
internal bool IsCorEval(ICorDebugEval corEval) |
|
|
@ -293,8 +280,8 @@ namespace Debugger |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (value == null) { |
|
|
|
if (value == null) { |
|
|
|
ICorDebugClass corClass = appDomain.ObjectType.CorType.GetClass(); |
|
|
|
ICorDebugClass corClass = appDomain.ObjectType.CorType.GetClass(); |
|
|
|
Thread thread; |
|
|
|
Thread thread = GetEvaluationThread(appDomain); |
|
|
|
ICorDebugEval corEval = CreateCorEval(appDomain, out thread); |
|
|
|
ICorDebugEval corEval = thread.CorThread.CreateEval(); |
|
|
|
ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass); |
|
|
|
ICorDebugValue corValue = corEval.CreateValue((uint)CorElementType.CLASS, corClass); |
|
|
|
return new Value(appDomain, corValue); |
|
|
|
return new Value(appDomain, corValue); |
|
|
|
} else if (value is string) { |
|
|
|
} else if (value is string) { |
|
|
|