Skip to content

Commit 7707698

Browse files
ArseniiCherniaevnerzhulart
authored andcommitted
handle exception on breakpoint condition evaluation
(cherry picked from commit b2acc57)
1 parent bd2c8fe commit 7707698

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

Mono.Debugging.Win32/CorDebuggerSession.cs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,22 @@ bool ShouldContinueOnBreakpoint (CorThread thread, BreakEventInfo binfo)
503503
return true;
504504

505505
if (!string.IsNullOrEmpty (bp.ConditionExpression)) {
506-
string res = EvaluateExpression (thread, bp.ConditionExpression);
507-
if (bp.BreakIfConditionChanges) {
508-
if (res == bp.LastConditionValue)
509-
return true;
510-
bp.LastConditionValue = res;
511-
} else {
512-
if (res != null && res.ToLower () != "true")
513-
return true;
506+
try {
507+
string res = EvaluateExpression (thread, bp.ConditionExpression);
508+
if (bp.BreakIfConditionChanges) {
509+
if (res == bp.LastConditionValue)
510+
return true;
511+
bp.LastConditionValue = res;
512+
}
513+
else {
514+
if (res != null && res.ToLower () != "true")
515+
return true;
516+
}
517+
}
518+
catch (EvaluatorException e) {
519+
OnDebuggerOutput (false, e.Message);
520+
binfo.SetStatus (BreakEventStatus.Invalid, e.Message);
521+
return true;
514522
}
515523
}
516524

@@ -1713,7 +1721,13 @@ string EvaluateTrace (CorThread thread, string exp)
17131721
if (j == -1)
17141722
break;
17151723
string se = exp.Substring (i + 1, j - i - 1);
1716-
se = EvaluateExpression (thread, se);
1724+
try {
1725+
se = EvaluateExpression (thread, se);
1726+
}
1727+
catch (EvaluatorException e) {
1728+
OnDebuggerOutput (false, e.ToString ());
1729+
return String.Empty;
1730+
}
17171731
sb.Append (exp.Substring (last, i - last));
17181732
sb.Append (se);
17191733
last = j + 1;
@@ -1734,7 +1748,11 @@ string EvaluateExpression (CorThread thread, string exp)
17341748
ctx.Thread = thread;
17351749
ValueReference val = ctx.Evaluator.Evaluate (ctx, exp);
17361750
return val.CreateObjectValue (false).Value;
1737-
} catch (Exception ex) {
1751+
}
1752+
catch (EvaluatorException e) {
1753+
throw;
1754+
}
1755+
catch (Exception ex) {
17381756
OnDebuggerOutput (true, ex.ToString ());
17391757
return string.Empty;
17401758
}

0 commit comments

Comments
 (0)