Beispiel #1
0
 internal void GetState(out bool isRunning, out BreakPosition position)
 {
     lock (SyncRoot)
     {
         isRunning = _breaker == null;
         position  = _position;
     }
 }
Beispiel #2
0
 internal void GetState(
     out bool isRunning,
     out List <ProgramInfo> programs,
     out BreakPosition position,
     out List <Watch> watches,
     out ReadOnlyCollection <MondDebugContext.CallStackEntry> callStack)
 {
     lock (_sync)
     {
         isRunning = _breaker == null;
         programs  = _programs.ToList();
         position  = _position;
         watches   = _watches.ToList();
         callStack = _context?.CallStack;
     }
 }
Beispiel #3
0
        private void UpdateState(MondDebugContext context, int address)
        {
            var program   = context.Program;
            var debugInfo = program.DebugInfo;

            // find out where we are in the source code
            var statement = debugInfo.FindStatement(address);

            if (!statement.HasValue)
            {
                var position = debugInfo.FindPosition(address);

                if (position.HasValue)
                {
                    var line   = position.Value.LineNumber;
                    var column = position.Value.ColumnNumber;
                    statement = new MondDebugInfo.Statement(0, line, column, line, column);
                }
                else
                {
                    statement = new MondDebugInfo.Statement(0, -1, -1, -1, -1);
                }
            }

            // refresh all watches
            List <Watch> watches;

            lock (_sync)
                watches = _watches.ToList();

            foreach (var watch in watches)
            {
                RefreshWatch(_context, watch);
            }

            // apply new state and broadcast it
            MondValue message;

            lock (_sync)
            {
                var stmtValue = statement.Value;
                var programId = FindProgramIndex(program);

                _position = new BreakPosition(
                    programId,
                    stmtValue.StartLineNumber,
                    stmtValue.StartColumnNumber,
                    stmtValue.EndLineNumber,
                    stmtValue.EndColumnNumber);

                message                = new MondValue(MondValueType.Object);
                message["Type"]        = "State";
                message["Running"]     = false;
                message["Id"]          = _position.Id;
                message["StartLine"]   = _position.StartLine;
                message["StartColumn"] = _position.StartColumn;
                message["EndLine"]     = _position.EndLine;
                message["EndColumn"]   = _position.EndColumn;
                message["Watches"]     = new MondValue(watches.Select(Utility.JsonWatch));
                message["CallStack"]   = BuildCallStackArray(_context.CallStack);
            }

            Broadcast(message);
        }