Search notes:

Oracle internals: functions

Some module names

KCB Kernel Cache Buffer (Get, change, and release buffers)
KCBL Kernel Cache Buffer Load (Direct I/O routines)

Some functions (some are very speculated)

dbktUnlimitMaxDumpSize Unlimited size for the new trace files, See MOS Note 2677831.1
kcbgcur Kernel Cache Buffer Get Current Read When event 10046 is enabled and this function is called, the value of cu= is incremented. Compare with kcbget
kcbget Kernel Cache Buffer Get Buffer Alexander Anokhin observed, this function is the analog of kcbgcur for index branch and leaf blocks.
kcbgtcr Kernel Cache Buffer Get Consistent Read The entry point for a consistent read. When event 10046 is enabled, callig this function increments the value of cr=. This function receives the pointer to the structure containing a 64-bit variable that stores the object_id in the 32 most significant bits and the block address in the least 32 significant bits (… tested on Oracle 19.13 and 19.14).
kcbispnd Kernel Cache Buffer Is Pinned checks is a buffer pinned yet or not. This function increments statistic either buffer is pinned count or buffer is not pinned count.
kcbldrget Kernel Cache Buffer Load Direct-Read Get This function performs a direct path read. Apparently, the function kcbldrget is called from kcbgtcr See also event 10357, level 8.
kcbrls Kernel Cache Buffer Release Pin
ksudss Dumps a systemstate. Can be called from gdb or dbx: print ksudss(256), which seems to correspond to oradebug dump systemstate 256. See also MOS notes 121779.1 and 273324.1. Compare with ksudps and ksdhng.
ksudps Dumps a processsate. Can be called from gdb or dbx: print ksudps(10), which seems to correspond to oradebug dump processstate 10.
ksdsel Sets an event(?). Can be called from gdb or dbx: print ksdsel(10046,12) equivalent to attached process set 10046 event level 12, which seems to be equivalent to set event 10046 level 12.
kslfre See kslgetl
kslgetl Try to acquire a latch. succcess = kslgetl(addr, willing_to_wait, from_where_acquired, why) ? See also kslfre. Values for where can be queried from x$ksllw. See also Andrey Nikolaev: Latch, mutex and beyond
opilof Session logoff (MOS note 403584.1)
qctcte1 Join elimination? (MOS note 2278359.1)
sdbgrfuwf_write_file Writes text to a tracfile (calls write(3))
skdxipc Can be called from gdb or dbx and seems to be equivalent to oradebug ipc
skdxprst Can be called from gdb or dbx and seems to be equivalent to oradebug procstat
sltrgftime64 Returns a timestamp in μ-seconds. GDB: call (signed long long) sltrgftime64() / 1000 / 1000

Waiting for input from a client over TCP

The callstack of an Oracle User process (thread) when waiting for the next command from the client via TCP (Oracle 19c on Windows):
ntdll!NtWaitForMultipleObjects+0x14
KERNELBASE!WaitForMultipleObjectsEx+0xf0
orantcp19!snttclose+0x37d4
orantcp19!nttini+0x28642
oran19!nsbrecv+0x29a
oran19!nioqrc+0x1d4 (opikndf2()+1116?)
opitsk()+1292
opiino()+1142
opiodr()+1614
opidrv()+816
sou2o()+110
opimai_real()+174
opimai()+268
OracleThreadStart()+643
???
KERNEL32!BaseThreadInitThunk+0x14
ntdll!RtlUserThreadStart+0x21

erroep

erroep throws an exception/error. It's unclear to me how many parameters the function expects nor what they're supposed to mean.
SQL> oradebug call erroep 0 1477 0 0
ORA-01477: user data area descriptor is too large
SQL> oradebug call erroep 1555
ORA-01555: snapshot too old: rollback segment number  with name "" too small

Wait interface: kslwtbctx / kslwtectx

As per Frits Hoogland, kslwtbctx and kslwtectx are the entry points for the wait interface (Kernel service layer wait begin / end context) and the wait number is passed in the function kskthewt (register RSI).
The wait time is passed by calling the function kslwtrk_enter_wait_int (register r13).

Tracing function calls

Function calls can be traced:
SQL> oradebug setospid 14820
SQL> oradebug event sql_trace {callstack: fname opifch2} callstack(3)
SQL> oradebug tracefile_name
Then, in other session:
select …

TODO

create or replace function tq84_kecr_os_seconds return binary_integer is
   language  c
   name     "kecr_OS_seconds"
   library   dbms_workload_capture_lib
   with context
   parameters(context) ;
/

select
   tq84_kecr_OS_seconds - round((sysdate - date '1970-01-01') * 86400) + 1 zero
from
   dual

kkziexecidxddl - Execute a DDL statement as another user:

create or replace procedure tq84_kkziexecidxddl(
    ddl_stmt in varchar2,
    as_user  in varchar2
)
is
   external language c
      name "kkziexecidxddl"
      library dbms_snapshot_lib
   with context
   parameters(context,
      ddl_stmt ocistring, ddl_stmt indicator sb2,
      as_user  ocistring, as_user  indicator sb2
   );
/

grant execute on tq84_kkziexecidxddl to rene;
connect rene/…

exec sys.tq84_kkziexecidxddl('create table tq84_table_in_sys_created_by_rene(n number)', 'SYS');
connect sys/…
desc tq84_table_in_sys_created_by_rene;

ktfa_signal_error - Raise an error

create or replace procedure tq84_ktfa_signal_error(
   error_code      in pls_integer,
   error_arg_1     in varchar2 := null,
   error_arg_2     in varchar2 := null,
   error_arg_3     in varchar2 := null,
   error_arg_4     in varchar2 := null)
is
   external language c
      name "ktfa_signal_error"
      library dbms_fda_lib
   with context
   parameters(context,
      error_code     ub2,        error_code      indicator sb2,
      error_arg_1    string,     error_arg_1     indicator sb2,
      error_arg_2    string,     error_arg_2     indicator sb2,
      error_arg_3    string,     error_arg_3     indicator sb2,
      error_arg_4    string,     error_arg_4     indicator sb2
   );
/
  
begin
   tq84_ktfa_signal_error(6550, 'one', 'two', 'three', 'four');
end;
/
--
-- ORA-06550: line one, column two:
Compare with ktbdat_signal_err

kupuxCreateDir - Create a directory

create or replace procedure
   tq84_kupuxCreateDir(path in varchar2)
is
   external language c
      name   "kupuxCreateDir"
      library kupulib
   with context
   parameters ( context,
      path string,
      path length,
      path indicator
   );
/

begin
   tq84_kupuxCreateDir('/tmp/test');
end;
/

begin
   tq84_kupuxCreateDir('/tmp/directories/with/multiple/levels');
end;
/

plsql_run

plsql_run executes a PL/SQL function called from SQL.

See also

A way to find function names and the amount of parameters is using oradebug dump errorstack.
Memory addresses (in the .text segment of the executable of Oracle) can be translated to function names with oradebug translate_addr.
Using _dump_qbc_tree can possibly be used to reveal interesting function names and how they're called.

Links

Alexander Anokhin: Dynamic tracing of Oracle logical I/O: part 2. Dtrace LIO v2 is released.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1745360019, '3.144.99.0', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/internals/functions/index(247): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78