Пример #1
0
        private static int CallClousotInternally(string[] args, TextWriter textWriter)
        {
            var cciilProvider   = CciILCodeProvider.CreateCodeProvider();
            var metadataDecoder = cciilProvider.MetaDataDecoder;
            var contractDecoder = cciilProvider.ContractDecoder;
            var assemblyCache   = new System.Collections.Hashtable();

            var outputFactory = new FullTextWriterOutputFactory <MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput");

            try
            {
                // We now call Clousot
                int returnCode = Clousot.ClousotMain(args,
                                                     metadataDecoder,
                                                     contractDecoder,
                                                     assemblyCache,
                                                     outputFactory: outputFactory,
                                                     cacheAccessorFactories: null
                                                     );
                return(returnCode);
            }
            finally
            {
                cciilProvider.Dispose(); // make sure all open files are closed
            }
        }
Пример #2
0
        static int CallClousot1(string[] args)
        {
            var assemblyCache = new System.Collections.Hashtable();

            // We handle the platform option here as we can't do it from within Clousot
            // as it is very CCI specific.
            //
            //SetTargetPlatform(args, assemblyCache);

            try
            {
                var textWriter    = Console.Out;
                var outputFactory = new FullTextWriterOutputFactory <Method, AssemblyNode>(textWriter, "ServiceOutput");

                int returnCode = Clousot.ClousotMain(args,
                                                     CCIMDDecoder.Value,
                                                     CCIContractDecoder.Value,
                                                     assemblyCache,
                                                     outputFactory,
                                                     null
                                                     );

                return(returnCode);
            }
            catch (ExitRequestedException e)
            {
                return(e.ExitCode);
            }
            finally
            {
                DisposeAssemblies(assemblyCache.Values);
            }
        }
Пример #3
0
        public static int Main(string[] args, ISimpleLineWriter lineWriter)
        {
            Contract.Requires(args != null);

            var textWriter    = lineWriter.AsTextWriter();
            var outputFactory = new FullTextWriterOutputFactory <MethodReferenceAdaptor, IAssemblyReference>(textWriter);

            return(Main(args, outputFactory, null));
        }
Пример #4
0
    public static int Main(string[] args, ISimpleLineWriter lineWriter)
    {
      Contract.Requires(args != null);

      var textWriter = lineWriter.AsTextWriter();
      var outputFactory = new FullTextWriterOutputFactory<System.Compiler.Method, System.Compiler.AssemblyNode>(textWriter);

      return Main(args, outputFactory, null);
    }
Пример #5
0
        public static int Main(string[] args, ISimpleLineWriter lineWriter)
        {
            Contract.Requires(args != null);

            var textWriter    = lineWriter.AsTextWriter();
            var outputFactory = new FullTextWriterOutputFactory <System.Compiler.Method, System.Compiler.AssemblyNode>(textWriter);

            return(Main(args, outputFactory, null));
        }
Пример #6
0
    public static int Main(string[] args, ISimpleLineWriter lineWriter)
    {
      Contract.Requires(args != null);

      var textWriter = lineWriter.AsTextWriter();
      var outputFactory = new FullTextWriterOutputFactory<MethodReferenceAdaptor, IAssemblyReference>(textWriter);

      return Main(args, outputFactory, null);
    }
Пример #7
0
        static int CallClousot2(string[] args)
        {
            var cciilProvider   = CciILCodeProvider.CreateCodeProvider();
            var metadataDecoder = cciilProvider.MetaDataDecoder;
            var contractDecoder = cciilProvider.ContractDecoder;
            var assemblyCache   = new System.Collections.Hashtable();

            var textWriter    = Console.Out;
            var outputFactory = new FullTextWriterOutputFactory <MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput");

            try
            {
                // We now call Clousot
                int returnCode = Clousot.ClousotMain(args,
                                                     metadataDecoder,
                                                     contractDecoder,
                                                     assemblyCache,
                                                     outputFactory: outputFactory,
                                                     cacheAccessorFactories: null
                                                     );

                return(returnCode);
            }
            catch (ExitRequestedException e)
            {
                return(e.ExitCode);
            }
            catch (Exception e)
            {
                // We need to catch all exception, otherwise the service is turned into an faulted state and remains unusable
                textWriter.WriteLine("[{0}]: Many Clousot: caught exception: {1}", DateTime.Now, e);
                if (e.InnerException != null)
                {
                    textWriter.WriteLine("Inner exception: {0}", e.InnerException);
                }
                return(-4444);
            }
            finally
            {
                Console.WriteLine("Analysis done".PrefixWithCurrentTime());
                textWriter.Close();      // make sure all pending output are flushed
                cciilProvider.Dispose(); // make sure all open files are closed
            }
        }
