From 791cf64930579adf9ad72d4a3609c64db5c0f84b Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 6 Aug 2008 15:25:48 -0400 Subject: itrace: move test suite item to appropriate location --- systemtap.base/itrace.exp | 102 ---------------------------------- testsuite/systemtap.base/itrace.exp | 106 ++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 102 deletions(-) delete mode 100644 systemtap.base/itrace.exp create mode 100644 testsuite/systemtap.base/itrace.exp diff --git a/systemtap.base/itrace.exp b/systemtap.base/itrace.exp deleted file mode 100644 index 4b73ac1c..00000000 --- a/systemtap.base/itrace.exp +++ /dev/null @@ -1,102 +0,0 @@ -# itrace test - -# 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 - { - instrs += 1 - if (instrs == 5) - exit() - } - - - probe end { printf("systemtap ending probe\n") - printf("itraced = %%d\n", instrs) - } -} -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) - { - instrs += 1 - if (instrs == 5) - exit() - } - - - probe timer.ms(1) if (start_timer) - { - itrace_on = 1 - } - - probe timer.ms(10) if (start_timer) - { - itrace_on = 0 - } - probe end { printf("systemtap ending probe\n") - printf("itraced = %%d\n", instrs) - } -} -set itrace2_script_output "itraced = 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 -# a cross-device link. We can't use 'ln -s' here, since the kernel -# resolves the symbolic link and reports that /bin/ls is being -# exec'ed (instead of our local copy). -if {[catch {exec cp /bin/ls $exepath} res]} { - fail "unable to copy /bin/ls: $res" - return -} - -# "load" generation function for stap_run. It spawns our own copy of -# /bin/ls, waits 5 seconds, then kills it. -proc run_ls_5_sec {} { - global exepath - - spawn $exepath - set exe_id $spawn_id - after 5000; - exec kill -INT -[exp_pid -i $exe_id] - return 0; -} - - -# 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} { - untested "$TEST_NAME : no kernel utrace support found" -} elseif {![installtest_p]} { - untested "$TEST_NAME : not installtest_p" -} else { - set script [format $itrace1_script $exepath] - stap_run $TEST_NAME run_ls_5_sec $itrace1_script_output -e $script -} - - -set TEST_NAME "itrace2" -if {$utrace_support_found == 0} { - untested "$TEST_NAME : no kernel utrace support found" -} elseif {![installtest_p]} { - untested "$TEST_NAME : not installtest_p" -} else { - set script [format $itrace2_script $exepath] - stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script -} - -# Cleanup -exec rm -f $exepath diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp new file mode 100644 index 00000000..f19af977 --- /dev/null +++ b/testsuite/systemtap.base/itrace.exp @@ -0,0 +1,106 @@ +# 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 + { + instrs += 1 + if (instrs == 5) + exit() + } + + + probe end { printf("systemtap ending probe\n") + printf("itraced = %%d\n", instrs) + } +} +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) + { + instrs += 1 + if (instrs == 5) + exit() + } + + + probe timer.ms(1) if (start_timer) + { + itrace_on = 1 + } + + probe timer.ms(10) if (start_timer) + { + itrace_on = 0 + } + probe end { printf("systemtap ending probe\n") + printf("itraced = %%d\n", instrs) + } +} +set itrace2_script_output "itraced = 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 +# a cross-device link. We can't use 'ln -s' here, since the kernel +# resolves the symbolic link and reports that /bin/ls is being +# exec'ed (instead of our local copy). +if {[catch {exec cp /bin/ls $exepath} res]} { + fail "unable to copy /bin/ls: $res" + return +} + +# "load" generation function for stap_run. It spawns our own copy of +# /bin/ls, waits 5 seconds, then kills it. +proc run_ls_5_sec {} { + global exepath + + spawn $exepath + set exe_id $spawn_id + after 5000; + exec kill -INT -[exp_pid -i $exe_id] + return 0; +} + + +# 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} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + set script [format $itrace1_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace1_script_output -e $script +} + + +set TEST_NAME "itrace2" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + set script [format $itrace2_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script +} + +# Cleanup +exec rm -f $exepath -- cgit From 445cb916dbd5faaa56e106ac23853a710768f0d7 Mon Sep 17 00:00:00 2001 From: Eugeniy Meshcheryakov Date: Wed, 6 Aug 2008 13:46:53 -0700 Subject: Fix minor problems in staprun(8) --- ChangeLog | 6 ++++++ staprun.8.in | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 09e2ff37..88497aef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-06 Josh Stone + + PR 6820 + From Eugeniy Meshcheryakov eugen@debian.org: + * staprun.8.in: fix minor formatting problems + 2008-08-05 Stan Cox * NEWS: Updated $$vars, $$parms, $$locals. diff --git a/staprun.8.in b/staprun.8.in index ca976a4a..c7e77dc4 100644 --- a/staprun.8.in +++ b/staprun.8.in @@ -99,8 +99,7 @@ to compile a script. The .I stap program will report the pathname to the resulting module. .PP -.Vb 1 -\& $ stap \-p4 \-e 'probe begin { printf("Hello World!\\n"); exit() }' +\& $ stap \-p4 \-e \[aq]probe begin { printf("Hello World!\\n"); exit() }\[aq] .br \& /home/user/.systemtap/cache/85/stap_8553d83f78c_265.ko .PP @@ -108,7 +107,6 @@ Run .I staprun with the pathname to the module as an argument. .PP -.Vb 1 \& $ staprun /home/user/.systemtap/cache/85/stap_8553d83f78c_265.ko .br \& Hello World! @@ -161,6 +159,6 @@ user and not be world writable. .SH BUGS Use the Bugzilla link off of the project web page or our mailing list. .nh -.BR http://sources.redhat.com/systemtap/ , . +.BR http://sources.redhat.com/systemtap/ ", " . .hy -- cgit From b20db09e9ea98f63604aa14048a7fb663fb3f804 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 6 Aug 2008 21:02:20 -0400 Subject: client-server: improve random port selection and mdns txt use --- ChangeLog | 8 ++++++++ stap-find-servers | 4 ++-- stap-serverd | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 88497aef..88de8c62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-06 Frank Ch. Eigler + + * stap-find-servers (match_server, client_sysinfo): + Use "sysinfo=...." keyword in mdns TXT record. + * stap-serverd (advertise_presence): Ditto. + (initialization): Locate random usable server port if needed. + (listen): Complain if port turns out to be unusable after all. + 2008-08-06 Josh Stone PR 6820 diff --git a/stap-find-servers b/stap-find-servers index 9e7b633d..fea645bd 100755 --- a/stap-find-servers +++ b/stap-find-servers @@ -87,7 +87,7 @@ function match_server { server_port=`expr "$service_data" : '\[\([^]]*\)\]'` ;; txt ) - server_sysinfo=`expr "$service_data" : '\[\"\([^]]*\)\"\]'` + server_sysinfo=`expr "$service_data" : '\[.*\"\(sysinfo=[^]]*\)\"\]'` ;; * ) break ;; @@ -115,7 +115,7 @@ function client_sysinfo { # Add some info from uname sysinfo_client="`uname -rvm`" fi - echo $sysinfo_client + echo sysinfo=$sysinfo_client } #----------------------------------------------------------------------------- diff --git a/stap-serverd b/stap-serverd index af4b2717..6170eb8f 100755 --- a/stap-serverd +++ b/stap-serverd @@ -26,6 +26,11 @@ function initialization { avahi_type=_stap._tcp port=$1 test "X$port" = "X" && port=65000 + port2=$(($port + 1)) + if netstat -atn | awk '{print $4}' | cut -f2 -d: | egrep -q "^($port|$port2)\$"; then + # Whoops, the port is busy; try another one. + initialization $((1024+($port + $RANDOM)%64000)) + fi } # function: advertise_presence @@ -35,7 +40,7 @@ function advertise_presence { # Build up a string representing our server's properties. # TODO: this needs fleshing out. local sysinfo=`uname -rvm` - local txt="$sysinfo" + local txt="sysinfo=$sysinfo" # Call avahi-publish-service to advertise our presence. avahi-publish-service "Systemtap Compile Server on `uname -n`" \ @@ -65,6 +70,9 @@ function listen { # received (i.e. SIGTERM) will be processed. nc -l $port < $fifo_name | stap-server $((port + 1)) > $fifo_name 2>&1 & wait %nc + if [ $? -ne 0 ]; then + fatal "ERROR: cannot listen on port $port" + fi done } -- cgit From b27554b93d855972c0b8484226fab1253d1472e3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 7 Aug 2008 12:43:39 +0200 Subject: Add meta file tag descriptions to systemtap.examples/README. --- testsuite/ChangeLog | 4 +++ testsuite/systemtap.examples/README | 52 +++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 9dd388ad..0edcb89a 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-08-05 Mark Wielaard + + * systemtap.examples/README: Add meta file tag descriptions. + 2008-08-05 Stan Cox * systemtap.base/warnings.stp: Use relative instead of absolute line. diff --git a/testsuite/systemtap.examples/README b/testsuite/systemtap.examples/README index 6718a55a..e505bdfb 100644 --- a/testsuite/systemtap.examples/README +++ b/testsuite/systemtap.examples/README @@ -5,5 +5,53 @@ Each script should be checked in as executable. The first line should be #! /usr/bin/env stap -There should be an accompanying ".txt" file describing what the -script does and how to use it. +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. + +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") + -- cgit From ea667a9f0d42dad0652563e7b76ce1527ebb9fc3 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 7 Aug 2008 14:24:51 +0200 Subject: Correct futexes.meta name: entry. --- testsuite/systemtap.examples/ChangeLog | 4 ++++ testsuite/systemtap.examples/futexes.meta | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index 7cb39fb9..ca2ffbdd 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,7 @@ +2008-08-07 Mark Wielaard + + * futexes.meta: Correct name: entry. + 2008-08-01 William Cohen * helloworld.meta, traceio2.meta: Tweak test_installcheck. diff --git a/testsuite/systemtap.examples/futexes.meta b/testsuite/systemtap.examples/futexes.meta index 0a34b2d8..ff303122 100644 --- a/testsuite/systemtap.examples/futexes.meta +++ b/testsuite/systemtap.examples/futexes.meta @@ -1,5 +1,5 @@ title: System-Wide Futex Contention -name: futex.stp +name: futexes.stp version: 1.0 author: anonymous keywords: syscall locking futex -- cgit From 1cfd2143ecabdf664b2d61f6d46bfab6fdd77816 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 7 Aug 2008 15:18:14 +0200 Subject: Add new examples-index-gen.pl script and support files. --- testsuite/Makefile.am | 9 +- testsuite/systemtap.examples/ChangeLog | 10 + testsuite/systemtap.examples/examples-index-gen.pl | 290 +++++++++++++++++++++ testsuite/systemtap.examples/html_footer.tmpl | 14 + testsuite/systemtap.examples/html_header.tmpl | 41 +++ testsuite/systemtap.examples/systemtap.css | 164 ++++++++++++ testsuite/systemtap.examples/systemtapcorner.gif | Bin 0 -> 970 bytes testsuite/systemtap.examples/systemtaplogo.png | Bin 0 -> 1860 bytes 8 files changed, 527 insertions(+), 1 deletion(-) create mode 100644 testsuite/systemtap.examples/examples-index-gen.pl create mode 100644 testsuite/systemtap.examples/html_footer.tmpl create mode 100644 testsuite/systemtap.examples/html_header.tmpl create mode 100644 testsuite/systemtap.examples/systemtap.css create mode 100644 testsuite/systemtap.examples/systemtapcorner.gif create mode 100644 testsuite/systemtap.examples/systemtaplogo.png diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 03c70cb6..db278139 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -32,7 +32,14 @@ EXTRA_DIST = execrc config lib systemtap \ parseok parseko semok semko transok transko buildok buildok \ systemtap.syscall systemtap.stress systemtap.string \ systemtap.pass1-4 systemtap.samples systemtap.printf \ - systemtap.maps systemtap.base + systemtap.maps systemtap.base \ + systemtap.examples/examples-index-gen.pl \ + systemtap.examples/systemtap.css \ + systemtap.examples/systemtapcorner.gif \ + systemtap.examples/systemtaplogo.png \ + systemtap.examples/html_footer.tmpl \ + systemtap.examples/html_header.tmpl + # $(srcdir)/These values point the test suite to the install tree, and # are overridden by "make check" from full source/build tree diff --git a/testsuite/systemtap.examples/ChangeLog b/testsuite/systemtap.examples/ChangeLog index ca2ffbdd..fa6a3aa3 100644 --- a/testsuite/systemtap.examples/ChangeLog +++ b/testsuite/systemtap.examples/ChangeLog @@ -1,3 +1,13 @@ +2008-08-07 Mark Wielaard + + * examples-index-gen.pl: New file. + * systemtap.css: Likewise. + * systemtapcorner.gif: Likewise. + * systemtaplogo.png: Likewise. + * html_footer.tmpl: Likewise. + * html_header.tmpl: Likewise. + * Makefile.am (EXTRA_DIST): Add new support files. + 2008-08-07 Mark Wielaard * futexes.meta: Correct name: entry. diff --git a/testsuite/systemtap.examples/examples-index-gen.pl b/testsuite/systemtap.examples/examples-index-gen.pl new file mode 100644 index 00000000..bc12577e --- /dev/null +++ b/testsuite/systemtap.examples/examples-index-gen.pl @@ -0,0 +1,290 @@ +# Generates index files from examples .meta file info. +# 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. + +use strict; +use warnings; + +use File::Copy; +use File::Find; +use File::Path; +use Text::Wrap; + +my $inputdir; +if ($#ARGV >= 0) { + $inputdir = $ARGV[0]; +} else { + $inputdir = "."; +} + +my $outputdir; +if ($#ARGV >= 1) { + $outputdir = $ARGV[1]; +} else { + $outputdir = $inputdir; +} + +my %scripts = (); +print "Parsing .meta files in $inputdir...\n"; +find(\&parse_meta_files, $inputdir); + +my $meta; +my $subsystem; +my %subsystems; +my $keyword; +my %keywords; + +# Adds a formatted meta entry to a given file handle as text. +sub add_meta_txt(*;$) { + my($file,$meta) = @_; + + print $file "$scripts{$meta}{name} - $scripts{$meta}{title}\n"; + + print $file "output: $scripts{$meta}{output}, "; + print $file "exits: $scripts{$meta}{exit}, "; + print $file "status: $scripts{$meta}{status}\n"; + + print $file "subsystem: $scripts{$meta}{subsystem}, "; + print $file "keywords: $scripts{$meta}{keywords}\n\n"; + + $Text::Wrap::columns = 72; + my $description = wrap(' ', ' ', $scripts{$meta}{description}); + print $file "$description\n\n\n"; +} + +# Adds a formatted meta entry to a given file handle as text. +sub add_meta_html(*;$) { + my($file,$meta) = @_; + + my $name = $scripts{$meta}{name}; + print $file "
  • $name "; + print $file "- $scripts{$meta}{title}
    \n"; + + print $file "output: $scripts{$meta}{output}, "; + print $file "exits: $scripts{$meta}{exit}, "; + print $file "status: $scripts{$meta}{status}
    \n"; + + print $file "subsystem: $scripts{$meta}{subsystem}, "; + print $file "keywords: $scripts{$meta}{keywords}
    \n"; + + print $file "

    $scripts{$meta}{description}"; + print $file "

  • \n"; +} + +my $HEADER = "SYSTEMTAP EXAMPLES INDEX\n" + . "(see also subsystem-index.txt, keyword-index.txt)\n\n"; + +my $header_tmpl = "$inputdir/html_header.tmpl"; +open(TEMPLATE, "<$header_tmpl") + || die "couldn't open $header_tmpl, $!"; +my $HTMLHEADER = do { local $/;