Debugging the RT services library

When troubleshooting issues in an application built with DevOps Model RealTime, it may be necessary to look into the C++ implementation of the RT services library.

By default, a standard Model RealTime installation does not come with prebuilt debug configurations for the RT services library. As a result, you may have to set up a custom debug configuration.

This article provides a step-by-step guide for debugging the RT services library by creating your own custom debug configuration.

1. Copy the TargetRTS folder

Copy the <Model RealTime-install-dir>/rsa_rt/C++/TargetRTS folder to a directory where you have write permissions.

2. Modify the Target Configuration

In the libset folder, locate an appropriate target configuration to modify to become a debug configuration. In this example, we use the x64-VisualC++-17.0 configuration.

3. Update the libset.mk File

Open the libset.mk file and modify the variable LIBSETCCEXTRA to include the flag $(DEBUG_TAG). This variable expands to the debug compilation flag of the compiler. You might also want to remove any specified optimization flags.

4. Navigate to the src folder

Open a command prompt and go to the src folder. This folder contains all source code for the RT services library and also makefiles and scripts for building it.

5. Execute the Build command

Run the following command to build the RT services library:

rtperl Build.pl <configuration> <make tool> all

Here, <configuration> is the name of the target configuration to build (corresponds to a subfolder in the config folder, which should match the name of the libset subfolder you modified previously) and <make tool> is the name of the make tool to use for building the library.

Example for Windows

Execute the following command in the terminal:

rtperl Build.pl WinT.x64-VisualC++-17.0 nmake all

Note: The rtperl utility can be found inside the plugin com.ibm.xtools.umldt.rt.core.tools in the Model RealTime installation. Locate the version under 'tools' that matches your operating system and add its folder to your PATH variable before running the command.

Example for macOS

Execute the following command in the terminal:

make PERL=perl BUILDOPTS=-flat CONFIG=MacT.AArch64-Clang-15.x

6. Check the Build output

The Perl script builds two libraries, which make up the RT services library. The output of the build is placed in a folder called build-<configuration> that is created in the TargetRTS folder. For this example, it is called build-WinT.x64-VisualC++-17.0. This folder contains all the object files and also the *.olist files that contain the names of all object files. The object files are archived together to create the two libraries, which are located in lib/<configuration>:

Also, there is an object file for the main function in the folder.

A known issue that might occur with certain versions of build tools is that the archive command fails to produce the two libraries from the object files. If this happens, you can modify the archive command in the makefile main.mk to avoid using the *.olist files.

For example, change:

@ $(AR_CMD) $(LIBOUT_OPT) $(LIBOUT_TAG)"$@" "%A.olist"

to:

@ $(AR_CMD) $(LIBOUT_OPT) $(LIBOUT_TAG)"$@" $(A_OBJECTS)

7. Start debugging

Now you are ready to start debugging the RT services library. Double-click the TC for a C++ executable to use for the debug session. Go to the "Target Configuration" tab and modify the "Target services library" property to point at the folder where your copy of the TargetRTS folder is located. Also, add the $(DEBUG_TAG) tag to the "Compile arguments" property.

Note that for Visual Studio, you also need to add the /DEBUG option in "Link arguments".

8. Build Transformation Configuration

Clean the Transformation Configuration if necessary, and build it.

9. Follow the debugging process

Refer to the instructions described in Debugging a generated RT application using CDT to start debugging the application using CDT.