Пример #1
0
        internal void BuildAllocationTrace(Graph graph, int stackTraceIndex, int typeIndex, ulong size, 
            Vertex[] typeVertex, Vertex[] funcVertex, ref Vertex[] vertexStack)
        {
            int stackPtr = BuildVertexStack(stackTraceIndex, funcVertex, ref vertexStack, 2);

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;
            if ((typeVertex[typeIndex].interestLevel & InterestLevel.Interesting) == InterestLevel.Interesting
                && ReadNewLog.InterestingCallStack(vertexStack, stackPtr))
            {
                vertexStack[stackPtr] = typeVertex[typeIndex];
                stackPtr++;
                stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
                stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
                for (int i = 0; i < stackPtr; i++)
                {
                    fromVertex = toVertex;
                    toVertex = vertexStack[i];
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight(size);
                }
                fromVertex = toVertex;
                toVertex = graph.BottomVertex;
                edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                edge.AddWeight(size);
            }
        }
Пример #2
0
        internal Vertex(string name, string signature, string module, Graph containingGraph)
        {
            this.signature = signature;
            this.incomingEdges = new Dictionary<Vertex, Edge>();
            this.outgoingEdges = new Dictionary<Vertex, Edge>();
            this.level = Int32.MaxValue;
            this.weight = 0;
            this.containingGraph = containingGraph;
            this.moduleName = module;

            nameSpace = nameSpaceOf(name, out basicName);
            this.name = name;
            basicSignature = signature;
            if (nameSpace.Length > 0 && signature != null)
            {
                int index;
                while ((index = basicSignature.IndexOf(nameSpace)) >= 0)
                {
                    basicSignature = basicSignature.Remove(index, nameSpace.Length);
                }
            }
        }
Пример #3
0
        internal Graph BuildHandleAllocationGraph()
        {
            Vertex[] funcVertex = new Vertex[1];
            Vertex[] vertexStack = new Vertex[1];

            Graph graph = new Graph(this);
            graph.graphType = Graph.GraphType.HandleAllocationGraph;

            BuildFuncVertices(graph, ref funcVertex);

            for (int i = 0; i < typeSizeStacktraceToCount.Length; i++)
            {
                if (typeSizeStacktraceToCount[i] > 0)
                {
                    int[] stacktrace = readNewLog.stacktraceTable.IndexToStacktrace(i);

                    uint count = (uint)typeSizeStacktraceToCount[i];

                    BuildHandleAllocationTrace(graph, i, count, funcVertex, ref vertexStack);
                }
            }

            foreach (Vertex v in graph.vertices.Values)
                v.active = true;
            graph.BottomVertex.active = false;

            return graph;
        }
Пример #4
0
 internal void BuildTypeVertices(Graph graph, ref Vertex[] typeVertex)
 {
     for (int i = 0; i < readNewLog.typeName.Length; i++)
     {
         string typeName = readNewLog.typeName[i];
         if (typeName == null)
             typeName = string.Format("???? type {0}", i);
         readNewLog.AddTypeVertex(i, typeName, graph, ref typeVertex);
     }
 }
Пример #5
0
        internal Graph BuildAllocationGraph()
        {
            Vertex[] typeVertex = new Vertex[1];
            Vertex[] funcVertex = new Vertex[1];
            Vertex[] vertexStack = new Vertex[1];

            Graph graph = new Graph(this);
            graph.graphType = Graph.GraphType.AllocationGraph;

            BuildTypeVertices(graph, ref typeVertex);
            BuildFuncVertices(graph, ref funcVertex);

            for (int i = 0; i < typeSizeStacktraceToCount.Length; i++)
            {
                if (typeSizeStacktraceToCount[i] > 0)
                {
                    int[] stacktrace = readNewLog.stacktraceTable.IndexToStacktrace(i);

                    int typeIndex = stacktrace[0];
                    ulong size = (ulong)stacktrace[1] * (ulong)typeSizeStacktraceToCount[i];

                    BuildAllocationTrace(graph, i, typeIndex, size, typeVertex, funcVertex, ref vertexStack);
                }
            }

            foreach (Vertex v in graph.vertices.Values)
                v.active = true;
            graph.BottomVertex.active = false;

            return graph;
        }
Пример #6
0
        internal Graph BuildAssemblyGraph()
        {
            Vertex[] assemblyVertex = new Vertex[1];
            Vertex[] funcVertex = new Vertex[1];
            Vertex[] typeVertex = new Vertex[1];
            Vertex[] vertexStack = new Vertex[1];

            Graph graph = new Graph(this);
            graph.graphType = Graph.GraphType.AssemblyGraph;

            int count = BuildAssemblyVertices(graph, ref assemblyVertex);
            BuildTypeVertices(graph, ref typeVertex);
            BuildFuncVertices(graph, ref funcVertex);

            for (int i = 0; i < count; i++)
            {
                Vertex v = (Vertex)assemblyVertex[i], tv = null;

                string c = v.name;
                int stackid = readNewLog.assemblies[c];
                if (stackid < 0)
                {
                    int[] stacktrace = readNewLog.stacktraceTable.IndexToStacktrace(-stackid);
                    tv = typeVertex[stacktrace[0]];
                }
                BuildAssemblyTrace(graph, stackid, v, tv, funcVertex, ref vertexStack);
            }

            foreach (Vertex v in graph.vertices.Values)
            {
                v.active = true;
            }
            graph.BottomVertex.active = false;
            return graph;
        }
