Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2) Part Number A96612-01 |
|
DBMS_DEBUG, 2 of 2
This procedure returns the version number of DBMS_DEBUG
on the server.
DBMS_DEBUG.PROBE_VERSION ( major out BINARY_INTEGER, minor out BINARY_INTEGER);
Parameter | Description |
---|---|
major |
Major version number. |
minor |
Minor version number: increments as functionality is added. |
This procedure performs an internal consistency check. SELF_CHECK
also runs a communications test to ensure that the Probe processes are able to communicate.
If SELF_CHECK
does not return successfully, then an incorrect version of DBMS_DEBUG
was probably installed on this server. The solution is to install the correct version (pbload
.sql
loads DBMS_DEBUG
and the other relevant packages).
DBMS_DEBUG.SELF_CHECK ( timeout IN binary_integer := 60);
Parameter | Description |
---|---|
timeout |
The timeout to use for the communication test. Default is 60 seconds. |
All of these exceptions are fatal. They indicate a serious problem with Probe that prevents it from working correctly.
This function sets the timeout value and returns the new timeout value.
DBMS_DEBUG.SET_TIMEOUT ( timeout BINARY_INTEGER) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
timeout |
The timeout to use for communication between the target and debug sessions. |
The following subprograms are run in the target session (the session that is to be debugged):
This function initializes the target session for debugging.
DBMS_DEBUG.INITIALIZE ( debug_session_id IN VARCHAR2 := NULL, diagnostics IN BINARY_INTEGER := 0) RETURN VARCHAR2;
Parameter | Description |
---|---|
debug_session_id |
Name of session ID. If |
diagnostics |
Indicates whether to dump diagnostic output to the tracefile. 1 = print diagnostics |
The newly-registered debug session ID (debugID)
This procedure marks the target session so that all PL/SQL is run in debug mode. This must be done before any debugging can take place.
DBMS_DEBUG.DEBUG_ON ( no_client_side_plsql_engine BOOLEAN := TRUE, immediate BOOLEAN := FALSE);
This procedure notifies the target session that debugging should no longer take place in that session. It is not necessary to call this function before ending the session.
DBMS_DEBUG.DEBUG_OFF;
The server does not handle this entrypoint specially. Therefore, it attempts to debug this entrypoint.
This procedure notifies the debug session about the target program.
DBMS_DEBUG.ATTACH_SESSION ( debug_session_id IN VARCHAR2, diagnostics IN BINARY_INTEGER := 0);
Parameter | Description |
---|---|
debug_session_id |
Debug ID from a call to |
diagnostics |
Generate diagnostic output if nonzero. |
This function waits until the target program signals an event. If info_requested
is not NULL
, then it calls GET_RUNTIME_INFO
.
DBMS_DEBUG.SYNCHRONIZE ( run_info OUT runtime_info, info_requested IN BINARY_INTEGER := NULL) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
run_info |
Structure in which to write information about the program. By default, this includes information about what program is running and at which line execution has paused. |
info_requested |
Optional bit-field in which to request information other than the default (which is See "Information Flags". |
Return | Description |
---|---|
success |
|
error_timeout |
Timed out before the program started execution. |
error_communication |
Other communication error. |
The best way to get the source code (for a program that is being run) is to use SQL. For example:
DECLARE info DBMS_DEBUG.runtime_info; BEGIN -- call DBMS_DEBUG.SYNCHRONIZE, CONTINUE, -- or GET_RUNTIME_INFO to fill in 'info' SELECT text INTO <buffer> FROM all_source WHERE owner = info.Program.Owner AND name = info.Program.Name AND line = info.Line#; END;
However, this does not work for nonpersistent programs (for example, anonymous blocks and trigger invocation blocks). For nonpersistent programs, call SHOW_SOURCE
. There are two flavors: one returns an indexed table of source lines, and the other returns a packed (and formatted) buffer.
There are two overloaded SHOW_SOURCE
procedures.
DBMS_DEBUG.SHOW_SOURCE ( first_line IN BINARY_INTEGER, last_line IN BINARY_INTEGER, source OUT vc2_table);
An indexed table of source-lines. The source lines are stored starting at first_line
. If any error occurs, then the table is empty.
This second overloading of SHOW_SOURCE
returns the source in a formatted buffer, complete with line-numbers. It is faster than the indexed table version, but it does not guarantee to fetch all the source.
If the source does not fit in bufferlength (buflen
), then additional pieces can be retrieved using the GET_MORE_SOURCE
procedure (pieces
returns the number of additional pieces that need to be retrieved).
DBMS_DEBUG.SHOW_SOURCE ( first_line IN BINARY_INTEGER, last_line IN BINARY_INTEGER, window IN BINARY_INTEGER, print_arrow IN BINARY_INTEGER, buffer IN OUT VARCHAR2, buflen IN BINARY_INTEGER, pieces OUT BINARY_INTEGER);
This procedure prints a backtrace listing of the current execution stack. This should only be called if a program is currently running.
There are two overloaded PRINT_BACKTRACE
procedures.
DBMS_DEBUG.PRINT_BACKTRACE ( listing IN OUT VARCHAR2);
Parameter | Description |
---|---|
listing |
A formatted character buffer with embedded newlines. |
DBMS_DEBUG.PRINT_BACKTRACE ( backtrace OUT backtrace_table);
This function passes the given breakflags (a mask of the events that are of interest) to Probe in the target process. It tells Probe to continue execution of the target process, and it waits until the target process runs to completion or signals an event.
If info_requested
is not NULL
, then calls GET_RUNTIME_INFO
.
DBMS_DEBUG.CONTINUE ( run_info IN OUT runtime_info, breakflags IN BINARY_INTEGER, info_requested IN BINARY_INTEGER := NULL) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
run_info |
Information about the state of the program. |
breakflags |
Mask of events that are of interest. See "Breakflags" . |
info_requested |
Which information should be returned in |
Return | Description |
---|---|
success |
|
error_timeout |
Timed out before the program started running. |
error_communication |
Other communication error. |
This function sets a breakpoint in a program unit, which persists for the current session. Execution pauses if the target program reaches the breakpoint.
DBMS_DEBUG.SET_BREAKPOINT ( program IN program_info, line# IN BINARY_INTEGER, breakpoint# OUT BINARY_INTEGER, fuzzy IN BINARY_INTEGER := 0, iterations IN BINARY_INTEGER := 0) RETURN BINARY_INTEGER;
Return | Description |
---|---|
success |
|
error_illegal_line |
Cannot set a breakpoint at that line. |
error_bad_handle |
No such program unit exists. |
This function deletes a breakpoint.
DBMS_DEBUG.DELETE_BREAKPOINT ( breakpoint IN BINARY_INTEGER) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
breakpoint |
Breakpoint number from a previous call to |
This function makes an existing breakpoint inactive, but it leaves it in place.
DBMS_DEBUG.DISABLE_BREAKPOINT ( breakpoint IN BINARY_INTEGER) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
breakpoint |
Breakpoint number from a previous call to |
Returns | Description |
---|---|
success |
|
error_no_such_breakpt |
No such breakpoint exists. |
error_idle_breakpt |
Cannot disable an unused breakpoint. |
This function is the reverse of disabling. This enables a previously disabled breakpoint.
DBMS_DEBUG.ENABLE_BREAKPOINT ( breakpoint IN BINARY_INTEGER) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
breakpoint |
Breakpoint number from a previous call to |
Return | Description |
---|---|
success |
|
error_no_such_breakpt |
No such breakpoint exists. |
error_idle_breakpt |
Cannot enable an unused breakpoint. |
This procedure returns a listing of the current breakpoints. There are two overloaded SHOW_BREAKPOINTS
procedures.
DBMS_DEBUG.SHOW_BREAKPOINTS ( listing IN OUT VARCHAR2);
Parameter | Description |
---|---|
listing |
A formatted buffer (including newlines) of the breakpoints. |
DBMS_DEBUG.SHOW_BREAKPOINTS ( listing OUT breakpoint_table);
Parameter | Description |
---|---|
listing |
Indexed table of breakpoint entries. The breakpoint number is indicated by the index into the table. Breakpoint numbers start at 1 and are reused when deleted. |
This function gets a value from the currently-running program. There are two overloaded GET_VALUE
functions.
DBMS_DEBUG.GET_VALUE ( variable_name IN VARCHAR2, frame# IN BINARY_INTEGER, scalar_value OUT VARCHAR2, format IN VARCHAR2 := NULL) RETURN BINARY_INTEGER;
This form of GET_VALUE
is for fetching package variables. Instead of a frame#, it takes a handle, which describes the package containing the variable.
DBMS_DEBUG.GET_VALUE ( variable_name IN VARCHAR2, handle IN program_info, scalar_value OUT VARCHAR2, format IN VARCHAR2 := NULL) RETURN BINARY_INTEGER;
This example illustrates how to get the value with a given package PACK
in schema SCOTT
, containing variable VAR
:
DECLARE handle dbms_debug.program_info; resultbuf VARCHAR2(500); retval BINARY_INTEGER; BEGIN handle.Owner := 'SCOTT'; handle.Name := 'PACK'; handle.namespace := dbms_debug.namespace_pkgspec_or_toplevel; retval := dbms_debug.get_value('VAR', handle, resultbuf, NULL); END;
This function sets a value in the currently-running program. There are two overloaded SET_VALUE
functions.
DBMS_DEBUG.SET_VALUE ( frame# IN binary_integer, assignment_statement IN varchar2) RETURN BINARY_INTEGER;
This form of SET_VALUE
sets the value of a package variable.
DBMS_DEBUG.SET_VALUE ( handle IN program_info, assignment_statement IN VARCHAR2) RETURN BINARY_INTEGER;
Return | Description |
---|---|
error_no_such_object |
- Package is not instantiated. - User does not have privileges to debug the package. - Object does not exist in the package. |
In some cases, the PL/SQL compiler uses temporaries to access package variables, and Probe does not guarantee to update such temporaries. It is possible, although unlikely, that modification to a package variable using SET_VALUE
might not take effect for a line or two.
To set the value of SCOTT
.PACK
.var
to 6:
DECLARE handle dbms_debug.program_info; retval BINARY_INTEGER; BEGIN handle.Owner := 'SCOTT'; handle.Name := 'PACK'; handle.namespace := dbms_debug.namespace_pkgspec_or_toplevel; retval := dbms_debug.set_value(handle, 'var := 6;'); END;
This procedure stops debugging the target program. This procedure may be called at any time, but it does not notify the target session that the debug session is detaching itself, and it does not abort execution of the target session. Therefore, care should be taken to ensure that the target session does not hang itself.
DBMS_DEBUG.DETACH_SESSION;
This function returns information about the current program. It is only needed if the info_requested
parameter to SYNCHRONIZE
or CONTINUE
was set to 0
.
DBMS_DEBUG.GET_RUNTIME_INFO ( info_requested IN BINARY_INTEGER, run_info OUT runtime_info) RETURN BINARY_INTEGER;
Parameter | Description |
---|---|
info_requested |
Which information should be returned in |
run_info |
Information about the state of the program. |
Given a name of a variable or parameter, this function returns the set of its indexes, if it is an indexed table. An error is returned if it is not an indexed table.
DBMS_DEBUG.GET_INDEXES ( varname IN VARCHAR2, frame# IN BINARY_INTEGER, handle IN program_info, entries OUT index_table) RETURN BINARY_INTEGER;
Return | Description |
---|---|
error_no_such_object |
- The package is not instantiated. - The user does not have privileges to debug the package. - The object does not exist in the package. |
This procedure executes SQL or PL/SQL code in the target session. The target session is assumed to be waiting at a breakpoint (or other event). The call to DBMS_DEBUG
.EXECUTE
occurs in the debug session, which then asks the target session to execute the code.
DBMS_DEBUG.EXECUTE ( what IN VARCHAR2, frame# IN BINARY_INTEGER, bind_results IN BINARY_INTEGER, results IN OUT NOCOPY dbms_debug_vc2coll, errm IN OUT NOCOPY VARCHAR2);
This example executes a SQL statement. It returns no results.
DECLARE coll sys.dbms_debug_vc2coll; -- results (unused) errm VARCHAR2(100); BEGIN dbms_debug.execute('insert into emp(ename,empno,deptno) ' || 'values(''LJE'', 1, 1)', -1, 0, coll, errm); END;
This example executes a PL/SQL block, and it returns no results. The block is an autonomous transaction, which means that the value inserted into the table becomes visible in the debug session.
DECLARE coll sys.dbms_debug_vc2coll; errm VARCHAR2(100); BEGIN dbms_debug.execute( 'DECLARE PRAGMA autonomous_transaction; ' || 'BEGIN ' || ' insert into emp(ename, empno, deptno) ' || ' values(''LJE'', 1, 1); ' || ' COMMIT; ' || 'END;', -1, 0, coll, errm); END;
This example executes a PL/SQL block, and it returns some results.
DECLARE coll sys.dbms_debug_vc2coll; errm VARCHAR2(100); BEGIN dbms_debug.execute( 'DECLARE ' || ' pp SYS.dbms_debug_vc2coll := SYS.dbms_debug_vc2coll(); ' || ' x PLS_INTEGER; ' || ' i PLS_INTEGER := 1; ' || 'BEGIN ' || ' SELECT COUNT(*) INTO x FROM emp; ' || ' pp.EXTEND(x * 6); ' || ' FOR c IN (SELECT * FROM emp) LOOP ' || ' pp(i) := ''Ename: '' || c.ename; i := i+1; ' || ' pp(i) := ''Empno: '' || c.empno; i := i+1; ' || ' pp(i) := ''Job: '' || c.job; i := i+1; ' || ' pp(i) := ''Mgr: '' || c.mgr; i := i+1; ' || ' pp(i) := ''Sal: '' || c.sal; i := i+1; ' || ' pp(i) := null; i := i+1; ' || ' END LOOP; ' || ' :1 := pp;' || 'END;', -1, 1, coll, errm); each := coll.FIRST; WHILE (each IS NOT NULL) LOOP dosomething(coll(each)); each := coll.NEXT(each); END LOOP; END;
This procedure returns a list of the packages that have been instantiated in the current session.
DBMS_DEBUG.PRINT_INSTANTIATIONS ( pkgs IN OUT NOCOPY backtrace_table, flags IN BINARY_INTEGER);
Parameter | Description |
---|---|
|
The instantiated packages |
|
Bitmask of options: |
no_target_program
- target session is not currently executing
On return, pkgs
contains a program_info
for each instantiation. The valid fields are: Namespace, Name, Owner,
and LibunitType.
In addition, Line# contains a bitmask of:
This procedure returns TRUE
if the target session is currently executing a stored procedure, or FALSE
if it is not.
FUNCTION target_program_running RETURN BOOLEAN;
This procedure pings the target session, to prevent it from timing out. Use this procedure when execution is suspended in the target session, for example at a breakpoint.
If the timeout_behavior
is set to retry_on_timeout
then this procedure is not necessary.
DBMS_DEBUG.PING;
Oracle will display the no_target_program
exception if there is no target program or if the target session is not currently waiting for input from the debug session.
Timeout options for the target session are registered with the target session by calling set_timeout_behavior.
retry_on_timeout
- Retry. Timeout has no effect. This is like setting the timeout to an infinitely large value.continue_on_timeout
- Continue execution, using same event flags.nodebug_on_timeout
- Turn debug-mode OFF (in other words, call debug_off) and then continue execution. No more events will be generated by this target session unless it is re-initialized by calling debug_on.abort_on_timeout
- Continue execution, using the abort_execution flag, which should cause the program to abort immediately. The session remains in debug-mode.retry_on_timeout CONSTANT BINARY_INTEGER:= 0;
continue_on_timeout CONSTANT BINARY_INTEGER:= 1;
nodebug_on_timeout CONSTANT BINARY_INTEGER:= 2;
abort_on_timeout CONSTANT BINARY_INTEGER:= 3;
This procedure tells Probe what to do with the target session when a timeout occurs. This call is made in the target session.
DBMS_DEBUG.SET_TIMEOUT_BEHAVIOR ( behavior IN PLS_INTEGER);
unimplemented - the requested behavior is not recognized
The default behavior (if this procedure is not called) is continue_on_timeout,
since it allows a debugger client to reestablish control (at the next event) but does not cause the target session to hang indefinitely.
This procedure returns the current timeout behavior. This call is made in the target session.
DBMS_DEBUG.GET_TIMEOUT_BEHAVIOR ( RETURN BINARY_INTEGER;
info_getOerInfo
CONSTANT PLS_INTEGER:= 32;
reason_oer_breakpoint CONSTANT BINARY_INTEGER:= 26;
Runtime_info
gives context information about the running program.
Probe v2.4:
Added OER. It gets set if info_getOerInfo
is set. The OER is a positive number. It can be translated into SQLCODE by translating 1403 to 100, 6510 to 1, and negating any other value.
TYPE runtime_info IS RECORD ( Line# BINARY_INTEGER, (duplicate of program.line#) Terminated BINARY_INTEGER, has the program terminated? Breakpoint BINARY_INTEGER, breakpoint number StackDepth BINARY_INTEGER, number of frames on the stack InterpreterDepth BINARY_INTEGER, <reserved field> Reason BINARY_INTEGER, reason for suspension Program program_info, source location Following fields were added in Probe v2.4 oer PLS_INTEGER OER (exception), if any );
oer_table
Used by show_breakpoints
TYPE oer_table IS TABLE OF BINARY_INTEGER INDEX BY BINARY_INTEGER;
- SET_OER_BREAKPOINT
Set a breakpoint on an OER. The breakpoint persists for the session (or until deleted), as with code breakpoints.
Parameter | Description |
---|---|
|
The OER (a 4-byte positive number). |
success
Less functionality is supported on OER breakpoints than on code breakpoints. In particular, note that:
delete_oer_breakpoint.
This function sets an OER breakpoint.
DBMS_DEBUG.SET_OER_BREAKPOINT ( oer IN PLS_INTEGER) RETURN PLS_INTEGER;
Parameter | Description |
---|---|
|
The OER (positive 4-byte number) to delete. |
success
error_no_such_breakpt
- no such OER breakpoint exists
This function deletes an OER breakpoint.
DBMS_DEBUG.DELETE_OER_BREAKPOINT ( oer IN PLS_INTEGER) RETURN PLS_INTEGER;
DBMS_DEBUG.SHOW_BREAKPOINTS ( code_breakpoints OUT breakpoint_table, oer_breakpoints OUT oer_table);
Parameter | Description |
---|---|
|
The indexed table of breakpoint entries, indexed by breakpoint number. |
|
The indexed table of OER breakpoints, indexed by OER. |
|
Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|