Ejemplo n.º 1
0
    public static int Main(string[] args, IOutputFullResultsFactory<MethodReferenceAdaptor, IAssemblyReference> outputFactory, IEnumerable<Caching.IClousotCacheFactory> cacheAccessorFactories)
    {
      Contract.Requires(args != null);

      if (args.Length > 0 && args[0] == "-cloudot")
      {
        try
        {
          return ClousotViaService.Main(args);
        }
        catch (Exception)
        {
          Console.WriteLine("Process terminated with an exception".PrefixWithCurrentTime());
          return -1;
        }
      }
      else
      {
        var cciilProvider = CciILCodeProvider.CreateCodeProvider();
        var metadataDecoder = cciilProvider.MetaDataDecoder;
        var contractDecoder = cciilProvider.ContractDecoder;
        var assemblyCache = new System.Collections.Hashtable();

        try
        {
          int returnCode = Clousot.ClousotMain(args,
            metadataDecoder,
            contractDecoder,
            assemblyCache,
            outputFactory: outputFactory,
            cacheAccessorFactories: cacheAccessorFactories
          );

          return returnCode; // important for regressions
        }
        catch (ExitRequestedException e)
        {
          return e.ExitCode;
        }
        finally
        {
          cciilProvider.Dispose();
        }
      }
    }
