Example #1
0
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            AutoResetEvent         completion = new AutoResetEvent(false);
            PythonEvaluationResult result     = null;

            TaskHelpers.RunSynchronouslyOnUIThread(ct => _frame.StackFrame.ExecuteTextAsync(_expression, (obj) => {
                result = obj;
                completion.Set();
            }, ct));

            while (!_frame.StackFrame.Thread.Process.HasExited && !completion.WaitOne(Math.Min((int)dwTimeout, 100)))
            {
                if (dwTimeout <= 100)
                {
                    break;
                }
                dwTimeout -= 100;
            }

            if (_frame.StackFrame.Thread.Process.HasExited || result == null)
            {
                ppResult = null;
                return(VSConstants.E_FAIL);
            }
            else if (result == null)
            {
                ppResult = null;
                return(DebuggerConstants.E_EVALUATE_TIMEOUT);
            }
            ppResult = new AD7Property(_frame, result, _writable);

            return(VSConstants.S_OK);
        }
Example #2
0
 int IDebugExpression2.EvaluateAsync(
     enum_EVALFLAGS dwFlags,
     IDebugEventCallback2 pExprCallback)
 {
     // For now, no async evaluation supported.
     return(VSConstants.E_NOTIMPL);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EvaluateSync(enum_EVALFLAGS evaluateFlags, uint timeout, IDebugEventCallback2 eventCallback, out IDebugProperty2 result)
        {
            //
            // Evaluate the expression synchronously.
            //

            LoggingUtils.PrintFunction();

            try
            {
                CLangDebuggeeStackFrame stackFrame = m_stackFrame as CLangDebuggeeStackFrame;

                result = stackFrame.EvaluateCustomExpression(evaluateFlags, m_expression, m_radix);

                if (result == null)
                {
                    return(Constants.E_FAIL);
                }

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                result = null;

                return(Constants.E_FAIL);
            }
        }
 int IDebugExpression2.EvaluateAsync(
   enum_EVALFLAGS dwFlags, 
   IDebugEventCallback2 pExprCallback)
 {
   // For now, no async evaluation supported.
   return VSConstants.E_NOTIMPL;
 }
        // This method evaluates the expression asynchronously.
        // This method should return immediately after it has started the expression evaluation. 
        // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2 
        // must be sent to the IDebugEventCallback2 event callback
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) {
            _tokenSource = new CancellationTokenSource();

            _frame.StackFrame.ExecuteTextAsync(_expression, _tokenSource.Token)
                .ContinueWith(p => {
                    try {
                        IDebugProperty2 property;
                        if (p.Exception != null && p.Exception.InnerException != null) {
                            property = new AD7EvalErrorProperty(p.Exception.InnerException.Message);
                        } else if (p.IsCanceled) {
                            property = new AD7EvalErrorProperty("Evaluation canceled");
                        } else if (p.IsFaulted || p.Result == null) {
                            property = new AD7EvalErrorProperty("Error");
                        } else {
                            property = new AD7Property(_frame, p.Result);
                        }

                        _tokenSource.Token.ThrowIfCancellationRequested();
                        _frame.Engine.Send(
                            new AD7ExpressionEvaluationCompleteEvent(this, property),
                            AD7ExpressionEvaluationCompleteEvent.IID,
                            _frame.Engine,
                            _frame.Thread);
                    } finally {
                        _tokenSource.Dispose();
                        _tokenSource = null;
                    }
                }, _tokenSource.Token);

            return VSConstants.S_OK;
        }
Example #6
0
        // This method evaluates the expression asynchronously.
        // This method should return immediately after it has started the expression evaluation.
        // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
        // must be sent to the IDebugEventCallback2 event callback
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            if (pExprCallback == null)
            {
                return(VisualStudioExtensionConstants.S_FALSE);
            }

            if (_asyncEval == null || _asyncEval.ThreadState != System.Threading.ThreadState.Running)
            {
                _asyncEval = new System.Threading.Thread(() =>
                {
                    uint attributes;
                    Guid riidEvent = new Guid(XamarinExpressionEvaluationCompleteEvent.IID);
                    IDebugExpressionEvaluationCompleteEvent2 evnt = new XamarinExpressionEvaluationCompleteEvent(this, new XamarinProperty(_var));
                    IDebugEvent2 eventObject = evnt as IDebugEvent2;
                    if (eventObject.GetAttributes(out attributes) != VisualStudioExtensionConstants.S_OK)
                    {
                        throw new InvalidOperationException("Failed to create and register a thread. The event object failed to get its attributes");
                    }
                    if (pExprCallback.Event(_engine.MonoEngine, null, _engine.ActiveProgram, _thread, eventObject, ref riidEvent, attributes) != VisualStudioExtensionConstants.S_OK)
                    {
                        throw new InvalidOperationException("Failed to create and register a thread. The event has not been sent succesfully");
                    }
                });
                _asyncEval.Start();
                return(VisualStudioExtensionConstants.S_OK);
            }
            return(VisualStudioExtensionConstants.S_FALSE);
        }
