public bool TryInferPreconditions(APC pc, Postconditions postconditions)
                {
                    Trace("Starting backwards postcondition propagation", postconditions);

                    if (this.timeout.HasAlreadyTimeOut)
                    {
                        return(false);
                    }

                    try
                    {
                        this.timeout.Start();

                        FixpointComputation(pc, postconditions);

                        return(this.invariants != null && this.invariants.Count != 0);
                    }
                    catch (TimeoutExceptionFixpointComputation)
                    {
                        return(false);
                    }
                    finally
                    {
                        this.timeout.Stop();
                    }
                }
Example #2
0
        /// <summary>
        /// Get the temporary directory path to store instance data. Sub-Directory will be appended
        /// if specified.
        /// </summary>
        /// <param name="subdir">Relative Sub-Directory</param>
        /// <returns>Temporary Folder path</returns>
        public string GetInstancePath(string subdir)
        {
            Postconditions.CheckCondition(Settings);
            Postconditions.CheckCondition(Header);

            lock (this)
            {
                string dir = String.Format("{0}{1}{2}{1}{3}{1}{4}", Header.ApplicationGroup, Path.PathSeparator, Header.Application, Header.Name, Header.Version.ToString());
                if (!String.IsNullOrWhiteSpace(subdir))
                {
                    dir = String.Format("{0}{1}{2}", dir, Path.PathSeparator, subdir);
                }
                return(Settings.GetTempDirectory(dir));
            }
        }
Example #3
0
        /// <summary>
        /// Load a configuration from local file.
        /// </summary>
        /// <param name="configName">Configuration name</param>
        /// <param name="configFile">Configuration File Path</param>
        /// <param name="version">Configuration Version (expected)</param>
        /// <param name="settings">Configuration Settings</param>
        /// <param name="password">Password (if required)</param>
        /// <returns>Loaded Configruation</returns>
        public Configuration Load(string configName, string configFile,
                                  Version version, ConfigurationSettings settings,
                                  string password = null)
        {
            Preconditions.CheckArgument(configName);
            Preconditions.CheckArgument(configFile);
            Preconditions.CheckArgument(version);

            LogUtils.Info(String.Format("Loading Configuration. [name={0}][version={1}][file={2}]", configName, version.ToString(), configFile));

            using (FileReader reader = new FileReader(configFile))
            {
                AbstractConfigParser parser = ConfigProviderFactory.GetParser(configFile);
                Postconditions.CheckCondition(parser);

                parser.Parse(configName, reader, version, settings, password);

                return(parser.GetConfiguration());
            }
        }
                private void FixpointComputation(APC entry, Postconditions initialState)
                {
                    var todo = new List <Tuple <APC, Preconditions> >()
                    {
                        new Tuple <APC, Preconditions>(entry, initialState)
                    };
                    var stable = new Set <APC>();

                    while (todo.Count != 0)
                    {
                        this.timeout.CheckTimeOut("backwards postcondition propagation");

                        var next = todo.ExtractFirst();

                        var nextPC    = next.Item1;
                        var nextState = next.Item2;

                        var newPre = nextState;

                        // do the block
                        {
                            APC pred;
                            while (CFG.HasSinglePredecessor(nextPC, out pred) && !CFG.IsJoinPoint(nextPC))
                            {
                                this.timeout.CheckTimeOut("backwards postcondition propagation (block)");

                                //var post = CFG.Predecessors(nextPC).First();
                                newPre = this.Mdriver.BackwardTransfer(nextPC, pred, newPre, this);

                                // no pre, killing the path
                                if (newPre == null)
                                {
                                    break;
                                }

                                // TODO: check for contraddictions

                                nextPC = pred;
                            }
                        }
                        if (nextPC.Equals(CFG.EntryAfterRequires) || nextPC.Equals(CFG.Entry))
                        {
                            this.invariants = newPre;

                            continue;
                        }

                        var fixpointReached = false;

                        if (CFG.IsJoinPoint(nextPC))
                        {
                            Preconditions prev;
                            if (this.joinPoints.TryGetValue(nextPC, out prev))
                            {
                                newPre = Join(prev, newPre, CFG.IsForwardBackEdgeTarget(nextPC.Block.First), out fixpointReached);

                                if (fixpointReached)
                                {
                                    stable.Add(nextPC.Block.First);
                                }
                            }
                            joinPoints[nextPC] = newPre;
                        }

                        // Split in the backwards analysis
                        foreach (var pred in CFG.Predecessors(nextPC))
                        {
                            if (fixpointReached && CFG.IsForwardBackEdge(pred, nextPC))
                            {
                                continue;
                            }
                            if (this.Mdriver.IsUnreachable(nextPC))
                            {
                                continue;
                            }
                            var transf = this.Mdriver.BackwardTransfer(nextPC, pred, newPre, this);
                            if (transf != null)
                            {
                                todo.Add(new Tuple <APC, Preconditions>(pred, transf));
                            }
                        }
                    }
                }
Example #5
0
 public void AddPostcondition(string key, bool value)
 {
     Postconditions.Add(new KeyValuePair <string, bool>(key, value));
 }