private IFrontEndController CreateControllerWithProfiler(PathTable pathTable, SymbolTable symbolTable) { var frontEndFactory = new FrontEndFactory(); var profilerDecorator = new ProfilerDecorator(); // When evaluation is done we materialize the result of the profiler frontEndFactory.AddPhaseEndHook(EnginePhases.Evaluate, () => { var entries = profilerDecorator.GetProfiledEntries(); var materializer = new ProfilerMaterializer(pathTable); var reportDestination = Configuration.FrontEnd.ProfileReportDestination(pathTable); Logger.Log.MaterializingProfilerReport(LoggingContext, reportDestination.ToString(pathTable)); try { materializer.Materialize(entries, reportDestination); } catch (BuildXLException ex) { Logger.Log.ErrorMaterializingProfilerReport(LoggingContext, ex.LogEventErrorCode, ex.LogEventMessage); } }); return(TryCreateFrontEndController( frontEndFactory, profilerDecorator, Configuration, symbolTable, LoggingContext, Collector, collectMemoryAsSoonAsPossible: CollectMemoryAsSoonAsPossible, statistics: m_statistics)); }
private IFrontEndController CreateControllerWithDebugger(PathTable pathTable, SymbolTable symbolTable) { var confPort = Configuration.FrontEnd.DebuggerPort(); var debugServerPort = confPort != 0 ? confPort : DebugServer.DefaultDebugPort; var pathTranslator = GetPathTranslator(Configuration.Logging, pathTable); var debugState = new DebuggerState(pathTable, LoggingContext, DScriptDebugerRenderer.Render, new DScriptExprEvaluator(LoggingContext)); var debugServer = new DebugServer(LoggingContext, debugServerPort, (debugger) => new DebugSession(debugState, pathTranslator, debugger)); Task <IDebugger> debuggerTask = debugServer.StartAsync(); var evaluationDecorator = new LazyDecorator(debuggerTask, Configuration.FrontEnd.DebuggerBreakOnExit()); var frontEndFactory = new FrontEndFactory(); frontEndFactory.AddPhaseStartHook(EnginePhases.Evaluate, () => { if (!debuggerTask.IsCompleted) { Logger.Log.WaitingForClientDebuggerToConnect(LoggingContext, debugServer.Port); } debuggerTask.Result?.Session.WaitSessionInitialized(); }); frontEndFactory.AddPhaseEndHook(EnginePhases.Evaluate, () => { // make sure the debugger is shut down at the end (unnecessary in most cases, as the debugger will shut itself down after completion) debugServer.ShutDown(); debuggerTask.Result?.ShutDown(); }); return(TryCreateFrontEndController( frontEndFactory, evaluationDecorator, Configuration, symbolTable, LoggingContext, Collector, collectMemoryAsSoonAsPossible: CollectMemoryAsSoonAsPossible, statistics: m_statistics)); }