Compiling Delphi 2006 Applications With Debug Information

Applies to TestComplete 15.47, last modified on January 20, 2023

Debug Info Agent™ exposes public, published, protected and private members of objects in Delphi applications as soon as the application is compiled with debug information. This topic explains how to include debug information into applications created with Borland Delphi 2006 for Win32. To learn how to prepare applications created with other Delphi versions, see Implementing Debug Info Agent™ Support in Applications.

The Delphi compiler generates debug information in the TD32 format, which is compiled into the application’s binary modules. However, it is possible to extract debug information into separate .tds files using the TestComplete StripTDS utility.

Debug Info Agent™ can work with both formats. However, we recommend that you create external .tds files for release builds of your products. This will decrease the overall size of your application. The TD32 format of debug information can be used for intermediate or special builds.

Below are detailed instructions on changing the project options to use the desired format of debug information.

Note: Debug Info Agent™ is incompatible with tools that change the debug information format. An example of such a tool is EurekaLog 7. We recommend that you disable EurekaLog when compiling an application aimed for automated testing with TestComplete. Otherwise, you will be unable to access private, protected and public methods and properties of your Delphi applications from tests.

External Debug Information (TDS Files)

The .tds files are created based on executables and DLLs compiled with TD32 debug information included. To remove debug information from modules and store them in separate .tds files, you can use the StripTDS utility that is shipped with TestComplete.

So, to create .tds files, you should first compile the tested Delphi application with debug information and then process the compiled modules with the StripTDS utility. Below are detailed steps:

  1. Change the project settings to compile the application with TD32 debug information:

    1. Open your project in Borland Delphi 2006 for Win32.

    2. Select Project | Options from Delphi’s main menu. This will open the Project Options dialog.

    3. Select to the Compiler category and enable the Debug information and Local symbols options in the Debugging group:

      Project Options: Compiler
      Note: It is possible to keep the Local symbols disabled, but in this case the names of some method parameters will not be displayed in the Object Browser panel.
    4. Switch to the Linker category and enable the Include TD32 debug info option in the EXE and DLL options group:

      Project Options: Linker
    5. Press OK to save the changes and close the Project Options dialog.

    6. Re-build the application.

  2. Strip the debug information from each compiled executable or DLL. You can do this by using the TestComplete StripTDS utility or the Turbo Debugger 32-bit Symbol Table Stripper utility that is shipped along with Borland Developer Studio 2006 (the utility is installed with Borland C++Builder 2006 and has the following path: <Program Files>\Borland\BDS\4.0\Bin\tdstrp32.exe). Both utilities perform the same actions - remove debug information from the binary files and save it to separate .tds files. However, the tdstrp32 utility can only process one file at a time whereas the TestComplete StripTDS utility supports file masks and recursive processing.

    For example, to process all EXE and DLL files in the C:\MyApp folder and its subfolders using the StripTDS utility, you can use the following command:

    StripTDS.exe -r -w C:\MyApp\*.exe;C:\MyApp\*.dll

    To do this using the tdstrp32 utility, run the following command:

    for /r "C:\MyApp" %f in (*.exe *.dll) do tdstrp32.exe -s "%~ff"

    or this one if processing is done from a batch file:

    for /r "C:\MyApp" %%f in (*.exe *.dll) do (
      tdstrp32.exe -s "%%~ff"
    )

    Note: Both utilities only work with those sections in the binary files that contain debug information. They do not change the code and data sections, so your modules will still work as designed.

Some notes concerning this approach:

  • The .tds files containing debug information must reside in the same folders that the appropriate modules of the tested application.

  • Even if the application is compiled with the Local symbols option enabled, the names of some method parameters may not be displayed in the Object Browser. If viewing parameter names is important to you (for instance, if you are developing new tests), compile the tested Delphi application with internal TD32 debug information (see below).

  • There is no need to distribute the generated .tds files with your application.

Internal Debug Information (TD32)

To compile your Delphi application with internal TD32 debug information, follow these steps:

  1. Open your project in Borland Delphi 2006 for Win32.

  2. Choose Project | Options from the main menu to open the Project Options dialog.

  3. Select the Compiler category and do the following:

    • Disable the Optimization option in the Code Generation group.
    • Enable the Debug information, Local symbols and Use Debug DCUs options in the Debugging group.
    Project Options: Compiler
    Note: It is possible to keep the Local symbols disabled, but in this case the names of some method parameters will not be displayed in the Object Browser panel.
  4. Switch to the Linker category and check the Include TD32 debug info option in the EXE and DLL options group:

    Project Options: Linker
  5. It is recommended that you turn off the Build with runtime packages option in the Packages category:

    Project Options: Packages

    If this property is checked, Delphi creates Borland package library (.bpl) files when compiling the application. TestComplete cannot access debug information in these files and some controls. If this property is unchecked, all information is included in a single executable and can be accessed by TestComplete. For more information about runtime packeges, see About Runtime Packages.

    If, for some reason, you cannot turn off the Build with runtime packages option, TestComplete may not be able to get access to the application's internal methods and properties. To resolve the problem, enable the Read debug information for statically linked libraries project option in TestComplete.
  6. Once you have completed these steps, click OK to save the changes and close the Project Options dialog.

  7. Re-build the application.

Remember to recompile the release version of your application without TD32 debug information in order to reduce the application size.

See Also

Debug Info Agent™
Debug Info Agent™ Specifics
Testing Delphi Applications - Overview

Highlight search results