Example #7
0
        public override async Task<Results> VarCreate(string expression, int threadId, uint frameLevel, enum_EVALFLAGS dwFlags, ResultClass resultClass = ResultClass.done)
        {
            string command = string.Format("-var-create - - \"{0}\"", expression);  // use '-' to indicate that "--frame" should be used to determine the frame number
            Results results = await ThreadFrameCmdAsync(command, resultClass, threadId, frameLevel);

            return results;
        }
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) {
            AutoResetEvent completion = new AutoResetEvent(false);
            PythonEvaluationResult result = null;
            _frame.StackFrame.ExecuteText(_expression, (obj) => {
                result = obj;
                completion.Set();
            });
            
            while (!_frame.StackFrame.Thread.Process.HasExited && !completion.WaitOne(Math.Min((int)dwTimeout, 100))) {
                if (dwTimeout <= 100) {
                    break;
                }
                dwTimeout -= 100;
            }

            if (_frame.StackFrame.Thread.Process.HasExited || result == null) {
                ppResult = null;
                return VSConstants.E_FAIL;
            } else if (result == null) {
                ppResult = null;
                return DebuggerConstants.E_EVALUATE_TIMEOUT;
            }
            ppResult = new AD7Property(_frame, result, _writable);

            return VSConstants.S_OK;
        }
Example #9
0
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            var res = TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.StackFrame.EvaluateAsync(_expression, AD7Property.PrefetchedFields, AD7Property.ReprMaxLength, ct));

            ppResult = new AD7Property(StackFrame, res);
            return(VSConstants.S_OK);
        }
            // Token: 0x06000201 RID: 513 RVA: 0x00006FC0 File Offset: 0x000051C0
            int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
            {
                EvaluationOptions defaultOptions = StackFrame.DefaultOptions;

                defaultOptions.EvaluationTimeout       = (int)dwTimeout;
                defaultOptions.MemberEvaluationTimeout = (int)dwTimeout;
                defaultOptions.EllipsizeStrings        = false;
                defaultOptions.IntegerDisplayFormat    = this.Frame.Session.EvaluationOptions.IntegerDisplayFormat;
                if ((dwFlags & enum_EVALFLAGS.EVAL_NOFUNCEVAL) != 0)
                {
                    defaultOptions.AllowMethodEvaluation = false;
                    defaultOptions.AllowTargetInvoke     = false;
                }
                ObjectValue expressionValue = this.Frame.Frame.GetExpressionValue(this.Text, defaultOptions);

                if (expressionValue == null)
                {
                    ppResult = null;
                    return(1);
                }
                if (!expressionValue.WaitHandle.WaitOne((int)dwTimeout))
                {
                    ppResult = null;
                    return(-2147221455);
                }
                if (expressionValue.IsError)
                {
                    ppResult = null;
                    return(1);
                }
                expressionValue.Name = this.Text;
                ppResult             = new StackFrame.Property(this.Frame, expressionValue);
                return(0);
            }
Example #11
0
 public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                         out IDebugProperty2 ppResult)
 {
     if (property != null)
     {
         ppResult = property;
         return(Constants.S_OK);
     }
     else
     {
         property = frame.Engine.DebuggedProcess.Resolve(frame, exp, dwTimeout) as ILProperty;
         ppResult = property;
         if (property != null)
         {
             if (string.IsNullOrEmpty(property.Name))
             {
                 property.Name = oriExp;
             }
             return(Constants.S_OK);
         }
         else
         {
             return(Constants.E_FAIL);
         }
     }
 }
 public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                         out IDebugProperty2 ppResult)
 {
     Log.Debug("EvaluateSync");
     ppResult = ScriptPropertyFactory.MakeProperty(_debugger, _var, string.Empty); // no parent path
     return(VSConstants.S_OK);
 }
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            //bool hex = SquirrelDebuggerEngine.SquirrelDebuggerEnginePackage.HexDisplayMode;

            ppResult = new AD7Property(var);
            return(EngineConstants.S_OK);
        }
Example #14
0
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            var timeout     = TimeSpan.FromMilliseconds(dwTimeout);
            var tokenSource = new CancellationTokenSource(timeout);

            ppResult = null;

            NodeEvaluationResult result;

            try
            {
                result = this._frame.StackFrame.ExecuteTextAsync(this._expression, tokenSource.Token).WaitAsync(timeout, tokenSource.Token).WaitAndUnwrapExceptions();
            }
            catch (DebuggerCommandException ex)
            {
                ppResult = new AD7EvalErrorProperty(ex.Message);
                return(VSConstants.S_OK);
            }
            catch (OperationCanceledException)
            {
                return(DebuggerConstants.E_EVALUATE_TIMEOUT);
            }

            if (result == null)
            {
                return(VSConstants.E_FAIL);
            }

            ppResult = new AD7Property(this._frame, result);
            return(VSConstants.S_OK);
        }
Example #15
0
        // This method evaluates the expression asynchronously.
        // This method should return immediately after it has started the expression evaluation.
        // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
        // must be sent to the IDebugEventCallback2 event callback
        //
        // This is primarily used for the immediate window which this engine does not currently support.
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            Thread m_processingThread;
            m_processingThread = new Thread(evaluatingAsync);
            m_processingThread.Start();

            return VSConstants.S_OK;
        }
Example #16
0
        /// <summary>
        /// This method evaluates the expression synchronously. (http://msdn.microsoft.com/en-ca/library/bb146982.aspx)
        /// </summary>
        /// <param name="dwFlags"> A combination of flags from the EVALFLAGS enumeration that control expression evaluation. </param>
        /// <param name="dwTimeout"> Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait
        /// indefinitely. </param>
        /// <param name="pExprCallback"> This parameter is always a null value. </param>
        /// <param name="ppResult"> Returns the IDebugProperty2 object that contains the result of the expression evaluation. </param>
        /// <returns> VSConstants.S_OK. </returns>
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            VariableInfo vi = VariableInfo.get(exp, m_eventDispatcher, m_frame);

            ppResult = new AD7Property(vi);
            m_frame._lastEvaluatedExpression = vi;
            return(VSConstants.S_OK);
        }
