[20240618]Oracle C functions annotations.txt

lfree發表於2024-07-13
[20240618]Oracle C functions annotations.txt

--//網站orafun.info可以查詢oracle c functions.Created by Frits Hoogland with a little help from Kamil Stawiarski.
--//可以透過它瞭解oracle 內部C 函式.實際上可以直接下載相關檔案,在本地使用.

https://gitlab.com/FritsHoogland/ora_functions/archive/master/ora_functions-master.tar.gz
https://gitlab.com/FritsHoogland/ora_functions

--//例子:
$ ./lookup.awk kgllkal
kgllkal : kernel generic library cache management library cache lock allocate

--//如果是windows系統,如果安裝awk了.可以使用如下:

D:\tools\ora_functions-master>awk -f lookup.awk kgllkal
kgllkal : kernel generic library cache management library cache lock allocate

--//我開始以為我直接使用grep直接查詢functions.csv檔案,實際情況按照層次組織該檔案.透過例子說明:

D:\tools\ora_functions-master>grep -i kgllkal functions.csv
kgllkal|allocate

--//僅僅看到allocate.實際上看lookup.awk 程式碼,執行如下

D:\tools\ora_functions-master>grep -E "^k\||^kg\||^kgl\||^kgllk\||^kgllkal" functions.csv
k|kernel
kg|generic
kgl|library cache management
kgllk|library cache lock
kgllkal|allocate

--//拚接起來就是如下內容:

D:\tools\ora_functions-master>grep -E "^k\||^kg\||^kgl\||^kgllk\||^kgllkal" functions.csv| cut -f2 -d"|" | paste -sd" "
kernel generic library cache management library cache lock allocate

D:\tools\ora_functions-master>awk -f lookup.awk -h
Usage: ./lookup.awk [-w] <function>
<function> = full function name, or part of a function name when used with -w.
-w = wildcard, lookup all functions start with <function>
--//可以使用-w引數,模糊查詢,不過無法使用字首模糊查詢.這個由於函式的組織結構決定的.

D:\tools\ora_functions-master>awk -f lookup.awk -w kgllk
kgllk : kernel generic library cache management library cache lock
kgllkdl : kernel generic library cache management library cache lock delete
kgllkds : kernel generic library cache management library cache lock delete state object
kgllkal : kernel generic library cache management library cache lock allocate
(kgllk)a : kernel generic library cache management library cache lock ??
(kgllk)d : kernel generic library cache management library cache lock ??

--//最後兩個為不完整的資訊,注意結尾出現的??.
D:\tools\ora_functions-master>awk -f lookup.awk kgllka
(kgllk)a : kernel generic library cache management library cache lock ??
--//提示括號內的內容可以查詢到kgllk.
--//另外注意函式的大小寫.

$ ./lookup.awk -w kglget
kglget : kernel generic library cache management get a lock on an object

$ ./lookup.awk -w kglGetMutex
kglGetMutex : kernel generic library cache management get mutex
--//前者沒有找到kglGetMutex.

--//如果pstack的執行結果.例子:

SCOTT@book> select count(*) from emp,emp,dba_objects,dba_objects ;

$ pstack 54305
#0 0x0000000009726543 in qersoFetch ()
#1 0x000000000970b15d in qerjotFetch ()
#2 0x000000000256715f in qergsFetch ()
#3 0x00000000095b5776 in opifch2 ()
#4 0x0000000001ba5c5d in kpoal8 ()
#5 0x00000000095bbdad in opiodr ()
#6 0x00000000097a629f in ttcpip ()
#7 0x000000000186470e in opitsk ()
#8 0x0000000001869235 in opiino ()
#9 0x00000000095bbdad in opiodr ()
#10 0x00000000018607ac in opidrv ()
#11 0x0000000001e3a48f in sou2o ()
#12 0x0000000000a29265 in opimai_real ()
#13 0x0000000001e407ad in ssthrdmain ()
#14 0x0000000000a291d1 in main ()

