The DBMS_DEBUG system package is primarily used to implement a server-side debugger, providing a method for debugging server-side PL programs.
Applicability
This content applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL-compatible mode.
To debug a PL program using the DBMS_DEBUG system package, you need at least two database sessions: one is the target session for executing the target program, and the other is the debug session for debugging the target program.
A target session is used to initialize debugging for a session, marking the session so that the PL Interpreter runs in debug mode and generates debug events. After debug events are generated, they are published from the session. In most cases, debug events require a response: the Interpreter pauses and waits for an answer.
The debug session must also be initialized using DBMS_DEBUG to identify which target session it is to monitor. After initialization, the debug session can call the entry points of DBMS_DEBUG to read events published by the target session and communicate with it.
DBMS_DEBUG does not provide an interface to the PL compiler, but it relies on the debug information generated by the compiler. Without debug information, it is impossible to examine or modify the values of parameters or variables.
Usage instructions for DBMS_DEBUG
Use one of the following statements (the second statement recompiles the package or type body) to generate debug information for existing PL code:
ALTER [PROCEDURE | FUNCTION | PACKAGE | TRIGGER | TYPE] <name> COMPILE DEBUG;
ALTER [PACKAGE | TYPE] <name> COMPILE DEBUG BODY;
Breakflags
The following table describes the breakflags parameters of CONTINUE. These flags can be combined.
Value |
Description |
|---|---|
| break_next_line | Break at the next source line (skip the call). |
| break_any_call | Break at the next source line (step-by-step call). |
| break_any_return | Return from the current entry point and abort (skip any entry points called from the current routine). |
| break_return | The next entry point is interrupted when it is about to return, including the entry point called from the current entry point. If the interpreter is running a callProc2ofProc1, thenbreak_returnWill be inProc2ends. |
| abort_execution | OnceDBMS_DEBUG.CONTINUEIf called, it stops the execution and forcibly "exits" the event. |
Information Flags
The following identifiers can be passed as the info requested parameter to SYNCHRONIZE, CONTINUE, and GET_RUNTIME_INFO.
Identifier |
Description |
|---|---|
| info_getStackDepth | Gets the current depth of the stack. |
| info_getBreakpoint | Gets the breakpoint number. |
| info_getLineinfo | Retrieves program unit information. |
Overview of DBMS_DEBUG Subprograms
The following table lists the DBMS_DEBUG subprograms supported by the current version of OceanBase Database and provides brief descriptions.
Subprogram |
Description |
|---|---|
| ATTACH_SESSION | Notifies the debug session of the target DebugID. |
| CONTINUE | Continue to execute the target program. |
| DEBUG_ON | Enable debug mode. |
| DEBUG_OFF | Disable debug mode. |
| DETACH_SESSION | Stop debugging the target program. |
| DELETE_BREAKPOINT | Delete a breakpoint. |
| DISABLE_BREAKPOINT | Disables breakpoints. |
| ENABLE_BREAKPOINT | Activates an existing breakpoint. |
| GET_VALUE | Gets a value from the currently running program. |
| GET_VALUES | Returns information about all variables in the current stack frame. |
| GET_RUNTIME_INFO | Returns information about the current program. |
| GET_TIMEOUT_BEHAVIOUR | Returns the current timeout behavior. |
| INITIALIZE | Set the DebugID in the target session. |
| PROBE_VERSION | Returns the version number of DBMS_DEBUG on the server. |
| PRINT_BACKTRACE | Print the stack trace. |
| SET_TIMEOUT | Set the timeout value. |
| SET_TIMEOUT_BEHAVIOUR | Specifies how to handle target sessions when the monitoring thread times out. |
| SET_BREAKPOINT | Set breakpoints in the program unit. |
| SHOW_BREAKPOINTS | Returns the list of current breakpoints. |