Example #17
0
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
            out IDebugProperty2 ppResult)
        {
            ppResult = null;
            int idx = _index;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int) dwTimeout)
                                     .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return VSConstants.S_OK;
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not 
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash the VM if the register is not of the casted type)", _castExpr, null)
                                                     { HasSideEffects = true };
                    return VSConstants.E_FAIL;
                }

                var isParam = _registerType == "p";

                if (isParam)
                {
                    var loc = _stackFrame.GetDocumentLocationAsync().Await((int) dwTimeout);
                    if (loc == null)
                        return VSConstants.E_FAIL;
                    var methodDiss = _stackFrame.Thread.Program.DisassemblyProvider.GetFromLocation(loc);
                    if (methodDiss == null)
                        return VSConstants.E_FAIL;
                    idx += methodDiss.Method.Body.Registers.Count - methodDiss.Method.Body.IncomingArguments;
                }

                var reg = _stackFrame.GetRegistersAsync(false, tag, idx).Await((int) dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return VSConstants.S_OK;
                }
            }

            return VSConstants.E_FAIL;
        }
 /// <summary>
 /// This method evaluates the expression synchronously.
 /// </summary>
 /// <param name="dwFlags">A combination of flags from the EVALFLAGS enumeration that control expression evaluation.</param>
 /// <param name="dwTimeout">Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait indefinitely.</param>
 /// <param name="pExprCallback">This parameter is always a null value.</param>
 /// <param name="ppResult">Returns the IDebugProperty2 object that contains the result of the expression evaluation.</param>
 /// <returns>
 /// If successful, returns S_OK; otherwise returns an error code. Some typical error codes are:
 /// Error                               Description
 /// E_EVALUATE_BUSY_WITH_EVALUATION     Another expression is currently being evaluated, and simultaneous expression evaluation is not supported.
 /// E_EVALUATE_TIMEOUT                  Evaluation timed out.
 /// </returns>
 /// <remarks>For synchronous evaluation, it is not necessary to send an event back to Visual Studio upon completion of the evaluation.</remarks>
 public int EvaluateSync( enum_EVALFLAGS dwFlags,
     uint dwTimeout,
     IDebugEventCallback2 pExprCallback,
     out IDebugProperty2 ppResult)
 {
     Logger.Debug( string.Empty );
     ppResult = null;
     return VSConstants.E_NOTIMPL;
 }
Example #19
0
        public int EvaluateSync(enum_EVALFLAGS flags, uint timeout, IDebugEventCallback2 callback,
                                out IDebugProperty2 result)
        {
            EvaluationResult evalResult = taskExecutor
                                          .Run(async() => await asyncEvaluator.EvaluateExpressionAsync());

            result = evalResult.Result;
            return(evalResult.Status);
        }
Example #20
0
 /// <summary>
 /// This method evaluates the expression synchronously.
 /// </summary>
 /// <param name="dwFlags">A combination of flags from the EVALFLAGS enumeration that control expression evaluation.</param>
 /// <param name="dwTimeout">Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait indefinitely.</param>
 /// <param name="pExprCallback">This parameter is always a null value.</param>
 /// <param name="ppResult">Returns the IDebugProperty2 object that contains the result of the expression evaluation.</param>
 /// <returns>
 /// If successful, returns S_OK; otherwise returns an error code. Some typical error codes are:
 /// Error                               Description
 /// E_EVALUATE_BUSY_WITH_EVALUATION     Another expression is currently being evaluated, and simultaneous expression evaluation is not supported.
 /// E_EVALUATE_TIMEOUT                  Evaluation timed out.
 /// </returns>
 /// <remarks>For synchronous evaluation, it is not necessary to send an event back to Visual Studio upon completion of the evaluation.</remarks>
 public int EvaluateSync(enum_EVALFLAGS dwFlags,
                         uint dwTimeout,
                         IDebugEventCallback2 pExprCallback,
                         out IDebugProperty2 ppResult)
 {
     Logger.Debug(string.Empty);
     ppResult = null;
     return(VSConstants.E_NOTIMPL);
 }
Example #21
0
        public void SyncEval(enum_EVALFLAGS dwFlags = 0)
        {
            Task eval = Task.Run(async() =>
            {
                await Eval(dwFlags);
            });

            eval.Wait();
        }
Example #22
0
        public int EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            // don't use pExprCallback!

            IDebugEventCallback2 callback = _context.StackFrame.Thread.Program.Callback;
            Task<IDebugProperty2> evaluateTask = Task.Factory.StartNew(() => EvaluateImpl(dwFlags)).HandleNonCriticalExceptions();
            Task successCompletionTask = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(task, callback), TaskContinuationOptions.OnlyOnRanToCompletion).HandleNonCriticalExceptions();
            Task failureCompletionTask = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(null, callback), TaskContinuationOptions.NotOnRanToCompletion).HandleNonCriticalExceptions();
            return VSConstants.S_OK;
        }
