Beispiel #1
0
        public override Procedure VisitProcedure(Procedure node)
        {
            // Make sure not to visit the same Procedure twice
            if (allProcs.Contains(node.Name))
            {
                return(node);
            }
            allProcs.Add(node.Name);

            if (node.Name.Equals(mainProcName))
            {
                mainProcExists = true;

                /*
                 * // Check if this guy takes input parameters
                 * if (node.InParams.Length != 0)
                 * {
                 *  throw new InvalidProg("main procedure " + node.Name + " has input paramters");
                 * }
                 *
                 * if (node.OutParams.Length != 0)
                 * {
                 *  Console.WriteLine("Warning: output parameters of the main procedure will be ignored");
                 * }
                 */
            }

            // Keep record of all modified globals
            foreach (IdentifierExpr ie in node.Modifies)
            {
                GlobalVariable g = (GlobalVariable)ie.Decl;
                if (g == null)
                {
                    continue;
                }
                if (!modifiedGlobals.ContainsKey(g.Name))
                {
                    modifiedGlobals.Add(g.Name, g);
                }
            }

            // No need to go down into a procedure
            //node.Modifies = this.VisitIdentifierExprSeq(node.Modifies);
            //node.InParams = this.VisitVariableSeq(node.InParams);
            //node.OutParams = this.VisitVariableSeq(node.OutParams);

            if (node.Name == LanguageSemantics.getThreadIDName() ||
                node.Name == LanguageSemantics.getChildThreadIDName())
            {
                Debug.Assert(node.OutParams.Count == 1);
                if (node.OutParams[0].TypedIdent.Type.IsBv)
                {
                    threadIdType = node.OutParams[0].TypedIdent.Type;
                }
            }

            return(node);
        }
Beispiel #2
0
        public InstrumentationPolicy(int K, HashSet <string> glob, HashSet <string> procsWithImpl, HashSet <string> asyncProcs, HashSet <Tuple <string, string> > recursiveProcs, ConcurrencyMode mode)
        {
            executionContextBound = K;
            globalsToInstrument   = glob;
            this.procsWithImpl    = procsWithImpl;
            this.asyncProcs       = asyncProcs;
            this.recursiveProcs   = recursiveProcs;
            this.mode             = mode;

            atomicBeginProcName    = LanguageSemantics.atomicBeginProcName();
            atomicEndProcName      = LanguageSemantics.atomicEndProcName();
            assertNotReachableName = LanguageSemantics.assertNotReachableName();
            getThreadIDName        = LanguageSemantics.getThreadIDName();
        }