Пример #1
0
        bool matchStrings(string containsString, string ignoreString, allocXML alloc)
        {
            if (containsString == "" && ignoreString == "")
            {
                return(true);
            }

            for (int stackIndex = 0; stackIndex < alloc.stack.Count; stackIndex++)
            {
                bool test = false;
                if (containsString != "")
                {
                    if (alloc.stack[stackIndex].function.Contains(containsString) ||
                        alloc.stack[stackIndex].file.Contains(containsString))
                    {
                        test = true;
                    }
                }

                if (ignoreString != "")
                {
                    if (alloc.stack[stackIndex].function.Contains(ignoreString) ||
                        alloc.stack[stackIndex].file.Contains(ignoreString))
                    {
                        test = false;
                    }
                }

                if (test)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        void addAllocToListBox(allocXML alloc)
        {
            listBox1.Items.Add("=============================================");
            listBox1.Items.Add("Allocation Size : " + MemoryNumber.convert(Int32.Parse(alloc.size)) + " address : 0x" + uint.Parse(alloc.address).ToString("x"));

            string tab = "";

            for (int stackIndex = 0; stackIndex < alloc.stack.Count; stackIndex++)
            {
                listBox1.Items.Add(tab + alloc.stack[stackIndex].function + "(" + alloc.stack[stackIndex].file + ", line: " + alloc.stack[stackIndex].line + ")");
                tab += " ";
            }
        }
Пример #3
0
        void doSearch(string stringMatch, string stringIgnore,
                      int minMem, int maxMem,
                      bool doSort, bool printSummary)
        {
            listBox1.Items.Clear();
            List <Point> passedAllocs = new List <Point>();


            for (int allocIndex = 0; allocIndex < fsXML.allocations.Count; allocIndex++)
            {
                allocXML alloc = fsXML.allocations[allocIndex];
                bool     test  = false;
                test = matchStrings(stringMatch, stringIgnore, alloc);

                test &= matchMemory(minMem, maxMem, alloc);

                if (test)
                {
                    Point p = new Point(allocIndex, int.Parse(alloc.size));
                    passedAllocs.Add(p);
                }
            }


            if (doSort)
            {
                passedAllocs.Sort(ComparePassedAllocSizes);
            }

            int totalMem = 0;

            for (int i = 0; i < passedAllocs.Count; i++)
            {
                allocXML alloc = fsXML.allocations[passedAllocs[i].X];
                totalMem += int.Parse(alloc.size);
                addAllocToListBox(alloc);
            }

            if (printSummary)
            {
                printSummaryToListBox(passedAllocs.Count, totalMem);
            }
        }
Пример #4
0
        //==================================================
        void populateTreeView(memStatsXML fsXML)
        {
            allocTreeNode tnRootNode = new allocTreeNode();

            tnRootNode.function  = "ALL";
            tnRootNode.file      = "";
            tnRootNode.line      = "";
            tnRootNode.allocSize = 0;


            for (int allocIndex = 0; allocIndex < fsXML.allocations.Count; allocIndex++)
            {
                allocXML alloc     = fsXML.allocations[allocIndex];
                int      allocSize = int.Parse(alloc.size);

                int stackIndex = 0;

                allocTreeNode lastNode = tnRootNode;
                bool          added    = false;
                while (stackIndex < alloc.stack.Count)
                {
                    bool found = false;
                    for (int i = 0; i < lastNode.Nodes.Count; i++)
                    {
                        allocTreeNode node = lastNode.Nodes[i] as allocTreeNode;
                        if (node == null)
                        {
                            continue;
                        }

                        if (node.function == alloc.stack[stackIndex].function)
                        {
                            lastNode = node;
                            stackIndex++;
                            found = true;
                            break;
                        }
                    }

                    //we didn't find ourselves at this node, add us.
                    if (!found)
                    {
                        added = true;
                        allocTreeNode atn = new allocTreeNode();
                        atn.function  = alloc.stack[stackIndex].function;
                        atn.file      = alloc.stack[stackIndex].file;
                        atn.line      = alloc.stack[stackIndex].line;
                        atn.allocSize = allocSize;
                        atn.samples   = new List <allocTreeSampleData>();
                        foreach (sizeSampleXML sample in alloc.sizeSamples)
                        {
                            allocTreeSampleData sampleData = new allocTreeSampleData();
                            sampleData.size        = Int32.Parse(sample.size);
                            sampleData.sampleIndex = Int32.Parse(sample.sample);
                            atn.samples.Add(sampleData);
                        }
                        atn.samples.Sort(SortBySamples);

                        lastNode.Nodes.Add(atn);
                        stackIndex++;
                        lastNode = (allocTreeNode)lastNode.Nodes[lastNode.Nodes.Count - 1];
                    }
                }


                //if we never added, then this is a duplicate path, so add our memory to the leaf node
                if (!added)
                {
                    lastNode.allocSize += allocSize;
                }
            }

            updateTreeNodes(tnRootNode);
            removeFilteredNodes(tnRootNode);
            sortTreeNodes(tnRootNode);
            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(tnRootNode);
        }
Пример #5
0
        bool matchMemory(int minMem, int maxMem, allocXML alloc)
        {
            int allocSize = int.Parse(alloc.size);

            return(allocSize >= minMem && allocSize <= maxMem);
        }