コード例 #1
0
        public static ScopeAnalysisStats AnalyzeAssemblies(Options options)
        {
            Utils.IsVerbose = options.Verbose;

            var vertexDef          = LoadVertexDef(options);
            var processorIdMapping = LoadProcessorMapping(options);

            var host       = new PeReader.DefaultHost();
            var assemblies = LoadAssemblies(host, options);
            var stats      = new ScopeAnalysisStats();

            stats.Assemblies = options.Assemblies.Count;

            var mainAssemblies = assemblies.Item1;

            stats.AssembliesLoaded = mainAssemblies.Count;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            foreach (var mAssembly in mainAssemblies)
            {
                try
                {
                    Utils.WriteLine("\n====== Analyzing assembly: " + mAssembly.FileName + " =========\n");

                    // If processor to id mapping and xml with id information are both available,
                    // then we ask ScopeAnalysis to analyze only those processors mentioned in the mapping.
                    ScopeAnalysis analysis = new ScopeAnalysis(host, mAssembly, assemblies.Item2,
                                                               processorIdMapping == null || vertexDef == null? null : processorIdMapping.Keys);
                    analysis.Analyze();

                    //Update the stats.
                    UpdateStats(analysis.Results, ref stats, vertexDef, processorIdMapping);

                    Utils.WriteLine("\n====== Done analyzing the assembly  =========\n");
                }
                catch (ScopeAnalysis.MissingScopeMetadataException e)
                {
                    Utils.WriteLine("ASSEMBLY WARNING: " + e.Message);
                }
                catch (Exception e)
                {
                    Utils.WriteLine("ASSEMBLY FAILURE: " + e.Message);
                }
            }

            stopWatch.Stop();
            var ts = stopWatch.Elapsed;

            Utils.WriteLine(String.Format("Total analysis time: {0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10));

            return(stats);
        }
コード例 #2
0
        private static IEnumerable <ScopeMethodAnalysisResult> AnalyzeAssembly(IMetadataHost host, IAssembly assembly, ISourceLocationProvider sourceLocationProvider, IEnumerable <IAssembly> referenceAssemblies, IEnumerable <string> ips)
        {
            if (ips == null)
            {
                Utils.WriteLine("Interesting processors list not provided, continuing without it.");
            }

            var analysis = new ScopeAnalysis(host, assembly, sourceLocationProvider, referenceAssemblies, ips);

            analysis.Analyze();
            return(analysis.Results);
        }