Пример #7
0
 internal int BuildAssemblyVertices(Graph graph, ref Vertex[] typeVertex)
 {
     int count = 0;
     foreach (string c in readNewLog.assemblies.Keys)
     {
         readNewLog.AddTypeVertex(count++, c, graph, ref typeVertex);
     }
     return count;
 }
Пример #8
0
 internal void BuildFuncVertices(Graph graph, ref Vertex[] funcVertex)
 {
     for (int i = 0; i < readNewLog.funcName.Length; i++)
     {
         string name = readNewLog.funcName[i];
         string signature = readNewLog.funcSignature[i];
         if (name == null)
             name = string.Format("???? function {0}", i);
         if (signature == null)
             signature = "( ???????? )";
         readNewLog.AddFunctionVertex(i, name, signature, graph, ref funcVertex);
     }
 }
Пример #9
0
 internal void GetAllocationGraph(ReadLogResult readLogResult)
 {
     graph = readLogResult.allocatedHistogram.BuildAllocationGraph();
     PlaceVertices();
 }
Пример #10
0
        internal void BuildCallTrace(Graph graph, int stackTraceIndex, Vertex[] funcVertex, 
            ref Vertex[] vertexStack, int count)
        {
            int stackPtr = BuildVertexStack(stackTraceIndex, funcVertex, ref vertexStack, 0);

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;
            if (ReadNewLog.InterestingCallStack(vertexStack, stackPtr))
            {
                stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
                stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
                for (int i = 0; i < stackPtr; i++)
                {
                    fromVertex = toVertex;
                    toVertex = vertexStack[i];
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight((uint)count);
                }
            }
        }
Пример #11
0
        internal Graph BuildClassGraph()
        {
            Vertex[] funcVertex = new Vertex[1];
            Vertex[] vertexStack = new Vertex[1];

            Graph graph = new Graph(this);
            graph.graphType = Graph.GraphType.ClassGraph;

            BuildFuncVertices(graph, ref funcVertex);

            foreach (FunctionDescriptor fd in functionList)
            {
                BuildClassTrace(graph, fd.funcCallStack, fd.functionId, fd.funcSize, funcVertex, ref vertexStack);
            }

            foreach (Vertex v in graph.vertices.Values)
                v.active = true;
            graph.BottomVertex.active = false;

            return graph;
        }
Пример #12
0
        internal void BuildAssemblyTrace(Graph graph, int stackTraceIndex, Vertex assembly, Vertex typeVertex, Vertex[] funcVertex, ref Vertex[] vertexStack)
        {
            int stackPtr = BuildVertexStack(Math.Abs(stackTraceIndex), funcVertex, ref vertexStack, stackTraceIndex < 0 ? 2 : 0);

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;

            if (typeVertex != null)
            {
                vertexStack[stackPtr++] = typeVertex;
            }
            vertexStack[stackPtr++] = assembly;

            stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
            stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
            for (int i = 0; i < stackPtr; i++)
            {
                fromVertex = toVertex;
                toVertex = vertexStack[i];
                edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                edge.AddWeight(1);
            }
            fromVertex = toVertex;
            toVertex = graph.BottomVertex;
            edge = graph.FindOrCreateEdge(fromVertex, toVertex);
            edge.AddWeight(1);
        }
Пример #13
0
        void BuildClassTrace(Graph graph, int stackTraceIndex, int funcIndex, 
            ulong size, Vertex[] funcVertex, ref Vertex[] vertexStack)
        {
            string className = ClassNameOfFunc(funcIndex);
            int functionsToSkip = FunctionsInSameClass(className, stackTraceIndex);
            int stackPtr = BuildVertexStack(stackTraceIndex, funcVertex, ref vertexStack, 0) - functionsToSkip;

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;
            if (ReadNewLog.InterestingCallStack(vertexStack, stackPtr))
            {
                vertexStack[stackPtr] = graph.FindOrCreateVertex(className, null, null);
                

                stackPtr++;
                stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
                stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
                for (int i = 0; i < stackPtr; i++)
                {
                    fromVertex = toVertex;
                    toVertex = vertexStack[i];
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight(size);
                }
                if (toVertex != graph.TopVertex)
                {
                    fromVertex = toVertex;
                    toVertex = graph.BottomVertex;
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight(size);
                }
            }
        }
