Ejemplo n.º 1
0
        private int SetState(enum_BP_STATE state)
        {
            if (_state == enum_BP_STATE.BPS_ENABLED)
            {
                if (state == enum_BP_STATE.BPS_DISABLED || state == enum_BP_STATE.BPS_DELETED)
                {
                    if (DebugBreakpoint != null)
                    {
                        DebugBreakpoint.BreakpointHit -= DebugBreakpoint_BreakpointHit;
                        if (Engine.IsConnected)
                        {
                            if (Engine.IsProgramDestroyed)
                            {
                                // If engine is shutting down, do not wait for the delete eval to complete, to avoid
                                // blocking debugger detach if a long-running operation is in progress. This way the
                                // engine can just report successful detach right away, and breakpoints are deleted
                                // later, but as soon as it's actually possible.
                                DebugBreakpoint.DeleteAsync().DoNotWait();
                            }
                            else
                            {
                                TaskExtensions.RunSynchronouslyOnUIThread(ct => DebugBreakpoint.DeleteAsync(ct));
                            }
                        }
                    }
                }
            }
            else
            {
                if (state == enum_BP_STATE.BPS_ENABLED)
                {
                    if (Engine.IsProgramDestroyed)
                    {
                        // Do not allow enabling breakpoints when engine is shutting down.
                        return(VSConstants.E_ABORT);
                    }

                    DebugBreakpoint = TaskExtensions.RunSynchronouslyOnUIThread(ct => Engine.Tracer.CreateBreakpointAsync(Location, ct));
                    DebugBreakpoint.BreakpointHit += DebugBreakpoint_BreakpointHit;
                }
            }

            _state = state;
            return(VSConstants.S_OK);
        }
Ejemplo n.º 2
0
        private IReadOnlyList <IREvaluationResultInfo> CreateChildren() =>
        TaskExtensions.RunSynchronouslyOnUIThread(async ct => {
            var valueResult = EvaluationResult as IRValueInfo;
            if (valueResult == null)
            {
                return(new IREvaluationResultInfo[0]);
            }

            var children = await valueResult.DescribeChildrenAsync(PrefetchedProperties, Repr, ChildrenMaxCount, ct);

            // Children of environments do not have any meaningful order, so sort them by name.
            if (valueResult.TypeName == "environment")
            {
                children = children.OrderBy(er => er.Name).ToArray();
            }

            return(children);
        });
Ejemplo n.º 3
0
        int IDebugProperty2.EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum)
        {
            IEnumerable <IREvaluationResultInfo> children = _children.Value;

            if (!RToolsSettings.Current.ShowDotPrefixedVariables)
            {
                children = children.Where(v => v.Name != null && !v.Name.StartsWithOrdinal("."));
            }

            var infos = children.Select(v => new AD7Property(this, v).GetDebugPropertyInfo(dwRadix, dwFields));

            var valueResult = EvaluationResult as IRValueInfo;

            if (valueResult != null)
            {
                if (valueResult.HasAttributes() == true)
                {
                    string attrExpr   = Invariant($"base::attributes({valueResult.Expression})");
                    var    attrResult = TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.StackFrame.TryEvaluateAndDescribeAsync(attrExpr, "attributes()", PrefetchedProperties, Repr, ct));
                    if (!(attrResult is IRErrorInfo))
                    {
                        var attrInfo = new AD7Property(this, attrResult, isSynthetic: true).GetDebugPropertyInfo(dwRadix, dwFields);
                        infos = new[] { attrInfo }.Concat(infos);
                    }
                }

                if (valueResult.Flags.HasFlag(RValueFlags.HasParentEnvironment))
                {
                    string parentExpr   = Invariant($"base::parent.env({valueResult.Expression})");
                    var    parentResult = TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.StackFrame.TryEvaluateAndDescribeAsync(parentExpr, "parent.env()", PrefetchedProperties, Repr, ct));
                    if (!(parentResult is IRErrorInfo))
                    {
                        var parentInfo = new AD7Property(this, parentResult, isSynthetic: true).GetDebugPropertyInfo(dwRadix, dwFields);
                        infos = new[] { parentInfo }.Concat(infos);
                    }
                }
            }

            ppEnum = new AD7PropertyInfoEnum(infos.ToArray());
            return(VSConstants.S_OK);
        }
Ejemplo n.º 4
0
        private string GetReprToString()
        {
            var code = Invariant($"rtvs:::repr_toString(eval(quote({EvaluationResult.Expression}), envir = {EvaluationResult.EnvironmentExpression}))");

            return(TaskExtensions.RunSynchronouslyOnUIThread(ct => StackFrame.Engine.Tracer.Session.EvaluateAsync <string>(code, REvaluationKind.Normal, ct)));
        }