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)); }