From 184b9da7621b2fe0c588801fc0a4e94f6557bdeb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 30 Jan 2009 16:08:39 -0500 Subject: reduce systemtap.log contribution by semok/twenty.stp --- testsuite/ChangeLog | 4 ++++ testsuite/semok/twenty.stp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index e374565d..d14375a3 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-01-30 Frank Ch. Eigler + + * semok/twenty.stp: Don't spew so much into systemtap.log. + 2009-01-30 Dave Brolley * lib/systemtap.exp (setup_systemtap_environment): Make sure that diff --git a/testsuite/semok/twenty.stp b/testsuite/semok/twenty.stp index 46dcefca..73dbb3bf 100755 --- a/testsuite/semok/twenty.stp +++ b/testsuite/semok/twenty.stp @@ -1,5 +1,7 @@ -#! stap -wp2 +#! /bin/sh +set -e +stap -wp2 -e ' probe kernel.function("*") {} probe module("*").function("*") {} probe kernel.function("*").call {} @@ -8,3 +10,6 @@ probe kernel.function("*").return {} probe module("*").function("*").return {} probe kernel.function("*").inline {} probe module("*").function("*").inline {} +' | wc + +# without the |wc, we'd log the humongous list of stuff stap -p2 prints -- cgit From 255b5e73f14c9fc72e5566edf595ab8df184f14f Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 30 Jan 2009 16:56:08 -0500 Subject: Correct ChangeLog date type. --- testsuite/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index d14375a3..41b99541 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -8,7 +8,7 @@ the build directory is on the path if using a server for 'make check'. Use a string to check $server_pid. -2009-01-23 Will Cohen +2009-01-30 Will Cohen * systemtap.samples/scf.stp: * systemtap.samples/scf2.stp: Remove -- cgit From 7627c52330b476c13498144cd1288be0f5869e0f Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 30 Jan 2009 17:00:15 -0500 Subject: Remove systemtap.samples/queue_demo.{exp|stp}. --- testsuite/ChangeLog | 5 +++++ testsuite/systemtap.samples/queue_demo.exp | 13 ------------ testsuite/systemtap.samples/queue_demo.stp | 32 ------------------------------ 3 files changed, 5 insertions(+), 45 deletions(-) delete mode 100644 testsuite/systemtap.samples/queue_demo.exp delete mode 100644 testsuite/systemtap.samples/queue_demo.stp diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 41b99541..07f2a15c 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-30 Will Cohen + + * systemtap.samples/queue_demo.exp: + * systemtap.samples/queue_demo.stp: Remove. + 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. diff --git a/testsuite/systemtap.samples/queue_demo.exp b/testsuite/systemtap.samples/queue_demo.exp deleted file mode 100644 index 49dfac05..00000000 --- a/testsuite/systemtap.samples/queue_demo.exp +++ /dev/null @@ -1,13 +0,0 @@ -set test "queue_demo" -if {![installtest_p]} { untested $test; return } - -spawn stap $srcdir/$subdir/queue_demo.stp -set ok 0 -expect { - -timeout 240 - -re {block-[^\r]*} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} - -if {$ok > 4 && $ok < 10} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/queue_demo.stp b/testsuite/systemtap.samples/queue_demo.stp deleted file mode 100644 index 61a3b6d1..00000000 --- a/testsuite/systemtap.samples/queue_demo.stp +++ /dev/null @@ -1,32 +0,0 @@ - -probe begin { - qsq_start ("block-read") - qsq_start ("block-write") -} - -probe timer.ms(3500), end { - qsq_print ("block-read") - qsq_start ("block-read") - qsq_print ("block-write") - qsq_start ("block-write") -} - -probe timer.ms(10000) { exit () } - - -# synthesize queue work/service using three randomized "threads" for each queue. - -global tc -function qs_doit (thread, name) { - n = tc[thread] = (tc[thread]+1) % 3 # per-thread state counter - if (n==1) qs_wait (name) - else if (n==2) qs_run (name) - else if (n==0) qs_done (name) -} - -probe timer.ms(100).randomize(100) { qs_doit (0, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (1, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (2, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (3, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (4, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (5, "block-write") } -- cgit From 9a8d8be369cd1d2ac148b367e1c4b74ab9a005ba Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Fri, 30 Jan 2009 18:54:06 -0500 Subject: PR6936: Add systemtap initscript and systemtap-initscript subpackage. --- ChangeLog | 7 + NEWS | 5 + configure | 3 +- configure.ac | 2 +- initscript/ChangeLog | 6 + initscript/README.initscript | 355 +++++++++++++++++++++++ initscript/config | 20 ++ initscript/systemtap.in | 664 +++++++++++++++++++++++++++++++++++++++++++ systemtap.spec | 40 +++ 9 files changed, 1100 insertions(+), 2 deletions(-) create mode 100644 initscript/ChangeLog create mode 100644 initscript/README.initscript create mode 100644 initscript/config create mode 100644 initscript/systemtap.in diff --git a/ChangeLog b/ChangeLog index 62708e24..618588a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-30 Masami Hiramatsu + + PR6936 + * configure.ac (AC_CONFIG_FILES): Add initscript/systemtap.in. + * configure: Regenerated. + * systemtap.spec: Add systemtap-initscript subpackage. + 2009-01-30 Dave Brolley * Makefile.am (install-scripts): New target. Set exec_prefix and diff --git a/NEWS b/NEWS index 47d4199b..25ebcccf 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ * What's new +- Systemtap initscript is available. This initscript allows you to run + systemtap scripts as system services (in flight recorder mode) and + control those scripts individually. + See README.initscript for details. + - The stap "-r DIR" option may be used to identify a hand-made kernel build directory. The tool determines the appropriate release string automatically from the directory. diff --git a/configure b/configure index 4f63ffda..7bf7bb14 100755 --- a/configure +++ b/configure @@ -7937,7 +7937,7 @@ _ACEOF ac_config_headers="$ac_config_headers config.h:config.in" -ac_config_files="$ac_config_files Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" +ac_config_files="$ac_config_files Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 initscript/systemtap" @@ -8644,6 +8644,7 @@ do "man/stapprobes.socket.5") CONFIG_FILES="$CONFIG_FILES man/stapprobes.socket.5" ;; "man/stapprobes.tcp.5") CONFIG_FILES="$CONFIG_FILES man/stapprobes.tcp.5" ;; "man/stapprobes.udp.5") CONFIG_FILES="$CONFIG_FILES man/stapprobes.udp.5" ;; + "initscript/systemtap") CONFIG_FILES="$CONFIG_FILES initscript/systemtap" ;; "run-stap") CONFIG_FILES="$CONFIG_FILES run-stap" ;; *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 diff --git a/configure.ac b/configure.ac index a0d18c29..542b3b48 100644 --- a/configure.ac +++ b/configure.ac @@ -335,7 +335,7 @@ dnl Don't use this directly (when not given it is set to NONE). AC_DEFINE_UNQUOTED(STAP_PREFIX, "$prefix", [configure prefix location]) AC_CONFIG_HEADERS([config.h:config.in]) -AC_CONFIG_FILES(Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) +AC_CONFIG_FILES(Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 initscript/systemtap) AC_CONFIG_SUBDIRS(testsuite) AC_CONFIG_FILES([run-stap], [chmod +x run-stap]) AC_OUTPUT diff --git a/initscript/ChangeLog b/initscript/ChangeLog new file mode 100644 index 00000000..3672a901 --- /dev/null +++ b/initscript/ChangeLog @@ -0,0 +1,6 @@ +2009-01-30 Masami Hiramatsu + + PR6936 + * systemtap.in: First commit of systemtap initscript. + * README.initscript: Ditto. + * config: Ditto. diff --git a/initscript/README.initscript b/initscript/README.initscript new file mode 100644 index 00000000..f566cf71 --- /dev/null +++ b/initscript/README.initscript @@ -0,0 +1,355 @@ +Systemtap initscript +Version 0.2 +Author: Masami Hiramatsu + +INDEX +===== +1. Introduction +2. Usage +3. Files +4. Configuration Format +5. How to use + +1. Introduction +=============== +Systemtap initscript aims to provide +- running systemtap script as a service with dependency. +- easy way to control(start/stop) those scripts individually. +The dependency means that which user-defined systemtap script is required by +other script (Here the scripts don't include tapsets). This dependency +will be useful for users who use -DRELAY_HOST and -DRELAY_GUEST. + +2. Usage +======== +2.1 Synopsis + +/sbin/service systemtap {start|stop|restart|status|compile|cleanup} \ + [-r kernelrelease] [-c config] [-R] [-y] [script(s)] + +2.2 Commands + You have to specify one of the below commands. + +2.2.1 start + Run script(s). If the script(s) is already started, the command will be + ignored. If it fails to start, return FAIL. If AUTOCOMPILE option is 'yes' + (see 4.1.9), this will try to compile or update the specified script when + one of the below condition is true. + - compiled cache file does not exist. + - mtime (modified time stamp) of original script file is newer than compiled + script cache. + - script options which is used when compiling(see 4.2.1) has been changed. + - result of `uname -a` has been changed. + If no scripts specified from command line, it starts all scripts in the script + directory or the scripts specified by DEFAULT_START in config (see 4.1.10). + +2.2.2 stop + Stop script(s). If the script(s) is already stopped, this will be ignored. + If it fails to stop, return FAIL. + If no scripts specified from command line, it stops all running scripts. + +2.2.3 restart + Stop and start script(s) again. + +2.2.4 status + Show running script(s) status and dependency. + +2.2.5 compile + Compile script(s) on the specified kernel. This command takes '-r' option + which specifies the release of the kernel(see 2.3.4) on which you would + like to compile script(s). This command asks user whether it can overwrite +existing caches. + +2.2.6 cleanup + Cleanup compiled script(s) from cache directory(see 3.4). This command also + takes '-r' option. If '-r' option is omitted, cleanup all caches for running + kernel. This command asks user whether it can remove caches. + +2.3 Options + Systemtap initscript can have some options. However, since user can't pass + these options on boot, these options are only for testing or managing scripts + after booting. + +2.3.1 -c config_path + You can specify configuration path of this initscript. + +2.3.2 script(s) + You can specify individual scripts to the commands. If you omit to specify + any script, systemtap initscript will execute the command with all scripts + in the script directory(except 'start' and 'stop' command, see 2.2.1 and + 2.2.2). + +2.3.3 -R + If this option is specified, systemtap initscript will try to solve + dependency of specified script(s). This option is always set if you don't + specify any script(s) from command line. + +2.3.4 -r kernelrelease + You can specify release version of the kernel(e.g. 2.6.26.1). This option + is valid only with compile and cleanup commands. + +2.3.5 -y + Answer yes for all questions. + +2.4 Misc +2.4.1 Service Priority + Each initscript has execution priority. Since user would like to trace + other services by using systemtap, systemtap initscript should have the + highest priority. + +3. Files +======== +3.1 initscript + /etc/init.d/systemtap + + This file is an executable bash script. + +3.2 Configurations + Configuration files are written in bash script. + +3.2.1 Global config file + /etc/systemtap/config + + This config file is for global parameters(see 4.1). + +3.2.2 Script config files + /etc/systemtap/conf.d/*.conf + + The config files under this directory are for each scripts or script groups + (see 4.2). + +3.3 Script directory + /etc/systemtap/script.d/ + + Systemtap initscript finds systemtap scripts from this directory. + +3.3.1 Scripts in the directory + /etc/systemtap/script.d/.stp + + Systemtap scripts stored in the script directory must have ".stp" suffix. + +3.4 Cache directory + /var/cache/systemtap// + + Systemtap initscript stores compiled scripts in this directory. + +3.4.1 Compiled scripts (or script caches) + /var/cache/systemtap//.ko + /var/cache/systemtap//.opts + + *.ko file is the compiled script, and *.opts is the file which stores + stap options and uname -a. + +3.5 Message Log + /var/log/systemtap.log + + All messages including compilation errors and detailed messages are sent + to this file. + Some error and warning messages are also sent to console and syslogd (syslog + output is optional, because this service will start before syslog). + +3.7 Status files + /var/run/systemtap/ + + +4. Configuration Format +======================= +Configuration file allows us +- specifying options for each script +- supporting flight recorder mode (on file or memory) + +4.1 Global Parameters + +4.1.1 SCRIPT_PATH + Specify the absolute path of the script directory. + (default: /etc/systemtap/script.d) + +4.1.2 CONFIG_PATH + Specify the absolute path of the script config directory. + (default: /etc/systemtap/conf.d) + +4.1.3 CACHE_PATH + Specify the absolute path of the parent directory of the cache directory. + (default: /var/cache/systemtap) + +4.1.4 TEMP_PATH + Specify the absolute path of the temporary directory on which systemtap + initscript make temporary directories to compile scripts. + (default: /tmp) + +4.1.5 STAT_PATH + Specify the absolute path of the running status directory. + (default: /var/run/systemtap) + +4.1.6 LOG_FILE + Specify the absolute path of the log file + (default: /var/log/systemtap.log) + +4.1.7 PASSALL + If this is set 'yes', systemtap initscript will fail when it fails + to run one of the scripts. If not, systemtap initscript will not + fail(just warn). + (default: yes) + +4.1.8 RECURSIVE + If this is set 'yes', systemtap initscript will always follow script + dependencies. This means, you don't need to specify '-R' option. This flag is + effective only if you specify script(s) from command line. + (default: no) + +4.1.9 AUTOCOMPILE + If this is set 'yes', systemtap initscript automatically tries to compile + specified script if there is no valid cache. Otherwides, it just fails to + run script(s). + (default: yes) + +4.1.10 DEFAULT_START + Specify scripts which will be started by default. If omitted (or empty), + all scripts in the script directory will be started. + (default: "") + +4.1.11 ALLOW_CACHEONLY + If this is set 'yes', systemtap initscript list up cache-only scripts too. + *NOTE*: systemtap initscript will load unexpected obsolate caches with this + option. You should check cache directory before enabling this option. + (default: no) + +4.2 Script Parameters + +4.2.1 _OPT + Specify options passed to stap command for each script. "script-name" is the + name of the script file without the suffix extension(.stp). + Some options are just ignored. And even if you don't specify -F option, + systemtap initscript always add it for flight recorder mode. + - Below options are ignored when compiling script. + -p,-m,-r,-c,-x,-e,-s,-o,-h,-V,-k + - Below options are ignored when starting script. + -h,-V,-M,-v,-t,-p,-I,-e,-R,-r,-m,-k,-g,-P,-D,-b,-u,-q,-w,-l,-d,-L,-F, and + other long options. + +4.2.2 _REQ + Specify script dependency(which script this script requires). + For example, "foo.stp" script requires(or run after) "bar.stp" script, set + + foo_REQ="bar" + + If the script requires many scripts, set all scripts separated by spaces. + + foo_REQ="bar baz" + +4.3 Configuration Example + +4.3.1 Global Config Example +--- +SCRIPT_PATH=/var/systemtap/script.d/ +PASSALL=yes +RECURSIVE=no +--- + +4.3.2 Script Config Example +--- +script1_OPT="-o /var/log/script1.out -DRELAYHOST=group1" +script2_OPT="-DRELAYGUEST=group1" +script2_REQ=script1 +--- + +5. How to use +============= + +5.1 Package Installation + After installing systemtap package, install systemtap-initscript package. + # yum install systemtap-initscript + This package will include initscript and default configuration file and + other files. + +5.2 Script installation +5.2.1 Installing script files + Copy a systemtap script ("script1.stp") into script directory. + # cp script1.stp /etc/systemtap/script.d/ + +5.2.2 Configuration script options + Add configuration file to specify options. + # vi /etc/systemtap/conf.d/group1 + script1_OPT="-o /var/log/group1.log -DRELAYHOST=group1" + +5.2.3 Installing script file with dependency + For example, a script("script2.stp") which shares buffer with another + script("script1.stp"), there is a dependency. In this case, you just do + as following. + + # cp script2.stp /etc/systemtap/script.d/ + # vi /etc/systemtap/conf.d/group1 + script2_OPT="-DRELAYGUEST=group1" + script2_REQ=script1 + + In this case, if stap fails to run script1.stp, systemtap initscript will + not run script2.stp. + +5.3 Testing + After installing all scripts, please make sure to run service successfully. + # service systemtap start + # service systemtap stop + If there is no error, we are ready to use it. + +5.4 Service Enabling + After all test passed, enable systemtap initscript. + # chkconfig systemtap on + +5.5 Adding script +5.5.1 Installing and configuring new scripts + Copy new systemtap script("script3.stp") into script directory. + # cp script3.stp /etc/systemtap/script.d/ + and configure it. + # vi /etc/systemtap/conf.d/group1 + script3_OPT="-DRELAYGUEST=group1" + script3_REQ="script1" + +5.5.2 Start new script + If you've already started systemtap initscript, just start new script. + # service systemtap start script3 + +5.6 Deleting script +5.6.1 Deleting old script + Remove old script ("script2.stp") and remove configure lines + # rm /etc/systemtap/script.d/script2.stp + # vi /etc/systemtap/conf.d/group1 + (delete script2_OPT and script2_REQ) + +5.6.2 Stopping old script and cleanup + Stop old script. + # service systemtap stop script2 + And cleanup the script caches. + # service systemtap cleanup script2 + +5.7 Updating kernel + Usually, you don't need to do anything. Systemtap initscript checks the + kernel version when starting the service, and compile scripts. + (If you would like to use compiled scripts due to lack of compiler or + debuginfo on the system, see 5.8) + However, if you want to avoid compiling when booting system, you can prepare + script caches for new kernel. + # service systemtap compile -r + +5.8 Using with compiled scripts + Sometimes, production systems don't have any compilation environment. Even + though, you can use systemtap initscript with compiled scripts as script + caches, which are compiled on other machine (but same software environment). + +5.8.1 Preparing compiled scripts + As described in 5.2, installing scripts and configure it on the compiling + machine (which has compilation environment). + After that, compile those scripts. + # service systemtap compile -r + And package the compiled scripts and configuration file. + # tar czf stap-scripts-.tar.gz \ + /var/cache/systemtap/ /etc/systemtap/conf.d/ + And copy this package to the target machine. + +5.8.2 Installing pre-compiled scripts + On the target machine, unpackage the compiled scripts into cache + directory. + # tar xzf stap-scripts-.tar.gz -C /var/cache/systemtap/ + # mv /var/cache/systemtap/ /etc/systemtap/conf.d/ + At last, set AUTOCOMPILE=no and ALLOW_CACHEONLY=yes in config file. + # vi /etc/systemtap/config + AUTOCOMPILE=no + ALLOW_CACHEONLY=yes diff --git a/initscript/config b/initscript/config new file mode 100644 index 00000000..c49a34a5 --- /dev/null +++ b/initscript/config @@ -0,0 +1,20 @@ +# Path setup +# SCRIPT_PATH=/etc/systemtap/script.d +# CONFIG_PATH=/etc/systemtap/conf.d +# CACHE_PATH=/var/cache/systemtap +# STAT_PATH=/var/run/systemtap +# TEMP_PATH=/tmp +# LOG_FILE=/var/log/systemtap.log + +# Fail unless all scripts succeeded to run +# PASSALL=yes + +# Always follows script dependencies +# RECURSIVE=no + +# Automatically recompile scripts if caches are old or do not exist. +# AUTOCOMPILE=yes + +# Start these scripts by default. If omitted, all scripts are started. +# DEFAULT_START= + diff --git a/initscript/systemtap.in b/initscript/systemtap.in new file mode 100644 index 00000000..eaa1d969 --- /dev/null +++ b/initscript/systemtap.in @@ -0,0 +1,664 @@ +#!/bin/bash +# +# systemtap Startup script for systemtap scrips +# +# chkconfig: - 00 99 +# description: Systemtap is a programable kernel/application tracing tool. +# config: /etc/systemtap/config +# config: /etc/systemtap/conf.d +### BEGIN INIT INFO +# Provides: Systemtap scripts startup +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Short-Description: start and stop systemtap scripts +# Description: Systemtap is a programable kernel/application tracing tool. +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +prog=systemtap + +# Commands +STAP=@bindir@/stap +STAPRUN=@bindir@/staprun +UNAME=/bin/uname +LSMOD=/sbin/lsmod + +# Path setup +SCRIPT_PATH=/etc/systemtap/script.d +CONFIG_PATH=/etc/systemtap/conf.d +CACHE_PATH=/var/cache/systemtap +STAT_PATH=/var/run/systemtap +TEMP_PATH=/tmp +LOG_FILE=/var/log/systemtap.log + +# FAIL unless all scripts succeeded to run +PASSALL=yes + +# Always follows script dependencies +RECURSIVE=no + +# Automatically recompile scripts if caches are old or do not exist. +AUTOCOMPILE=yes + +# Start these scripts by default. If omitted, all scripts are started. +DEFAULT_START= + +# Allow cache only scripts +ALLOW_CACHEONLY=no + +# Optional settings +CONFIG=/etc/systemtap/config +SCRIPTS= +KRELEASE=`uname -r` +OPT_RECURSIVE= +OPT_SCRIPTS= +OPTS= +OPT_ASSUMEYES= + +echo_usage () { + echo $"Usage: $prog {start|stop|restart|status|compile|cleanup} [option]" + echo $"Options:" + echo $" -c configfile : specify config file" + echo $" -r kernelrelease: specify kernel release version" + echo $" -R : recursively dependency checking" + echo $" -y : answer yes for all questions." + echo $" script(s) : specify systemtap scripts" +} + +#----------------------------------------------------------------- +# Helper functions +#----------------------------------------------------------------- +log () { # message + echo `LC_ALL=en date +"%b %e %T"`": $1" >> "$LOG_FILE" +} +clog () { # message [-n] + echo $2 $1 + log "$1" +} +slog () { # message + logger "$1" # if syslogd is running, this message will be sent to syslog. + log "$1" +} +logex () { # command + eval log \"Exec: $@\" + "$@" >> "$LOG_FILE" 2>&1 + return $? +} +do_warning () { # message + slog "Warning: $1" + warning "$1" +} +do_failure () { # message + slog "Error: $1" + failure "$1" +} +do_success () { # message + log "Pass: $1" + success "$1" +} +# Normalize options +check_bool () { # value + case $1 in + n|N|no|No|NO|0) + return 0;; + y|Y|yes|Yes|YES|1) + return 1;; + *) + return 2;; + esac +} +ask_yesno () { # message + local yn ret=2 + [ "$OPT_ASSUMEYES" ] && return 1 + while [ $ret -eq 2 ]; do + echo -n "$1 [y/N]: " + read yn + [ -z "$yn" ] && return 0 + check_bool $yn + ret=$? + done + return $ret +} + +#------------------------------------------------------------------ +# Parameter parsing and setup options +#------------------------------------------------------------------ +parse_args () { # arguments + while [ -n "$1" ]; do + case "$1" in + -c) + CONFIG=$2 + shift 1 + ;; + -r) + KRELEASE=$2 + shift 1 + ;; + -R) + OPT_RECURSIVE=1 + ;; + -y) + OPT_ASSUMEYES=1 + ;; + --) + ;; + *) + OPT_SCRIPTS=$OPT_SCRIPTS\ $1 + ;; + esac + shift 1 + done +} + +CMD=$1 +shift 1 +OPTS=`getopt -s bash -u -o 'r:c:R' -- $@` +if [ $? -ne 0 ]; then + slog "Error: Argument parse error: $@" + failure $"parse error" + echo_usage + exit 3 +fi +parse_args $OPTS + +# Include configs +. "$CONFIG" + +for f in "$CONFIG_PATH"/*.conf; do + if [ -f "$f" ]; then + . "$f" + fi +done + +check_bool $PASSALL +PASSALL=$? +check_bool $RECURSIVE +RECURSIVE=$? +if [ "$OPT_RECURSIVE" ]; then # -r option overrides RECURSIVE. + RECURSIVE=1 +fi +check_bool $AUTOCOMPILE +AUTOCOMPILE=$? +CACHE_PATH="$CACHE_PATH/$KRELEASE" + +check_bool $ALLOW_CACHEONLY +ALLOW_CACHEONLY=$? + +__get_all_scripts () { + local s + if [ $ALLOW_CACHEONLY -eq 1 ]; then + for s in "$CACHE_PATH"/*.ko; do + if [ -f "$s" ]; then + basename "$s" | sed s/\.ko$//g + fi + done + fi + for s in "$SCRIPT_PATH"/*.stp; do + if [ -f "$s" ]; then + basename "$s" | sed s/\.stp$//g + fi + done +} + +get_all_scripts() { + __get_all_scripts | sort | uniq +} + +if [ -z "$OPT_SCRIPTS" ]; then + SCRIPTS=`get_all_scripts | xargs` + RECURSIVE=1 +else + SCRIPTS="$OPT_SCRIPTS" +fi + +#------------------------------------------------------------------ +# Main routine +#------------------------------------------------------------------ +NR_FAILS=0 +might_fail () { # message exitcode + if [ $PASSALL -eq 1 ]; then + do_failure "$1" + echo + [ -z "$2" ] && exit 1 + exit $2 + else + log "Warning: "$1 + NR_FAILS=$((NR_FAILS+1)) + return 0 + fi +} +might_success () { # message + if [ $NR_FAILS -ne 0 ]; then + log "Warning: $NR_FAILS failure occured." + do_warning "$1" + else + do_success "$1" + fi + return 0 +} + +get_all_runnings () { + local f + for f in "$STAT_PATH"/*; do + if [ -f "$f" ]; then + basename "$f" + fi + done +} + +get_daemon_pid () { # script + cat "$STAT_PATH/$1" +} + +check_running () { # script + local m f + f="$STAT_PATH/$1" + m=`$LSMOD | grep "^$1 "` + if [ "$m" ]; then + [ -f "$f" ] && return 0 # running + return 4 # another script is running + else + [ -f "$f" ] && return 1 # dead, but pidfile remains + return 3 # dead + fi +} + +# check whether a script cache need to be updated. +check_cache () { # script opts + local s tmp tmp2 + s=$1; shift 1 + [ ! -f "$CACHE_PATH/$s.ko" -o ! -f "$CACHE_PATH/$s.opts" ] && return 1 + if [ $ALLOW_CACHEONLY -ne 1 -o -f "$SCRIPT_PATH/$s.stp" ]; then + [ "$SCRIPT_PATH/$s.stp" -nt "$CACHE_PATH/$s.ko" ] && return 2 + fi + tmp=`head -n 1 "$CACHE_PATH/$s.opts"` + tmp2=`$UNAME -a` + [ "$tmp" != "$tmp2" ] && return 3 + tmp=`tail -n 1 "$CACHE_PATH/$s.opts"` + tmp2="$*" + [ "$tmp" != "$tmp2" ] && return 4 + return 0 +} + +stap_getopt () { # opts + local ret + # TODO: support quoted options + getopt -s bash -u \ + -l 'kelf,kmap::,ignore-vmlinux,ignore-dwarf,vp:' \ + -o 'hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:F' -- $@ + ret=$? + [ $ret -ne 0 ] && slog "Failed to parse parameters. ($@)" + return $ret +} + +get_compile_opts () { # opts + local opts o skip + opts=`stap_getopt $*` + [ $? -ne 0 ] && return 1 + skip=0 + for o in $opts; do + if [ $skip -ne 0 ]; then skip=0; continue; fi + case $o in + -p|-m|-r|-c|-x|-e|-s|-o) + skip=1 ;; + -h|-V|-k) + ;; + *) + echo -n $o" " ;; + esac + done +} + +get_run_opts () { # normalized_opts + local opts o show + opts=`stap_getopt $*` + [ $? -ne 0 ] && return 1 + show=0 + for o in $opts; do + case $o in + -c|-x|-s|-o) + [ $o == '-s' ] && o='-b' + echo -n $o" " + show=1 + ;; + *) + if [ $show -ne 0 ]; then + echo -n $o" " + show=0 + fi + ;; + esac + done +} + +prepare_cache_dir () { + if [ ! -d "$CACHE_PATH" ]; then + logex mkdir -p "$CACHE_PATH" + [ $? -ne 0 ] && return 1 + fi + return 0 +} + +prepare_stat_dir () { + if [ ! -d "$STAT_PATH" ]; then + logex mkdir -p "$STAT_PATH" + [ $? -ne 0 ] && return 1 + fi + return 0 +} + +compile_script () { # script checkcache + local opts f tmpdir ret + eval f="$SCRIPT_PATH/$1.stp" + if [ ! -f "$f" ]; then + if [ $ALLOW_CACHEONLY -eq 1 ]; then + clog "Warning: no script file($f). Use compiled cache." + return 0 + else + clog "Error: no script file($f)." + return 1 + fi + fi + + eval opts=\$$1_OPT + opts=`get_compile_opts $opts` + [ $? -ne 0 ] && return 2 + + if [ "$2" = "check" ]; then + check_cache $1 $opts + [ $? -eq 0 ] && return 0 # already compiled + if [ $AUTOCOMPILE -eq 0 ]; then + slog "No valid cache for $1" + return 1 + fi + fi + + clog " Compiling $1 ... " -n + tmpdir=`mktemp -d -p "$TEMP_PATH" cache.XXXXXXXX` + if [ $? -ne 0 ]; then + clog "failed to create temporary directory." + return 1 + fi + pushd "$tmpdir" &> /dev/null + logex $STAP -m "$1" -p4 -r $KRELEASE $opts "$f" + ret=$? + if [ $ret -eq 0 ]; then + $UNAME -a > "$1.opts" + echo $opts >> "$1.opts" + logex mv "$1.ko" "$1.opts" "$CACHE_PATH/" + ret=$? + else + slog "Failed to compile script($1)." + fi + popd &> /dev/null + rm -rf $tmpdir + [ $ret -eq 0 ] && clog "done" || clog "error" + return $ret +} + +# dependency resolver +__SORTED= +__follow_dependency () { # script requesters + local opts r reqs s ret + s=$1 + shift 1 + r=`echo \ $*\ | grep \ $s\ ` + if [ -n "$r" ]; then + might_fail $"Dependency loop detected on $s" + return 1 + fi + r=`echo \ $__SORTED\ | grep \ $s\ ` + [ -n "$r" ] && return 0 # already listed up + eval reqs=\$${s}_REQ + if [ -n "$reqs" ]; then + for r in $reqs; do + __follow_dependency $r $s $* + ret=$? + if [ $ret -ne 0 ]; then + return $ret # if one of requires failed, we can't run this script. + fi + done + fi + echo -n "$s " + return 0 +} + +sort_dependency () { # scripts + local s r=0 + __SORTED= + for s in $*; do + __SORTED="$__SORTED "`__follow_dependency $s` + [ $? -ne 0 ] && return 1 + done + echo $__SORTED + return 0 +} + +start_script () { # script + local tmpdir s=$1 + check_running $s + ret=$? + [ $ret -eq 0 ] && return 0 # already running + if [ $ret -eq 4 ]; then + clog "$s is dead, but another script is running." + return 4 + fi + + compile_script $s check + ret=$? + [ $ret -ne 0 ] && return $ret + + eval opts=\$${s}_OPT + opts=`get_run_opts $opts` + [ $? -ne 0 ] && return 2 + + clog " Starting $1 ... " -n + tmpdir=`mktemp -d -p "$TEMP_PATH" cache.XXXXXXXX` # bz7097 + if [ $? -ne 0 ]; then + clog "failed to create temporary directory." + return 1 + fi + pushd "$tmpdir" &> /dev/null + logex $STAPRUN -L $opts "$CACHE_PATH/$s.ko" + ret=$? + if [ $ret -eq 0 ]; then + # TODO: store daemon pid after supporting on-file flight recorder + echo 0 > "$STAT_PATH/$s" + fi + popd &> /dev/null + rm -rf "$tmpdir" + [ $ret -eq 0 ] && clog "done" || clog "error" + return $ret +} + +start () { + local scripts s ret + clog $"Starting $prog: " -n + + if [ -n "$DEFAULT_START" -a -z "$OPT_SCRIPTS" ]; then + SCRIPTS="$DEFAULT_START" + fi + + if [ -z "$SCRIPTS" ]; then + do_warning $"no scripts exist." + return 5 # program is not installed + fi + + prepare_stat_dir + if [ $? -ne 0 ]; then + do_failure $"Failed to make stat directory ($STAT_PATH)" + return 1 + fi + prepare_cache_dir + if [ $? -ne 0 ]; then + do_failure $"Failed to make cache directory ($CACHE_PATH)" + return 1 + fi + + if [ $RECURSIVE -eq 1 ]; then + SCRIPTS=`sort_dependency $SCRIPTS` + if [ $? -ne 0 ]; then + do_failure $"Failed to sort dependency" + return 6 # program is not configured + fi + fi + for s in $SCRIPTS; do + start_script "$s" + ret=$? + if [ $ret -ne 0 ]; then + might_fail $"Failed to run \"$s\". ($ret)" + fi + done + might_success $"$prog startup" + return 0 +} + +stop_script () { # script + local p + check_running "$1" + ret=$? + [ $ret -eq 1 ] && rm -f "$STAT_PATH/$1" + [ $ret -ne 0 ] && return 0 + + p=`get_daemon_pid $1` + if [ $p -ne 0 ]; then + logex killall -TERM $p + else + logex $STAPRUN -d "$1" + fi + [ $? -ne 0 ] && return 1 + rm -f "$STAT_PATH/$1" + return $? +} + +stop () { + local s sl= + clog $"Stopping $prog: " -n + [ -z "$OPT_SCRIPTS" ] && SCRIPTS=`get_all_runnings` + if [ $RECURSIVE -eq 1 ]; then + SCRIPTS=`sort_dependency $SCRIPTS` + if [ $? -ne 0 ]; then + do_failure $"Failed to sort dependency" + return 6 # program is not configured + fi + fi + for s in $SCRIPTS; do + sl="$s $sl" + done + for s in $sl; do + stop_script $s + [ $? -ne 0 ] && might_fail $"Failed to run \"$s\". " + done + might_success $"$prog stopping " + return 0 +} + +status () { + local s pid ret r + [ -z "$SCRIPTS" ] && SCRIPTS=`get_all_runnings` + ret=3 + for s in $SCRIPTS; do + check_running $s + r=$? + [ $ret -ne 0 ] && ret=$r + case $r in + 0) + pid=`get_daemon_pid $s` + [ $pid -ne 0 ] && pid="($pid)" || pid= + echo $"$s$pid is running..." ;; + 1|3) echo $"$s is stopped" ;; + 4) echo $"$s is dead, but another script is running.";; + esac + done + return $ret +} + +compile () { + local s ss + clog $"Compiling $prog: " -n + prepare_cache_dir + if [ $? -ne 0 ]; then + do_failure $"Failed to make cache directory ($CACHE_PATH)" + return 1 + fi + for s in $SCRIPTS; do + ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null` + done + ss=`echo -n $ss` + if [ "$ss" ]; then + clog "Updating caches: $ss" + ask_yesno "Do you really want to update above caches" + [ $? -eq 0 ] && return 0 + fi + for s in $SCRIPTS; do + compile_script $s nocheck + [ $? -ne 0 ] && might_fail $"$s compilation failed " + done + might_success $"$prog compiled " + return 0 +} + +# Cleanup caches +cleanup () { + local s ss ret + clog $"Cleaning up $prog: " -n + if [ ! -d "$CACHE_PATH" ]; then + do_success "no cache" + return 0 + fi + + for s in $SCRIPTS; do + ss="$ss "`ls "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" 2> /dev/null` + done + ss=`echo -n $ss` + if [ "$ss" ]; then + echo "Removing caches: $ss" + ask_yesno "Do you really want to remove above caches" + [ $? -eq 0 ] && return 0 + for s in $SCRIPTS; do + logex rm -f "$CACHE_PATH/$s.ko" "$CACHE_PATH/$s.opts" + [ $? -ne 0 ] && might_fail $"failed to clean cache $s.ko" + done + might_success "done" + return 0 + fi +} + +RETVAL=0 + +case $CMD in + start) + start + RETVAL=$? + ;; + stop) + stop + RETVAL=$? + ;; + restart|force-reload) + stop + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + compile) + compile + RETVAL=$? + ;; + cleanup) + cleanup + RETVAL=$? + ;; + *) + echo_usage + RETVAL=3 + ;; +esac + +echo +exit $RETVAL diff --git a/systemtap.spec b/systemtap.spec index 2586b85a..be00fa98 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -116,6 +116,16 @@ Requires: systemtap %description sdt-devel Support tools to allow applications to use static probes. +%package initscript +Summary: Systemtap Initscript +Group: Development/System +License: GPLv2+ +URL: http://sourceware.org/systemtap/ +Requires: systemtap-runtime, initscripts + +%description initscript +Initscript for Systemtap scripts. + %prep %setup -q %{?setup_elfutils} @@ -203,6 +213,15 @@ mv $RPM_BUILD_ROOT%{_datadir}/doc/systemtap/*.pdf docs.installed/ mv $RPM_BUILD_ROOT%{_datadir}/doc/systemtap/tapsets docs.installed/ %endif +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d/ +install -m 755 initscript/systemtap $RPM_BUILD_ROOT%{_sysconfdir}/init.d/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/systemtap +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/systemtap/conf.d +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/systemtap/script.d +install -m 644 initscript/config $RPM_BUILD_ROOT%{_sysconfdir}/systemtap +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/cache/systemtap +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/systemtap + %clean rm -rf ${RPM_BUILD_ROOT} @@ -211,6 +230,15 @@ getent group stapdev >/dev/null || groupadd -r stapdev getent group stapusr >/dev/null || groupadd -r stapusr exit 0 +%post initscript +chkconfig --add systemtap +exit 0 + +%preun initscript +chkconfig --del systemtap +exit 0 + + %files %defattr(-,root,root) @@ -276,6 +304,18 @@ exit 0 %{_bindir}/dtrace %{_includedir}/sys/sdt.h +%files initscript +%defattr(-,root,root) +%{_sysconfdir}/init.d/systemtap +%dir %{_sysconfdir}/systemtap +%dir %{_sysconfdir}/systemtap/conf.d +%dir %{_sysconfdir}/systemtap/script.d +%config(noreplace) %{_sysconfdir}/systemtap/config +%dir %{_localstatedir}/cache/systemtap +%dir %{_localstatedir}/run/systemtap +%doc initscript/README.initscript + + %changelog * Thu Nov 13 2008 Frank Ch. Eigler - 0.8-1 - Upstream release. -- cgit From 881ba90812c88a82da4a4963924e7363b3fe3377 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 30 Jan 2009 18:24:13 -0800 Subject: update .gitignore's --- .gitignore | 3 +++ doc/SystemTap_Tapset_Reference/.gitignore | 1 + 2 files changed, 4 insertions(+) create mode 100644 doc/SystemTap_Tapset_Reference/.gitignore diff --git a/.gitignore b/.gitignore index f4f6ed6a..48ee168d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,12 +12,15 @@ config.status *.[158] .deps loc2c-test +run-stap stamp-h1 stap staprun testresults stapio stap_merge +stap-client-connect +stap-server-connect CVS .checkstyle .cproject diff --git a/doc/SystemTap_Tapset_Reference/.gitignore b/doc/SystemTap_Tapset_Reference/.gitignore new file mode 100644 index 00000000..af43f913 --- /dev/null +++ b/doc/SystemTap_Tapset_Reference/.gitignore @@ -0,0 +1 @@ +/docproc -- cgit From 30d163f5e3c082128548a45b3e5609bbd58fd128 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 1 Feb 2009 12:54:51 +0100 Subject: Process extra_offset for kernel symbols with dwfl_module_relocate_address. --- ChangeLog | 5 +++++ translate.cxx | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 618588a8..ebb378b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-02-01 Mark Wielaard + + * translate.cxx (dump_unwindsyms): Process extra_offset with + dwfl_module_relocate_address. + 2009-01-30 Masami Hiramatsu PR6936 diff --git a/translate.cxx b/translate.cxx index 7361edbe..d3298802 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4522,7 +4522,11 @@ dump_unwindsyms (Dwfl_Module *m, // we're already iterating over the same data here... if (modname == "kernel" && !strcmp(name, "_stext")) { + int ki; extra_offset = sym.st_value; + ki = dwfl_module_relocate_address (m, &extra_offset); + dwfl_assert ("dwfl_module_relocate_address extra_offset", + ki >= 0); if (c->session.verbose > 2) clog << "Found kernel _stext 0x" << hex << extra_offset << dec << endl; } -- cgit From 0f336e95987931dd9fd35de02deee0ce682b987a Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 1 Feb 2009 21:22:21 -0500 Subject: Add .label("label") --- ChangeLog | 6 +++++ runtime/sdt.h | 2 +- tapsets.cxx | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ testsuite/ChangeLog | 4 ++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ebb378b1..0aa574cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-02-01 Stan Cox + + * tapsets.cxx (dwflpp::iterate_over_cu_labels): New. + (query_cu): Use it. + (dwarf_derived_probe::register_patterns): Register .label. + 2009-02-01 Mark Wielaard * translate.cxx (dump_unwindsyms): Process extra_offset with diff --git a/runtime/sdt.h b/runtime/sdt.h index b36c6973..359ce4da 100644 --- a/runtime/sdt.h +++ b/runtime/sdt.h @@ -28,7 +28,7 @@ struct _probe_ ## probe \ static char probe ## _ ## probe_name [strlen(#probe)+1] \ __attribute__ ((section (".probes"))) \ = #probe; \ - static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(long)& probe ## _ ## probe_name[0],argc}; +static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(size_t)& probe ## _ ## probe_name[0],argc}; #define STAP_CONCAT(a,b) a ## b #define STAP_LABEL(p,n) \ diff --git a/tapsets.cxx b/tapsets.cxx index 45c7b0e4..86e4a1e3 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -480,6 +480,7 @@ static string TOK_STATEMENT("statement"); static string TOK_ABSOLUTE("absolute"); static string TOK_PROCESS("process"); static string TOK_MARK("mark"); +static string TOK_LABEL("label"); // Can we handle this query with just symbol-table info? enum dbinfo_reqt @@ -1329,6 +1330,62 @@ struct dwflpp } } + void + iterate_over_cu_labels (string label_val, Dwarf_Die *cu, void *data, + void (* callback)(const string &, + const char *, + int, + Dwarf_Die *, + Dwarf_Addr, + dwarf_query *)) + { + dwarf_query * q __attribute__ ((unused)) = static_cast(data) ; + + get_module_dwarf(); + + const char * sym = label_val.c_str(); + Dwarf_Die die; + dwarf_child (cu, &die); + static string function_name; + do + { + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (&die, DW_AT_name, &attr_mem); + int tag = dwarf_tag(&die); + const char *name = dwarf_formstring (attr); + if (name == NULL) + continue; + if (tag == DW_TAG_subprogram) + { + function_name = name; + } + else if (tag == DW_TAG_label + && ((strncmp(name, sym, sizeof(sym)) == 0) + || (name_has_wildcard (sym) + && function_name_matches_pattern (name, sym)))) + { + const char *file = dwarf_decl_file (&die); + int line; + line = dwarf_decl_line (&die, &line); + Dwarf_Addr stmt_addr; + if (dwarf_lowpc (&die, &stmt_addr) != 0) + continue; + Dwarf_Die *scopes; + int nscopes = 0; + nscopes = dwarf_getscopes_die (&die, &scopes); + if (nscopes > 1) + callback(function_name.c_str(), file, + line, &scopes[1], stmt_addr, q); + } + if (dwarf_haschildren (&die) && tag != DW_TAG_structure_type + && tag != DW_TAG_union_type) + { + iterate_over_cu_labels (label_val, &die, q, callback); + } + } + while (dwarf_siblingof (&die, &die) == 0); + } + void collect_srcfiles_matching (string const & pattern, set & filtered_srcfiles) @@ -2930,6 +2987,8 @@ dwarf_query::dwarf_query(systemtap_session & sess, has_statement_str = get_string_param(params, TOK_STATEMENT, statement_str_val); has_statement_num = get_number_param(params, TOK_STATEMENT, statement_num_val); + has_label = get_string_param(params, TOK_LABEL, label_val); + has_call = has_null_param(params, TOK_CALL); has_inline = has_null_param(params, TOK_INLINE); has_return = has_null_param(params, TOK_RETURN); @@ -3905,6 +3964,12 @@ query_cu (Dwarf_Die * cudie, void * arg) q->dw.iterate_over_srcfile_lines (*i, q->line, q->has_statement_str, q->line_type, query_srcfile_line, q); } + else if (q->has_label) + { + // If we have a pattern string with target *label*, we + // have to look at labels in all the matched srcfiles. + q->dw.iterate_over_cu_labels (q->label_val, q->dw.cu, q, query_statement); + } else { // Otherwise, simply probe all resolved functions. @@ -4930,6 +4995,8 @@ dwarf_derived_probe::register_patterns(match_node * root) register_function_and_statement_variants(root->bind(TOK_KERNEL), dw); register_function_and_statement_variants(root->bind_str(TOK_MODULE), dw); root->bind(TOK_KERNEL)->bind_num(TOK_STATEMENT)->bind(TOK_ABSOLUTE)->bind(dw); + root->bind(TOK_KERNEL)->bind_str(TOK_FUNCTION)->bind_str(TOK_LABEL)->bind(dw); + root->bind_str(TOK_PROCESS)->bind_str(TOK_FUNCTION)->bind_str(TOK_LABEL)->bind(dw); register_function_and_statement_variants(root->bind_str(TOK_PROCESS), dw); root->bind_str(TOK_PROCESS)->bind_str(TOK_MARK)->bind(dw); diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 41b99541..9d78ebce 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-02-01 Stan Cox + + * systemtap.base/labels.exp: New. + 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. -- cgit From d44d3f7f73e2ef22694e9d2f6c48f77ba2204a59 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 1 Feb 2009 21:34:52 -0500 Subject: Add test for .label("label") --- testsuite/systemtap.base/labels.exp | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 testsuite/systemtap.base/labels.exp diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp new file mode 100644 index 00000000..6c62d576 --- /dev/null +++ b/testsuite/systemtap.base/labels.exp @@ -0,0 +1,67 @@ +set test "labels" +if {![installtest_p]} {untested $test; return} + +# Try to find utrace_attach symbol in /proc/kallsyms +# copy from utrace_p5.exp +set utrace_support_found 0 +set path "/proc/kallsyms" +if {! [catch {exec grep -q utrace_attach $path} dummy]} { + set utrace_support_found 1 +} +if {$utrace_support_found == 0} { untested "$test"; return } + +# Compile a C program to use as the user-space probing target +set label_srcpath "[pwd]/labels.c" +set label_exepath "[pwd]/labels.x" +set label_flags "additional_flags=-g" +set fp [open $label_srcpath "w"] +puts $fp " +int +main () +{ + sleep(5); + int a = 0; + int b = 0; + char *c; +init_an_int: + a = 2; +init_another_int: + b = 3; + c = \"abc\"; +ptr_inited: + return 1; +} +" +close $fp + +set fp [open "[pwd]/labels.stp" "w"] +puts $fp " +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +" +close $fp + +set ok 0 + +set res [target_compile $label_srcpath $label_exepath executable $label_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "compiling labels.c -g" + return +} else { + pass "compiling labels.c -g" +} + +verbose -log "spawn stap -c $label_exepath [pwd]/labels.stp" +spawn stap -c $label_exepath [pwd]/labels.stp + +expect { + -timeout 180 + -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +wait + +if {$ok == 1} { pass "$test" } { fail "$test ($ok)" } -- cgit From 4edeafb20ffbb8adb14963b5f12babc2aa7fd415 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 2 Feb 2009 12:55:01 +1000 Subject: edited authorship --- doc/Tapset_Reference_Guide/en-US/Author_Group.xml | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 doc/Tapset_Reference_Guide/en-US/Author_Group.xml diff --git a/doc/Tapset_Reference_Guide/en-US/Author_Group.xml b/doc/Tapset_Reference_Guide/en-US/Author_Group.xml new file mode 100644 index 00000000..d795efba --- /dev/null +++ b/doc/Tapset_Reference_Guide/en-US/Author_Group.xml @@ -0,0 +1,25 @@ + + + + + Red Hat Enterprise Linux Documentation + + Don + Domingo + + Engineering Services and Operations + Content Services + + ddomingo@redhat.com + + + Will + Cohen + + Engineering Services and Operations + Performance Tools + + wcohen@redhat.com + + -- cgit From 75dde87962b94fb7c4e9ebec750c1e96609702bf Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 2 Feb 2009 12:56:14 +1000 Subject: script copies automated tapsets.xml then cleans it for publican --- doc/Tapset_Reference_Guide/publicanize.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/Tapset_Reference_Guide/publicanize.sh diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh new file mode 100644 index 00000000..127e647f --- /dev/null +++ b/doc/Tapset_Reference_Guide/publicanize.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +#copy the automated tapsets.xml +cp ../SystemTap_Tapset_Reference/tapsets.xml en-US/Tapset_Reference_Guide.xml ; + +#remove all excess whitespace +sed -i -e 's/^\s*//g' en-US/Tapset_Reference_Guide.xml ; + +#replace header + +cat en-US/Tapset_Reference_Guide.xml | perl -p -e 'undef $/;s|\nSystemTap Tapset Reference Manual|\n|msg' | perl -p -e 'undef $/;s|\n\nWilliam\nCohen\n\n
\nwcohen\@redhat.com\n
\n
\n
\n
||msg' | perl -p -e 'undef $/;s|\n2008, 2009\nRed Hat, Inc.\n||msg' | perl -p -e 'undef $/;s|\n\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n||msg' | perl -p -e 'undef $/;s|\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n||msg' | perl -p -e 'undef $/;s|\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 59 Temple Place, Suite 330, Boston,\nMA 02111-1307 USA\n||msg' | perl -p -e 'undef $/;s|\nFor more details see the file COPYING in the source\ndistribution of Linux.\n\n\n
||msg' | perl -p -e 'undef $/;s|||msg' | perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' > clean.xml + +cp clean.xml en-US/Tapset_Reference_Guide.xml + + +# next 3 sed statements are change synopsis tags, as they are still currently unfixed in publican-redhat +sed -i -e 's/refsynopsisdiv>/refsect1>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/refsect1>/refsection>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/synopsis>/programlisting>\n/g' en-US/Tapset_Reference_Guide.xml; \ No newline at end of file -- cgit From f8a382089ed083ae23c5735d3af99d4c2aa46f94 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 2 Feb 2009 13:05:39 +1000 Subject: added conversion for tags command and emphasis --- doc/Tapset_Reference_Guide/publicanize.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh index 127e647f..292a76e8 100644 --- a/doc/Tapset_Reference_Guide/publicanize.sh +++ b/doc/Tapset_Reference_Guide/publicanize.sh @@ -16,4 +16,12 @@ cp clean.xml en-US/Tapset_Reference_Guide.xml # next 3 sed statements are change synopsis tags, as they are still currently unfixed in publican-redhat sed -i -e 's/refsynopsisdiv>/refsect1>/g' en-US/Tapset_Reference_Guide.xml; sed -i -e 's/refsect1>/refsection>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/synopsis>/programlisting>\n/g' en-US/Tapset_Reference_Guide.xml; \ No newline at end of file +sed -i -e 's/synopsis>/programlisting>\n/g' en-US/Tapset_Reference_Guide.xml; + +# re-convert tags + +sed -i -e 's/<emphasis>//g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<\/emphasis>/<\/emphasis>/g' en-US/Tapset_Reference_Guide.xml; + +sed -i -e 's/<command>//g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<\/command>/<\/command>/g' en-US/Tapset_Reference_Guide.xml; \ No newline at end of file -- cgit From ee08323d54db2ca61e5bfecccd4ac6bc9812585a Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 2 Feb 2009 13:06:07 +1000 Subject: minor correction to comment on probe vm.brk --- tapset/memory.stp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tapset/memory.stp b/tapset/memory.stp index 9370073b..ea976d15 100644 --- a/tapset/memory.stp +++ b/tapset/memory.stp @@ -118,9 +118,9 @@ probe vm.munmap = kernel.function("do_munmap") { } /** - * probe vm.brk -Fires when a brk is requested (resizing a heap). - * @address - the requested address - * @length - the length of the memory segment + * probe vm.brk - Fires when a brk is requested (resizing a heap). + * @address: the requested address + * @length: the length of the memory segment * * Context: * The process calling brk. -- cgit From d1d11e962cda0f69476d23c0cadfa050b8da9f78 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 2 Feb 2009 13:51:23 +1000 Subject: added tagging for sfunction entries --- doc/Tapset_Reference_Guide/publicanize.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh index 292a76e8..b9cd7d8f 100644 --- a/doc/Tapset_Reference_Guide/publicanize.sh +++ b/doc/Tapset_Reference_Guide/publicanize.sh @@ -8,12 +8,12 @@ sed -i -e 's/^\s*//g' en-US/Tapset_Reference_Guide.xml ; #replace header -cat en-US/Tapset_Reference_Guide.xml | perl -p -e 'undef $/;s|\nSystemTap Tapset Reference Manual|\n|msg' | perl -p -e 'undef $/;s|\n\nWilliam\nCohen\n\n
\nwcohen\@redhat.com\n
\n
\n
\n
||msg' | perl -p -e 'undef $/;s|\n2008, 2009\nRed Hat, Inc.\n||msg' | perl -p -e 'undef $/;s|\n\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n||msg' | perl -p -e 'undef $/;s|\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n||msg' | perl -p -e 'undef $/;s|\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 59 Temple Place, Suite 330, Boston,\nMA 02111-1307 USA\n||msg' | perl -p -e 'undef $/;s|\nFor more details see the file COPYING in the source\ndistribution of Linux.\n\n\n
||msg' | perl -p -e 'undef $/;s|||msg' | perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' > clean.xml +cat en-US/Tapset_Reference_Guide.xml | perl -p -e 'undef $/;s|\nSystemTap Tapset Reference Manual|\n|msg' | perl -p -e 'undef $/;s|\n\nWilliam\nCohen\n\n
\nwcohen\@redhat.com\n
\n
\n
\n
||msg' | perl -p -e 'undef $/;s|\n2008, 2009\nRed Hat, Inc.\n||msg' | perl -p -e 'undef $/;s|\n\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n||msg' | perl -p -e 'undef $/;s|\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n||msg' | perl -p -e 'undef $/;s|\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 59 Temple Place, Suite 330, Boston,\nMA 02111-1307 USA\n||msg' | perl -p -e 'undef $/;s|\nFor more details see the file COPYING in the source\ndistribution of Linux.\n\n\n
||msg' | perl -p -e 'undef $/;s|||msg' | perl -p -e 'undef $/;s|\n\n\n\n\n\n\n\n\n\n\n\n\n\n||msg' | perl -p -e 'undef $/;s|\n|\n(sfunction) <\/emphasis>|msg' > clean.xml cp clean.xml en-US/Tapset_Reference_Guide.xml -# next 3 sed statements are change synopsis tags, as they are still currently unfixed in publican-redhat +# statements change synopsis tags, as they are still currently unfixed in publican-redhat sed -i -e 's/refsynopsisdiv>/refsect1>/g' en-US/Tapset_Reference_Guide.xml; sed -i -e 's/refsect1>/refsection>/g' en-US/Tapset_Reference_Guide.xml; sed -i -e 's/synopsis>/programlisting>\n/g' en-US/Tapset_Reference_Guide.xml; -- cgit From 3d65f39002440cfdeeac94d7a7a6c9a7aead2e54 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 2 Feb 2009 13:52:14 +0100 Subject: Add STAP_PROBE7, 8 and 9 variants to sdt.h. --- runtime/ChangeLog | 4 +++ runtime/sdt.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 0420183d..1c8f33b4 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,7 @@ +2009-02-02 Mark Wielaard + + * sdt.h: Add STAP_PROBE7, 8 and 9 variants. + 2009-01-27 Mark Wielaard * sdt.h (STAP_PROBE): Use "g", not "r", for asm args. diff --git a/runtime/sdt.h b/runtime/sdt.h index 359ce4da..905074ad 100644 --- a/runtime/sdt.h +++ b/runtime/sdt.h @@ -134,7 +134,7 @@ STAP_LABEL(probe,__LINE__): \ _stap_probe_6 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5,(size_t)arg6); #else #define STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \ - {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \ + {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \ volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \ volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \ volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \ @@ -147,6 +147,69 @@ STAP_LABEL(probe,__LINE__): \ goto STAP_LABEL(probe,__LINE__);} #endif +#ifdef USE_STAP_PROBE +#define STAP_PROBE7(provider,probe,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \ + STAP_PROBE_STRUCT(probe,0,7) \ + _stap_probe_7 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5,(size_t)arg6,(size_t)arg7); +#else +#define STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \ + {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \ + volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \ + volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \ + volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \ + volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \ + volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \ + volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \ +STAP_LABEL(probe,__LINE__): \ + asm volatile ("nop" :: "g"(arg1), "g"(arg2), "g"(arg3), "g"(arg4), "g"(arg5), "g"(arg6), "g"(arg7)); \ + STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \ + if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \ + goto STAP_LABEL(probe,__LINE__);} +#endif + +#ifdef USE_STAP_PROBE +#define STAP_PROBE8(provider,probe,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \ + STAP_PROBE_STRUCT(probe,0,8) \ + _stap_probe_8 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5,(size_t)arg6,(size_t)arg7,(size_t)arg8); +#else +#define STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \ + {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \ + volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \ + volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \ + volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \ + volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \ + volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \ + volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \ + volatile typeof((parm8)) arg8 __attribute__ ((unused)) = parm8; \ +STAP_LABEL(probe,__LINE__): \ + asm volatile ("nop" :: "g"(arg1), "g"(arg2), "g"(arg3), "g"(arg4), "g"(arg5), "g"(arg6), "g"(arg7), "g"(arg8)); \ + STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \ + if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \ + goto STAP_LABEL(probe,__LINE__);} +#endif + +#ifdef USE_STAP_PROBE +#define STAP_PROBE9(provider,probe,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \ + STAP_PROBE_STRUCT(probe,0,9) \ + _stap_probe_9 (_probe_ ## probe.probe_name,(size_t)arg1,(size_t)arg2,(size_t)arg3,(size_t)arg4,(size_t)arg5,(size_t)arg6,(size_t)arg7,(size_t)arg8,(size_t)arg9); +#else +#define STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \ + {volatile typeof((parm1)) arg1 __attribute__ ((unused)) = parm1; \ + volatile typeof((parm2)) arg2 __attribute__ ((unused)) = parm2; \ + volatile typeof((parm3)) arg3 __attribute__ ((unused)) = parm3; \ + volatile typeof((parm4)) arg4 __attribute__ ((unused)) = parm4; \ + volatile typeof((parm5)) arg5 __attribute__ ((unused)) = parm5; \ + volatile typeof((parm6)) arg6 __attribute__ ((unused)) = parm6; \ + volatile typeof((parm7)) arg7 __attribute__ ((unused)) = parm7; \ + volatile typeof((parm8)) arg8 __attribute__ ((unused)) = parm8; \ + volatile typeof((parm9)) arg9 __attribute__ ((unused)) = parm9; \ +STAP_LABEL(probe,__LINE__): \ + asm volatile ("nop" :: "g"(arg1), "g"(arg2), "g"(arg3), "g"(arg4), "g"(arg5), "g"(arg6), "g"(arg7), "g"(arg8), "g"(arg9)); \ + STAP_PROBE_STRUCT(probe,1,(size_t)&& STAP_LABEL(probe,__LINE__)) \ + if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \ + goto STAP_LABEL(probe,__LINE__);} +#endif + #define DTRACE_PROBE(provider,probe) \ STAP_PROBE(provider,probe) #define DTRACE_PROBE1(provider,probe,parm1) \ @@ -157,7 +220,13 @@ STAP_PROBE2(provider,probe,parm1,parm2) STAP_PROBE3(provider,probe,parm1,parm2,parm3) #define DTRACE_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \ STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4) -#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \ +#define DTRACE_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \ STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) -#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \ +#define DTRACE_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \ STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) +#define DTRACE_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \ +STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) +#define DTRACE_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \ +STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) +#define DTRACE_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \ +STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) -- cgit From 470ac2acd8a52f33e9ce020d38ea2d0881e6cc84 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 10:02:13 -0500 Subject: Merge ChangeLog conflict --- testsuite/ChangeLog | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index f44c6488..542df531 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,15 +1,12 @@ -<<<<<<< HEAD:testsuite/ChangeLog +2009-02-01 Stan Cox + + * systemtap.base/labels.exp: New. + 2009-01-30 Will Cohen * systemtap.samples/queue_demo.exp: * systemtap.samples/queue_demo.stp: Remove. -======= -2009-02-01 Stan Cox - - * systemtap.base/labels.exp: New. - ->>>>>>> 3d65f39002440cfdeeac94d7a7a6c9a7aead2e54:testsuite/ChangeLog 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. -- cgit From ca1d53c1c0eab03b2bf9422d645e09be7518ea4e Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 10:12:58 -0500 Subject: Remove redundant tcp_connections_wa.stp. --- testsuite/ChangeLog | 4 ++ testsuite/systemtap.samples/tcp_connections_wa.stp | 55 ---------------------- 2 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 testsuite/systemtap.samples/tcp_connections_wa.stp diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 542df531..ad2ea6fb 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-02-02 Will Cohen + + * systemtap.samples/tcp_connections_wa.stp: Remove. + 2009-02-01 Stan Cox * systemtap.base/labels.exp: New. diff --git a/testsuite/systemtap.samples/tcp_connections_wa.stp b/testsuite/systemtap.samples/tcp_connections_wa.stp deleted file mode 100644 index 4c5e2399..00000000 --- a/testsuite/systemtap.samples/tcp_connections_wa.stp +++ /dev/null @@ -1,55 +0,0 @@ -%{ -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - - -function get_eax:long () %{ - if (CONTEXT && CONTEXT->regs) - THIS->__retvalue = CONTEXT->regs->eax; - else - THIS->__retvalue = 0; -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} -probe kernel.function("tcp_accept").return { - sock = get_eax() - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} - - -- cgit From 492d227f2caa558c4fdcd4e7aae65cf32b4549cc Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 11:18:01 -0500 Subject: Revise tcp_connections.stp example and place in sysemtap.examples directory. --- testsuite/ChangeLog | 10 +++++ testsuite/systemtap.examples/index.html | 3 ++ testsuite/systemtap.examples/index.txt | 10 +++++ testsuite/systemtap.examples/keyword-index.html | 14 ++++++- testsuite/systemtap.examples/keyword-index.txt | 32 ++++++++++++++ .../network/tcp_connections.meta | 13 ++++++ .../systemtap.examples/network/tcp_connections.stp | 14 +++++++ testsuite/systemtap.samples/tcp_connections.stp | 49 ---------------------- 8 files changed, 95 insertions(+), 50 deletions(-) create mode 100644 testsuite/systemtap.examples/network/tcp_connections.meta create mode 100644 testsuite/systemtap.examples/network/tcp_connections.stp delete mode 100644 testsuite/systemtap.samples/tcp_connections.stp diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index ad2ea6fb..c8883da4 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2009-02-02 Will Cohen + + * systemtap.samples/tcp_connections.stp: Revised and moved to examples. + * systemtap.examples/network/tcp_connections.stp: + * systemtap.examples/network/tcp_connections.meta: New. + * systemtap.examples/index.html: + * systemtap.examples/index.txt: + * systemtap.examples/keyword-index.html: + * systemtap.examples/keyword-index.txt: Regenerate. + 2009-02-02 Will Cohen * systemtap.samples/tcp_connections_wa.stp: Remove. diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 87a5a50e..3395edca 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -76,6 +76,9 @@ keywords: NETWORK network/socket-trace.stp - Trace Functions called in Network Socket Code
keywords: NETWORK SOCKET

