Exemple #1
0
        internal static int GetEngineIgnoreCount(BreakOn breakOn, uint hitCount)
        {
            var count = 0;

            switch (breakOn.Kind)
            {
            case BreakOnKind.Always:
                count = 0;
                break;

            case BreakOnKind.Equal:
            case BreakOnKind.GreaterThanOrEqual:
                count = (int)breakOn.Count - (int)hitCount - 1;
                if (count < 0)
                {
                    count = 0;
                }
                break;

            case BreakOnKind.Mod:
                count = (int)(breakOn.Count - hitCount % breakOn.Count - 1);
                break;
            }
            return(count);
        }
 public NodeBreakpoint(NodeDebugger process, FilePosition target, bool enabled, BreakOn breakOn, string condition) {
     _process = process;
     _target = target;
     _enabled = enabled;
     _breakOn = breakOn;
     _condition = condition;
 }
Exemple #3
0
 public NodeBreakpoint(NodeDebugger process, FilePosition target, bool enabled, BreakOn breakOn, string condition)
 {
     this._process   = process;
     this._target    = target;
     this._enabled   = enabled;
     this._breakOn   = breakOn;
     this._condition = condition;
 }
Exemple #4
0
 internal static bool GetEngineEnabled(bool enabled, BreakOn breakOn, uint hitCount)
 {
     if (enabled && breakOn.Kind == BreakOnKind.Equal && hitCount >= breakOn.Count)
     {
         // Disable BreakOnKind.Equal breakpoints if hit count "exceeds" pass count
         return(false);
     }
     return(enabled);
 }
 internal static NodeBreakpoint AddBreakPoint(
     NodeDebugger newproc,
     string fileName,
     int line,
     int column,
     bool enabled = true,
     BreakOn breakOn = new BreakOn(),
     string condition = ""
 ) {
     NodeBreakpoint breakPoint = newproc.AddBreakpoint(fileName, line, column, enabled, breakOn, condition);
     breakPoint.BindAsync().WaitAndUnwrapExceptions();
     return breakPoint;
 }
 public NodeBreakpointBinding(NodeBreakpoint breakpoint, FilePosition target, FilePosition position, int breakpointId, int? scriptId, bool fullyBound) {
     _breakpoint = breakpoint;
     _target = target;
     _position = position;
     _breakpointId = breakpointId;
     _scriptId = scriptId;
     _enabled = breakpoint.Enabled;
     _breakOn = breakpoint.BreakOn;
     _condition = breakpoint.Condition;
     _engineEnabled = GetEngineEnabled();
     _engineIgnoreCount = GetEngineIgnoreCount();
     _fullyBould = fullyBound;
 }