Example #23
0
        /// <summary>
        /// This method evaluates the expression asynchronously.
        /// This is primarily used for the immediate window. (http://msdn.microsoft.com/en-ca/library/bb146752.aspx)
        /// </summary>
        /// <param name="dwFlags"> A combination of flags from the EVALFLAGS enumeration that control expression evaluation. </param>
        /// <param name="pExprCallback"> This parameter is always a null value. </param>
        /// <returns> VSConstants.S_OK. </returns>
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            // Creating a thread to evaluate the expression asynchronously.
            Thread m_processingThread;

            m_processingThread = new Thread(evaluatingAsync);
            m_processingThread.Start();

            return(VSConstants.S_OK);
        }
 // This method evaluates the expression asynchronously.
 // This method should return immediately after it has started the expression evaluation. 
 // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2 
 // must be sent to the IDebugEventCallback2 event callback
 //
 // This is primarily used for the immediate window which this engine does not currently support.
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) {
     _frame.StackFrame.ExecuteText(_expression, (obj) => {
         _frame.Engine.Send(
             new AD7ExpressionEvaluationCompleteEvent(this, new AD7Property(_frame, obj, _writable)), 
             AD7ExpressionEvaluationCompleteEvent.IID, 
             _frame.Engine, 
             _frame.Thread);
     });
     return VSConstants.S_OK;
 }
Example #25
0
 // This method evaluates the expression asynchronously.
 // This method should return immediately after it has started the expression evaluation.
 // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
 // must be sent to the IDebugEventCallback2 event callback
 //
 // This is primarily used for the immediate window which this engine does not currently support.
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
 {
     TaskHelpers.RunSynchronouslyOnUIThread(ct => _frame.StackFrame.ExecuteTextAsync(_expression, (obj) => {
         _frame.Engine.Send(
             new AD7ExpressionEvaluationCompleteEvent(this, new AD7Property(_frame, obj, _writable)),
             AD7ExpressionEvaluationCompleteEvent.IID,
             _frame.Engine,
             _frame.Thread);
     }, ct));
     return(VSConstants.S_OK);
 }
        public int EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            // don't use pExprCallback!

            IDebugEventCallback2   callback     = _context.StackFrame.Thread.Program.Callback;
            Task <IDebugProperty2> evaluateTask = Task.Factory.StartNew(() => EvaluateImpl(dwFlags)).HandleNonCriticalExceptions();
            Task successCompletionTask          = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(task, callback), TaskContinuationOptions.OnlyOnRanToCompletion).HandleNonCriticalExceptions();
            Task failureCompletionTask          = evaluateTask.ContinueWith(task => SendEvaluationCompleteEvent(null, callback), TaskContinuationOptions.NotOnRanToCompletion).HandleNonCriticalExceptions();

            return(VSConstants.S_OK);
        }
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                                out IDebugProperty2 ppResult)
        {
            ppResult = null;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int)dwTimeout)
                          .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return(VSConstants.S_OK);
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash a DalvikVM if the register is not of the casted type)", _castExpr, null)
                    {
                        HasSideEffects = true
                    };
                    return(VSConstants.E_FAIL);
                }

                var regNames = _stackFrame.GetRegisterNamesAsync().Await((int)dwTimeout);
                var vmIdx    = regNames.GetVmIndex(_registerType == "p", _index);

                if (vmIdx < 0)
                {
                    return(VSConstants.E_FAIL);
                }

                var reg = _stackFrame.GetRegistersAsync(false, tag, vmIdx).Await((int)dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return(VSConstants.S_OK);
                }
            }

            return(VSConstants.E_FAIL);
        }
            // Token: 0x060001FF RID: 511 RVA: 0x00006F1C File Offset: 0x0000511C
            int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
            {
                EvaluationOptions defaultOptions = StackFrame.DefaultOptions;

                defaultOptions.EvaluationTimeout       = -1;
                defaultOptions.MemberEvaluationTimeout = -1;
                defaultOptions.EllipsizeStrings        = false;
                defaultOptions.IntegerDisplayFormat    = this.Frame.Session.EvaluationOptions.IntegerDisplayFormat;
                ObjectValue value = this.Frame.Frame.GetExpressionValue(this.Text, defaultOptions);

                value.ValueChanged += (o, e) => SendResult(new StackFrame.Property(this.Frame, value));
                return(0);
            }
Example #29
0
        public int EvaluateAsync(enum_EVALFLAGS flags, IDebugEventCallback2 callback)
        {
            Func <Task> evaluationTask = () => taskExecutor.SubmitAsync(async() =>
            {
                EvaluationResult evalResult = await asyncEvaluator.EvaluateExpressionAsync();
                debugEngineHandler.OnEvaluationComplete(Self, evalResult.Result, program, thread);
            }, CancellationToken.None, nameof(EvaluateAsync), typeof(DebugExpression));

            SafeErrorUtil.SafelyLogErrorAndForget(evaluationTask,
                                                  "EvaluateAsync: error evaluating expression asynchronously");

            return(VSConstants.S_OK);
        }
Example #30
0
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        /// <param name="dwFlags">[in] A combination of flags from the EVALFLAGS enumeration that control expression evaluation.</param>
        /// <param name="dwTimeout">[in] Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait indefinitely.</param>
        /// <param name="pExprCallback">[in]This parameter is always a null value.</param>
        /// <param name="ppResult">[out] Returns the IDebugProperty2 object that contains the result of the expression evaluation.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise returns an error code. Some typical error codes are:
        ///  * E_EVALUATE_BUSY_WITH_EVALUATION  Another expression is currently being evaluated, and simultaneous
        ///                                     expression evaluation is not supported.
        ///  * E_EVALUATE_TIMEOUT               Evaluation timed out.
        /// </returns>
        /// <remarks>
        /// For synchronous evaluation, it is not necessary to send an event back to Visual Studio upon completion of the evaluation.
        /// </remarks>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            ppResult = null;

            Task<IDebugProperty2> task = Task.Factory.StartNew(() => EvaluateImpl(dwFlags)).HandleNonCriticalExceptions();
            if (!task.Wait((int)dwTimeout))
                return AD7Constants.E_EVALUATE_TIMEOUT;

            if (task.Status != TaskStatus.RanToCompletion || task.Result == null)
                return VSConstants.E_FAIL;

            ppResult = task.Result;
            return VSConstants.S_OK;
        }
