DBMS_DEBUG_JDWP

The DBMS_DEBUG_JDWP provides the interface to initiate and control the debugging of PL/SQL stored procedures and Java stored procedures over Java Debug Wire Protocol (JDWP).

This chapter contains the following topics:

DBMS_DEBUG_JDWP Overview

Oracle supports the debugging of PL/SQL stored procedures and Java stored procedures over JDWP. Using the DBMS_DEBUG_JDWP package, you can:

DBMS_DEBUG_JDWP Security Model

The debugging user invoking a DBMS_DEBUG_JDWP subprogram requires a privilege to connect the target database session to the debugger.

Table 1 System Privileges

System Privilege Description
DEBUG CONNECT SESSION Allows a user to connect his current session to a debugger
DEBUG CONNECT ANY Allows a user to connect a session by any logon user to a debugger

In addition, the user can also be granted the following user privilege to debug another user’s session.

Table 2 User Privileges

User Privilege Description
DEBUG CONNECT ON USER <user> Allows a user to connect any of the specified user’s logon sessions to a debugger to debug another user’s session or his own

Summary DBMS_DEBUG_JDWP Subprograms

This table lists the DBMS_DEBUG_JDWP subprograms and briefly describes them.

Table 3 DBMS_DEBUG_JDWP Package Subprograms

Subprogram Description
CONNECT_TCP Procedure Connects the specified session to the debugger waiting at host:port
CURRENT_SESSION_ID Function Gets the current session’s session ID
CURRENT_SESSION_SERIAL Function Gets the current session’s session serial number
DISCONNECT Procedure Disconnects the specified session from any debugger with which it is connected
GET_NLS_PARAMETER Function Gets the value of the specified NLS parameter affecting the format in which NUMBER, DATE, TIME (WITH TIME ZONE) and TIMESTAMP (WITH TIME ZONE) runtime values of PL/SQL programs are converted to strings as they are presented through JDWP
PROCESS_CONNECT_STRING Procedure Connects a session to a debugger without having to directly modify an application’s code
SET_NLS_PARAMETER Procedure Sets the value of the specified NLS parameter affecting the format in which NUMBER, DATE, TIME (WITH TIME ZONE) and TIMESTAMP (WITH TIME ZONE) runtime values of PL/SQL programs are converted to strings as they are presented through JDWP

CONNECT_TCP Procedure

This procedure connects the specified session to the debugger waiting at host:port.

Syntax

DBMS_DEBUG_JDWP.CONNECT_TCP(
   host                 IN  VARCHAR2,
   port                 IN  VARCHAR2,
   session_id           IN  PLS_INTEGER := NULL,
   session_serial       IN  PLS_INTEGER := NULL,
   debug_role           IN  VARCHAR2  := NULL,
   debug_role_pwd       IN  VARCHAR2  := NULL,
   option_flags         IN  PLS_INTEGER := 0,
   extensions_cmd_set   IN  PLS_INTEGER := 128);

Parameters

Table 4 CONNECT_TCP Parameters

Parameter Description
host The host name the debugger is waiting at
port The port number the debugger is waiting at
session_id Session ID
session_serial Session number
debug_role Debug role
debug_role_pwd Debug password
option_flags

Values:

  • 1 : Does not suspend the program until the next client/server request begins. This can be used to hide the startup sequence from end users, who may only want to see their own code

  • 2 : Forces the connection even if the session appears to be connected to a debugger. This should best only be specified after some human-interaction confirmation step has occurred; i.e., if an attempt without this option raised ORA-30677, then if the user confirms, retry with this bit set.

These may be added together to select multiple option choices.

extensions_cmd_set The ID of the Oracle JDWP extension command set

Exceptions

Table 5 CONNECT_TCP Exceptions

