public async Task LldbEvalWithFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode) { const string expressionText = "myVar"; IDebugExpression expression = CreateExpression( expressionText, ExpressionEvaluationStrategy.LLDB_EVAL_WITH_FALLBACK); RemoteValueFake errorValue = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode); RemoteValueFake expressionValue = RemoteValueFakeUtil.CreateClass("CustomType", "$17", "23"); _mockDebuggerStackFrame.EvaluateExpressionLldbEvalAsync(expressionText) .Returns(errorValue); _mockDebuggerStackFrame.EvaluateExpressionAsync(expressionText) .Returns(expressionValue); Assert.AreEqual(VSConstants.S_OK, expression.EvaluateSync(0, 0, null, out IDebugProperty2 property)); Assert.AreEqual(expressionText, GetName(property)); Assert.AreEqual("CustomType", GetType(property)); Assert.AreEqual("23", GetValue(property)); // Make sure that a fallback to the LLDB happened. await _mockDebuggerStackFrame.Received(1).EvaluateExpressionLldbEvalAsync( Arg.Is(expressionText)); await _mockDebuggerStackFrame.Received(1).EvaluateExpressionAsync( Arg.Is(expressionText)); }
public ExpressionEvaluationStepBatchParams(ExpressionEvaluationEngine stepEngine, LldbEvalErrorCode lldbEvalErrorCode, long durationUs) { StepEngine = stepEngine; LldbEvalErrorCode = lldbEvalErrorCode; DurationUs = durationUs; }
public void LldbEvalEvaluationResultBatchTest(LldbEvalErrorCode resultSource, ExpressionEvaluationStep.Types.EngineResult resultExpected) { var step = new ExpressionEvaluationStepBatchParams(ExpressionEvaluationEngine.LLDB_EVAL, resultSource, 500); var steps = new List <ExpressionEvaluationStepBatchParams> { step }; var batchParams = new ExpressionEvaluationBatchParams( ExpressionEvaluationStrategy.LLDB, ExpressionEvaluationContext.FRAME, steps, 500, 2000, null); _expressionEvaluationBatch.Add(batchParams); var batchSummary = _expressionEvaluationBatch.GetSummary(); Assert.NotNull(batchSummary.Proto.ExpressionEvaluations); Assert.AreEqual(1, batchSummary.Proto.ExpressionEvaluations.Count); var expressionEvaluation = batchSummary.Proto.ExpressionEvaluations[0]; Assert.NotNull(expressionEvaluation.EvaluationSteps); Assert.AreEqual(1, expressionEvaluation.EvaluationSteps.Count); var firstStep = expressionEvaluation.EvaluationSteps[0]; Assert.AreEqual(resultExpected, firstStep.Result); }
public static RemoteValueFake CreateLldbEvalError(LldbEvalErrorCode errCode, string errorMessage = "", string name = "", string value = "") { var errorValue = new RemoteValueFake(name, value); errorValue.SetError(new SbErrorStub(false, errorMessage, Convert.ToUInt32(errCode))); return(errorValue); }
public void InvalidLldbEvalErrorCodeMappedToUnknownTest(LldbEvalErrorCode code) { var step = new ExpressionEvaluationStepBatchParams( ExpressionEvaluationEngine.LLDB_EVAL, code, 500); var steps = new List <ExpressionEvaluationStepBatchParams> { step }; var batchParams = new ExpressionEvaluationBatchParams( ExpressionEvaluationStrategy.LLDB_EVAL, ExpressionEvaluationContext.FRAME, steps, 500, 2000, null); _expressionEvaluationBatch.Add(batchParams); var summary = _expressionEvaluationBatch.GetSummary(); Assert.AreEqual( ExpressionEvaluationStep.Types.EngineResult.LldbEvalUnknown, summary.Proto.ExpressionEvaluations[0].EvaluationSteps[0].Result.Value); }
public void LldbEvalDontFallbackCommonErrors(LldbEvalErrorCode lldbEvalErrorCode) { _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB_EVAL_WITH_FALLBACK; RemoteValue mockVariable = CreateMockVariable(); RemoteValue errorValue = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode, "the error message"); mockVariable .EvaluateExpressionLldbEvalAsync(Arg.Any <string>(), Arg.Any <IDictionary <string, RemoteValue> >()) .Returns(errorValue); var exception = Assert.ThrowsAsync <ExpressionEvaluationFailed>( async() => await _evaluator.EvaluateExpressionAsync( "2 + 2", _varInfoFactory.Create(mockVariable), new NatvisScope(), "result")); Assert.That(exception.Message, Does.Contain("the error message")); }
public async Task LldbEvalWithoutFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode) { const string expressionText = "myVar"; IDebugExpression expression = CreateExpression(expressionText, ExpressionEvaluationStrategy.LLDB_EVAL); RemoteValueFake errorValue = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode); _mockDebuggerStackFrame.EvaluateExpressionLldbEvalAsync(expressionText) .Returns(errorValue); Assert.AreEqual(VSConstants.S_OK, expression.EvaluateSync(0, 0, null, out IDebugProperty2 property)); // Make sure that a fallback to the LLDB didn't happen. await _mockDebuggerStackFrame.Received(1).EvaluateExpressionLldbEvalAsync( Arg.Is(expressionText)); await _mockDebuggerStackFrame.DidNotReceive().EvaluateExpressionAsync( Arg.Any <string>()); }
public async Task LldbEvalWithFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode) { _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB_EVAL_WITH_FALLBACK; RemoteValue mockVariable = CreateMockVariable(); RemoteValue errorValue = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode); var natvisScope = new NatvisScope(); mockVariable .EvaluateExpressionLldbEvalAsync(Arg.Any <string>(), Arg.Any <IDictionary <string, RemoteValue> >()) .Returns(errorValue); await _evaluator.EvaluateExpressionAsync("expr", _varInfoFactory.Create(mockVariable), natvisScope, "result"); await mockVariable.Received(1).EvaluateExpressionLldbEvalAsync( Arg.Is("expr"), Arg.Is(natvisScope.ContextVariables)); mockVariable.DidNotReceiveWithAnyArgs().GetValueForExpressionPath(Arg.Any <string>()); await mockVariable.Received(1).EvaluateExpressionAsync(Arg.Is("expr")); }
// Step finalization for LLDB_EVAL engine. public void Finalize(LldbEvalErrorCode lldbEvalErrorCode) { long endTicks = _timeSource.GetTimestampTicks(); if (_engine != ExpressionEvaluationEngine.LLDB_EVAL) { throw new ArgumentException( $"Engine {_engine} is incompatible with LldbEvalErrorCode (" + $"{lldbEvalErrorCode}). Check the parameters for the invoked method."); } if (_finalized) { throw new InvalidOperationException("Object is already finalized"); } var batchParams = new ExpressionEvaluationStepBatchParams( _engine, lldbEvalErrorCode, _timeSource.GetDurationUs(_startTicks, endTicks)); _stepsRecorder.AddStep(batchParams); _finalized = true; }