* [PATCH] itrace probe documentation in man page, and a testsuite test
@ 2008-07-10 22:26 Dave Nomura
0 siblings, 0 replies; only message in thread
From: Dave Nomura @ 2008-07-10 22:26 UTC (permalink / raw)
To: Frank Ch. Eigler; +Cc: systemtap
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
As requested here is a patch that adds a few lines of documentation to
the stapprobes documentation and a testsuite test.
--
Dave Nomura
LTC Linux Power Toolchain
[-- Attachment #2: itrace2.patch --]
[-- Type: text/plain, Size: 3617 bytes --]
diff -paurN old/ChangeLog new/ChangeLog
--- old/ChangeLog 2008-07-10 12:43:42.000000000 -0500
+++ new/ChangeLog 2008-07-10 13:19:00.000000000 -0500
@@ -1,3 +1,7 @@
+2008-07-10 Dave Nomura <dcnltc@us.ibm.com>
+
+ * stapprobes.5.in : Added documentation of itrace probe.
+
2008-07-10 Frank Ch. Eigler <fche@elastic.org>
PR 6736.
diff -paurN old/systemtap.base/itrace.exp new/systemtap.base/itrace.exp
--- old/systemtap.base/itrace.exp 1969-12-31 18:00:00.000000000 -0600
+++ new/systemtap.base/itrace.exp 2008-07-10 12:32:02.000000000 -0500
@@ -0,0 +1,102 @@
+# 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 -paurN old/testsuite/ChangeLog new/testsuite/ChangeLog
--- old/testsuite/ChangeLog 2008-07-10 12:43:42.000000000 -0500
+++ new/testsuite/ChangeLog 2008-07-10 13:20:19.000000000 -0500
@@ -1,3 +1,7 @@
+2008-07-08 Dave Nomura <dcnltc@us.ibm.com>
+
+ * systemtap.base/itrace.stp: Added simple tests of itrace probe.
+
2008-07-09 Frank Ch. Eigler <fche@elastic.org>
From <James.Bottomley@HansenPartnership.com>:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-07-10 22:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-10 22:26 [PATCH] itrace probe documentation in man page, and a testsuite test Dave Nomura
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).