Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="raceDetectionEngine">IRaceDetectionEngine</param>
        /// <param name="configuration">Configuration</param>
        public RaceInstrumentationEngine(IRegisterRuntimeOperation raceDetectionEngine, Configuration configuration)
            : base(new Container(), new EngineOptions(),
                   new MonitorManager(raceDetectionEngine, configuration),
                   new ThreadMonitorManager(configuration))
        {
            if (SingletonEngine != null)
            {
                throw new InvalidOperationException("RaceInstrumentationEngine created more than once.");
            }

            SingletonEngine = this;

            // required?
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomainProcessExit);
            this.GetService <ISymbolManager>().AddStackFrameFilter(new StackFrameFilter());

            if (!ControllerEnvironment.IsMonitoringEnabled)
            {
                Console.WriteLine("ExtendedReflection monitor not enabled");
                throw new NotImplementedException("ExtendedReflection monitor not enabled");
            }

            ((IMonitorManager)this.GetService <MonitorManager>()).RegisterThreadMonitor(
                new ThreadMonitorFactory(this.GetService <ThreadMonitorManager>(),
                                         raceDetectionEngine, configuration));

            ((IMonitorManager)this.GetService <MonitorManager>()).RegisterObjectAccessThreadMonitor();

            this.ExecutionMonitor.Initialize();
            var tid = this.ExecutionMonitor.CreateThread();

            _ThreadContext.Start(this.ExecutionMonitor, tid);
        }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="testingEngine">ITestingEngine</param>
        /// <param name="configuration">Configuration</param>
        public RaceInstrumentationEngine(ITestingEngine testingEngine, Configuration configuration)
            : base(new Container(), new EngineOptions(),
                  new MonitorManager(testingEngine, configuration),
                  new ThreadMonitorManager(configuration))
        {
            if (SingletonEngine != null)
            {
                throw new InvalidOperationException("RaceInstrumentationEngine created more than once.");
            }

            SingletonEngine = this;

            // required?
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomainProcessExit);
            this.GetService<ISymbolManager>().AddStackFrameFilter(new StackFrameFilter());

            if (!ControllerEnvironment.IsMonitoringEnabled)
            {
                Console.WriteLine("ExtendedReflection monitor not enabled");
                throw new NotImplementedException("ExtendedReflection monitor not enabled");
            }

            ((IMonitorManager)this.GetService<MonitorManager>()).RegisterThreadMonitor(
               new ThreadMonitorFactory(this.GetService<ThreadMonitorManager>(),
               testingEngine, configuration));

            ((IMonitorManager)this.GetService<MonitorManager>()).RegisterObjectAccessThreadMonitor();

            this.ExecutionMonitor.Initialize();
            var tid = this.ExecutionMonitor.CreateThread();
            _ThreadContext.Start(this.ExecutionMonitor, tid);
        }