Пример #8
0
            protected override int Do(IWorkId work)
            {
                var args = this.MakeArgs(work).ToArray();

                var bufferedOutput = BufferedTextWriter.Create();

                try
                {
                    var outputFactory = new FullTextWriterOutputFactory <Method, Assembly>(bufferedOutput);

                    this.output.WriteLine("[SlicerWorker: {0}] Analysis of dll (Time stamp {1}) {2}", DateTime.Now, work.Time, work.SliceId.Dll);

                    return(this.callClousotMain(args, outputFactory, this.db.AsEnumerable()));
                }
                finally
                {
                    this.output.WriteLine(bufferedOutput.ToString());
                }
            }
Пример #9
0
    private static int CallClousotInternally(string[] args, TextWriter textWriter)
    {
      var cciilProvider = CciILCodeProvider.CreateCodeProvider();
      var metadataDecoder = cciilProvider.MetaDataDecoder;
      var contractDecoder = cciilProvider.ContractDecoder;
      var assemblyCache = new System.Collections.Hashtable();

      var outputFactory = new FullTextWriterOutputFactory<MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput");

      try
      {
        // We now call Clousot
        int returnCode = Clousot.ClousotMain(args,
          metadataDecoder,
          contractDecoder,
          assemblyCache,
          outputFactory: outputFactory,
          cacheAccessorFactories: null
        );
        return returnCode;
      }
      finally
      {
        cciilProvider.Dispose(); // make sure all open files are closed
      }
    }
Пример #10
0
    static int CallClousot1(string[] args)
    {
      var assemblyCache = new System.Collections.Hashtable();

      // We handle the platform option here as we can't do it from within Clousot
      // as it is very CCI specific.
      //
      //SetTargetPlatform(args, assemblyCache);

      try
      {
        var textWriter = Console.Out;
        var outputFactory = new FullTextWriterOutputFactory<Method, AssemblyNode>(textWriter, "ServiceOutput");

        int returnCode = Clousot.ClousotMain(args,
          CCIMDDecoder.Value,
          CCIContractDecoder.Value,
          assemblyCache,
          outputFactory,
          null
          );

        return returnCode;
      }
      catch (ExitRequestedException e)
      {
        return e.ExitCode;
      }
      finally
      {
        DisposeAssemblies(assemblyCache.Values);
      }
    }
Пример #11
0
    static int CallClousot2(string[] args)
    {
      var cciilProvider = CciILCodeProvider.CreateCodeProvider();
      var metadataDecoder = cciilProvider.MetaDataDecoder;
      var contractDecoder = cciilProvider.ContractDecoder;
      var assemblyCache = new System.Collections.Hashtable();

      var textWriter = Console.Out;
      var outputFactory = new FullTextWriterOutputFactory<MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput");

      try
      {
        // We now call Clousot
        int returnCode = Clousot.ClousotMain(args,
          metadataDecoder,
          contractDecoder,
          assemblyCache,
          outputFactory: outputFactory,
          cacheAccessorFactories: null
        );

        return returnCode;
      }
      catch (ExitRequestedException e)
      {
        return e.ExitCode;
      }
      catch (Exception e)
      {
        // We need to catch all exception, otherwise the service is turned into an faulted state and remains unusable
        textWriter.WriteLine("[{0}]: Many Clousot: caught exception: {1}", DateTime.Now, e);
        if (e.InnerException != null)
        {
          textWriter.WriteLine("Inner exception: {0}", e.InnerException);
        }
        return -4444;
      }
      finally
      {
        Console.WriteLine("Analysis done".PrefixWithCurrentTime());
        textWriter.Close(); // make sure all pending output are flushed
        cciilProvider.Dispose(); // make sure all open files are closed
      }
    }