예제 #1
0
 void ILocalsOwner.Refresh(NormalValueVM vm)
 {
     if (dispatcher.HasShutdownFinished || dispatcher.HasShutdownStarted)
     {
         return;
     }
     if (callingReread)
     {
         return;
     }
     callingReread = true;
     dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => {
         callingReread = false;
         InitializeLocals(LocalInitType.Full);
     }));
 }
예제 #2
0
        bool CanReuseChildren(ICorValueHolder ex, int numArgs, int numLocals, int numGenArgs)
        {
            var children = rootNode.Children;

            int index = 0;

            if (index < children.Count && NormalValueVM.IsType <ExceptionValueType>(children[index]))
            {
                index++;
            }

            if (index + numArgs + numLocals > children.Count)
            {
                return(false);
            }
            for (int i = 0; i < numArgs; i++, index++)
            {
                if (!NormalValueVM.IsType <ArgumentValueType>(children[index]))
                {
                    return(false);
                }
            }
            for (int i = 0; i < numLocals; i++, index++)
            {
                if (!NormalValueVM.IsType <LocalValueType>(children[index]))
                {
                    return(false);
                }
            }

            if (numGenArgs != 0)
            {
                if (index >= children.Count)
                {
                    return(false);
                }
                if (!(children[index++] is TypeVariablesValueVM))
                {
                    return(false);
                }
            }

            return(index == children.Count);
        }
예제 #3
0
        void InitializeLocals(LocalInitType initType)
        {
            if (!IsEnabled || DebugManager.Instance.ProcessState != DebuggerProcessState.Stopped)
            {
                ClearAllLocals();
                return;
            }

            if (initType == LocalInitType.Simple)
            {
                // Property eval has completed, don't do a thing
                return;
            }

            var       thread  = StackFrameManager.Instance.SelectedThread;
            var       frame   = StackFrameManager.Instance.SelectedFrame;
            int       frameNo = StackFrameManager.Instance.SelectedFrameNumber;
            DnProcess process;

            if (thread == null)
            {
                process = DebugManager.Instance.Debugger.Processes.FirstOrDefault();
                thread  = process == null ? null : process.Threads.FirstOrDefault();
            }
            else
            {
                process = thread.Process;
            }

            var newFrameInfo = new FrameInfo(this, thread, process, frame, frameNo);

            if (frameInfo == null || !frameInfo.Equals(newFrameInfo))
            {
                ClearAndDisposeChildren();
            }
            frameInfo = newFrameInfo;

            CorValue[] corArgs, corLocals;
            if (frame != null)
            {
                corArgs   = frame.ILArguments.ToArray();
                corLocals = frame.ILLocals.ToArray();
            }
            else
            {
                corArgs = corLocals = new CorValue[0];
            }
            var args   = new List <ICorValueHolder>(corArgs.Length);
            var locals = new List <ICorValueHolder>(corLocals.Length);

            for (int i = 0; i < corArgs.Length; i++)
            {
                args.Add(new LocArgCorValueHolder(true, this, corArgs[i], i));
            }
            for (int i = 0; i < corLocals.Length; i++)
            {
                locals.Add(new LocArgCorValueHolder(false, this, corLocals[i], i));
            }

            var exValue       = thread == null ? null : thread.CorThread.CurrentException;
            var exValueHolder = exValue == null ? null : new DummyCorValueHolder(exValue);

            int numGenArgs = frameInfo.ValueContext.GenericTypeArguments.Count + frameInfo.ValueContext.GenericMethodArguments.Count;

            if (!CanReuseChildren(exValueHolder, args.Count, locals.Count, numGenArgs))
            {
                ClearAndDisposeChildren();
            }

            if (rootNode.Children.Count == 0)
            {
                hasInitializedArgNames              = false;
                hasInitializedLocalNames            = false;
                hasInitializedArgNamesFromMetadata  = false;
                hasInitializedLocalNamesFromPdbFile = false;
            }

            List <TypeSig> argTypes;
            List <TypeSig> localTypes;

            if (frame != null)
            {
                frame.GetArgAndLocalTypes(out argTypes, out localTypes);
            }
            else
            {
                argTypes = localTypes = new List <TypeSig>();
            }

            if (rootNode.Children.Count == 0)
            {
                if (exValueHolder != null)
                {
                    rootNode.Children.Add(new CorValueVM(frameInfo.ValueContext, exValueHolder, null, new ExceptionValueType()));
                }
                for (int i = 0; i < args.Count; i++)
                {
                    rootNode.Children.Add(new CorValueVM(frameInfo.ValueContext, args[i], Read(argTypes, i), new ArgumentValueType(i)));
                }
                for (int i = 0; i < locals.Count; i++)
                {
                    rootNode.Children.Add(new CorValueVM(frameInfo.ValueContext, locals[i], Read(localTypes, i), new LocalValueType(i)));
                }
                if (numGenArgs != 0)
                {
                    rootNode.Children.Add(new TypeVariablesValueVM(frameInfo.ValueContext));
                }
            }
            else
            {
                int index = 0;

                if (exValueHolder != null)
                {
                    if (index < rootNode.Children.Count && NormalValueVM.IsType <ExceptionValueType>(rootNode.Children[index]))
                    {
                        ((CorValueVM)rootNode.Children[index++]).Reinitialize(frameInfo.ValueContext, exValueHolder, null);
                    }
                    else
                    {
                        rootNode.Children.Insert(index++, new CorValueVM(frameInfo.ValueContext, exValueHolder, null, new ExceptionValueType()));
                    }
                }
                else
                {
                    if (index < rootNode.Children.Count && NormalValueVM.IsType <ExceptionValueType>(rootNode.Children[index]))
                    {
                        ValueVM.DisposeAndRemoveAt(rootNode, index);
                    }
                }

                for (int i = 0; i < args.Count; i++, index++)
                {
                    ((CorValueVM)rootNode.Children[index]).Reinitialize(frameInfo.ValueContext, args[i], Read(argTypes, i));
                }
                for (int i = 0; i < locals.Count; i++, index++)
                {
                    ((CorValueVM)rootNode.Children[index]).Reinitialize(frameInfo.ValueContext, locals[i], Read(localTypes, i));
                }
                if (numGenArgs != 0)
                {
                    ((TypeVariablesValueVM)rootNode.Children[index++]).Reinitialize(frameInfo.ValueContext);
                }
            }

            InitializeLocalAndArgNames();
            if (!hasInitializedArgNames && !hasInitializedArgNamesFromMetadata)
            {
                InitializeArgNamesFromMetadata();
            }
            if (!hasInitializedLocalNames && !hasInitializedLocalNamesFromPdbFile)
            {
                InitializeLocalNamesFromPdbFile();
            }
        }