https://baoz.net/using-systemtap/
http://nanxiao.me/category/%E6%8A%80%E6%9C%AF/systemtap-%E7%AC%94%E8%AE%B0/
http://gmd20.blog.163.com/blog/static/168439232015475525227/
http://zhengheng.me/page/3/
http://www.golaravel.com/php/features.dtrace.systemtap.html
http://www.golaravel.com/php/features.dtrace.dtrace.html
http://www.golaravel.com/laravel/docs/5.1/
http://user.yeeyan.org/u/seth

SystemTap is commonly used to probe or trace kernel space system or function calls. Excellent examples are at
https://sourceware.org/systemtap ... temtap-scripts.html

Beginning with certain Linux kernel level, the uprobes kernel module allows SystemTap to probe user space processes. Newer kernel has uprobes module instead. Make sure you have one of the modules configured:

grep CONFIG_UTRACE /boot/config-`uname -r`
grep CONFIG_UPROBES /boot/config-`uname -r`

Other people have used SystemTap to probe Oracle user processes. See examples at
https://sourceware.org/systemtap/wiki/HomePage
Find (press ^F) "oracle" in browser to see them. But they all require that you already know the specific function to probe, such as kslwtbctx that signifies the beginning of a wait event.

Here, I'll use the para-callgraph.stp script from
https://www.sourceware.org/syste ... /paracallgraph.html
to probe Oracle server processes with no prior knowledge of which function to probe; I just want to see what function is called. Since I don't intend to pass the 2nd optional argument (used as trigger), I simplify the para-callgraph.stp script by removing the conditional compilation lines as follows (I renamed the filename to cg.stp to save typing):

# cat cg.stp
#! /usr/bin/env stap

function trace(entry_p, extra) {
printf("%s%s%s %s\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc (),
extra)
}

probe $1.call { trace(1, $$parms) }
probe $1.return { trace(-1, $$return) }

Let's say I want to probe all Oracle server processes calling functions named like kks*:

# stap cg.stp 'process("/u01/app/oracle/product/11.2.0/db/bin/oracle").function("kks*")'
0 oracle(5588):->kksCompileCallNotifier
17 oracle(5588):<-kksCompileCallNotifier
0 oracle(5860):->kksMapCursor
16 oracle(5860):<-kksMapCursor
0 oracle(5860):->kksMapCursor
5 oracle(5860):<-kksMapCursor
^C

Two processes were captured calling kksCompileCallNotifier and kksMapCursor functions, respectively.

We can limit the probe to a specific process with -x option:

# stap cg.stp 'process("/u01/app/oracle/product/12c/db/bin/oracle").function("kks*")' -x 62148
0 oracle_62148_sa(62148):->kksMapCursor
43 oracle_62148_sa(62148): ->kksParentCursor
64 oracle_62148_sa(62148): <-kksParentCursor
71 oracle_62148_sa(62148): ->kksParentCursor
81 oracle_62148_sa(62148): <-kksParentCursor
90 oracle_62148_sa(62148):<-kksMapCursor
0 oracle_62148_sa(62148):->kksCloseCursor
19 oracle_62148_sa(62148): ->kksGetStats
36 oracle_62148_sa(62148): <-kksGetStats
47 oracle_62148_sa(62148): ->kksdip
64 oracle_62148_sa(62148): <-kksdip
89 oracle_62148_sa(62148): ->kksIsVPDCursorSessionCacheable
106 oracle_62148_sa(62148): <-kksIsVPDCursorSessionCacheable
121 oracle_62148_sa(62148):<-kksCloseCursor
0 oracle_62148_sa(62148):->kksMapCursor
^C

