Пример #1
0
 public void ShowMethodBlocks(MethodEntry methodEntry)
 {
     Method = methodEntry;
     if (methodEntry != null)
     {
         BindMethodBlocks(methodEntry.Blocks);
     }
     else
     {
         ClearPane();
     }
 }
Пример #2
0
        /// <summary>
        /// Called when receiving a report about a method
        /// </summary>
        /// <param name="methodName"></param>
        /// <param name="methodSig"></param>
        /// <param name="bodySize"></param>
        /// <param name="flags"></param>
        /// <param name="implFlags"></param>
        /// <param name="symbolFileId"></param>
        /// <param name="methodDef"></param>
        public void EnterMethod(string methodName, string methodSig, int bodySize, uint flags, uint implFlags, int symbolFileId, int methodDef)
        {
            currentTypedef.Methods.Add(currentMethod = new MethodEntry
            {
                Type = currentTypedef,
                Name = methodName,
                Signature = methodSig,
                BodySize = bodySize,
                MethodDef = methodDef,
                Flags = (MethodAttributes)flags,
                ImplFlags = (MethodImplAttributes)implFlags
            });

            if (_symbolReader != null)
            {
                var token = new SymbolToken(methodDef);
                ISymbolMethod method;
                try
                {
                    method = _symbolReader.GetMethod(token);
                    var count = method.SequencePointCount;

                    int[] offsets = new int[count];
                    int[] sls = new int[count];
                    int[] scs = new int[count];
                    int[] els = new int[count];
                    int[] ecs = new int[count];
                    ISymbolDocument[] docs = new ISymbolDocument[count];

                    method.GetSequencePoints(offsets, docs, sls, scs, els, ecs);

                    for (int i = 0; i < count; i++)
                    {
                        MethodBlock block = new MethodBlock();
                        block.Offset = offsets[i];
                        var fileId = GetFileIdentifier(docs[i].URL);
                        if (fileId > 0 && sls[i] != 0xFEEFEE)
                        {
                            block.Start = new Position { Column = scs[i], Line = sls[i] };
                            block.End = new Position { Column = ecs[i], Line = els[i] };
                            block.File = fileId;
                        }
                        currentMethod.Blocks.Add(block);
                    }

                    docs = null;
                }
                catch (Exception ex)
                {

                }
                finally
                {
                    method = null;
                }
            }
        }
Пример #3
0
 public void Select(MethodEntry method)
 {
     SelectionHandlers.ForEach(x => x.Select(method));
 }
        private static void CopyCoverage(MethodEntry dst, MethodEntry src)
        {
            dst.BodySize = Math.Max(dst.BodySize, src.BodySize);

            foreach (var el in src.Blocks)
            {
                var srcBlock = el;
                var dstBlock = dst.Blocks.Find(x => x.Offset == srcBlock.Offset);
                if (dstBlock == null)
                {
                    dst.Blocks.Add(srcBlock.Copy());
                }
                else
                {
                    dstBlock.VisitCount = srcBlock.VisitCount;
                }
            }
        }
Пример #5
0
 public static int ForEventRemove(MethodEntry md)
 {
     return VSImage.Current.EventRemove;
 }
Пример #6
0
 public static int ForEventAdd(MethodEntry md)
 {
     return VSImage.Current.EventAdd;
 }
Пример #7
0
 public static int ForPropertySet(MethodEntry md)
 {
     return VSImage.Current.PropertySet;
 }
Пример #8
0
        public static int ForMethod(MethodEntry md)
        {
            var access = Methods.GetAccess(md.Flags);
            if (Methods.IsStatic(md.Flags))
            {
                access |= MethodAttributes.Static;
            }

            int index;
            if (methodImages.TryGetValue(access, out index))
                return index;

            return -1;
        }
Пример #9
0
        public static void Load(XmlElement node, Report report)
        {
            report.Date = ReadAttributeDate(node, "date");

            foreach (var dFile in SelectChildNodes(node, "file"))
            {
                report.Files.Add(new FileEntry
                {
                    Id = ReadAttributeInt(dFile, "id"),
                    PathUri = ReadAttribute(dFile, "url")
                });
            }

            foreach (var asmNode in SelectChildNodes(node, "assembly"))
            {
                report.Assemblies.Add(new AssemblyEntry
                {
                    AssemblyRef = ReadAttributeInt(asmNode, "id"),
                    Name = ReadAttribute(asmNode, "name"),
                    Module = ReadAttribute(asmNode, "module"),
                    Domain = ReadAttribute(asmNode, "domain"),
                    DomainIndex = ReadAttributeInt(asmNode, "domainIdx")
                });
            }

            foreach (var typeNode in SelectChildNodes(node, "type"))
            {
                var assmRef = ReadAttributeInt(typeNode, "asmref");
                var assemblyEntry = report.Assemblies.Find(x => x.AssemblyRef == assmRef);
                if (assemblyEntry == null)
                {
                    continue;
                }

                var typedefEntry = new TypedefEntry
                {
                    Name = ReadAttribute(typeNode, "name"),
                    Attributes = (TypeAttributes)ReadAttributeLong(typeNode, "flags"),
                    Assembly = assemblyEntry
                };
                assemblyEntry.Types.Add(typedefEntry);

                foreach (var methodNode in SelectChildNodes(typeNode, "method"))
                {
                    var methodEntry = new MethodEntry
                    {
                        Name = ReadAttribute(methodNode, "name"),
                        Signature = ReadAttribute(methodNode, "sig"),
                        BodySize = ReadAttributeInt(methodNode, "bodysize"),
                        Flags = (MethodAttributes)ReadAttributeLong(methodNode, "flags"),
                        ImplFlags = (MethodImplAttributes)ReadAttributeLong(methodNode, "iflags")
                    };
                    typedefEntry.Methods.Add(methodEntry);


                    foreach (var pointNode in SelectChildNodes(methodNode, "pt"))
                    {
                        methodEntry.Blocks.Add(new MethodBlock
                        {
                            VisitCount = ReadAttributeInt(pointNode, "visit"),
                            Offset = ReadAttributeInt(pointNode, "pos"),
                            Length = ReadAttributeInt(pointNode, "len"),
                            File = ReadAttributeInt(pointNode, "fid"),
                            Start = new Position
                            {
                                Column = ReadAttributeInt(pointNode, "sc"),
                                Line = ReadAttributeInt(pointNode, "sl")
                            },
                            End = new Position
                            {
                                Column = ReadAttributeInt(pointNode, "ec"),
                                Line = ReadAttributeInt(pointNode, "el")
                            }
                        });
                    }
                }
            }
        }
Пример #10
0
 private static void AddMethodTreeNode(TreeNode classNode, MethodEntry md)
 {
     classNode.Nodes.Add(new MethodTreeNode(md));
 }
Пример #11
0
 public void Select(MethodEntry method)
 {
     rtbNodeProps.Rtf = string.Format(METHOD_INFO, method.Name, method.Signature, method.Flags, method.ImplFlags, method.BodySize);
 }
Пример #12
0
 public void Select(MethodEntry method)
 {
     ShowMethodBlocks(method);
 }