top

Using JS Debugger: 2010 and 2011 Emulators

Published 2014-10-28 | (Compatible with SDK 2.5,3.5 and 2011,2012 models)

Using JS Debugger

Note

This document explains how to use the JS Debugger with the 2010 and 2011 Emulators. To learn about the 2012 and future Emulators, please read Using JS Debugger : 2012 and Later Emulators.

Debug Menu

To start debugging:

  1. Open a tutorial in the SDK. The Debug menu is not displayed if no JavaScript file is opened.

    Figure: Debug menu not displayed

  2. Open a JavaScript file. The full menu is displayed.

    Figure: Debug menu

Only the Start Debugging item is enabled in the Debug menu. The other items are disabled.

Breakpoints

Use breakpoints when dealing with large scripts. The red dot on the marker margin of the source pane indicates that a breakpoint is set on that line. The breakpoint pane shows information about the script name and the breakpoint’s line number. Setting a breakpoint in the source pane updates the breakpoint list in the breakpoint pane, as shown below.

Figure: Breakpoint pane

New Breakpoints

To set a new breakpoint:

  1. Select the line on which the breakpoint is to be set.
  2. Select the Debug menu.
  3. Click Add/Remove Breakpoint.

Figure: Adding a new breakpoint

If the line selected in step 1 does not already have a breakpoint, a new one is created. A red point in the line number margin marks the breakpoint.

Figure: Breakpoint created at line number 27

Remove Breakpoints

To remove a breakpoint:

  1. Select the breakpoint line.
  2. Select the Debug menu.
  3. Click Add/Remove Breakpoint .

Figure: Removing a breakpoint

After step 3, the breakpoint is removed.

Figure: Breakpoint removed

Remove All Breakpoints

To remove all breakpoints:

  1. Select the breakpoint line.
  2. Select the Debug menu.
  3. Click Remove All Breakpoints .

Figure: Removing all breakpoints in the project

After step 3, all breakpoints in the project are removed.

Figure: No breakpoints in the project

Start Debugging

To start debugging:

  1. Select the Debug menu.
  2. Click Start Debugging or press the F5 button. The program starts executing and halts at the first breakpoint.
  3. Set breakpoints on lines 24, 27, 31 and 35 before starting debugging. For more information, see New Breakpoints.

Figure: Start Debugging item in the Debug menu

The debugging halts at line 24.

Figure: Execution halts at the breakpoint in line 24

Stop Debugging

To stop debugging:

  1. Select the Debug menu.
  2. Click Stop Debugging. The program stops executing.

Figure: Stop Debugging item in the Debug menu

Continue

The Continue feature is used to navigate to the next breakpoint if the control is halted at a breakpoint. If there are no further breakpoints, it causes the script to finish executing uninterrupted. The figure below shows two breakpoints on lines 35 and 38.

Figure: Breakpoints on lines 35 and 38

To continue:

  1. Select the Debug menu.
  2. Click the Continue item.

Figure: Continue item in the Debug menu

The execution is navigated to line 38 where the next breakpoint is.

Figure: Execution point moves to the breakpoint on line 38

Step Over

The Step Over feature is used to go to the next line in the debugging of the project.

To step over:

  1. Select the Debug menu.
  2. Click the Step Over item. The program execution halts at the next line.

Figure: Step Over item in the Debug menu

When you click Step Over, the execution point moves from line 115 to the next line, 116.

Figure: Execution point moves to line 116

Step Into

The Step Into feature is used to move to a function and halt on the next line.

To step into a function:

  1. Select the Debug menu.
  2. Click the Step Into item. The program execution moves into the function and halts on the next line.

Figure: Step Into item in the Debug menu

Step Out

The Step Out feature is used to finish running the current function and then halt in the calling function.

To step out:

  1. Select the Debug menu.
  2. Click the Step Out menu item. The program execution finishes the current function and halts in the calling function.

Figure: Step Out item in the Debug menu