Example #31
0
 public int EvaluateAsync(enum_EVALFLAGS flags, IDebugEventCallback2 callback)
 {
     cancellationToken = new CancellationTokenSource();
     Task.Run(
         () =>
     {
         IDebugProperty2 result;
         EvaluateSync(flags, uint.MaxValue, callback, out result);
         callback = new MonoCallbackWrapper(callback ?? engine.Callback);
         callback.Send(engine, new MonoExpressionCompleteEvent(engine, thread, value, Expression), MonoExpressionCompleteEvent.IID, thread);
     },
         cancellationToken.Token);
     return(VSConstants.S_OK);
 }
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
            out IDebugProperty2 ppResult)
        {
            ppResult = null;

            if (string.IsNullOrEmpty(_castExpr))
            {
                var reg = _stackFrame.GetRegistersAsync().Await((int) dwTimeout)
                                     .FirstOrDefault(r => r.Name == _registerType + _index);
                if (reg != null)
                {
                    ppResult = new DebugStackFrameValueProperty(reg, null, _stackFrame);
                    return VSConstants.S_OK;
                }
            }
            else
            {
                var tag = GetTagFromString(_castExpr);

                if (!tag.IsPrimitive() && (dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0)
                {
                    // this evaluation has "side effects" in that it might crash the VM
                    // if the cast is to "object" or "string", but the register does not
                    // hold an object or string.
                    ppResult = new DebugConstProperty(_expression, "(this cast might crash a DalvikVM if the register is not of the casted type)", _castExpr, null)
                                                     { HasSideEffects = true };
                    return VSConstants.E_FAIL;
                }

                var regNames = _stackFrame.GetRegisterNamesAsync().Await((int)dwTimeout);
                var vmIdx = regNames.GetVmIndex(_registerType == "p", _index);

                if (vmIdx < 0)
                    return VSConstants.E_FAIL;

                var reg = _stackFrame.GetRegistersAsync(false, tag, vmIdx).Await((int)dwTimeout);

                if (reg != null && reg.Count > 0)
                {
                    ppResult = new DebugStackFrameValueProperty(reg[0], null, _stackFrame, _expression)
                    {
                        HasSideEffects = !tag.IsPrimitive()
                    };
                    return VSConstants.S_OK;
                }
            }

            return VSConstants.E_FAIL;
        }
Example #33
0
 public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
                         out IDebugProperty2 ppResult)
 {
     if (property != null || resolved)
     {
         ppResult = property;
         return(Constants.S_OK);
     }
     else
     {
         DoResolve();
         ppResult = property;
         return(Constants.S_OK);
     }
 }
Example #34
0
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback) {
     _cts = new CancellationTokenSource();
     Task.Run(async () => {
         try {
             var res = await StackFrame.StackFrame.EvaluateAsync(_expression, reprMaxLength: AD7Property.ReprMaxLength);
             _cts.Token.ThrowIfCancellationRequested();
             var prop = new AD7Property(StackFrame, res);
             StackFrame.Engine.Send(new AD7ExpressionEvaluationCompleteEvent(this, prop), AD7ExpressionEvaluationCompleteEvent.IID);
         } catch (Exception ex) when (!ex.IsCriticalException()) {
             StackFrame.Engine.Send(new AD7ExpressionEvaluationCompleteEvent(ex), AD7ExpressionEvaluationCompleteEvent.IID);
         } finally {
             _cts = null;
         }
     });
     return VSConstants.S_OK;
 }
        public async Task Eval(enum_EVALFLAGS dwFlags = (enum_EVALFLAGS)0)
        {
            var variable = _engine.DebuggedProcess.ThreadCache.GetVariable(Client.Id, Name);

            var val = String.Empty;

            if (variable != null && !variable.Value.Contains("roAssociativeArray"))
            {
                val = variable.Value;
            }
            else
            {
                val = await _engine.DebuggedProcess.CommandFactory.Print(FullName());
            }

            foreach (var node in mapper)
            {
                if (val.StartsWith(node.Key))
                {
                    VariableNodeType = node.Value;

                    val = val.Replace(node.Key, "").Trim();
                }
            }

            Value = val;

            switch (VariableNodeType)
            {
            case NodeType.Field:
                var parts = val.Split(new char[] { '\n', '\r' });
                foreach (var part in parts)
                {
                    if (part.Contains(":"))
                    {
                        var vals = part.Split(':');
                        Children.Add(new VariableInformation(vals[0].Trim(), this));
                    }
                }
                break;

            default:
                break;
            }
        }
Example #36
0
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
 {
     _cts = new CancellationTokenSource();
     Task.Run(async() => {
         try {
             var res = await StackFrame.StackFrame.EvaluateAsync(_expression, AD7Property.PrefetchedFields, AD7Property.ReprMaxLength);
             _cts.Token.ThrowIfCancellationRequested();
             var prop = new AD7Property(StackFrame, res);
             StackFrame.Engine.Send(new AD7ExpressionEvaluationCompleteEvent(this, prop), AD7ExpressionEvaluationCompleteEvent.IID);
         } catch (Exception ex) when(!ex.IsCriticalException())
         {
             StackFrame.Engine.Send(new AD7ExpressionEvaluationCompleteEvent(ex), AD7ExpressionEvaluationCompleteEvent.IID);
         } finally {
             _cts = null;
         }
     });
     return(VSConstants.S_OK);
 }
