public void NotifyListenersWeAreDone(ClousotAnalysisResults results)
        {
            Contract.Requires(results != null);

            results.NotifyDone();
            var namedPipeClient = new NamedPipeClientStream(".", CommonNames.GetPipeNameForCCCheckPulseCallBack(0), PipeDirection.InOut);

            try
            {
#if DEBUG && DEBUG_PRINT
                Console.WriteLine("[Debug] Trying to connect to the server to write back (we also wait {0})", TIMEOUTFORCONNECTION);
#endif
                namedPipeClient.Connect(TIMEOUTFORCONNECTION);
                new PipeStreamSimple(namedPipeClient).WriteIfConnected(results.ToList());

#if DEBUG && DEBUG_PRINT
                Console.WriteLine("[Debug] We are done writing back");
#endif
            }
            catch (Exception
#if DEBUG && DEBUG_PRINT
                   e
#endif
                   )
            {
#if DEBUG && DEBUG_PRINT
                Console.WriteLine("[Debug] We failed in writing back: {0}", e.Message);
#endif
                // do nothing
            }
            finally
            {
                namedPipeClient.Close();
            }
        }
Пример #2
0
        private void CallBack(object data)
        {
            NamedPipeServerStream namedPipeServer = null;

            while (true)
            {
                try
                {
                    namedPipeServer = new NamedPipeServerStream(this.myCallBackPipe, PipeDirection.InOut, 254);

                    namedPipeServer.WaitForConnection(); // wait

                    var stream = new PipeStreamSimple(namedPipeServer);

                    List <Tuple <string, object> > list;
                    if (stream.TryRead(out list))
                    {
                        var results = new ClousotAnalysisResults(list);

                        UpdateResults(results);
                    }
                }
                catch
                {
                    // do nothing
                }
                finally
                {
                    if (namedPipeServer != null)
                    {
                        namedPipeServer.Disconnect();
                    }
                }
            }
        }
        public static ClousotAnalysisResults EmitStats(this AnalysisStatistics @this, int swallowedTop, int swallowedBottom, int swallowedFalse, string assemblyName, IOutputResults output)
        {
            Contract.Requires(swallowedTop >= 0);
            Contract.Requires(swallowedBottom >= 0);
            Contract.Requires(swallowedFalse >= 0);
            Contract.Requires(assemblyName != null);
            Contract.Ensures(Contract.Result <ClousotAnalysisResults>() != null);

            var result = new ClousotAnalysisResults();

            if (@this.Total > 0)
            {
                var True   = @this.True;
                var Top    = Math.Max(@this.Top - swallowedTop, 0);
                var Bottom = Math.Max(@this.Bottom - swallowedBottom, 0);
                var False  = Math.Max(@this.False - swallowedFalse, 0);

                var Total = True + Top + Bottom + False;

                var masked = swallowedTop + swallowedFalse + swallowedBottom;

                Contract.Assert(masked >= 0);

                Contract.Assert(Top >= 0);
                Contract.Assert(Bottom >= 0);
                Contract.Assert(False >= 0);

                var stats = String.Format("Checked {0} assertion{1}: {2}{3}{4}{5}{6}",
                                          @this.Total.ToString(),
                                          @this.Total > 1 ? "s" : "",
                                          True > 0 ? True + " correct " : "",
                                          Top > 0 ? Top + " unknown " : "",
                                          Bottom > 0 ? Bottom + " unreached " : "",
                                          False > 0 ? False + " false" : "",
                                          masked > 0 ? "(" + masked + " masked)" : "");

                output.FinalStatistic(assemblyName, stats);

                double precision = Total != 0 ? True / (double)Total : 1.0;
                output.Statistic("Validated: {0,6:P1}", precision);

                // for scripts parsing msbuild output
                output.WriteLine(stats);

                // Update the result
                result.Total  = @this.Total;
                result.True   = True;
                result.False  = False;
                result.Bottom = Bottom;
                result.Top    = Top;
                result.Masked = masked;
            }
            else
            {
                output.FinalStatistic(assemblyName, "Checked 0 assertions.");
            }

            return(result);
        }
    public static ClousotAnalysisResults EmitStats(this AnalysisStatistics @this, int swallowedTop, int swallowedBottom, int swallowedFalse, string assemblyName, IOutputResults output)
    {
      Contract.Requires(swallowedTop >= 0);
      Contract.Requires(swallowedBottom >= 0);
      Contract.Requires(swallowedFalse >= 0);
      Contract.Requires(assemblyName != null);
      Contract.Ensures(Contract.Result<ClousotAnalysisResults>() != null);

      var result = new ClousotAnalysisResults();

      if (@this.Total > 0)
      {
        var True = @this.True;
        var Top = Math.Max(@this.Top - swallowedTop, 0);
        var Bottom = Math.Max(@this.Bottom - swallowedBottom, 0);
        var False = Math.Max(@this.False - swallowedFalse, 0);

        var Total = True + Top + Bottom + False;

        var masked = swallowedTop + swallowedFalse + swallowedBottom;

        Contract.Assert(masked >= 0);

        Contract.Assert(Top >= 0);
        Contract.Assert(Bottom >= 0);
        Contract.Assert(False >= 0);

        var stats = String.Format("Checked {0} assertion{1}: {2}{3}{4}{5}{6}",
          @this.Total.ToString(),
          @this.Total > 1 ? "s" : "",
          True > 0 ? True + " correct " : "",
          Top > 0 ? Top + " unknown " : "",
          Bottom > 0 ? Bottom + " unreached " : "",
          False > 0 ? False + " false" : "",
          masked > 0 ? "(" + masked + " masked)" : "");

        output.FinalStatistic(assemblyName,stats);

        double precision = Total != 0 ? True / (double)Total : 1.0;
        output.Statistic("Validated: {0,6:P1}", precision);

        // for scripts parsing msbuild output
        output.WriteLine(stats);

        // Update the result
        result.Total = @this.Total;
        result.True = True;
        result.False = False;
        result.Bottom = Bottom;
        result.Top = Top;
        result.Masked = masked;
      }
      else
      {
        output.FinalStatistic(assemblyName, "Checked 0 assertions.");
      }

      return result;
    }
