Debugging the RT services library

To track down problems in an application built by DevOps Model RealTime, it is often necessary to debug into the RT services library implementation. This article describes the steps to take to be able to debug the C++ implementation of the RT services library.

An Model RealTime installation does not contain prebuilt debug configurations of the RT services library. Therefore, you have to start by building a debug configuration:

  1. Copy the <Model RealTime-install-dir>/rsa_rt/C++/TargetRTS folder to a place where you have write access.
  2. 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. Open the file libset.mk 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. 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. Run the following command: rtperl Build.pl <configuration> <make tool> all where <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. For this example, the command line looks like this: 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.
  6. 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>:
    libObjecTime.a
    libObjecTimeTypes.a
    Also, there is an object file for the main function in the folder. A known issue that might occur with certain versions of the build tools involved is that the archive command fails to produce the two libraries from the object files. If this occurs, you can modify the archive command in the makefile main.mk to not use the *.olist files. For example, change
    @ $(AR_CMD) $(LIBOUT_OPT) $(LIBOUT_TAG)"$@" "%A.olist"
    to
    @ $(AR_CMD) $(LIBOUT_OPT) $(LIBOUT_TAG)"$@" $(A_OBJECTS)
  7. 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 the TC. Clean it first if necessary.
  9. Follow the steps described in Debugging a generated RT application using CDT to start debugging the application using CDT.