The DBMS_DEBUG package is primarily used to implement the server-side debugger. It provides a method for debugging server-side PL programs.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
To debug a PL program using the DBMS_DEBUG package, you need at least two database sessions: one for executing the target program (Target Session) and another for debugging the target program (Debug Session).
The Target Session is used to initialize the debugging session, mark the session, and enable the PL interpreter to run in debug mode, generating debugging events. Once these events are generated, they are published from the session. In most cases, the interpreter will pause and wait for a response.
The debug session must also be initialized using DBMS_DEBUG to determine which target session it will monitor. After initialization, the debug session can call entry points of DBMS_DEBUG to read events published from the target session and communicate with it.
DBMS_DEBUG does not provide an interface to the PL compiler, but it relies on the debugging information generated by the compiler. Without this debugging information, you cannot inspect or modify the values of parameters or variables.
Considerations
Use one of the following statements (the second statement recompiles the package or type body) to generate debugging information for existing PL/SQL code:
ALTER [PROCEDURE | FUNCTION | PACKAGE | TRIGGER | TYPE] <name> COMPILE DEBUG;
ALTER [PACKAGE | TYPE] <name> COMPILE DEBUG BODY;
Breakflags
The following values are available for the breakflags parameter of CONTINUE. You can combine these flags.
| Value | Description |
|---|---|
| break_next_line | Break at the next source line (skips calls). |
| break_any_call | Break at the next source line (steps through calls). |
| break_any_return | Break after returning from the current entry point (skips any entry points called by the current routine). |
| break_return | Break when the next entry point is about to return, including entry points called from the current entry point. If the interpreter is running Proc2 called by Proc1, then break_return will stop at the end of Proc2. |
| abort_execution | Stop execution and force the "exit" event once DBMS_DEBUG.CONTINUE is called. |
Information Flags
The following identifiers can be passed as the info requested parameter to SYNCHRONIZE, CONTINUE, and GET_RUNTIME_INFO.
| Identifier | Description |
|---|---|
| info_getStackDepth | Get the current stack depth. |
| info_getBreakpoint | Get the breakpoint number. |
| info_getLineinfo | Get the unit information. |
Overview of DBMS_DEBUG subprograms
The following table lists the DBMS_DEBUG subprograms supported in the current version of OceanBase Database and their brief descriptions.
| Subprogram | Description |
|---|---|
| ATTACH_SESSION | Notifies the debug session of the target DebugID. |
| CONTINUE | Continues execution of the target program. |
| DEBUG_ON | Enables debug mode. |
| DEBUG_OFF | Disables debug mode. |
| DETACH_SESSION | Stops debugging the target program. |
| DELETE_BREAKPOINT | Deletes a breakpoint. |
| DISABLE_BREAKPOINT | Disables a breakpoint. |
| ENABLE_BREAKPOINT | Activates an existing breakpoint. |
| GET_VALUE | Retrieves a value from the currently running program. |
| GET_VALUES | Returns all variable information for the current stack frame. |
| GET_RUNTIME_INFO | Returns information about the current program. |
| GET_TIMEOUT_BEHAVIOUR | Returns the current timeout behavior. |
| INITIALIZE | Sets the DebugID in the target session. |
| PROBE_VERSION | Returns the version number of DBMS_DEBUG on the server. |
| PRINT_BACKTRACE | Prints the stack trace. |
| SET_TIMEOUT | Sets the timeout value. |
| SET_TIMEOUT_BEHAVIOUR | Specifies how to handle the target session when a timeout occurs. |
| SET_BREAKPOINT | Sets a breakpoint in a program unit. |
| SHOW_BREAKPOINTS | Returns a list of current breakpoints. |
