MCPcopy Create free account
hub / github.com/beefytech/Beef / CheckConditionalBreakpoint

Method CheckConditionalBreakpoint

IDEHelper/Compiler/CeDebugger.cpp:416–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416bool CeDebugger::CheckConditionalBreakpoint(CeBreakpoint* breakpoint)
417{
418 auto _SplitExpr = [&](const StringImpl& expr, StringImpl& outExpr, StringImpl& outSubject)
419 {
420 int crPos = (int)expr.IndexOf('\n');
421 if (crPos != -1)
422 {
423 outExpr += expr.Substring(0, crPos);
424 outSubject += expr.Substring(crPos + 1);
425 }
426 else
427 {
428 outExpr += expr;
429 }
430 };
431
432 if (breakpoint->mCondition != NULL)
433 {
434 ClearCallStack();
435
436 auto conditional = breakpoint->mCondition;
437 if (conditional->mDbgEvaluationContext == NULL)
438 {
439 StringT<256> expr;
440 StringT<256> subjectExpr;
441 _SplitExpr(conditional->mExpr, expr, subjectExpr);
442
443 conditional->mDbgEvaluationContext = new CeEvaluationContext(this, expr);
444 conditional->mDbgEvaluationContext->mCallStackIdx = -1;
445 }
446
447 CeDbgState dbgState;
448 BfTypedValue result = conditional->mDbgEvaluationContext->EvaluateInContext(BfTypedValue(), &dbgState);
449
450 if (conditional->mDbgEvaluationContext->mPassInstance->HasFailed())
451 {
452 String errorStr = "FAILED";
453 for (auto error : conditional->mDbgEvaluationContext->mPassInstance->mErrors)
454 {
455 if (!error->mIsWarning)
456 errorStr = error->mError;
457 }
458 String condError = StrFormat("error Conditional breakpoint expression '%s' failed: %s", conditional->mExpr.c_str(), errorStr.c_str());
459 mDebugManager->mOutMessages.push_back(condError);
460 return true;
461 }
462 else if (dbgState.mBlockedSideEffects)
463 {
464 mDebugManager->mOutMessages.push_back(StrFormat("error Conditional breakpoint expression '%s' contained function calls, which is not allowed", conditional->mExpr.c_str()));
465 return true;
466 }
467 else if ((!result) || (!result.mType->IsBoolean()))
468 {
469 mDebugManager->mOutMessages.push_back(StrFormat("error Conditional breakpoint expression '%s' must result in a boolean value", conditional->mExpr.c_str()));
470 return true;
471 }
472 else if (ValueToInt(result) <= 0)
473 return false;

Callers 1

ExecuteMethod · 0.45

Calls 11

BfTypedValueClass · 0.85
SubstringMethod · 0.80
HasFailedMethod · 0.80
AppendMethod · 0.80
IndexOfMethod · 0.45
EvaluateInContextMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45
IsBooleanMethod · 0.45
IsEmptyMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected