Exemplo n.º 1
0
        private IDebugProperty2 EvaluateExpression(IDebugThread2 thread, string expression)
        {
            // Capture a IDebugExpression2 interface inorder to do that.
            IEnumDebugFrameInfo2 debugFrameEnumerator;

            if (thread.EnumFrameInfo((uint)enum_FRAMEINFO_FLAGS.FIF_FRAME, decimalBaseRadix, out debugFrameEnumerator) != S_OK)
            {
                return(null);
            }

            IDebugExpressionContext2 expressionContext = null;

            using (new DisposableComReference(debugFrameEnumerator)) {
                debugFrameEnumerator.Reset();

                uint frameCount;
                if (debugFrameEnumerator.GetCount(out frameCount) != S_OK)
                {
                    return(null);
                }

                FRAMEINFO[] frameInfo = new FRAMEINFO[frameCount];
                if (debugFrameEnumerator.Next(frameCount, frameInfo, ref frameCount) != S_OK)
                {
                    return(null);
                }

                for (int i = 0; i < frameInfo.Length; i++)
                {
                    if (frameInfo[i].m_pFrame != null && frameInfo[i].m_pFrame.GetExpressionContext(out expressionContext) == S_OK)
                    {
                        break;
                    }
                }
            }

            using (new DisposableComReference(expressionContext)) {
                IDebugExpression2 debugExpression;
                string            errorString;
                uint errorIndex;

                if (expressionContext.ParseText(expression, (uint)enum_PARSEFLAGS.PARSE_EXPRESSION, decimalBaseRadix, out debugExpression, out errorString, out errorIndex) != S_OK)
                {
                    return(null);
                }

                using (new DisposableComReference(debugExpression)) {
                    IDebugProperty2 debugProperty;
                    if (debugExpression.EvaluateSync((uint)enum_EVALFLAGS.EVAL_NOSIDEEFFECTS, evaluateExpressionTimeout, null, out debugProperty) == S_OK)
                    {
                        return(debugProperty);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 2
0
 private static void __Execute(IDebugExpressionContext2 context, string expression)
 {
     if ((context != null) && (string.IsNullOrEmpty(expression) == false))
     {
         var a_Context = (IDebugExpression2)null;
         {
             var a_Context1 = "";
             var a_Context2 = (uint)0;
             if (context.ParseText(expression, enum_PARSEFLAGS.PARSE_EXPRESSION, 0, out a_Context, out a_Context1, out a_Context2) == VSConstants.S_OK)
             {
                 var a_Context3 = (IDebugProperty2)null;
                 a_Context.EvaluateSync(enum_EVALFLAGS.EVAL_RETURNVALUE, 2000, null, out a_Context3);
             }
             else
             {
                 service.Output.WriteError(a_Context1 + "// Error code: " + a_Context2.ToString());
             }
         }
     }
 }