Ejemplo n.º 2
0
        public static int Main(string[] args, IOutputFullResultsFactory <MethodReferenceAdaptor, IAssemblyReference> outputFactory, IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories)
        {
            Contract.Requires(args != null);

            if (args.Length > 0 && args[0] == "-cloudot")
            {
                try
                {
                    return(ClousotViaService.Main(args));
                }
                catch (Exception)
                {
                    Console.WriteLine("Process terminated with an exception".PrefixWithCurrentTime());
                    return(-1);
                }
            }
            else
            {
                var cciilProvider   = CciILCodeProvider.CreateCodeProvider();
                var metadataDecoder = cciilProvider.MetaDataDecoder;
                var contractDecoder = cciilProvider.ContractDecoder;
                var assemblyCache   = new System.Collections.Hashtable();

                try
                {
                    int returnCode = Clousot.ClousotMain(args,
                                                         metadataDecoder,
                                                         contractDecoder,
                                                         assemblyCache,
                                                         outputFactory: outputFactory,
                                                         cacheAccessorFactories: cacheAccessorFactories
                                                         );

                    return(returnCode); // important for regressions
                }
                catch (ExitRequestedException e)
                {
                    return(e.ExitCode);
                }
                finally
                {
                    cciilProvider.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
    public static int Main(string[] args, IOutputFullResultsFactory<System.Compiler.Method, System.Compiler.AssemblyNode> outputFactory, IEnumerable<Caching.IClousotCacheFactory> cacheAccessorFactories)
    {
      Contract.Requires(args != null);

      var assemblyCache = new Hashtable();
      try
      {
        return Clousot.ClousotMain(args, CCIMDDecoder.Value, CCIContractDecoder.Value, assemblyCache, outputFactory, cacheAccessorFactories);
      }
      catch (ExitRequestedException e)
      {
        return e.ExitCode;
      }
      finally
      {
        DisposeAssemblies(assemblyCache.Values);
      }
    }
Ejemplo n.º 4
0
        public static int Main(string[] args, IOutputFullResultsFactory <System.Compiler.Method, System.Compiler.AssemblyNode> outputFactory, IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories)
        {
            Contract.Requires(args != null);

            var assemblyCache = new Hashtable();

            try
            {
                return(Clousot.ClousotMain(args, CCIMDDecoder.Value, CCIContractDecoder.Value, assemblyCache, outputFactory, cacheAccessorFactories));
            }
            catch (ExitRequestedException e)
            {
                return(e.ExitCode);
            }
            finally
            {
                DisposeAssemblies(assemblyCache.Values);
            }
        }
Ejemplo n.º 5
0
        public static int Main(string[] args, IOutputFullResultsFactory <System.Compiler.Method, System.Compiler.AssemblyNode> outputFactory, IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories)
        {
            Contract.Requires(args != null);

#if USECLOUDOT
            if (OptionsHelper.UseCloudot(args))
            {
                // Just an horrible shortcut to invoke the debugger
                if (args.Contains("-break"))
                {
                    System.Diagnostics.Debugger.Launch();
                }

                for (var i = 0; i < CloudotAnalysesRetry; i++)
                {
                    string[] clousotArgs = null;
                    try
                    {
                        return(ClousotViaService.Main(args, out clousotArgs));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Connection to Cloudot terminated with an exception".PrefixWithCurrentTime());
                        Console.WriteLine("Exception details: {0}", e.ToString());

                        if (i == CloudotAnalysesRetry - 1)
                        {
                            Console.WriteLine("We gave up with the service. Reverting to local execution");
                        }
                        else
                        {
                            Console.WriteLine("Try to use the Cloudot again (remaining {0})", CloudotAnalysesRetry - (i - 1));
                        }

                        args = clousotArgs; // We use the service specific options in the case we revert to local execution
                    }
                }
            }
#endif
            var assemblyCache = new Hashtable();
            try
            {
#if DEBUG
#if USECLOUDOT
                if (args != null)
#endif
                {
                    args = args.Where(s => s != StringConstants.DoNotUseCloudot).ToArray();
                }
#endif
                return(Clousot.ClousotMain(args, CCIMDDecoder.Value, CCIContractDecoder.Value, assemblyCache, outputFactory, cacheAccessorFactories));
            }
            catch (ExitRequestedException e)
            {
                return(e.ExitCode);
            }
            finally
            {
                DisposeAssemblies(assemblyCache.Values);
            }
        }
Ejemplo n.º 6
0
 protected override int CallClousotMain(string[] args, IOutputFullResultsFactory <MethodReferenceAdaptor, IAssemblyReference> outputFactory, IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories)
 {
     return(CCI2Driver.Main(args, outputFactory, cacheAccessorFactories));
 }
Ejemplo n.º 7
0
    public static int Main(string[] args, IOutputFullResultsFactory<System.Compiler.Method, System.Compiler.AssemblyNode> outputFactory, IEnumerable<Caching.IClousotCacheFactory> cacheAccessorFactories)
    {
      Contract.Requires(args != null);

#if USECLOUDOT
      if (OptionsHelper.UseCloudot(args))
      {
        // Just an horrible shortcut to invoke the debugger
        if (args.Contains("-break"))
        {
          System.Diagnostics.Debugger.Launch();
        }

        for (var i = 0; i < CloudotAnalysesRetry; i++)
        {
          string[] clousotArgs = null;
          try
          {
            return ClousotViaService.Main(args, out clousotArgs);
          }
          catch (Exception e)
          {
            Console.WriteLine("Connection to Cloudot terminated with an exception".PrefixWithCurrentTime());
            Console.WriteLine("Exception details: {0}", e.ToString());

            if(i == CloudotAnalysesRetry -1 )
            {
              Console.WriteLine("We gave up with the service. Reverting to local execution");
            }
            else
            {
              Console.WriteLine("Try to use the Cloudot again (remaining {0})", CloudotAnalysesRetry - (i-1));
            }

            args = clousotArgs; // We use the service specific options in the case we revert to local execution
          }
        }
      }
#endif
      var assemblyCache = new Hashtable();
      try
      {
#if DEBUG
#if USECLOUDOT
        if (args != null)
#endif
        {
          args = args.Where(s => s != StringConstants.DoNotUseCloudot).ToArray();
        }
#endif
        return Clousot.ClousotMain(args, CCIMDDecoder.Value, CCIContractDecoder.Value, assemblyCache, outputFactory, cacheAccessorFactories);
      }
      catch (ExitRequestedException e)
      {
        return e.ExitCode;
      }
      finally
      {
        DisposeAssemblies(assemblyCache.Values);
      }
    }
Ejemplo n.º 8
0
 protected abstract int CallClousotMain(string[] args,
                                        IOutputFullResultsFactory <Method, Assembly> outputFactory,
                                        IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories);
Ejemplo n.º 9
0
 protected override int CallClousotMain(string[] args, IOutputFullResultsFactory <Method, AssemblyNode> outputFactory, IEnumerable <IClousotCacheFactory> cacheAccessorFactories)
 {
     return(CCI1Driver.Main(args, outputFactory, cacheAccessorFactories));
 }