使用dtrace跟蹤oracle函式呼叫
以前用gdb跟蹤過oracle的一些函式呼叫,今天找了本dtrace的書看了看。
dtrace比gdb的能力強大多了,而且簡單了很多。
語法基本是 awk + C,做了3個例子,繼續研究
gdb的例子請看:
Tracing Oracle Internal Calls
http://space.itpub.net/?uid-8242091-action-viewspace-itemid-676943
****************************************************************
1.跟蹤邏輯讀取的塊。
****************************************************************
#!/usr/sbin/dtrace -s
#pragma D option quiet
struct arg {
int32_t arg0;
int32_t arg1;
int32_t arg2;
int32_t arg3;
};
struct arg *arg;
pid$1::kkspsc0:entry{
i=0;
}
pid$1::kcbgtcr:entry{
i++;
arg=(struct arg *)copyin(arg0,sizeof(arg));
printf("%5d %s:%s:%s:%s 0x%08x[%d,%d]\n",i,probeprov,probemod,probefunc,probename, arg->arg1,arg->arg1>>22,arg->arg1&0x3fffff);
}
bash-3.2# ./aaa.d 2068
1 pid2068:oracle:kcbgtcr:entry 0x010000aa[4,170]
2 pid2068:oracle:kcbgtcr:entry 0x010000aa[4,170]
3 pid2068:oracle:kcbgtcr:entry 0x010000ab[4,171]
4 pid2068:oracle:kcbgtcr:entry 0x010000ac[4,172]
5 pid2068:oracle:kcbgtcr:entry 0x010000ad[4,173]
6 pid2068:oracle:kcbgtcr:entry 0x010000ae[4,174]
7 pid2068:oracle:kcbgtcr:entry 0x010000af[4,175]
8 pid2068:oracle:kcbgtcr:entry 0x010000b0[4,176]
9 pid2068:oracle:kcbgtcr:entry 0x010000b1[4,177]
10 pid2068:oracle:kcbgtcr:entry 0x010000b2[4,178]
11 pid2068:oracle:kcbgtcr:entry 0x010000b3[4,179]
12 pid2068:oracle:kcbgtcr:entry 0x010000b4[4,180]
13 pid2068:oracle:kcbgtcr:entry 0x010000b5[4,181]
14 pid2068:oracle:kcbgtcr:entry 0x010000b6[4,182]
15 pid2068:oracle:kcbgtcr:entry 0x010000b7[4,183]
16 pid2068:oracle:kcbgtcr:entry 0x010000b9[4,185]
17 pid2068:oracle:kcbgtcr:entry 0x010000ba[4,186]
18 pid2068:oracle:kcbgtcr:entry 0x010000bb[4,187]
19 pid2068:oracle:kcbgtcr:entry 0x010000bc[4,188]
20 pid2068:oracle:kcbgtcr:entry 0x010000bd[4,189]
21 pid2068:oracle:kcbgtcr:entry 0x010000be[4,190]
22 pid2068:oracle:kcbgtcr:entry 0x010000bf[4,191]
23 pid2068:oracle:kcbgtcr:entry 0x010000c0[4,192]
24 pid2068:oracle:kcbgtcr:entry 0x010000c1[4,193]
25 pid2068:oracle:kcbgtcr:entry 0x010000c2[4,194]
26 pid2068:oracle:kcbgtcr:entry 0x010000c3[4,195]
27 pid2068:oracle:kcbgtcr:entry 0x010000c4[4,196]
28 pid2068:oracle:kcbgtcr:entry 0x010000c5[4,197]
****************************************************************
2.跟蹤latch的獲取和釋放
****************************************************************
SELECT LOWER(addr)||','||NAME||','||'C'||child#||','||latch#||','||level# FROM v$latch_children
UNION ALL
SELECT LOWER(addr)||','||NAME||','||'P'||','||latch#||','||level# FROM v$latch
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option destructive
pid$1::kslgetl:entry,pid$1::kslfre:entry{
printf("%s:%s:%s:%s\t", probeprov,probemod,probefunc,probename);
system("grep %x latchlist.txt",arg0);
}
bash-3.2# ./aaa.d 2068
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
****************************************************************
3.函式呼叫棧
****************************************************************
#!/usr/sbin/dtrace -s
#pragma D option quiet
pid$1::*:entry{
printf("%s.%s.%s", probemod,probefunc,probename);
ustack();
}
dtrace比gdb的能力強大多了,而且簡單了很多。
語法基本是 awk + C,做了3個例子,繼續研究
gdb的例子請看:
Tracing Oracle Internal Calls
http://space.itpub.net/?uid-8242091-action-viewspace-itemid-676943
****************************************************************
1.跟蹤邏輯讀取的塊。
****************************************************************
#!/usr/sbin/dtrace -s
#pragma D option quiet
struct arg {
int32_t arg0;
int32_t arg1;
int32_t arg2;
int32_t arg3;
};
struct arg *arg;
pid$1::kkspsc0:entry{
i=0;
}
pid$1::kcbgtcr:entry{
i++;
arg=(struct arg *)copyin(arg0,sizeof(arg));
printf("%5d %s:%s:%s:%s 0x%08x[%d,%d]\n",i,probeprov,probemod,probefunc,probename, arg->arg1,arg->arg1>>22,arg->arg1&0x3fffff);
}
bash-3.2# ./aaa.d 2068
1 pid2068:oracle:kcbgtcr:entry 0x010000aa[4,170]
2 pid2068:oracle:kcbgtcr:entry 0x010000aa[4,170]
3 pid2068:oracle:kcbgtcr:entry 0x010000ab[4,171]
4 pid2068:oracle:kcbgtcr:entry 0x010000ac[4,172]
5 pid2068:oracle:kcbgtcr:entry 0x010000ad[4,173]
6 pid2068:oracle:kcbgtcr:entry 0x010000ae[4,174]
7 pid2068:oracle:kcbgtcr:entry 0x010000af[4,175]
8 pid2068:oracle:kcbgtcr:entry 0x010000b0[4,176]
9 pid2068:oracle:kcbgtcr:entry 0x010000b1[4,177]
10 pid2068:oracle:kcbgtcr:entry 0x010000b2[4,178]
11 pid2068:oracle:kcbgtcr:entry 0x010000b3[4,179]
12 pid2068:oracle:kcbgtcr:entry 0x010000b4[4,180]
13 pid2068:oracle:kcbgtcr:entry 0x010000b5[4,181]
14 pid2068:oracle:kcbgtcr:entry 0x010000b6[4,182]
15 pid2068:oracle:kcbgtcr:entry 0x010000b7[4,183]
16 pid2068:oracle:kcbgtcr:entry 0x010000b9[4,185]
17 pid2068:oracle:kcbgtcr:entry 0x010000ba[4,186]
18 pid2068:oracle:kcbgtcr:entry 0x010000bb[4,187]
19 pid2068:oracle:kcbgtcr:entry 0x010000bc[4,188]
20 pid2068:oracle:kcbgtcr:entry 0x010000bd[4,189]
21 pid2068:oracle:kcbgtcr:entry 0x010000be[4,190]
22 pid2068:oracle:kcbgtcr:entry 0x010000bf[4,191]
23 pid2068:oracle:kcbgtcr:entry 0x010000c0[4,192]
24 pid2068:oracle:kcbgtcr:entry 0x010000c1[4,193]
25 pid2068:oracle:kcbgtcr:entry 0x010000c2[4,194]
26 pid2068:oracle:kcbgtcr:entry 0x010000c3[4,195]
27 pid2068:oracle:kcbgtcr:entry 0x010000c4[4,196]
28 pid2068:oracle:kcbgtcr:entry 0x010000c5[4,197]
****************************************************************
2.跟蹤latch的獲取和釋放
****************************************************************
SELECT LOWER(addr)||','||NAME||','||'C'||child#||','||latch#||','||level# FROM v$latch_children
UNION ALL
SELECT LOWER(addr)||','||NAME||','||'P'||','||latch#||','||level# FROM v$latch
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option destructive
pid$1::kslgetl:entry,pid$1::kslfre:entry{
printf("%s:%s:%s:%s\t", probeprov,probemod,probefunc,probename);
system("grep %x latchlist.txt",arg0);
}
bash-3.2# ./aaa.d 2068
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslfre:entry 000000009e4a3748,session idle bit,C2,14,1
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslgetl:entry 00000000601069d8,shared pool,C1,307,7
pid2068:oracle:kslfre:entry 00000000601069d8,shared pool,C1,307,7
****************************************************************
3.函式呼叫棧
****************************************************************
#!/usr/sbin/dtrace -s
#pragma D option quiet
pid$1::*:entry{
printf("%s.%s.%s", probemod,probefunc,probename);
ustack();
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-755399/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 像跟蹤分散式服務呼叫那樣跟蹤 Go 函式呼叫鏈分散式Go函式
- 轉:使用 Tkprof 分析 ORACLE 跟蹤檔案Oracle
- Itrace跟蹤程式呼叫庫函式引數選項-怎麼學習linux運維函式Linux運維
- 使用docker-compose 一鍵部署你的分散式呼叫鏈跟蹤框架skywalkingDocker分散式框架
- 呼叫鏈與日誌的關聯式跟蹤查詢
- Oracle資料庫跟蹤SQLOracle資料庫SQL
- Oracle執行語句跟蹤 使用sql trace實現語句追蹤OracleSQL
- [20190401]跟蹤dbms_lock.sleep呼叫.txt
- 分散式呼叫鏈跟蹤工具Jaeger?兩分鐘極速體驗分散式
- oracle跟蹤常用內部事件號Oracle事件
- 使用zipKin構建NetCore分散式鏈路跟蹤NetCore分散式
- 如何使用函式指標呼叫類中的函式和普通函式函式指標
- DiagnosticSource DiagnosticListener 無侵入式分散式跟蹤分散式
- 使用Spring Cloud Sleuth和OpenTelemetry實現分散式跟蹤SpringCloud分散式
- js 使用 DotNetObjectReference 呼叫 c# 函式JSObjectC#函式
- Oracle中Decode()函式的使用Oracle函式
- Welcome to YARP - 8.分散式跟蹤分散式
- 中介軟體---分散式跟蹤---Pinpoint分散式
- [20190917]oracle跟蹤事件簡單寫法.txtOracle事件
- 子函式呼叫函式
- 函式呼叫棧函式
- 使用Excel呼叫ABAP系統的函式Excel函式
- 如何使用python super函式呼叫父類?Python函式
- 基於OpenTelemetry實現Java微服務呼叫鏈跟蹤Java微服務
- 【函式】Oracle12c 列轉行函式使用listagg函式Oracle
- oracle 函式Oracle函式
- oracle or 函式Oracle函式
- Spring Cloud Sleuth 和 Zipkin 進行分散式跟蹤使用指南SpringCloud分散式
- 分散式跟蹤系統zipkin簡介分散式
- 分散式系統的跟蹤系統分散式
- Dapper分散式跟蹤系統論文APP分散式
- 一個非侵入式跟蹤分析程式
- 分散式服務呼叫鏈追蹤分散式
- 使用 Python 和 Prometheus 跟蹤天氣PythonPrometheus
- 如何使用iPhone限制IP地址跟蹤iPhone
- Java呼叫鏈跟蹤關鍵技術(四)SQL監控JavaSQL
- Istio最佳實踐系列:如何實現方法級呼叫跟蹤?
- 外部函式的呼叫函式
- gdb 如何呼叫函式?函式