Using breakpoints

A breakpoint is a point in a program that, when reached, triggers some special behavior useful to the process of debugging.

A breakpoint causes the execution of a session to suspend at the location where the breakpoint is set.

This table shows the breakpoint types you can define in LN Studio:

Line breakpoints You can set a line breakpoint on an executable line in the source code. During the debugging, the session execution suspends before that line of code is executed. The debugger selects the session that has suspended and displays the stack frames on that session's stack. The line where the breakpoint was set is highlighted in the editor in the Debug perspective.
Method breakpoints You can set method breakpoints on the functions displayed in the Outline view. The session execution suspends when the execution reaches a function for which a breakpoint was set.
Watchpoints You can use watchpoints to monitor variables. There are two types of watchpoints:
  • Modification watchpoint. This is the default type. For this type of watchpoint, session execution suspends each time the variable being monitored is modified.
  • Condition watchpoint. For this type of watchpoint, session execution suspends when the variable gets a certain value.

You can change the watchpoint type through a Properties dialog in the Breakpoints view.

You cannot set a watchpoint on array elements.

You can set line breakpoints and watchpoints in the LN Studio script editor. You can set method breakpoints in the Outline view.

Breakpoints are displayed in the vertical script editor ruler and in the Breakpoints view.

You can enable and disable breakpoints via their context menus in the Breakpoints view.:

  • When a breakpoint is enabled, it causes a session to suspend whenever the breakpoint is reached. Enabled breakpoints are indicated with a blue circle. Resolved breakpoints are shown with a check mark overlay.
  • When a breakpoint is disabled, it does not cause sessions to suspend. Disabled breakpoints are indicated with a white circle.
Note: You cannot define breakpoints in report scripts. For a report, breakpoints must be defined in the report's debug script. To open the debug script, in the Overview tab in the Report Editor, click View Debug Script. The debug script is displayed in a separate tab in the editor area.

Adding line breakpoints

To set a line breakpoint:

  1. In the script editor, go to the line where you want to set the breakpoint.
  2. Double-click on the marker bar directly to the left of the line.

    Alternatively, right-click on the marker bar and, on the shortcut menu, select Toggle Breakpoint.

A new breakpoint marker appears on the marker bar. Also, the new breakpoint appears in the Breakpoints view.

Adding method breakpoints

To set a method breakpoint, complete one of these steps:

  • In the Outline view, right-click a function and, on the shortcut menu, select Toggle Method Breakpoint.
  • In the script editor, double-click the marker bar next to a line that is part of a function header.
  • In the script editor, right-click the marker bar next to a line that is part of a function header and, on the shortcut menu, select Toggle Breakpoint.

A new method breakpoint marker appears on the marker bar in the script editor. Also, the new breakpoint appears in the Breakpoints view.

Adding watchpoints

You can define watchpoints for local and global variables via the LN Studio script editor.

Adding a modification watchpoint for a local variable

To set a modification watchpoint for a local variable:

  1. In the script editor, select the variable (or table field) you want to monitor.
  2. Right-click and, on the shortcut menu, select Modification Watchpoint. A modification watchpoint marker appears in the editor's marker bar, and the new watchpoint is displayed in the Breakpoints view.

Adding a condition watchpoint for a local variable

To set a condition watchpoint for a local variable:

  1. In the script editor, select the variable (or table field) you want to monitor.
  2. Right-click and select Modification Watchpoint. A modification watchpoint marker appears in the editor's marker bar, and the new watchpoint is displayed in the Breakpoints view.
  3. Use the Properties dialog in the Breakpoints view to change the new watchpoint into a condition watchpoint.

    See Watchpoint properties.

Note: Alternatively, complete these steps:
  1. Right-click in the script editor and, on the shortcut menu, click Condition Watchpoint. The New Condition Watchpoint dialog is started.
  2. Specify the name of the variable (or table field) you want to monitor.
  3. Select Variable Value and indicate when the session must suspend.

    See Watchpoint properties.

Adding a watchpoint for an external or global variable

To set a condition or modification watchpoint for an external or global variable that does not occur in the source code you are editing:

  1. Right-click in the script editor and click Condition Watchpoint. The New Condition Watchpoint dialog is started.
  2. Specify the name of the variable (or table field) you want to monitor, and indicate when the session must suspend.

    See Watchpoint properties.

Note: When you define a watchpoint in the script editor, you must be sure that the selected text really is a variable or table field: the editor does not check this. In the editor you can select any piece of text, and subsequently define a watchpoint for it, which is completely useless.

When you define a condition or modification watchpoint, a watch expression is added automatically.

See Evaluating expressions.

Removing breakpoints

You can easily remove breakpoints when you no longer need them.

To remove a line breakpoint or a watchpoint:

  1. In the script editor, go to the line where the breakpoint is defined.
  2. Double-click on the breakpoint icon, or right-click the breakpoint icon and, on the shortcut menu, select Toggle Breakpoint.

To remove a method breakpoint, complete one of these steps:

  • In the Outline view, right-click the involved function and, on the shortcut menu, select Toggle Method Breakpoint.
  • In the script editor, go to the line where the breakpoint is defined and double-click on the breakpoint icon, or right-click the breakpoint icon and, on the shortcut menu, select Toggle Breakpoint.

You can also remove breakpoints in the Breakpoints view:

  • Right-click the breakpoint(s) to be removed and, on the shortcut menu, select Remove.
  • To remove all breakpoints in one go, on the shortcut menu of the Breakpoints view, click Remove All.

If you find yourself frequently adding and removing a breakpoint in the same place, consider disabling the breakpoint when you do not need it and enabling it when needed again.

See Breakpoints view.

Enabling and disabling breakpoints

You can disable and enable breakpoints as needed. When a breakpoint is disabled, session execution is not suspended by the presence of the breakpoint.

To disable a breakpoint, complete one of these steps:

  • Go to the Breakpoints view and clear the breakpoint's check box.
  • In the script editor, right-click the breakpoint in the marker bar and, on the shortcut menu, select Disable Breakpoint.

The breakpoint image changes to a white circle.

To enable a breakpoint, complete one of these steps:

  • Go to the Breakpoints view and select the breakpoint's check box.
  • In the script editor, right-click the breakpoint in the marker bar and, on the shortcut menu, select Enable Breakpoint.

The breakpoint image changes back to a blue circle.

Note: To disable all breakpoints in one go, use the Skip All Breakpoints command in the Breakpoints view.