Exemple #7
0
 public NodeBreakpointBinding(NodeBreakpoint breakpoint, FilePosition target, FilePosition position, int breakpointId, int?scriptId, bool fullyBound)
 {
     this._breakpoint        = breakpoint;
     this._target            = target;
     this._position          = position;
     this._breakpointId      = breakpointId;
     this._scriptId          = scriptId;
     this._enabled           = breakpoint.Enabled;
     this._breakOn           = breakpoint.BreakOn;
     this._condition         = breakpoint.Condition;
     this._engineEnabled     = GetEngineEnabled();
     this._engineIgnoreCount = GetEngineIgnoreCount();
     this._fullyBould        = fullyBound;
 }
        public void CreateSetBreakpointCommandOnRemoteFile() {
            // Arrange
            const int commandId = 3;
            const int line = 2;
            const int column = 0;
            const string fileName = @"module.js";
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, true);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"^[Mm][Oo][Dd][Uu][Ll][Ee]\\\\.[Jj][Ss]$\",\"ignoreCount\":1}}}}",
                    commandId, line, column),
                setBreakpointCommand.ToString());
        }
        internal async Task <bool> SetBreakOnAsync(BreakOn breakOn, bool force = false)
        {
            if (!force && _breakOn.Kind == breakOn.Kind && _breakOn.Count == breakOn.Count)
            {
                return(true);
            }

            SyncCounts();

            bool engineEnabled = GetEngineEnabled(_enabled, breakOn, HitCount);
            bool?enabled       = (_engineEnabled != engineEnabled) ? (bool?)engineEnabled : null;

            int engineIgnoreCount = GetEngineIgnoreCount(breakOn, HitCount);
            await Process.UpdateBreakpointBindingAsync(_breakpointId, ignoreCount : engineIgnoreCount, enabled : enabled, validateSuccess : true).ConfigureAwait(false);

            _engineEnabled     = engineEnabled;
            _engineIgnoreCount = engineIgnoreCount;
            _breakOn           = breakOn;

            return(true);
        }
        public void CreateSetBreakpointCommand() {
            // Arrange
            const int commandId = 3;
            const int moduleId = 5;
            const int line = 2;
            const int column = 0;
            const string fileName = "module.js";
            var module = new NodeModule(moduleId, fileName);
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptId\",\"target\":{3},\"ignoreCount\":1}}}}",
                    commandId, line, column, module.Id),
                setBreakpointCommand.ToString());
        }
        /// <summary>
        /// Adds a breakpoint in the specified file.
        /// </summary>
        public NodeBreakpoint AddBreakpoint(string fileName, int line, int column, bool enabled = true, BreakOn breakOn = new BreakOn(), string condition = null) {
            var target = new FilePosition(fileName, line, column);

            return new NodeBreakpoint(this, target, enabled, breakOn, condition);
        }
        public void ProcessSetBreakpointResponse() {
            // Arrange
            const int commandId = 3;
            const int moduleId = 33;
            const int line = 2;
            const int column = 0;
            const string fileName = "module.js";
            var module = new NodeModule(moduleId, fileName);
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);
            var setBreakpointCommand = new SetBreakpointCommand(commandId, module, breakpoint, false, false);
            JObject breakpointResponse = SerializationTestData.GetSetBreakpointResponse();

            // Act
            setBreakpointCommand.ProcessResponse(breakpointResponse);

            // Assert
            Assert.AreEqual(2, setBreakpointCommand.BreakpointId);
            Assert.AreEqual(0, setBreakpointCommand.Column);
            Assert.AreEqual(0, setBreakpointCommand.Line);
            Assert.AreEqual(false, setBreakpointCommand.Running);
            Assert.AreEqual(33, setBreakpointCommand.ScriptId);
        }
        public void CreateSetBreakpointCommandOnLocalFile() {
            // Arrange
            const int commandId = 3;
            const int line = 2;
            const int column = 0;
            const string fileName = @"c:\module.js";
            var breakOn = new BreakOn(BreakOnKind.Equal, 2);
            var position = new FilePosition(fileName, line, column);
            var breakpoint = new NodeBreakpoint(null, position, true, breakOn, null);

            // Act
            var setBreakpointCommand = new SetBreakpointCommand(commandId, null, breakpoint, false, false);

            // Assert
            Assert.AreEqual(commandId, setBreakpointCommand.Id);
            Assert.AreEqual(
                string.Format(
                    "{{\"command\":\"setbreakpoint\",\"seq\":{0},\"type\":\"request\",\"arguments\":{{\"line\":{1},\"column\":{2},\"type\":\"scriptRegExp\",\"target\":\"{3}\",\"ignoreCount\":1}}}}",
                    commandId, line, column, SetBreakpointCommand.CreateLocalScriptRegExp(fileName).Replace(@"\", @"\\")),
                setBreakpointCommand.ToString());
        }
 internal TestStep(
     TestAction action = TestAction.None,
     int? expectedEntryPointHit = null,
     int? expectedBreakpointHit = null,
     int? expectedStepComplete = null,
     string expectedBreakFile = null,
     ExceptionInfo expectedExceptionRaised = null,
     int? targetBreakpoint = null,
     int? targetBreakpointColumn = null,
     string targetBreakpointFile = null,
     uint? expectedHitCount = null,
     uint? hitCount = null,
     bool? enabled = null,
     BreakOn? breakOn = null,
     string condition = null,
     bool builtin = false,
     bool expectFailure = false,
     bool expectReBind = false,
     Action<NodeDebugger, NodeThread> validation = null,
     int? expectedExitCode = null,
     string expectedBreakFunction = null
 ) {
     _action = action;
     _expectedEntryPointHit = expectedEntryPointHit;
     _expectedBreakpointHit = expectedBreakpointHit;
     _expectedStepComplete = expectedStepComplete;
     _expectedBreakFile = expectedBreakFile;
     _expectedExceptionRaised = expectedExceptionRaised;
     _targetBreakpointFile = targetBreakpointFile;
     _targetBreakpoint = targetBreakpoint;
     _targetBreakpointColumn = targetBreakpointColumn;
     _expectedHitCount = expectedHitCount;
     _hitCount = hitCount;
     _enabled = enabled;
     _breakOn = breakOn;
     _condition = condition;
     _builtin = builtin;
     _expectFailure = expectFailure;
     _expectReBind = expectReBind;
     _validation = validation;
     _expectedExitCode = expectedExitCode;
     _expectedBreakFunction = expectedBreakFunction;
 }
 internal static int GetEngineIgnoreCount(BreakOn breakOn, uint hitCount) {
     int count = 0;
     switch (breakOn.Kind) {
         case BreakOnKind.Always:
             count = 0;
             break;
         case BreakOnKind.Equal:
         case BreakOnKind.GreaterThanOrEqual:
             count = (int)breakOn.Count - (int)hitCount - 1;
             if (count < 0) {
                 count = 0;
             }
             break;
         case BreakOnKind.Mod:
             count = (int)(breakOn.Count - hitCount % breakOn.Count - 1);
             break;
     }
     return count;
 }
 internal static bool GetEngineEnabled(bool enabled, BreakOn breakOn, uint hitCount) {
     if (enabled && breakOn.Kind == BreakOnKind.Equal && hitCount >= breakOn.Count) {
         // Disable BreakOnKind.Equal breakpoints if hit count "exceeds" pass count 
         return false;
     }
     return enabled;
 }
        internal async Task<bool> SetBreakOnAsync(BreakOn breakOn, bool force = false) {
            if (!force && _breakOn.Kind == breakOn.Kind && _breakOn.Count == breakOn.Count) {
                return true;
            }

            SyncCounts();

            bool engineEnabled = GetEngineEnabled(_enabled, breakOn, HitCount);
            bool? enabled = (_engineEnabled != engineEnabled) ? (bool?)engineEnabled : null;

            int engineIgnoreCount = GetEngineIgnoreCount(breakOn, HitCount);
            await Process.UpdateBreakpointBindingAsync(_breakpointId, ignoreCount: engineIgnoreCount, enabled: enabled, validateSuccess: true).ConfigureAwait(false);

            _engineEnabled = engineEnabled;
            _engineIgnoreCount = engineIgnoreCount;
            _breakOn = breakOn;

            return true;
        }