informix
DataBlade Developers Kit User's Guide
Debugging and Testing DataBlade Modules on Windows NT

Debugging a DataBlade Module

Debugging a DataBlade module is usually an iterative process, repeated many times until the code is completely debugged. The "Creating a Simple User-Define Routine" exercise in the DBDK InfoShelf tutorial guides you through this process.

The debugging process on a local database server has the following general steps:

  1. Open the project.dsw file in Visual C++. You can do this in BladeSmith by clicking the MSDev button on the Generate DataBlade dialog box or by choosing Tools MSDev.
  2. The DBDK Visual C++ Add-In toolbar should be present in the Visual C++ program if you installed DBDK after you installed Visual C++. If it is not present, you must add it manually before you continue with the next step. See Manually Loading the Add-In for instructions.

  3. The DBDK Visual C++ Add-In prompts you to configure the session for your new DataBlade project. Click Yes to select a local server.
  4. Specify the project database server, database, and, optionally, the SQL script to initialize your database.
  5. See Specifying Properties for a Project for more information.

  6. Set appropriate breakpoints in one of the source code files.
  7. See Setting Breakpoints for instructions.

  8. Open the appropriate unit test file in Visual C++ and edit it to add appropriate SQL.
  9. See Editing Unit Test Files for more information.

  10. Click the Debug DataBlade Module button.
  11. If you need to specify an executable file for the debugging session, the Executable For Debug Session dialog box will prompt you to do so. Use the browse button to select %INFORMIXDIR%\bin\oninit.exe.
  12. If a dialog box appears, warning that oninit.exe does not have debugging information, click OK to begin debugging.
  13. The debugger runs until the first breakpoint.

  14. To resume debugging, choose Debug Go from the Visual C++ menu bar.
  15. When you pass all breakpoints and all routines return, IfxQuery displays the SQL results in your default browser.

  16. If necessary, edit and compile the source code.
  17. Repeat the procedure, as necessary.

The following sections describe some of these steps.

Important: If you attempt to start or stop the database server with the Services dialog box of the Control Panel during debugging, you receive an error. When the add-in starts the database server attached to the debugger, the database server does not run as a Windows NT service. To stop the database server, shut down the debugger.

Manually Loading the Add-In

The DBDK Visual C++ Add-In toolbar should be present in the Visual C++ program if you installed DBDK after you installed Visual C++. If it is not present, you must add it manually.

To manually load the Visual C++ Add-In

  1. Close your project.dsw file.
  2. Choose Tools Customize.
  3. On the Add-Ins and Macro Files page of the Customize dialog box, check the box for DBDKAddIn.1.
  4. If the box for DBDKAddIn.1 is already checked, uncheck it, close the Customize dialog box, and then repeat Steps 2 and 3.

  5. Click Close.
  6. Open your project.dsw file.

Specifying Properties for a Project

To debug a project, each DataBlade module project must have an associated database server and database.

When you first open a DataBlade module project in Visual C++, the Configure DBDK Visual C++ dialog box appears, prompting you to choose a database server and database. If you choose a local database server, you can use any of the add-in commands. If you choose a remote database server, you can use only the Upload DataBlade Module, Upload DataBlade SQL Scripts, and Register DataBlade Module commands.

You can choose an existing database from the DBDK Database list or, if you are using a local database server, type in a new database name. IfxQuery creates the database you specify if it does not exist when you run the Debug DataBlade Module command. If the database server you specified is a remote server, you must choose an existing database name.

You can also specify an SQL file to initialize your test database for the project in the Initialize Database File field. You can use the generated Setup.sql file in the src directory as your initialization file after you add SQL statements to it. See Editing Unit Test Files for a description of the Setup.sql file.

You can change the properties of a project at any time by clicking Configure DBDK Visual C++ Add-In button and completing the corresponding dialog box.

Setting Breakpoints

Before you start the debugger, set breakpoints in your source code.

To set breakpoints with Visual C++

  1. Open a source code file. You can do this by double-clicking a routine under the Globals node in the Class view.
  2. Right-click the line of code for which you want to set a breakpoint.
  3. Choose Insert Breakpoint.

Editing Unit Test Files

Before you start debugging, edit the unit test files to add the SQL statements necessary to debug your DataBlade module.

When you generate unit tests for a DataBlade module, BladeSmith generates the files listed in the following table in the src\tests directory.

Test Name Purpose
Setup.sql Optionally initializes the database. You can add SQL statements to create and populate the tables necessary for your debugging tests. If you specify this file as your initialization file in the Configure DBDK Visual C++ Add-In dialog box, IfxQuery automatically runs this file after it creates a new database.
Routine.sql Tests the user-defined routine. You can add SQL statements or modify the sample data for the routine. Use this file if you are debugging udr.c. IfxQuery runs this file if you click Debug DataBlade Module with this file in the active window.
Opaque.sql Tests the support routines for each opaque data type. You can add SQL statements or modify the sample data for each support routine. Use this file if you are debugging Opaque.c or OpaqueServer.cpp. IfxQuery runs this file if you click Debug DataBlade Module with this file in the active window.
Cleanup.sql Optionally deletes and drops tables and data in your test database. IfxQuery runs this file if you click Debug DataBlade Module with this file in the active window.

When you edit unit test files, add SQL statements in the areas marked with TEST comments. This ensures that your statements are merged when you regenerate unit tests with BladeSmith.


DataBlade Developers Kit User's Guide, Version 4.0
Copyright © 1999, Informix Software, Inc. All rights reserved