--//在http://orafun.info/stack/,copy and paste上面內容,顯示如下:
Parsed stack:
Discovered stack type: gdb/pstack stack
Parsed gdb/pstack stack:
#0 0x0000000009726543 in qersoFetch () query execute rowsource sort fetch from from a sort row source
#1 0x000000000970b15d in qerjotFetch () query execute rowsource nested loop outer join tunneling fetch
#2 0x000000000256715f in qergsFetch () query execute rowsource group by sort fetch
#3 0x00000000095b5776 in opifch2 () oracle program interface oracle side of the fetch interface main routine
#4 0x0000000001ba5c5d in kpoal8 () kernel programmatic interface oracle V8 bundled execution
#5 0x00000000095bbdad in opiodr () oracle program interface oracle code request driver, route the current request
#6 0x00000000097a629f in ttcpip () two task common pipe read/write
#7 0x000000000186470e in opitsk () oracle program interface two task function dispatcher
#8 0x0000000001869235 in opiino () oracle program interface initialize opi
#9 0x00000000095bbdad in opiodr () oracle program interface oracle code request driver, route the current request
#10 0x00000000018607ac in opidrv () oracle program interface route current request driver, entry side into two task interface
#11 0x0000000001e3a48f in sou2o () main oracle executable entry point
#12 0x0000000000a29265 in opimai_real () oracle program interface main real oracle start point
#13 0x0000000001e407ad in ssthrdmain () operating system dependent system main for every thread in a threaded oracle
#14 0x0000000000a291d1 in main () (non oracle)general c starting function

--//如果本地操作可以執行如下:
D:\tools\ora_functions-master>awk "{print $4}" a.txt | tr -d "\r" | xargs -iQ awk -f lookup.awk Q"
qersoFetch : query execute rowsource sort fetch from from a sort row source
qerjotFetch : query execute rowsource nested loop outer join tunneling fetch
qergsFetch : query execute rowsource group by sort fetch
opifch2 : oracle program interface oracle side of the fetch interface main routine
kpoal8 : kernel programmatic interface oracle V8 bundled execution
opiodr : oracle program interface oracle code request driver, route the current request
ttcpip : two task common pipe read/write
opitsk : oracle program interface two task function dispatcher
opiino : oracle program interface initialize opi
opiodr : oracle program interface oracle code request driver, route the current request
opidrv : oracle program interface route current request driver, entry side into two task interface
sou2o : main oracle executable entry point. reads environment var ORACLE_SPAWNED_PROCESS.
opimai_real : oracle program interface main real oracle start point
ssthrdmain : operating system dependent system main for every thread in a threaded oracle
main : (non oracle)general c starting function

--//如果是跟蹤檔案裡面記錄的stack資訊,可以執行如下:
kglLock()+1406<-kglget()+293<-qostobkglcrt1()+498<-qostobkglcrt()+248<-qostobkglcrt2()+412<-qospsis()+2511<-qospPostProcessIStats()+2765<-qerltFetch()+1544<-qerstFetch()+449<-insdlexe()+364<-insExecStmtExecIniEngine()+1810<-insexe()+2283<-atbugi_update_global_indexes()+1656<-atbFMdrop()+3088<-atbdrv()+7719

--//另外儲存檔案b.txt,執行如下:
D:\tools\ora_functions-master>cat b.txt | tr "<-" " \n" | sed "s/().*$//"| tr -d "\r" | xargs -iQ awk -f lookup.awk Q
kglLock : kernel generic library cache management library cache lock
kglget : kernel generic library cache management get a lock on an object
(qos)tobkglcrt1 : query optimizer statistics ??
(qos)tobkglcrt : query optimizer statistics ??
(qos)tobkglcrt2 : query optimizer statistics ??
qospsis : query optimizer statistics DBMS_STATS.SET_INDEX_STATS_CALLOUT
(qos)pPostProcessIStats : query optimizer statistics ??
qerltFetch : query execute rowsource load table fetch
qerstFetch : query execute rowsource statistics row source fetch
insdlexe : insert direct load execute
(ins)ExecStmtExecIniEngine : insert ??
insexe : insert execute
(atb)ugi_update_global_indexes : alter table ??
(atb)FMdrop : alter table ??
atbdrv : alter table driver





相關文章