Example #37
0
        // This method evaluates the expression asynchronously.
        // This method should return immediately after it has started the expression evaluation.
        // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
        // must be sent to the IDebugEventCallback2 event callback
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            this._tokenSource = new CancellationTokenSource();

            this._frame.StackFrame.ExecuteTextAsync(this._expression, this._tokenSource.Token)
            .ContinueWith(p =>
            {
                try
                {
                    IDebugProperty2 property;
                    if (p.Exception != null && p.Exception.InnerException != null)
                    {
                        property = new AD7EvalErrorProperty(p.Exception.InnerException.Message);
                    }
                    else if (p.IsCanceled)
                    {
                        property = new AD7EvalErrorProperty("Evaluation canceled");
                    }
                    else if (p.IsFaulted || p.Result == null)
                    {
                        property = new AD7EvalErrorProperty("Error");
                    }
                    else
                    {
                        property = new AD7Property(this._frame, p.Result);
                    }

                    this._tokenSource.Token.ThrowIfCancellationRequested();
                    this._frame.Engine.Send(
                        new AD7ExpressionEvaluationCompleteEvent(this, property),
                        AD7ExpressionEvaluationCompleteEvent.IID,
                        this._frame.Engine,
                        this._frame.Thread);
                }
                finally
                {
                    this._tokenSource.Dispose();
                    this._tokenSource = null;
                }
            }, this._tokenSource.Token);

            return(VSConstants.S_OK);
        }
Example #38
0
        int IDebugExpression2.EvaluateAsync(
            enum_EVALFLAGS dwFlags,
            IDebugEventCallback2 pExprCallback)
        {
            _ = Task.Run(() =>
            {
                var value = Debugger.Evaluate(StackFrame.FrameNumber, ExpressionString);
                if (value != null)
                {
                    value.Name = ExpressionString;
                }

                Program.Refresh();

                DebugEvent.Send(new ExpressionEvaluationCompleteEvent(
                                    pExprCallback, this, Property.Create(StackFrame, 0, value)));
            });
            return(VSConstants.S_OK);
        }
        /// <summary>
        /// This method evaluates the expression synchronously.
        /// </summary>
        /// <param name="dwFlags">[in] A combination of flags from the EVALFLAGS enumeration that control expression evaluation.</param>
        /// <param name="dwTimeout">[in] Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait indefinitely.</param>
        /// <param name="pExprCallback">[in]This parameter is always a null value.</param>
        /// <param name="ppResult">[out] Returns the IDebugProperty2 object that contains the result of the expression evaluation.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise returns an error code. Some typical error codes are:
        ///  * E_EVALUATE_BUSY_WITH_EVALUATION  Another expression is currently being evaluated, and simultaneous
        ///                                     expression evaluation is not supported.
        ///  * E_EVALUATE_TIMEOUT               Evaluation timed out.
        /// </returns>
        /// <remarks>
        /// For synchronous evaluation, it is not necessary to send an event back to Visual Studio upon completion of the evaluation.
        /// </remarks>
        public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            ppResult = null;

            Task <IDebugProperty2> task = Task.Factory.StartNew(() => EvaluateImpl(dwFlags)).HandleNonCriticalExceptions();

            if (!task.Wait((int)dwTimeout))
            {
                return(AD7Constants.E_EVALUATE_TIMEOUT);
            }

            if (task.Status != TaskStatus.RanToCompletion || task.Result == null)
            {
                return(VSConstants.E_FAIL);
            }

            ppResult = task.Result;
            return(VSConstants.S_OK);
        }
Example #40
0
        int IDebugExpression2.EvaluateSync(
            enum_EVALFLAGS dwFlags,
            uint dwTimeout,
            IDebugEventCallback2 pExprCallback,
            out IDebugProperty2 ppResult)
        {
            ppResult = null;
            var value = Debugger.Evaluate(StackFrame.FrameNumber, ExpressionString);

            if (value == null || value is JsError)
            {
                return(VSConstants.S_FALSE);
            }

            Program.Refresh();

            value.Name = ExpressionString;
            ppResult   = Property.Create(StackFrame, 0, value);
            return(VSConstants.S_OK);
        }
