DataBlade Developers Kit Tutorial |
Tutorial Exercise 2Debugging a DataBlade ModuleThis exercise demonstrates debugging a DataBlade module. You will debug the AddInts DataBlade module that you created in Exercise 1. The AddInts DataBlade module contains one user-defined routine, AddIntegers(), which adds two integers and returns the result. This exercise provides instructions for debugging a DataBlade module on Windows NT using Microsoft Visual C++ Developer Studio. You are assumed to be running your Informix server on the Windows NT workstation on which you built the AddInts DataBlade module. WARNING: Use a test database server for debugging because when you bring down the debugger in Step 5, the database server crashes. For information about debugging on UNIX, see the DataBlade Developers Kit User's Guide. Additional information about debugging is available from the Informix Developers Network. Tutorial StepsThis exercise consists of seven steps. It takes approximately 30 minutes to complete.
Before you attach the debugger process to the database server, load your DataBlade module dynamic link library file into the database server address space. With the dynamic link library file loaded, you can set breakpoints on module entry points and examine local storage provided by module functions. To load the DataBlade module into the database server address space, execute a DataBlade module routine using SQL Editor or DB-Access. Because you have not debugged your routines, you should execute a noncritical routine to load your DataBlade module. There are two methods for loading a DataBlade module dynamic link library without executing an untested critical routine:
See " Starting Informix Dynamic Server on Windows NT" for detailed instructions on starting Informix Dynamic Server on Windows NT. For instructions on starting Informix Dynamic Server on UNIX, see the Administrator's Guide for your database server.
Start Microsoft Visual C++ Developer Studio. Choose Build Start Debug Attach to Process. The Attach to Process dialog box appears. Select the Informix server process oninit.
Choose File Open and select udr.c from the AddInts\src\C directory. To set breakpoints in your code, place your cursor on the line in which you want to set a breakpoint and right-click anywhere on the line. Select Insert/Remove Breakpoint from the popup menu. Set a breakpoint at the line in which the AddInts() function adds the two integers:
Using SQL Editor or DB-Access, issue the following SQL statements to call the AddInts() function:
The debugger stops the function from executing before it adds the two input values. You can check the values of the variables before and after their values are added. At the breakpoint, the variables have the following values.
Use the Step Into or Step Over commands in the Debug toolbar to pass the breakpoint. The variables now have the following values.
Run your code until the function is finished executing. In Visual C++, choose Debug Stop Debugging and exit Visual C++. The database server crashes. Disconnect SQL Editor or DB-Access from the database. The tool may take a few minutes to exit.
If you have detected problems, you can re-open the Visual C++ workspace for your project (in this example, the file AddInts.dsw in the src\C directory) and modify the source code to correct the problems. Then save your changes and rebuild your DataBlade module to repeat the debugging process. Important: You must shut down the database server before you replace the DataBlade module dynamic link library (shared object file). See the "DataBlade Developers Kit User's Guide" for more information.
Copyright © 1998, Informix Software, Inc. All rights reserved. |