コード例 #1
0
        public void AnalyzeSimpleSolution2(AnalysisStrategy strategy)
        {
            var callgraph = GenerateCallGraph(50);
            var syntax = GenerateCode(callgraph);
            var code = syntax.ToFullString();
            Logger.Instance.Log("CallGraphGenerator", "AnalyzeSimpleSolution2", code);
            var solution = ReachingTypeAnalysis.Utils.CreateSolution(code);
            Logger.Instance.Log("CallGraphGenerator", "AnalyzeSimpleSolution2", solution.FilePath);
            var solAnalyzer = new SolutionAnalyzer(solution);
            solAnalyzer.Analyze(strategy);
            var resolved = solAnalyzer.GenerateCallGraph();
            var resolvedNodes = resolved.GetNodes().Count();
            var callgraphNodes = callgraph.GetNodes().Count();
            Assert.IsTrue(resolvedNodes == callgraphNodes);
            var resolveEdgeCount = resolved.GetEdges().Count();
            var callgraphEdgeCount = callgraph.GetEdges().Count();

            foreach (var node in resolved.GetNodes())
            {
                //var callees = callgraph.GetCallees(node.Name);
                var callees = callgraph.GetCallees(node.MethodName);
                var resolvedCallees = resolved.GetCallees(node);
                Assert.IsTrue(callees.Count() == resolvedCallees.Count(), "Mismatched callee counts for " + node);
            }

            Assert.IsTrue(resolved.GetEdges().Count() == callgraph.GetEdges().Count());
        }
コード例 #2
0
 //public static CallGraph<IMethodSymbol,Location> BuildCallGraph(Solution solution)
 public static CallGraph<MethodDescriptor, LocationDescriptor> BuildCallGraph(Solution solution)
 {
     var analyzer = new SolutionAnalyzer(solution);
     analyzer.Analyze();
     //analyzer.GenerateCallGraph();
     var callgraph = analyzer.GenerateCallGraph();
     Console.WriteLine("Reachable methods={0}", callgraph.GetReachableMethods().Count);
     return callgraph;
 }
コード例 #3
0
        private static bool CompareDispatchers(Solution solution)
        {
            var analyzerLocal = new SolutionAnalyzer(solution);
            var timerLocal = new Stopwatch();
            timerLocal.Start();
            // This dispacher doesn't parse the methods... analyzerLocal.Analyze(new SynchronousLocalDispatcher());
            analyzerLocal.Analyze(AnalysisStrategy.ONDEMAND_SYNC);
            timerLocal.Stop();
            var callgraphLocal = analyzerLocal.GenerateCallGraph();
            Logger.Instance.Log("Program", "CompareDispatchers", "Local analysis time: {0}", timerLocal.Elapsed);

            var analyzerParallel = new SolutionAnalyzer(solution);
            var timerQueuing = new Stopwatch();
            timerQueuing.Start();
            analyzerParallel.Analyze(AnalysisStrategy.ONDEMAND_ASYNC);

            /*
            using (var queryingDispatcher = new QueueingDispatcher(solution))
            {
                analyzerParallel.AnalyzeEntireSolution();

                // block here waiting
                while (!queryingDispatcher.IsDoneProcessing)
                {
                    Console.WriteLine("Queue {0}", queryingDispatcher.GetQueueCount());
                    Console.WriteLine("A total of {0} messages delivered", queryingDispatcher.MessageCount);
                    System.Threading.Thread.Sleep(10000);
                }
            }*/
            timerQueuing.Stop();

            var callgraphQueuing = analyzerParallel.GenerateCallGraph();

            Logger.Instance.Log("Program", "CompareDispatchers", "Queueing analysis time: {0}", timerLocal.Elapsed);
            Logger.Instance.Log("Program", "CompareDispatchers", "Analysis {0} {1} methods ", 1, callgraphLocal.GetReachableMethods().Count);
            Logger.Instance.Log("Program", "CompareDispatchers", "Analysis {0} {1} methods ", 2, callgraphQueuing.GetReachableMethods().Count);

            if (callgraphLocal.GetReachableMethods().Count != callgraphQueuing.GetReachableMethods().Count)
            {
                return false;
            }
            if (callgraphLocal.GetEdges().Count() != callgraphQueuing.GetEdges().Count())
            {
                return false;
            }

            // seems like they are the same
            return true;
        }
コード例 #4
0
        private static CallGraph<MethodDescriptor, LocationDescriptor> GenerateCallGraph(Solution solution)
        {
            var analyzer = new SolutionAnalyzer(solution);
            var timerLocal = new Stopwatch();
            timerLocal.Start();
            // This dispacher doesn't parse the methods... analyzerLocal.Analyze(new SynchronousLocalDispatcher());
            analyzer.Analyze(AnalysisStrategy.ONDEMAND_ORLEANS);
            timerLocal.Stop();

            return analyzer.GenerateCallGraph();
        }
コード例 #5
0
        private static void CompareExample(string source)
        {
            var solution = ReachingTypeAnalysis.Utils.CreateSolution(source);
            var analyzerLocal = new SolutionAnalyzer(solution);
            analyzerLocal.Analyze(AnalysisStrategy.ONDEMAND_SYNC);

            var callgraphLocal = analyzerLocal.GenerateCallGraph();

            var analyzerParallel = new SolutionAnalyzer(solution);
            var queueingDispatcher = new QueueingDispatcher();
            analyzerParallel.Analyze(AnalysisStrategy.ENTIRE_ASYNC);
            var callgraphQueuing = analyzerParallel.GenerateCallGraph();

            var localReachable = callgraphLocal.GetReachableMethods().Count;
            var queuingReachable = callgraphQueuing.GetReachableMethods().Count;

            Assert.IsTrue(localReachable == queuingReachable);
            Assert.IsTrue(callgraphLocal.GetEdges().Count() == callgraphQueuing.GetEdges().Count());
        }
コード例 #6
0
        private static void AnalyzeExample(string source, RunChecks checker, AnalysisStrategy strategy = AnalysisStrategy.NONE)
        {
            //var solution = ReachingTypeAnalysis.Utils.CreateSolution(source);
            //var solAnalyzer = new SolutionAnalyzer(solution);
            var solAnalyzer = new SolutionAnalyzer(source);
            solAnalyzer.Analyze(strategy);
            var callgraph = solAnalyzer.GenerateCallGraph();

            checker(solAnalyzer, callgraph);
        }
コード例 #7
0
 private static void AnalizeSolution(Solution solution, RunChecks checker, AnalysisStrategy type = AnalysisStrategy.NONE)
 {
     var solAnalyzer = new SolutionAnalyzer(solution);
     solAnalyzer.Analyze(type);
     var callgraph = solAnalyzer.GenerateCallGraph();
     checker(solAnalyzer, callgraph);
 }
コード例 #8
0
 internal MethodEntitiesCallsInfo(Solution solution)
 {
     this.solutionAnalyzer= new SolutionAnalyzer(solution);
     this.solutionAnalyzer.AnalyzeWithoutAppSettings();
 }