| 10609 | } |
| 10610 | |
| 10611 | String WinDebugger::EvaluateToAddress(const StringImpl& expr, int callStackIdx, int cursorPos) |
| 10612 | { |
| 10613 | AutoCrit autoCrit(mDebugManager->mCritSect); |
| 10614 | |
| 10615 | if (IsInRunState()) |
| 10616 | return "!Target not paused"; |
| 10617 | |
| 10618 | auto dbgModule = GetCallStackDbgModule(callStackIdx); |
| 10619 | auto dbgCompileUnit = GetCallStackCompileUnit(callStackIdx); |
| 10620 | |
| 10621 | BfParser parser(mBfSystem); |
| 10622 | parser.mCompatMode = true; |
| 10623 | |
| 10624 | BfPassInstance bfPassInstance(mBfSystem); |
| 10625 | auto terminatedExpr = expr + ";"; |
| 10626 | parser.SetSource(terminatedExpr.c_str(), terminatedExpr.length()); |
| 10627 | parser.Parse(&bfPassInstance); |
| 10628 | |
| 10629 | BfReducer bfReducer; |
| 10630 | bfReducer.mAlloc = parser.mAlloc; |
| 10631 | bfReducer.mSystem = mBfSystem; |
| 10632 | bfReducer.mPassInstance = &bfPassInstance; |
| 10633 | bfReducer.mVisitorPos = BfReducer::BfVisitorPos(parser.mRootNode); |
| 10634 | bfReducer.mVisitorPos.MoveNext(); |
| 10635 | bfReducer.mSource = &parser; |
| 10636 | auto exprNode = bfReducer.CreateExpression(parser.mRootNode->GetFirst()); |
| 10637 | parser.Close(); |
| 10638 | |
| 10639 | DwAutoComplete autoComplete; |
| 10640 | DbgExprEvaluator dbgExprEvaluator(this, dbgModule, &bfPassInstance, callStackIdx, cursorPos); |
| 10641 | if (cursorPos != -1) |
| 10642 | dbgExprEvaluator.mAutoComplete = &autoComplete; |
| 10643 | dbgExprEvaluator.mDbgCompileUnit = dbgCompileUnit; |
| 10644 | |
| 10645 | DwFormatInfo formatInfo; |
| 10646 | formatInfo.mCallStackIdx = callStackIdx; |
| 10647 | |
| 10648 | DbgTypedValue exprResult; |
| 10649 | if (exprNode != NULL) |
| 10650 | exprResult = dbgExprEvaluator.Resolve(exprNode); |
| 10651 | |
| 10652 | DbgType* resultType = exprResult.mType->RemoveModifiers(); |
| 10653 | |
| 10654 | String val; |
| 10655 | if (bfPassInstance.HasFailed()) |
| 10656 | { |
| 10657 | val = StrFormat("!%d\t%d\t%s", bfPassInstance.mErrors[0]->mSrcStart, bfPassInstance.mErrors[0]->GetSrcLength(), bfPassInstance.mErrors[0]->mError.c_str()); |
| 10658 | } |
| 10659 | else if (exprResult.mType == NULL) |
| 10660 | { |
| 10661 | val = "!Invalid expression"; |
| 10662 | } |
| 10663 | else if (!resultType->IsPointerOrRef()) |
| 10664 | { |
| 10665 | if (exprResult.mSrcAddress != 0) |
| 10666 | val = StrFormat("!Type '%s' is invalid. A sized pointer type is expected. Try using the '&' address-of operator.", exprResult.mType->ToString().c_str()); |
| 10667 | else |
| 10668 | val = StrFormat("!Type '%s' is invalid. A sized pointer type is expected. An explicit cast may be required.", exprResult.mType->ToString().c_str()); |
no test coverage detected