Skip to content

Commit 2c1ca37

Browse files
author
David Karlaš
authored
Merge pull request #88 from JetBrains/evaluationFixes
Evaluation fixes
2 parents 06e4781 + e3e6655 commit 2c1ca37

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Mono.Debugger.Soft/Mono.Debugger.Soft/ThreadMirror.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class ThreadMirror : ObjectMirror
1313
ManualResetEvent fetchingEvent = new ManualResetEvent (false);
1414
ThreadInfo info;
1515
StackFrame[] frames;
16+
bool threadStateInvalid = true;
17+
ThreadState threadState;
1618

1719
internal ThreadMirror (VirtualMachine vm, long id) : base (vm, id) {
1820
}
@@ -30,6 +32,7 @@ public StackFrame[] GetFrames () {
3032

3133
internal void InvalidateFrames () {
3234
cacheInvalid = true;
35+
threadStateInvalid = true;
3336
}
3437

3538
internal void FetchFrames (bool mustFetch = false) {
@@ -91,7 +94,11 @@ public string Name {
9194

9295
public ThreadState ThreadState {
9396
get {
94-
return (ThreadState)vm.conn.Thread_GetState (id);
97+
if (threadStateInvalid) {
98+
threadState = (ThreadState) vm.conn.Thread_GetState (id);
99+
threadStateInvalid = false;
100+
}
101+
return threadState;
95102
}
96103
}
97104

Mono.Debugging.Soft/SoftDebuggerAdaptor.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using System.Threading;
3636

3737
using Mono.Debugger.Soft;
38+
using Mono.Debugging.Backend;
3839
using Mono.Debugging.Evaluation;
3940
using Mono.Debugging.Client;
4041

@@ -1241,6 +1242,16 @@ public override void GetNamespaceContents (EvaluationContext ctx, string namspac
12411242
types.CopyTo (childTypes);
12421243
}
12431244

1245+
protected override ObjectValue CreateObjectValueImpl (EvaluationContext ctx, IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
1246+
{
1247+
try {
1248+
return base.CreateObjectValueImpl (ctx, source, path, obj, flags);
1249+
}
1250+
catch (NotSupportedException e) {
1251+
throw new EvaluatorException ("Evaluation failed: {0}", e.Message);
1252+
}
1253+
}
1254+
12441255
protected override IEnumerable<ValueReference> OnGetParameters (EvaluationContext ctx)
12451256
{
12461257
var soft = (SoftEvaluationContext) ctx;

Mono.Debugging.Soft/SoftEvaluationContext.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Mono.Debugger.Soft;
3030
using DC = Mono.Debugging.Client;
3131
using System.Runtime.CompilerServices;
32+
using System.Threading;
3233

3334
namespace Mono.Debugging.Soft
3435
{
@@ -184,7 +185,11 @@ Value RuntimeInvoke (MethodMirror method, object target, Value[] values, bool en
184185
return method.Evaluate (target is TypeMirror ? null : (Value) target, values);
185186
} catch (NotSupportedException) {
186187
AssertTargetInvokeAllowed ();
187-
188+
var threadState = Thread.ThreadState;
189+
if ((threadState & ThreadState.WaitSleepJoin) == ThreadState.WaitSleepJoin) {
190+
DC.DebuggerLoggingService.LogMessage ("Thread state before evaluation is {0}", threadState);
191+
throw new EvaluatorException ("Evaluation is not allowed when the thread is in 'Wait' state");
192+
}
188193
var mc = new MethodCall (this, method, target, values, enableOutArgs);
189194
//Since runtime is returning NOT_SUSPENDED error if two methods invokes are executed
190195
//at same time we have to lock invoking to prevent this...

0 commit comments

Comments
 (0)