Step by step debugging

In addition to the cycle by cycle execution mode, the debugger has a rich collection of powerful features for making step by step debugging in the source code of your application. The step by step feature is completed by the possibility to place breakpoints in the source code of the application. The debugger also shows you the call stack of called UDFBs and sub-programs when stepping. Step by step debugging is available:

- in ST and IL text programs (a step is a statement)
- in LD program (a step is a rung)
- in FBD (a step is a graphic symbol corresponding to an action)

Step by step debugging is not possible in SFC programs.

Important notes:

  • Step by step debugging is available only if the project has been compiled with the "DEBUG" option. This option can be selected from the project compiling options dialog box.
  • An application compiled in DEBUG mode includes additional information for stepping. This leads to bigger code size and less performances. It is recommended to compile your application in RELEASE mode when the debugging is finished.

  • Step by step debugging may be not supported on some target systems. Please refer to OEM instructions for further details about available features.

There are two possibilities for entering the step by step debugging mode:

- Place a breakpoint in a program (using the "Build / Set-Remove Breakpoint" command). When the breakpoint is reached, the execution stops at the specified location and you can step further in the program.
- When the target is in cycle stepping mode (STOP), you can step at the beginning of the first program.

The following commands are available for stepping, either from the main control panel, or from the "Build" menu of editors:

Step over: If the next instruction is a call of a function block or a sub-program, the execution continues up to the end of the called block.
Step in: If the next instruction is a call of a function block or a sub-program, the next step will be at the beginning of the called block.
Step out: If the current stepping position is in a called function block or a sub-program, the execution continues up to the end of the block.

In addition to these commands, you can at any time:

- execute the cycle (from the current position up to the end of the last program)
- restart the target in "normal" execution mode (RUN)

Breakpoints

To put or remove a breakpoint in a program, use the "Build / Set-Remove Breakpoint" menu command. If the current position is not on a valid line for stepping, the breakpoint is automatically moved to the nearest valid position.

Breakpoints can be placed in programs, sub-programs or UDFBs. They are not available in SFC programs.

You can see the list of active breakpoints in the Log Window or in the output window of an editor. From here you have the possibility to remove all breakpoints in a single command. At any moment you can double click on a breakpoint in the Log window to open the corresponding program at the breakpoint location.

The call stack

When stepping, the Call Stack is available in the Log Window or in the output window of editors. It shows the stack of called function blocks and/or sub-programs, from the top level calling program up to the current stepping position. For a UDFB, the Call Stack also indicates which instance of the UDFB is executed.

At any moment you can double click on a line of the Call Stack to open the corresponding program.