Example #41
0
        public void GetAndCheckChildValue(string caller_trace, string ExpectedResult, string variable,
                                          int childIndex, bool setEvalFlags, enum_EVALFLAGS evalFlags)
        {
            var res = MIDebugger.Request("-var-create - * " +
                                         "\"" + variable + "\"" +
                                         (setEvalFlags ? (" --evalFlags " + (int)evalFlags) : ""));

            Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace);

            string struct2 = ((MIConst)res["name"]).CString;

            res = MIDebugger.Request("-var-list-children --simple-values " +
                                     "\"" + struct2 + "\"");
            Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace);

            var children = (MIList)res["children"];
            var child    = (MITuple)((MIResult)children[childIndex]).Value;

            Assert.Equal(ExpectedResult, ((MIConst)child["value"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace);
        }
 int IDebugExpression2.EvaluateSync(
   enum_EVALFLAGS dwFlags, 
   uint dwTimeout, 
   IDebugEventCallback2 pExprCallback, 
   out IDebugProperty2 ppResult)
 {
   if (MySql.Debugger.Debugger.GetTagHashCode(_stackFrame._rs.OwningRoutine.SourceCode) !=
     DebuggerManager.Instance.Debugger.CurrentScope.OwningRoutine.Hash)
   {
     // This should never happen.
     ppResult = null;
     return VSConstants.E_NOTIMPL;
   }
   AD7Property prop = new AD7Property( _expr,_stackFrame.Node, _stackFrame._rs );
   ppResult = prop;
   // Send evaluation complete event
   DebuggerManager.Instance._events.ExpressionEvalCompleted( 
     _stackFrame.Node, ( IDebugExpression2 )this, ( IDebugProperty2 )prop );
   return VSConstants.S_OK;
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #region IDebugExpression2 Members

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int EvaluateAsync (enum_EVALFLAGS evaluateFlags, IDebugEventCallback2 eventCallback)
    {
      // 
      // Evaluate the expression asynchronously.
      // Method should return immediately after starting the expression evaluation, when completed successfully
      // a 'IDebugExpressionEvaluationCompleteEvent2' event should be sent to the provided IDebugEventCallback2 callback.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        ThreadPool.QueueUserWorkItem (delegate (object state)
        {
          try
          {
            IDebugProperty2 result;

            IDebugThread2 thread;

            LoggingUtils.RequireOk (m_stackFrame.GetThread (out thread));

            LoggingUtils.RequireOk (EvaluateSync (evaluateFlags, 0, eventCallback, out result));

            m_debugEngine.Broadcast (eventCallback, new DebugEngineEvent.ExpressionEvaluationComplete (this, result), m_debugEngine.Program, thread);
          }
          catch (Exception e)
          {
            LoggingUtils.HandleException (e);
          }
        });

        return Constants.S_OK;
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        return Constants.E_FAIL;
      }
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region IDebugExpression2 Members

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EvaluateAsync(enum_EVALFLAGS evaluateFlags, IDebugEventCallback2 eventCallback)
        {
            //
            // Evaluate the expression asynchronously.
            // Method should return immediately after starting the expression evaluation, when completed successfully
            // a 'IDebugExpressionEvaluationCompleteEvent2' event should be sent to the provided IDebugEventCallback2 callback.
            //

            LoggingUtils.PrintFunction();

            try
            {
                ThreadPool.QueueUserWorkItem(delegate(object state)
                {
                    try
                    {
                        IDebugProperty2 result;

                        IDebugThread2 thread;

                        LoggingUtils.RequireOk(m_stackFrame.GetThread(out thread));

                        LoggingUtils.RequireOk(EvaluateSync(evaluateFlags, 0, eventCallback, out result));

                        m_debugEngine.Broadcast(eventCallback, new DebugEngineEvent.ExpressionEvaluationComplete(this, result), m_debugEngine.Program, thread);
                    }
                    catch (Exception e)
                    {
                        LoggingUtils.HandleException(e);
                    }
                });

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
Example #45
0
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            ppResult = null;
            if ((dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0 && _var.IsVisualized)
            {
                IVariableInformation variable = DebuggedProcess.g_Process.Natvis.Cache.Lookup(_var);
                if (variable == null)
                {
                    ppResult = new AD7ErrorProperty(_var.Name, ResourceStrings.NoSideEffectsVisualizerMessage);
                }
                else
                {
                    _var = variable;
                    ppResult = new AD7Property(_var);
                }
                return Constants.S_OK;
            }

            _var.SyncEval();
            ppResult = new AD7Property(_var);
            return Constants.S_OK;
        }
Example #46
0
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
        {
            NodeEvaluationResult result;
            ppResult = null;

            try
            {
                result = _frame.StackFrame.EvaluateExpressionAsync(_expression).Result;
            }
            catch (Exception)
            {
                return VSConstants.E_FAIL;
            }
            
            if (result == null)
            {
                return VSConstants.E_FAIL;
            }

            ppResult = new AD7Property(result);
            return VSConstants.S_OK;
        }
Example #47
0
        private IDebugProperty2 EvaluateImpl(enum_EVALFLAGS flags)
        {
            ITreeNodeStream input = new CommonTreeNodeStream(_expression);
            DebugExpressionEvaluatorWalker walker = new DebugExpressionEvaluatorWalker(input, _context.StackFrame.StackFrame);
            EvaluatedExpression evaluatedExpression = walker.standaloneExpression();

            // make sure the Name and FullName of the evaluated expression match what the user typed
            evaluatedExpression = new EvaluatedExpression(
                _expressionText,
                _expressionText,
                evaluatedExpression.LocalVariable,
                evaluatedExpression.Referencer,
                evaluatedExpression.Field,
                evaluatedExpression.Method,
                evaluatedExpression.Index,
                evaluatedExpression.Value,
                evaluatedExpression.ValueType,
                evaluatedExpression.StrongReference,
                evaluatedExpression.HasSideEffects);

            return new JavaDebugProperty(null, evaluatedExpression);
        }
Example #48
0
 // This method evaluates the expression asynchronously.
 // This method should return immediately after it has started the expression evaluation.
 // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
 // must be sent to the IDebugEventCallback2 event callback
 //
 // This is primarily used for the immediate window
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
 {
     if (((dwFlags & enum_EVALFLAGS.EVAL_NOSIDEEFFECTS) != 0 && (dwFlags & enum_EVALFLAGS.EVAL_ALLOWBPS) == 0) && _var.IsVisualized)
     {
         IVariableInformation variable = DebuggedProcess.g_Process.Natvis.Cache.Lookup(_var);
         if (variable == null)
         {
             _var.AsyncError(pExprCallback, new AD7ErrorProperty(_var.Name, ResourceStrings.NoSideEffectsVisualizerMessage));
         }
         else
         {
             _var = variable;    // use the old value
             Task.Run(() =>
             {
                 new EngineCallback(DebuggedProcess.g_Process.Engine, pExprCallback).OnExpressionEvaluationComplete(variable);
             });
         }
     }
     else
     {
         _var.AsyncEval(pExprCallback);
     }
     return Constants.S_OK;
 }
        // This method evaluates the expression synchronously.
        int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) {
            TimeSpan timeout = TimeSpan.FromMilliseconds(dwTimeout);
            var tokenSource = new CancellationTokenSource(timeout);
            ppResult = null;

            NodeEvaluationResult result;
            try {
                result = _frame.StackFrame.ExecuteTextAsync(_expression, tokenSource.Token).WaitAsync(timeout, tokenSource.Token).WaitAndUnwrapExceptions();
            } catch (DebuggerCommandException ex) {
                ppResult = new AD7EvalErrorProperty(ex.Message);
                return VSConstants.S_OK;
            } catch (OperationCanceledException) {
                return DebuggerConstants.E_EVALUATE_TIMEOUT;
            }

            if (result == null) {
                return VSConstants.E_FAIL;
            }

            ppResult = new AD7Property(_frame, result);
            return VSConstants.S_OK;
        }
Example #50
0
 int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) {
     var res = TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.StackFrame.TryEvaluateAndDescribeAsync(_expression, AD7Property.PrefetchedProperties, AD7Property.Repr, ct));
     ppResult = new AD7Property(StackFrame, res);
     return VSConstants.S_OK;
 }
