Bläddra i källkod

Disallow function calls in conditional breakpoints

Brian Fiete 5 år sedan
förälder
incheckning
cfc25003a0
2 ändrade filer med 11 tillägg och 1 borttagningar
  1. 5 0
      IDEHelper/DbgExprEvaluator.cpp
  2. 6 1
      IDEHelper/WinDebugger.cpp

+ 5 - 0
IDEHelper/DbgExprEvaluator.cpp

@@ -7937,6 +7937,11 @@ DbgTypedValue DbgExprEvaluator::Resolve(BfExpression* expr, DbgType* wantType)
 	SetAndRestoreValue<DbgType*> prevType(mExpectingType, wantType);
 	SetAndRestoreValue<DbgTypedValue> prevResult(mResult, DbgTypedValue());
 
+	if ((mExpressionFlags & DwEvalExpressionFlag_AllowCalls) != 0)
+	{
+		BF_ASSERT(mCallResults != NULL);
+	}
+
 	if (mExplicitThis)
 		mExplicitThis = FixThis(mExplicitThis);
 

+ 6 - 1
IDEHelper/WinDebugger.cpp

@@ -3704,7 +3704,7 @@ bool WinDebugger::CheckConditionalBreakpoint(WdBreakpoint* breakpoint, DbgSubpro
 			conditional->mDbgEvaluationContext->mDbgExprEvaluator->mSubjectExpr = subjectExpr;
 			conditional->mDbgEvaluationContext->mDbgExprEvaluator->mDbgCompileUnit = subprogram->mCompileUnit;
 			conditional->mDbgEvaluationContext->mDbgExprEvaluator->mCallStackIdx = 0;
-			conditional->mDbgEvaluationContext->mDbgExprEvaluator->mExpressionFlags = (DwEvalExpressionFlags)(DwEvalExpressionFlag_AllowSideEffects | DwEvalExpressionFlag_AllowCalls);
+			conditional->mDbgEvaluationContext->mDbgExprEvaluator->mExpressionFlags = (DwEvalExpressionFlags)(DwEvalExpressionFlag_AllowSideEffects);
 		}
 
 		WdStackFrame* wdStackFrame = new WdStackFrame();
@@ -3726,6 +3726,11 @@ bool WinDebugger::CheckConditionalBreakpoint(WdBreakpoint* breakpoint, DbgSubpro
 			mDebugManager->mOutMessages.push_back(condError);
 			return true;
 		}
+		else if (conditional->mDbgEvaluationContext->mDbgExprEvaluator->mBlockedSideEffects)
+		{
+			mDebugManager->mOutMessages.push_back(StrFormat("error Conditional breakpoint expression '%s' contained function calls, which is not allowed", conditional->mExpr.c_str()));
+			return true;
+		}
 		else if ((!result) || (!result.mType->IsBoolean()))
 		{
 			mDebugManager->mOutMessages.push_back(StrFormat("error Conditional breakpoint expression '%s' must result in a boolean value", conditional->mExpr.c_str()));