Table of Contents Previous Next


7 Debugger

Standalone Debugging. The Debugger is used to start the program to be tested. You supply any input parameter values required by the program and you can immediately observe and step through the code of the program. Standalone debugging is the typical method used for new programs and for initial problem investigation.
In-Context Debugging. The program to be tested is initiated by an application other than the Debugger. You first set a global breakpoint on the program to be tested. The application that makes the first call to the program encounters the global breakpoint. The application suspends execution at which point the Debugger takes control of the called program. You can then observe and step through the code of the called program as it runs within the context of the calling application. After you have completely stepped through the code of the called program in the Debugger, the suspended application resumes execution. In-context debugging is useful if it is difficult to reproduce a problem using standalone debugging due to complex interaction with the calling application.
Before using the Debugger, edit the postgresql.conf file (located in the data subdirectory of your Advanced Server home directory), adding $libdir/plugin_debugger to the libraries listed in the shared_preload_libraries configuration parameter:
After modifying the shared_preload_libraries parameter, you must restart the database server.
open_debugger_1
You can also right-click on the name of the stored procedure or function in the PEM client Object Browser, and select Debugging, and the Debug from the context menu as shown in Figure 7.2.
open_debugger_2
You can use the View Data Options window to pass parameter values when you are standalone-debugging a program that expects parameters. When you start the debugger, the View Data Options window opens automatically to display any IN or IN OUT parameters expected by the program. If the program declares no IN or IN OUT parameters, the View Data Options window does not open.
view_data_options
Use the fields on the View Data Options window (shown in Figure 7.3) to provide a value for each parameter:
The Name field contains the formal parameter name.
The Type field contains the parameter data type.
Check the Null? checkbox to indicate that the parameter is a NULL value.
Check the Expression checkbox if the Value field contains an expression.
The Value field contains the parameter value that will be passed to the program.
Check the Use default? checkbox to indicate that the program should use the value in the Default Value field.
The Default Value field contains the default value of the parameter.
Press the Enter key to select the next parameter in the list for data entry, or click on a Value field to select the parameter for data entry.
If you are debugging a procedure or function that is a member of a package that has an initialization section, check the Debug Package Initializer check box to instruct the Debugger to step into the package initialization section, allowing you to debug the initialization section code before debugging the procedure or function. If you do not select the check box, the Debugger executes the package initialization section without allowing you to see or step through the individual lines of code as they are executed.
After entering the desired parameter values, click the OK button to start the debugging process. Click the Cancel button to terminate the Debugger and return control to the PEM client.
Note: The View Data Options window does not open during in-context debugging. Instead, the application calling the program to be debugged must supply any required input parameter values.
When you have completed a full debugging cycle by stepping through the program code, the View Data Options window re-opens, allowing you to enter new parameter values and repeat the debugging cycle, or end the debugging session.

7 Debugger

Table of Contents Previous Next