Пример #5
0
        private void UpdateResults(ClousotAnalysisResults results)
        {
            var fields = typeof(ClousotAnalysisResults).GetFields();

            var row = new string[fields.Count()];
            var i   = 0;

            foreach (var f in fields)
            {
                var v = f.GetValue(results);
                if (v != null)
                {
                    row[i] = v.ToString();
                }
                i++;
            }

            this.clousotResultsGrid.Invoke(
                new Action(delegate() { this.clousotResultsGrid.Rows.Insert(0, row); }));

            // This will throw, as we are in a different thread!
            //      this.gridResults.Rows.Insert(0, row);
        }
    public void NotifyListenersWeAreDone(ClousotAnalysisResults results)
    {
      Contract.Requires(results != null);

      results.NotifyDone();
      var namedPipeClient = new NamedPipeClientStream(".", CommonNames.GetPipeNameForCCCheckPulseCallBack(0), PipeDirection.InOut);

      try
      {
#if DEBUG && DEBUG_PRINT
        Console.WriteLine("[Debug] Trying to connect to the server to write back (we also wait {0})", TIMEOUTFORCONNECTION);
#endif
        namedPipeClient.Connect(TIMEOUTFORCONNECTION);
        new PipeStreamSimple(namedPipeClient).WriteIfConnected(results.ToList());

#if DEBUG && DEBUG_PRINT
        Console.WriteLine("[Debug] We are done writing back");
#endif
      }
      catch (Exception
#if DEBUG && DEBUG_PRINT
 e
#endif
        )
      {
#if DEBUG && DEBUG_PRINT
        Console.WriteLine("[Debug] We failed in writing back: {0}", e.Message);
#endif
        // do nothing
      }
      finally
      {
        namedPipeClient.Close();
      }
    }
Пример #7
0
    private void CallBack(object data)
    {
      NamedPipeServerStream namedPipeServer = null;

      while (true)
      {
        try
        {
          namedPipeServer = new NamedPipeServerStream(this.myCallBackPipe, PipeDirection.InOut, 254);

          namedPipeServer.WaitForConnection(); // wait

          var stream = new PipeStreamSimple(namedPipeServer);

          List<Tuple<string, object>> list;
          if (stream.TryRead(out list))
          {
            var results = new ClousotAnalysisResults(list);

            UpdateResults(results);
          }
        }
        catch
        {
          // do nothing
        }
        finally
        {
          if (namedPipeServer != null)
            namedPipeServer.Disconnect();
        }
      }
    }
Пример #8
0
    private void UpdateResults(ClousotAnalysisResults results)
    {
      var fields = typeof(ClousotAnalysisResults).GetFields();

      var row = new string[fields.Count()];
      var i = 0;
      foreach (var f in fields)
      {
        var v = f.GetValue(results);
        if (v != null)
        {
          row[i] = v.ToString();
        }
        i++;
      }

      this.clousotResultsGrid.Invoke(
        new Action(delegate() { this.clousotResultsGrid.Rows.Insert(0, row); }));

      // This will throw, as we are in a different thread!
      //      this.gridResults.Rows.Insert(0, row);


    }