Ejemplo n.º 1
0
        private int ReportRace(AssertCounterexample cex)
        {
            this.PopulateModelWithStatesIfNecessary(cex);

            var resource           = this.GetSharedResourceName(cex.FailingAssert.Attributes);
            var conflictingActions = this.GetConflictingAccesses(cex, resource);

            this.UnprotectedResources.Add(resource);

            if (WhoopCommandLineOptions.Get().DebugWhoop)
            {
                Console.WriteLine("Conflict in resource: " + resource);
            }
            if (WhoopCommandLineOptions.Get().ShowErrorModel)
            {
                this.Write(cex.Model, conflictingActions);
            }

            int errorCounter = 0;

            foreach (var action1 in conflictingActions)
            {
                foreach (var action2 in conflictingActions)
                {
                    if (this.AnalyseConflict(action1.Key, action2.Key, action1.Value, action2.Value))
                    {
                        errorCounter++;
                    }
                }
            }

            return(errorCounter == 0 ? 1 : errorCounter);
        }
Ejemplo n.º 2
0
        public SourceLocationInfo(QKeyValue attributes)
        {
            this.Line = QKeyValue.FindIntAttribute(attributes, "line", -1);
            if (this.Line == -1)
            {
                throw new Exception();
            }

            this.Column = QKeyValue.FindIntAttribute(attributes, "column", -1);
            if (this.Column == -1)
            {
                throw new Exception();
            }

            this.File       = WhoopCommandLineOptions.Get().OriginalFile;
            this.Directory  = Path.GetDirectoryName(WhoopCommandLineOptions.Get().OriginalFile);
            this.StackTrace = SourceLocationInfo.TrimLeadingSpaces(this.FetchCodeLine(0), 2);
        }
Ejemplo n.º 3
0
        public bool TryParseNew(ref AnalysisContext ac, List <string> additional = null)
        {
            List <string> filesToParse = new List <string>();

            filesToParse.Add(WhoopCommandLineOptions.Get().WhoopDeclFile);

            if (additional != null)
            {
                foreach (var str in additional)
                {
                    string file = this.File.Substring(0, this.File.IndexOf(Path.GetExtension(this.File))) +
                                  "_" + str + "." + this.Extension;
                    if (!System.IO.File.Exists(file))
                    {
                        return(false);
                    }
                    filesToParse.Add(file);
                }
            }
            else
            {
                string file = this.File.Substring(0, this.File.IndexOf(Path.GetExtension(this.File))) +
                              "." + this.Extension;
                if (!System.IO.File.Exists(file))
                {
                    return(false);
                }
                filesToParse.Add(file);
            }

            Program program = ExecutionEngine.ParseBoogieProgram(filesToParse, false);

            if (program == null)
            {
                return(false);
            }

            ResolutionContext rc = new ResolutionContext(null);

            program.Resolve(rc);
            if (rc.ErrorCount != 0)
            {
                Console.WriteLine("{0} name resolution errors detected", rc.ErrorCount);
                return(false);
            }

            int errorCount = program.Typecheck();

            if (errorCount != 0)
            {
                Console.WriteLine("{0} type checking errors detected", errorCount);
                return(false);
            }

            ac = new AnalysisContext(program, rc);
            if (ac == null)
            {
                Environment.Exit((int)Outcome.ParsingError);
            }

            return(true);
        }