protected override void AfterRun(IPexPathComponent host, object data) { Term[] pathConditions = new Term[] {}; IList <Term> conditions = null; IList <CodeLocation> locations = null; SafeSet <Method> trackingMethods = null; var database = host.GetService <ProblemTrackDatabase>(); var unInstrumentedMethods = database.ExternalMethods; log = database.SimpleLog; foreach (var unInstrumentedMethod in unInstrumentedMethods) { var controller = new ResultTracer(host, unInstrumentedMethod.Method, log); log.AppendLine("try tracking " + unInstrumentedMethod.Method.FullName); log.AppendLine("*****************************************************"); using (IEngine trackingEngine = host.PathServices.TrackingEngineFactory.CreateTrackingEngine(controller) ) { trackingEngine.GetService <IPexTrackingDriver>().Run(); pathConditions = Enumerable.ToArray(controller.PathConditions); conditions = controller.Conditions; locations = controller.Locations; trackingMethods = controller.TrackingMethods; } PexLog(host, "ResultTracing", prettyPrintPathCondition(host, pathConditions)); // log.AppendLine("condition: " + prettyPrintPathCondition(host, pathConditions)); PexLog(host, "tracking methods", trackingMethods.Select(x => x.FullName)); for (int i = 0; i < conditions.Count; i++) { var condition = conditions[i]; using (var extractor = new ResultTrackConditionExtractor(host.ExplorationServices.TermManager)) { extractor.VisitTerm(default(TVoid), condition); if (extractor.Method == null) { host.Log.Dump("method", "not in branch", "null"); continue; } PexLog(host, "method", extractor.Method.FullName); PexLog(host, "offset", extractor.CallerOffset.ToString("x")); PexLog(host, "location", extractor.Location.ToString()); var method = extractor.Signature as Method; PexLog(host, "signature", method.FullName); log.AppendLine("found method: " + method.FullName + " in branch " + locations[i]); if (!host.GetService <ProblemTrackDatabase>().ExternalMethodInBranch.ContainsKey(method)) { host.GetService <ProblemTrackDatabase>().ExternalMethodInBranch.Add(method, new HashSet <CodeLocation>()); } host.GetService <ProblemTrackDatabase>().ExternalMethodInBranch[method].Add(locations[i]); } } PexLog(host, "location", locations.Select(x => x.ToString())); log.AppendLine("*****************************************************"); } log.AppendLine("========================="); }
public override int GetNextCallId(int threadId, int offset, IMethodSignature methodSignature, TypeEx[] varArgTypes, Term[] arguments) { DumpInfo(methodSignature, threadId, offset, varArgTypes); var termManager = host.ExplorationServices.TermManager; var method = methodSignature as Method; if (method != null) { Dump("method name: " + method.FullName + " offset: " + offset); if (!method.FullName.Equals(_trackMethod.FullName)) { Dump("method: " + method.FullName + " is not tracking method " + _trackMethod); Dump("end GetNextCallId============================="); Dump(""); return(0); } } if (method != null) { Dump("method name: " + method.FullName); if (method.FullName.Equals(_trackMethod.FullName)) { bool foundSymbol = false; if (arguments == null) { Dump("args is null"); } else { string arg = ""; foreach (Term term in arguments) { arg += "arg: " + term + " is symbolic: " + termManager.IsSymbol(term); var extractor = new ResultTrackConditionExtractor(termManager); extractor.VisitTerm(default(TVoid), term); arg += " symbol: " + extractor.Log; } Dump("args: " + arg); foreach (Term argument in arguments) { //pex bug if (termManager.IsSymbol(argument)) { foundSymbol = true; break; } else { var extractor = new ResultTrackConditionExtractor(termManager); extractor.VisitTerm(default(TVoid), argument); if (extractor.foundSymbol) { foundSymbol = true; break; } } } } track = foundSymbol; // track = true; if (track) { Dump("track " + method.FullName); trackArg = true; methodForTrackingArg = method; Dump("track parameter of " + method.FullName); } } } else { Dump(methodSignature + " signature is null."); } Dump("end GetNextCallId============================="); Dump(""); return(0); }