The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

+
  • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
    +keywords: NETWORK TCP SOCKET
    +

    The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

  • process/futexes.stp - System-Wide Futex Contention
    keywords: SYSCALL LOCKING FUTEX

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index 5ffc341a..ddf24471 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -109,6 +109,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + process/futexes.stp - System-Wide Futex Contention keywords: syscall locking futex diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 9ff68c8d..6c367ad7 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -39,7 +39,7 @@

    Examples by Keyword

    -

    BACKTRACE CALLGRAPH CPU DISK FUNCTIONS FUTEX GRAPH INTERRUPT IO LOCKING NETWORK PER-PROCESS PROFILING READ SCHEDULER SIGNALS SIMPLE SLEEP SOCKET SYSCALL TIME TRACE TRAFFIC USE WAIT4 WRITE

    +

    BACKTRACE CALLGRAPH CPU DISK FUNCTIONS FUTEX GRAPH INTERRUPT IO LOCKING NETWORK PER-PROCESS PROFILING READ SCHEDULER SIGNALS SIMPLE SLEEP SOCKET SYSCALL TCP TIME TRACE TRAFFIC USE WAIT4 WRITE

    BACKTRACE

    • interrupt/scf.stp - Tally Backtraces for Inter-Processor Interrupt (IPI)
      @@ -132,6 +132,9 @@ keywords: NETWORK network/socket-trace.stp - Trace Functions called in Network Socket Code
      keywords: NETWORK SOCKET

      The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

    • +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    PER-PROCESS

      @@ -198,6 +201,9 @@ keywords: SYSCALL network/socket-trace.stp - Trace Functions called in Network Socket Code
      keywords: NETWORK SOCKET

      The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

      +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    SYSCALL

      @@ -220,6 +226,12 @@ keywords: SYSCALL
      keywords: SYSCALL WAIT4

      The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

    +

    TCP

    +
      +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    • +

    TIME

    • io/iotime.stp - Trace Time Spent in Read and Write for Files
      diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 0127f3a8..3cb0c3cf 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -204,6 +204,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = PER-PROCESS = network/nettop.stp - Periodic Listing of Processes Using Network Interfaces @@ -352,6 +362,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = SYSCALL = io/iotime.stp - Trace Time Spent in Read and Write for Files @@ -415,6 +435,18 @@ keywords: syscall wait4 waiting for. If the waited for PID is not specified , it is "-1". += TCP = + +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = TIME = io/iotime.stp - Trace Time Spent in Read and Write for Files diff --git a/testsuite/systemtap.examples/network/tcp_connections.meta b/testsuite/systemtap.examples/network/tcp_connections.meta new file mode 100644 index 00000000..0bc9bcb1 --- /dev/null +++ b/testsuite/systemtap.examples/network/tcp_connections.meta @@ -0,0 +1,13 @@ +title: Track Creation of Incoming TCP Connections +name: tcp_connections.stp +version: 1.0 +author: anonymous +keywords: network tcp socket +subsystem: kernel +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request. +test_check: stap -p4 tcp_connections.stp +test_installcheck: stap tcp_connections.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/network/tcp_connections.stp b/testsuite/systemtap.examples/network/tcp_connections.stp new file mode 100644 index 00000000..bd2db76a --- /dev/null +++ b/testsuite/systemtap.examples/network/tcp_connections.stp @@ -0,0 +1,14 @@ +#! /usr/bin/env stap + +probe begin { + printf("%6s %16s %6s %6s %16s\n", + "UID", "CMD", "PID", "PORT", "IP_SOURCE") +} + +probe kernel.function("tcp_accept").return?, + kernel.function("inet_csk_accept").return? { + sock = $return + if (sock != 0) + printf("%6d %16s %6d %6d %16s\n", uid(), execname(), pid(), + inet_get_local_port(sock), inet_get_ip_source(sock)) +} diff --git a/testsuite/systemtap.samples/tcp_connections.stp b/testsuite/systemtap.samples/tcp_connections.stp deleted file mode 100644 index a4449b60..00000000 --- a/testsuite/systemtap.samples/tcp_connections.stp +++ /dev/null @@ -1,49 +0,0 @@ -#! stap - -%{ -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} - -probe kernel.function("tcp_accept").return { - sock = $return - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} -- cgit From 592470cde0ceb84bbf409482927ba6554b536b95 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 2 Feb 2009 11:47:31 -0500 Subject: Add documentation for .label("label") --- ChangeLog | 4 ++++ NEWS | 5 ++++- doc/ChangeLog | 4 ++++ doc/langref.tex | 8 ++++++-- stapprobes.5.in | 15 +++++++++------ 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0aa574cc..a3e99781 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-02-02 Stan Cox + + * NEWS, stapprobes.5.in: Add process.label. + 2009-02-01 Stan Cox * tapsets.cxx (dwflpp::iterate_over_cu_labels): New. diff --git a/NEWS b/NEWS index 25ebcccf..81887a7f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ * What's new +- function("func").label("label") probes are now supported to allow matching + the label of a function. + - Systemtap initscript is available. This initscript allows you to run systemtap scripts as system services (in flight recorder mode) and control those scripts individually. @@ -10,7 +13,7 @@ automatically from the directory. - Serious problems associated with user-space probing in shared libraries - was corrected, making it now possible to experiment with probe shared + were corrected, making it now possible to experiment with probe shared libraries. Assuming dwarf debugging information is installed, use this twist on the normal syntax: diff --git a/doc/ChangeLog b/doc/ChangeLog index 34f5dbe0..01e9dcce 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2009-02-02 Stan Cox + + * langref.tex: Add process.label. + 2009-01-30 Dave Brolley * Makefile.in: Regenerated. diff --git a/doc/langref.tex b/doc/langref.tex index 3af2bd15..5aefa278 100644 --- a/doc/langref.tex +++ b/doc/langref.tex @@ -706,6 +706,7 @@ kernel.function(PATTERN).call kernel.function(PATTERN).return kernel.function(PATTERN).return.maxactive(VALUE) kernel.function(PATTERN).inline +kernel.function(PATTERN).label(LPATTERN) module(MPATTERN).function(PATTERN) module(MPATTERN).function(PATTERN).call module(MPATTERN).function(PATTERN).return.maxactive(VALUE) @@ -737,8 +738,11 @@ The \textbf{.statement} variant places a probe at the exact spot, exposing those variables that are visible there. In the above probe descriptions, MPATTERN stands for a string literal -that identifies the loaded kernel module of interest. It may include asterisk -({*}), square brackets \char`\"{}{[}]\char`\"{}, and question mark (?) wildcards. +that identifies the loaded kernel module of interest and LPATTERN +stands for a source program label. Both MPATTERN and LPATTERN may +include asterisk ({*}), square brackets \char`\"{}{[}]\char`\"{}, and +question mark (?) wildcards. + PATTERN stands for a string literal that identifies a point in the program. It is composed of three parts: diff --git a/stapprobes.5.in b/stapprobes.5.in index b50adc9d..0854be53 100644 --- a/stapprobes.5.in +++ b/stapprobes.5.in @@ -263,6 +263,8 @@ kernel.function(PATTERN).return .br kernel.function(PATTERN).inline .br +kernel.function(PATTERN).label(LPATTERN) +.br module(MPATTERN).function(PATTERN) .br module(MPATTERN).function(PATTERN).call @@ -280,8 +282,10 @@ module(MPATTERN).statement(PATTERN) .ESAMPLE In the above list, MPATTERN stands for a string literal that aims to -identify the loaded kernel module of interest. It may include "*", "[]", -and "?" wildcards. PATTERN stands for a string literal that +identify the loaded kernel module of interest and LPATTERN stands for +a source program label. Both MPATTERN and LPATTERN may include the "*" +"[]", and "?" wildcards. +PATTERN stands for a string literal that aims to identify a point in the program. It is made up of three parts: .IP \(bu 4 @@ -445,14 +449,13 @@ A .B .mark probe gets called via a static probe which is defined in the application by -STAP_PROBE1(handle,LABEL,arg1). The handle is an application handle, +STAP_PROBE1(handle,LABEL,arg1), which is defined in sdt.h. The handle is an application handle, LABEL corresponds to the .mark argument, and arg1 is the argument. STAP_PROBE1 is used for probes with 1 argument, STAP_PROBE2 is used for probes with 2 arguments, and so on. The arguments of the probe are available in the context variables -$arg1, $arg2, ... -The application should be compiled with ../share/systemtap/runtime/sduprobes.h -and should be linked with libsduprobes.a. +$arg1, $arg2, ... An alternative to using the STAP_PROBE macros is to +use the dtrace script to create custom macros. .PP Note that .I PATH -- cgit From 1bf72dfea404434f954214298367817d5c591903 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 14:21:25 -0500 Subject: Revised topsys.stp and moved to the testsuite/systemtap.examples directory. --- testsuite/ChangeLog | 10 ++++ testsuite/systemtap.examples/index.html | 3 + testsuite/systemtap.examples/index.txt | 8 +++ testsuite/systemtap.examples/keyword-index.html | 3 + testsuite/systemtap.examples/keyword-index.txt | 8 +++ testsuite/systemtap.examples/profiling/topsys.meta | 13 ++++ testsuite/systemtap.examples/profiling/topsys.stp | 24 ++++++++ testsuite/systemtap.samples/topsys.stp | 69 ---------------------- 8 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 testsuite/systemtap.examples/profiling/topsys.meta create mode 100644 testsuite/systemtap.examples/profiling/topsys.stp delete mode 100644 testsuite/systemtap.samples/topsys.stp diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index c8883da4..4c0a85a9 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2009-02-02 Will Cohen + + * systemtap.samples/topsys.stp: Revised and moved to examples. + * systemtap.examples/profiling/topsys.stp: + * systemtap.examples/profiling/topsys.meta: New. + * systemtap.examples/index.html: + * systemtap.examples/index.txt: + * systemtap.examples/keyword-index.html: + * systemtap.examples/keyword-index.txt: Regenerate. + 2009-02-02 Will Cohen * systemtap.samples/tcp_connections.stp: Revised and moved to examples. diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 3395edca..e02ab867 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -121,6 +121,9 @@ keywords: PROFILING
    • profiling/timeout.stp - Show Processes Doing Polling Operations
      keywords: PROFILING

      The timeout.stp script is based on a blog entry (http://udrepper.livejournal.com/19041.html) mentioning a need for a tool to help developers find applications that are polling. The timeout.stp script monitors systemcall used for polling and records the systemcalls that timed out rather than returned because some action occurred. The script updates the screen once a second with the top twenty processes.

    • +
    • profiling/topsys.stp - Show Processes Doing Polling Operations
      +keywords: PROFILING
      +

      The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent.

    diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index ddf24471..0076afaa 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -243,3 +243,11 @@ keywords: profiling top twenty processes. +profiling/topsys.stp - Show Processes Doing Polling Operations +keywords: profiling + + The topsys.stp script lists out the top twenty systemcalls for the + previous 5 seconds. The output is sorted from most frequent to least + frequent. + + diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 6c367ad7..3156cc08 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -156,6 +156,9 @@ keywords: PROFILING
  • profiling/timeout.stp - Show Processes Doing Polling Operations
    keywords: PROFILING

    The timeout.stp script is based on a blog entry (http://udrepper.livejournal.com/19041.html) mentioning a need for a tool to help developers find applications that are polling. The timeout.stp script monitors systemcall used for polling and records the systemcalls that timed out rather than returned because some action occurred. The script updates the screen once a second with the top twenty processes.

  • +
  • profiling/topsys.stp - Show Processes Doing Polling Operations
    +keywords: PROFILING
    +

    The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent.

  • READ

      diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 3cb0c3cf..a940ccfa 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -266,6 +266,14 @@ keywords: profiling top twenty processes. +profiling/topsys.stp - Show Processes Doing Polling Operations +keywords: profiling + + The topsys.stp script lists out the top twenty systemcalls for the + previous 5 seconds. The output is sorted from most frequent to least + frequent. + + = READ = io/iotime.stp - Trace Time Spent in Read and Write for Files diff --git a/testsuite/systemtap.examples/profiling/topsys.meta b/testsuite/systemtap.examples/profiling/topsys.meta new file mode 100644 index 00000000..3642713d --- /dev/null +++ b/testsuite/systemtap.examples/profiling/topsys.meta @@ -0,0 +1,13 @@ +title: Show Processes Doing Polling Operations +name: topsys.stp +version: 1.0 +author: anonymous +keywords: profiling +subsystem: kernel syscalls +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent. +test_check: stap -p4 topsys.stp +test_installcheck: stap topsys.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/profiling/topsys.stp b/testsuite/systemtap.examples/profiling/topsys.stp new file mode 100644 index 00000000..34cf826c --- /dev/null +++ b/testsuite/systemtap.examples/profiling/topsys.stp @@ -0,0 +1,24 @@ +#! /usr/bin/env stap +# +# This script continuously lists the top 20 systemcalls in the interval +# 5 seconds +# + +global syscalls_count + +probe syscall.* { + syscalls_count[name]++ +} + +function print_systop () { + printf ("%25s %10s\n", "SYSCALL", "COUNT") + foreach (syscall in syscalls_count- limit 20) { + printf("%25s %10d\n", syscall, syscalls_count[syscall]) + } + delete syscalls_count +} + +probe timer.s(5) { + print_systop () + printf("--------------------------------------------------------------\n") +} diff --git a/testsuite/systemtap.samples/topsys.stp b/testsuite/systemtap.samples/topsys.stp deleted file mode 100644 index da31c858..00000000 --- a/testsuite/systemtap.samples/topsys.stp +++ /dev/null @@ -1,69 +0,0 @@ -#! stap -g -# -# This script continuously lists the top 20 systemcalls in the interval -# of 2000 jiffies. -# - -global syscalls_count, syscalls - -function syscall_name:string () %{ - char *str, buff[80]; - char *tok; - str = buff; - strlcpy(str, CONTEXT->probe_point, sizeof(buff)); - tok = strsep(&str, "\""); - tok = strsep(&str, "@"); - sprintf(str, "%-25s", tok); - strlcpy(THIS->__retvalue, str, MAXSTRINGLEN); -%} - -function reset_maxaction () %{ - if (CONTEXT && CONTEXT->actioncount) - CONTEXT->actioncount=0; -%} - -function accumulate () { - syscall=syscall_name() - syscalls_count[syscall]++ - # I use this array to refer to syscalls_count array in - # the reset_syscalls_count. Initalize with a non-zero. - syscalls[syscall]=1 -} - - -function print_top () { - lcnt=0 - reset_maxaction () - foreach ([syscall] in syscalls_count-) { - sys_cnt = syscalls_count[syscall] - log (syscall . "\t\t\t\t" . sprint(sys_cnt)) - if (lcnt++ == 20) - break; - } - syscalls_count[lsyscall]=0 -} - -function reset_syscalls_count () { - # For some reason, I have to do this to get pass the elaboration - # phase on RHEL4 (seg fault). Under FC4, it works fine with out - # the 'dummy_init' - syscalls["dummy_init"]=0 - foreach ([sys] in syscalls) - syscalls_count[sys]=0 -} - -function print_systop () { - log ("SYSCALL \t\t\t\tCOUNT") - print_top() - reset_syscalls_count () -} - -probe kernel.function("sys_*").call { - accumulate () -} - -probe timer.jiffies(2000) { - print_systop () - log("--------------------------------------------------------------") -} - -- cgit