Exemple #1
0
        public List <Breakpoint> UpdateBreakpoints(
            AphidDebugSession session,
            Response response,
            string scriptFile,
            SourceBreakpoint[] sourceBreakpoints)
        {
            // Todo: better handle forward slashes
            var fullScriptFile = Path.GetFullPath(scriptFile).Replace('/', '\\');
            var lastWrite      = new FileInfo(fullScriptFile).LastWriteTime;

            //if (_codeCacheTime.TryGetValue(fullScriptFile, out var time) && time < lastWrite)
            //{
            //    _astMemoizer.Remove(fullScriptFile);
            //    _codeMemoizer.Remove(fullScriptFile);
            //    _codeCacheTime[fullScriptFile] = lastWrite;
            //}
            //else
            //{
            //    _codeCacheTime.Add(fullScriptFile, lastWrite);
            //}

            Cli.WriteInfoMessage("Parsing {0}", fullScriptFile);
            //var code = _codeMemoizer.Call(File.ReadAllText, fullScriptFile);
            var code = File.ReadAllText(fullScriptFile);

            var ast = _astMemoizer.Call(x => session.Parse(response, x), fullScriptFile);

            if (ast == null)
            {
                return(null);
            }

            var lineResolver = new AphidLineResolver();

            var breakpointExpressions = lineResolver.ResolveLineExpressions(
                ast,
                code,
                sourceBreakpoints);

            var bps    = new List <Breakpoint>();
            var j      = 0;
            var bpExps = new List <AphidExpression>();

            foreach (var exp in breakpointExpressions)
            {
                //var line = clientLines[j++];
                Program.Log("Setting breakpoint at index {0}: {1}",
                            exp.Index,
                            exp.ToString());
            }

            session.Interpreter.SetFileBreakpoints(
                fullScriptFile,
                breakpointExpressions.Select(x => x.Index).ToArray());

            return(sourceBreakpoints
                   .Select(x => new Breakpoint(true, x.line, x.column))
                   .ToList());;
        }
Exemple #2
0
        private static void RunSession(Stream inputStream, Stream outputStream)
        {
            Log("[s] Begin debug session");
            //System.Diagnostics.Debugger.Launch();
            DebugSession debugSession = new AphidDebugSession
            {
                TRACE          = trace_requests,
                TRACE_RESPONSE = trace_responses
            };

            debugSession.Start(inputStream, outputStream).Wait();

            if (logFile != null)
            {
                logFile.Flush();
                logFile.Close();
                logFile = null;
            }
        }