5. QGen Model Debugger

5.1. Requirements and installation

The QGen Debugger is a separate add-on for QGen that can be acquired by contacting sales@adacore.com. You will have to proceed with the QGen installation before installing the QGen debugger, see Installing QGen.

The QGen Debugger package contains multiple tools including a compiler and a debugger that are not intended to be used independently from the QGen Debugger and are not supported outside of that usage.

5.4. Generating code and starting a debugging session

Once the project is successfully loaded inside GPS you should see the following icons:

_images/GPS_Toolbar.png

The left one will generate code using qgenc and the options specified inside the project file and then compile the executable using the generated code and any additional source file provided by the project file.

The right icon will compile like the left one but will also start a debugging session.

If you do not wish to generate code, but still need to build your executable and/or debug the model you can use the GPS menus Build > Project > Build all and Debug > Initialize > [project_name] > main.[c|adb].

If you open the model by double cliking on it gps will load it and open it in a new view, displaying all the blocks and signals (cf. image below)

_images/model_view.png

5.5. Debugging features

Once the debugger has started you can right click in the model view to display a contextual menu giving you access to the model debugging features.

_images/debugger_contextual.png

In the contextual menu hover on the Debug submenu to choose between the following options during debugging session

  1. Show the current execution pointer in the source code
  2. Set/Delete a breakpoint on the block (the corresponding breakpoints will be set or deleted inside the generated source code at the lines corresponding to the chosen block).
  3. Change the value of a signal to alter the corresponding variable value in the code by clicking on Set Value for signal. This is really valuable to force a model to reach a certain stage and test it with a variety of values.
  4. In the Models submenu the Show source code action will show the block corresponding source code in the generated source file.
  5. Force a signal to stay at a given value using Set Persistent value for signal and enter the desired value in the dialog box. This is similar to 3. but the effect will be persistent over the program iterations. This can be disabled using Disable Persistent value for signal entry of the menu.

During the execution the model view is also updated to show the current block under execution with a green outline, and the value for all the signals in the current subsystem. Some signal values will not be up to date at some point during the execution but you can refer to the source code to find out where this is the case.

_images/debugger_execution.png

You can navigate between subsystems by double clicking on a subsystem or using the Uparrow and LeftArrow buttons above the diagram to navigate to the parent or previous subsystem respectively. The model hierarchy is also represented in the outline panel when the diagram is under focus, and you can click on a subsystem to visit it. All current blocks from the current subsystem are also listed in the outline panel, clicking on a block will highlight item.

_images/debugger_outline.png

All signals values are updated when the displayed subsystem changes.

5.6. Advanced usage

5.6.1. Use a separate compiler/debugger/GPS version

You might be interested in using a different version of the tools packaged with the QGen Debugger. This is possible but please be aware that some features of the debugger might not work with older versions of the tools.

To specify which tools to use when launching GPS and the QGen debugger from MATLAB you must edit the file etc/qgen_tools.env in the QGen installation path. You can either add each necessary environment variable manually or on Unix*, simply run env >> etc/qgen_tools.env from your terminal.

To change the compiler/debugger within GPS go to Build > Settings > Toolchains and edit the Compiler path and Tools path as necessary.