示例#1
0
 /// <summary>
 /// Constructs a new DebugLocator based on a source locator and current line information.
 /// </summary>
 /// <param name="locator">The source locator.</param>
 /// <param name="line">The current line number (1-based)</param>
 /// <param name="linePos">The current line position (1-based)</param>
 public DebugLocator(DebugLocator locator, int line, int linePos) : base()
 {
     _locator = locator.Locator;
     _line    = locator.Line < 1 ? line : (locator.Line + Math.Max(line - 1, 0));
     linePos  = Math.Max(linePos - 1, 0);
     _linePos = locator.Line == line?Math.Max(locator.LinePos - 1, 0) + linePos : linePos;
 }
示例#2
0
        private bool ShouldBreak(ServerProcess process, PlanNode node)
        {
            if (_disposed)
            {
                return(false);
            }

            if (process.ShouldBreak())
            {
                return(true);
            }

            if (_breakpoints.Count > 0)
            {
                DebugLocator currentLocation = process.ExecutingProgram.GetCurrentLocation();

                // Determine whether or not a breakpoint has been hit
                for (int index = 0; index < _breakpoints.Count; index++)
                {
                    Breakpoint breakpoint = _breakpoints[index];
                    if
                    (
                        (breakpoint.Locator == currentLocation.Locator) &&
                        (breakpoint.Line == currentLocation.Line) &&
                        ((breakpoint.LinePos == -1) || (breakpoint.LinePos == currentLocation.LinePos))
                    )
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#3
0
 public CallStackEntry(int index, string description, DebugLocator locator, string location, string statement)
 {
     _index       = index;
     _description = description;
     _locator     = locator;
     _location    = location;
     _statement   = statement;
 }
示例#4
0
        /// <summary>
        /// Dynamic debug locator used as the locator for all dynamic execution.
        /// </summary>
        //public static DebugLocator Dynamic = new DebugLocator("DYNAMIC", 1, 1);

        public override bool Equals(object other)
        {
            DebugLocator localOther = other as DebugLocator;

            if (localOther != null && localOther._locator == this._locator && localOther._line == this._line && localOther._linePos == this._linePos)
            {
                return(true);
            }
            else
            {
                return(base.Equals(other));
            }
        }
示例#5
0
        public override object InternalExecute(Program program, object argument1)
        {
            if (argument1 == null)
            {
                return(null);
            }

            string locator = (string)argument1;

            if (DebugLocator.IsProgramLocator(locator))
            {
                return(program.ServerProcess.ServerSession.CheckedDebugger.GetProgram(DebugLocator.GetProgramID(locator)).Source);
            }

            if (DebugLocator.IsOperatorLocator(locator))
            {
                return(new D4TextEmitter().Emit(((Schema.Operator)program.ResolveCatalogObjectSpecifier(DebugLocator.GetOperatorSpecifier(locator), true)).EmitStatement(EmitMode.ForCopy)));
            }

            throw new ServerException(ServerException.Codes.InvalidDebugLocator, locator);
        }
示例#6
0
 public SourceContext(string script, DebugLocator locator) : base()
 {
     _script  = script;
     _locator = locator;
 }
示例#7
0
        /// <summary>
        /// Returns the current call stack of a process.
        /// </summary>
        public CallStack GetCallStack(int processID)
        {
            lock (_syncHandle)
            {
                CheckPaused();

                ServerProcess process = _processes.GetProcess(processID);

                CallStack callStack = new CallStack();

                if (process.IsRunning)
                {
                    for (int programIndex = process.ExecutingPrograms.Count - 1; programIndex > 0; programIndex--)
                    {
                        Program  program     = process.ExecutingPrograms[programIndex];
                        PlanNode currentNode = program.CurrentNode;
                        bool     afterNode   = program.AfterNode;

                        foreach (RuntimeStackWindow window in program.Stack.GetCallStack())
                        {
                            callStack.Add
                            (
                                new CallStackEntry
                                (
                                    callStack.Count,
                                    window.Originator != null
                                                                                ? window.Originator.Description
                                                                                :
                                    (
                                        program.Code != null
                                                                                                ? program.Code.Description
                                                                                                : window.Locator.Locator
                                    ),
                                    currentNode != null
                                                                                ?
                                    new DebugLocator
                                    (
                                        window.Locator,
                                        afterNode ? currentNode.EndLine : currentNode.Line,
                                        (afterNode && currentNode.Line != currentNode.EndLine) ? currentNode.EndLinePos : currentNode.LinePos
                                    )
                                                                                : new DebugLocator(window.Locator, -1, -1),
                                    window.Originator != null
                                                                                ? DebugLocator.OperatorLocator(window.GetOriginatingOperator().DisplayName)
                                                                                : DebugLocator.ProgramLocator(program.ID),
                                    currentNode != null
                                                                                ? currentNode.SafeEmitStatementAsString()
                                                                                :
                                    (
                                        program.Code != null
                                                                                                ? program.Code.SafeEmitStatementAsString()
                                                                                                : "<no statement available>"
                                    )
                                )
                            );

                            currentNode = window.Originator;
                            afterNode   = false;
                        }
                    }
                }

                return(callStack);
            }
        }