Exemple #1
0
        public void Fill()
        {
            tvNodes.BeginUpdate();
            tvNodes.Nodes.Clear();
            ILDebugger debugger = ILDebugManager.Instance.Debugger;

            while (debugger != null && debugger.MethodDebugger != null)
            {
                debugger = debugger.MethodDebugger; // find top of the stack
            }
            if (debugger != null)
            {
                var debugNode = MemberNode.GetNodeOfMember(debugger.Method, true);

                TreeNode localsNode = new TreeNode("Locals");

                for (int i = 0; i < debugger.Locals.Length; i++)
                {
                    var itm = debugger.Locals[i].Value;

                    string prefix     = "[" + debugger.Locals[i].Info.LocalIndex + "] ";
                    string typeSuffix = " (" + (debugger.Locals[i].Info.LocalType == null ? "" : debugger.Locals[i].Info.LocalType.ToSignatureString()) + ")";
                    try
                    {
                        if (itm == null)
                        {
                            localsNode.Nodes.Add(prefix + "null" + typeSuffix);
                        }
                        else
                        {
                            localsNode.Nodes.Add(prefix + itm + typeSuffix);
                        }
                    }
                    catch (Exception)
                    {
                        localsNode.Nodes.Add(prefix + "" + typeSuffix);
                    }
                }

                debugNode.Nodes.Add(localsNode);

                TreeNode argumentsNode = new TreeNode("Arguments");

                for (int i = 0; i < debugger.Parameters.Length; i++)
                {
                    var itm = debugger.Parameters[i];

                    string typeSuffix = " (" + (itm.Info.ParameterType == null ? "" : itm.Info.ParameterType.ToSignatureString()) + ")";
                    try
                    {
                        if (itm.Value == null)
                        {
                            argumentsNode.Nodes.Add(itm.Info.Name + "= " + "null" + typeSuffix);
                        }
                        else
                        {
                            argumentsNode.Nodes.Add(itm.Info.Name + "= " + itm.Value + typeSuffix);
                        }
                    }
                    catch (Exception)
                    {
                        argumentsNode.Nodes.Add(typeSuffix);
                    }
                }

                debugNode.Nodes.Add(argumentsNode);

                tvNodes.Nodes.Add(debugNode);
            }

            tvNodes.EndUpdate();
            tvNodes.ExpandAll();
            tvNodes.Refresh();
        }
Exemple #2
0
        public override void Fill()
        {
            tvNodes.BeginUpdate();

            var cache = analysisManager.GetMemberCache(member);

            var usedByNode = new TreeNode("Used by", (int)IconEnum.Bullet, (int)IconEnum.Bullet);

            foreach (MemberLookupEntry m in cache.UsedBy)
            {
                var n = MemberNode.GetNodeOfMember(m.Member, true);
                if (n != null)
                {
                    n.Tag = m.Offset;
                    usedByNode.Nodes.Add(n);
                }
            }

            TreeNode calledByNode = null;
            TreeNode usesNode     = null;
            TreeNode wiredForNode = null;

            if (member is MethodInfo || member is ConstructorInfo)
            {
                var methodBaseCache = ((MethodBaseCache)cache);

                usesNode = new TreeNode("Uses", (int)IconEnum.Bullet, (int)IconEnum.Bullet);
                foreach (MemberInfo m in methodBaseCache.Uses.Select(u => u.Member))
                {
                    var n = MemberNode.GetNodeOfMember(m, true);
                    if (n != null)
                    {
                        usesNode.Nodes.Add(n);
                    }
                }

                calledByNode = new TreeNode("Called by", (int)IconEnum.Bullet, (int)IconEnum.Bullet);
                foreach (MemberInfo m in ((MethodBaseCache)cache).CalledBy)
                {
                    var n = MemberNode.GetNodeOfMember(m, true);
                    if (n != null)
                    {
                        calledByNode.Nodes.Add(n);
                    }
                }


                wiredForNode = new TreeNode("Wired to", (int)IconEnum.Bullet, (int)IconEnum.Bullet);
                foreach (WiredLookupEntry m in ((MethodBaseCache)cache).WiredForEvent)
                {
                    var n = GetEventWireNode(m);
                    if (n != null)
                    {
                        wiredForNode.Nodes.Add(n);
                    }
                }
            }

            TreeNode wiresNode = null;

            if (member is EventInfo)
            {
                wiresNode = new TreeNode("Wires", (int)IconEnum.Bullet, (int)IconEnum.Bullet);

                var addMethod = ((EventInfo)member).GetAddMethod();
                if (addMethod != null)
                {
                    var addMethodCache = (MethodBaseCache)AnalysisManager.Instance.GetMemberCache(addMethod);
                    foreach (var wire in addMethodCache.WiresEvent)
                    {
                        var n = GetEventWireNode(wire);
                        if (n != null)
                        {
                            wiresNode.Nodes.Add(n);
                        }
                    }
                }
            }

            TreeNode assignedByNode = null;
            TreeNode readByNode     = null;

            if (member is FieldInfo)
            {
                assignedByNode = new TreeNode("Assigned by", (int)IconEnum.Bullet, (int)IconEnum.Bullet);
                foreach (MemberInfo m in ((FieldCache)cache).AssignedBy)
                {
                    var n = MemberNode.GetNodeOfMember(m, true);
                    if (n != null)
                    {
                        assignedByNode.Nodes.Add(n);
                    }
                }

                readByNode = new TreeNode("Read by", (int)IconEnum.Bullet, (int)IconEnum.Bullet);
                foreach (MemberInfo m in ((FieldCache)cache).ReadBy)
                {
                    var n = MemberNode.GetNodeOfMember(m, true);
                    if (n != null)
                    {
                        readByNode.Nodes.Add(n);
                    }
                }
            }

            if (usesNode != null)
            {
                tvNodes.Nodes.Add(usesNode);
            }

            if (usedByNode != null)
            {
                tvNodes.Nodes.Add(usedByNode);
            }

            if (calledByNode != null)
            {
                tvNodes.Nodes.Add(calledByNode);
            }
            if (assignedByNode != null)
            {
                tvNodes.Nodes.Add(assignedByNode);
            }

            if (wiredForNode != null)
            {
                tvNodes.Nodes.Add(wiredForNode);
            }
            if (wiresNode != null)
            {
                tvNodes.Nodes.Add(wiresNode);
            }

            if (readByNode != null)
            {
                tvNodes.Nodes.Add(readByNode);
            }

            tvNodes.ExpandAll();
            tvNodes.EndUpdate();
        }