private async Task <int> AnalyzeAsync() { var debugServer = new DebugServer(LoggingContext, m_port, (d) => new DebugSession(m_state, m_pathTranslator, d)); Debugger = await debugServer.StartAsync(); Session = (DebugSession)Debugger.Session; Session.WaitSessionInitialized(); m_state.SetThreadState(XlgState); Debugger.SendEvent(new StoppedEvent(XlgState.ThreadId, "Break on start", "")); await Session.Completion; return(0); }
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)); }