Exemplo n.º 1
0
        public void GenerateSnapshotText(Snapshot snapshot)
        {
            this.snapshot = snapshot;
            this.result   = new StringBuilder();

            if (snapshot.CallLevel > Snapshot.GLOBAL_CALL_LEVEL)
            {
                output.EmptyLine();
                output.Headline2("Local variables");
                createRepresentation(snapshot.Structure.Readonly.ReadonlyLocalContext.ReadonlyVariables);
            }
            output.EmptyLine();
            output.Headline2("Global variables");
            createRepresentation(snapshot.Structure.Readonly.ReadonlyGlobalContext.ReadonlyVariables);

            if (snapshot.CallLevel > Snapshot.GLOBAL_CALL_LEVEL)
            {
                output.EmptyLine();
                output.Headline2("Local controls");
                createRepresentation(snapshot.Structure.Readonly.ReadonlyLocalContext.ReadonlyControllVariables);
            }

            output.EmptyLine();
            output.Headline2("Global controls");
            createRepresentation(snapshot.Structure.Readonly.ReadonlyGlobalContext.ReadonlyControllVariables);

            output.EmptyLine();
            output.Headline2("Objects");
            createObjectsRepresentation();


            /*output.EmptyLine();
             * output.Headline2("===ARRAYS===");
             * createArraysRepresentation();
             *
             *
             * output.EmptyLine();
             * output.Headline2("===ALIASES===");
             * createAliasesRepresentation();*/
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generates the output of the analysis.
        /// </summary>
        /// <param name="output">The output.</param>
        public void GenerateOutput(OutputBase output)
        {
            output.EmptyLine();
            output.Headline("Analysis summary");

            if (Watch != null)
            {
                var ts = Watch.Elapsed;

                output.EmptyLine();
                output.Headline2("Time consumption");
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                output.CommentLine("Weverca analyzer time consumption: " + elapsedTime);

                if (IsFirstPhaseStarted)
                {
                    var ts1 = WatchFirstPhase.Elapsed;
                    elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", ts1.Hours, ts1.Minutes, ts1.Seconds, ts1.Milliseconds);
                    output.CommentLine("First phase time consumption: " + elapsedTime);
                }
                if (IsSecondPhaseStarted)
                {
                    var ts2 = WatchSecondPhase.Elapsed;
                    elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:000}", ts2.Hours, ts2.Minutes, ts2.Seconds, ts2.Milliseconds);
                    output.CommentLine("Second phase time consumption: " + elapsedTime);
                }
            }

            if (FirstPhaseInitialMemory != 0)
            {
                output.EmptyLine();
                output.Headline2("Memory consumption");
                output.CommentLine(string.Format("Initial memory before the first phase: {0}",
                                                 OutputUtils.GetMemoryText(FirstPhaseInitialMemory)
                                                 ));

                if (IsFirstPhaseStarted)
                {
                    output.CommentLine(string.Format("Memory at the end of the first phase: {0} (diff: {1})",
                                                     OutputUtils.GetMemoryText(FirstPhaseEndMemory),
                                                     OutputUtils.GetMemoryText(FirstPhaseEndMemory - FirstPhaseInitialMemory)
                                                     ));
                }
                if (IsSecondPhaseStarted)
                {
                    output.CommentLine(string.Format("Memory at the end of the second phase: {0} (diff: {1})",
                                                     OutputUtils.GetMemoryText(SecondPhaseEndMemory),
                                                     OutputUtils.GetMemoryText(SecondPhaseEndMemory - FirstPhaseEndMemory)
                                                     ));
                }
            }

            output.EmptyLine();
            output.Headline2("Code statistics");

            if (controlFlowGraph != null)
            {
                List <BasicBlock> basicBlocks = controlFlowGraph.CollectAllBasicBlocks();
                output.CommentLine("The number of basic blocks of code is: " + basicBlocks.Count);
            }

            if (programPointGraph != null)
            {
                var programLines          = new Dictionary <string, HashSet <int> >();
                int numberOfProgramPoints = NumProgramPoints(new HashSet <ProgramPointGraph>(), programLines, programPointGraph);
                int numberOfProgramLines  = NumProgramLines(programLines);

                output.CommentLine("The number of processed lines of code is: " + numberOfProgramLines);
                output.CommentLine("The number of program points in the application is: " + numberOfProgramPoints);

                if (programPointGraph.End.OutSet != null)
                {
                    output.CommentLine("The number of memory locations in final snapshot is: " + programPointGraph.End.OutSnapshot.NumMemoryLocations());
                }
                else
                {
                    output.CommentLine("End program point was not reached");
                }
            }
            else
            {
                output.CommentLine("Program point graph was not built");
            }

            output.EmptyLine();
            output.Headline2("Warnings");
            output.CommentLine("Total number of warnings: " + GetNumberOfWarnings());
            if (IsFirstPhaseStarted)
            {
                output.CommentLine("Number of warnings in the first phase: " + (analysisWarnings.Count + securityWarnings.Count));
            }
            if (IsSecondPhaseStarted)
            {
                output.CommentLine("Number of warnings in the second phase: " + secondPhaseWarnings.Count);
            }
        }