diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2008-06-10 16:54:29 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2008-06-10 16:56:37 -0400 |
commit | d57671d335d788aa3a738f7f284bfee30151c86c (patch) | |
tree | c5bafe2246fdb50a60b00a453abf936db2a92012 | |
parent | 3f847830da8905e8d8d2a9f939c8c8274fc0f19b (diff) | |
download | systemtap-steved-d57671d335d788aa3a738f7f284bfee30151c86c.tar.gz systemtap-steved-d57671d335d788aa3a738f7f284bfee30151c86c.tar.xz systemtap-steved-d57671d335d788aa3a738f7f284bfee30151c86c.zip |
PR6470: new argv[] tapset, docs, test cases
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 10 | ||||
-rw-r--r-- | NEWS | 8 | ||||
-rwxr-xr-x | configure | 3 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | parse.cxx | 22 | ||||
-rw-r--r-- | stap.1.in | 1 | ||||
-rw-r--r-- | stapvars.5.in | 45 | ||||
-rw-r--r-- | tapset/ChangeLog | 5 | ||||
-rw-r--r-- | tapset/argv.stp | 48 | ||||
-rw-r--r-- | testsuite/ChangeLog | 6 | ||||
-rwxr-xr-x | testsuite/parseko/preprocess08.stp | 4 | ||||
-rwxr-xr-x | testsuite/parseko/preprocess08b.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/cmd_parse.exp | 37 |
15 files changed, 186 insertions, 22 deletions
@@ -13,6 +13,17 @@ 2008-06-10 Frank Ch. Eigler <fche@elastic.org> PR 6470 + * NEWS: Note argv[] tapset. + * parse.cxx (scan_pp): Better handle premature EOF. + * stapvars.5.in: New file. + * stap.1.in: Mention it. + * Makefile.am (dist_man_MANS): Add stapvars.5. + * configure.ac (AC_CONFIG_FILES): Add stapvars.5.in. + * Makefile.in, configure: Regenerated. + +2008-06-10 Frank Ch. Eigler <fche@elastic.org> + + PR 6470 * parse.cxx (scan_pp): Eliminate expand_args argument to control nested preprocess evaluation. Rewrite to use a combination of exceptions and non-recursion. diff --git a/Makefile.am b/Makefile.am index e3327244..6b5ac6fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DPKGDATADIR='"${pkgdatadir}"' -DPKGLIBDIR= AM_CFLAGS = -D_GNU_SOURCE -fexceptions -Wall -Werror -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -Werror -dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 +dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 bin_PROGRAMS = stap staprun stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ diff --git a/Makefile.in b/Makefile.in index 38b0b79e..af2bea5d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,8 +47,8 @@ DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/config.in $(srcdir)/stap.1.in $(srcdir)/stapex.5.in \ $(srcdir)/stapfuncs.5.in $(srcdir)/stapprobes.5.in \ - $(srcdir)/staprun.8.in $(srcdir)/systemtap.spec.in \ - $(top_srcdir)/configure \ + $(srcdir)/staprun.8.in $(srcdir)/stapvars.5.in \ + $(srcdir)/systemtap.spec.in $(top_srcdir)/configure \ $(top_srcdir)/man/stapprobes.iosched.5.in \ $(top_srcdir)/man/stapprobes.netdev.5.in \ $(top_srcdir)/man/stapprobes.nfs.5.in \ @@ -72,7 +72,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = systemtap.spec stap.1 stapprobes.5 stapfuncs.5 \ - stapex.5 staprun.8 man/stapprobes.iosched.5 \ + stapvars.5 stapex.5 staprun.8 man/stapprobes.iosched.5 \ man/stapprobes.netdev.5 man/stapprobes.nfs.5 \ man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 \ man/stapprobes.process.5 man/stapprobes.rpc.5 \ @@ -270,7 +270,7 @@ pkglibexecdir = ${libexecdir}/${PACKAGE} AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DPKGDATADIR='"${pkgdatadir}"' -DPKGLIBDIR='"$(pkglibexecdir)"' AM_CFLAGS = -D_GNU_SOURCE -fexceptions -Wall -Werror -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -Werror -dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 +dist_man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \ @@ -406,6 +406,8 @@ stapprobes.5: $(top_builddir)/config.status $(srcdir)/stapprobes.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ stapfuncs.5: $(top_builddir)/config.status $(srcdir)/stapfuncs.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ +stapvars.5: $(top_builddir)/config.status $(srcdir)/stapvars.5.in + cd $(top_builddir) && $(SHELL) ./config.status $@ stapex.5: $(top_builddir)/config.status $(srcdir)/stapex.5.in cd $(top_builddir) && $(SHELL) ./config.status $@ staprun.8: $(top_builddir)/config.status $(srcdir)/staprun.8.in @@ -1,5 +1,13 @@ * What's new in version 0.7 +- The vector of script command line arguments is available in a + tapset-provided global array argv[]. It is indexed 1 ... argc, + another global. This can substitute for of preprocessor + directives @NNN that fail at parse time if there are not + enough arguments. + + printf("argv: %s %s %s", argv[1], argv[2], argv[3]) + - .statement("func@file+line") probes are now supported to allow a match relative to the entry of the function incremented by line number. This allows using the same systemtap script if the rest @@ -7267,7 +7267,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h:config.in" -ac_config_files="$ac_config_files Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" +ac_config_files="$ac_config_files Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" subdirs="$subdirs testsuite" @@ -7899,6 +7899,7 @@ do "stap.1") CONFIG_FILES="$CONFIG_FILES stap.1" ;; "stapprobes.5") CONFIG_FILES="$CONFIG_FILES stapprobes.5" ;; "stapfuncs.5") CONFIG_FILES="$CONFIG_FILES stapfuncs.5" ;; + "stapvars.5") CONFIG_FILES="$CONFIG_FILES stapvars.5" ;; "stapex.5") CONFIG_FILES="$CONFIG_FILES stapex.5" ;; "staprun.8") CONFIG_FILES="$CONFIG_FILES staprun.8" ;; "man/stapprobes.iosched.5") CONFIG_FILES="$CONFIG_FILES man/stapprobes.iosched.5" ;; diff --git a/configure.ac b/configure.ac index 3f7686fa..b561cf3a 100644 --- a/configure.ac +++ b/configure.ac @@ -233,7 +233,7 @@ AC_CHECK_HEADERS([tr1/unordered_map]) AC_LANG_POP(C++) AC_CONFIG_HEADERS([config.h:config.in]) -AC_CONFIG_FILES(Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) +AC_CONFIG_FILES(Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) AC_CONFIG_SUBDIRS(testsuite) AC_OUTPUT @@ -350,7 +350,7 @@ parser::scan_pp (bool wildcard) catch (const parse_error &e) { if (result) throw e; // propagate errors if THEN branch taken - m = 0; + continue; } if (m && m->type == tok_operator && m->content == "%(") // nested %( @@ -361,13 +361,11 @@ parser::scan_pp (bool wildcard) if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) nesting --; - if (result && !m) - throw parse_error ("unexpected end-of-file"); - if (result && m) + if (!m) + throw parse_error ("incomplete conditional - missing '%:' or '%)'", t); + if (result) my_enqueued_pp.push_back (m); - if (!result && !m) - // do nothing; probably a parse error in an unkept THEN token - if (!result && m) + if (!result) delete m; // do nothing, just dispose of unkept THEN token continue; @@ -386,7 +384,7 @@ parser::scan_pp (bool wildcard) catch (const parse_error& e) { if (!result) throw e; // propagate errors if ELSE branch taken - m = 0; + continue; } if (m && m->type == tok_operator && m->content == "%(") // nested %( @@ -396,13 +394,11 @@ parser::scan_pp (bool wildcard) if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) nesting --; - if (!result && !m) + if (!m) throw parse_error ("incomplete conditional - missing %)", t); - if (!result && m) + if (!result) my_enqueued_pp.push_back (m); - if (result && !m) - // do nothing; probably a parse error in an unkept ELSE token - if (result && m) + if (result) delete m; // do nothing, just dispose of unkept ELSE token continue; @@ -1050,6 +1050,7 @@ unloading. .SH SEE ALSO .IR stapprobes (5), .IR stapfuncs (5), +.IR stapvars (5), .IR stapex (5), .IR awk (1), .IR gdb (1) diff --git a/stapvars.5.in b/stapvars.5.in new file mode 100644 index 00000000..f0f0bbfc --- /dev/null +++ b/stapvars.5.in @@ -0,0 +1,45 @@ +.\" -*- nroff -*- +.TH STAPVARS 5 @DATE@ "Red Hat" +.SH NAME +stapvars \- systemtap variables + +.SH DESCRIPTION +The following sections enumerate the public variables provided by +standard tapsets installed under @prefix@/share/systemtap/tapset. Each +variable is described with a type, and its behavior/restrictions. +The syntax is the same as printed with the +.IR stap " option " \-p2 . +Examples: + +.TP +example1:long +Variable "example1" contains an integer. + +.TP +example2:string [long] +Variable "example2" is an array of strings, indexed by integers. + +.SS ARGV + +.TP +argc:long +Contains the value of the +.BR +$# +value: the number of command line arguments passed to the systemtap script. +It is initialized with an implicit begin(-1) probe. + +.TP +argv:string [long] +Contains each command line argument as a string. argv[1] will equal @1 if +there was at least one command line argument. Arguments beyond #32 are not +transcribed, and produce a warning message within the begin(-1) probe that +initializes this array. + +.SH FILES +.nh +.IR @prefix@/share/systemtap/tapset +.hy + +.SH SEE ALSO +.IR stap (1) diff --git a/tapset/ChangeLog b/tapset/ChangeLog index 2cff2220..51298ce1 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -7,6 +7,11 @@ * syscalls.stp(syscall.mkdirat): Use _dfd_str() to add support for AT_FDCWD. +2008-06-10 Frank Ch. Eigler <fche@elastic.org> + + PR 6470. + * argv.stp: New tapset. + 2008-06-09 David Smith <dsmith@redhat.com> * x86_64/registers.stp (syscall_nr): Added syscall_nr function. diff --git a/tapset/argv.stp b/tapset/argv.stp new file mode 100644 index 00000000..c941bfc5 --- /dev/null +++ b/tapset/argv.stp @@ -0,0 +1,48 @@ +// argument vector tapset +// 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. + + +global argc = $# +global argv %( $# >= 1 %? [$#] %: [1] %) + +probe begin(-1) { + %( $# == 0 %? argv[0] = "nothing"; delete argv[0] %) # ensure argv is set sometime + %( $# >= 1 %? argv[1]=@1 %) + %( $# >= 2 %? argv[2]=@2 %) + %( $# >= 3 %? argv[3]=@3 %) + %( $# >= 4 %? argv[4]=@4 %) + %( $# >= 5 %? argv[5]=@5 %) + %( $# >= 6 %? argv[6]=@6 %) + %( $# >= 7 %? argv[7]=@7 %) + %( $# >= 8 %? argv[8]=@8 %) + %( $# >= 9 %? argv[9]=@9 %) + %( $# >= 10 %? argv[10]=@10 %) + %( $# >= 11 %? argv[11]=@11 %) + %( $# >= 12 %? argv[12]=@12 %) + %( $# >= 13 %? argv[13]=@13 %) + %( $# >= 14 %? argv[14]=@14 %) + %( $# >= 15 %? argv[15]=@15 %) + %( $# >= 16 %? argv[16]=@16 %) + %( $# >= 17 %? argv[17]=@17 %) + %( $# >= 18 %? argv[18]=@18 %) + %( $# >= 19 %? argv[19]=@19 %) + %( $# >= 20 %? argv[20]=@20 %) + %( $# >= 21 %? argv[21]=@21 %) + %( $# >= 22 %? argv[22]=@22 %) + %( $# >= 23 %? argv[23]=@23 %) + %( $# >= 24 %? argv[24]=@24 %) + %( $# >= 25 %? argv[25]=@25 %) + %( $# >= 26 %? argv[26]=@26 %) + %( $# >= 27 %? argv[27]=@27 %) + %( $# >= 28 %? argv[28]=@28 %) + %( $# >= 29 %? argv[29]=@29 %) + %( $# >= 30 %? argv[30]=@30 %) + %( $# >= 31 %? argv[31]=@31 %) + %( $# >= 32 %? argv[32]=@32 %) + %( $# >= 33 %? warn(sprintf("argv is limited to 32 arguments")) %) +} diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index bdae76e3..48f6fbcb 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-06-10 Frank Ch. Eigler <fche@elastic.org> + + PR 6470. + * parseko/preprocess08.stp, ...08b.stp: Revised/new test. + * systemtap.base/cmd_parse.exp: Added some argv[] tests. + 2008-06-09 Stan Cox <scox@redhat.com> * systemtap.base/stmt_rel.stp: New test. diff --git a/testsuite/parseko/preprocess08.stp b/testsuite/parseko/preprocess08.stp index 6665983d..ba0d68e2 100755 --- a/testsuite/parseko/preprocess08.stp +++ b/testsuite/parseko/preprocess08.stp @@ -1,4 +1,4 @@ #! stap -p1 -# missing "then" token -%( arch == "2.6" %? +# premature EOF during THEN tokens +%( 0 == 0 %? diff --git a/testsuite/parseko/preprocess08b.stp b/testsuite/parseko/preprocess08b.stp new file mode 100755 index 00000000..a9697c28 --- /dev/null +++ b/testsuite/parseko/preprocess08b.stp @@ -0,0 +1,4 @@ +#! stap -p1 + +# premature EOF during ELSE tokens +%( 0 == 1 %? %: diff --git a/testsuite/systemtap.base/cmd_parse.exp b/testsuite/systemtap.base/cmd_parse.exp index cbce0455..e33bfa85 100644 --- a/testsuite/systemtap.base/cmd_parse.exp +++ b/testsuite/systemtap.base/cmd_parse.exp @@ -84,3 +84,40 @@ expect { eof {fail "cmd_parse8: unexpected EOF"} } wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 1 +expect { + -timeout 60 + "1 1" { pass cmd_parse9 } + timeout { fail "cmd_parse9 timeout" } + eof { fail "cmd_parse9 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 5 a b c d +expect { + -timeout 60 + "5 d" { pass cmd_parse10 } + timeout { fail "cmd_parse10 timeout" } + eof { fail "cmd_parse10 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[$1]) exit() }} 10 a b c d +expect { + -timeout 60 + "5 " { pass cmd_parse11 } + timeout { fail "cmd_parse11 timeout" } + eof { fail "cmd_parse11 eof" } +} +wait + +spawn stap -e {probe begin { printf("%d %s\n", argc, argv[0]) exit() }} +expect { + -timeout 60 + "0 " { pass cmd_parse12 } + timeout { fail "cmd_parse12 timeout" } + eof { fail "cmd_parse12 eof" } +} +wait + |