The DBMS_DEBUG package implements server-side debuggers. It provides a way to debug server-side PL programs.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
To debug PL programs by using the DBMS_DEBUG package, you must have at least two database sessions: a target session for executing the program and a debug session for debugging the program.
The target session becomes available for debugging after initializing itself. This marks the target session so that the PL interpreter runs in debug mode and generates debug events. After a debug event is generated, it is posted from the session. In most cases, a debug event requires a return notification. As a result, the interpreter pauses to wait for a response.
At the same time, the debug session must use DBMS_DEBUG to initialize itself to know which target session to monitor. The debug session can then call entry points in DBMS_DEBUG to read events that were posted from the target session and communicate with the target session.
DBMS_DEBUG does not provide an interface to the PL compiler, but it relies on debug information that the compiler may generate. It is impossible to examine or modify the value of parameters or variables without the debug information.
Considerations
You can use one of the following statements to generate debug information for existing PL code. The second statement recompiles a package or type body.
ALTER [PROCEDURE | FUNCTION | PACKAGE | TRIGGER | TYPE] <name> COMPILE DEBUG;
ALTER [PACKAGE | TYPE] <name> COMPILE DEBUG BODY;
Breakflags
The breakflags parameter for CONTINUE can have the following values. These flags can be combined.
| Value | Description |
|---|---|
| break_next_line | Breaks at the next source line (steps over calls). |
| break_any_call | Breaks at the next source line (steps into calls). |
| break_any_return | Breaks after returning from the current entry point (skips over any entry points called from the current routine). |
| break_return | Breaks the next time an entry point is ready to return, including entry points called from the current one. If the interpreter is running Proc1, which calls Proc2, break_return stops at the end of Proc2. |
| abort_execution | Stops execution and forces an exit event immediately after DBMS_DEBUG.CONTINUE is called. |
Information flags
You can pass the following flags as the info_requested parameter to SYNCHRONIZE, CONTINUE, and GET_RUNTIME_INFO.
| Flag | Description |
|---|---|
| info_getStackDepth | Obtains the current depth of the stack. |
| info_getBreakpoint | Obtains the breakpoint number. |
| info_getLineinfo | Obtains information about the program unit. |
Subprograms
The following table describes the DBMS_DEBUG subprograms supported by the current OceanBase Database version.
| Subprogram | Description |
|---|---|
| ATTACH_SESSION | Sends the target debug ID to the debug session. |
| CONTINUE | Continues executing the target program. |
| DEBUG_ON | Turns on the debug mode. |
| DEBUG_OFF | Turns off the debug mode. |
| DETACH_SESSION | Stops debugging the target program. |
| DELETE_BREAKPOINT | Deletes a breakpoint. |
| DISABLE_BREAKPOINT | Disables a breakpoint. |
| ENABLE_BREAKPOINT | Enables a breakpoint. |
| GET_VALUE | Gets a value from the running program. |
| GET_VALUES | Returns information about all the variables in the current stack frame. |
| GET_RUNTIME_INFO | Returns information about the current program. |
| GET_TIMEOUT_BEHAVIOUR | Returns the current timeout behavior. |
| INITIALIZE | Sets a debug ID in the target session. |
| PROBE_VERSION | Returns the version number of DBMS_DEBUG on the server. |
| PRINT_BACKTRACE | Prints a backtrace list of the current execution stack. |
| SET_TIMEOUT | Sets the timeout value. |
| SET_TIMEOUT_BEHAVIOUR | Tells Probe 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. |