Example #51
0
        public virtual async Task<Results> VarCreate(string expression, int threadId, uint frameLevel, enum_EVALFLAGS dwFlags, ResultClass resultClass = ResultClass.done)
        {
            string quoteEscapedExpression = EscapeQuotes(expression);
            string command = string.Format("-var-create - * \"{0}\"", quoteEscapedExpression);
            Results results = await ThreadFrameCmdAsync(command, resultClass, threadId, frameLevel);

            return results;
        }
Example #52
0
 // This method evaluates the expression asynchronously.
 // This method should return immediately after it has started the expression evaluation.
 // When the expression is successfully evaluated, an IDebugExpressionEvaluationCompleteEvent2
 // must be sent to the IDebugEventCallback2 event callback
 //
 // This is primarily used for the immediate window which this engine does not currently support.
 int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
 {
     throw new NotImplementedException();
 }
Example #53
0
 int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult) {
     var res = TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.StackFrame.EvaluateAsync(_expression, reprMaxLength: AD7Property.ReprMaxLength, cancellationToken:ct));
     ppResult = new AD7Property(StackFrame, res);
     return VSConstants.S_OK;
 }
Example #54
0
        /// <summary>
        /// This method evaluates the expression asynchronously.
        /// This is primarily used for the immediate window. (http://msdn.microsoft.com/en-ca/library/bb146752.aspx)
        /// </summary>
        /// <param name="dwFlags"> A combination of flags from the EVALFLAGS enumeration that control expression evaluation. </param>
        /// <param name="pExprCallback"> This parameter is always a null value. </param>
        /// <returns> VSConstants.S_OK. </returns>
        int IDebugExpression2.EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
        {
            // Creating a thread to evaluate the expression asynchronously.
            Thread m_processingThread;
            m_processingThread = new Thread(evaluatingAsync);
            m_processingThread.Start();

            return VSConstants.S_OK;
        }
 public int EvaluateAsync(enum_EVALFLAGS dwFlags, IDebugEventCallback2 pExprCallback)
 {
     return VSConstants.E_NOTIMPL;
 }
 public int EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback,
     out IDebugProperty2 ppResult)
 {
     ppResult = _monoProperty;
     return VSConstants.S_OK;
 }
Example #57
0
        public override async Task<Results> VarCreate(string expression, int threadId, uint frameLevel, enum_EVALFLAGS dwFlags, ResultClass resultClass = ResultClass.done)
        {
            string command = string.Format("-var-create - * \"{0}\" --evalFlags {1}", expression, (uint)dwFlags);
            Results results = await ThreadFrameCmdAsync(command, resultClass, threadId, frameLevel);

            return results;
        }
Example #58
0
 public void SyncEval(enum_EVALFLAGS dwFlags)
 {
     Parent.SyncEval(dwFlags);
 }
Example #59
0
 // This method evaluates the expression synchronously.
 int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
 {
     ppResult = this;
     return Constants.S_OK;
 }
Example #60
0
 /// <summary>
 /// This method evaluates the expression synchronously. (http://msdn.microsoft.com/en-ca/library/bb146982.aspx)
 /// </summary>
 /// <param name="dwFlags"> A combination of flags from the EVALFLAGS enumeration that control expression evaluation. </param>
 /// <param name="dwTimeout"> Maximum time, in milliseconds, to wait before returning from this method. Use INFINITE to wait 
 /// indefinitely. </param>
 /// <param name="pExprCallback"> This parameter is always a null value. </param>
 /// <param name="ppResult"> Returns the IDebugProperty2 object that contains the result of the expression evaluation. </param>
 /// <returns> VSConstants.S_OK. </returns>
 int IDebugExpression2.EvaluateSync(enum_EVALFLAGS dwFlags, uint dwTimeout, IDebugEventCallback2 pExprCallback, out IDebugProperty2 ppResult)
 {
     VariableInfo vi = VariableInfo.get(exp, m_eventDispatcher, m_frame);
     ppResult = new AD7Property(vi);
     m_frame._lastEvaluatedExpression = vi;
     return VSConstants.S_OK;
 }