/// <summary> /// Populates the divergence information. /// </summary> /// <param name="example">The counter example.</param> /// <param name="error">The divergence error.</param> public void PopulateDivergenceInformation(CallCounterexample example, DivergenceError error) { CallCmd call = example.FailingCall; SourceLocationInfo source = new SourceLocationInfo(GetAttributes(call), GetSourceFileName(), call.tok); error.Location = source; }
public bool Equals(SourceLocationInfo source) { if (Count == source.GetRecords().Count) { bool result = true; for (int i = 0; i < Count; i++) { result = result && this[i].Equals(source.GetRecords()[i]); } return(result); } // handling the case where the verifier ignores header and we don't // refer OpenCL/atomics/refined_atomic_abstraction/access_in_loop as an example if (source.GetRecords().Count == 1) { SourceLocationInfo.Record record = source.GetRecords().First(); if (this.Count(x => x.File == record.GetFile()) == 1) { return(this.First(x => x.File == record.GetFile()).Equals(record)); } } return(false); }
public bool IsBetween(SourceLocationInfo start, SourceLocationInfo end) { IEnumerable <LocationChain> start_chains = start.GetLocationChain(); IEnumerable <LocationChain> end_chains = end.GetLocationChain(); foreach (LocationChain start_chain in start_chains) { foreach (LocationChain end_chain in end_chains) { if (IsBetween(start_chain, end_chain)) { return(true); } } } return(false); }
/// <summary> /// Filter the barriers based on the source information. /// </summary> /// <param name="start">The start location.</param> /// <param name="end">The end location.</param> /// <returns>The barriers to be considered.</returns> private List <Barrier> FilterBarriers(SourceLocationInfo start, SourceLocationInfo end) { List <Barrier> location_barriers = new List <Barrier>(); foreach (Barrier barrier in ProgramMetadata.Barriers.Values) { LocationChain chain = ProgramMetadata.Locations[barrier.SourceLocation]; if (start != null && end != null) { if (chain.IsBetween(start, end)) { AddBarrier(location_barriers, barrier); } } } return(location_barriers); }
/// <summary> /// Retrieves the race information. /// </summary> /// <param name="example">The counter example.</param> /// <param name="error">The race error.</param> /// <returns>The race errors.</returns> public IEnumerable <RaceError> GetRaceInformation(CallCounterexample example, RaceError error) { string raceName, access1, access2; DetermineNatureOfRace(example, out raceName, out access1, out access2); PopulateModelWithStatesIfNecessary(example); string raceyArrayName = GetArrayName(example.FailingRequires); IEnumerable <SourceLocationInfo> possibleSourcesForFirstAccess = GetPossibleSourceLocationsForFirstAccessInRace( example, raceyArrayName, AccessType.Create(access1), GetStateName(example)); SourceLocationInfo sourceInfoForSecondAccess = new SourceLocationInfo( GetAttributes(example.FailingCall), GetSourceFileName(), example.FailingCall.tok); error.RaceType = raceName; error.Access1 = access1; error.Access2 = access2; List <RaceError> errors = new List <RaceError>(); foreach (SourceLocationInfo possibleSourceForFirstAccess in possibleSourcesForFirstAccess) { RaceError race = new RaceError(error.CounterExample, error.Implementation) { RaceType = raceName, Access1 = access1, Access2 = access2, Start = possibleSourceForFirstAccess, End = sourceInfoForSecondAccess }; errors.Add(race); } if (!errors.Any()) { return new List <RaceError> { error } } ; return(errors); }
/// <summary> /// Gets the loop barriers if any of the given locations are inside a loop. /// </summary> /// <param name="start">The starting location.</param> /// <param name="end">The ending location.</param> /// <returns>The loop barriers.</returns> private List <Barrier> GetLoopBarriers(SourceLocationInfo start, SourceLocationInfo end) { List <Barrier> result = new List <Barrier>(); foreach (BackEdge edge in ProgramMetadata.LoopBarriers.Keys) { List <Barrier> loop_barriers = ProgramMetadata.LoopBarriers[edge]; IEnumerable <LocationChain> locations = loop_barriers.Select(x => ProgramMetadata.Locations[x.SourceLocation]); foreach (LocationChain chain in locations) { if (chain.Equals(start) || chain.Equals(end)) { result.AddRange(loop_barriers); break; } } } return(result); }
public static IEnumerable <LocationChain> GetLocationChain(this SourceLocationInfo source) { List <LocationChain> chains = new List <LocationChain>(); foreach (LocationChain chain in ProgramMetadata.Locations.Values) { if (chain.Equals(source)) { chains.Add(chain); return(chains); } } foreach (LocationChain chain in ProgramMetadata.Locations.Values) { if (chain.Last().Equals(source.GetRecords().Last())) { chains.Add(chain); } } return(chains); }