INFORMIX
DataBlade Developers Kit User's Guide
Chapter 9: Testing and Debugging DataBlade Modules on Windows
Home Contents Index Master Index New Book

Debugging a DataBlade Module

Debugging a DataBlade module is usually an iterative process, repeated several times until the code is completely debugged. The debugging exercise in the DBDK InfoShelf tutorial guides you through this process.

The process has the following general steps:

    1. Build the project.bld file with debugging support (if necessary). To debug a DataBlade module, the dynamic link library file must be compiled as a debug version so that debugging symbols are available to the database server.

    2. Install the project.bld file and the contents of the scripts directory in the %INFORMIXDIR%\extend\project directory.

    3. Set the attributes of the project.bld file as read-only so that it can be loaded by the Informix database server. If the project.bld file is not read-only, the database server issues an "unable to load function" message in the online.log file.

    4. Start or shut down and restart your Informix database server from the Services application in the Control Panel. Do not start the Informix messaging service; it is started automatically by the database server.

    See INFORMIX-Universal Server Administrator's Supplement for Windows NT for more information.

    5. Register the DataBlade module, using BladeManager (if necessary).

    6. Load the DataBlade module by calling one of its routines from DB-Access or SQL Editor.

    7. Start Microsoft Developers Studio Visual C++.

    8. Start the debugger and attach to the database server process (oninit).

    9. Open one of the source code files in Microsoft Developers Studio.

    10. Set appropriate breakpoints.

    11. Issue SQL statements to call your DataBlade module routines and step through the code to identify bugs.

    See the DB-Access User Manual or the SQL Editor on-line help for instructions on issuing SQL statements.

    12. Stop the debugger and shut down the database server.

    13. Edit the source code (if necessary).

    14. Repeat the procedure, as necessary.

The following sections describe some of these steps.

Loading the DataBlade Module

Before you can attach to the database server process with the debugger, load your DataBlade module dynamic link library file into the database server address space. With the dynamic link library file loaded, set breakpoints on the routine entry points and examine local storage provided by the routines.

To load the DataBlade module into the database server address space, execute one of its routines in DB-Access or SQL Editor. One technique is to call the routine with an impossible condition, as follows:

routine_name is the name of your routine, column_name is the name of a column in the table, and table_name is the name of the table. This statement loads your DataBlade module dynamic link library file without executing the routine.

Important: If you receive an error when loading your DataBlade module dynamic link library file, the dynamic link library file attributes may not be read-only. See "Dynamic Link Library Permissions" for instructions on setting the attributes of a dynamic link library file to read-only.

Running the Microsoft Developers Studio Debugger

To debug a DataBlade module on Windows NT, use Microsoft Developers Studio Visual C++ 4.2 or later.

You can set breakpoints, examine the stack, resume execution, or carry out any other necessary Developer Studio command. See the Developer Studio on-line help for more information about available commands.

When you are finished debugging, shut down the database server, which also stops the debugger.

Starting the Debugger Against the Server Process

To debug your source code, attach the debugger to the Informix Dynamic Server process. Microsoft Developer Studio Visual C++ Versions 4.2 and 5.0 have different procedures for starting the debugger against the server.

To start the Visual C++ 4.2 debugger against the database server process

    1. Open the Windows Task Manager window and find the process ID for the oninit database server process.

    2. Execute this command from the MS-DOS command prompt:

    PID is the process ID of the Informix Dynamic Server process.

To start the Visual C++ 5.0 debugger against the database server process

    1. Choose Build Start Debug Attach to Process. The Attach to Process dialog box appears.

    2. Select the Informix database server process, oninit.

    You may also see the online database server process, but you cannot use it to debug your DataBlade module. Use oninit, the larger of the two processes.

    3. Click OK.

Setting Breakpoints

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

To set breakpoints in Microsoft Developer Studio

    1. Open a source code file.

    2. Right-click a routine on which you want to set a breakpoint.

    3. Choose Insert Breakpoint.

Stopping the Debugger and the Server Cleanly

Stop the debugger and the Informix database server by shutting down the oninit process in the Services application in the Control Panel. You might receive error messages in the debugger when the database server shuts down; you can ignore them.

Important: If you stop the debugger before shutting down the database server, you might corrupt your database if the database server is in use by another process.




DataBlade Developers Kit User's Guide, version 3.6
Copyright © 1998, Informix Software, Inc. All rights reserved.