One issue is that because the oracle binary has tens of thousands of global and local functions (check with `nm $ORACLE_HOME/bin/oracle | egrep ' [Tt] ' | wc -l), if you simply pass * as the argument to function, stap hogs the CPU for a long time to enumerate the functions and no probe will be done. You have to limit the functions to a small set. My test shows that even trying to probe kk*, not alone k*, takes stap too long to prepare and I have to abort. Focusing on function main can be a start:

stap cg.stp 'process("/u01/app/oracle/product/11.2.0/db/bin/oracle").function("main")'

If you probe other binaries, such as sqlplus or tnslsnr or lsnrctl, passing * is fine. They don't contain too many functions.

Due to this issue, I didn't quite achieve the goal of "want to see what function is called", because I can't pass a simple * and have to qualify it to some extent.

Another issue is that $$parms and $$return, the two so-called pretty printing target variables, are always null for me. If they worked, they would show function parameters and function return value, respectively. See https://sourceware.org/systemtap ... rgetprettyprinting. I was able to use ulong_arg or s64_arg function to get a specific argument (e.g. the first one) in number format, e.g.

function trace(entry_p, extra) {
printf("%s%s%s %ld\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc (),
extra)
}
function trace2(entry_p) {
printf("%s%s%s\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc ())
}

//probe $1.call { trace(1, ulong_arg(1)) }
probe $1.call { trace(1, s64_arg(1)) }
probe $1.return { trace2(-1) }

I have to omit the second argument of the trace function used by return so I changed it to trace2. The result is

0 oracle(5588):->kksCompileCallNotifier 2
10 oracle(5588):<-kksCompileCallNotifier
0 oracle(5860):->kksMapCursor 139787894174976
9 oracle(5860):<-kksMapCursor
^C

systemtap-与 oracle 转的更多相关文章

  1. Life of an Oracle I/O: tracing logical and physical I/O with systemtap

    https://db-blog.web.cern.ch/blog/luca-canali/2014-12-life-oracle-io-tracing-logical-and-physical-io- ...

  2. 使用动态跟踪技术SystemTap监控MySQL、Oracle性能

    [IT168 技术]本文根据吕海波2018年5月11日在[第九届中国数据库技术大会]上的演讲内容整理而成. 讲师介绍: 吕海波,美创科技研究员,ITPUB管理版版主.出版技术书籍<Oracle内 ...

  3. oracle systemtap tracing

    https://github.com/LucaCanali?tab=repositories https://github.com/LucaCanali/Linux_tracing_scripts/t ...

  4. systemtap dtrace与 oracle

    https://fritshoogland.wordpress.com/page/3/ http://externaltable.blogspot.com/2013/06/dtrace-explora ...

  5. 动态追踪技术(中) - Dtrace、SystemTap、火焰图

    http://openresty.org/cn/presentations.html http://weibo.com/agentzh?is_all=1 http://openresty.org/po ...

  6. 内核调试神器SystemTap — 简介与使用(一)

    a linux trace/probe tool. 官网:https://sourceware.org/systemtap/ 简介 SystemTap是我目前所知的最强大的内核调试工具,有些家伙甚至说 ...

  7. linux 内核分析工具 Dtrace、SystemTap、火焰图、crash等

    << System语言详解 >> 关于 SystemTap 的书. 我们在分析各种系统异常和故障的时候,通常会用到 pstack(jstack) /pldd/ lsof/ tc ...

  8. Linux Perf Probes for Oracle Tracing

    Luca Canali on 21 Jan 2016 Topic: this post is about Linux perf and uprobes for tracing and profilin ...

  9. Linux BPF/bcc for Oracle Tracing

    Luca Canali on 26 May 2016 Topic: In this post you will find a short discussion and pointers to the ...

随机推荐

  1. (转)oracle字符集与汉字

    Oracle与汉字问题与字符集 分类: oracle 2012-10-29 17:31 425人阅读 评论(0) 收藏 举报 Oracle字符集引起的几个问题,常见的就是汉字占多少个字节,其次就是字符 ...

  2. python测试api接口

    在开发中,需要测试web-api的接口 spring mvc 使用单元测试非常方便,但是,受不了单元测试的启动速度.用python写了一个小脚本,用于测试接口, 测试脚本配置文件 api.yaml s ...

  3. pku3659 Cell Phone Network

    http://poj.org/problem?id=3659 树状DP,树的最小点覆盖 #include <stdio.h> #include <vector> #define ...

  4. 第二百一十九天 how can I 坚持

    今天好冷,白天在家待了一天,晚上,老贾生日,生日快乐,去海底捞吃了个火锅,没感觉呢. 今天还发现了个好游戏,纪念碑谷,挺新颖,就是难度有点大了. 好累.睡觉,明天想去爬山啊,可是该死的天气.

  5. 【MySql】性能优化之分析命令

    一 当发现程序运行比较慢的时候,首先排除物力资源问题之后,就将注意力转向mysq数据库: 1.首先确定运行慢的sql语句: mysql> show full processlist; 2.确认低 ...

  6. Terrain & Light & Camera

    [Terrain Engine] 1.When you press F, wherever your mouse is positioned will be moved to the center o ...

  7. 自然对数e

    上学时课本里提到过,有一种以无理数e=2.71828--为底数的对数,称为自然对数.当时老师并没有讲明白这是个啥东西.并且还有一个很奇怪的极限,也是靠记忆的,完全不理解. \[\lim_{n\to\i ...

  8. UVaLive 6698 Sightseeing Bus Drivers (水题,贪心)

    题意:n个工人,有n件工作a,n件工作b,每个工人干一件a和一件b,a[i] ,b[i]代表工作时间,如果a[i]+b[j]>t,则老板要额外付钱a[i]+b[j]-t;现在要求老板付钱最少: ...

  9. C# 固定窗体大小且不能鼠标调整大小完美实现

    1.先把MaximizeBox和MinimumBox设置为false,这时你发现最大最小化按钮不见了,但是鼠标仍能调整窗体的大小. 2.有人说直接把MaximumSize和MinimumSize设置成 ...

  10. String.valueOf(null) 报空指针

    String.valueOf 默认的方法 argument 可以为null 的 boolean b = null; char c = null; char[] data = null; double ...