public PlaySlotCommand(ISymbolManager symbolManager, IWriter writer, ISlotFactory slotFactory, IMath mathProvider) { this.symbolManager = symbolManager; this.writer = writer; this.slotFactory = slotFactory; this.mathProvider = mathProvider; }
public void Dump() { //aggregate the coverage database.AccumulateMaxCoverage(this.ExplorationServices.Driver.TotalCoverageBuilder); //for debugging purpose in report SafeStringBuilder sb = new SafeStringBuilder(); HashSet <CodeLocation> coveredLocations = new HashSet <CodeLocation>(); foreach (var cl in database.FieldsForUnsuccessfullyFlippedCodeLocations.Keys) { sb.AppendLine("about code location" + cl.ToString()); MethodDefinitionBodyInstrumentationInfo info; if (cl.Method.TryGetBodyInstrumentationInfo(out info)) { ISymbolManager sm = this.Services.SymbolManager; SequencePoint sp; sm.TryGetSequencePoint(null, 0, out sp); int coveredBranchesCount = 0; foreach (var outgoingBranchLabel in info.GetOutgoingBranchLabels(cl.Offset)) { CodeBranch codeBranch = new CodeBranch(cl.Method, outgoingBranchLabel); if (!codeBranch.IsBranch) // is explicit branch? { coveredBranchesCount = 2; // if not, pretend we covered it continue; } CoverageDomain domain; int[] hits; if ( this.ExplorationServices.Driver.TotalCoverageBuilder.TryGetMethodHits(cl.Method, out domain, out hits) && outgoingBranchLabel < hits.Length && hits[outgoingBranchLabel] > 0) //we have branches not being covered for the code location { sb.AppendLine(" outgoing branch " + outgoingBranchLabel + " hit"); coveredBranchesCount++; } } if (coveredBranchesCount > 1) //the location has been covered { coveredLocations.Add(cl); } } } foreach (var cl in coveredLocations) { database.FieldsForUnsuccessfullyFlippedCodeLocations.Remove(cl); } this.Log.Dump("foo", "insufficiency summary", sb.ToString()); //database.DumpInSufficientObjectFactoryFieldInfoIToFile(); }
public void DumpAssemblyCoverage(IPexComponent host) { StringBuilder sb = new StringBuilder(); foreach (var item in UnCoveredBranchCodeLocations) { CodeLocation codeLocation = item.Location; ISymbolManager sm = host.Services.SymbolManager; SequencePoint sp; MethodDefinitionBodyInstrumentationInfo info; if (sm.TryGetSequencePoint(codeLocation.Method, codeLocation.Offset, out sp) && codeLocation.Method.TryGetBodyInstrumentationInfo(out info)) { sb.AppendLine(codeLocation.Method.FullName + "," + sp.Document + "," + sp.Line + "," + sp.Column + " outgoingbranch label: " + item.OutgointBranchLabel + " offset: " + codeLocation.Offset.ToString("x")); var branchInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, codeLocation.Method.FullName, codeLocation.Offset); _nonCoveredBranchInfo.Branches.Add(branchInfo); } } DumpInfoToDebugFile(sb.ToString(), assemblyCovFileName + TXT); DumpInfoToFile(_nonCoveredBranchInfo, assemblyCovFileName); StringBuilder sb2 = new StringBuilder("instruction cov: \n"); foreach (var cov in InstructionCov) { sb2.AppendLine("method: " + cov.Key); foreach (var pair in cov.Value) { sb2.AppendLine("offset: " + pair.Key.ToString("x") + " covered: " + pair.Value); } } DumpInfoToDebugFile(sb2.ToString(), instructionCovFileName + TXT); DumpInfoToFile(InstructionCov, instructionCovFileName); StringBuilder sb3 = new StringBuilder("basicblockOffsets cov: \n"); foreach (var offset in BasicBlocksOffsets) { sb3.AppendLine("method: " + offset.Key); foreach (var pair in offset.Value) { sb3.AppendLine("offset: " + pair.ToString("x")); } } DumpInfoToDebugFile(sb3.ToString(), basicBlockOffsetFileName + TXT); }
/// <summary> /// Gets a line number of a method /// </summary> /// <returns></returns> public int GetLineNumberOfOffset(Method method, int offset) { int line = -1; var methodDef = method.Definition; ISymbolManager smanager = this.Host.GetService <ISymbolManager>(); SequencePoint sp; if (smanager.TryGetSequencePoint(methodDef, offset, out sp)) { line = sp.Line; } return(line); }
private void DumpTest() { Log.Dump("test", "test", "test: "); StringBuilder sb = new StringBuilder(); sb.AppendLine("test: "); try { TaggedBranchCoverageBuilder <PexGeneratedTestName> cov; Services.CoverageManager.TryGetAssemblyCoverageBuilder(out cov); IEnumerable <MethodDefinition> definitions = cov.GetMethods(CoverageDomain.UserCodeUnderTest); IEnumerator <MethodDefinition> enumerator = definitions.GetEnumerator(); Log.Dump("test", "test", "method count: " + definitions.Count().ToString()); while (enumerator.MoveNext()) { MethodDefinition definition = enumerator.Current; CoverageDomain domain; int[] hits; cov.TryGetMethodHits(definition, out domain, out hits); Log.Dump("test", "test", "method hits: " + hits.Length); MethodDefinitionBodyInstrumentationInfo body; definition.TryGetBodyInstrumentationInfo(out body); Converter <int, int> converter = body.GetInstructionCoverage(hits); for (int i = 0; i < hits.Length; i++) { int offset = converter.Invoke(hits[i]); ISymbolManager sm = Services.SymbolManager; SequencePoint sp; sm.TryGetSequencePoint(definition, offset, out sp); sb.AppendLine("test: " + definition.FullName + " domain: " + domain + " doc: " + sp.Document + " line: " + sp.Line + " column: " + sp.Column); } Log.Dump("test", "test", sb.ToString()); } } catch (Exception e) { sb.AppendLine("exception: " + e); Log.Dump("test", "test", "exception: " + e); } DumpInfoToDebugFile(sb.ToString(), testFileName); }
private void DumpResultTrackingInfo() { // DumpInfoToDebugFile(sb.ToString(), resultTrackingFileName+TXT); foreach (var keyValue in ExternalMethodInBranch) { var method = keyValue.Key; var locations = keyValue.Value; ISymbolManager sm = Services.SymbolManager; SequencePoint sp; MethodDefinitionBodyInstrumentationInfo info; foreach (var location in locations) { if (sm.TryGetSequencePoint(location.Method, location.Offset, out sp) && location.Method.TryGetBodyInstrumentationInfo(out info)) { // sb.AppendLine(codeLocation.Method.FullName + "," + // sp.Document + "," + // sp.Line + "," + sp.Column // + " outgoingbranch label: " + item.Value); var branchInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, location.Method.FullName, location.Offset); if (!resultTrackingInfo.UnIntrumentedMethodInBranch.ContainsKey(method.FullName)) { resultTrackingInfo.UnIntrumentedMethodInBranch.Add(method.FullName, new HashSet <BranchInfo>()); } resultTrackingInfo.UnIntrumentedMethodInBranch[method.FullName].Add(branchInfo); } } } var sb = new StringBuilder("result track: "); foreach (var branch in resultTrackingInfo.UnIntrumentedMethodInBranch) { sb.AppendLine("branch: " + branch.Key + " method: " + branch.Value); } DumpInfoToDebugFile(sb.ToString(), resultTrackingFileName + TXT); DumpInfoToFile(resultTrackingInfo, resultTrackingFileName); }
public SocketServiceManager(IUserManager userManager, IAlertManager alertManager, ISubscriptionManager subscriptionManager, ISymbolManager symbolManager, IPriceManager priceManager) { _userManager = userManager; _alertManager = alertManager; _subscriptionManager = subscriptionManager; _symbolManager = symbolManager; _priceManager = priceManager; Users = new List <UserModel>(); Symbols = new List <SymbolModel>(); Prices = new List <PriceModel>(); SymbolSubscriptions = new List <SubscriptionModel>(); SymbolAlerts = new List <AlertModel>(); SymbolSockets = new Dictionary <string, WebSocket>(); }
/// <summary> /// Standard constructor /// </summary> /// <param name="symbolManager">the symbol manager that will provide the data</param> public InstrumentationModelBuilder(ISymbolManager symbolManager) { _symbolManager = symbolManager; }
public LangController(ISymbolManager mgr, IUser usr) { _symmgr = mgr; _user = usr; }
public static void InitSymbols(ISymbolManager mgr) { mgr.OptimizeAsync().Wait(); }
public void FindUncoveredBranches(IPexComponent host) { TaggedBranchCoverageBuilder <PexGeneratedTestName> cov; IPexCoverageManager manager = host.Services.CoverageManager; StringBuilder sb = new StringBuilder("method coverage: \n"); try { if (manager.TryGetAssemblyCoverageBuilder(out cov)) { // var definitions = cov.Methods; IEnumerable <MethodDefinition> definitions = cov.Methods; host.Log.Dump("test", "test", "methods: " + definitions.Count()); Log.AppendLine("assembly methods: " + definitions.Count()); sb.AppendLine("methods: " + definitions.Count()); foreach (var method in definitions) { Log.AppendLine("method: " + method.FullName); // Method m = method.Instantiate(TypeEx.NoTypes, TypeEx.NoTypes); // MethodBodyEx body; // if (!m.TryGetBody(out body)) // { // //error // Log.AppendLine("load method body failed"); // } // method.Instantiate() CoverageDomain domain; if (!branchCoverageDetails.ContainsKey(method)) { branchCoverageDetails.Add(method, new HashSet <BranchCoverageDetail>()); } int[] hits; if (cov.TryGetMethodHits(method, out domain, out hits)) { Log.AppendLine("method hits: " + hits.Length + " " + hits); for (int branchLabel = 0; branchLabel < hits.Length; branchLabel++) { CodeLocation location = method.GetBranchLabelSource(branchLabel); Log.AppendLine("current location: " + location); MethodDefinitionBodyInstrumentationInfo info; if (method.TryGetBodyInstrumentationInfo(out info)) { ISymbolManager sm = host.Services.SymbolManager; SequencePoint sp; sm.TryGetSequencePoint(method, location.Offset, out sp); Log.AppendLine("info: " + info.MethodDefinition.FullName); // foreach (var index in info.BasicBlockStartOffsets) // { // Log.AppendLine("start of BB: " + index.ToString("x")); // } // var util = new BasicBlockUtil(Log, body, info.BasicBlockStartOffsets); // ReadInstructionCov(method, hits, info); foreach ( var outgoingBranchLabel in info.GetOutgoingBranchLabels(location.Offset)) { CodeBranch codeBranch = new CodeBranch(location.Method, outgoingBranchLabel); if (!codeBranch.IsBranch && !codeBranch.IsSwitch && !codeBranch.IsCheck) // is explicit branch? { host.Log.Dump("coverage", "coverage", "CodeBranch: " + codeBranch + " is not explicit"); sb.AppendLine("CodeBranch: " + codeBranch + " is not explicit"); Log.AppendLine("CodeBranch: " + codeBranch + " is not explicit"); continue; // if not, we don't log it } var fromMethod = method.FullName + "," + sp.Document + "," + sp.Line + ", column: " + sp.Column + " outgoing label: " + outgoingBranchLabel; BranchInfo branchInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, method.FullName, location.Offset); Log.AppendLine("Checking CodeBranch: " + codeBranch); Log.AppendLine("CodeBranch location: " + fromMethod); Log.AppendLine("hits.Length: " + hits.Length); Log.AppendLine("codeBranch.IsBranch: " + codeBranch.IsBranch); Log.AppendLine("codeBranch.IsCheck: " + codeBranch.IsCheck); Log.AppendLine("codeBranch.IsContinue: " + codeBranch.IsContinue); Log.AppendLine("codeBranch.IsFailedCheck: " + codeBranch.IsFailedCheck); Log.AppendLine("codeBranch.IsStartMethod: " + codeBranch.IsStartMethod); Log.AppendLine("codeBranch.IsSwitch: " + codeBranch.IsSwitch); Log.AppendLine("codeBranch.IsTarget: " + codeBranch.IsTarget); int branchhit = 0; if (outgoingBranchLabel < hits.Length && hits[outgoingBranchLabel] != 0) { Log.AppendLine("CodeBranch: " + codeBranch + " is covered " + hits[outgoingBranchLabel] + " times"); branchhit = hits[outgoingBranchLabel]; } if (outgoingBranchLabel >= hits.Length) { Log.AppendLine("CodeBranch: " + codeBranch + " is not covered " + " since outgoing label" + outgoingBranchLabel + " is larger than" + hits.Length + "."); branchhit = 0; } string type = ""; if (codeBranch.IsBranch) { type = "Explicit"; } else if (codeBranch.IsCheck) { type = "Implicit"; } BranchCoverageDetail coverageDetail = new BranchCoverageDetail(branchInfo, branchhit, null, 0, type); coverageDetail.CopyBranchProperties(codeBranch); coverageDetail.OutgoingLabel = outgoingBranchLabel; coverageDetail.BranchLabel = branchLabel; int targetOffset; if (info.TryGetTargetOffset(outgoingBranchLabel, out targetOffset)) { sm.TryGetSequencePoint(method, targetOffset, out sp); var targetCovTimes = info.GetInstructionCoverage(hits).Invoke(targetOffset); Log.AppendLine(fromMethod + "\n going to: " + sp.Document + " line: " + sp.Line + " column: " + sp.Column + " endcolumn: " + sp.EndColumn + " target: " + targetOffset.ToString("x")); Log.AppendLine("target offset: " + targetOffset.ToString("x")); Log.AppendLine("it is covered at " + targetCovTimes + " times"); Log.AppendLine("outgoing lables: " + info.GetOutgoingBranchLabels(targetOffset).Count); BranchInfo targetInfo = new BranchInfo(sp.Document, sp.Line, sp.Column, sp.EndColumn, method.FullName, targetOffset); coverageDetail.TargetLocation = targetInfo; coverageDetail.targetCoveredTimes = targetCovTimes; if (!branchCoverageDetails[method].Contains(coverageDetail)) { branchCoverageDetails[method].Add(coverageDetail); } else { foreach (BranchCoverageDetail detail in branchCoverageDetails[method]) { if (detail.Equals(coverageDetail)) { if (coverageDetail.CoveredTimes > detail.CoveredTimes) { detail.CoveredTimes = coverageDetail.CoveredTimes; } } } } } if (outgoingBranchLabel < hits.Length && hits[outgoingBranchLabel] == 0 || branchhit == 0) { Log.AppendLine("CodeBranch: " + codeBranch + " is not covered" + " current offset: " + location.Offset.ToString("x")); // if (!targetBlockCovered) // { locations.Add(new BranchLocation(location, outgoingBranchLabel)); continue; // } if (info.TryGetTargetOffset(outgoingBranchLabel, out targetOffset)) { sm.TryGetSequencePoint(method, targetOffset, out sp); var times = info.GetInstructionCoverage(hits).Invoke(targetOffset); Log.AppendLine(fromMethod + " going to: " + sp.Document + " line: " + sp.Line + " column: " + sp.Column + " endcolumn: " + sp.EndColumn + " target: " + targetOffset.ToString("x")); Log.AppendLine("target offset: " + targetOffset.ToString("x")); Log.AppendLine("it is covered at " + times + " times"); Log.AppendLine("outgoing lables: " + info.GetOutgoingBranchLabels(targetOffset).Count); if (times == 0) { IIndexable <int> basicBlockStartOffsets = info.BasicBlockStartOffsets; int indexOfBasicBlock; for (indexOfBasicBlock = 0; indexOfBasicBlock < basicBlockStartOffsets.Count; indexOfBasicBlock++) { Log.AppendLine("basicBlockStartOffsets: " + basicBlockStartOffsets[indexOfBasicBlock]. ToString("x")); if (basicBlockStartOffsets[indexOfBasicBlock] == targetOffset) { break; } } bool targetBlockCovered = true; if (targetOffset + 1 >= basicBlockStartOffsets[indexOfBasicBlock + 1]) { Log.AppendLine("basicBlockStartOffsets: " + basicBlockStartOffsets[indexOfBasicBlock + 1]); Log.AppendLine("Target Offset " + (targetOffset + 1).ToString("x") + " reach next block"); targetBlockCovered = false; } else { Log.AppendLine("basicBlockStartOffsets: " + basicBlockStartOffsets[indexOfBasicBlock + 1]. ToString("x")); Log.AppendLine("Target Offset " + (targetOffset + 1).ToString("x") + " inside same block"); int coveredTimes = info.GetInstructionCoverage(hits).Invoke(targetOffset + 1); Log.AppendLine("Target Offset " + (targetOffset + 1).ToString("x") + " is covered at " + coveredTimes + " times."); if (coveredTimes == 0) { targetBlockCovered = false; } } if (!targetBlockCovered) { // locations.Add(location, outgoingBranchLabel); } } } } } } } } } } else { sb.AppendLine("manager.TryGetAssemblyCoverageBuilder is null!"); } host.GetService <ProblemTrackDatabase>().InstructionCov = instructionCov; host.GetService <ProblemTrackDatabase>().BasicBlocksOffsets = basicBlockOffsets; host.GetService <ProblemTrackDatabase>().BranchCoverageDetails = branchCoverageDetails; DumpInfoToDebugFile(sb.ToString(), assemblyCovFileName); } catch (Exception ex) { host.Log.Dump("coverage", "cov ex", ex.Message); host.GetService <ProblemTrackDatabase>().ErrorLog.AppendLine("exception in FindUncoveredBranches: " + ex); DumpInfoToDebugFile("cov ex" + ex.Message, assemblyCovFileName); } }
/// <summary> /// Standard constructor /// </summary> /// <param name="symbolManager">the symbol manager that will provide the data</param> /// <param name="filter">A filter to decide whether to include or exclude an assembly or its classes</param> public InstrumentationModelBuilder(ISymbolManager symbolManager, IFilter filter) { _symbolManager = symbolManager; _filter = filter; }
public PriceManager(IPriceRepository priceRepository, ISymbolManager symbolManager) { _priceRepository = priceRepository; _symbolManager = symbolManager; }
public SearchController(ISymbolManager mgr) { _symmgr = mgr; }
public ExampleRequestController(IUser usr, IExampleModule module, ISymbolManager symbolManager) { _user = usr; _manager = module.RequestManager; _symbolManager = symbolManager; }