Exception Description
ORA-00022 Invalid session ID
ORA-01031 Insufficient privilege
ORA-30677 Session is already connected to a debugger
ORA-30681 Improper value for argument EXTENSIONS_CMD_SET
ORA-30682 Improper value for argument OPTION_FLAGS
ORA-30683 Failure establishing connection to debugger

Usage Notes

CURRENT_SESSION_ID Function

This function gets the current session’s session ID

Syntax

DBMS_DEBUG_JDWP.CURRENT_SESSION_ID
  RETURN PLS_INTEGER;

CURRENT_SESSION_SERIAL Function

This function gets the current session’s session number.

Syntax

DBMS_DEBUG_JDWP.CURRENT_SESSION_SERIAL
  RETURN PLS_INTEGER;

DISCONNECT Procedure

This procedure disconnects the specified session from any debugger with which it is connected.

Syntax

DBMS_DEBUG_JDWP.DISCONNECT(
   session_id        IN  PLS_INTEGER  := NULL,
   session_serial    IN  PLS_INTEGER := NULL);

Parameters

Table 6 DISCONNECT Procedure Parameters

Parameter Description
session_id Session ID
session_serial Session number

Usage Notes

GET_NLS_PARAMETER Function

This function gets the value of the specified NLS parameter affecting the format in which the NUMBER, DATE, TIME (WITH TIME ZONE) and TIMESTAMP (WITH TIME ZONE) runtime values of PL/SQL programs are converted to strings, as they are presented through JDWP.

These values are private to the current session, but further are private to the debugger mechanisms, separate from the values used to convert values within the debugged program itself.

Syntax

DBMS_DEBUG_JDWP.GET_NLS_PARAMETER(
   name   IN  VARCHAR2)
  RETURN VARCHAR2;

Parameters

Table 7 GET_NLS_PARAMETER Function Parameters

Parameter Description
name Specified NLS parameter

Usage Notes

PROCESS_CONNECT_STRING Procedure

This procedure connects a session to a debugger in two ways, so that you do not have to directly modify the application code.

The two ways are:

Syntax

DBMS_DEBUG_JDWP.PROCESS_CONNECT_STRING (
   connect_string          IN  VARCHAR2,
   connect_string_type     IN  PLS_INTEGER);

Parameters

Table 8 PROCESS_CONNECT_STRING Procedure Parameters

Parameter Description
connect_string The ORA_DEBUG_JDWP environment variable or OWA_DEBUG_<dad> cookie value that contains the JDWP connection information such as the host and port number of the debugger to connect to
connect_string_type <p>Can have the following two values: <ul style="list-style-type: disc;"> <li> 1 if the connect string value is retrieved from the ORA_DEBUG_JDWP environment </li> <li> 2 if the value is from the OWA_DEBUG_<dad> cookie </li> </ul> </p>

Exceptions

Table 9 PROCESS_CONNECT_STRING Procedure Exceptions

Exception Description
ORA-00022 Invalid session ID
ORA-01031 Insufficient privilege
ORA-30677 Session is already connected to a debugger
ORA-30681 Improper value for argument EXTENSIONS_CMD_SET
ORA-30682 Improper value for argument OPTION_FLAGS
ORA-30683 Failure establishing connection to debugger
ORA-30689 Improper value for environment variable ORA_DEBUG_JDWP

SET_NLS_PARAMETER Procedure

This function sets the value of the specified NLS parameter affecting the format in which NUMBER, DATE, TIME (WITH TIME ZONE) and TIMESTAMP (WITH TIME ZONE) runtime values of PL/SQL programs are converted to strings as they are presented through JDWP.

These values are private to the current session, but further are private to the debugger mechanisms, separate from the values used to convert values within the debugged program itself.

Syntax

DBMS_DEBUG_JDWP.SET_NLS_PARAMETER(
   name      IN  VARCHAR2,
   value     IN  VARCHAR2);

Parameters

Table 10 SET_NLS_PARAMETER Procedure Parameters

Parameter Description
name Specified NLS parameter
value Value of specified NLS parameter

Usage Notes