Пример #14
0
        void BuildModuleTrace(Graph graph, int stackTraceIndex, int modIndex, ulong size, 
            Vertex[] funcVertex, Vertex[] modVertex, ref Vertex[] vertexStack)
        {
            int functionsToSkip = FunctionsInSameModule(modIndex, stackTraceIndex);
            int stackPtr = BuildVertexStack(stackTraceIndex, funcVertex, ref vertexStack, 0) - functionsToSkip;

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;
            if (ReadNewLog.InterestingCallStack(vertexStack, stackPtr))
            {
                vertexStack[stackPtr] = modVertex[modIndex];
                stackPtr++;
                stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
                stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
                for (int i = 0; i < stackPtr; i++)
                {
                    fromVertex = toVertex;
                    toVertex = vertexStack[i];
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight(size);
                }
                fromVertex = toVertex;
                toVertex = graph.BottomVertex;
                edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                edge.AddWeight(size);
            }
        }
Пример #15
0
 void BuildModVertices(Graph graph, ref Vertex[] modVertex)
 {
     for (int i = 0; i < readNewLog.modBasicName.Length; i++)
     {
         string basicName = readNewLog.modBasicName[i];
         string fullName = readNewLog.modFullName[i];
         if (basicName != null && fullName != null)
         {
             readNewLog.AddFunctionVertex(i, basicName, fullName, graph, ref modVertex);
             modVertex[i].basicName = basicName;
             modVertex[i].basicSignature = fullName;
         }
     }
 }
Пример #16
0
        internal void BuildHandleAllocationTrace(Graph graph, int stackTraceIndex, uint count, 
            Vertex[] funcVertex, ref Vertex[] vertexStack)
        {
            int stackPtr = BuildVertexStack(stackTraceIndex, funcVertex, ref vertexStack, 0);

            Vertex handleVertex = graph.FindOrCreateVertex("Handle", null, null);
            handleVertex.interestLevel = InterestLevel.Interesting;

            Vertex toVertex = graph.TopVertex;
            Vertex fromVertex;
            Edge edge;
            if (ReadNewLog.InterestingCallStack(vertexStack, stackPtr))
            {
                vertexStack[stackPtr] = handleVertex;
                stackPtr++;
                stackPtr = ReadNewLog.FilterVertices(vertexStack, stackPtr);
                stackPtr = Vertex.SqueezeOutRepetitions(vertexStack, stackPtr);
                for (int i = 0; i < stackPtr; i++)
                {
                    fromVertex = toVertex;
                    toVertex = vertexStack[i];
                    edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                    edge.AddWeight(count);
                }
                fromVertex = toVertex;
                toVertex = graph.BottomVertex;
                edge = graph.FindOrCreateEdge(fromVertex, toVertex);
                edge.AddWeight(count);
            }
        }
Пример #17
0
 void BuildFuncVertices(Graph graph, ref Vertex[] funcVertex)
 {
     for (int i = 0; i < readNewLog.funcName.Length; i++)
     {
         string name = readNewLog.funcName[i];
         string signature = readNewLog.funcSignature[i];
         if (name != null && signature != null)
             readNewLog.AddFunctionVertex(i, name, signature, graph, ref funcVertex);
     }
 }
Пример #18
0
 private void readLogFile(ReadNewLog log, ReadLogResult logResult, string exeName, Graph.GraphType graphType)
 {
     log.ReadFile(logFileStartOffset, logFileEndOffset, logResult);
     //ViewGraph(logResult, exeName, graphType);
 }
Пример #19
0
 internal void AddTypeVertex(int typeId, string typeName, Graph graph, ref Vertex[] typeVertex)
 {
     EnsureVertexCapacity(typeId, ref typeVertex);
     typeVertex[typeId] = graph.FindOrCreateVertex(typeName, null, null);
     
 }
Пример #20
0
 private ArrayList BuildLevels(Graph g)
 {
     ArrayList al = new ArrayList();
     for (int level = 0; level <= g.BottomVertex.level; level++)
     {
         al.Add(new ArrayList());
     }
     foreach (Vertex v in g.vertices.Values)
     {
         if (v.level <= g.BottomVertex.level)
         {
             ArrayList all = (ArrayList)al[v.level];
             all.Add(v);
         }
         else
         {
             //Debug.Assert(v.level == int.MaxValue);
         }
     }
     foreach (ArrayList all in al)
     {
         all.Sort();
     }
     return al;
 }
Пример #21
0
 internal void AddFunctionVertex(int funcId, string functionName, string signature, Graph graph, 
     ref Vertex[] funcVertex)
 {
     EnsureVertexCapacity(funcId, ref funcVertex);
     int moduleId = funcModule[funcId];
     string moduleName = null;
     if (moduleId >= 0)
         moduleName = modBasicName[moduleId];
     funcVertex[funcId] = graph.FindOrCreateVertex(functionName, signature, moduleName);
     
 }