To debug your DataBlade module, use a debugger that can attach to the active server process and access the symbol tables of dynamically loaded shared object files.
On UNIX or Linux, the debugger and dbx utilities meet these criteria. To start a debugger, enter the following command at the shell prompt, in which pid is the process identifier of the CPU or virtual processor:
debugger - pid
This command starts the debugger on the server virtual-processor process without starting a new instance of the virtual processor. For more information about available debugger commands, see the debugger manual page.
The following sections describe these steps.
To debug a shared-object file, you must compile the shared-object file with an option that makes additional symbol-table information available to the debugger. Many C compilers use the -g compiler option to create a debugging version of a shared-object file. For more information on how to compile, see Compiling a C UDR.
To connect to the database server, choose a client tool that allows you to submit ad-hoc queries.
On UNIX or Linux, you can use the DB-Access utility. For example, execute the following command, where database is a database in which you registered the shared-object file that you want to debug:
dbaccess database
On Windows, you can use the SQL Editor.
To load the shared-object file, you must execute one of the UDRs within the file. One technique is to execute the UDR itself within DB–Access. For example, if a user-defined function named my_udf( ) resides within the shared-object file, you can use the following SQL statement to execute my_udf( ), which causes the database server to load the shared-object file that contains my_udf( ):
EXECUTE FUNCTION my_udf( );
Another technique for loading the shared-object file is to define a dummy UDR in the shared-object file that you use to load the shared-object file, as follows:
The routine can be as simple as the following example:
mi_integer load_so( ) { return 0; }
To prevent name conflicts with other shared-object files (or DataBlade modules), you can put a prefix in the routine name.
CREATE FUNCTION load_so( ) RETURNS INTEGER WITH (NOT VARIANT) EXTERNAL NAME '/usr/lib/udrs/myudrs.so(load_so)' LANGUAGE C;
To load the shared-object file, execute the dummy UDR. The following SELECT statement in your client application (or DB–Access) loads the myudrs shared-object file, which contains load_so( ):
SELECT load_so( ) FROM informix.systables WHERE tabid=1;
For more information about loading a shared-object file, see Loading a Shared-Object File.
To find the virtual processor in which your shared-object file is loaded, execute the onstat utility with the -g glo or -g sch option. Locate the CPU or user-defined virtual processor that you want to debug and record its process identifier (pid) for the next step. For more information on the -g glo and -g sch options of onstat, see Monitoring Virtual Processors.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]