Пример #1
0
        public void EvaluateSyncWithFormatSpecifier()
        {
            string           expressionText  = "myVar";
            string           formatSpecifier = ",x";
            string           testText        = expressionText + formatSpecifier;
            IDebugExpression expression      = CreateExpression(testText);

            RemoteValueFake remoteValue = RemoteValueFakeUtil.CreateSimpleInt("myVar", 16);

            _mockDebuggerStackFrame.FindValue(testText, ValueType.VariableGlobal)
            .Returns((RemoteValue)null);
            _mockDebuggerStackFrame.GetValueForVariablePath(expressionText)
            .Returns((RemoteValue)null);
            _mockDebuggerStackFrame.FindValue(expressionText, ValueType.VariableGlobal)
            .Returns((RemoteValue)null);
            _mockDebuggerStackFrame.EvaluateExpressionAsync(expressionText).Returns(remoteValue);

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            Assert.AreEqual(testText, GetName(property));
            Assert.AreEqual(testText, GetFullName(property));
            Assert.AreEqual("int", GetType(property));
            Assert.AreEqual("0x10", GetValue(property));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public void EvaluateSyncForLldbScratchVariable()
        {
            IDebugExpression expression = CreateExpression("$10");

            _mockDebuggerStackFrame.FindValue("10", ValueType.Register).Returns((RemoteValue)null);

            Assert.AreEqual(VSConstants.E_FAIL,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));
            Assert.AreEqual(null, property);
        }
Пример #4
0
        public void InvalidCommand()
        {
            IDebugExpression expression = CreateExpression(".invalidcommand");

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            DEBUG_PROPERTY_INFO info =
                GetPropertyInfo(property, enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB);

            Assert.That(info.dwAttrib.HasFlag(enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_ERROR));
        }
Пример #5
0
        public void NatvisReloadCommand()
        {
            IDebugExpression expression = CreateExpression(".natvisreload");

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            DEBUG_PROPERTY_INFO info =
                GetPropertyInfo(property, enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ATTRIB);

            Assert.That(!info.dwAttrib.HasFlag(enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_VALUE_ERROR));

            _engineCommandsMock.Received().ReloadNatvis(Arg.Any <TextWriter>(), out string _);
        }
Пример #6
0
        public void EvaluateSyncForNullResult()
        {
            string           testText   = "myVar";
            IDebugExpression expression = CreateExpression(testText);

            _mockDebuggerStackFrame.GetValueForVariablePath(testText).Returns((RemoteValue)null);
            _mockDebuggerStackFrame.FindValue(testText, ValueType.VariableGlobal)
            .Returns((RemoteValue)null);
            _mockDebuggerStackFrame.EvaluateExpressionAsync(testText).Returns((RemoteValue)null);

            Assert.AreEqual(VSConstants.E_FAIL,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));
            Assert.AreEqual(null, property);
        }
Пример #7
0
        public void EvaluateSyncForVariablePath()
        {
            const string     expressionText        = "myVar";
            IDebugExpression expression            = CreateExpression(expressionText);
            RemoteValueFake  variablePathValueNode =
                RemoteValueFakeUtil.CreateClass("CustomType", "$17", "23");

            _mockDebuggerStackFrame.GetValueForVariablePath(expressionText)
            .Returns(variablePathValueNode);

            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));
        }
Пример #8
0
        public void EvaluateSyncForRegister()
        {
            string expressionText = "$rax";

            IDebugExpression expression         = CreateExpression(expressionText);
            RemoteValueFake  findValueValueNode =
                RemoteValueFakeUtil.CreateUnsignedLongRegister("rax", 123u);

            _mockDebuggerStackFrame.FindValue("rax", ValueType.Register)
            .Returns(findValueValueNode);

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            Assert.AreEqual(expressionText, GetName(property));
            Assert.AreEqual("unsigned long", GetType(property));
            Assert.AreEqual("123", GetValue(property));
        }
Пример #9
0
        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>());
        }
Пример #10
0
        public void EvaluateSyncForAddressOf()
        {
            const string     expressionText = "&myVar";
            IDebugExpression expression     = CreateExpression("&myVar");

            var expressionValueNode = new RemoteValueFake("$17", "23");

            expressionValueNode.SetTypeInfo(new SbTypeStub("CustomType", TypeFlags.IS_CLASS));

            _mockDebuggerStackFrame.FindValue(expressionText, ValueType.VariableGlobal)
            .Returns((RemoteValue)null);
            _mockDebuggerStackFrame.EvaluateExpressionAsync(expressionText)
            .Returns(expressionValueNode);

            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));
            _mockDebuggerStackFrame.DidNotReceiveWithAnyArgs().GetValueForVariablePath(null);
        }