protected void ProcessFaultInjectionLine(string line) { InternalBypassTrace.FaultInjectionConfigurationTracer.TraceDebug(50735, 0L, "Processing line: {0}", new object[] { line }); string text = null; FaultInjectionType type = FaultInjectionType.None; string empty = string.Empty; uint key = 0U; List <string> parameters = null; for (;;) { bool flag = false; string nextLexem = this.GetNextLexem(ref line, ref flag); if (flag) { break; } if (string.IsNullOrEmpty(nextLexem)) { goto IL_A4; } if (nextLexem == ",") { if (!this.ReadFaultInjectionTagComponent(ref line, ref empty)) { goto Block_4; } } else { if (nextLexem == ":") { goto IL_A4; } text = nextLexem; } } this.ReportError("Low level scanning error in the statement header.", new object[0]); return; Block_4: this.ReportError("Failed to read fault injection tag component.", new object[0]); return; IL_A4: if (string.IsNullOrEmpty(text)) { this.ReportError("Colon is not preceded with component name.", new object[0]); return; } TraceComponentInfo traceComponentInfo = this.CreateComponentIfNeccessary(text, true); if (traceComponentInfo == null) { this.ReportError("Not a component.", new object[0]); return; } if (!this.ReadFaultInjectionType(ref line, ref type)) { this.ReportError("Failed to read fault injection type.", new object[0]); return; } if (!this.ReadFaultInjectionLid(ref line, ref key)) { this.ReportError("Failed to read fault injection LID.", new object[0]); return; } if (!this.ReadFaultInjectionParameters(ref line, ref parameters)) { this.ReportError("Failed to read fault injection parameters.", new object[0]); return; } lock (this.FaultInjectionConfig) { FaultInjectionTagComponentConfig faultInjectionTagComponentConfig = null; FaultInjectionComponentConfig faultInjectionComponentConfig = null; if (!this.FaultInjectionConfig.TryGetValue(traceComponentInfo.ComponentGuid, out faultInjectionTagComponentConfig)) { faultInjectionTagComponentConfig = new FaultInjectionTagComponentConfig(); this.FaultInjectionConfig.Add(traceComponentInfo.ComponentGuid, faultInjectionTagComponentConfig); } if (!faultInjectionTagComponentConfig.TryGetValue(empty, out faultInjectionComponentConfig)) { faultInjectionComponentConfig = new FaultInjectionComponentConfig(); faultInjectionTagComponentConfig.Add(empty, faultInjectionComponentConfig); } faultInjectionComponentConfig[key] = new FaultInjectionPointConfig(type, parameters); } }
public void TraceTest <T>(uint lid, ref T objectToChange) { string text = ExTraceConfiguration.Instance.ComponentInjection(); ExTraceGlobals.TracingTracer.TraceDebug <uint, string>(35221, (long)((ulong)lid), "TraceTest called for LID:{0}, TagIdentifier:'{1}'.", lid, text); if (base.IsTraceEnabled(TraceType.FaultInjection)) { if (ExTraceConfiguration.DisableAllTraces != null && ExTraceConfiguration.DisableAllTraces.Contains(this.category)) { ExTraceGlobals.TracingTracer.TraceDebug <Guid>(56316L, "Component: {0} has all traces temporary disabled for this thread.", this.category); return; } ExTraceGlobals.TracingTracer.TraceDebug <Guid, uint, string>(51605, (long)((ulong)lid), "FI tracing is enabled for category:{0}, lid:{1}, tagIdentifier:'{2}'.", this.category, lid, text); FaultInjectionTagComponentConfig faultInjectionTagComponentConfig = null; if (ExTraceConfiguration.Instance.FaultInjectionConfiguration.TryGetValue(this.category, out faultInjectionTagComponentConfig)) { FaultInjectionComponentConfig faultInjectionComponentConfig = null; if (faultInjectionTagComponentConfig.TryGetValue(text, out faultInjectionComponentConfig) || faultInjectionTagComponentConfig.TryGetValue(string.Empty, out faultInjectionComponentConfig)) { ExTraceGlobals.TracingTracer.TraceDebug <string>(33320, (long)((ulong)lid), "Tracing found for tag identifier:'{0}'", text); if (ExTraceConfiguration.DisabledLids != null && ExTraceConfiguration.DisabledLids.Contains(lid)) { ExTraceGlobals.TracingTracer.TraceDebug <uint>(43932, (long)((ulong)lid), "LID:{0} is temporary disabled for this thread.", lid); return; } FaultInjectionPointConfig faultInjectionPointConfig = null; if (faultInjectionComponentConfig.TryGetValue(lid, out faultInjectionPointConfig)) { ExTraceGlobals.TracingTracer.TraceDebug <FaultInjectionType, uint>(45461, (long)((ulong)lid), "Tracing found for a configuration of type:{0} for lid:{1}", faultInjectionPointConfig.Type, lid); string valueToCompareTo = null; InjectionComparisonOperator comparisonOperator = InjectionComparisonOperator.Skip; List <string> expectedCallStack = null; switch (faultInjectionPointConfig.Type) { case FaultInjectionType.None: break; case FaultInjectionType.Sync: { int condition = FaultInjectionTrace.GetCondition(faultInjectionPointConfig.Parameters, out comparisonOperator, out valueToCompareTo); if (condition < faultInjectionPointConfig.Parameters.Count) { expectedCallStack = faultInjectionPointConfig.Parameters.GetRange(condition, faultInjectionPointConfig.Parameters.Count - condition); } if (FaultInjectionTrace.ValidateCondition <T>(valueToCompareTo, ref objectToChange, comparisonOperator) && FaultInjectionTrace.ValidateCallStack(lid, expectedCallStack)) { ExTraceGlobals.TracingTracer.TraceInformation <uint>(59951, (long)((ulong)lid), "FI.Sync[lid:{0}]", lid); FaultInjectionTrace.InjectSync(lid, text); return; } break; } case FaultInjectionType.Exception: if (faultInjectionPointConfig.Parameters != null && 0 < faultInjectionPointConfig.Parameters.Count) { int condition2 = FaultInjectionTrace.GetCondition(faultInjectionPointConfig.Parameters, out comparisonOperator, out valueToCompareTo); if (condition2 < faultInjectionPointConfig.Parameters.Count) { string text2 = faultInjectionPointConfig.Parameters[condition2]; if (condition2 + 1 < faultInjectionPointConfig.Parameters.Count) { expectedCallStack = faultInjectionPointConfig.Parameters.GetRange(condition2 + 1, faultInjectionPointConfig.Parameters.Count - condition2 - 1); } if (FaultInjectionTrace.ValidateCondition <T>(valueToCompareTo, ref objectToChange, comparisonOperator) && FaultInjectionTrace.ValidateCallStack(lid, expectedCallStack)) { this.EnsureExceptionInjectionCallbackExists(); ExTraceGlobals.TracingTracer.TraceInformation <uint, string>(43567, (long)((ulong)lid), "FI.Exception[lid:{0}] {1}", lid, text2); FaultInjectionTrace.InjectException(this.category, text2); return; } } } break; case FaultInjectionType.Investigate: ExTraceGlobals.TracingTracer.TraceInformation <StackTrace>(53653, 0L, "Tracing FaultInjectionType.Investigate with stack trace: {0}", new StackTrace()); return; case FaultInjectionType.ChangeValue: if (faultInjectionPointConfig.Parameters != null && 0 < faultInjectionPointConfig.Parameters.Count) { int condition3 = FaultInjectionTrace.GetCondition(faultInjectionPointConfig.Parameters, out comparisonOperator, out valueToCompareTo); string text3 = null; if (condition3 < faultInjectionPointConfig.Parameters.Count) { text3 = faultInjectionPointConfig.Parameters[condition3]; } if (string.IsNullOrEmpty(text3)) { throw new InvalidOperationException("Expected non-null and non-empty string: string.IsNullOrEmpty(valueToChangeTo)"); } if (condition3 + 1 < faultInjectionPointConfig.Parameters.Count) { expectedCallStack = faultInjectionPointConfig.Parameters.GetRange(1, faultInjectionPointConfig.Parameters.Count - 1); } object obj = null; if (FaultInjectionTrace.ValidateCondition <object>(valueToCompareTo, ref obj, comparisonOperator) && FaultInjectionTrace.ValidateCallStack(lid, expectedCallStack)) { ExTraceGlobals.TracingTracer.TraceInformation <uint, T, string>(55855, (long)((ulong)lid), "FI.ChangeValue[lid:{0}] {1} => {2}", lid, objectToChange, text3); FaultInjectionTrace.StringToValue <T>(text3, ref objectToChange); } } break; default: return; } } } } } }