diff options
author | David Smith <dsmith@redhat.com> | 2009-05-21 16:57:04 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2009-05-21 16:57:04 -0500 |
commit | c8e9eb18d8d13d099a4a177fe53de507c1d9ce8b (patch) | |
tree | ab2388afb795ed1a7ead2fbbf8b9d1b368a8231f /testsuite | |
parent | dd9a3bcbef65bde65491d959e9458bc641924811 (diff) | |
parent | 3863e7999255deeaa7f8f4bba7df893773812537 (diff) | |
download | systemtap-steved-c8e9eb18d8d13d099a4a177fe53de507c1d9ce8b.tar.gz systemtap-steved-c8e9eb18d8d13d099a4a177fe53de507c1d9ce8b.tar.xz systemtap-steved-c8e9eb18d8d13d099a4a177fe53de507c1d9ce8b.zip |
Merge commit 'origin/master' into pr7043
Conflicts:
runtime/print.c
runtime/transport/transport.c
runtime/transport/transport_msgs.h
Diffstat (limited to 'testsuite')
197 files changed, 3651 insertions, 874 deletions
diff --git a/testsuite/.gitignore b/testsuite/.gitignore index 19b30bf1..709de57f 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -2,3 +2,6 @@ site.exp systemtap.log systemtap.sum +*.so +*_exe +*.exe.[0-9] diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in index 9547479b..c0f0b19c 100644 --- a/testsuite/Makefile.in +++ b/testsuite/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -31,14 +31,16 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -subdir = testsuite -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +subdir = . +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/configure $(am__configure_deps) ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = SOURCES = DEJATOOL = $(PACKAGE) @@ -48,39 +50,22 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ -DATE = @DATE@ DEFS = @DEFS@ -DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ -LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ @@ -88,25 +73,15 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -PIECFLAGS = @PIECFLAGS@ -PIECXXFLAGS = @PIECXXFLAGS@ -PIELDFLAGS = @PIELDFLAGS@ -PROCFLAGS = @PROCFLAGS@ -RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ -U = @U@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -am__include = @am__include@ am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ @@ -114,15 +89,10 @@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ +dejazilla = @dejazilla@ docdir = @docdir@ dvidir = @dvidir@ -elfutils_abs_srcdir = @elfutils_abs_srcdir@ exec_prefix = @exec_prefix@ -have_dvips = @have_dvips@ -have_latex = @have_latex@ -have_latex2html = @have_latex2html@ -have_ps2pdf = @have_ps2pdf@ -have_xmlto = @have_xmlto@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ @@ -134,8 +104,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -nspr_CFLAGS = @nspr_CFLAGS@ -nss_CFLAGS = @nss_CFLAGS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ @@ -143,14 +111,9 @@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ -sqlite3_LIBS = @sqlite3_LIBS@ srcdir = @srcdir@ -stap_LIBS = @stap_LIBS@ -staplog_CPPFLAGS = @staplog_CPPFLAGS@ -subdirs = @subdirs@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = dejagnu no-dist @@ -171,35 +134,39 @@ RUNTEST = "env SYSTEMTAP_RUNTIME=$(SYSTEMTAP_RUNTIME) SYSTEMTAP_TAPSET=$(SYSTEMT all: all-am .SUFFIXES: +am--refresh: + @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu testsuite/Makefile + $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) tags: TAGS TAGS: @@ -270,6 +237,7 @@ clean: clean-am clean-am: clean-generic clean-local mostlyclean-am distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-DEJAGNU distclean-generic @@ -302,6 +270,8 @@ install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -321,16 +291,17 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: all all-am all-local check check-DEJAGNU check-am check-local \ - clean clean-generic clean-local distclean distclean-DEJAGNU \ - distclean-generic dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am +.PHONY: all all-am all-local am--refresh check check-DEJAGNU check-am \ + check-local clean clean-generic clean-local distclean \ + distclean-DEJAGNU distclean-generic dvi dvi-am html html-am \ + info info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ + uninstall-am all-local: diff --git a/testsuite/aclocal.m4 b/testsuite/aclocal.m4 index c9daa488..5aee677e 100644 --- a/testsuite/aclocal.m4 +++ b/testsuite/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.10.1 -*- Autoconf -*- +# generated automatically by aclocal 1.10 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2005, 2006 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,15 +11,12 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(AC_AUTOCONF_VERSION, [2.61],, -[m4_warning([this file was generated for autoconf 2.61. -You have another version of autoconf. It may work, but is not guaranteed to. -If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) +m4_if(m4_PACKAGE_VERSION, [2.61],, +[m4_fatal([this file was generated for autoconf 2.61. +You have another version of autoconf. If you want to use that, +you should regenerate the build system entirely.], [63])]) -# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -34,7 +31,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.10' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.10.1], [], +m4_if([$1], [1.10], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -50,10 +47,8 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.10.1])dnl -m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) +[AM_AUTOMAKE_VERSION([1.10])dnl +_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- @@ -146,13 +141,13 @@ fi])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008 Free Software Foundation, Inc. +# 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 13 +# serial 12 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. @@ -257,17 +252,16 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC], # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. -_am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in - $_am_arg | $_am_arg:* ) + $1 | $1:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done -echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # @@ -516,7 +510,7 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- -# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) diff --git a/testsuite/buildko/two.stp b/testsuite/buildko/two.stp new file mode 100755 index 00000000..25350dc0 --- /dev/null +++ b/testsuite/buildko/two.stp @@ -0,0 +1,14 @@ +#! stap -p4 + +# tests overwide arrays +global a10 +global b10 +global c10 +global d10 + +probe begin { + a10[0,"a",0,"a",0,"a",0,"a",0,"a"]="a"; + b10["b",0,"b",0,"b",0,"b",0,"b",0]=0; + c10[0,"a",0,"a",0,"a",0,"a",0,"a"]<<<0; + d10["b",0,"b",0,"b",0,"b",0,"b",0]<<<0; +} diff --git a/testsuite/buildok/context_test.stp b/testsuite/buildok/context_test.stp index 84f1cbf1..acc4ea07 100755 --- a/testsuite/buildok/context_test.stp +++ b/testsuite/buildok/context_test.stp @@ -1,6 +1,6 @@ #! stap -p4 -function print_stuff () { +probe begin { print_regs() print_backtrace() bt = backtrace() @@ -18,23 +18,5 @@ function print_stuff () { printf("gid is %d\n", gid()) printf("egid is %d\n", egid()) printf("pp is %s\n", pp()) -} - -probe kernel.function("uptime_read_proc") ? { - print("NOW IN UPTIME\n") - print_stuff () -} - -probe kernel.function("uptime_read_proc").return ? { - print("DONE WITH UPTIME\n") - print_stuff () - exit () -} - -probe begin { - print ("BEGIN\n") -} - -probe end { - print ("END\n") + printf("sid is %d\n", sid()) } diff --git a/testsuite/buildok/maxactive01.stp b/testsuite/buildok/maxactive01.stp index afdb2cea..1cf893ef 100755 --- a/testsuite/buildok/maxactive01.stp +++ b/testsuite/buildok/maxactive01.stp @@ -1,6 +1,6 @@ #! stap -p4 -probe kernel.function("sys_read").return.maxactive(3) +probe kernel.function("vfs_read").return.maxactive(3) { printf("."); } diff --git a/testsuite/buildok/modname.stp b/testsuite/buildok/modname.stp new file mode 100755 index 00000000..02229301 --- /dev/null +++ b/testsuite/buildok/modname.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for modname() +# +probe begin +{ + log(modname(0)) +} diff --git a/testsuite/buildok/process-all-probes.stp b/testsuite/buildok/process-all-probes.stp index 91a96514..c754462b 100755 --- a/testsuite/buildok/process-all-probes.stp +++ b/testsuite/buildok/process-all-probes.stp @@ -2,11 +2,11 @@ // Tests if all probes in the process tapset are resolvable. -probe process.create, - process.start, - process.exec, - process.exec_complete, - process.exit, - process.release +probe kprocess.create, + kprocess.start, + kprocess.exec, + kprocess.exec_complete, + kprocess.exit, + kprocess.release { } diff --git a/testsuite/buildok/process_test.stp b/testsuite/buildok/process_test.stp index 90de8b69..ba3fadf1 100755 --- a/testsuite/buildok/process_test.stp +++ b/testsuite/buildok/process_test.stp @@ -1,31 +1,31 @@ #! stap -p4 -probe process.create { +probe kprocess.create { log(pp()) log(sprint(task)) } -probe process.start { +probe kprocess.start { log(pp()) } -probe process.exec { +probe kprocess.exec { log(pp()) log(filename) } -probe process.exec_complete { +probe kprocess.exec_complete { log(pp()) log(sprint(errno)) log(sprint(success)) } -probe process.exit { +probe kprocess.exit { log(pp()) log(sprint(code)) } -probe process.release { +probe kprocess.release { log(pp()) log(sprint(task)) } diff --git a/testsuite/buildok/seventeen.stp b/testsuite/buildok/seventeen.stp index 126db1fb..4e0b07c4 100755 --- a/testsuite/buildok/seventeen.stp +++ b/testsuite/buildok/seventeen.stp @@ -11,3 +11,12 @@ probe kernel.function("pipe_write") printf("0x%x\n", $write_fifo_fops->llseek) %) } + +# PR10000: We're looking for *some* module function that has a nearby global variable in scope +# XXX: See PR4096 +probe module("nfs").function("nfs_create_client") !, module("nfs").function("nfs_init_client") !, + kernel.function("nfs_fsync_dir") { + println(kernel_string($nfs_program->name)) +} + +probe timer.s(5) { exit() } diff --git a/testsuite/buildok/symdata.stp b/testsuite/buildok/symdata.stp new file mode 100755 index 00000000..d7e803a9 --- /dev/null +++ b/testsuite/buildok/symdata.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for symdata() +# +probe begin +{ + log(symdata(0)) +} diff --git a/testsuite/buildok/symname.stp b/testsuite/buildok/symname.stp new file mode 100755 index 00000000..e082d1a5 --- /dev/null +++ b/testsuite/buildok/symname.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for symname() +# +probe begin +{ + log(symname(0)) +} diff --git a/testsuite/buildok/task-embedded.stp b/testsuite/buildok/task-embedded.stp index 4d1f5300..d35f3e0d 100755 --- a/testsuite/buildok/task-embedded.stp +++ b/testsuite/buildok/task-embedded.stp @@ -14,6 +14,8 @@ probe begin { task_nice (0) + task_cpu (0) + task_open_file_handles (0) + - task_max_file_handles (0)) + task_max_file_handles (0) + + pid2task(0)) print (task_execname (0)) + print (pid2execname (0)) } diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp index c8da7da5..792f96ea 100755 --- a/testsuite/buildok/task_test.stp +++ b/testsuite/buildok/task_test.stp @@ -16,5 +16,7 @@ probe begin { log(sprint(task_cpu(c))) log(sprint(task_open_file_handles(c))) log(sprint(task_max_file_handles(c))) + log(sprint(pid2task(pid()))) + log(sprint(pid2execname(pid()))) exit() } diff --git a/testsuite/buildok/tcp_test.stp b/testsuite/buildok/tcp_test.stp index a262ab29..a5e3bafb 100755 --- a/testsuite/buildok/tcp_test.stp +++ b/testsuite/buildok/tcp_test.stp @@ -8,16 +8,16 @@ function print_report() } probe tcp.sendmsg { - ports = inet_get_local_port(sk) - src_ips = inet_get_ip_source(sk) - rtos = tcp_get_info_rto(sk) + ports = inet_get_local_port(sock) + src_ips = inet_get_ip_source(sock) + rtos = tcp_get_info_rto(sock) } probe tcp.recvmsg { - cwnd = tcp_get_info_snd_cwnd(sk) - mss = tcp_ts_get_info_rcv_mss(sk) - ssthresh = tcp_ts_get_info_snd_ssthresh(sk) - state = tcp_ts_get_info_state(sk) + cwnd = tcp_get_info_snd_cwnd(sock) + mss = tcp_ts_get_info_rcv_mss(sock) + ssthresh = tcp_ts_get_info_snd_ssthresh(sock) + state = tcp_ts_get_info_state(sock) } probe tcp.sendmsg.return { diff --git a/testsuite/buildok/thirteen.stp b/testsuite/buildok/thirteen.stp index 4dffc4b9..32228e79 100755 --- a/testsuite/buildok/thirteen.stp +++ b/testsuite/buildok/thirteen.stp @@ -1,6 +1,6 @@ #! stap -p4 -probe kernel.function("sys_read") +probe kernel.function("vfs_read") { printf ("count=%d\n", $count) } diff --git a/testsuite/buildok/thirty.stp b/testsuite/buildok/thirty.stp new file mode 100755 index 00000000..042bae56 --- /dev/null +++ b/testsuite/buildok/thirty.stp @@ -0,0 +1,49 @@ +#! stap -p4 + +# tests wide arrays +global a1, a2, a3, a4, a5, a6, a7, a8, a9 +global b1, b2, b3, b4, b5, b6, b7, b8, b9 +global c1, c2, c3, c4, c5, c6, c7, c8, c9 +global d1, d2, d3, d4, d5, d6, d7, d8, d9 + +probe begin { + a1[0]="a"; + a2[0,"a"]="a"; + a3[0,"a",0]="a"; + a4[0,"a",0,"a"]="a"; + a5[0,"a",0,"a",0]="a"; + a6[0,"a",0,"a",0,"a"]="a"; + a7[0,"a",0,"a",0,"a",0]="a"; + a8[0,"a",0,"a",0,"a",0,"a"]="a"; + a9[0,"a",0,"a",0,"a",0,"a",0]="a"; + + b1["b"]=0; + b2["b",0]=0; + b3["b",0,"b"]=0; + b4["b",0,"b",0]=0; + b5["b",0,"b",0,"b"]=0; + b6["b",0,"b",0,"b",0]=0; + b7["b",0,"b",0,"b",0,"b"]=0; + b8["b",0,"b",0,"b",0,"b",0]=0; + b9["b",0,"b",0,"b",0,"b",0,"b"]=0; + + c1[0]<<<0; + c2[0,"a"]<<<0; + c3[0,"a",0]<<<0; + c4[0,"a",0,"a"]<<<0; + c5[0,"a",0,"a",0]<<<0; + c6[0,"a",0,"a",0,"a"]<<<0; + c7[0,"a",0,"a",0,"a",0]<<<0; + c8[0,"a",0,"a",0,"a",0,"a"]<<<0; + c9[0,"a",0,"a",0,"a",0,"a",0]<<<0; + + d1["b"]<<<0; + d2["b",0]<<<0; + d3["b",0,"b"]<<<0; + d4["b",0,"b",0]<<<0; + d5["b",0,"b",0,"b"]<<<0; + d6["b",0,"b",0,"b",0]<<<0; + d7["b",0,"b",0,"b",0,"b"]<<<0; + d8["b",0,"b",0,"b",0,"b",0]<<<0; + d9["b",0,"b",0,"b",0,"b",0,"b"]<<<0; +} diff --git a/testsuite/buildok/thirtyone.stp b/testsuite/buildok/thirtyone.stp new file mode 100755 index 00000000..8a97d84f --- /dev/null +++ b/testsuite/buildok/thirtyone.stp @@ -0,0 +1,4 @@ +#! stap -p4 + +probe kprobe.function("sys_open") {} +probe kernel.function("sys_close") {} diff --git a/testsuite/buildok/twentysix.stp b/testsuite/buildok/twentysix.stp deleted file mode 100755 index 3fb7526f..00000000 --- a/testsuite/buildok/twentysix.stp +++ /dev/null @@ -1,7 +0,0 @@ -#! stap -up4 - -global a -probe begin -{ - a [1,2,3,4,5,6] = 0 -} diff --git a/testsuite/buildok/uaddr.stp b/testsuite/buildok/uaddr.stp new file mode 100755 index 00000000..8acfc495 --- /dev/null +++ b/testsuite/buildok/uaddr.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for uaddr() +# +probe begin +{ + printf("uaddr: 0x%x\n", uaddr()) +} diff --git a/testsuite/buildok/ustack.stp b/testsuite/buildok/ustack.stp new file mode 100755 index 00000000..23af0bff --- /dev/null +++ b/testsuite/buildok/ustack.stp @@ -0,0 +1,10 @@ +#! stap -p4 +# +# Test the translatability for ubacktrace(), print_ustack() +# and print_ubacktrace() +# +probe begin +{ + print_ustack(ubacktrace()); + print_ubacktrace(); +} diff --git a/testsuite/buildok/usymdata.stp b/testsuite/buildok/usymdata.stp new file mode 100755 index 00000000..48c1f36f --- /dev/null +++ b/testsuite/buildok/usymdata.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for usymdata() +# +probe begin +{ + log(usymdata(0)) +} diff --git a/testsuite/buildok/usymname.stp b/testsuite/buildok/usymname.stp new file mode 100755 index 00000000..57e3f9c2 --- /dev/null +++ b/testsuite/buildok/usymname.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for usymname() +# +probe begin +{ + log(usymname(0)) +} diff --git a/testsuite/configure b/testsuite/configure index 094f99c7..cc73571a 100755 --- a/testsuite/configure +++ b/testsuite/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for systemtap 0.9. +# Generated by GNU Autoconf 2.61 for systemtap 0.9.7. # # Report bugs to <systemtap@sources.redhat.com>. # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='systemtap' PACKAGE_TARNAME='systemtap' -PACKAGE_VERSION='0.9' -PACKAGE_STRING='systemtap 0.9' +PACKAGE_VERSION='0.9.7' +PACKAGE_STRING='systemtap 0.9.7' PACKAGE_BUGREPORT='systemtap@sources.redhat.com' ac_subst_vars='SHELL @@ -1149,7 +1149,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures systemtap 0.9 to adapt to many kinds of systems. +\`configure' configures systemtap 0.9.7 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1215,7 +1215,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of systemtap 0.9:";; + short | recursive ) echo "Configuration of systemtap 0.9.7:";; esac cat <<\_ACEOF @@ -1291,7 +1291,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -systemtap configure 0.9 +systemtap configure 0.9.7 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1305,7 +1305,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by systemtap $as_me 0.9, which was +It was created by systemtap $as_me 0.9.7, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -1997,7 +1997,7 @@ fi # Define the identity of the package. PACKAGE='systemtap' - VERSION='0.9' + VERSION='0.9.7' cat >>confdefs.h <<_ACEOF @@ -2617,7 +2617,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by systemtap $as_me 0.9, which was +This file was extended by systemtap $as_me 0.9.7, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -2660,7 +2660,7 @@ Report bugs to <bug-autoconf@gnu.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -systemtap config.status 0.9 +systemtap config.status 0.9.7 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/testsuite/configure.ac b/testsuite/configure.ac index c40fdf72..1a82fe36 100644 --- a/testsuite/configure.ac +++ b/testsuite/configure.ac @@ -1,7 +1,7 @@ dnl configure.ac --- autoconf input file for systemtap testsuite dnl Process this file with autoconf to produce a configure script. -AC_INIT([systemtap], 0.9, systemtap@sources.redhat.com, systemtap) +AC_INIT([systemtap], 0.9.7, systemtap@sources.redhat.com, systemtap) AC_PREREQ(2.59) AC_CONFIG_AUX_DIR(..) diff --git a/testsuite/lib/stap_run.exp b/testsuite/lib/stap_run.exp index a4beaa12..3043eeed 100644 --- a/testsuite/lib/stap_run.exp +++ b/testsuite/lib/stap_run.exp @@ -30,6 +30,7 @@ proc stap_run { TEST_NAME {LOAD_GEN_FUNCTION ""} {OUTPUT_CHECK_STRING ""} args } if [file readable $test_file_name] { lappend cmd $test_file_name } + send_log "executing: $cmd\n" eval spawn $cmd expect { -timeout 180 diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp index cb1c6615..d1f02c83 100644 --- a/testsuite/lib/stap_run2.exp +++ b/testsuite/lib/stap_run2.exp @@ -10,12 +10,27 @@ proc stap_run2 { TEST_NAME args } { # zap the srcdir prefix - set test_file_name $TEST_NAME + set TEST_FILE $TEST_NAME set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""] - + if {[llength $args] == 0} { + stap_run3 $TEST_NAME $TEST_FILE + } else { + stap_run3 $TEST_NAME $TEST_FILE $args + } +} + +# stap_run3 TEST_NAME TEST_FILE +# TEST_NAME is the name of the test as shown in PASS/FAIL/SKIPPED messages. +# TEST_FILE is the path to the current test +# Additional arguments are passed to stap as-is. +# +# global result_string must be set to the expected output + +proc stap_run3 { TEST_NAME TEST_FILE args } { if {[info procs installtest_p] != "" && ![installtest_p]} { untested $TEST_NAME; return } - - set cmd [concat stap $args $test_file_name] + + set cmd [concat stap $TEST_FILE $args] + send_log "executing: $cmd\n" catch {eval exec $cmd} res set n 0 diff --git a/testsuite/lib/systemtap.exp b/testsuite/lib/systemtap.exp index c80ad171..379f6c58 100644 --- a/testsuite/lib/systemtap.exp +++ b/testsuite/lib/systemtap.exp @@ -16,6 +16,16 @@ proc use_server_p {} { } +proc utrace_p {} { + set path "/proc/kallsyms" + if {! [catch {exec grep -q utrace_attach $path} dummy]} { + return 1 + } else { + return 0 + } +} + + proc print_systemtap_version {} { set version [exec /bin/uname -r] set location "/boot/vmlinux-$version" @@ -75,7 +85,7 @@ proc setup_server {} { # Make sure that the necessary resources are available to run the client/server. if {[installtest_p]} then { - if {[exec /usr/bin/which stap-client-connect] == ""} then { + if {[catch {exec /usr/bin/which stap-client-connect} dummy]} then { print "Unable to start a server: stap-client-connect is not found in PATH" return 0 } @@ -83,7 +93,7 @@ proc setup_server {} { print "Unable to start a server: [exec pwd]/../stap-client-connect is not found" return 0 } - if {[exec /usr/bin/which avahi-publish-service] == ""} then { + if {[catch {exec /usr/bin/which avahi-publish-service} dummy]} then { print "Unable to start a server: avahi-publish-service is not found in PATH" return 0 } @@ -99,6 +109,7 @@ proc setup_server {} { if {! [installtest_p]} then { # Make sure the server management scripts and tools are on the $PATH. set env(PATH) "$srcdir/..:[exec pwd]/..:$env(PATH)" + set env(SYSTEMTAP_SERVER_SCRIPTS) "$srcdir/.." } # Try to find or start the server. @@ -118,8 +129,10 @@ proc setup_server {} { # The server does not call this instance of 'stap' if {[installtest_p]} then { exec /bin/cp -p [exec which stap-client] $net_path/stap + exec /bin/cp -p [exec which stap-env] $net_path/stap-env } else { exec /bin/cp -p $srcdir/../stap-client $net_path/stap + exec /bin/cp -p $srcdir/../stap-env $net_path/stap-env } set env(PATH) "$net_path:$env(PATH)" @@ -148,13 +161,18 @@ proc get_system_info {} { set Snapshot [exec /bin/cat $env(SRCDIR)/../SNAPSHOT] } else { regexp {version [^)]*} [exec stap -V 2>@ stdout] version - set Snapshot $version + set Snapshot $version } set Distro "Linux" - if [file exists /etc/fedora-release] {set Distro [exec /bin/cat /etc/fedora-release]} - if [file exists /etc/redhat-release] {set Distro [exec /bin/cat /etc/redhat-release]} - if [file exists /etc/suse-release] {set Distro [exec /bin/cat /etc/suse-release]} - if [file exists /etc/debian_version] {set Distro [exec /bin/cat /etc/debian_version]} + if [file exists /usr/bin/lsb_release] { + # this produces one line of this format: + # Distribution:\tSTRING + set Distro [lrange [exec /usr/bin/lsb_release -d] 1 end] + } else { + foreach f {/etc/fedora-release /etc/enterprise-release /etc/redhat-release /etc/suse-release /etc/debian_version} { + if [file exists $f] then {set Distro [exec /bin/cat $f]; break } + } + } } if {! [setup_systemtap_environment]} then { diff --git a/testsuite/parseko/cmdline17.stp b/testsuite/parseko/cmdline17.stp new file mode 100755 index 00000000..a9baf2d4 --- /dev/null +++ b/testsuite/parseko/cmdline17.stp @@ -0,0 +1,8 @@ +#!/bin/sh + +# options '-D' and '-L' are mutually exclusive +# +#-D Run in background. This requires '-o' option. +#-L Load module and start probes, then detach. + +staprun -L -D fake_module diff --git a/testsuite/parseko/cmdline18.stp b/testsuite/parseko/cmdline18.stp new file mode 100755 index 00000000..bbdfbcc5 --- /dev/null +++ b/testsuite/parseko/cmdline18.stp @@ -0,0 +1,10 @@ +#!/bin/sh + +# options '-D' and '-d' are mutually exclusive +# +#-D Run in background. This requires '-o' option. +#-d Delete a module. Only detached or unused modules +# the user has permission to access will be deleted. Use "*" +# (quoted) to delete all unused modules. + +staprun -d -D fake_module diff --git a/testsuite/parseko/cmdline19.stp b/testsuite/parseko/cmdline19.stp new file mode 100755 index 00000000..fbcef351 --- /dev/null +++ b/testsuite/parseko/cmdline19.stp @@ -0,0 +1,10 @@ +#!/bin/sh + +# options '-D' and '-c cmd' are mutually exclusive +# +#-D Run in background. This requires '-o' option. +#-c cmd Command 'cmd' will be run and staprun will +# exit when it does. The '_stp_target' variable +# will contain the pid for the command. + +staprun -c /bin/ls -D fake_module diff --git a/testsuite/parseko/cmdline20.stp b/testsuite/parseko/cmdline20.stp new file mode 100755 index 00000000..625cf20d --- /dev/null +++ b/testsuite/parseko/cmdline20.stp @@ -0,0 +1,9 @@ +#!/bin/sh + +# You have to specify ouput FILE with '-D' option +# +#-D Run in background. This requires '-o' option. +#-o FILE Send output to FILE. This supports strftime(3) +# formats for FILE. + +staprun -D fake_module diff --git a/testsuite/parseko/cmdline21.stp b/testsuite/parseko/cmdline21.stp new file mode 100755 index 00000000..d7496c8c --- /dev/null +++ b/testsuite/parseko/cmdline21.stp @@ -0,0 +1,15 @@ +#!/bin/sh + +# You have to specify ouput FILE with '-S' option +# +#-S size[,N] Switches output file to next file when the size +# of file reaches the specified size. The value +# should be an integer greater than 1 which is +# assumed to be the maximum file size in MB. +# When the number of output files reaches N, it +# switches to the first output file. You can omit +# the second argument. +#-o FILE Send output to FILE. This supports strftime(3) +# formats for FILE. + +staprun -S 1,1 fake_module diff --git a/testsuite/parseko/utrace01.stp b/testsuite/parseko/utrace01.stp index 1cb4227f..9f3619b5 100755 --- a/testsuite/parseko/utrace01.stp +++ b/testsuite/parseko/utrace01.stp @@ -1,4 +1,4 @@ #! stap -p2 # process NAME must be a string -probe process(/bin/cat).death { } +probe process(/bin/cat).end { } diff --git a/testsuite/semko/forty.stp b/testsuite/semko/forty.stp index f7721a47..b7d1d139 100755 --- a/testsuite/semko/forty.stp +++ b/testsuite/semko/forty.stp @@ -1,4 +1,4 @@ #! stap -p2 global x -probe kernel.function("sys_open") if (x = 1) { } # bad side-effect +probe kernel.function("do_sys_open") if (x = 1) { } # bad side-effect diff --git a/testsuite/semko/fortyone.stp b/testsuite/semko/fortyone.stp index e9b986df..d3ba6205 100755 --- a/testsuite/semko/fortyone.stp +++ b/testsuite/semko/fortyone.stp @@ -1,3 +1,3 @@ #! stap -p2 -probe kernel.function("sys_open") if (x > 1) { } # not a global +probe kernel.function("vfs_read") if (x > 1) { } # not a global diff --git a/testsuite/semko/fortytwo.stp b/testsuite/semko/fortytwo.stp index 17dacb1c..09a04ea7 100755 --- a/testsuite/semko/fortytwo.stp +++ b/testsuite/semko/fortytwo.stp @@ -1,6 +1,6 @@ #! stap -p2 -probe kernel.function("sys_open") if (foo(2)) { } # must not call functions +probe kernel.function("vfs_read") if (foo(2)) { } # must not call functions function foo(x) { return x } diff --git a/testsuite/semko/maxactive04.stp b/testsuite/semko/maxactive04.stp index 9471fd21..25d63ef4 100755 --- a/testsuite/semko/maxactive04.stp +++ b/testsuite/semko/maxactive04.stp @@ -1,5 +1,5 @@ #! stap -p2 -probe kernel.function("sys_open").return.maxactive(-4) +probe kernel.function("vfs_read").return.maxactive(-4) { } diff --git a/testsuite/semko/maxactive05.stp b/testsuite/semko/maxactive05.stp index bdc8a101..3833ab6c 100755 --- a/testsuite/semko/maxactive05.stp +++ b/testsuite/semko/maxactive05.stp @@ -1,5 +1,5 @@ #! stap -p2 -probe kernel.function("sys_open").return.maxactive(99999999) +probe kernel.function("vfs_read").return.maxactive(99999999) { } diff --git a/testsuite/semko/return02.stp b/testsuite/semko/return02.stp index db4cd8c7..3d64f5dc 100755 --- a/testsuite/semko/return02.stp +++ b/testsuite/semko/return02.stp @@ -1,6 +1,6 @@ #! stap -p2 -probe kernel.function("sys_read") +probe kernel.function("vfs_read") { # this should fail - using $return not in a '.return' probe printf("in sys_read - return = %d\n", $return) diff --git a/testsuite/semko/thirtyfour.stp b/testsuite/semko/thirtyfour.stp index 515fcfbb..dca63722 100755 --- a/testsuite/semko/thirtyfour.stp +++ b/testsuite/semko/thirtyfour.stp @@ -2,9 +2,9 @@ # can't write to target variables in .return probes -probe kernel.function("sys_read").return +probe kernel.function("fget_light").return { $fd = 0 printf("fd is %d\n", $fd) } -probe kernel.function("sys_open").return { $filename } +probe kernel.function("do_sys_open").return { $filename } diff --git a/testsuite/semko/twentytwo.stp b/testsuite/semko/twentytwo.stp index 9321d5f6..ef04cd30 100755 --- a/testsuite/semko/twentytwo.stp +++ b/testsuite/semko/twentytwo.stp @@ -3,6 +3,6 @@ # tests that a non-inline function is *not* matched using # the inline() pattern -probe kernel.function("sys_recv").inline { +probe kernel.function("vfs_read").inline { log ("found a non-inline via inline()") } diff --git a/testsuite/semko/utrace01.stp b/testsuite/semko/utrace01.stp deleted file mode 100755 index a4707008..00000000 --- a/testsuite/semko/utrace01.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# missing process NAME|PID -probe process.death { } diff --git a/testsuite/semko/utrace03.stp b/testsuite/semko/utrace03.stp index c682410b..92177ffd 100755 --- a/testsuite/semko/utrace03.stp +++ b/testsuite/semko/utrace03.stp @@ -1,4 +1,4 @@ #! stap -p2 # invalid probe type -probe process("/bin/cat").death.return { } +probe process("/bin/cat").end.return { } diff --git a/testsuite/semko/utrace04.stp b/testsuite/semko/utrace04.stp index 6345f9f6..1d26a43c 100755 --- a/testsuite/semko/utrace04.stp +++ b/testsuite/semko/utrace04.stp @@ -1,4 +1,4 @@ #! stap -p2 -# death probes don't support target symbols -probe process("/bin/cat").death.return { print($syscall) } +# end probes don't support target symbols +probe process("/bin/cat").end { print($syscall) } diff --git a/testsuite/semko/utrace08.stp b/testsuite/semko/utrace08.stp deleted file mode 100755 index a558a5be..00000000 --- a/testsuite/semko/utrace08.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# process path must be absolute -probe process("cat").death { } diff --git a/testsuite/semko/utrace09.stp b/testsuite/semko/utrace09.stp deleted file mode 100755 index 60c49cd2..00000000 --- a/testsuite/semko/utrace09.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# process path must be absolute -probe process("/foo/../bar").death { } diff --git a/testsuite/semko/utrace10.stp b/testsuite/semko/utrace10.stp deleted file mode 100755 index b46baea9..00000000 --- a/testsuite/semko/utrace10.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't contain an empty component -probe process("/foo//bar").death { } diff --git a/testsuite/semko/utrace11.stp b/testsuite/semko/utrace11.stp deleted file mode 100755 index d78b602c..00000000 --- a/testsuite/semko/utrace11.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '/' -probe process("/foo/bar/").death { } diff --git a/testsuite/semko/utrace12.stp b/testsuite/semko/utrace12.stp deleted file mode 100755 index 478aa1d3..00000000 --- a/testsuite/semko/utrace12.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '.' -probe process("/foo/bar/.").death { } diff --git a/testsuite/semko/utrace13.stp b/testsuite/semko/utrace13.stp deleted file mode 100755 index 16cc0391..00000000 --- a/testsuite/semko/utrace13.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '..' -probe process("/foo/bar/..").death { } diff --git a/testsuite/semok/badvar.stp b/testsuite/semok/badvar.stp index b3bd2d67..677187a3 100755 --- a/testsuite/semok/badvar.stp +++ b/testsuite/semok/badvar.stp @@ -1,7 +1,9 @@ -#! stap --skip-badvars +#! /bin/sh +stap -p2 --skip-badvars -e ' probe syscall.read { if ($foo == 0) printf ("Voila! It works..\n") exit () } +' diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp index 93da18ef..14401886 100755 --- a/testsuite/semok/cast.stp +++ b/testsuite/semok/cast.stp @@ -10,4 +10,14 @@ probe begin { // would be nice to test usermode @cast too, // but who knows what debuginfo is installed... + + // check modules generated from headers + println(@cast(0, "task_struct", "kernel<linux/sched.h>")->tgid) + println(@cast(0, "timeval", "<sys/time.h>")->tv_sec) + + // make sure that bogus @casts can get optimized away + @cast(0, "task_struct")->no_such_field + @cast(0, "task_struct")->parent->no_such_field + @cast(0, "no_such_type")->tgid + @cast(0, "task_struct", "no_such_module")->tgid } diff --git a/testsuite/semok/thirtythree.stp b/testsuite/semok/thirtythree.stp index 90070370..0f0cacf6 100755 --- a/testsuite/semok/thirtythree.stp +++ b/testsuite/semok/thirtythree.stp @@ -1,5 +1,9 @@ #! stap -p2 # Per bz3016, this should get through the semantic pass without warnings. probe kernel.function("do_mpage_readpage") { - printf("\n page->mapping %p",$page->mapping) + printf("\n page->mapping %p",$page->mapping) + %( kernel_v >= "2.6.22" %? + printf("\n page->first_page->mapping %p",$page->first_page->mapping) + %) + } diff --git a/testsuite/semok/thirtytwo.stp b/testsuite/semok/thirtytwo.stp index 2a69b8cd..0f0334a1 100755 --- a/testsuite/semok/thirtytwo.stp +++ b/testsuite/semok/thirtytwo.stp @@ -2,4 +2,4 @@ # PR 6836 -probe kernel.function("sys_open").return { log($$return . $$parms) } +probe kernel.function("do_sys_open").return { log($$return . $$parms) } diff --git a/testsuite/semok/twentynine.stp b/testsuite/semok/twentynine.stp index 05e591ce..4b2e5056 100755 --- a/testsuite/semok/twentynine.stp +++ b/testsuite/semok/twentynine.stp @@ -5,7 +5,7 @@ function dummy:long () {return p;} # alias with a condition probe alias0 = begin if (3) {p=1} # alias with a kernel-variable condition -- not valid -probe alias1 = kernel.function("sys_read").return if (0) { if ($return) {p=0} } +probe alias1 = kernel.function("vfs_read").return if (0) { if ($return) {p=0} } # alias with a function-call condition probe blias0 = timer.s(1) if (1 /* dummy() */) {p=10} diff --git a/testsuite/semok/utrace01.stp b/testsuite/semok/utrace01.stp new file mode 100755 index 00000000..864bdf15 --- /dev/null +++ b/testsuite/semok/utrace01.stp @@ -0,0 +1,4 @@ +#! stap -p2 + +# process path doesn't need to be absolute +probe process("cat").end { } diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp index deaf3bf8..f5dc4513 100644 --- a/testsuite/systemtap.base/alternatives.exp +++ b/testsuite/systemtap.base/alternatives.exp @@ -14,11 +14,11 @@ # listed, but that some alternatives are listed. set local1_script { - probe kernel.function("sys_getrlimit") { x = $z; } + probe kernel.function("vfs_write") { ret = $z; } } set struct1_script { - probe kernel.function("sys_getrlimit") { rlim_cur = $rlim->rlim_cud; } + probe kernel.function("vfs_write") { f_pos = $file->f_po; } } proc stap_run_alternatives {args} { @@ -26,10 +26,11 @@ proc stap_run_alternatives {args} { verbose -log "starting $args" eval spawn $args expect { + -timeout 60 -re {semantic error: .+ \(alternatives: [a-zA-Z_]} {incr alternatives_found; exp_continue} -re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue } - eof { } - timeout { } + eof { verbose -log "EOF" } + timeout { verbose -log "TIMEOUT" } } set results [wait] verbose -log "wait results: $results" @@ -37,9 +38,9 @@ proc stap_run_alternatives {args} { } set test "LOCAL1" -set rc [stap_run_alternatives stap -vu -p2 -e $local1_script] -if {$rc == 1} { pass $test } else { fail "$test ($rc)" } +set rc [stap_run_alternatives stap -u -p2 -e $local1_script] +if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } set test "STRUCT1" -set rc [stap_run_alternatives stap -vu -p2 -e $struct1_script] -if {$rc == 1} { pass $test } else { fail "$test ($rc)" } +set rc [stap_run_alternatives stap -u -p2 -e $struct1_script] +if {$rc >= 1} { pass $test } else { fail "$test ($rc)" } diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp index efc06695..c0815fbe 100644 --- a/testsuite/systemtap.base/badkprobe.exp +++ b/testsuite/systemtap.base/badkprobe.exp @@ -1,14 +1,28 @@ -set script "probe kernel.statement(-1).absolute {} probe timer.s(1) { exit() }" set test "bad kprobe registration" +set script { + probe $1 {} + probe timer.s(1) { exit() } + probe end { println("cleanup ok") } +} if {! [installtest_p]} { untested $test; return } -spawn stap -g -w -e "$script" -expect { - -timeout 60 - -re "^WARNING: probe .*registration error.*" { pass $test } - eof { fail "$test (eof)" } - timeout { fail "$test (timeout)" } +set bad_kprobes { + kernel.statement(-1).absolute + kprobe.statement(-1).absolute + kprobe.function("no_such_function") + kprobe.function("no_such_function").return +} + +foreach bk $bad_kprobes { + set test "bad kprobe registration: $bk" + spawn stap -g -w -e "$script" "$bk" + expect { + -timeout 60 + -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test } + eof { fail "$test (eof)" } + timeout { fail "$test (timeout)" } + } + catch {close} + catch {wait} } -catch {close} -catch {wait} diff --git a/testsuite/systemtap.base/bitfield.exp b/testsuite/systemtap.base/bitfield.exp new file mode 100644 index 00000000..16451369 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.exp @@ -0,0 +1,3 @@ +# test that bitfield r/w works correctly +set test "bitfield" +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp new file mode 100644 index 00000000..c2ff4929 --- /dev/null +++ b/testsuite/systemtap.base/bitfield.stp @@ -0,0 +1,46 @@ +%{ +#include <linux/tcp.h> +static struct tcphdr foo = {0}; +%} + +function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %} +function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %} +function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %} + +function check:long(ack:long, urg:long) { + ptr = get_ptr() + + /* set the bits with cast */ + @cast(ptr, "tcphdr")->ack = ack + @cast(ptr, "tcphdr")->urg = urg + + /* check that reading with embedded-C is ok */ + real_ack = get_ack() + real_urg = get_urg() + errors = (ack != real_ack) + (urg != real_urg) + + /* check that reading with a cast is ok */ + cast_ack = @cast(ptr, "tcphdr")->ack + cast_urg = @cast(ptr, "tcphdr")->urg + errors += (ack != cast_ack) + (urg != cast_urg) + + if (errors) + printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n", + errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg) + + return errors +} + +probe begin { + println("systemtap starting probe") + + errors = check(0, 0) + errors += check(0, 1) + errors += check(1, 0) + errors += check(1, 1) + + println("systemtap ending probe") + if (errors == 0) + println("systemtap test success") + exit() +} diff --git a/testsuite/systemtap.base/bz10078.c b/testsuite/systemtap.base/bz10078.c new file mode 100644 index 00000000..9075fbc7 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.c @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include <stdio.h> + +struct point { int x, y; }; + +struct point mkpoint2(void) +{ + struct point p = { 1, 2 }; + return p; +} + +struct point mkpoint1(void) +{ + return mkpoint2(); +} + +main() +{ + struct point p = mkpoint1(); + printf("%d,%d\n", p.x, p.y); + exit(0); +} diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp new file mode 100644 index 00000000..cad3a3a8 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.exp @@ -0,0 +1,35 @@ +set test bz10078 + +catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err +if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } + +if {![utrace_p]} { + catch {exec rm -f $test} + untested "$test -p4" + untested "$test -p5" + return +} + +set rc [stap_run_batch $srcdir/$subdir/$test.stp] +if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" } + +if {! [installtest_p]} { + catch {exec rm -f $test} + untested "$test -p5" + return +} + +# Pick up the stap being tested. +set stapexe [exec /usr/bin/which stap] +spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test +set ok 0 +expect { + -timeout 60 + -re {mkpoint[^\r\n]* returns\r\n} { incr ok; exp_continue } + -re {1,2\r\n} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$ok == 3} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" } +exec rm -f $test diff --git a/testsuite/systemtap.base/bz10078.stp b/testsuite/systemtap.base/bz10078.stp new file mode 100755 index 00000000..0318e4e9 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.stp @@ -0,0 +1,4 @@ +#! stap -p4 +probe process("./bz10078").function("mkpoint*").return { + printf("%s returns\n", probefunc()) +} diff --git a/testsuite/systemtap.base/bz5274.exp b/testsuite/systemtap.base/bz5274.exp index 92441e9e..2f76a43f 100755 --- a/testsuite/systemtap.base/bz5274.exp +++ b/testsuite/systemtap.base/bz5274.exp @@ -17,14 +17,7 @@ if {! [installtest_p]} { 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} { +if {![utrace_p]} { catch {exec rm -f $test} untested "$test -p5" return diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp index b96ed95c..32ecdaf5 100644 --- a/testsuite/systemtap.base/bz6850.exp +++ b/testsuite/systemtap.base/bz6850.exp @@ -3,14 +3,7 @@ set test bz6850 catch {exec gcc -g -o bz6850 $srcdir/$subdir/bz6850.c} err if {$err == "" && [file exists bz6850]} then { pass "$test compile" } else { fail "$test compile" } -# 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} { +if {![utrace_p]} { catch {exec rm -f $test} untested "$test -p4" untested "$test -p5" diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp index df3246e8..374132f0 100644 --- a/testsuite/systemtap.base/cast.exp +++ b/testsuite/systemtap.base/cast.exp @@ -1,4 +1,6 @@ set test "cast" set ::result_string {PID OK -execname OK} -stap_run2 $srcdir/$subdir/$test.stp +PID2 OK +execname OK +sa_data OK} +stap_run2 $srcdir/$subdir/$test.stp -g diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index bec0cc9b..e2505000 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -10,6 +10,13 @@ probe begin else printf("PID %d != %d\n", pid, cast_pid) + // Compare PIDs using a generated kernel module + cast_pid = @cast(curr, "task_struct", "kernel<linux/sched.h>")->tgid + if (pid == cast_pid) + println("PID2 OK") + else + printf("PID2 %d != %d\n", pid, cast_pid) + // Compare execnames name = execname() cast_name = kernel_string(@cast(curr, "task_struct")->comm) @@ -18,5 +25,23 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) + // Compare sa_data using a generated user module + data = 42 + cast_data = @cast(get_sockaddr(data), "sockaddr", "<sys/socket.h>")->sa_data[0] + if (data == cast_data) + println("sa_data OK") + else + printf("sa_data %d != %d\n", data, cast_data) + exit() } + +%{ +#include <linux/socket.h> +%} + +function get_sockaddr:long(data:long) %{ + static struct sockaddr sa = {0}; + sa.sa_data[0] = THIS->data; + THIS->__retvalue = (long)&sa; +%} diff --git a/testsuite/systemtap.base/flightrec1.exp b/testsuite/systemtap.base/flightrec1.exp new file mode 100644 index 00000000..c32a77f2 --- /dev/null +++ b/testsuite/systemtap.base/flightrec1.exp @@ -0,0 +1,43 @@ +set test "flightrec1" +if {![installtest_p]} { untested $test; return } + +# run stapio in background mode +spawn stap -F -o $test.out -we {probe begin {}} +# check whether stap outputs stapio pid +set pid 0 +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (flight recorder option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +# check whether stapio is running in background +spawn ps -o cmd hc $pid +expect { + -timeout 10 + "stapio" {pass "$test (stapio in background)"} # don't contine + timeout { fail "$test (timeout)"} + eof { fail "$test (stapio was not found)" } +} +wait + +exec kill -TERM $pid + +# check output file +if {[catch {exec rm $test.out}]} { + fail "$test (no output file)" + return -1 +} else { + pass "$test (output file)" +} + + diff --git a/testsuite/systemtap.base/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp new file mode 100644 index 00000000..d4481db4 --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.exp @@ -0,0 +1,68 @@ +set test "flightrec2" +if {![installtest_p]} { untested $test; return } + +# cleanup +system "rm -f flightlog.out*" + +set pid 0 +# check -S option +spawn stap -F -o flightlog.out -S 1,3 $srcdir/$subdir/$test.stp +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (-S option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)"} + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +exec sleep 4 +set scnt 0 +set cnt1 0 +# wait for log files +eval spawn stat -c %s [glob flightlog.out.*] +expect { + -timeout 100 + -re {[0-9]+} { + incr cnt1; + if {$expect_out(buffer) <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec sleep 3 +set cnt2 0 +# wait for log files +eval spawn stat -c %s [glob flightlog.out.*] +expect { + -timeout 100 + -re {[0-9]+} { + incr cnt2; + if {$expect_out(buffer) <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +# check logfile number +if {$cnt1 == 3 && $cnt2 == 3} { + pass "$test (log file numbers limitation)" +} else { + fail "$test (log file numbers ($cnt1, $cnt2))" +} +# check logfile size +if {$scnt == $cnt1 + $cnt2 } { + pass "$test (log file size limitation)" +} else { + fail "$test (log file size ($scnt != $cnt1 + $cnt2))" +} +exec kill -TERM $pid +# wait for exiting... +exec sleep 1 +system "rm -f flightlog.out*" + diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp new file mode 100644 index 00000000..f42c9b8e --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.stp @@ -0,0 +1,5 @@ +probe timer.ms(10) +{ + for (j = 0; j < 1000; j++) + printf("1234567890\n") +} diff --git a/testsuite/systemtap.base/flightrec3.exp b/testsuite/systemtap.base/flightrec3.exp new file mode 100644 index 00000000..5b9d8253 --- /dev/null +++ b/testsuite/systemtap.base/flightrec3.exp @@ -0,0 +1,79 @@ +set test "flightrec3" +if {![installtest_p]} { untested $test; return } + +# cleanup +system "rm -f flightlog.out*" + +set pid 0 +# check -S option with bulk(percpu file) mode +spawn stap -F -o flightlog.out -S 1,3 -b $srcdir/$subdir/$test.stp +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (-S option with bulk mode)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)"} + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +exec sleep 4 +array set cpus {} +set scnt 0 +# wait for log files +exec kill -STOP $pid +exec sleep 1 +eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*] +expect { + -timeout 100 + -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} { + set cpuid $expect_out(1,string) + set size $expect_out(2,string) + if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0} + incr cpus($cpuid); + if {$size <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec kill -CONT $pid +exec sleep 3 +exec kill -STOP $pid +eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*] +expect { + -timeout 100 + -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} { + set cpuid $expect_out(1,string) + set size $expect_out(2,string) + if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0} + incr cpus($cpuid); + if {$size <= 1048576 } {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec kill -CONT $pid +# check logfile number +set cnt 0 +foreach e [array names cpus] { + if {$cpus($e) != 6} { + fail "$test (log file numbers cpu:$e, cnt:$cpus($e)))" + } + set cnt [expr $cnt + $cpus($e)] +} +# check logfile size +if {$scnt == $cnt} { + pass "$test (log file size limitation with bulk mode)" +} else { + fail "$test (log file size ($scnt != $cnt))" +} +exec kill -TERM $pid +# wait for exiting... +exec sleep 1 +system "rm -f flightlog.out*" + diff --git a/testsuite/systemtap.base/flightrec3.stp b/testsuite/systemtap.base/flightrec3.stp new file mode 100644 index 00000000..d660793f --- /dev/null +++ b/testsuite/systemtap.base/flightrec3.stp @@ -0,0 +1,5 @@ +probe kernel.function("update_process_times") +{ + for (j = 0; j < 100; j++) + printf("1234567890\n") +} diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index f19af977..5da0dfaf 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -1,17 +1,13 @@ # itrace test -# temporarily disabled -return - # Initialize variables -set utrace_support_found 0 set exepath "[pwd]/ls_[pid]" set itrace1_script { global instrs = 0 probe begin { printf("systemtap starting probe\n") } - probe process("%s").itrace + probe process("%s").insn { instrs += 1 if (instrs == 5) @@ -28,7 +24,7 @@ set itrace1_script_output "itraced = 5\r\n" set itrace2_script { global instrs = 0, itrace_on = 0, start_timer = 0 probe begin { start_timer = 1; printf("systemtap starting probe\n") } - probe process("%s").itrace if (itrace_on) + probe process("%s").insn if (itrace_on) { instrs += 1 if (instrs == 5) @@ -51,6 +47,26 @@ set itrace2_script { } set itrace2_script_output "itraced = 5\r\n" +set itrace3_script { + global branches = 0 + probe begin + { + printf("systemtap starting probe\n") + } + probe process("%s").insn.block + { + branches += 1 + if (branches == 5) + exit() + } + + + probe end { printf("systemtap ending probe\n") + printf("itraced block mode = %%d\n", branches) + } +} +set itrace3_script_output "itraced block mode = 5\r\n" + # Set up our own copy of /bin/ls, to make testing for a particular # executable easy. We can't use 'ln' here, since we might be creating @@ -75,14 +91,8 @@ proc run_ls_5_sec {} { } -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - set TEST_NAME "itrace1" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME @@ -93,7 +103,7 @@ if {$utrace_support_found == 0} { set TEST_NAME "itrace2" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME @@ -102,5 +112,16 @@ if {$utrace_support_found == 0} { stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script } +set TEST_NAME "itrace3" +if {![utrace_p]} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + send_log "ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n" + set script [format $itrace3_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script +} + # Cleanup exec rm -f $exepath diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp new file mode 100644 index 00000000..635930f8 --- /dev/null +++ b/testsuite/systemtap.base/kprobes.exp @@ -0,0 +1,2 @@ +set test "kprobes" +stap_run $srcdir/$subdir/$test.stp no_load "probe point hit" diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp new file mode 100644 index 00000000..884b321c --- /dev/null +++ b/testsuite/systemtap.base/kprobes.stp @@ -0,0 +1,25 @@ +/* + * kprobes.stp + * Probe to test the functionality of kprobe-based probes + * (Dwarfless Probing) + */ +global hit_str + +probe begin +{ + println("systemtap starting probe"); + hit_str = "" +} + +probe kprobe.function("vfs_read") +{ + hit_str = "probe point hit" + exit(); +} + +probe end +{ + println("systemtap ending probe"); + println(hit_str); + delete hit_str; +} diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 6db81c54..79e3f483 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -1,14 +1,6 @@ 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 } +if {![utrace_p]} { untested $test; return } # Compile a C program to use as the user-space probing target set label_srcpath "[pwd]/labels.c" @@ -18,15 +10,22 @@ set label_flags "additional_flags=-g" set fp [open $label_srcpath "w"] puts $fp " int +foo () +{ +init_an_int: + return 1; +} +int main () { sleep(5); + foo(); int a = 0; int b = 0; char *c; init_an_int: a = 2; -init_another_int: +init_an_int_again: b = 3; c = \"abc\"; ptr_inited: @@ -38,8 +37,9 @@ close $fp set label_stppath "[pwd]/labels.stp" set fp [open $label_stppath "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)} +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)} +probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp @@ -55,20 +55,66 @@ if { $res != "" } { pass "compiling labels.c -g" } +# line number error + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:10\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {no match while resolving probe point} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + +# line number + +set ok 0 +spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:4\").label(\"*\")" + +wait +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } + +# list of labels + +spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" + +wait +set ok 0 +expect { + -timeout 180 + -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +if {$ok == 1} { pass "$test -l .label" } { fail "$test -l .label $ok" } + # label in an executable +set ok 0 verbose -log "spawn stap -c $label_exepath $label_stppath" spawn stap -c $label_exepath $label_stppath wait 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 } + -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" } +if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } # address of label in an executable @@ -76,7 +122,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_exepath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " @@ -111,7 +157,7 @@ if { $res != "" } { # label in a shared object -spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)" +spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)" expect { -timeout 180 -re {process.*function} { incr ok; exp_continue } @@ -119,7 +165,7 @@ expect { eof { } } -if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" } +if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" } # address of label in a shared object @@ -127,7 +173,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_sopath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " diff --git a/testsuite/systemtap.base/maxactive.exp b/testsuite/systemtap.base/maxactive.exp index 7c03a1bf..79ede897 100644 --- a/testsuite/systemtap.base/maxactive.exp +++ b/testsuite/systemtap.base/maxactive.exp @@ -10,12 +10,12 @@ proc sleep_five_sec {} { return 0; } -# Script1. For 5 seconds, probe the return of "sys_select" and -# "sys_read". See if we skip any probes. +# Script1. For 5 seconds, probe the return of "vfs_read" and +# "do_select". See if we skip any probes. set script1 { global foo - probe kernel.function("sys_select").return, - kernel.function("sys_read").return { foo++ } + probe kernel.function("vfs_read").return, + kernel.function("do_select").return { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} @@ -26,13 +26,13 @@ set script1 { stap_run "MAXACTIVE01" sleep_five_sec "" -e $script1 set skipped1 $skipped_probes -# Script2. For 5 seconds, probe the return of "sys_select" and -# "sys_read", with a limit of 1 probe active at a time. See if we +# Script2. For 5 seconds, probe the return of "vfs_read" and +# "do_select", with a limit of 1 probe active at a time. See if we # skip any probes. set script2 { global foo - probe kernel.function("sys_select").return.maxactive(1), - kernel.function("sys_read").return.maxactive(1) { foo++ } + probe kernel.function("vfs_read").return.maxactive(1), + kernel.function("do_select").return.maxactive(1) { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} diff --git a/testsuite/systemtap.base/onoffprobe.stp b/testsuite/systemtap.base/onoffprobe.stp index f7169039..79c41a3c 100644 --- a/testsuite/systemtap.base/onoffprobe.stp +++ b/testsuite/systemtap.base/onoffprobe.stp @@ -10,13 +10,13 @@ probe begin if (switch==0) { } #dwarf probe (return) -probe kernel.function("sys_write").return if (switch == 1) { +probe kernel.function("vfs_write").return if (switch == 1) { log("function return probed") switch = 0 } #dwarf probe (entry) -probe kernel.function("sys_write") if (switch == 2) { +probe kernel.function("vfs_write").return if (switch == 2) { log("function entry probed") switch = 0 } diff --git a/testsuite/systemtap.base/optionalprobe.exp b/testsuite/systemtap.base/optionalprobe.exp new file mode 100644 index 00000000..5484003c --- /dev/null +++ b/testsuite/systemtap.base/optionalprobe.exp @@ -0,0 +1,9 @@ +set test "optionalprobe" +spawn stap -p2 -w $srcdir/$subdir/$test.stp +expect { + -timeout 60 + -re "# probes\r\n" { exp_continue } + -re "^begin" { pass $test } + eof { fail $test } + timeout { fail "$test unexpected timeout" } +} diff --git a/testsuite/systemtap.base/optionalprobe.stp b/testsuite/systemtap.base/optionalprobe.stp new file mode 100644 index 00000000..13918cee --- /dev/null +++ b/testsuite/systemtap.base/optionalprobe.stp @@ -0,0 +1,14 @@ +#! stap + +# test optional probe + +probe foo ?, + process("/do/not/exist").function("main") !, + kernel.mark("no such mark") ?, + kernel.trace("no trace") !, + process.foo ?, + kernel.statement("no statement") !, + module("no mod").function("*") ?, + kernel.function("no such func*") !, + begin { +} diff --git a/testsuite/systemtap.base/overload.exp b/testsuite/systemtap.base/overload.exp index cbcbe817..ac9ceb24 100644 --- a/testsuite/systemtap.base/overload.exp +++ b/testsuite/systemtap.base/overload.exp @@ -8,7 +8,7 @@ set script { k["foo"] = 0 } - probe kernel.function("sys_read"), kernel.function("sys_write") { + probe kernel.function("vfs_read"), kernel.function("vfs_write") { k["foo"]++ } probe end { diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index 74818beb..c3aed91e 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -10,11 +10,12 @@ set ::result_string {1 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10} -set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic}} +set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-ansi additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}} # Iterate extra_flags, trying each with C and C++ for {set i 0} {$i < [llength $extra_flags]} {incr i} { set extra_flag [lindex $extra_flags $i] +set testprog "sdt.c.exe.$i" # C set test_flags "additional_flags=-g" @@ -23,44 +24,47 @@ set test_flags "$test_flags additional_flags=-Wall" set test_flags "$test_flags additional_flags=-Wextra" set test_flags "$test_flags additional_flags=-Werror" -set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"] +set saveidx 0 + +set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"] if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c $extra_flag" - return + untested "$test $extra_flag" + continue } else { pass "compiling $test.c $extra_flag" } -if {[installtest_p]} { -# XXX: we need distinct test names for these - stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog +if {[installtest_p] && [utrace_p]} { + stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test $extra_flag" } # C++ +set testprog "sdt.cxx.exe.$i" + set test_flags "additional_flags=-g" set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys" set test_flags "$test_flags additional_flags=-Wall" set test_flags "$test_flags additional_flags=-Werror" set test_flags "$test_flags additional_flags=-x additional_flags=c++" -set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_flags $extra_flag"] +set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"] if { $res != "" } { verbose "target_compile failed: $res" 2 fail "compiling $test.c c++ $extra_flag" - return + untested "$test $extra_flag" + continue } else { pass "compiling $test.c c++ $extra_flag" } -if {[installtest_p]} { -# XXX: we need distinct test names for these - stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog +if {[installtest_p] && [utrace_p]} { + stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog } else { untested "$test c++ $extra_flag" } } -catch {exec rm -f $test.prog} diff --git a/testsuite/systemtap.base/sdt.stp b/testsuite/systemtap.base/sdt.stp index 1f075bca..5df1fdc9 100644 --- a/testsuite/systemtap.base/sdt.stp +++ b/testsuite/systemtap.base/sdt.stp @@ -1,49 +1,49 @@ -probe process("sdt.prog").mark("mark_a") +probe process(@1).mark("mark_a") { printf("%d\n", $arg1); } -probe process("sdt.prog").mark("mark_b") +probe process(@1).mark("mark_b") { printf("%d %d\n", $arg1, $arg2); } -probe process("sdt.prog").mark("mark_c") +probe process(@1).mark("mark_c") { printf("%d %d %d\n", $arg1, $arg2, $arg3); } -probe process("sdt.prog").mark("mark_d") +probe process(@1).mark("mark_d") { printf("%d %d %d %d\n", $arg1, $arg2, $arg3, $arg4); } -probe process("sdt.prog").mark("mark_e") +probe process(@1).mark("mark_e") { printf("%d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5); } -probe process("sdt.prog").mark("mark_f") +probe process(@1).mark("mark_f") { printf("%d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6); } -probe process("sdt.prog").mark("mark_g") +probe process(@1).mark("mark_g") { printf("%d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); } -probe process("sdt.prog").mark("mark_h") +probe process(@1).mark("mark_h") { printf("%d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8); } -probe process("sdt.prog").mark("mark_i") +probe process(@1).mark("mark_i") { printf("%d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9); } -probe process("sdt.prog").mark("mark_j") +probe process(@1).mark("mark_j") { printf("%d %d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9, $arg10); } diff --git a/testsuite/systemtap.base/sdt_types.c b/testsuite/systemtap.base/sdt_types.c new file mode 100644 index 00000000..2e04ec7e --- /dev/null +++ b/testsuite/systemtap.base/sdt_types.c @@ -0,0 +1,168 @@ +#include "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */ +#include <stdint.h> +#include <values.h> + +int +main (int argc, char **argv) +{ + char char_var = '~'; + STAP_PROBE1(provider,char_var,char_var); + const char const_char_var = '!'; + STAP_PROBE1(provider,const_char_var,const_char_var); + volatile char volatile_char_var = '!'; + STAP_PROBE1(provider,volatile_char_var,volatile_char_var); + char *ptr_char_var = &char_var; + STAP_PROBE2(provider,ptr_char_var,ptr_char_var,&char_var); + const char *ptr_const_char_var = &char_var; + STAP_PROBE2(provider,ptr_const_char_var,ptr_const_char_var,&char_var); + char * const char_ptr_const_var = &char_var; + STAP_PROBE2(provider,char_ptr_const_var,char_ptr_const_var,&char_var); + volatile char *ptr_volatile_char_var = &char_var; + STAP_PROBE2(provider,ptr_volatile_char_var,ptr_volatile_char_var,&char_var); + char * volatile char_ptr_volatile_var = &char_var; + STAP_PROBE2(provider,char_ptr_volatile_var,char_ptr_volatile_var,&char_var); + short int short_int_var = 32767; + STAP_PROBE1(provider,short_int_var,short_int_var); + const short int const_short_int_var = -32767; + STAP_PROBE1(provider,const_short_int_var,const_short_int_var); + volatile short int volatile_short_int_var = -32767; + STAP_PROBE1(provider,volatile_short_int_var,volatile_short_int_var); + short int *ptr_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_short_int_var,ptr_short_int_var,&short_int_var); + const short int *ptr_const_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_const_short_int_var,ptr_const_short_int_var,&short_int_var); + short int * const short_int_ptr_const_var = &short_int_var; + STAP_PROBE2(provider,short_int_ptr_const_var,short_int_ptr_const_var,&short_int_var); + volatile short int *ptr_volatile_short_int_var = &short_int_var; + STAP_PROBE2(provider,ptr_volatile_short_int_var,ptr_volatile_short_int_var,&short_int_var); + short int * volatile short_int_ptr_volatile_var = &short_int_var; + STAP_PROBE2(provider,short_int_ptr_volatile_var,short_int_ptr_volatile_var,&short_int_var); + int int_var = 65536; + STAP_PROBE1(provider,int_var,int_var); + const int const_int_var = -65536; + STAP_PROBE1(provider,const_int_var,const_int_var); + volatile int volatile_int_var = -65536; + STAP_PROBE1(provider,volatile_int_var,volatile_int_var); + int *ptr_int_var = &int_var; + STAP_PROBE2(provider,ptr_int_var,ptr_int_var,&int_var); + const int *ptr_const_int_var = &int_var; + STAP_PROBE2(provider,ptr_const_int_var,ptr_const_int_var,&int_var); + int * const int_ptr_const_var = &int_var; + STAP_PROBE2(provider,int_ptr_const_var,int_ptr_const_var,&int_var); + volatile int *ptr_volatile_int_var = &int_var; + STAP_PROBE2(provider,ptr_volatile_int_var,ptr_volatile_int_var,&int_var); + int * volatile int_ptr_volatile_var = &int_var; + STAP_PROBE2(provider,int_ptr_volatile_var,int_ptr_volatile_var,&int_var); + long int long_int_var = 65536; + STAP_PROBE1(provider,long_int_var,long_int_var); + const long int const_long_int_var = -65536; + STAP_PROBE1(provider,const_long_int_var,const_long_int_var); + volatile long int volatile_long_int_var = -65536; + STAP_PROBE1(provider,volatile_long_int_var,volatile_long_int_var); + long int *ptr_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_long_int_var,ptr_long_int_var,&long_int_var); + const long int *ptr_const_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_const_long_int_var,ptr_const_long_int_var,&long_int_var); + long int * const long_int_ptr_const_var = &long_int_var; + STAP_PROBE2(provider,long_int_ptr_const_var,long_int_ptr_const_var,&long_int_var); + volatile long int *ptr_volatile_long_int_var = &long_int_var; + STAP_PROBE2(provider,ptr_volatile_long_int_var,ptr_volatile_long_int_var,&long_int_var); + long int * volatile long_int_ptr_volatile_var = &long_int_var; + STAP_PROBE2(provider,long_int_ptr_volatile_var,long_int_ptr_volatile_var,&long_int_var); + long long int long_long_int_var = 65536; + STAP_PROBE1(provider,long_long_int_var,long_long_int_var); + const long long int const_long_long_int_var = -65536; + STAP_PROBE1(provider,const_long_long_int_var,const_long_long_int_var); + volatile long long int volatile_long_long_int_var = -65536; + STAP_PROBE1(provider,volatile_long_long_int_var,volatile_long_long_int_var); + long long int *ptr_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_long_long_int_var,ptr_long_long_int_var,&long_long_int_var); + const long long int *ptr_const_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_const_long_long_int_var,ptr_const_long_long_int_var,&long_long_int_var); + long long int * const long_long_int_ptr_const_var = &long_long_int_var; + STAP_PROBE2(provider,long_long_int_ptr_const_var,long_long_int_ptr_const_var,&long_long_int_var); + volatile long long int *ptr_volatile_long_long_int_var = &long_long_int_var; + STAP_PROBE2(provider,ptr_volatile_long_long_int_var,ptr_volatile_long_long_int_var,&long_long_int_var); + long long int * volatile long_long_int_ptr_volatile_var = &long_long_int_var; + STAP_PROBE2(provider,long_long_int_ptr_volatile_var,long_long_int_ptr_volatile_var,&long_long_int_var); + + char arr_char [2] = "!~"; + STAP_PROBE1(provider,arr_char,&arr_char); + struct { + int int_var; + } arr_struct [2] = {{ + .int_var=1, + },{ + .int_var=2, + }}; + STAP_PROBE1(provider,arr_struct,&arr_struct); + struct { + unsigned int bit1_0:1; + unsigned int bit1_1:1; + char char_2; + unsigned int bit1_6:1; + unsigned int bit1_7:1; + char char_8; + unsigned int bit1_9:1; + unsigned int bit1_10:1; + } bitfields_small_var = { + .bit1_0=1, + .bit1_1=0, + .char_2='a', + .bit1_6=1, + .bit1_7=0, + .char_8='z', + .bit1_9=1, + .bit1_10=0, + }; + STAP_PROBE8(provider,bitfields_small_var, + (int)bitfields_small_var.bit1_0, + (int)bitfields_small_var.bit1_1, + bitfields_small_var.char_2, + (int)bitfields_small_var.bit1_6, + (int)bitfields_small_var.bit1_7, + bitfields_small_var.char_8, + (int)bitfields_small_var.bit1_9, + (int)bitfields_small_var.bit1_10); + struct { + unsigned char char_0; + int bit1_4:1; + unsigned int bit1_5:1; + int bit2_6:2; + unsigned int bit2_8:2; + int bit3_10:3; + unsigned int bit3_13:3; + int bit9_16:9; + unsigned int bit9_25:9; + char char_34; + } bitfields_bit_var = { + .char_0='A', + .bit1_4=-1, + .bit1_5=1, + .bit2_6=1, + .bit2_8=3, + .bit3_10=3, + .bit3_13=7, + .bit9_16=255, + .bit9_25=511, + .char_34='Z', + }; + STAP_PROBE10(provider,bitfields_bit_var,bitfields_bit_var.char_0, + (int)bitfields_bit_var.bit1_4, + (int)bitfields_bit_var.bit1_5, + (int)bitfields_bit_var.bit2_6, + (int)bitfields_bit_var.bit2_8, + (int)bitfields_bit_var.bit3_10, + (int)bitfields_bit_var.bit3_13, + (int)bitfields_bit_var.bit9_16, + (int)bitfields_bit_var.bit9_25, + bitfields_bit_var.char_34); + enum { + red = 0, + green = 1, + blue = 2 + } primary_colors_var = green; + STAP_PROBE1(provider,primary_colors_var,primary_colors_var); + return 0; +} + diff --git a/testsuite/systemtap.base/sdt_types.stp b/testsuite/systemtap.base/sdt_types.stp new file mode 100644 index 00000000..654b0d18 --- /dev/null +++ b/testsuite/systemtap.base/sdt_types.stp @@ -0,0 +1,371 @@ +probe process(@1).mark("char_var") { + if ($arg1 != 126) + printf("FAIL: char_var\n") + else + printf("PASS: char_var\n") +} + +probe process(@1).mark("const_char_var") { + if ($arg1 != 33) + printf("FAIL: const_char_var\n") + else + printf("PASS: const_char_var\n") +} + +probe process(@1).mark("volatile_char_var") { + if ($arg1 != 33) + printf("FAIL: volatile_char_var\n") + else + printf("PASS: volatile_char_var\n") +} + +probe process(@1).mark("ptr_char_var") { + if ($arg1 != $arg2) + printf("FAIL: ptr_char_var\n") + else + printf("PASS: ptr_char_var\n") +} + +probe process(@1).mark("ptr_const_char_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_char_var\n") + else + printf("PASS: ptr_const_char_var\n") +} + +probe process(@1).mark("char_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: char_ptr_const_var\n") + else + printf("PASS: char_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_char_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_char_var\n") + else + printf("PASS: ptr_volatile_char_var\n") +} + +probe process(@1).mark("char_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: char_ptr_volatile_var\n") + else + printf("PASS: char_ptr_volatile_var\n") +} + +probe process(@1).mark("short_int_var") +{ + if ($arg1 != 32767) + printf("FAIL: short_int_var\n") + else + printf("PASS: short_int_var\n") +} + +probe process(@1).mark("const_short_int_var") +{ + if ($arg1 != -32767) + printf("FAIL: const_short_int_var\n") + else + printf("PASS: const_short_int_var\n") +} + +probe process(@1).mark("volatile_short_int_var") +{ + if ($arg1 != -32767) + printf("FAIL: volatile_short_int_var\n") + else + printf("PASS: volatile_short_int_var\n") +} + +probe process(@1).mark("ptr_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_short_int_var\n") + else + printf("PASS: ptr_short_int_var\n") +} + +probe process(@1).mark("ptr_const_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_short_int_var\n") + else + printf("PASS: ptr_const_short_int_var\n") +} + +probe process(@1).mark("short_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: short_int_ptr_const_var\n") + else + printf("PASS: short_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_short_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_short_int_var\n") + else + printf("PASS: ptr_volatile_short_int_var\n") +} + +probe process(@1).mark("short_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: short_int_ptr_volatile_var\n") + else + printf("PASS: short_int_ptr_volatile_var\n") +} + +probe process(@1).mark("int_var") +{ + if ($arg1 != 65536) + printf("FAIL: int_var") + else + printf("PASS: int_var") +} + +probe process(@1).mark("const_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_int_var\n") + else + printf("PASS: const_int_var\n") +} + +probe process(@1).mark("volatile_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_int_var\n") + else + printf("PASS: volatile_int_var\n") +} + +probe process(@1).mark("ptr_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_int_var\n") + else + printf("PASS: ptr_const_int_var\n") +} + +probe process(@1).mark("ptr_const_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_int_var\n") + else + printf("PASS: ptr_const_int_var\n") +} + +probe process(@1).mark("int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: int_ptr_const_var\n") + else + printf("PASS: int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_int_var\n") + else + printf("PASS: ptr_volatile_int_var\n") +} + +probe process(@1).mark("int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: int_ptr_volatile_var\n") + else + printf("PASS: int_ptr_volatile_var\n") +} + +probe process(@1).mark("long_int_var") +{ + if ($arg1 != 65536) + printf("FAIL: long_int_var\n") + else + printf("PASS: long_int_var\n") +} + +probe process(@1).mark("const_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_long_int_var\n") + else + printf("PASS: const_long_int_var\n") +} + +probe process(@1).mark("volatile_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_long_int_var\n") + else + printf("PASS: volatile_long_int_var\n") +} + +probe process(@1).mark("ptr_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_long_int_var\n") + else + printf("PASS: ptr_long_int_var\n") +} + +probe process(@1).mark("ptr_const_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_long_int_var\n") + else + printf("PASS: ptr_const_long_int_var\n") +} + +probe process(@1).mark("long_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_int_ptr_const_var\n") + else + printf("PASS: long_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_long_int_var\n") + else + printf("PASS: ptr_volatile_long_int_var\n") +} + +probe process(@1).mark("long_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_int_ptr_volatile_var\n") + else + printf("PASS: long_int_ptr_volatile_var\n") +} + +probe process(@1).mark("long_long_int_var") +{ + if ($arg1 != 65536) + printf("FAIL: long_long_int_var\n") + else + printf("PASS: long_long_int_var\n") +} + +probe process(@1).mark("const_long_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: const_long_long_int_var\n") + else + printf("PASS: const_long_long_int_var\n") +} + +probe process(@1).mark("volatile_long_long_int_var") +{ + if ($arg1 != -65536) + printf("FAIL: volatile_long_long_int_var\n") + else + printf("PASS: volatile_long_long_int_var\n") +} + +probe process(@1).mark("ptr_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_long_long_int_var\n") + else + printf("PASS: ptr_long_long_int_var\n") +} + +probe process(@1).mark("ptr_const_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_const_long_long_int_var\n") + else + printf("PASS: ptr_const_long_long_int_var\n") +} + +probe process(@1).mark("long_long_int_ptr_const_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_long_int_ptr_const_var\n") + else + printf("PASS: long_long_int_ptr_const_var\n") +} + +probe process(@1).mark("ptr_volatile_long_long_int_var") +{ + if ($arg1 != $arg2) + printf("FAIL: ptr_volatile_long_long_int_var\n") + else + printf("PASS: ptr_volatile_long_long_int_var\n") +} + +probe process(@1).mark("long_long_int_ptr_volatile_var") +{ + if ($arg1 != $arg2) + printf("FAIL: long_long_int_ptr_volatile_var\n") + else + printf("PASS: long_long_int_ptr_volatile_var\n") +} + +probe process(@1).mark("arr_char") +{ + arr_char = user_string ($arg1); + if (arr_char != "!~") + printf("FAIL: arr_char_var\n") + else + printf("PASS: arr_char_var\n") +} + +probe process(@1).mark("arr_struct") +{ + arr_struct_int_var = user_int ($arg1) + if (arr_struct_int_var != 1) + printf("FAIL: arr_struct_var\n") + else + printf("PASS: arr_struct_var\n") +} + +probe process(@1).mark("bitfields_small_var") +{ + if ($arg1 != 1 || $arg2 != 0 || $arg3 != 97 || $arg4 != 1 + || $arg5 != 0 || $arg6 != 122 || $arg7 != 1 || $arg8 != 0) + printf("FAIL: bitfields_small_var\n") + +} + +probe process(@1).mark("bitfields_bit_var") +{ + if ($arg1 != 65 || $arg2 != -1 || $arg3 != 1 || $arg4 != 1 + || $arg5 != 3 || $arg6 != 3 || $arg7 != 7 || $arg8 != 255 + || $arg9 != 511 || $arg10 != 90) + printf("FAIL: bitfields_bit_var\n") + else + printf("PASS: bitfields_bit_var\n") +} + + +probe process(@1).mark("primary_colors_var") +{ + if ($arg1 != 1) + printf("FAIL: primary_colors_var\n") + else + printf("PASS: primary_colors_var\n") +} + + + + + + + + + + + diff --git a/testsuite/systemtap.base/skipped.exp b/testsuite/systemtap.base/skipped.exp index 8c491037..f3048c8a 100644 --- a/testsuite/systemtap.base/skipped.exp +++ b/testsuite/systemtap.base/skipped.exp @@ -2,8 +2,8 @@ set test "skip tracking" if {! [installtest_p]} { untested $test; return } -set cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"] -if {$cpus < 2} { unsupported $test; return } +set nr_cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"] +if {$nr_cpus < 2} { unsupported $test; return } set ok 0 spawn stap -e "probe timer.s(5) {exit()} probe timer.profile,syscall.* {f++} global f" -DMAXTRYLOCK=0 -tu @@ -18,4 +18,4 @@ expect { catch {close} catch {wait} -if {$ok >= 3} { pass "$test ($cpus $ok)" } else { fail "$test ($cpus $ok)" } +if {$ok >= 3} { pass "$test ($nr_cpus $ok)" } else { fail "$test ($nr_cpus $ok)" } diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp index a4bd5e2c..1e53d5d3 100644 --- a/testsuite/systemtap.base/static_uprobes.exp +++ b/testsuite/systemtap.base/static_uprobes.exp @@ -1,5 +1,6 @@ +set test "static_uprobes" -set test "sduprobes" +# Test miscellaneous features of .mark probes # Compile a C program to use as the user-space probing target set sup_srcpath "[pwd]/static_uprobes.c" @@ -81,6 +82,9 @@ provider static_uprobes { }; " close $fp + +# Test dtrace + if {[installtest_p]} { set dtrace $env(SYSTEMTAP_PATH)/dtrace } else { @@ -89,11 +93,10 @@ if {[installtest_p]} { if {[catch {exec $dtrace -h -s $sup_dpath} res]} { verbose -log "unable to run $dtrace: $res" } -catch {exec rm -f $sup_dpath} if {[file exists $sup_hpath]} then { - pass "$test generating header" + pass "$test dtrace" } else { - fail "$test generating header" + fail "$test dtrace" catch {exec rm -f $sup_srcpath $sup_hpath $sup_stppath} return } @@ -104,7 +107,11 @@ if {[installtest_p]} { set sdtdir $srcdir/../includes } -set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I." +set sup_flags "additional_flags=-I$srcdir/../includes/sys" +set sup_flags "$sup_flags additional_flags=-I$sdtdir" +set sup_flags "$sup_flags additional_flags=-g" +set sup_flags "$sup_flags additional_flags=-O" +set sup_flags "$sup_flags additional_flags=-I." set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags] if { $res != "" } { verbose "target_compile failed: $res" 2 @@ -115,34 +122,15 @@ if { $res != "" } { pass "$test compiling C -g" } -spawn mv $sup_srcpath "[pwd]/static_uprobes.cc" -set sup_srcpath "[pwd]/static_uprobes.cc" -set sup_flags "$sup_flags c++" -set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags] -if { $res != "" } { - verbose "target_compile failed: $res" 2 - fail "$test compiling C++ -g" - catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath} - return -} else { - pass "$test compiling C++ -g" -} - 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} { +if {![utrace_p]} { untested "$test" catch {exec rm -f $sup_srcpath} return } +# Run stap on executable built with dtrace generated header file + set ok 0 verbose -log "spawn stap -c $sup_exepath $sup_stppath" @@ -161,28 +149,56 @@ wait if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" } -set ok 0 +# Test passing various C types to .mark probes -# spawn objcopy -R .probes $supcplus_exepath $sup_exepath -verbose -log "cp $supcplus_exepath $sup_exepath" -spawn cp $supcplus_exepath $sup_exepath -verbose -log "spawn stap -c $sup_exepath $sup_stppath" -spawn stap -c $sup_exepath $sup_stppath +set sup_flags "$sup_flags additional_flags=-O0" +set res [target_compile $srcdir/$subdir/sdt_types.c sdt_types.x executable $sup_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compiling types -g" + return +} else { + pass "$test compiling types -g" +} + +set ok 0 +set fail "types" +verbose -log "spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x" +spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x expect { -timeout 180 - -re {In test_probe_2 probe 0x2} { incr ok; exp_continue } - -re {In test_probe_0 probe 0x3} { incr ok; exp_continue } - -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue } - -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue } - timeout { fail "$test C++ (timeout)" } + -re {FAIL: [a-z_]+var} { regexp " .*$" $expect_out(0,string) s; + incr ok; set fail "$fail $s"; exp_continue } + timeout { fail "$test C (timeout)" } eof { } } wait -if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" } +if { $ok != 0 } { + fail "$test $fail" +} else { + pass "$test types" +} + +# Test .mark probe wildcard matching + +set ok 0 +spawn stap -l "process(\"./sdt_types.x\").mark(\"*\")" +expect { + -timeout 180 + -re {mark\(\"[a-z_]+\"\)} { incr ok; exp_continue } + timeout { fail "$test C (timeout)" } + eof { } +} -# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath} +if { $ok == 45 } { + pass "$test wildcard" +} else { + fail "$test wildcard ($ok)" +} + +if { $verbose == 0 } { +catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath sdt_types.x} +} -# It's not so important to clean up, and it's unhelpful if -# one needs to diagnose a test failure. diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp index be51fef9..619c91a5 100644 --- a/testsuite/systemtap.base/stmt_rel.exp +++ b/testsuite/systemtap.base/stmt_rel.exp @@ -1,8 +1,42 @@ -# test integer limits. Set and print variables and print constants. - set test "stmt_rel" -set ::result_string {PASS bio_init -PASS line number -PASS wildcard} -stap_run2 $srcdir/$subdir/$test.stp +set line1 "" +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+2\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line1; } + timeout { fail "$test C (timeout)" } + eof { } +} + +set line2 "" +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c+3\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { regexp "\[0-9\]\[0-9\]\[0-9\]" $expect_out(0,string) line2; } + timeout { fail "$test C (timeout)" } + eof { } +} + +if { $line1 < $line2 } { + pass "$test line numbers" +} else { + fail "$test line numbers" +} + +set ok 0 +spawn stap -l "kernel.statement(\"bio_init@fs/bio.c:*\")" +expect { + -timeout 180 + -re {[0-9][0-9][0-9]} { incr ok; exp_continue } + timeout { fail "$test C (timeout)" } + eof { } +} + +# bio_init drifts a bit in different kernels. +# maybe 3, 4 or 15 lines in it. +if { $ok >= 3 } { + pass "$test wildcard" +} else { + fail "$test wildcard ($ok)" +} diff --git a/testsuite/systemtap.base/stmt_rel.stp b/testsuite/systemtap.base/stmt_rel.stp deleted file mode 100644 index cfe77317..00000000 --- a/testsuite/systemtap.base/stmt_rel.stp +++ /dev/null @@ -1,71 +0,0 @@ -global stack2pp, stack2func, stack3pp, stack3func -global wildcardpp, wild_count - -probe kernel.statement("bio_init@fs/bio.c+2") { - # stack2 = tokenize(backtrace(), " ") - stack2func = probefunc() - stack2pp = pp() -} -probe kernel.statement("bio_init@fs/bio.c+3") { - # stack3 = tokenize(backtrace(), " " ) - stack3func = probefunc() - stack3pp = pp() -} - -probe kernel.statement("bio_put@fs/bio.c:*") { - line = tokenize(pp(),":") - line = tokenize("",":") - line = substr(line,0,strlen(line)-2) - wildcardpp[strtol(line,10)]++ - - if (wild_count++ <= 10) { - next - } - - stack2pp = tokenize(stack2pp,":") - stack2pp = tokenize("",":") - stack3pp = tokenize(stack3pp,":") - stack3pp = tokenize("",":") - - stack2line = strtol (substr(stack2pp,0,strlen(stack2pp)-2), 10) - stack3line = strtol (substr(stack3pp,0,strlen(stack3pp)-2), 10) - - # Did functions for both bio_init probes match? - if (stack2func == stack3func) { - printf ("PASS %s\n", stack2func) - } - else { - printf ("FAIL %s %s\n", stack2func, stack3func) - } - - # Was line # for bio_init probe +2 < line # for bio_init probe +3? - if ((stack2line + 1) == stack3line) { - printf ("PASS line number\n") - } - else { - printf ("FAIL line number %d %d\n", stack2line, stack3line) - } - - # This test does not take optimized code into account - # Was address for bio_init probe +2 < address for bio_init probe +3? - # if (stack2 < stack3) { - # printf ("PASS address\n") - # } - # else { - # printf ("FAIL address %s %s\n", stack2, stack3) - # } - - # Did wildcard probe hit at least 4 different statements? - foreach ([i] in wildcardpp) { - statement_count += 1 - } - if (statement_count >= 4) { - printf ("PASS wildcard\n") - } - else - { - printf ("FAIL wildcard %d\n", statement_count) - } - - exit() -} diff --git a/testsuite/systemtap.base/stmtvars.exp b/testsuite/systemtap.base/stmtvars.exp index 822e0d7e..c0099f2d 100644 --- a/testsuite/systemtap.base/stmtvars.exp +++ b/testsuite/systemtap.base/stmtvars.exp @@ -3,9 +3,9 @@ set test "stmtvars" set pc 0 set vars "" -spawn stap -e "probe kernel.function(\"sys_open\") {\$foo}" -p4 -vv -u +spawn stap -e "probe kernel.function(\"do_sys_open\") {\$foo}" -p4 -vv -u expect { - -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue } + -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc $expect_out(1,string); exp_continue } -re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars $expect_out(1,string); exp_continue } timeout { fail "$test (timeout)" } eof @@ -18,7 +18,7 @@ set pc2 0 set vars2 "" spawn stap -e "probe kernel.statement($pc) {\$foo}" -p4 -vv -u expect { - -re {probe sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue } + -re {probe do_sys_open[^\r\n]*pc=(0x[^\r\n]*)\r\n} { set pc2 $expect_out(1,string); exp_continue } -re {alternatives: ([^\r\n]*)\): identifier [^\r\n]*\r\n} { set vars2 $expect_out(1,string); exp_continue } timeout { fail "$test (timeout)" } eof diff --git a/testsuite/systemtap.base/strftime.exp b/testsuite/systemtap.base/strftime.exp new file mode 100644 index 00000000..ad9e471d --- /dev/null +++ b/testsuite/systemtap.base/strftime.exp @@ -0,0 +1,49 @@ +set test "strftime" +if {![installtest_p]} { untested $test; return } +# cleanup +system "rm -f %*" + +# check %S and %T +set format %%%S_%T +exec stap -o $format -we {probe begin {println("hello");exit()}} + +spawn ls -1 +set ok 0 +expect { + -re {%([0-9][0-9])_[0-9][0-9]:[0-9][0-9]:\1} {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (%S and %T)" +} else { + fail "$test (%S and %T)" +} + +# check except for %S and %T +set format %%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k,%l,%M,%R,%u,%w + +set date1 [exec date +$format] +# run stapio with strftime +exec stap -o $format -we {probe begin {println("hello");exit()}} +# check whether stap outputs stapio pid +set date2 [exec date +$format] + +spawn ls -1 +set ok 0 +expect { + $date1 {incr ok} + $date2 {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (except %S and %T)" +} else { + fail "$test (except %S and %T)" +} + +# cleanup +system "rm -f %*" diff --git a/testsuite/systemtap.base/system_func.stp b/testsuite/systemtap.base/system_func.stp index d14fb25b..6a6bb04a 100644 --- a/testsuite/systemtap.base/system_func.stp +++ b/testsuite/systemtap.base/system_func.stp @@ -4,10 +4,10 @@ global saw_echo, did_cat -probe kernel.function("sys_open") { +probe kernel.function("do_sys_open") { if (!saw_echo) { # very inefficient. Testing only. DO NOT DO THIS - msg="echo sys_open" + msg="echo do_sys_open" system(msg) saw_echo = 1 } diff --git a/testsuite/systemtap.base/tracepoints.exp b/testsuite/systemtap.base/tracepoints.exp index bea461c4..cd033908 100644 --- a/testsuite/systemtap.base/tracepoints.exp +++ b/testsuite/systemtap.base/tracepoints.exp @@ -1,3 +1,26 @@ + +set tracepoints {} +spawn stap -l {kernel.trace("*")} +expect { + -re {^kernel.trace[^\r\n]*\r\n} { + append tracepoints $expect_out(0,string) + exp_continue + } + timeout {} + eof {} +} +catch {close}; catch { wait } + +foreach tp $tracepoints { + set test "tracepoint $tp -p4" + if {[catch {exec stap -w -p4 -e "probe $tp {}"} res]} { + fail "$test $res" + } else { + pass "$test" + } +} + set test "tracepoints" +if {![installtest_p]} { untested $test; return } set ::result_string {tracepoints OK} stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp index 89250e7b..6344cbf0 100644 --- a/testsuite/systemtap.base/uprobes.exp +++ b/testsuite/systemtap.base/uprobes.exp @@ -18,14 +18,7 @@ if [file exists $path] then { pass "$test prep" } else { fail "$test prep" } catch {exec gcc -g -o jennie jennie.c} err if {$err == "" && [file exists jennie]} then { pass "$test compile" } else { fail "$test compile" } -# 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} { +if {![utrace_p]} { untested "$test -p4"; untested "$test -p5" catch {exec rm -f jennie.c jennie} return diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c new file mode 100644 index 00000000..b4811335 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_exe.c @@ -0,0 +1,29 @@ +/* uprobes_lib test case + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +#include <unistd.h> + +// function from our library +int lib_main (void); + +void +main_func (int foo) +{ + if (foo > 1) + main_func (foo - 1); + else + lib_main(); +} + +int +main (int argc, char *argv[], char *envp[]) +{ + main_func (3); + return 0; +} diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c new file mode 100644 index 00000000..25297b6b --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.c @@ -0,0 +1,21 @@ +/* uprobes_lib test case - library helper + * Copyright (C) 2009, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +void +lib_func (int bar) +{ + if (bar > 1) + lib_func (bar - 1); +} + +void +lib_main () +{ + lib_func (3); +} diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp new file mode 100644 index 00000000..313c01b6 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.exp @@ -0,0 +1,46 @@ +set test "uprobes_lib" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {main +main_func +main_func +main_func +lib_main +lib_func +lib_func +lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } +stap_run2 $srcdir/$subdir/$test.stp -c $testexe + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp new file mode 100644 index 00000000..459351a4 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_lib.stp @@ -0,0 +1,15 @@ +probe process("uprobes_exe").function("main") { + printf("main\n"); +} + +probe process("uprobes_exe").function("main_func") { + printf("main_func\n"); +} + +probe process("libuprobes_lib.so").function("lib_main") { + printf("lib_main\n"); +} + +probe process("libuprobes_lib.so").function("lib_func") { + printf("lib_func\n"); +} diff --git a/testsuite/systemtap.base/uprobes_uname.exp b/testsuite/systemtap.base/uprobes_uname.exp new file mode 100644 index 00000000..65e1ff70 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.exp @@ -0,0 +1,46 @@ +set test "uprobes_uname" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } +stap_run2 $srcdir/$subdir/$test.stp -c $testexe + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_uname.stp b/testsuite/systemtap.base/uprobes_uname.stp new file mode 100644 index 00000000..a44d78d3 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_uname.stp @@ -0,0 +1,7 @@ +probe process("uprobes_exe").function("*") { + printf("exe: %s=%s\n",probefunc(), usymname(uaddr())); +} + +probe process("libuprobes_lib.so").function("*") { + printf("lib: %s=%s\n",probefunc(), usymname(uaddr())); +} diff --git a/testsuite/systemtap.base/uprobes_ustack.exp b/testsuite/systemtap.base/uprobes_ustack.exp new file mode 100644 index 00000000..bfc435e9 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.exp @@ -0,0 +1,97 @@ +set test "uprobes_ustack" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } + +# Output is: +#print_ubacktrace exe 0 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack exe 1 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ubacktrace lib 2 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack lib 3 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2431 : lib_func+0x25/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] + +set print 0 +set main 0 +set main_func 0 +set lib_main 0 +set lib_func 0 +# Needs extra space since on 64bit the last ubacktrace string is +# 7 entries * (16 hex + 2 for 0x + 1 space) = 133 chars. +# Default MAXSTRINGLEN is 128 chars. +spawn stap -DMAXSTRINGLEN=133 $srcdir/$subdir/$test.stp -c $testexe + +wait +expect { + -timeout 60 + -re {^print_[^\r\n]+\r\n} {incr print; exp_continue} + -re {^ 0x[a-f0-9]+ : main\+0x[^\r\n]+\r\n} {incr main; exp_continue} + -re {^ 0x[a-f0-9]+ : main_func\+0x[^\r\n]+\r\n} {incr main_func; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_main\+0x[^\r\n]+\r\n} {incr lib_main; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_func\+0x[^\r\n]+\r\n} {incr lib_func; exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} + +if {$print == 4} {pass "$test print"} {fail "$test print ($print)"} +if {$main == 4} {pass "$test main"} {fail "$test main ($main)"} +if {$main_func == 9} {pass "$test main_func"} {fail "$test main_func ($main_func)"} +if {$lib_main == 2} {pass "$test lib_main"} {fail "$test lib_main ($lib_main)"} +if {$lib_func == 3} {pass "$test lib_func"} {fail "$test lib_func ($lib_func)"} + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_ustack.stp b/testsuite/systemtap.base/uprobes_ustack.stp new file mode 100644 index 00000000..6de03b42 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.stp @@ -0,0 +1,35 @@ +// Prints backtrace from lib through exe twice using diffent ustack functions. + +global hits = 0; + +probe process("uprobes_exe").function("main_func") +{ + if (hits == 0) + { + log("print_ubacktrace exe 0"); + print_ubacktrace(); + hits++; + } + else if (hits == 1) + { + log("print_ustack exe 1"); + print_ustack(ubacktrace()); + hits++; + } +} + +probe process("libuprobes_lib.so").function("lib_func") +{ + if (hits == 2) + { + log("print_ubacktrace lib 2"); + print_ubacktrace(); + hits++; + } + else if (hits == 3) + { + log("print_ustack lib 3"); + print_ustack(ubacktrace()); + hits++; + } +} diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp index 1467d9c8..8d323a8a 100644 --- a/testsuite/systemtap.base/utrace_p4.exp +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -7,8 +7,6 @@ # utrace doesn't exist in the kernel, marks the tests as 'untested'. # Initialize variables -set utrace_support_found 0 - set begin_script {"probe process(\"/bin/ls\").begin { print(\"ls begin\") }"} set end_script {"probe process(\"/bin/ls\").end { print(\"ls end\") }"} set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"} @@ -24,18 +22,12 @@ set pid_syscall_return_script {"probe process(123).syscall.return { printf(\"|%d set pid_thread_begin_script {"probe process(123).thread.begin { print(\"123 thread.begin\") }"} set pid_thread_end_script {"probe process(123).thread.end { print(\"123 thread.end\") }"} -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - # # Do some utrace compile tests. # set TEST_NAME "UTRACE_P4_01" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a begin script using a path @@ -43,7 +35,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_01_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a begin script using a pid @@ -51,7 +43,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_02" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a end script using a path @@ -59,7 +51,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_02_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a end script using a pid @@ -67,7 +59,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_03" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall script using a path @@ -75,7 +67,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_03_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall script using a pid @@ -83,7 +75,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_04" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall return script using a path @@ -91,7 +83,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_04_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling a syscall return script using a pid @@ -99,7 +91,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_05" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.begin script using a path @@ -107,7 +99,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_05_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.begin script using a pid @@ -115,7 +107,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_06" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.end script using a path @@ -123,7 +115,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_06_pid" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an thread.end script using a pid @@ -131,7 +123,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P4_07" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } else { # Try compiling an system-wide begin script diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp index 33281350..3d432dc3 100644 --- a/testsuite/systemtap.base/utrace_p5.exp +++ b/testsuite/systemtap.base/utrace_p5.exp @@ -1,7 +1,6 @@ # Utrace run (pass 5) tests. # Initialize variables -set utrace_support_found 0 set exepath "[pwd]/cat_[pid]" set multi_srcpath "$srcdir/systemtap.base/utrace_p5_multi.c" set multi_exepath "[pwd]/utrace_p5_multi_[pid]" @@ -90,12 +89,6 @@ set bz6841_script { } set bz6841_script_output ".+ issues syscall \\d+ times\r\n" -# Try to find utrace_attach symbol in /proc/kallsyms -set path "/proc/kallsyms" -if {! [catch {exec grep -q utrace_attach $path} dummy]} { - set utrace_support_found 1 -} - # Set up our own copy of /bin/cat, to make testing for a particular # executable easy. We can't use 'ln' here, since we might be creating # a cross-device link. We can't use 'ln -s' here, since the kernel @@ -138,7 +131,7 @@ proc run_utrace_p5_multi {} { } set TEST_NAME "UTRACE_P5_01" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -148,7 +141,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_02" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -158,7 +151,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_03" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -168,7 +161,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_04" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -178,7 +171,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_05" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -189,7 +182,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_06" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" @@ -200,7 +193,7 @@ if {$utrace_support_found == 0} { } set TEST_NAME "UTRACE_P5_07" -if {$utrace_support_found == 0} { +if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested "$TEST_NAME" diff --git a/testsuite/systemtap.base/utrace_syscall_args.c b/testsuite/systemtap.base/utrace_syscall_args.c new file mode 100644 index 00000000..2d3da838 --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.c @@ -0,0 +1,67 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/syscall.h> /* For SYS_xxx definitions */ + +int main() +{ + int fd, ret; + struct stat fs; + void *r; + int rc; + + /* create a file with something in it */ + fd = open("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600); + lseek(fd, 1024, SEEK_SET); + write(fd, "abcdef", 6); + close(fd); + + fd = open("foobar", O_RDONLY); + + /* stat for file size */ + ret = fstat(fd, &fs); + + /* mmap file file, then unmap it. */ + r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (r != MAP_FAILED) + munmap(r, fs.st_size); + close(fd); + + /* OK, try some system calls to see if we get the arguments + * correctly. */ +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffffffffffff, + (unsigned long)0xa5a5a5a5a5a5a5a5, + (unsigned long)0xf0f0f0f0f0f0f0f0, + (unsigned long)0x5a5a5a5a5a5a5a5a, + (unsigned long)0xe38e38e38e38e38e); +#else + rc = syscall (__NR_dup, (unsigned long)-12345, + (unsigned long)0xffffffff, + (unsigned long)0xa5a5a5a5, + (unsigned long)0xf0f0f0f0, + (unsigned long)0x5a5a5a5a, + (unsigned long)0xe38e38e3); +#endif +#if (__LONG_MAX__ > __INT_MAX__) + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c71c71c71, + (unsigned long)0x0f0f0f0f0f0f0f0f, + (unsigned long)0xdb6db6db6db6db6d, + (unsigned long)0x2492492492492492, + (unsigned long)0xad6b5ad6b5ad6b5a, + (unsigned long)0xdef7ddef7ddef7dd); +#else + rc = syscall ((unsigned long)-1, + (unsigned long)0x1c71c71c, + (unsigned long)0x0f0f0f0f, + (unsigned long)0xdb6db6db, + (unsigned long)0x24924924, + (unsigned long)0xad6b5ad6, + (unsigned long)0xdef7ddef); +#endif + return 0; +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.exp b/testsuite/systemtap.base/utrace_syscall_args.exp new file mode 100644 index 00000000..98bc457e --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.exp @@ -0,0 +1,82 @@ +# Utrace system call argument tests. + +set flags "" +set srcpath "$srcdir/$subdir/utrace_syscall_args.c" +set exepath "[pwd]/utrace_syscall_args" +set stppath "$srcdir/$subdir/utrace_syscall_args.stp" + +set output_string "mmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nmunmap\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nclose\\(\[0-9\]+\\)\\(0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\ndup\\(\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nbad_syscall\\(-?\[0-9\]+\\)\\(0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+, 0x\[0-9a-f]+\\) = 0x\[0-9a-f]+\r\nsystemtap test success\r\n" + +# For first pass, force 64-bit compilation for 64-bit systems. Add +# any other 64-bit architecture you want tested below. +# +# To find tcl's platform name for your machine, run the following: +# echo "puts $::tcl_platform(machine)" | tclsh + +switch -regexp $::tcl_platform(machine) { + ^ia64$ { + set do_64_bit_pass 1 + set flags "" + } + ^(x86_64|ppc64|s390x)$ { + set do_64_bit_pass 1 + set flags "additional_flags=-m64" + } + default { + set do_64_bit_pass 0 + } +} + +if {$do_64_bit_pass} { + set testname "64_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program. + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + # Run the test. + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} + +# The second pass is for systems that support 32-bit executables +# (either exclusively or in addition to 64-bit executables). +set do_32_bit_pass 1 +switch -regexp $::tcl_platform(machine) { + ^(x86_64|ppc64)$ { + set flags "additional_flags=-m32" + } + ^s390x$ { + set flags "additional_flags=-m31" + } + ^ia64$ { + set do_32_bit_pass 0 + } +} + +if {$do_32_bit_pass} { + set testname "32_BIT_UTRACE_SYSCALL_ARGS" + if {![installtest_p]} { untested $testname; continue } + if {![utrace_p]} { untested $testname; continue } + send_log "Testing ${testname}\n" + + # Compile our test program + set res [target_compile $srcpath $exepath executable $flags] + if { $res != "" } { + verbose "target_compile for $exepath failed: $res" 2 + fail "$testname: unable to compile $srcpath" + return + } + + stap_run $testname no_load $output_string -g $stppath -c $exepath + + catch {exec rm -f $exepath foobar} +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp new file mode 100644 index 00000000..6c9e14fc --- /dev/null +++ b/testsuite/systemtap.base/utrace_syscall_args.stp @@ -0,0 +1,406 @@ +%{ +#include "syscall.h" +%} + +function mmap_syscall_no:long () %{ + THIS->__retvalue = MMAP_SYSCALL_NO(current); /* pure */ +%} +function mmap2_syscall_no:long () %{ + THIS->__retvalue = MMAP2_SYSCALL_NO(current); /* pure */ +%} +function munmap_syscall_no:long () %{ + THIS->__retvalue = MUNMAP_SYSCALL_NO(current); /* pure */ +%} + +global syscalls_seen = 0 +global failures = 0 + +global mmap_found = 0 +global mmap_args[10] + +global munmap_found = 0 +global munmap_args[10] + +global close_found = 0 +global close_args[10] + +global dup_found = 0 +global dup_args[10] + +global bad_syscall_found = 0 +global bad_syscall_args[10] + +probe begin +{ + printf("systemtap starting probe\n") +} + +probe syscall.open { + if (filename == "foobar") { + syscalls_seen += 1 + } +} + +probe process("utrace_syscall_args").syscall { + if (syscalls_seen >= 2) { + syscalls_seen += 1 + + # We skip the fstat() syscall, which is the 1st syscall after + # the open() by not looking at 'syscalls_seen == 3'. + + if (syscalls_seen == 4 && ($syscall == mmap_syscall_no() + || $syscall == mmap2_syscall_no())) { + mmap_found = 1 + mmap_args[0] = $syscall + mmap_args[1] = $arg1 + mmap_args[2] = $arg2 + mmap_args[3] = $arg3 + mmap_args[4] = $arg4 + mmap_args[5] = $arg5 + mmap_args[6] = $arg6 + +%(arch == "s390x" %? + # s390 requires this for mmap. Verified by running: + # # strace strace utrace_syscall_args + addr = mmap_args[1] + mmap_args[1] = user_long(addr) + addr += 8 + mmap_args[2] = user_long(addr) + addr += 8 + mmap_args[3] = user_long(addr) + addr += 8 + mmap_args[4] = user_long(addr) + addr += 8 + mmap_args[5] = user_long(addr) + addr += 8 + mmap_args[6] = user_long(addr) +%) + } + else if (syscalls_seen == 5 && $syscall == munmap_syscall_no()) { + munmap_found = 1 + munmap_args[0] = $syscall + munmap_args[1] = $arg1 + munmap_args[2] = $arg2 + } + else if (syscalls_seen == 6) { + close_found = 1 + close_args[0] = $syscall + close_args[1] = $arg1 + } + else if (syscalls_seen == 7) { + dup_found = 1 + dup_args[0] = $syscall + dup_args[1] = $arg1 + dup_args[2] = $arg2 + dup_args[3] = $arg3 + dup_args[4] = $arg4 + dup_args[5] = $arg5 + dup_args[6] = $arg6 + } + else if (syscalls_seen == 8) { + bad_syscall_found = 1 + bad_syscall_args[0] = $syscall + bad_syscall_args[1] = $arg1 + bad_syscall_args[2] = $arg2 + bad_syscall_args[3] = $arg3 + bad_syscall_args[4] = $arg4 + bad_syscall_args[5] = $arg5 + bad_syscall_args[6] = $arg6 + } + } +} +probe process("utrace_syscall_args").syscall.return { + if (syscalls_seen >= 4) { + if (syscalls_seen == 4) { + mmap_args[7] = $return + mmap_args[8] = $syscall + } + else if (syscalls_seen == 5) { + munmap_args[3] = $return + munmap_args[4] = $syscall + } + else if (syscalls_seen == 6) { + close_args[2] = $return + close_args[3] = $syscall + } + else if (syscalls_seen == 7) { + dup_args[7] = $return + dup_args[8] = $syscall + } + else if (syscalls_seen == 8) { + bad_syscall_args[7] = $return + bad_syscall_args[8] = $syscall + syscalls_seen = 0 + } + } +} + +probe end +{ + printf("systemtap ending probe\n") + + # print mmap info + if (mmap_found == 0) { + printf("error: no mmap system call found\n") + failures += 1 + } + else { + printf("mmap(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + mmap_args[0], mmap_args[1], mmap_args[2], mmap_args[3], + mmap_args[4], mmap_args[5], mmap_args[6], mmap_args[7]) + + # Validate arguments. We can only check certain arguments. + # It is possible that mmap's 'prot' and 'flags' arguments + # could vary per platform, so we'll ignore them. + if (mmap_args[1] != 0) { + failures += 1 + printf("mmap bad arg 1: 0x%x vs 0x0\n", mmap_args[1]) + } + if (mmap_args[2] != 0x406) { + failures += 1 + printf("mmap bad arg 2: 0x%x vs 0x406\n", mmap_args[2]) + } + if (mmap_args[6] != 0) { + failures += 1 + printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6]) + } + + # Validate syscall number + if (mmap_args[0] != mmap_args[8]) { + failures += 1 + printf("mmap $syscall mismatch: %d vs. %d\n", + mmap_args[0], mmap_args[8]) + } + } + + # print munmap info + if (munmap_found == 0) { + printf("error: no munmap system call found\n") + failures += 1 + } + else if (munmap_found == 0 || mmap_found == 0) { + printf("error: no munmap/mmap system call found\n") + failures += 1 + } + else { + printf("munmap(%d)(0x%x, 0x%x) = 0x%x\n", + munmap_args[0], munmap_args[1], munmap_args[2], munmap_args[3]) + + # Validate arguments. munmap()'s first argument should be the + # same as the mmap() return value. + if (munmap_args[1] != mmap_args[7]) { + failures += 1 + printf("munmap bad arg 1: 0x%x vs 0x%x\n", munmap_args[1], + mmap_args[7]) + } + if (munmap_args[2] != mmap_args[2]) { + failures += 1 + printf("munmap bad arg 2: 0x%x vs 0x%x\n", munmap_args[2], + mmap_args[2]) + } + # Validate return value + if (munmap_args[7] != 0) { + failures += 1 + printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7]) + } + + # Validate syscall number + if (munmap_args[0] != munmap_args[4]) { + failures += 1 + printf("munmap $syscall mismatch: %d vs. %d\n", + munmap_args[0], munmap_args[4]) + } + } + + # print close info + if (close_found == 0) { + printf("error: no close system call found\n") + failures += 1 + } + else if (close_found == 1) { + printf("close(%d)(0x%x) = 0x%x\n", + close_args[0], close_args[1], close_args[2]) + + if (mmap_args[5] != close_args[1]) { + failures += 1 + printf("close bad arg 1: 0x%x vs 0x%x\n", + close_args[0], mmap_args[5]) + } + + # Validate syscall number + if (close_args[0] != close_args[3]) { + failures += 1 + printf("close $syscall mismatch: %d vs. %d\n", + close_args[0], close_args[3]) + } + } + + # print dup info + if (dup_found == 0) { + printf("error: no dup system call found\n") + failures += 1 + } + else { + printf("dup(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + dup_args[0], dup_args[1], dup_args[2], dup_args[3], + dup_args[4], dup_args[5], dup_args[6], dup_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if ((dup_args[1] & 0xffffffff00000000) != 0) { + if (dup_args[1] != 0xffffffffffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffffffffffcfc7\n", + dup_args[1]) + } + if (dup_args[2] != 0xffffffffffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffffffffffff\n", + dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5a5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5a5a5a5a5\n", + dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0f0f0f0f0) { + failures += 1 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0f0f0f0f0\n", + dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a5a5a5a5a\n", + dup_args[5]) + } + if (dup_args[6] != 0xe38e38e38e38e38e) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e38e38d38e\n", + dup_args[6]) + } + } + else { + if (dup_args[1] != 0xffffcfc7) { + failures += 1 + printf("dup bad arg 1: 0x%x vs 0xffffcfc7\n", dup_args[1]) + } + if (dup_args[2] != 0xffffffff) { + failures += 1 + printf("dup bad arg 2: 0x%x vs 0xffffffff\n", dup_args[2]) + } + if (dup_args[3] != 0xa5a5a5a5) { + failures += 1 + printf("dup bad arg 3: 0x%x vs 0xa5a5a5a5\n", dup_args[3]) + } + if (dup_args[4] != 0xf0f0f0f0) { + failures += 4 + printf("dup bad arg 4: 0x%x vs 0xf0f0f0f0\n", dup_args[4]) + } + if (dup_args[5] != 0x5a5a5a5a) { + failures += 1 + printf("dup bad arg 5: 0x%x vs 0x5a5a5a5a\n", dup_args[5]) + } + if (dup_args[6] != 0xe38e38e3) { + failures += 1 + printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6]) + } + } + + # Validate syscall number + if (dup_args[0] != dup_args[8]) { + failures += 1 + printf("dup $syscall mismatch: %d vs. %d\n", + dup_args[0], dup_args[8]) + } + } + + # print bad_syscall info + if (bad_syscall_found == 0) { + printf("error: no bad_syscall system call found\n") + failures += 1 + } + else { + printf("bad_syscall(%d)(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) = 0x%x\n", + bad_syscall_args[0], bad_syscall_args[1], bad_syscall_args[2], bad_syscall_args[3], + bad_syscall_args[4], bad_syscall_args[5], bad_syscall_args[6], bad_syscall_args[7]) + + # Validate arguments - handle 32-bit vs. 64-bit. + if (bad_syscall_args[1] > 0xffffffff) { + if (bad_syscall_args[1] != 0x1c71c71c71c71c71) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c71c71c71\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db6db6db6d) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db6db6db6d\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x2492492492492492) { + failures += 1 + printf("bad_syscall bad arg 4: 0x%x vs 0x2492492492492492\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6b5ad6b5a) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6b5ad6b5a\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef7ddef7dd) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef7ddef7dd\n", + bad_syscall_args[6]) + } + } + else { + if (bad_syscall_args[1] != 0x1c71c71c) { + failures += 1 + printf("bad_syscall bad arg 1: 0x%x vs 0x1c71c71c\n", + bad_syscall_args[1]) + } + if (bad_syscall_args[2] != 0x0f0f0f0f) { + failures += 1 + printf("bad_syscall bad arg 2: 0x%x vs 0x0f0f0f0f\n", + bad_syscall_args[2]) + } + if (bad_syscall_args[3] != 0xdb6db6db) { + failures += 1 + printf("bad_syscall bad arg 3: 0x%x vs 0xdb6db6db\n", + bad_syscall_args[3]) + } + if (bad_syscall_args[4] != 0x24924924) { + failures += 4 + printf("bad_syscall bad arg 4: 0x%x vs 0x24924924\n", + bad_syscall_args[4]) + } + if (bad_syscall_args[5] != 0xad6b5ad6) { + failures += 1 + printf("bad_syscall bad arg 5: 0x%x vs 0xad6b5ad6\n", + bad_syscall_args[5]) + } + if (bad_syscall_args[6] != 0xdef7ddef) { + failures += 1 + printf("bad_syscall bad arg 6: 0x%x vs 0xdef7ddef\n", + bad_syscall_args[6]) + } + } + + # Validate syscall number + if (bad_syscall_args[0] != bad_syscall_args[8]) { + failures += 1 + printf("bad_syscall $syscall mismatch: %d vs. %d\n", + bad_syscall_args[0], bad_syscall_args[8]) + } + } + + if (failures == 0) { + printf("systemtap test success\n") + } + else { + printf("systemtap test failure\n") + } +} diff --git a/testsuite/systemtap.base/x86_gs.exp b/testsuite/systemtap.base/x86_gs.exp new file mode 100644 index 00000000..98ab3051 --- /dev/null +++ b/testsuite/systemtap.base/x86_gs.exp @@ -0,0 +1,12 @@ +set test "x86_gs" +if {![installtest_p]} { untested $test; return } +set arch [exec uname -m] +if {$arch!="i686"} { untested $test; return } +spawn stap $srcdir/$subdir/x86_gs.stp +expect { + -timeout 60 + -re "0\r\n" { pass $test } + -re "140\r\n" { pass $test } + eof { fail $test } + timeout { fail "$test unexpected timeout" } +} diff --git a/testsuite/systemtap.base/x86_gs.stp b/testsuite/systemtap.base/x86_gs.stp new file mode 100644 index 00000000..68b58512 --- /dev/null +++ b/testsuite/systemtap.base/x86_gs.stp @@ -0,0 +1,10 @@ +#! stap + +# test x86 gs register + +probe begin { + if (!_stp_regs_registered) + _stp_register_regs() + printf("%d\n",test_x86_gs() * 100 + _reg_offsets["gs"]) /* 0 or 140 */ + exit() +} diff --git a/testsuite/systemtap.context/args.tcl b/testsuite/systemtap.context/args.tcl index 7cb79cdf..cffaeaef 100644 --- a/testsuite/systemtap.context/args.tcl +++ b/testsuite/systemtap.context/args.tcl @@ -1,6 +1,6 @@ spawn stap $srcdir/$subdir/args.stp expect { - -timeout 240 + -timeout 60 "READY" { exec echo 1 > /proc/stap_test_cmd expect { diff --git a/testsuite/systemtap.context/backtrace.tcl b/testsuite/systemtap.context/backtrace.tcl index ca60c369..975e6c4d 100644 --- a/testsuite/systemtap.context/backtrace.tcl +++ b/testsuite/systemtap.context/backtrace.tcl @@ -5,10 +5,11 @@ set m4 0 set m5 0 set m6 0 +#spawn stap -d kernel -d systemtap_test_module1 -DMAXSTRINGLEN=256 $srcdir/$subdir/backtrace.stp spawn stap -DMAXSTRINGLEN=256 $srcdir/$subdir/backtrace.stp #exp_internal 1 expect { - -timeout 240 + -timeout 60 "Systemtap probe: begin\r\n" { pass "backtrace of begin probe" exec echo 0 > /proc/stap_test_cmd diff --git a/testsuite/systemtap.context/context.exp b/testsuite/systemtap.context/context.exp index 010db445..52bf260d 100644 --- a/testsuite/systemtap.context/context.exp +++ b/testsuite/systemtap.context/context.exp @@ -23,7 +23,7 @@ proc build_modules {} { global build_dir global srcdir subdir - if {[catch {exec mktemp -d staptestXXXXX} build_dir]} { + if {[catch {exec mktemp -d staptestXXXXXX} build_dir]} { puts stderr "Failed to create temporary directory: $build_dir" return 0 } @@ -80,6 +80,7 @@ if {[build_modules] == 0} { } foreach test $testlist { + send_log "sourcing: $srcdir/$subdir/$test.tcl\n" source $srcdir/$subdir/$test.tcl } diff --git a/testsuite/systemtap.context/num_args.tcl b/testsuite/systemtap.context/num_args.tcl index 7d12b433..62ac8dd3 100644 --- a/testsuite/systemtap.context/num_args.tcl +++ b/testsuite/systemtap.context/num_args.tcl @@ -3,7 +3,7 @@ foreach arglist $arglists { set tag [concat numeric $arglist] eval spawn stap $arglist $srcdir/$subdir/num_args.stp expect { - -timeout 240 + -timeout 60 "READY" { exec echo 1 > /proc/stap_test_cmd expect { diff --git a/testsuite/systemtap.context/pid.tcl b/testsuite/systemtap.context/pid.tcl index a2c091f1..70a87345 100644 --- a/testsuite/systemtap.context/pid.tcl +++ b/testsuite/systemtap.context/pid.tcl @@ -2,7 +2,7 @@ set tests [list execname pexecname pid ppid tid uid euid gid egid] spawn stap $srcdir/$subdir/pid.stp #exp_internal 1 expect { - -timeout 240 + -timeout 60 "READY" { set pid [exec echo 1 > /proc/stap_test_cmd &] set ppid {[0-9]*} diff --git a/testsuite/systemtap.context/usymbols.c b/testsuite/systemtap.context/usymbols.c new file mode 100644 index 00000000..7c590724 --- /dev/null +++ b/testsuite/systemtap.context/usymbols.c @@ -0,0 +1,39 @@ +/* usymbol test case + * Copyright (C) 2008, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + * + * Uses signal to tranfer user space addresses into the kernel where a + * probe on sigaction will extract them and produce the symbols. To + * poke into the executable we get the sa_handler from the main executable, + * and then the library through calling signal. + * + * FIXME. We call into the library to get the right symbol. If we + * register the handler from the main executable. We need to handle + * @plt symbols (setting a handler in the main executable that is in a + * shared library will have the @plt address, not the address inside + * the shared library). + */ + +#include <signal.h> +typedef void (*sighandler_t)(int); + +// function from our library +int lib_main (void); + +void +main_handler (int signum) +{ + /* dummy handler, just used for the address... */ +} + +int +main (int argc, char *argv[], char *envp[]) +{ + // Use SIGFPE since we never expect that to be triggered. + signal(SIGFPE, main_handler); + lib_main(); +} diff --git a/testsuite/systemtap.context/usymbols.exp b/testsuite/systemtap.context/usymbols.exp new file mode 100644 index 00000000..39b3b442 --- /dev/null +++ b/testsuite/systemtap.context/usymbols.exp @@ -0,0 +1,82 @@ +set test "./usymbols" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/usymbols.c" +set testsrclib "$testpath/usymbols_lib.c" +set testexe "[pwd]/usymbols" +set testlibname "usymbols" +set testlibdir "[pwd]" +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Only run on make installcheck and utrace present. +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested "$test"; return } + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "unable to compile $testsrclib" + return +} +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "unable to compile $testsrc" + return +} + +# We need the execname() trick to work around (the workaround of) PR6964 +# otherwise we get also the rt_sigactions of stapio. Get the handler +# (comes from the executable or the library). +set testscript { + probe syscall.rt_sigaction { + if (pid() == target() && execname() == "%s") { + handler = $act->sa_handler; + printf("handler: %%s\n", usymname(handler)); + } + } + /* track through uprobes, so as to make sure we have the symbols */ + probe process("%s").function("*") { printf(""); } +} + +set output {handler: main_handler +handler: lib_handler} + +# Got to run stap with both the exe and the libraries used as -d args. +# XXX Note how we need the fully resolved (absolute) path... +set script [format $testscript usymbols $testexe] +catch {eval exec [concat ldd $testexe | grep $testlibname]} libpath +set libpath [lindex [split $libpath " "] 2] +send_log "libpath: $libpath\n" +if {[string equal "link" [file type $libpath]]} { + set libpath [file join [file dirname $libpath] [file readlink $libpath]] +} +send_log "libpath: $libpath\n" + +set cmd [concat stap -d $libpath -d $testexe -c $testexe -e {$script}] +send_log "cmd: $cmd\n" +catch {eval exec $cmd} res +send_log "cmd output: $res\n" + +set n 0 +set m [llength [split $output "\n"]] +set expected [split $output "\n"] +foreach line [split $res "\n"] { + if {![string equal $line [lindex $expected $n]]} { + fail usymbols + send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\", " + send_log "Got \"$line\"\n" + return + } + incr n +} +if { $n != $m } { + fail usymbols + send_log "Got \"$n\" lines, expected \"$m\" lines\n" +} else { + pass usymbols +} +exec rm -f $testexe $testso diff --git a/testsuite/systemtap.context/usymbols_lib.c b/testsuite/systemtap.context/usymbols_lib.c new file mode 100644 index 00000000..faccb39b --- /dev/null +++ b/testsuite/systemtap.context/usymbols_lib.c @@ -0,0 +1,29 @@ +/* usymbol test case - library helper + * Copyright (C) 2008, Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + * + * Uses signal to tranfer user space addresses into the kernel where a + * probe on sigaction will extract them and produce the symbols. To + * poke into the executable we get the sa_handler set through signal + * from this library. + */ + +#include <signal.h> +typedef void (*sighandler_t)(int); + +void +lib_handler (int signum) +{ + /* dummy handler, just used for the address... */ +} + +void +lib_main () +{ + // Use SIGFPE since we never expect that to be triggered. + signal(SIGFPE, lib_handler); +} diff --git a/testsuite/systemtap.examples/README b/testsuite/systemtap.examples/README index e505bdfb..89586ece 100644 --- a/testsuite/systemtap.examples/README +++ b/testsuite/systemtap.examples/README @@ -1,57 +1,105 @@ -This directory contains example scripts. +This text describes contribution procedures for adding scripts to +systemtap.examples directory. Please read before submitting SystemTap +examples. Discussions take place on the +<systemtap@sources.redhat.com> mailing list. -Each script should be checked in as executable. +- general -The first line should be -#! /usr/bin/env stap + The script should do something that normal users of SystemTap might + like to do, such as show which processes have system calls that time + out or show which memory accesses cause page faults. Scripts that + check that some aspect of SystemTap operates correctly, but would + never be used by a regular user should go in one of the other + testsuite directories. -There should be an accompanying ".meta" file describing what the -script does and how to use it, and how the testsuite should compile -and run it. The meta files are also used to create a txt and html -index (by keyword and subsystem) of all the examples by the -examples-index-gen.pl script. +- copyright -The meta file contains the following elements. Each element (key and -value) are on one line. If a key can have a list of values, the list -elements are separated by spaces. + You must designate the appropriate copyright holder for your + contribution. The copyright holder is assumed to agree with the + general licensing terms (GPLv2+). + +- coding style -title: Descriptive title for the script (required) -name: the file name for the script, e.g. iotime.stp (required) -version: versioning if any fixes and developed can be identified (required) -author: name of author(s), "anonymous" if unknown (required) -exclusivearch: Stated if the script can only run on some arches + Abide by the general formatting of the code for SystemTap. The + code base generally follows the GNU standards in usermode code and + the Linux kernel standards in runtime code. + + - Try to keep the lines shorter than 80 characters long. + - Make use of SystemTap functions to factor out common idioms in code. + - Use tapset probe points rather than raw function names. + - No probes by file and line number are allowed in examples. + - Avoid using guru mode (-g) in the examples. + - Minimize use of globals variables: + All associative arrays must be global in SystemTap. + Variables used only for the duration of a probe should be local. + - Make the file executable and use the following line at the + beginning of the script to select the proper interpreter: + + #! /usr/bin/env stap + +- Describe the example + + Each example script has a description in a .meta file that provide + an easy-to-parse format that describes various aspect of the example + script. The .meta file has the same base name as the example script. + The .meta file is parsed to generate a web page listing all the + available examples; the webpage is available at: + http://sourceware.org/systemtap/examples/. The .meta file also + describes how to run the compiled example script for testing. This + ensures that the example is frequently run to verified it works on a + wide range fo platforms. + + The meta file contains the following elements. Each element (key and + value) are on one line. If a key can have a list of values, the list + elements are separated by spaces. + + title: Descriptive title for the script (required) + name: the file name for the script, e.g. iotime.stp (required) + version: versioning if any fixes and developed can be identified (required) + author: name of author(s), "anonymous" if unknown (required) + exclusivearch: Stated if the script can only run on some arches this concept borrowed from rpm, matches types for rpm: x86 i386 x86_64 ppc ppc64, s390 (optional) -requires: Some scripts may require software to be available. In some cases - may need version numbering, e.g. kernel >= 2.6 - Can have multiple "requires:" tags. (optional) -keywords: List of likely words to categorize the script (required) - keywords are separated by spaces. - #FIXME have list of keyword -subsystem: List what part of the kernel the instrumentation probes (required) - audit cpu blockio file filesystem locking memory numa network - process scheduler or user-space (probes are in the user-space) -application: when user-space probing becomes available (optional) - a script might probe a particular application - this tag indicates the applicaton -status: describes the state of development for the script (required) - proposed just an idea - experimental an implemented idea, but use at own risk - alpha - beta - production should be safe to use -exit: how long do the script run? (required) - fixed exits in a fixed amount of time - user-controlled exits with "cntrl-c" - event-ended exits with some arbitrary event -output: what kind of output does the script generate? (required) - trace histogram graph sorted batch timed -scope: How much of the processes on the machine does the script watch? - system-wide or pid -arg_[0-9]+: Describe what the arguments into the script are. (optional) -description: A text description what the script does. (required) -test_check: How to check that the example compiles. - (e.g. stap -p4 iotime.stp) -test_installcheck: How to check that the example runs. - (e.g. stap iotime.stp -c "sleep 1") + requires: Some scripts may require software to be available. In some cases + may need version numbering, e.g. kernel >= 2.6 + Can have multiple "requires:" tags. (optional) + keywords: List of likely words to categorize the script (required) + keywords are separated by spaces. + #FIXME have list of keyword + subsystem: List what part of the kernel the instrumentation probes (required) + audit cpu blockio file filesystem locking memory numa network + process scheduler or user-space (probes are in the user-space) + application: when user-space probing becomes available (optional) + a script might probe a particular application + this tag indicates the applicaton + status: describes the state of development for the script (required) + proposed just an idea + experimental an implemented idea, but use at own risk + alpha + beta + production should be safe to use + exit: how long do the script run? (required) + fixed exits in a fixed amount of time + user-controlled exits with "cntrl-c" + event-ended exits with some arbitrary event + output: what kind of output does the script generate? (required) + trace histogram graph sorted batch timed + scope: How much of the processes on the machine does the script watch? + system-wide or pid + arg_[0-9]+: Describe what the arguments into the script are. (optional) + description: A text description what the script does. (required) + test_check: How to check that the example compiles. + (e.g. stap -p4 iotime.stp) + test_installcheck: How to check that the example runs. + (e.g. stap iotime.stp -c "sleep 1") + + +- Review, revision, and submission of the example script + + When you have a SystemTap script that should be included as an + example, submit it to the SystemTap mailing list, + systemtap@sources.redhat.com for review. Even if the script is not + ready for submission as an example, feel free to ask questions or + discuss the work-in-progress script with other people working with + SystemTap. diff --git a/testsuite/systemtap.examples/general/ansi_colors.meta b/testsuite/systemtap.examples/general/ansi_colors.meta new file mode 100644 index 00000000..2818c235 --- /dev/null +++ b/testsuite/systemtap.examples/general/ansi_colors.meta @@ -0,0 +1,13 @@ +title: Color Table for ansi_set_color2() and ansi_set_color3() +name: ansi_colors.stp +version: 1.0 +author: Eugene Teo +keywords: format +subsystem: none +status: production +exit: fixed +output: text +scope: system-wide +description: The script prints a table showing the available color combinations for the ansi_set_color2() and ans_set_color3() functions in the ansi.stp tapset. +test_check: stap -p4 ansi_colors.stp +test_installcheck: stap ansi_colors.stp diff --git a/testsuite/systemtap.examples/general/ansi_colors.stp b/testsuite/systemtap.examples/general/ansi_colors.stp index ae954e69..01e58b9c 100755 --- a/testsuite/systemtap.examples/general/ansi_colors.stp +++ b/testsuite/systemtap.examples/general/ansi_colors.stp @@ -1,21 +1,30 @@ -#! /usr/bin/env stap +#!/usr/bin/env stap +# ansi_colors.stp +# Copyright (C) 2006-2009 Red Hat, Inc., Eugene Teo <eteo@redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# probe begin { - printf("a \\ b |"); - for (c = 40; c < 48; c++) - printf(" %d ", c); - printf("\12"); - for (l = 0; l < 71; l++) - printf("-"); - printf("\12"); + printf("fg,t \\ bg |"); + for (c = 40; c < 48; c++) + printf(" %d ", c); + ansi_new_line() + for (l = 0; l < 75; l++) + printf("-"); + ansi_new_line() - for (r = 30; r < 38; r++) - for (t = 0; t < 2; t++) { - printf("%d |", r); - for (c = 40; c < 48; c++) - printf("\033[%d;%d%s %s \033[0;0m", - r, c, !t ? "m" : ";1m", !t ? "Normal" : "Bold "); - printf("\12"); - } - exit(); + for (r = 30; r < 38; r++) + for (t = 0; t < 2; t++) { + printf(" %2d,%1d |", r, t); + for (c = 40; c < 48; c++) { + ansi_set_color3(r, c, t) + printf(" %s ", !t ? "Normal" : "Bold ") + ansi_reset_color() + } + ansi_new_line() + } + exit(); } diff --git a/testsuite/systemtap.examples/general/ansi_colors2.meta b/testsuite/systemtap.examples/general/ansi_colors2.meta new file mode 100644 index 00000000..4ccaf4e3 --- /dev/null +++ b/testsuite/systemtap.examples/general/ansi_colors2.meta @@ -0,0 +1,13 @@ +title: Show Attribues in Table for ansi_set_color3() +name: ansi_colors2.stp +version: 1.0 +author: Eugene Teo +keywords: format +subsystem: none +status: production +exit: fixed +output: text +scope: system-wide +description: The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color3() function in the ansi.stp tapset. +test_check: stap -p4 ansi_colors2.stp +test_installcheck: stap ansi_colors2.stp diff --git a/testsuite/systemtap.examples/general/ansi_colors2.stp b/testsuite/systemtap.examples/general/ansi_colors2.stp new file mode 100755 index 00000000..fadcf011 --- /dev/null +++ b/testsuite/systemtap.examples/general/ansi_colors2.stp @@ -0,0 +1,31 @@ +#!/usr/bin/env stap +# ansi_colors2.stp +# Copyright (C) 2009 Red Hat, Inc., Eugene Teo <eteo@redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# + +probe begin { + printf("fg,t \\ bg |"); + for (c = 40; c < 48; c++) + printf(" %d ", c); + ansi_new_line() + for (l = 0; l < 75; l++) + printf("-"); + ansi_new_line() + + for (r = 30; r < 38; r++) + # this displays more attributes + for (t = 0; t < 8; !t ? ++t : t+=3) { + printf(" %2d,%1d |", r, t); + for (c = 40; c < 48; c++) { + ansi_set_color3(r, c, t) + printf(" Colors ") + ansi_reset_color() + } + ansi_new_line() + } + exit(); +} diff --git a/testsuite/systemtap.examples/general/grapher.stp b/testsuite/systemtap.examples/general/grapher.stp new file mode 100644 index 00000000..4f326ec1 --- /dev/null +++ b/testsuite/systemtap.examples/general/grapher.stp @@ -0,0 +1,32 @@ +#! /usr/bin/stap + +probe begin +{ +printf ("%%Title:CPU utilization\n"); +printf ("%%XAxisTitle:Time"); +printf ("%%YAxisTitle:Percent"); +printf ("%%DataSet:cpu 100 00ff00 bar"); +printf ("%%DataSet:kbd 100 ff0000 dot"); +} + +# CPU utilization +probe begin { qnames["cpu"] ++; qsq_start ("cpu") } +probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }} +probe scheduler.cpu_off { if (!idle) qs_done ("cpu") } + +global qnames + +function qsq_util_reset(q) { + u=qsq_utilization (q, 100) + qsq_start (q) + return u +} + +probe timer.ms(100) { # collect utilization percentages frequently + foreach (q in qnames) + printf("cpu %d %d\n", gettimeofday_ms(), qsq_util_reset(q)) +} + +probe kernel.function("kbd_event") { + printf("kbd %d %d\n", gettimeofday_ms(), 75) +} diff --git a/testsuite/systemtap.examples/general/para-callgraph.meta b/testsuite/systemtap.examples/general/para-callgraph.meta index 87af07cf..84d1c93f 100644 --- a/testsuite/systemtap.examples/general/para-callgraph.meta +++ b/testsuite/systemtap.examples/general/para-callgraph.meta @@ -3,5 +3,5 @@ name: para-callgraph.stp keywords: trace callgraph subsystem: general description: Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger. -test_check: stap -p4 para-callgraph.stp kernel.function("*@fs/proc*.c") kernel.function("sys_read") -test_installcheck: stap para-callgraph.stp kernel.function("*@fs/proc*.c") kernel.function("sys_read") -c "cat /proc/sys/vm/*" +test_check: stap -p4 para-callgraph.stp kernel.function("*@fs/proc*.c") kernel.function("vfs_read") +test_installcheck: stap para-callgraph.stp kernel.function("*@fs/proc*.c") kernel.function("vfs_read") -c "cat /proc/sys/vm/*" diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 7b76baa1..0df681ac 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -40,6 +40,12 @@ <h2>All Examples</h2> <ul> +<li><a href="general/ansi_colors.stp">general/ansi_colors.stp</a> - Color Table for ansi_set_color2() and ansi_set_color3()<br> +keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> +<p>The script prints a table showing the available color combinations for the ansi_set_color2() and ans_set_color3() functions in the ansi.stp tapset.</p></li> +<li><a href="general/ansi_colors2.stp">general/ansi_colors2.stp</a> - Show Attribues in Table for ansi_set_color3()<br> +keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> +<p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color3() function in the ansi.stp tapset.</p></li> <li><a href="general/graphs.stp">general/graphs.stp</a> - Graphing Disk and CPU Utilization<br> keywords: <a href="keyword-index.html#DISK">DISK</a> <a href="keyword-index.html#CPU">CPU</a> <a href="keyword-index.html#USE">USE</a> <a href="keyword-index.html#GRAPH">GRAPH</a> <br> <p>The script tracks the disk and CPU utilization. The resulting output of the script can be piped into gnuplot to generate a graph of disk and CPU USE.</p></li> @@ -58,6 +64,9 @@ keywords: <a href="keyword-index.html#DISK">DISK</a> <br> <li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br> keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br> <p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li> +<li><a href="io/ioblktime.stp">io/ioblktime.stp</a> - Average Time Block IO Requests Spend in Queue <br> +keywords: <a href="keyword-index.html#IO">IO</a> <br> +<p>The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script computes the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.</p></li> <li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br> keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li> @@ -79,6 +88,9 @@ keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> <li><a href="memory/pfaults.stp">memory/pfaults.stp</a> - Generate Log of Major and Minor Page Faults<br> keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> <p>The pfaults.stp script generates a simple log for each major and minor page fault that occurs on the system. Each line contains a timestamp (in microseconds) when the page fault servicing was completed, the pid of the process, the address of the page fault, the type of access (read or write), the type of fault (major or minor), and the elapsed time for page fault. This log can be examined to determine where the page faults are occuring.</p></li> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> <li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br> keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <br> <p>Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.</p></li> @@ -88,6 +100,12 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde <li><a href="network/tcp_connections.stp">network/tcp_connections.stp</a> - Track Creation of Incoming TCP Connections<br> keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <br> <p>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.</p></li> +<li><a href="network/tcpdumplike.stp">network/tcpdumplike.stp</a> - Dump of Received TCP Packets<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <br> +<p>The tcpdumplike.stp prints out a line for each TCP packet received. Each line includes the source and destination IP addresses, the source and destination ports, and flags.</p></li> +<li><a href="process/errsnoop.stp">process/errsnoop.stp</a> - tabulate system call errors<br> +keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <br> +<p>The script prints a periodic tabular report about failing system calls, by process and by syscall failure. The first optional argument specifies the reporting interval (in seconds, default 5); the second optional argument gives a screen height (number of lines in the report, default 20).</p></li> <li><a href="process/futexes.stp">process/futexes.stp</a> - System-Wide Futex Contention<br> keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#LOCKING">LOCKING</a> <a href="keyword-index.html#FUTEX">FUTEX</a> <br> <p>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.</p></li> @@ -103,7 +121,7 @@ keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <li><a href="process/sigkill.stp">process/sigkill.stp</a> - Track SIGKILL Signals<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.</p></li> -<li><a href="process/syscalls_by_pid.stp">process/syscalls_by_pid.stp</a> - System-Wide Count of Syscalls by PID<br> +<li><a href="process/sigmon.stp">process/sigmon.stp</a> - Track a particular signal to a specific process<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.</p></li> <li><a href="process/sleepingBeauties.stp">process/sleepingBeauties.stp</a> - Generating Backtraces of Threads Waiting for IO Operations<br> diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index fdcd3b31..fa344933 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -1,6 +1,22 @@ SYSTEMTAP EXAMPLES INDEX (see also keyword-index.txt) +general/ansi_colors.stp - Color Table for ansi_set_color2() and ansi_set_color3() +keywords: format + + The script prints a table showing the available color combinations + for the ansi_set_color2() and ans_set_color3() functions in the + ansi.stp tapset. + + +general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color3() +keywords: format + + The script prints a table showing the available attributes (bold, + underline, and inverse) with color combinations for the + ans_set_color3() function in the ansi.stp tapset. + + general/graphs.stp - Graphing Disk and CPU Utilization keywords: disk cpu use graph @@ -52,6 +68,19 @@ keywords: io backtrace list from most common to least common backtrace. +io/ioblktime.stp - Average Time Block IO Requests Spend in Queue +keywords: io + + The ioblktime.stp script tracks the amount of time that each block IO + requests spend waiting for completion. The script computes the + average time waiting time for block IO per device and prints list + every 10 seconds. In some cases there can be too many oustanding + block IO operations and the script may exceed the default number of + MAXMAPENTRIES allowed. In this case the allowed number can be + increased with "-DMAXMAPENTRIES=10000" option on the stap command + line. + + io/iostats.stp - List Executables Reading and Writing the Most Data keywords: io profiling @@ -123,6 +152,13 @@ keywords: memory determine where the page faults are occuring. +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + network/nettop.stp - Periodic Listing of Processes Using Network Interfaces keywords: network traffic per-process @@ -153,6 +189,24 @@ keywords: network tcp socket originator of the request. +network/tcpdumplike.stp - Dump of Received TCP Packets +keywords: network traffic + + The tcpdumplike.stp prints out a line for each TCP packet received. + Each line includes the source and destination IP addresses, the + source and destination ports, and flags. + + +process/errsnoop.stp - tabulate system call errors +keywords: process syscall + + The script prints a periodic tabular report about failing system + calls, by process and by syscall failure. The first optional + argument specifies the reporting interval (in seconds, default 5); + the second optional argument gives a screen height (number of lines + in the report, default 20). + + process/futexes.stp - System-Wide Futex Contention keywords: syscall locking futex @@ -191,7 +245,7 @@ keywords: signals that sent the signal. -process/syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +process/sigmon.stp - Track a particular signal to a specific process keywords: signals The script watches for a particular signal sent to a specific diff --git a/testsuite/systemtap.examples/io/ioblktime.meta b/testsuite/systemtap.examples/io/ioblktime.meta new file mode 100644 index 00000000..18a8b168 --- /dev/null +++ b/testsuite/systemtap.examples/io/ioblktime.meta @@ -0,0 +1,13 @@ +title: Average Time Block IO Requests Spend in Queue +name: ioblktime.stp +version: 1.0 +author: William Cohen +keywords: io +subsystem: kernel +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script computes the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line. +test_check: stap -p4 ioblktime.stp +test_installcheck: stap ioblktime.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/io/ioblktime.stp b/testsuite/systemtap.examples/io/ioblktime.stp new file mode 100755 index 00000000..d6267b3e --- /dev/null +++ b/testsuite/systemtap.examples/io/ioblktime.stp @@ -0,0 +1,29 @@ +#! /usr/bin/env stap + +global req_time, etimes + +probe ioblock.request +{ + req_time[$bio] = gettimeofday_us() +} + +probe ioblock.end +{ + t = gettimeofday_us() + s = req_time[$bio] + delete req_time[$bio] + if (s) { + etimes[devname, bio_rw_str(rw)] <<< t - s + } +} + +probe timer.s(10), end { + ansi_clear_screen() + printf("%10s %3s %10s %10s %10s\n", + "device", "rw", "total (us)", "count", "avg (us)") + foreach ([dev,rw] in etimes - limit 20) { + printf("%10s %3s %10d %10d %10d\n", dev, rw, + @sum(etimes[dev,rw]), @count(etimes[dev,rw]), @avg(etimes[dev,rw])) + } + delete etimes +} diff --git a/testsuite/systemtap.examples/io/traceio.stp b/testsuite/systemtap.examples/io/traceio.stp index 9e2deec6..875000cb 100755 --- a/testsuite/systemtap.examples/io/traceio.stp +++ b/testsuite/systemtap.examples/io/traceio.stp @@ -1,6 +1,9 @@ #! /usr/bin/env stap # traceio.stp # Copyright (C) 2007 Red Hat, Inc., Eugene Teo <eteo@redhat.com> +# Copyright (C) 2009 Kai Meyer <kai@unixlords.com> +# Fixed a bug that allows this to run longer +# And added the humanreadable function # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -10,22 +13,32 @@ global reads, writes, total_io probe vfs.read.return { - reads[execname()] += $return + reads[pid(),execname()] += $return + total_io[pid(),execname()] += $return } probe vfs.write.return { - writes[execname()] += $return + writes[pid(),execname()] += $return + total_io[pid(),execname()] += $return +} + +function humanreadable(bytes) { + if (bytes > 1024*1024*1024) { + return sprintf("%d GiB", bytes/1024/1024/1024) + } else if (bytes > 1024*1024) { + return sprintf("%d MiB", bytes/1024/1024) + } else if (bytes > 1024) { + return sprintf("%d KiB", bytes/1024) + } else { + return sprintf("%d B", bytes) + } } probe timer.s(1) { - foreach (p in reads) - total_io[p] += reads[p] - foreach (p in writes) - total_io[p] += writes[p] - foreach(p in total_io- limit 10) - printf("%15s r: %8d KiB w: %8d KiB\n", - p, reads[p]/1024, - writes[p]/1024) + foreach([p,e] in total_io- limit 10) + printf("%8d %15s r: %12s w: %12s\n", + p, e, humanreadable(reads[p,e]), + humanreadable(writes[p,e])) printf("\n") # Note we don't zero out reads, writes and total_io, # so the values are cumulative since the script started. diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index b3ea0943..7edbec21 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -39,7 +39,7 @@ </ul> <h2>Examples by Keyword</h2> -<p><tt><a href="#BACKTRACE">BACKTRACE</a> <a href="#CALLGRAPH">CALLGRAPH</a> <a href="#CPU">CPU</a> <a href="#DISK">DISK</a> <a href="#FUNCTIONS">FUNCTIONS</a> <a href="#FUTEX">FUTEX</a> <a href="#GRAPH">GRAPH</a> <a href="#INTERRUPT">INTERRUPT</a> <a href="#IO">IO</a> <a href="#LOCKING">LOCKING</a> <a href="#MEMORY">MEMORY</a> <a href="#NETWORK">NETWORK</a> <a href="#PER-PROCESS">PER-PROCESS</a> <a href="#PROFILING">PROFILING</a> <a href="#READ">READ</a> <a href="#SCHEDULER">SCHEDULER</a> <a href="#SIGNALS">SIGNALS</a> <a href="#SIMPLE">SIMPLE</a> <a href="#SLEEP">SLEEP</a> <a href="#SOCKET">SOCKET</a> <a href="#SYSCALL">SYSCALL</a> <a href="#TCP">TCP</a> <a href="#TIME">TIME</a> <a href="#TRACE">TRACE</a> <a href="#TRAFFIC">TRAFFIC</a> <a href="#USE">USE</a> <a href="#WAIT4">WAIT4</a> <a href="#WRITE">WRITE</a> </tt></p> +<p><tt><a href="#BACKTRACE">BACKTRACE</a> <a href="#BUFFER">BUFFER</a> <a href="#CALLGRAPH">CALLGRAPH</a> <a href="#CPU">CPU</a> <a href="#DISK">DISK</a> <a href="#FORMAT">FORMAT</a> <a href="#FREE">FREE</a> <a href="#FUNCTIONS">FUNCTIONS</a> <a href="#FUTEX">FUTEX</a> <a href="#GRAPH">GRAPH</a> <a href="#INTERRUPT">INTERRUPT</a> <a href="#IO">IO</a> <a href="#LOCKING">LOCKING</a> <a href="#MEMORY">MEMORY</a> <a href="#NETWORK">NETWORK</a> <a href="#PER-PROCESS">PER-PROCESS</a> <a href="#PROCESS">PROCESS</a> <a href="#PROFILING">PROFILING</a> <a href="#READ">READ</a> <a href="#SCHEDULER">SCHEDULER</a> <a href="#SIGNALS">SIGNALS</a> <a href="#SIMPLE">SIMPLE</a> <a href="#SLEEP">SLEEP</a> <a href="#SOCKET">SOCKET</a> <a href="#SYSCALL">SYSCALL</a> <a href="#TCP">TCP</a> <a href="#TIME">TIME</a> <a href="#TRACE">TRACE</a> <a href="#TRACEPOINT">TRACEPOINT</a> <a href="#TRAFFIC">TRAFFIC</a> <a href="#USE">USE</a> <a href="#WAIT4">WAIT4</a> <a href="#WRITE">WRITE</a> </tt></p> <h3><a name="BACKTRACE">BACKTRACE</a></h3> <ul> <li><a href="interrupt/scf.stp">interrupt/scf.stp</a> - Tally Backtraces for Inter-Processor Interrupt (IPI)<br> @@ -52,6 +52,12 @@ keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BAC keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#SCHEDULER">SCHEDULER</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br> <p>The script monitors the time that threads spend waiting for IO operations (in "D" state) in the wait_for_completion function. If a thread spends over 10ms, its name and backtrace is printed, and later so is the total delay.</p></li> </ul> +<h3><a name="BUFFER">BUFFER</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="CALLGRAPH">CALLGRAPH</a></h3> <ul> <li><a href="general/para-callgraph.stp">general/para-callgraph.stp</a> - Callgraph tracing with arguments<br> @@ -73,6 +79,21 @@ keywords: <a href="keyword-index.html#DISK">DISK</a> <a href="keyword-index.html keywords: <a href="keyword-index.html#DISK">DISK</a> <br> <p>Get the status of reading/writing disk every 5 seconds, output top ten entries during that period.</p></li> </ul> +<h3><a name="FORMAT">FORMAT</a></h3> +<ul> +<li><a href="general/ansi_colors.stp">general/ansi_colors.stp</a> - Color Table for ansi_set_color2() and ansi_set_color3()<br> +keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> +<p>The script prints a table showing the available color combinations for the ansi_set_color2() and ans_set_color3() functions in the ansi.stp tapset.</p></li> +<li><a href="general/ansi_colors2.stp">general/ansi_colors2.stp</a> - Show Attribues in Table for ansi_set_color3()<br> +keywords: <a href="keyword-index.html#FORMAT">FORMAT</a> <br> +<p>The script prints a table showing the available attributes (bold, underline, and inverse) with color combinations for the ans_set_color3() function in the ansi.stp tapset.</p></li> +</ul> +<h3><a name="FREE">FREE</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="FUNCTIONS">FUNCTIONS</a></h3> <ul> <li><a href="profiling/functioncallcount.stp">profiling/functioncallcount.stp</a> - Count Times Functions Called<br> @@ -102,6 +123,9 @@ keywords: <a href="keyword-index.html#INTERRUPT">INTERRUPT</a> <a href="keyword- <li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br> keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br> <p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li> +<li><a href="io/ioblktime.stp">io/ioblktime.stp</a> - Average Time Block IO Requests Spend in Queue <br> +keywords: <a href="keyword-index.html#IO">IO</a> <br> +<p>The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script computes the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.</p></li> <li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br> keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br> <p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li> @@ -138,6 +162,9 @@ keywords: <a href="keyword-index.html#MEMORY">MEMORY</a> <br> </ul> <h3><a name="NETWORK">NETWORK</a></h3> <ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> <li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br> keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <br> <p>Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.</p></li> @@ -147,6 +174,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde <li><a href="network/tcp_connections.stp">network/tcp_connections.stp</a> - Track Creation of Incoming TCP Connections<br> keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TCP">TCP</a> <a href="keyword-index.html#SOCKET">SOCKET</a> <br> <p>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.</p></li> +<li><a href="network/tcpdumplike.stp">network/tcpdumplike.stp</a> - Dump of Received TCP Packets<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <br> +<p>The tcpdumplike.stp prints out a line for each TCP packet received. Each line includes the source and destination IP addresses, the source and destination ports, and flags.</p></li> </ul> <h3><a name="PER-PROCESS">PER-PROCESS</a></h3> <ul> @@ -154,6 +184,12 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <br> <p>Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.</p></li> </ul> +<h3><a name="PROCESS">PROCESS</a></h3> +<ul> +<li><a href="process/errsnoop.stp">process/errsnoop.stp</a> - tabulate system call errors<br> +keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <br> +<p>The script prints a periodic tabular report about failing system calls, by process and by syscall failure. The first optional argument specifies the reporting interval (in seconds, default 5); the second optional argument gives a screen height (number of lines in the report, default 20).</p></li> +</ul> <h3><a name="PROFILING">PROFILING</a></h3> <ul> <li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br> @@ -198,7 +234,7 @@ keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <li><a href="process/sigkill.stp">process/sigkill.stp</a> - Track SIGKILL Signals<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.</p></li> -<li><a href="process/syscalls_by_pid.stp">process/syscalls_by_pid.stp</a> - System-Wide Count of Syscalls by PID<br> +<li><a href="process/sigmon.stp">process/sigmon.stp</a> - Track a particular signal to a specific process<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.</p></li> </ul> @@ -228,6 +264,9 @@ keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-inde <li><a href="io/iotime.stp">io/iotime.stp</a> - Trace Time Spent in Read and Write for Files <br> keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#READ">READ</a> <a href="keyword-index.html#WRITE">WRITE</a> <a href="keyword-index.html#TIME">TIME</a> <a href="keyword-index.html#IO">IO</a> <br> <p>The script watches each open, close, read, and write syscalls on the system. For each file the scripts observes opened it accumulates the amount of wall clock time spend in read and write operations and the number of bytes read and written. When a file is closed the script prints out a pair of lines for the file. Both lines begin with a timestamp in microseconds, the PID number, and the executable name in parenthesese. The first line with the "access" keyword lists the file name, the attempted number of bytes for the read and write operations. The second line with the "iotime" keyword list the file name and the number of microseconds accumulated in the read and write syscalls.</p></li> +<li><a href="process/errsnoop.stp">process/errsnoop.stp</a> - tabulate system call errors<br> +keywords: <a href="keyword-index.html#PROCESS">PROCESS</a> <a href="keyword-index.html#SYSCALL">SYSCALL</a> <br> +<p>The script prints a periodic tabular report about failing system calls, by process and by syscall failure. The first optional argument specifies the reporting interval (in seconds, default 5); the second optional argument gives a screen height (number of lines in the report, default 20).</p></li> <li><a href="process/futexes.stp">process/futexes.stp</a> - System-Wide Futex Contention<br> keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-index.html#LOCKING">LOCKING</a> <a href="keyword-index.html#FUTEX">FUTEX</a> <br> <p>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.</p></li> @@ -262,11 +301,20 @@ keywords: <a href="keyword-index.html#SYSCALL">SYSCALL</a> <a href="keyword-inde keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.html#CALLGRAPH">CALLGRAPH</a> <br> <p>Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.</p></li> </ul> +<h3><a name="TRACEPOINT">TRACEPOINT</a></h3> +<ul> +<li><a href="network/dropwatch.stp">network/dropwatch.stp</a> - Watch Where Socket Buffers are Freed in the Kernel<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRACEPOINT">TRACEPOINT</a> <a href="keyword-index.html#BUFFER">BUFFER</a> <a href="keyword-index.html#FREE">FREE</a> <br> +<p>Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel.</p></li> +</ul> <h3><a name="TRAFFIC">TRAFFIC</a></h3> <ul> <li><a href="network/nettop.stp">network/nettop.stp</a> - Periodic Listing of Processes Using Network Interfaces<br> keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <a href="keyword-index.html#PER-PROCESS">PER-PROCESS</a> <br> <p>Every five seconds the nettop.stp script prints out a list of processed (PID and command) with the number of packets sent/received and the amount of data sent/received by the process during that interval.</p></li> +<li><a href="network/tcpdumplike.stp">network/tcpdumplike.stp</a> - Dump of Received TCP Packets<br> +keywords: <a href="keyword-index.html#NETWORK">NETWORK</a> <a href="keyword-index.html#TRAFFIC">TRAFFIC</a> <br> +<p>The tcpdumplike.stp prints out a line for each TCP packet received. Each line includes the source and destination IP addresses, the source and destination ports, and flags.</p></li> </ul> <h3><a name="USE">USE</a></h3> <ul> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 5f382e75..b53e776f 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -30,6 +30,15 @@ keywords: io scheduler backtrace so is the total delay. += BUFFER = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = CALLGRAPH = general/para-callgraph.stp - Callgraph tracing with arguments @@ -70,6 +79,33 @@ keywords: disk ten entries during that period. += FORMAT = + +general/ansi_colors.stp - Color Table for ansi_set_color2() and ansi_set_color3() +keywords: format + + The script prints a table showing the available color combinations + for the ansi_set_color2() and ans_set_color3() functions in the + ansi.stp tapset. + + +general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color3() +keywords: format + + The script prints a table showing the available attributes (bold, + underline, and inverse) with color combinations for the + ans_set_color3() function in the ansi.stp tapset. + + += FREE = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = FUNCTIONS = profiling/functioncallcount.stp - Count Times Functions Called @@ -125,6 +161,19 @@ keywords: io backtrace list from most common to least common backtrace. +io/ioblktime.stp - Average Time Block IO Requests Spend in Queue +keywords: io + + The ioblktime.stp script tracks the amount of time that each block IO + requests spend waiting for completion. The script computes the + average time waiting time for block IO per device and prints list + every 10 seconds. In some cases there can be too many oustanding + block IO operations and the script may exceed the default number of + MAXMAPENTRIES allowed. In this case the allowed number can be + increased with "-DMAXMAPENTRIES=10000" option on the stap command + line. + + io/iostats.stp - List Executables Reading and Writing the Most Data keywords: io profiling @@ -220,6 +269,13 @@ keywords: memory = NETWORK = +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + network/nettop.stp - Periodic Listing of Processes Using Network Interfaces keywords: network traffic per-process @@ -250,6 +306,14 @@ keywords: network tcp socket originator of the request. +network/tcpdumplike.stp - Dump of Received TCP Packets +keywords: network traffic + + The tcpdumplike.stp prints out a line for each TCP packet received. + Each line includes the source and destination IP addresses, the + source and destination ports, and flags. + + = PER-PROCESS = network/nettop.stp - Periodic Listing of Processes Using Network Interfaces @@ -261,6 +325,18 @@ keywords: network traffic per-process interval. += PROCESS = + +process/errsnoop.stp - tabulate system call errors +keywords: process syscall + + The script prints a periodic tabular report about failing system + calls, by process and by syscall failure. The first optional + argument specifies the reporting interval (in seconds, default 5); + the second optional argument gives a screen height (number of lines + in the report, default 20). + + = PROFILING = io/iostats.stp - List Executables Reading and Writing the Most Data @@ -373,7 +449,7 @@ keywords: signals that sent the signal. -process/syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +process/sigmon.stp - Track a particular signal to a specific process keywords: signals The script watches for a particular signal sent to a specific @@ -445,6 +521,16 @@ keywords: syscall read write time io syscalls. +process/errsnoop.stp - tabulate system call errors +keywords: process syscall + + The script prints a periodic tabular report about failing system + calls, by process and by syscall failure. The first optional + argument specifies the reporting interval (in seconds, default 5); + the second optional argument gives a screen height (number of lines + in the report, default 20). + + process/futexes.stp - System-Wide Futex Contention keywords: syscall locking futex @@ -533,6 +619,15 @@ keywords: trace callgraph the trigger. += TRACEPOINT = + +network/dropwatch.stp - Watch Where Socket Buffers are Freed in the Kernel +keywords: network tracepoint buffer free + + Every five seconds the dropwatch.stp script lists the number of + socket buffers freed at locations in the kernel. + + = TRAFFIC = network/nettop.stp - Periodic Listing of Processes Using Network Interfaces @@ -544,6 +639,14 @@ keywords: network traffic per-process interval. +network/tcpdumplike.stp - Dump of Received TCP Packets +keywords: network traffic + + The tcpdumplike.stp prints out a line for each TCP packet received. + Each line includes the source and destination IP addresses, the + source and destination ports, and flags. + + = USE = general/graphs.stp - Graphing Disk and CPU Utilization diff --git a/testsuite/systemtap.examples/network/dropwatch.meta b/testsuite/systemtap.examples/network/dropwatch.meta new file mode 100644 index 00000000..176ba236 --- /dev/null +++ b/testsuite/systemtap.examples/network/dropwatch.meta @@ -0,0 +1,13 @@ +title: Watch Where Socket Buffers are Freed in the Kernel +name: dropwatch.stp +version: 1.0 +author: Neil Horman +keywords: network tracepoint buffer free +subsystem: network +status: production +exit: user-controlled +output: timed +scope: system-wide +description: Every five seconds the dropwatch.stp script lists the number of socket buffers freed at locations in the kernel. +test_check: stap -p4 dropwatch.stp +test_installcheck: stap dropwatch.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/network/dropwatch.stp b/testsuite/systemtap.examples/network/dropwatch.stp new file mode 100755 index 00000000..79d50a4e --- /dev/null +++ b/testsuite/systemtap.examples/network/dropwatch.stp @@ -0,0 +1,30 @@ +#! /usr/bin/env stap + +############################################################ +# Dropwatch.stp +# Author: Neil Horman <nhorman@redhat.com> +# An example script to mimic the behavior of the dropwatch utility +# http://fedorahosted.org/dropwatch +############################################################ + +# Array to hold the list of drop points we find +global locations + +# Note when we turn the monitor on and off +probe begin { printf("Monitoring for dropped packets\n") } +probe end { printf("Stopping dropped packet monitor\n") } + +# increment a drop counter for every location we drop at +probe kernel.trace("kfree_skb") { locations[$location] <<< 1 } + +# Every 5 seconds report our drop locations +probe timer.sec(5) +{ + printf("\n") + foreach (l in locations-) { + printf("%d packets dropped at location %p\n", + @count(locations[l]), l) + } + delete locations +} + diff --git a/testsuite/systemtap.examples/network/nettop.stp b/testsuite/systemtap.examples/network/nettop.stp index 15b4d62a..e96548f1 100755 --- a/testsuite/systemtap.examples/network/nettop.stp +++ b/testsuite/systemtap.examples/network/nettop.stp @@ -1,6 +1,7 @@ #! /usr/bin/env stap global ifxmit, ifrecv +global ifmerged probe netdev.transmit { @@ -18,7 +19,13 @@ function print_activity() "PID", "UID", "DEV", "XMIT_PK", "RECV_PK", "XMIT_KB", "RECV_KB", "COMMAND") - foreach ([pid, dev, exec, uid] in ifrecv-) { + foreach ([pid, dev, exec, uid] in ifrecv) { + ifmerged[pid, dev, exec, uid] += @count(ifrecv[pid,dev,exec,uid]); + } + foreach ([pid, dev, exec, uid] in ifxmit) { + ifmerged[pid, dev, exec, uid] += @count(ifxmit[pid,dev,exec,uid]); + } + foreach ([pid, dev, exec, uid] in ifmerged-) { n_xmit = @count(ifxmit[pid, dev, exec, uid]) n_recv = @count(ifrecv[pid, dev, exec, uid]) printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n", @@ -32,6 +39,7 @@ function print_activity() delete ifxmit delete ifrecv + delete ifmerged } probe timer.ms(5000), end, error diff --git a/testsuite/systemtap.examples/network/tcp.stp b/testsuite/systemtap.examples/network/tcp.stp new file mode 100755 index 00000000..01db9d2d --- /dev/null +++ b/testsuite/systemtap.examples/network/tcp.stp @@ -0,0 +1,13 @@ +#! /usr/bin/env stap + +//A simple TCP tapset example + +probe begin { + printf("Expected IP 7.91.205.21 .... %s\n", ip_ntop(123456789)) + printf("Expected IP 58.222.104.177 .... %s\n", ip_ntop(987654321)) + printf("Expected IP 9.3.191.111 ... %s\n", ip_ntop(151240559)) +} + +probe tcp.recvmsg { + printf("received a message from %s on port %d from port %d\n", saddr, dport, sport) +} diff --git a/testsuite/systemtap.examples/network/tcpdumplike.meta b/testsuite/systemtap.examples/network/tcpdumplike.meta new file mode 100644 index 00000000..8fb9fccb --- /dev/null +++ b/testsuite/systemtap.examples/network/tcpdumplike.meta @@ -0,0 +1,12 @@ +title: Dump of Received TCP Packets +name: tcpdumplike.stp +version: 1.0 +author: anonymous +keywords: network traffic +subsystem: network +status: production +exit: user-controlled +output: timed +scope: system-wide +description: The tcpdumplike.stp prints out a line for each TCP packet received. Each line includes the source and destination IP addresses, the source and destination ports, and flags. +test_installcheck: stap tcpdumplike.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/network/tcpdumplike.stp b/testsuite/systemtap.examples/network/tcpdumplike.stp new file mode 100755 index 00000000..de3899d6 --- /dev/null +++ b/testsuite/systemtap.examples/network/tcpdumplike.stp @@ -0,0 +1,14 @@ +#! /usr/bin/env stap + +// A TCP dump like example + +probe begin, timer.s(1) { + printf("-----------------------------------------------------------------\n") + printf(" Source IP Dest IP SPort DPort U A P R S F \n") + printf("-----------------------------------------------------------------\n") +} + +probe tcp.receive { + printf(" %15s %15s %5d %5d %d %d %d %d %d %d\n", + saddr, daddr, sport, dport, urg, ack, psh, rst, syn, fin) +} diff --git a/testsuite/systemtap.examples/process/errsnoop.meta b/testsuite/systemtap.examples/process/errsnoop.meta new file mode 100644 index 00000000..34b8cb7c --- /dev/null +++ b/testsuite/systemtap.examples/process/errsnoop.meta @@ -0,0 +1,7 @@ +title: tabulate system call errors +name: errsnoop.stp +keywords: process syscall +subsystem: general +description: The script prints a periodic tabular report about failing system calls, by process and by syscall failure. The first optional argument specifies the reporting interval (in seconds, default 5); the second optional argument gives a screen height (number of lines in the report, default 20). +test_check: stap -p4 errsnoop.stp +test_installcheck: stap errsnoop.stp 1 10 -c "sleep 3" diff --git a/testsuite/systemtap.examples/process/errsnoop.stp b/testsuite/systemtap.examples/process/errsnoop.stp new file mode 100755 index 00000000..a3f17b77 --- /dev/null +++ b/testsuite/systemtap.examples/process/errsnoop.stp @@ -0,0 +1,44 @@ +#!/bin/sh +//usr/bin/env stap -DMAXMAPENTRIES=20480 $0 $@; exit $? +# errsnoop.stp +# Copyright (C) 2009 Red Hat, Inc., Eugene Teo <eteo@redhat.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# attack "stupid userspace" apps +# + +global error, trace + +probe syscall.* { + # assume syscall don't nest + trace[tid()] = argstr +} + +probe syscall.*.return { + errno = errno_p(returnval()) + if (errno != 0) { + t = tid() + argstr = trace[t] + delete trace[t] + + error[name, execname(), pid(), errno, argstr] <<< 1 + } +} + +probe timer.s(%( $# > 0 %? $1 %: 5 %)) { + ansi_clear_screen() + printf("%17s %15s %5s %4s %-12s %s\n", + "SYSCALL", "PROCESS", "PID", "HITS", "ERRSTR", "ARGSTR") + foreach([fn, comm, pid, errno, argstr] in error- limit %( $# > 1 %? $2 %: 20 %)) { + errstr = sprintf("%3d (%s)", errno, errno_str(errno)) + printf("%17s %15s %5d %4d %-12s %s\n", fn, comm, pid, + @count(error[fn, comm, pid, errno, argstr]), +# errstr, substr(argstr,0,22)) # within cols#80 + errstr, argstr) + + } + delete error +} diff --git a/testsuite/systemtap.examples/process/proc_snoop.stp b/testsuite/systemtap.examples/process/proc_snoop.stp index 06425d45..9a3768c2 100755 --- a/testsuite/systemtap.examples/process/proc_snoop.stp +++ b/testsuite/systemtap.examples/process/proc_snoop.stp @@ -18,30 +18,30 @@ function id:string(task:long) { task_execname(task)) } -probe process.create { +probe kprocess.create { report(sprintf("create %s", id(task))) } -probe process.start { +probe kprocess.start { report("start") } -probe process.exec { +probe kprocess.exec { report(sprintf("exec %s", filename)) } -probe process.exec_complete { +probe kprocess.exec_complete { if (success) report("exec success") else report(sprintf("exec failed %d (%s)", errno, errno_str(errno))) } -probe process.exit { +probe kprocess.exit { report(sprintf("exit %d", code)) } -probe process.release { +probe kprocess.release { report(sprintf("remove %s", id(task))) } diff --git a/testsuite/systemtap.examples/process/sigmon.meta b/testsuite/systemtap.examples/process/sigmon.meta index 18834997..fe192248 100644 --- a/testsuite/systemtap.examples/process/sigmon.meta +++ b/testsuite/systemtap.examples/process/sigmon.meta @@ -1,5 +1,5 @@ -title: System-Wide Count of Syscalls by PID -name: syscalls_by_pid.stp +title: Track a particular signal to a specific process +name: sigmon.stp version: 1.0 author: IBM keywords: signals diff --git a/testsuite/systemtap.examples/profiling/latencytap.stp b/testsuite/systemtap.examples/profiling/latencytap.stp index 28956129..d202ec81 100755 --- a/testsuite/systemtap.examples/profiling/latencytap.stp +++ b/testsuite/systemtap.examples/profiling/latencytap.stp @@ -23,7 +23,7 @@ function _get_sleep_time:long(rq_param:long, p_param:long) function task_backtrace:string (task:long) %{ _stp_stack_snprint_tsk(THIS->__retvalue, MAXSTRINGLEN, - (struct task_struct *)THIS->task, 0, MAXTRACE); + (struct task_struct *)(unsigned long)THIS->task, 0, MAXTRACE); %} probe kernel.function("enqueue_task_fair") { diff --git a/testsuite/systemtap.examples/profiling/timeout.stp b/testsuite/systemtap.examples/profiling/timeout.stp index 48d6d21d..8054b364 100755 --- a/testsuite/systemtap.examples/profiling/timeout.stp +++ b/testsuite/systemtap.examples/profiling/timeout.stp @@ -90,8 +90,8 @@ probe syscall.exit { } probe timer.s(1) { - printf("\033[2J\033[1;1H") /* clear screen */ - printf (" uid | poll select epoll itimer futex nanosle signal| process\n") + ansi_clear_screen() + printf (" pid | poll select epoll itimer futex nanosle signal| process\n") foreach (p in timeout_count- limit 20) { printf ("%5d |%7d %7d %7d %7d %7d %7d %7d| %-.38s\n", p, poll_timeout[p], select_timeout[p], diff --git a/testsuite/systemtap.pass1-4/buildok.exp b/testsuite/systemtap.pass1-4/buildok.exp index 08d50fb5..12275c1d 100644 --- a/testsuite/systemtap.pass1-4/buildok.exp +++ b/testsuite/systemtap.pass1-4/buildok.exp @@ -6,12 +6,12 @@ foreach file [lsort [glob -nocomplain $srcdir/$self/*.stp]] { # some tests are known to fail. switch $test { buildok/perfmon01.stp {setup_kfail 909 *-*-*} - buildok/twentysix.stp {setup_kfail 4105 *-*-*} buildok/twentyseven.stp {setup_kfail 4166 *-*-*} buildok/sched_test.stp {setup_kfail 1155 *-*-*} buildok/process_test.stp {setup_kfail 1155 *-*-*} buildok/rpc-all-probes.stp {setup_kfail 4413 *-*-*} buildok/nfs-all-probes.stp {setup_kfail 4413 *-*-*} + buildok/per-process-syscall.stp {if {![utrace_p]} { setup_kfail 9999 *-*-*} } } if {$rc == 0} { pass $test } else { fail $test } } diff --git a/testsuite/systemtap.printf/basic6.exp b/testsuite/systemtap.printf/basic6.exp new file mode 100644 index 00000000..72bf8f57 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.exp @@ -0,0 +1,3 @@ +set test "basic6" +set ::result_string {Hello%World} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.printf/basic6.stp b/testsuite/systemtap.printf/basic6.stp new file mode 100644 index 00000000..69721188 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.stp @@ -0,0 +1,5 @@ +probe begin +{ + printf("Hello%%World"); + exit() +} diff --git a/testsuite/systemtap.printf/char1.exp b/testsuite/systemtap.printf/char1.exp index 35aa479f..f9343c0e 100644 --- a/testsuite/systemtap.printf/char1.exp +++ b/testsuite/systemtap.printf/char1.exp @@ -1,3 +1,3 @@ set test "char1" -set ::result_string {stap} +set ::result_string {stapok} stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.printf/char1.stp b/testsuite/systemtap.printf/char1.stp index 207d1bc5..564c416b 100644 --- a/testsuite/systemtap.printf/char1.stp +++ b/testsuite/systemtap.printf/char1.stp @@ -3,6 +3,7 @@ probe begin printf("%c", 115) printf("%c", 116) printf("%c%c", 97, 112) + printf("%c%c", stringat("ok", 0), stringat("ok", 1)) print("\n") exit() } diff --git a/testsuite/systemtap.printf/end1.exp b/testsuite/systemtap.printf/end1.exp index e4f164f5..ab1de590 100644 --- a/testsuite/systemtap.printf/end1.exp +++ b/testsuite/systemtap.printf/end1.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/end1b.exp b/testsuite/systemtap.printf/end1b.exp index 08cfa648..46cdc9c7 100644 --- a/testsuite/systemtap.printf/end1b.exp +++ b/testsuite/systemtap.printf/end1b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/memory1.stp b/testsuite/systemtap.printf/memory1.stp index f9cbf60b..15aa565b 100644 --- a/testsuite/systemtap.printf/memory1.stp +++ b/testsuite/systemtap.printf/memory1.stp @@ -113,6 +113,20 @@ probe syscall.open { success = 0; } + expected_16_actual = sprintf (" %02x%02x%02x%02x%02x%02x", + stringat(filename, 0), + stringat(filename, 1), + stringat(filename, 2), + stringat(filename, 3), + stringat(filename, 4), + stringat(filename, 5)); + testName = "%M dynamic width larger than dynamic precision"; + result = sprintf ("%*.*M", 14, 6, $filename); + if (result != expected_16_actual) { + printf ("Test %s failed\n", testName); + success = 0; + } + if (success) print ("Test passed\n"); diff --git a/testsuite/systemtap.printf/mixed_out.exp b/testsuite/systemtap.printf/mixed_out.exp index d73a55a6..55320e80 100644 --- a/testsuite/systemtap.printf/mixed_out.exp +++ b/testsuite/systemtap.printf/mixed_out.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/mixed_outb.exp b/testsuite/systemtap.printf/mixed_outb.exp index 30c0c92f..c15520b1 100644 --- a/testsuite/systemtap.printf/mixed_outb.exp +++ b/testsuite/systemtap.printf/mixed_outb.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out1.exp b/testsuite/systemtap.printf/out1.exp index d5728c0f..f973ae00 100644 --- a/testsuite/systemtap.printf/out1.exp +++ b/testsuite/systemtap.printf/out1.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out1b.exp b/testsuite/systemtap.printf/out1b.exp index 2f702a2f..24efbf4c 100644 --- a/testsuite/systemtap.printf/out1b.exp +++ b/testsuite/systemtap.printf/out1b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out2.exp b/testsuite/systemtap.printf/out2.exp index dd96f394..8c66e73d 100644 --- a/testsuite/systemtap.printf/out2.exp +++ b/testsuite/systemtap.printf/out2.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out2b.exp b/testsuite/systemtap.printf/out2b.exp index 0b56c940..70a98ea2 100644 --- a/testsuite/systemtap.printf/out2b.exp +++ b/testsuite/systemtap.printf/out2b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.printf/out3.exp b/testsuite/systemtap.printf/out3.exp index 96ca2bc5..63a67d8f 100644 --- a/testsuite/systemtap.printf/out3.exp +++ b/testsuite/systemtap.printf/out3.exp @@ -4,7 +4,7 @@ set TEST_NAME "$subdir/$test" if {![installtest_p]} { untested $TEST_NAME; return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested $TEST_NAME return diff --git a/testsuite/systemtap.printf/out3b.exp b/testsuite/systemtap.printf/out3b.exp index c42d03b7..d49625e9 100644 --- a/testsuite/systemtap.printf/out3b.exp +++ b/testsuite/systemtap.printf/out3b.exp @@ -9,7 +9,7 @@ if (![file executable $stap_merge_path]) { return } -if {[catch {exec mktemp -t staptestXXXXX} tmpfile]} { +if {[catch {exec mktemp -t staptestXXXXXX} tmpfile]} { puts stderr "Failed to create temporary file: $tmpfile" untested "$TEST_NAME : failed to create temporary file" return diff --git a/testsuite/systemtap.samples/ioblocktest.exp b/testsuite/systemtap.samples/ioblocktest.exp deleted file mode 100644 index b5ab54c7..00000000 --- a/testsuite/systemtap.samples/ioblocktest.exp +++ /dev/null @@ -1,11 +0,0 @@ -# Test the functionality of the various ioblock probes. - -set test "ioblocktest" - -proc sleep_ten_secs {} { - after 10000; - return 0; -} - -set output_string "ioblock: \\S+\t\\d+\t\[RW]\t\[01]\r\n" -stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string diff --git a/testsuite/systemtap.samples/ioblocktest.stp b/testsuite/systemtap.samples/ioblocktest.stp deleted file mode 100644 index f8a1c568..00000000 --- a/testsuite/systemtap.samples/ioblocktest.stp +++ /dev/null @@ -1,12 +0,0 @@ -#! stap -global teststr -probe begin { println("systemtap starting probe") } - -probe ioblock.request, ioblock.end { - teststr = sprintf("ioblock: %s\t%d\t%s\t%d\n", devname, sector, - bio_rw_str(rw), bio_rw_num(rw)) -} -probe end { - println("systemtap ending probe") - printf("%s", teststr) -} diff --git a/testsuite/systemtap.server/server.exp b/testsuite/systemtap.server/server.exp index c2c60b97..d2dd0f16 100644 --- a/testsuite/systemtap.server/server.exp +++ b/testsuite/systemtap.server/server.exp @@ -16,7 +16,6 @@ foreach file [lsort [glob -nocomplain $srcdir/$self/*.stp]] { # some tests are known to fail. switch $test { "buildok/perfmon01.stp with server" {setup_kfail 909 *-*-*} - "buildok/twentysix.stp with server" {setup_kfail 4105 *-*-*} "buildok/twentyseven.stp with server" {setup_kfail 4166 *-*-*} "buildok/sched_test.stp with server" {setup_kfail 1155 *-*-*} "buildok/process_test.stp with server" {setup_kfail 1155 *-*-*} diff --git a/testsuite/systemtap.stress/whitelist.exp b/testsuite/systemtap.stress/whitelist.exp index 4a31c124..70973978 100644 --- a/testsuite/systemtap.stress/whitelist.exp +++ b/testsuite/systemtap.stress/whitelist.exp @@ -96,6 +96,7 @@ set init_probes_all_script { udp.*.return, tcp.*, tcp.*.return, + kprocess.*, process.*, nfs.fop.*, nfs.aop.*, diff --git a/testsuite/systemtap.syscall/access.c b/testsuite/systemtap.syscall/access.c index 682424d4..45066015 100644 --- a/testsuite/systemtap.syscall/access.c +++ b/testsuite/systemtap.syscall/access.c @@ -13,28 +13,28 @@ int main() fd1 = creat("foobar1",S_IREAD|S_IWRITE); access("foobar1", F_OK); - // access ("foobar1", F_OK) - // faccessat (AT_FDCWD, "foobar1", F_OK) = 0 + //staptest// access ("foobar1", F_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", F_OK) = 0 access("foobar1", R_OK); - // access ("foobar1", R_OK) - // faccessat (AT_FDCWD, "foobar1", R_OK) = 0 + //staptest// access ("foobar1", R_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", R_OK) = 0 access("foobar1", W_OK); - // access ("foobar1", W_OK) - // faccessat (AT_FDCWD, "foobar1", W_OK) = 0 + //staptest// access ("foobar1", W_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", W_OK) = 0 access("foobar1", X_OK); - // access ("foobar1", X_OK) - // faccessat (AT_FDCWD, "foobar1", X_OK) = -NNNN (EACCES) + //staptest// access ("foobar1", X_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", X_OK) = -NNNN (EACCES) access("foobar1", R_OK|W_OK); - // access ("foobar1", W_OK |R_OK) - // faccessat (AT_FDCWD, "foobar1", W_OK |R_OK) = 0 + //staptest// access ("foobar1", W_OK |R_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", W_OK |R_OK) = 0 access("foobar1", R_OK|W_OK|X_OK); - // access ("foobar1", X_OK |W_OK |R_OK) - // faccessat (AT_FDCWD, "foobar1", X_OK |W_OK |R_OK) = -NNNN (EACCES) + //staptest// access ("foobar1", X_OK |W_OK |R_OK) + //staptest// faccessat (AT_FDCWD, "foobar1", X_OK |W_OK |R_OK) = -NNNN (EACCES) return 0; } diff --git a/testsuite/systemtap.syscall/acct.c b/testsuite/systemtap.syscall/acct.c index 927e40c9..47f87961 100644 --- a/testsuite/systemtap.syscall/acct.c +++ b/testsuite/systemtap.syscall/acct.c @@ -4,7 +4,7 @@ int main() { acct("foobar"); - // acct ("foobar") = -NNNN + //staptest// acct ("foobar") = -NNNN return 0; } diff --git a/testsuite/systemtap.syscall/alarm.c b/testsuite/systemtap.syscall/alarm.c index 7cb17164..6f1bedce 100755..100644 --- a/testsuite/systemtap.syscall/alarm.c +++ b/testsuite/systemtap.syscall/alarm.c @@ -20,36 +20,36 @@ int main() alarm(1); #ifdef __ia64__ - // setitimer (ITIMER_REAL, \[0.000000,1.000000\], XXXX) = 0 + //staptest// setitimer (ITIMER_REAL, \[0.000000,1.000000\], XXXX) = 0 #else - // alarm (1) = 0 + //staptest// alarm (1) = 0 #endif pause(); #ifdef __ia64__ - // rt_sigsuspend () = + //staptest// rt_sigsuspend () = #else - // pause () = + //staptest// pause () = #endif alarm(0); #ifdef __ia64__ - // setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = 0 + //staptest// setitimer (ITIMER_REAL, \[0.000000,0.000000\], XXXX) = 0 #else - // alarm (0) = 0 + //staptest// alarm (0) = 0 #endif sleep(1); - // nanosleep (\[1.000000000\], XXXX) = 0 + //staptest// nanosleep (\[1.000000000\], XXXX) = 0 usleep(1234); - // nanosleep (\[0.001234000\], 0x[0]+) = 0 + //staptest// nanosleep (\[0.001234000\], 0x[0]+) = 0 nanosleep(&t, &rem); - // nanosleep (\[0.000000789\], XXXX) = 0 + //staptest// nanosleep (\[0.000000789\], XXXX) = 0 nanosleep(&t, NULL); - // nanosleep (\[0.000000789\], 0x[0]+) = 0 + //staptest// nanosleep (\[0.000000789\], 0x[0]+) = 0 return 0; } diff --git a/testsuite/systemtap.syscall/chmod.c b/testsuite/systemtap.syscall/chmod.c index 9b0c58e1..724b86c4 100644 --- a/testsuite/systemtap.syscall/chmod.c +++ b/testsuite/systemtap.syscall/chmod.c @@ -11,70 +11,70 @@ int main() int fd; fd = open("foobar",O_WRONLY|O_CREAT, 0666); - // open ("foobar", O_WRONLY|O_CREAT, 0666) = NNNN + //staptest// open ("foobar", O_WRONLY|O_CREAT, 0666) = NNNN chmod("foobar", 0644); - // chmod ("foobar", 0644) - // fchmodat (AT_FDCWD, "foobar", 0644) = 0 + //staptest// chmod ("foobar", 0644) + //staptest// fchmodat (AT_FDCWD, "foobar", 0644) = 0 fchmod(fd, 0444); - // fchmod (NNNN, 0444) = 0 + //staptest// fchmod (NNNN, 0444) = 0 chown("foobar", 5000, -1); #ifdef __i386__ - // chown ("foobar", 5000, -1) = + //staptest// chown ("foobar", 5000, -1) = #else - // chown ("foobar", 5000, NNNN) = + //staptest// chown ("foobar", 5000, NNNN) = #endif chown("foobar", -1, 5001); #ifdef __i386__ - // chown ("foobar", -1, 5001) = + //staptest// chown ("foobar", -1, 5001) = #else - // chown ("foobar", NNNN, 5001) = + //staptest// chown ("foobar", NNNN, 5001) = #endif fchown(fd, 5002, -1); #ifdef __i386__ - // fchown (NNNN, 5002, -1) = + //staptest// fchown (NNNN, 5002, -1) = #else - // fchown (NNNN, 5002, NNNN) = + //staptest// fchown (NNNN, 5002, NNNN) = #endif fchown(fd, -1, 5003); #ifdef __i386__ - // fchown (NNNN, -1, 5003) = + //staptest// fchown (NNNN, -1, 5003) = #else - // fchown (NNNN, NNNN, 5003) = + //staptest// fchown (NNNN, NNNN, 5003) = #endif lchown("foobar", 5004, -1); #ifdef __i386__ - // lchown ("foobar", 5004, -1) = + //staptest// lchown ("foobar", 5004, -1) = #else - // lchown ("foobar", 5004, NNNN) = + //staptest// lchown ("foobar", 5004, NNNN) = #endif lchown("foobar", -1, 5005); #ifdef __i386__ - // lchown ("foobar", -1, 5005) = + //staptest// lchown ("foobar", -1, 5005) = #else - // lchown ("foobar", NNNN, 5005) = + //staptest// lchown ("foobar", NNNN, 5005) = #endif #ifdef __i386__ syscall(SYS_chown, "foobar", 5000, -1); - // chown16 ("foobar", 5000, -1) = + //staptest// chown16 ("foobar", 5000, -1) = syscall(SYS_chown, "foobar", -1, 5001); - // chown16 ("foobar", -1, 5001) = + //staptest// chown16 ("foobar", -1, 5001) = syscall(SYS_fchown, fd, 5002, -1); - // fchown16 (NNNN, 5002, -1) = + //staptest// fchown16 (NNNN, 5002, -1) = syscall(SYS_fchown, fd, -1, 5003); - // fchown16 (NNNN, -1, 5003) = + //staptest// fchown16 (NNNN, -1, 5003) = syscall(SYS_lchown, "foobar", 5004, -1); - // lchown16 ("foobar", 5004, -1) = + //staptest// lchown16 ("foobar", 5004, -1) = syscall(SYS_lchown, "foobar", -1, 5005); - // lchown16 ("foobar", -1, 5005) = + //staptest// lchown16 ("foobar", -1, 5005) = #endif close(fd); diff --git a/testsuite/systemtap.syscall/clock.c b/testsuite/systemtap.syscall/clock.c index bc84871d..995d59df 100644 --- a/testsuite/systemtap.syscall/clock.c +++ b/testsuite/systemtap.syscall/clock.c @@ -14,64 +14,64 @@ int main() #ifdef SYS_time syscall(SYS_time, &tt); - // time (XXXX) = NNNN + //staptest// time (XXXX) = NNNN syscall(SYS_time, NULL); - // time (0x[0]+) = NNNN + //staptest// time (0x[0]+) = NNNN #endif t = syscall(SYS_gettimeofday, &tv, NULL); - // gettimeofday (XXXX, 0x[0]+) = 0 + //staptest// gettimeofday (XXXX, 0x[0]+) = 0 settimeofday(&tv, NULL); - // settimeofday (\[NNNN.NNNN\], NULL) = + //staptest// settimeofday (\[NNNN.NNNN\], NULL) = syscall(SYS_clock_gettime, CLOCK_REALTIME, &ts); - // clock_gettime (CLOCK_REALTIME, XXXX) = 0 + //staptest// clock_gettime (CLOCK_REALTIME, XXXX) = 0 syscall(SYS_clock_settime, CLOCK_REALTIME, &ts); - // clock_settime (CLOCK_REALTIME, \[NNNN.NNNN\]) = + //staptest// clock_settime (CLOCK_REALTIME, \[NNNN.NNNN\]) = syscall(SYS_clock_getres, CLOCK_REALTIME, &ts); - // clock_getres (CLOCK_REALTIME, XXXX) = 0 + //staptest// clock_getres (CLOCK_REALTIME, XXXX) = 0 syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts); - // clock_gettime (CLOCK_MONOTONIC, XXXX) = 0 + //staptest// clock_gettime (CLOCK_MONOTONIC, XXXX) = 0 syscall(SYS_clock_settime, CLOCK_MONOTONIC, &ts); - // clock_settime (CLOCK_MONOTONIC, \[NNNN.NNNN\]) = + //staptest// clock_settime (CLOCK_MONOTONIC, \[NNNN.NNNN\]) = syscall(SYS_clock_getres, CLOCK_MONOTONIC, &ts); - // clock_getres (CLOCK_MONOTONIC, XXXX) = 0 + //staptest// clock_getres (CLOCK_MONOTONIC, XXXX) = 0 syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID, &ts); - // clock_gettime (CLOCK_PROCESS_CPUTIME_ID, XXXX) = + //staptest// clock_gettime (CLOCK_PROCESS_CPUTIME_ID, XXXX) = syscall(SYS_clock_settime, CLOCK_PROCESS_CPUTIME_ID, &ts); - // clock_settime (CLOCK_PROCESS_CPUTIME_ID, \[NNNN.NNNN\]) = + //staptest// clock_settime (CLOCK_PROCESS_CPUTIME_ID, \[NNNN.NNNN\]) = syscall(SYS_clock_getres, CLOCK_PROCESS_CPUTIME_ID, &ts); - // clock_getres (CLOCK_PROCESS_CPUTIME_ID, XXXX) = + //staptest// clock_getres (CLOCK_PROCESS_CPUTIME_ID, XXXX) = syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &ts); - // clock_gettime (CLOCK_THREAD_CPUTIME_ID, XXXX) = + //staptest// clock_gettime (CLOCK_THREAD_CPUTIME_ID, XXXX) = syscall(SYS_clock_settime, CLOCK_THREAD_CPUTIME_ID, &ts); - // clock_settime (CLOCK_THREAD_CPUTIME_ID, \[NNNN.NNNN\]) = + //staptest// clock_settime (CLOCK_THREAD_CPUTIME_ID, \[NNNN.NNNN\]) = syscall(SYS_clock_getres, CLOCK_THREAD_CPUTIME_ID, &ts); - // clock_getres (CLOCK_THREAD_CPUTIME_ID, XXXX) = + //staptest// clock_getres (CLOCK_THREAD_CPUTIME_ID, XXXX) = syscall(SYS_clock_gettime, CLOCK_REALTIME, &ts); - // clock_gettime (CLOCK_REALTIME, XXXX) = 0 + //staptest// clock_gettime (CLOCK_REALTIME, XXXX) = 0 ts.tv_sec++; syscall(SYS_clock_nanosleep, CLOCK_REALTIME, TIMER_ABSTIME, &ts); - // clock_nanosleep (CLOCK_REALTIME, TIMER_ABSTIME, \[NNNN.NNNN\], XXXX) = 0 + //staptest// clock_nanosleep (CLOCK_REALTIME, TIMER_ABSTIME, \[NNNN.NNNN\], XXXX) = 0 ts.tv_sec = 0; ts.tv_nsec = 10000; syscall(SYS_clock_nanosleep, CLOCK_REALTIME, 0x0, &ts); - // clock_nanosleep (CLOCK_REALTIME, 0x0, \[NNNN.NNNN\], XXXX) = 0 + //staptest// clock_nanosleep (CLOCK_REALTIME, 0x0, \[NNNN.NNNN\], XXXX) = 0 return 0; } diff --git a/testsuite/systemtap.syscall/dir.c b/testsuite/systemtap.syscall/dir.c index 5de4ce35..3eda8175 100644 --- a/testsuite/systemtap.syscall/dir.c +++ b/testsuite/systemtap.syscall/dir.c @@ -11,43 +11,43 @@ int main() int fd; mkdir("foobar", 0765); - // mkdir ("foobar", 0765) = + //staptest// mkdir ("foobar", 0765) = chdir("foobar"); - // chdir ("foobar") = 0 + //staptest// chdir ("foobar") = 0 chdir(".."); - // chdir ("..") = 0 + //staptest// chdir ("..") = 0 fd = open("foobar", O_RDONLY); - // open ("foobar", O_RDONLY) = NNNN + //staptest// open ("foobar", O_RDONLY) = NNNN fchdir(fd); - // fchdir (NNNN) = 0 + //staptest// fchdir (NNNN) = 0 chdir(".."); - // chdir ("..") = 0 + //staptest// chdir ("..") = 0 close(fd); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 rmdir("foobar"); - // rmdir ("foobar") = 0 + //staptest// rmdir ("foobar") = 0 fd = open(".", O_RDONLY); - // open (".", O_RDONLY) = NNNN + //staptest// open (".", O_RDONLY) = NNNN #ifdef SYS_mkdirat mkdirat(fd, "xyzzy", 0765); - // mkdirat (NNNN, "xyzzy", 0765) = 0 + //staptest// mkdirat (NNNN, "xyzzy", 0765) = 0 #endif close(fd); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 rmdir("xyzzy"); - // rmdir ("xyzzy") = + //staptest// rmdir ("xyzzy") = return 0; } diff --git a/testsuite/systemtap.syscall/forkwait.c b/testsuite/systemtap.syscall/forkwait.c index bf7516f6..b7df4923 100644 --- a/testsuite/systemtap.syscall/forkwait.c +++ b/testsuite/systemtap.syscall/forkwait.c @@ -12,14 +12,14 @@ int main () int status; child = fork(); - // fork () = NNNN + //staptest// fork () = NNNN if (!child) { int i = 0xfffff; while (i > 0) i--; exit(0); } wait4(child, &status, WNOHANG, NULL); - // wait4 (NNNN, XXXX, WNOHANG, XXXX) = NNNN + //staptest// wait4 (NNNN, XXXX, WNOHANG, XXXX) = NNNN return 0; } diff --git a/testsuite/systemtap.syscall/futimes.c b/testsuite/systemtap.syscall/futimes.c index eca1efc7..4b812513 100644 --- a/testsuite/systemtap.syscall/futimes.c +++ b/testsuite/systemtap.syscall/futimes.c @@ -31,20 +31,20 @@ int main() times.actime = 1000000000; times.modtime = 2000000000; syscall(__NR_utime, "foobar", × ); - // utime ("foobar", \[Sun Sep 9 01:46:40 2001, Wed May 18 03:33:20 2033]) + //staptest// utime ("foobar", \[Sun Sep 9 01:46:40 2001, Wed May 18 03:33:20 2033]) #endif /* __NR_utimes */ #ifdef __NR_utimes syscall(__NR_utimes, "foobar", tv); - // utimes ("foobar", \[1000000000.001234\]\[2000000000.005678\]) + //staptest// utimes ("foobar", \[1000000000.001234\]\[2000000000.005678\]) #endif /* __NR_utimes */ #ifdef __NR_futimesat syscall(__NR_futimesat, 7, "foobar", tv); - // futimesat (7, "foobar", \[1000000000.001234\]\[2000000000.005678\]) + //staptest// futimesat (7, "foobar", \[1000000000.001234\]\[2000000000.005678\]) syscall(__NR_futimesat, AT_FDCWD, "foobar", tv); - // futimesat (AT_FDCWD, "foobar", \[1000000000.001234\]\[2000000000.005678\]) + //staptest// futimesat (AT_FDCWD, "foobar", \[1000000000.001234\]\[2000000000.005678\]) #endif /* __NR_futimesat */ #ifdef __NR_utimensat @@ -53,17 +53,17 @@ int main() ts[1].tv_sec = 2000000000; ts[1].tv_nsec = 56780000; syscall(__NR_utimensat, AT_FDCWD, "foobar", ts, 0); - // utimensat (AT_FDCWD, "foobar", \[1000000000.123456789\]\[2000000000.056780000\], 0x0) + //staptest// utimensat (AT_FDCWD, "foobar", \[1000000000.123456789\]\[2000000000.056780000\], 0x0) ts[0].tv_sec = 0; ts[0].tv_nsec = UTIME_NOW; ts[1].tv_sec = 0; ts[1].tv_nsec = UTIME_OMIT; syscall(__NR_utimensat, AT_FDCWD, "foobar", ts, AT_SYMLINK_NOFOLLOW); - // utimensat (AT_FDCWD, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) + //staptest// utimensat (AT_FDCWD, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], AT_SYMLINK_NOFOLLOW) syscall(__NR_utimensat, 22, "foobar", ts, 0x42); - // utimensat (22, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], 0x42) + //staptest// utimensat (22, "foobar", \[UTIME_NOW\]\[UTIME_OMIT\], 0x42) #endif diff --git a/testsuite/systemtap.syscall/itimer.c b/testsuite/systemtap.syscall/itimer.c index 5cebc902..ec2c8f5f 100644 --- a/testsuite/systemtap.syscall/itimer.c +++ b/testsuite/systemtap.syscall/itimer.c @@ -28,27 +28,27 @@ int main() itv.it_value.tv_sec = 1; itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, &old_itv); - // setitimer (ITIMER_REAL, \[0.500000,1.000000\], XXXX) = 0 + //staptest// setitimer (ITIMER_REAL, \[0.500000,1.000000\], XXXX) = 0 itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &itv, NULL); - // setitimer (ITIMER_REAL, \[0.500000,0.000000\], 0x[0]+) = 0 + //staptest// setitimer (ITIMER_REAL, \[0.500000,0.000000\], 0x[0]+) = 0 setitimer(ITIMER_VIRTUAL, &itv, NULL); - // setitimer (ITIMER_VIRTUAL, \[0.500000,0.000000\], 0x[0]+) = 0 + //staptest// setitimer (ITIMER_VIRTUAL, \[0.500000,0.000000\], 0x[0]+) = 0 setitimer(ITIMER_PROF, &itv, NULL); - // setitimer (ITIMER_PROF, \[0.500000,0.000000\], 0x[0]+) = 0 + //staptest// setitimer (ITIMER_PROF, \[0.500000,0.000000\], 0x[0]+) = 0 getitimer(ITIMER_REAL, &itv); - // getitimer (ITIMER_REAL, XXXX) = 0 + //staptest// getitimer (ITIMER_REAL, XXXX) = 0 getitimer(ITIMER_VIRTUAL, &itv); - // getitimer (ITIMER_VIRTUAL, XXXX) = 0 + //staptest// getitimer (ITIMER_VIRTUAL, XXXX) = 0 getitimer(ITIMER_PROF, &itv); - // getitimer (ITIMER_PROF, XXXX) = 0 + //staptest// getitimer (ITIMER_PROF, XXXX) = 0 return 0; } diff --git a/testsuite/systemtap.syscall/link.c b/testsuite/systemtap.syscall/link.c index 81280bf2..72f422cd 100644 --- a/testsuite/systemtap.syscall/link.c +++ b/testsuite/systemtap.syscall/link.c @@ -13,24 +13,24 @@ int main() close(fd); link("foobar", "foobar2"); - // link ("foobar", "foobar2") - // linkat (AT_FDCWD, "foobar", AT_FDCWD, "foobar2", 0x0) = 0 + //staptest// link ("foobar", "foobar2") + //staptest// linkat (AT_FDCWD, "foobar", AT_FDCWD, "foobar2", 0x0) = 0 link("foobar", "foobar"); - // link ("foobar", "foobar") - // linkat (AT_FDCWD, "foobar", AT_FDCWD, "foobar", 0x0) = -NNNN (EEXIST) + //staptest// link ("foobar", "foobar") + //staptest// linkat (AT_FDCWD, "foobar", AT_FDCWD, "foobar", 0x0) = -NNNN (EEXIST) link("nonexist", "foo"); - // link ("nonexist", "foo") - // linkat (AT_FDCWD, "nonexist", AT_FDCWD, "foo", 0x0) = -NNNN (ENOENT) + //staptest// link ("nonexist", "foo") + //staptest// linkat (AT_FDCWD, "nonexist", AT_FDCWD, "foo", 0x0) = -NNNN (ENOENT) symlink("foobar", "Sfoobar"); - // symlink ("foobar", "Sfoobar") - // symlinkat ("foobar", AT_FDCWD, "Sfoobar") = 0 + //staptest// symlink ("foobar", "Sfoobar") + //staptest// symlinkat ("foobar", AT_FDCWD, "Sfoobar") = 0 readlink("Sfoobar", buf, sizeof(buf)); - // readlink ("Sfoobar", XXXX, 128) - // readlinkat (AT_FDCWD, "Sfoobar", XXXX, 128) + //staptest// readlink ("Sfoobar", XXXX, 128) + //staptest// readlinkat (AT_FDCWD, "Sfoobar", XXXX, 128) return 0; } diff --git a/testsuite/systemtap.syscall/mmap.c b/testsuite/systemtap.syscall/mmap.c index a3a0dc34..13145fb2 100644 --- a/testsuite/systemtap.syscall/mmap.c +++ b/testsuite/systemtap.syscall/mmap.c @@ -13,41 +13,41 @@ int main() /* create a file with something in it */ fd = open("foobar",O_WRONLY|O_CREAT|O_TRUNC, 0600); - // open ("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN + //staptest// open ("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN lseek(fd, 1024, SEEK_SET); write(fd, "abcdef", 6); close(fd); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd = open("foobar", O_RDONLY); - // open ("foobar", O_RDONLY) = NNNN + //staptest// open ("foobar", O_RDONLY) = NNNN /* stat for file size */ ret = fstat(fd, &fs); - // fstat (NNNN, XXXX) = 0 + //staptest// fstat (NNNN, XXXX) = 0 r = mmap(NULL, fs.st_size, PROT_READ, MAP_SHARED, fd, 0); - // mmap[2]* (XXXX, 1030, PROT_READ, MAP_SHARED, NNNN, XXXX) = XXXX + //staptest// mmap[2]* (XXXX, 1030, PROT_READ, MAP_SHARED, NNNN, XXXX) = XXXX close(fd); mlock(r, fs.st_size); - // mlock (XXXX, 1030) = 0 + //staptest// mlock (XXXX, 1030) = 0 msync(r, fs.st_size, MS_SYNC); - // msync (XXXX, 1030, MS_SYNC) = 0 + //staptest// msync (XXXX, 1030, MS_SYNC) = 0 munlock(r, fs.st_size); - // munlock (XXXX, 1030) = 0 + //staptest// munlock (XXXX, 1030) = 0 mlockall(MCL_CURRENT); - // mlockall (MCL_CURRENT) = + //staptest// mlockall (MCL_CURRENT) = munlockall(); - // munlockall () = 0 + //staptest// munlockall () = 0 munmap(r, fs.st_size); - // munmap (XXXX, 1030) = 0 + //staptest// munmap (XXXX, 1030) = 0 return 0; } diff --git a/testsuite/systemtap.syscall/mount.c b/testsuite/systemtap.syscall/mount.c index 57ae030f..a59582dd 100644 --- a/testsuite/systemtap.syscall/mount.c +++ b/testsuite/systemtap.syscall/mount.c @@ -17,19 +17,19 @@ int main() { mount ("mount_source", "mount_target", "ext2", MS_BIND|MS_NOATIME|MS_NODIRATIME|MS_NOSUID, "some arguments"); - // mount ("mount_source", "mount_target", "ext2", MS_BIND|MS_NOATIME|MS_NODIRATIME|MS_NOSUID, "some arguments") = -NNNN (ENOENT) + //staptest// mount ("mount_source", "mount_target", "ext2", MS_BIND|MS_NOATIME|MS_NODIRATIME|MS_NOSUID, "some arguments") = -NNNN (ENOENT) umount("umount_target"); - // umount ("umount_target", 0) = -NNNN (ENOENT) + //staptest// umount ("umount_target", 0) = -NNNN (ENOENT) umount2("umount2_target", MNT_FORCE); - // umount ("umount2_target", MNT_FORCE) = -NNNN (ENOENT) + //staptest// umount ("umount2_target", MNT_FORCE) = -NNNN (ENOENT) umount2("umount2_target", MNT_DETACH); - // umount ("umount2_target", MNT_DETACH) = -NNNN (ENOENT) + //staptest// umount ("umount2_target", MNT_DETACH) = -NNNN (ENOENT) umount2("umount2_target", MNT_EXPIRE); - // umount ("umount2_target", MNT_EXPIRE) = -NNNN (ENOENT) + //staptest// umount ("umount2_target", MNT_EXPIRE) = -NNNN (ENOENT) return 0; } diff --git a/testsuite/systemtap.syscall/net1.c b/testsuite/systemtap.syscall/net1.c index 219a3860..f8079ffd 100644 --- a/testsuite/systemtap.syscall/net1.c +++ b/testsuite/systemtap.syscall/net1.c @@ -13,12 +13,12 @@ int main() listenfd = socket(AF_INET, SOCK_STREAM, 0); - // socket (PF_INET, SOCK_STREAM, 0) = NNNN + //staptest// socket (PF_INET, SOCK_STREAM, 0) = NNNN flags = fcntl(listenfd, F_GETFL, 0); - // fcntl[64]* (NNNN, F_GETFL, 0x[0]+) = NNNN + //staptest// fcntl[64]* (NNNN, F_GETFL, 0x[0]+) = NNNN fcntl(listenfd, F_SETFL, flags | O_NONBLOCK); - // fcntl[64]* (NNNN, F_SETFL, XXXX) = 0 + //staptest// fcntl[64]* (NNNN, F_SETFL, XXXX) = 0 bzero(&sa, sizeof(sa)); sa.sin_family=AF_INET; @@ -26,13 +26,13 @@ int main() sa.sin_port = htons(8765); bind(listenfd, (struct sockaddr *)&sa, sizeof(sa)); - // bind (NNNN, {AF_INET, 0.0.0.0, 8765}, 16) = 0 + //staptest// bind (NNNN, {AF_INET, 0.0.0.0, 8765}, 16) = 0 listen (listenfd, 7); - // listen (NNNN, 7) = 0 + //staptest// listen (NNNN, 7) = 0 cfd = accept(listenfd, (struct sockaddr *)NULL, NULL); - // accept (NNNN, 0x[0]+, 0x[0]+) = -NNNN (EAGAIN) + //staptest// accept (NNNN, 0x[0]+, 0x[0]+) = -NNNN (EAGAIN) close(cfd); close(listenfd); diff --git a/testsuite/systemtap.syscall/openclose.c b/testsuite/systemtap.syscall/openclose.c index a35f1a59..cb003a9e 100644 --- a/testsuite/systemtap.syscall/openclose.c +++ b/testsuite/systemtap.syscall/openclose.c @@ -13,46 +13,46 @@ int main() int fd1, fd2; fd2 = creat("foobar1",S_IREAD|S_IWRITE); - // open ("foobar1", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN + //staptest// open ("foobar1", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN fd1 = open("foobar2",O_WRONLY|O_CREAT, S_IRWXU); - // open ("foobar2", O_WRONLY|O_CREAT, 0700) = NNNN + //staptest// open ("foobar2", O_WRONLY|O_CREAT, 0700) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd1 = open("foobar2",O_RDONLY); - // open ("foobar2", O_RDONLY) = NNNN + //staptest// open ("foobar2", O_RDONLY) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd1 = open("foobar2",O_RDWR); - // open ("foobar2", O_RDWR) = NNNN + //staptest// open ("foobar2", O_RDWR) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd1 = open("foobar2",O_APPEND|O_WRONLY); - // open ("foobar2", O_WRONLY|O_APPEND) = NNNN + //staptest// open ("foobar2", O_WRONLY|O_APPEND) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd1 = open("foobar2",O_DIRECT|O_RDWR); - // open ("foobar2", O_RDWR|O_DIRECT) = NNNN + //staptest// open ("foobar2", O_RDWR|O_DIRECT) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 fd1 = open("foobar2",O_NOATIME|O_SYNC|O_RDWR); - // open ("foobar2", O_RDWR|O_NOATIME|O_SYNC) = NNNN + //staptest// open ("foobar2", O_RDWR|O_NOATIME|O_SYNC) = NNNN close(fd1); - // close (NNNN) = 0 + //staptest// close (NNNN) = 0 /* Now test some bad opens */ fd1 = open("/",O_WRONLY); - // open ("/", O_WRONLY) = -NNNN (EISDIR) + //staptest// open ("/", O_WRONLY) = -NNNN (EISDIR) close (fd1); - // close (NNNN) = -NNNN (EBADF) + //staptest// close (NNNN) = -NNNN (EBADF) fd1 = open("foobar2",O_WRONLY|O_CREAT|O_EXCL, S_IRWXU); - // open ("foobar2", O_WRONLY|O_CREAT|O_EXCL, 0700) = -NNNN (EEXIST) + //staptest// open ("foobar2", O_WRONLY|O_CREAT|O_EXCL, 0700) = -NNNN (EEXIST) return 0; } diff --git a/testsuite/systemtap.syscall/poll.c b/testsuite/systemtap.syscall/poll.c index 591c1f74..3caa2b14 100644 --- a/testsuite/systemtap.syscall/poll.c +++ b/testsuite/systemtap.syscall/poll.c @@ -17,21 +17,21 @@ int main() sigaddset(&sigs,SIGUSR2); fd = epoll_create(32); - // epoll_create (32) + //staptest// epoll_create (32) epoll_ctl(fd, EPOLL_CTL_ADD, 13, &ev); - // epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, XXXX) + //staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, XXXX) epoll_wait(fd, &ev, 17,0); - // epoll_wait (NNNN, XXXX, 17, 0) + //staptest// epoll_wait (NNNN, XXXX, 17, 0) close(fd); poll(&pfd, 1, 0); - // poll (XXXX, 1, 0) + //staptest// poll (XXXX, 1, 0) #ifdef SYS_ppoll ppoll(&pfd, 1, &tim, &sigs); - // ppoll (XXXX, 1, \[0.200000000\], XXXX, 8) + //staptest// ppoll (XXXX, 1, \[0.200000000\], XXXX, 8) #endif return 0; diff --git a/testsuite/systemtap.syscall/readwrite.c b/testsuite/systemtap.syscall/readwrite.c index aacd68f2..bd0914cc 100644 --- a/testsuite/systemtap.syscall/readwrite.c +++ b/testsuite/systemtap.syscall/readwrite.c @@ -26,56 +26,56 @@ int main() v[2].iov_len = sizeof(STRING3); fd = open("foobar1",O_WRONLY|O_CREAT, 0666); - // open ("foobar1", O_WRONLY|O_CREAT, 0666) = NNNN + //staptest// open ("foobar1", O_WRONLY|O_CREAT, 0666) = NNNN write(fd,"Hello world", 11); - // write (NNNN, "Hello world", 11) = 11 + //staptest// write (NNNN, "Hello world", 11) = 11 write(fd,"Hello world abcdefghijklmnopqrstuvwxyz 01234567890123456789", 59); - // write (NNNN, "Hello world abcdefghijklmnopqrstuvwxyz 012345"..., 59) = 59 + //staptest// write (NNNN, "Hello world abcdefghijklmnopqrstuvwxyz 012345"..., 59) = 59 pwrite(fd,"Hello Again",11,12); - // pwrite (NNNN, "Hello Again", 11, 12) = 11 + //staptest// pwrite (NNNN, "Hello Again", 11, 12) = 11 writev(fd, v, 3); - // writev (NNNN, XXXX, 3) = 15 + //staptest// writev (NNNN, XXXX, 3) = 15 lseek(fd, 0, SEEK_SET); - // lseek (NNNN, 0, SEEK_SET) = 0 + //staptest// lseek (NNNN, 0, SEEK_SET) = 0 lseek(fd, 1, SEEK_CUR); - // lseek (NNNN, 1, SEEK_CUR) = 1 + //staptest// lseek (NNNN, 1, SEEK_CUR) = 1 lseek(fd, -1, SEEK_END); - // lseek (NNNN, -1, SEEK_END) = 84 + //staptest// lseek (NNNN, -1, SEEK_END) = 84 #ifdef SYS__llseek syscall(SYS__llseek, fd, 1, 0, &res, SEEK_SET); - // llseek (NNNN, 0x1, 0x0, XXXX, SEEK_SET) = 0 + //staptest// llseek (NNNN, 0x1, 0x0, XXXX, SEEK_SET) = 0 syscall(SYS__llseek, fd, 0, 0, &res, SEEK_SET); - // llseek (NNNN, 0x0, 0x0, XXXX, SEEK_SET) = 0 + //staptest// llseek (NNNN, 0x0, 0x0, XXXX, SEEK_SET) = 0 syscall(SYS__llseek, fd, 0, 12, &res, SEEK_CUR); - // llseek (NNNN, 0x0, 0xc, XXXX, SEEK_CUR) = 0 + //staptest// llseek (NNNN, 0x0, 0xc, XXXX, SEEK_CUR) = 0 syscall(SYS__llseek, fd, 8, 1, &res, SEEK_END); - // llseek (NNNN, 0x8, 0x1, XXXX, SEEK_END) = 0 + //staptest// llseek (NNNN, 0x8, 0x1, XXXX, SEEK_END) = 0 #endif close (fd); fd = open("foobar1",O_RDONLY); - // open ("foobar1", O_RDONLY) = NNNN + //staptest// open ("foobar1", O_RDONLY) = NNNN read(fd, buf, 11); - // read (NNNN, XXXX, 11) = 11 + //staptest// read (NNNN, XXXX, 11) = 11 read(fd, buf, 50); - // read (NNNN, XXXX, 50) = 50 + //staptest// read (NNNN, XXXX, 50) = 50 pread(fd, buf, 11, 10); - // pread (NNNN, XXXX, 11, 10) = 11 + //staptest// pread (NNNN, XXXX, 11, 10) = 11 x[0].iov_base = buf1; x[0].iov_len = sizeof(STRING1); @@ -84,7 +84,7 @@ int main() x[2].iov_base = buf3; x[2].iov_len = sizeof(STRING3); readv(fd, x, 3); - // readv (NNNN, XXXX, 3) = 15 + //staptest// readv (NNNN, XXXX, 3) = 15 close (fd); diff --git a/testsuite/systemtap.syscall/rt_signal.c b/testsuite/systemtap.syscall/rt_signal.c index f25633b7..537b7706 100644 --- a/testsuite/systemtap.syscall/rt_signal.c +++ b/testsuite/systemtap.syscall/rt_signal.c @@ -20,30 +20,30 @@ int main() sigaddset(&mask, SIGUSR1); sigaddset(&mask, SIGUSR2); sigprocmask(SIG_BLOCK, &mask, NULL); - // rt_sigprocmask (SIG_BLOCK, \[SIGUSR1|SIGUSR2\], 0x[0]+, 8) = 0 + //staptest// rt_sigprocmask (SIG_BLOCK, \[SIGUSR1|SIGUSR2\], 0x[0]+, 8) = 0 sigdelset(&mask, SIGUSR2); sigprocmask(SIG_UNBLOCK, &mask, NULL); - // rt_sigprocmask (SIG_UNBLOCK, \[SIGUSR1\], 0x[0]+, 8) = 0 + //staptest// rt_sigprocmask (SIG_UNBLOCK, \[SIGUSR1\], 0x[0]+, 8) = 0 sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGALRM); sa.sa_flags = 0; sigaction(SIGUSR1, &sa, NULL); - // rt_sigaction (SIGUSR1, {SIG_IGN}, 0x[0]+, 8) = 0 + //staptest// rt_sigaction (SIGUSR1, {SIG_IGN}, 0x[0]+, 8) = 0 sa.sa_handler = SIG_DFL; sigaction(SIGUSR1, &sa, NULL); - // rt_sigaction (SIGUSR1, {SIG_DFL}, 0x[0]+, 8) = 0 + //staptest// rt_sigaction (SIGUSR1, {SIG_DFL}, 0x[0]+, 8) = 0 sa.sa_handler = sig_act_handler; sigaction(SIGUSR1, &sa, NULL); #ifdef __ia64__ - // rt_sigaction (SIGUSR1, {XXXX, [^,]+, \[SIGALRM\]}, 0x[0]+, 8) = 0 + //staptest// rt_sigaction (SIGUSR1, {XXXX, [^,]+, \[SIGALRM\]}, 0x[0]+, 8) = 0 #else - // rt_sigaction (SIGUSR1, {XXXX, [^,]+, XXXX, \[SIGALRM\]}, 0x[0]+, 8) = 0 + //staptest// rt_sigaction (SIGUSR1, {XXXX, [^,]+, XXXX, \[SIGALRM\]}, 0x[0]+, 8) = 0 #endif return 0; diff --git a/testsuite/systemtap.syscall/select.c b/testsuite/systemtap.syscall/select.c index 6ea13a01..088211e2 100644 --- a/testsuite/systemtap.syscall/select.c +++ b/testsuite/systemtap.syscall/select.c @@ -17,20 +17,20 @@ int main() sigaddset(&sigs,SIGUSR2); select( 1, &rfds, NULL, NULL, &tv); - // select (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117\]) + //staptest// select (1, XXXX, 0x[0]+, 0x[0]+, \[0.000117\]) tv.tv_sec = 0; tv.tv_usec = 113; select( 1, NULL, NULL, NULL, &tv); - // select (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113\]) + //staptest// select (1, 0x[0]+, 0x[0]+, 0x[0]+, \[0.000113\]) #ifdef SYS_pselect6 pselect( 1, &rfds, NULL, NULL, &tim, &sigs); - //pselect[67] (1, XXXX, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) + //staptest//pselect[67] (1, XXXX, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) pselect( 0, NULL, NULL, NULL, &tim, &sigs); - // pselect[67] (0, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = + //staptest// pselect[67] (0, 0x[0]+, 0x[0]+, 0x[0]+, \[0.200000000\], XXXX) = #endif return 0; diff --git a/testsuite/systemtap.syscall/sendfile.c b/testsuite/systemtap.syscall/sendfile.c index 06c6b260..690d078e 100644 --- a/testsuite/systemtap.syscall/sendfile.c +++ b/testsuite/systemtap.syscall/sendfile.c @@ -36,7 +36,7 @@ int main () * sendfile will fail. So we test for failure here. */ ret = sendfile (write_fd, read_fd, &offset, stat_buf.st_size); - // sendfile (NNNN, NNNN, XXXX, 512) = -22 (EINVAL) + //staptest// sendfile (NNNN, NNNN, XXXX, 512) = -22 (EINVAL) close (read_fd); close (write_fd); diff --git a/testsuite/systemtap.syscall/signal.c b/testsuite/systemtap.syscall/signal.c index 2c0abe38..e450c6d2 100644 --- a/testsuite/systemtap.syscall/signal.c +++ b/testsuite/systemtap.syscall/signal.c @@ -18,13 +18,13 @@ int main() #ifdef SYS_signal syscall(SYS_signal, SIGUSR1, SIG_IGN); - // signal (SIGUSR1, SIG_IGN) + //staptest// signal (SIGUSR1, SIG_IGN) syscall (SYS_signal, SIGUSR1, SIG_DFL); - // signal (SIGUSR1, SIG_DFL) = 1 + //staptest// signal (SIGUSR1, SIG_DFL) = 1 syscall (SYS_signal, SIGUSR1, sig_act_handler); - // signal (SIGUSR1, XXXX) = 0 + //staptest// signal (SIGUSR1, XXXX) = 0 #endif sigemptyset(&mask); @@ -32,10 +32,10 @@ int main() #ifdef SYS_sigprocmask syscall (SYS_sigprocmask, SIG_BLOCK, &mask, NULL); - // sigprocmask (SIG_BLOCK, XXXX, 0x0+) = 0 + //staptest// sigprocmask (SIG_BLOCK, XXXX, 0x0+) = 0 syscall (SYS_sigprocmask, SIG_UNBLOCK, &mask, NULL); - // sigprocmask (SIG_UNBLOCK, XXXX, 0x0+) = 0 + //staptest// sigprocmask (SIG_UNBLOCK, XXXX, 0x0+) = 0 #endif memset(&sa, 0, sizeof(sa)); @@ -44,12 +44,12 @@ int main() #ifdef SYS_sigaction syscall (SYS_sigaction, SIGUSR1, &sa, NULL); - // sigaction (SIGUSR1, {SIG_IGN}, 0x0+) = 0 + //staptest// sigaction (SIGUSR1, {SIG_IGN}, 0x0+) = 0 #endif #ifdef SYS_tgkill syscall(SYS_tgkill, 1234, 5678, 0); - // tgkill (1234, 5678, SIG_0) + //staptest// tgkill (1234, 5678, SIG_0) #endif return 0; diff --git a/testsuite/systemtap.syscall/stat.c b/testsuite/systemtap.syscall/stat.c index 6be5cc79..d47c1440 100644 --- a/testsuite/systemtap.syscall/stat.c +++ b/testsuite/systemtap.syscall/stat.c @@ -17,38 +17,38 @@ int main() struct utimbuf ubuf; getcwd(cwd, 128); - // getcwd (XXXX, 128) = NNNN + //staptest// getcwd (XXXX, 128) = NNNN fd = creat("foobar",S_IREAD|S_IWRITE); - // open ("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN + //staptest// open ("foobar", O_WRONLY|O_CREAT|O_TRUNC, 0600) = NNNN fstat(fd, &sbuf); - // fstat (NNNN, XXXX) = 0 + //staptest// fstat (NNNN, XXXX) = 0 close(fd); stat("foobar",&sbuf); - // stat ("foobar", XXXX) = 0 + //staptest// stat ("foobar", XXXX) = 0 lstat("foobar",&sbuf); - // lstat ("foobar", XXXX) = 0 + //staptest// lstat ("foobar", XXXX) = 0 ubuf.actime = 1; ubuf.modtime = 1135641600; utime("foobar", &ubuf); #ifdef __ia64__ - // utimes ("foobar", \[1.000000\]\[1135641600.000000\]) = + //staptest// utimes ("foobar", \[1.000000\]\[1135641600.000000\]) = #else - // utime ("foobar", \[Thu Jan 1 00:00:01 1970, Tue Dec 27 00:00:00 2005\]) = 0 + //staptest// utime ("foobar", \[Thu Jan 1 00:00:01 1970, Tue Dec 27 00:00:00 2005\]) = 0 #endif ubuf.actime = 1135690000; ubuf.modtime = 1135700000; utime("foobar", &ubuf); #ifdef __ia64__ - // utimes ("foobar", \[1135690000.000000\]\[1135700000.000000\]) = + //staptest// utimes ("foobar", \[1135690000.000000\]\[1135700000.000000\]) = #else - // utime ("foobar", \[Tue Dec 27 13:26:40 2005, Tue Dec 27 16:13:20 2005\]) = 0 + //staptest// utime ("foobar", \[Tue Dec 27 13:26:40 2005, Tue Dec 27 16:13:20 2005\]) = 0 #endif return 0; } diff --git a/testsuite/systemtap.syscall/statfs.c b/testsuite/systemtap.syscall/statfs.c index ea33193b..eafce77e 100644 --- a/testsuite/systemtap.syscall/statfs.c +++ b/testsuite/systemtap.syscall/statfs.c @@ -8,13 +8,13 @@ int main() { ustat(42, (struct ustat *)0x12345678); - // ustat (42, 0x0*12345678) = + //staptest// ustat (42, 0x0*12345678) = statfs("abc", (struct statfs *)0x12345678); - // statfs ("abc", 0x0*12345678) = + //staptest// statfs ("abc", 0x0*12345678) = fstatfs(77, (struct statfs *)0x12345678); - // fstatfs (77, 0x0*12345678) = + //staptest// fstatfs (77, 0x0*12345678) = return 0; } diff --git a/testsuite/systemtap.syscall/swap.c b/testsuite/systemtap.syscall/swap.c index 3708a477..8fcf9946 100755..100644 --- a/testsuite/systemtap.syscall/swap.c +++ b/testsuite/systemtap.syscall/swap.c @@ -6,22 +6,22 @@ int main() { swapon("foobar_swap", 0); - // swapon ("foobar_swap", 0) = + //staptest// swapon ("foobar_swap", 0) = swapon("foobar_swap", ((1 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER); - // swapon ("foobar_swap", 32769) = + //staptest// swapon ("foobar_swap", 32769) = swapon("foobar_swap", ((7 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER); - // swapon ("foobar_swap", 32775) = + //staptest// swapon ("foobar_swap", 32775) = swapon(0, 0); - // swapon (NULL, 0) = + //staptest// swapon (NULL, 0) = swapoff("foobar_swap"); - // swapoff ("foobar_swap") = + //staptest// swapoff ("foobar_swap") = swapoff(0); - // swapoff (NULL) = + //staptest// swapoff (NULL) = return 0; } diff --git a/testsuite/systemtap.syscall/sync.c b/testsuite/systemtap.syscall/sync.c index 637bc197..d6e22203 100644 --- a/testsuite/systemtap.syscall/sync.c +++ b/testsuite/systemtap.syscall/sync.c @@ -13,13 +13,13 @@ int main() fd = creat("foobar",S_IREAD|S_IWRITE); sync(); - // sync () = 0 + //staptest// sync () = 0 fsync(fd); - // fsync (NNNN) = 0 + //staptest// fsync (NNNN) = 0 fdatasync(fd); - // fdatasync (NNNN) = 0 + //staptest// fdatasync (NNNN) = 0 close(fd); diff --git a/testsuite/systemtap.syscall/syscall.exp b/testsuite/systemtap.syscall/syscall.exp index 2313403f..22e9dc07 100644 --- a/testsuite/systemtap.syscall/syscall.exp +++ b/testsuite/systemtap.syscall/syscall.exp @@ -48,15 +48,9 @@ proc test_procedure {} { set do_32_bit_pass 1 switch -regexp $::tcl_platform(machine) { - ^(x86_64|ppc64)$ { - set flags "additional_flags=-m32" - } - ^s390x$ { - set flags "additional_flags=-m31" - } - ^ia64$ { - set do_32_bit_pass 0 - } + {^(x86_64|ppc64)$} { set flags "additional_flags=-m32" } + {^s390x$} { set flags "additional_flags=-m31" } + {^ia64$} { set do_32_bit_pass 0 } } if {$do_32_bit_pass} { diff --git a/testsuite/systemtap.syscall/test-debug.tcl b/testsuite/systemtap.syscall/test-debug.tcl index 13e0ad54..eb730459 100755 --- a/testsuite/systemtap.syscall/test-debug.tcl +++ b/testsuite/systemtap.syscall/test-debug.tcl @@ -68,7 +68,7 @@ if {$ind == 0} { exit } -if {[catch {exec mktemp -d staptestXXXXX} dir]} { +if {[catch {exec mktemp -d staptestXXXXXX} dir]} { puts stderr "Failed to create temporary directory: $dir" cleanup } diff --git a/testsuite/systemtap.syscall/test.tcl b/testsuite/systemtap.syscall/test.tcl index db0df138..8a5801af 100755 --- a/testsuite/systemtap.syscall/test.tcl +++ b/testsuite/systemtap.syscall/test.tcl @@ -32,7 +32,7 @@ proc run_one_test {filename flags} { set testname [file tail [string range $filename 0 end-2]] set result "UNSUPP" - if {[catch {exec mktemp -d [pwd]/staptestXXXXX} dir]} { + if {[catch {exec mktemp -d [pwd]/staptestXXXXXX} dir]} { puts stderr "Failed to create temporary directory: $dir" cleanup } @@ -40,22 +40,28 @@ proc run_one_test {filename flags} { target_compile $filename $dir/$testname executable $flags set sys_prog "[file dirname [file normalize $filename]]/sys.stp" - set cmd "stap -c $dir/${testname} ${sys_prog}" + set cmd "stap --skip-badvars -c $dir/${testname} ${sys_prog}" # Extract the expected results # Use the preprocessor so we can ifdef tests in and out set ccmd "gcc -E -C -P $filename" + # XXX: but note, this will expand all system headers too! catch {eval exec $ccmd} output set ind 0 foreach line [split $output "\n"] { - if {[regsub {//} $line {} line]} { + if {[regsub {//staptest//} $line {} line]} { set line "$testname: [string trimleft $line]" - + + # We need to quote all these metacharacters regsub -all {\(} $line {\\(} line - regsub -all {\)} $line {\\)} line + regsub -all {\)} $line {\\)} line regsub -all {\|} $line {\|} line + # + and * are metacharacters, but should always be used + # as metacharacters in the expressions, don't escape them. + #regsub -all {\+} $line {\\+} line + #regsub -all {\*} $line {\\*} line regsub -all NNNN $line {[\-0-9]+} line regsub -all XXXX $line {[x0-9a-fA-F]+} line @@ -78,6 +84,7 @@ proc run_one_test {filename flags} { set i 0 foreach line [split $output "\n"] { + # send_log "Comparing $results($i) against $line" if {[regexp $results($i) $line]} { incr i if {$i >= $ind} {break} diff --git a/testsuite/systemtap.syscall/timer.c b/testsuite/systemtap.syscall/timer.c index 947f6a77..9a55b2e8 100644 --- a/testsuite/systemtap.syscall/timer.c +++ b/testsuite/systemtap.syscall/timer.c @@ -13,19 +13,19 @@ int main() struct itimerspec val, oval; syscall(SYS_timer_create, CLOCK_REALTIME, NULL, &tid); - // timer_create (CLOCK_REALTIME, 0x[0]+, XXXX) + //staptest// timer_create (CLOCK_REALTIME, 0x[0]+, XXXX) syscall(SYS_timer_gettime, tid, &val); - // timer_gettime (NNNN, XXXX) + //staptest// timer_gettime (NNNN, XXXX) syscall(SYS_timer_settime, 0, tid, &val, &oval); - // timer_settime (0, NNNN, \[0.000000,0.000000\], XXXX) + //staptest// timer_settime (0, NNNN, \[0.000000,0.000000\], XXXX) syscall(SYS_timer_getoverrun, tid); - // timer_getoverrun (NNNN) + //staptest// timer_getoverrun (NNNN) syscall(SYS_timer_delete, tid); - // timer_delete (NNNN) + //staptest// timer_delete (NNNN) return 0; } diff --git a/testsuite/systemtap.syscall/trunc.c b/testsuite/systemtap.syscall/trunc.c index 39a524a7..ef2b0c68 100644 --- a/testsuite/systemtap.syscall/trunc.c +++ b/testsuite/systemtap.syscall/trunc.c @@ -13,11 +13,11 @@ int main() fd = creat("foobar",S_IREAD|S_IWRITE); ftruncate(fd, 1024); - // ftruncate (NNNN, 1024) = 0 + //staptest// ftruncate (NNNN, 1024) = 0 close(fd); truncate("foobar", 2048); - // truncate ("foobar", 2048) = 0 + //staptest// truncate ("foobar", 2048) = 0 return 0; } diff --git a/testsuite/systemtap.syscall/uid.c b/testsuite/systemtap.syscall/uid.c index 3acb4cb8..6ccf8cdd 100644 --- a/testsuite/systemtap.syscall/uid.c +++ b/testsuite/systemtap.syscall/uid.c @@ -11,54 +11,54 @@ int main () gid_t rgid, egid, sgid; ruid = getuid(); - // getuid () = NNNN + //staptest// getuid () = NNNN euid = geteuid(); - // geteuid () = NNNN + //staptest// geteuid () = NNNN rgid = getgid(); - // getgid () = NNNN + //staptest// getgid () = NNNN egid = getegid(); - // getegid () = NNNN + //staptest// getegid () = NNNN setuid(4096); - // setuid (4096) = NNNN + //staptest// setuid (4096) = NNNN seteuid(4097); - // setresuid (-1, 4097, -1) = NNNN + //staptest// setresuid (-1, 4097, -1) = NNNN getresuid(&ruid, &euid, &suid); - // getresuid (XXXX, XXXX, XXXX) = 0 + //staptest// getresuid (XXXX, XXXX, XXXX) = 0 setgid(4098); - // setgid (4098) = NNNN + //staptest// setgid (4098) = NNNN setegid(4099); - // setresgid (-1, 4099, -1) = NNNN + //staptest// setresgid (-1, 4099, -1) = NNNN getresgid(&rgid, &egid, &sgid); - // getresgid (XXXX, XXXX, XXXX) = 0 + //staptest// getresgid (XXXX, XXXX, XXXX) = 0 setreuid(-1, 5000); - // setreuid (NNNN, 5000) = + //staptest// setreuid (NNNN, 5000) = setreuid(5001, -1); - // setreuid (5001, NNNN) = + //staptest// setreuid (5001, NNNN) = setregid(-1, 5002); - // setregid (NNNN, 5002) = + //staptest// setregid (NNNN, 5002) = setregid(5003, -1); - // setregid (5003, NNNN) = + //staptest// setregid (5003, NNNN) = setfsuid(5004); - // setfsuid (5004) = + //staptest// setfsuid (5004) = setfsgid(5005); - // setfsgid (5005) = + //staptest// setfsgid (5005) = return 0; } diff --git a/testsuite/systemtap.syscall/uid16.c b/testsuite/systemtap.syscall/uid16.c index 2d7d3349..4f2fcff1 100644 --- a/testsuite/systemtap.syscall/uid16.c +++ b/testsuite/systemtap.syscall/uid16.c @@ -17,54 +17,54 @@ int main () gid_t gid, rgid, egid, sgid; uid = syscall(__NR_getuid); - // getuid () = NNNN + //staptest// getuid () = NNNN uid = syscall(__NR_geteuid); - // geteuid () = NNNN + //staptest// geteuid () = NNNN gid = syscall(__NR_getgid); - // getgid () = NNNN + //staptest// getgid () = NNNN gid = syscall(__NR_getegid); - // getegid () = NNNN + //staptest// getegid () = NNNN syscall(__NR_setuid, 4096); - // setuid (4096) = + //staptest// setuid (4096) = syscall(__NR_setresuid, -1, 4097, -1); - // setresuid (-1, 4097, -1) = + //staptest// setresuid (-1, 4097, -1) = syscall(__NR_getresuid, &ruid, &euid, &suid); - // getresuid (XXXX, XXXX, XXXX) = + //staptest// getresuid (XXXX, XXXX, XXXX) = syscall(__NR_setgid, 4098); - // setgid (4098) = + //staptest// setgid (4098) = syscall(__NR_setresgid, -1, 4099, -1); - // setresgid (-1, 4099, -1) = + //staptest// setresgid (-1, 4099, -1) = syscall(__NR_getresgid, &rgid, &egid, &sgid); - // getresgid (XXXX, XXXX, XXXX) = + //staptest// getresgid (XXXX, XXXX, XXXX) = syscall(__NR_setreuid, -1, 5000); - // setreuid (-1, 5000) = + //staptest// setreuid (-1, 5000) = syscall(__NR_setreuid, 5001, -1); - // setreuid (5001, -1) = + //staptest// setreuid (5001, -1) = syscall(__NR_setregid, -1, 5002); - // setregid (-1, 5002) = + //staptest// setregid (-1, 5002) = syscall(__NR_setregid, 5003, -1); - // setregid (5003, -1) = + //staptest// setregid (5003, -1) = syscall(__NR_setfsuid, 5004); - // setfsuid (5004) = + //staptest// setfsuid (5004) = syscall(__NR_setfsgid, 5005); - // setfsgid (5005) = + //staptest// setfsgid (5005) = #endif /* __i386__ */ diff --git a/testsuite/systemtap.syscall/umask.c b/testsuite/systemtap.syscall/umask.c index 5d13575f..0a3d0534 100644 --- a/testsuite/systemtap.syscall/umask.c +++ b/testsuite/systemtap.syscall/umask.c @@ -5,16 +5,16 @@ int main() { umask (0); - // umask (00) = NNNN + //staptest// umask (00) = NNNN umask (7); - // umask (07) = 00 + //staptest// umask (07) = 00 umask (077); - // umask (077) = 07 + //staptest// umask (077) = 07 umask (0666); - // umask (0666) = 077 + //staptest// umask (0666) = 077 umask (0777); - // umask (0777) = 0666 + //staptest// umask (0777) = 0666 umask (01777); - // umask (01777) = 0777 + //staptest// umask (01777) = 0777 return 0; } diff --git a/testsuite/systemtap.syscall/unlink.c b/testsuite/systemtap.syscall/unlink.c index b0d00be8..33fe6157 100644 --- a/testsuite/systemtap.syscall/unlink.c +++ b/testsuite/systemtap.syscall/unlink.c @@ -14,22 +14,22 @@ int main() close (fd1); unlink("foobar1"); - // unlink ("foobar1") = 0 + //staptest// unlink ("foobar1") = 0 unlink("foobar1"); - // unlink ("foobar1") = -NNNN (ENOENT) + //staptest// unlink ("foobar1") = -NNNN (ENOENT) unlink("foobar2"); - // unlink ("foobar2") = -NNNN (ENOENT) + //staptest// unlink ("foobar2") = -NNNN (ENOENT) unlink(0); - // unlink (NULL) = -NNNN (EFAULT) + //staptest// unlink (NULL) = -NNNN (EFAULT) unlink(".."); - // unlink ("..") = -NNNN (EISDIR) + //staptest// unlink ("..") = -NNNN (EISDIR) unlink(""); - // unlink ("") = -NNNN (ENOENT) + //staptest// unlink ("") = -NNNN (ENOENT) return 0; } |