Debugging a RTDLL with Visual Studio

The following steps will demonstrate a simple Visual Studio debug session, when the application uses an RTDLL. An RTDLL is a real-time dynamic linked library, similar to a Windows DLL, so it can be debugged within the Visual Studio instance that is debugging your application.

To debug an RTX application and an RTDLL, do the following:

Start Visual Studio and Open the Solution

In this tutorial, we will use Visual Studio 2015.

Make a copy and open the solution:

  1. Browse to the IntervalZero samples and make a copy of the RTDLL sample in a location where you have read/write permissions. The IntervalZero samples are located under Program Files\IntervalZero\RTX SDK\Samples, if you installed them to the default location.
  2. Start Microsoft Visual Studio and open an existing Solution using: File > Open > Project /Solution
  3. Browse to the copy of the RTDLL sample you created, select the solution RtxApp_wRTDLL_VS2015, and click OK.
  4. There are two projects that are part of this solution:

Open the application that will use the RTDLL:

The program that will use the DLL should start when debugging begins. To ensure this, right-click on the UsingRTDLL_VS2015 project from the Solutions Explorer window and selecting Set as StartUp Project from the pull-down menu.

 

Build the Solution

Steps:

  1. To select which configuration will be built, select Batch Build from the Build pull-down menu.
  2. This tutorial will only use the RTSSDebug configurations. Check only SampleRtDll_VS2015 RTSSDebug configuration and UsingRtDll RTSSDebug configuration. After configuration options have been selected, click Rebuild.
  3. Output from the build will be displayed in the Output window.

The solution directory will now have executable files for each of the projects in the subdirectory \bin\RTSSDebug.

  1. Register the RTDLL with the Subsystem using RtssRun /d.

Perform Debug of Program and RTDLL

NOTE:  Hard-coded and Data breakpoints are not supported.

Steps:

  1. Set the first breakpoint in program UsingRTDLL.c by double-clicking in the column to the left of the RtCreateTimer function call or by right-clicking on the line and clicking Breakpoint > Insert Breakpoint in the pop-up menu.

  1. Set a second breakpoint in program UsingRTDLL.c by double-clicking in the column to the left of the call to function toggle (pointed to by FunctionPtr). This function is located in the RTDLL.

 

  1. To start debugging, select Start Debugging from the Debug pull-down menu, or press the F5 key.

  1. If you get a message asking if you would like to rebuild the SampleRTDLL click No. A rebuild is not necessary since there were no changes since the previous build.
  1. The debugger will stop at the first breakpoint, pointed to by a yellow arrow in a red circle.

 

  1. At the first breakpoint, select the Modules debug window. If symbols are not loaded for either of the modules, right-click and select Load Symbols from the pull-down menu.

NOTE:  If Modules is not available from the status bar, select Modules from the Windows option in the Debug pull-down menu to open the modules window.

  1. If necessary, locate the symbol file in the RTSSDebug subdirectory. The output window should indicate that the symbols are loaded.
  2. To continue from the first breakpoint, select Continue from the Debug pull-down menu or press the F5 key.
  3. When the debugger stops at the second breakpoint, if this is the call to the toggle function, select Step Into or press the F11 key to step into the DLL function.

Focus will now turn to the SampleRTDLL.c source code.

  1. To continue, select Step Out from the Debug pull-down menu or press Shift+F11.

When focus returns to the SampleRTDLL.c program, you can select to Continue or to Stop Debugging from the Debug pull-down menu.  If you select Continue, program execution will continue until it completes or reaches another breakpoint. If you select Stop, program execution will halt.

Related Topics:

MiniTutorials: