summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--AUTHORS1
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-tcp_connections.xml86
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml2
-rw-r--r--elaborate.cxx3
-rw-r--r--runtime/itrace.c3
-rw-r--r--runtime/ptrace_compatibility.h50
-rw-r--r--tapset/context.stp6
-rw-r--r--tapset/conversions.stp5
-rw-r--r--tapset/s390x/syscalls.stp24
-rw-r--r--tapsets.cxx33
-rwxr-xr-xtestsuite/buildok/maxactive01.stp2
-rwxr-xr-xtestsuite/buildok/thirteen.stp2
-rwxr-xr-xtestsuite/semko/forty.stp2
-rwxr-xr-xtestsuite/semko/fortyone.stp2
-rwxr-xr-xtestsuite/semko/fortytwo.stp2
-rwxr-xr-xtestsuite/semko/maxactive04.stp2
-rwxr-xr-xtestsuite/semko/maxactive05.stp2
-rwxr-xr-xtestsuite/semko/return02.stp2
-rwxr-xr-xtestsuite/semko/thirtyfour.stp4
-rwxr-xr-xtestsuite/semko/twentytwo.stp2
-rwxr-xr-xtestsuite/semok/thirtytwo.stp2
-rwxr-xr-xtestsuite/semok/twentynine.stp2
-rw-r--r--testsuite/systemtap.base/alternatives.exp8
-rw-r--r--testsuite/systemtap.base/cast.exp2
-rw-r--r--testsuite/systemtap.base/cast.stp24
-rw-r--r--testsuite/systemtap.base/flightrec2.exp17
-rw-r--r--testsuite/systemtap.base/flightrec2.stp4
-rw-r--r--testsuite/systemtap.base/maxactive.exp16
-rw-r--r--testsuite/systemtap.base/onoffprobe.stp4
-rw-r--r--testsuite/systemtap.base/optionalprobe.exp9
-rw-r--r--testsuite/systemtap.base/optionalprobe.stp6
-rw-r--r--testsuite/systemtap.base/overload.exp2
-rw-r--r--testsuite/systemtap.base/stmtvars.exp6
-rw-r--r--testsuite/systemtap.base/system_func.stp4
-rw-r--r--testsuite/systemtap.examples/general/para-callgraph.meta4
-rwxr-xr-xtestsuite/systemtap.examples/io/traceio.stp33
37 files changed, 288 insertions, 91 deletions
diff --git a/.mailmap b/.mailmap
index 2bf15895..b55c9ee3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -19,6 +19,7 @@ Graydon Hoare <graydon>
Hien Nguyen <hien>
Jim Keniston <kenistoj>
Josh Stone <jistone>
+Kai Meyer <kai@fiber.net>
Kent Sebastian <ksebasti>
Kevin Stafford <kevinrs>
K.Prasad <prasadkr>
diff --git a/AUTHORS b/AUTHORS
index 4a9182f9..fc1dd65a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -20,6 +20,7 @@ James Bottomley
Jim Keniston
Josh Stone
K.Prasad
+Kai Meyer
Kent Sebastian
Kevin Stafford
Li Guanglei
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-tcp_connections.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-tcp_connections.xml
new file mode 100644
index 00000000..c25465b4
--- /dev/null
+++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-tcp_connections.xml
@@ -0,0 +1,86 @@
+<?xml version='1.0'?>
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+]>
+
+
+ <section id="tcpconnectionssect">
+ <title>Monitoring Incoming TCP Connections</title>
+<indexterm>
+<primary>script examples</primary>
+<secondary>monitoring incoming TCP connections</secondary>
+</indexterm>
+
+<indexterm>
+<primary>examples of SystemTap scripts</primary>
+<secondary>monitoring incoming TCP connections</secondary>
+</indexterm>
+
+<indexterm>
+<primary>monitoring incoming TCP connections</primary>
+<secondary>examples of SystemTap scripts</secondary>
+</indexterm>
+<indexterm>
+ <primary>TCP connections (incoming), monitoring</primary>
+ <secondary>examples of SystemTap scripts</secondary>
+</indexterm>
+<indexterm>
+ <primary>incoming TCP connections, monitoring</primary>
+ <secondary>examples of SystemTap scripts</secondary>
+</indexterm>
+<!--
+<indexterm>
+ <primary>script examples</primary>
+ <secondary>net/socket.c, tracing functions from</secondary>
+</indexterm>
+
+<indexterm>
+ <primary>examples of SystemTap scripts</primary>
+ <secondary>net/socket.c, tracing functions from</secondary>
+</indexterm>
+
+<indexterm>
+ <primary>net/socket.c, tracing functions from</primary>
+ <secondary>examples of SystemTap scripts</secondary>
+</indexterm>
+-->
+
+<para>
+ This section illustrates how to monitor incoming TCP connections. This task is useful in
+ identifying any unauthorized, suspicious, or otherwise unwanted network access requests
+ in real time.
+</para>
+
+<formalpara id="tcpconnections">
+ <title>tcp_connections.stp</title>
+<para>
+<programlisting>
+<xi:include parse="text" href="extras/testsuite/systemtap.examples/network/tcp_connections.stp" xmlns:xi="http://www.w3.org/2001/XInclude" />
+</programlisting>
+</para>
+</formalpara>
+
+<para>
+ While <xref linkend="tcpconnections"/> is running, it will print out the following information
+ about any incoming TCP connections accepted by the system in real time:
+</para>
+
+<itemizedlist>
+ <listitem><para>Current <command>UID</command></para></listitem>
+ <listitem><para><command>CMD</command> - the command accepting the connection</para></listitem>
+ <listitem><para><command>PID</command> of the command</para></listitem>
+ <listitem><para>Port used by the connection</para></listitem>
+ <listitem><para>IP address from which the TCP connection originated</para></listitem>
+</itemizedlist>
+
+
+<example id="tcpconnectionsoutput">
+ <title><xref linkend="tcpconnections"/> Sample Output</title>
+<screen>
+UID CMD PID PORT IP_SOURCE
+0 sshd 3165 22 10.64.0.227
+0 sshd 3165 22 10.64.0.227
+</screen>
+</example>
+
+</section>
+
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
index b18062f3..80e68770 100644
--- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
+++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml
@@ -41,6 +41,8 @@
<para>The following sections showcase scripts that trace network-related functions and build a profile of network activity.</para>
<xi:include href="Useful_Scripts-nettop.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Useful_Scripts-sockettrace.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="Useful_Scripts-tcp_connections.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
</section>
<section id="mainsect-disk">
<title>Disk</title>
diff --git a/elaborate.cxx b/elaborate.cxx
index a1c2e652..f6e1bbbf 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -427,6 +427,9 @@ match_node::find_and_build (systemtap_session& s,
sub_map_iterator_t i = sub.find (match);
if (i == sub.end()) // no match
{
+ if (loc->optional) /* PR10102: to tolerate mismatched optional probe */
+ return;
+
string alternatives;
for (sub_map_iterator_t i = sub.begin(); i != sub.end(); i++)
alternatives += string(" ") + i->first.str();
diff --git a/runtime/itrace.c b/runtime/itrace.c
index 97ba427e..68f85301 100644
--- a/runtime/itrace.c
+++ b/runtime/itrace.c
@@ -18,6 +18,7 @@
#include <linux/sched.h>
#include <linux/rcupdate.h>
#include <linux/utrace.h>
+#include "ptrace_compatibility.h"
/* PR9974: Adapt to struct renaming. */
#ifdef UTRACE_API_VERSION
@@ -143,7 +144,7 @@ static u32 usr_itrace_report_quiesce(enum utrace_resume_action action,
WARN_ON(!ui);
#ifdef UTRACE_ORIG_VERSION
- return (ui->step_flag); // XXX XXX XXX
+ return (ui->step_flag | UTRACE_ACTION_NEWSTATE);
#else
return (event == 0 ? ui->step_flag : UTRACE_RESUME);
#endif
diff --git a/runtime/ptrace_compatibility.h b/runtime/ptrace_compatibility.h
new file mode 100644
index 00000000..939c3b56
--- /dev/null
+++ b/runtime/ptrace_compatibility.h
@@ -0,0 +1,50 @@
+#ifndef _PTRACE_COMPATIBILITY_H_
+#define _PTRACE_COMPATIBILITY_H_
+
+#include <linux/ptrace.h>
+
+/* Older kernel's linux/ptrace.h don't define
+ * arch_has_single_step()/arch_has_block_step(). */
+
+#ifndef arch_has_single_step
+
+#include <linux/tracehook.h>
+
+/**
+ * arch_has_single_step - does this CPU support user-mode single-step?
+ *
+ * If this is defined, then there must be function declarations or
+ * inlines for user_enable_single_step() and user_disable_single_step().
+ * arch_has_single_step() should evaluate to nonzero iff the machine
+ * supports instruction single-step for user mode.
+ * It can be a constant or it can test a CPU feature bit.
+ */
+
+#ifdef ARCH_HAS_SINGLE_STEP
+#define arch_has_single_step() (ARCH_HAS_SINGLE_STEP)
+#else
+#define arch_has_single_step() (0)
+#endif /* ARCH_HAS_SINGLE_STEP */
+
+#endif /* arch_has_single_step */
+
+#ifndef arch_has_block_step
+/**
+ * arch_has_block_step - does this CPU support user-mode block-step?
+ *
+ * If this is defined, then there must be a function declaration or inline
+ * for user_enable_block_step(), and arch_has_single_step() must be defined
+ * too. arch_has_block_step() should evaluate to nonzero iff the machine
+ * supports step-until-branch for user mode. It can be a constant or it
+ * can test a CPU feature bit.
+ */
+
+#ifdef ARCH_HAS_BLOCK_STEP
+#define arch_has_block_step() (ARCH_HAS_BLOCK_STEP)
+#else
+#define arch_has_block_step() (0)
+#endif /* ARCH_HAS_BLOCK_STEP */
+
+#endif /* arch_has_block_step */
+
+#endif /* _PTRACE_COMPATIBILITY_H_ */
diff --git a/tapset/context.stp b/tapset/context.stp
index 6fad3740..fcb60201 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -14,6 +14,12 @@
%{
#include <asm/processor.h>
+
+#if defined(__powerpc64__)
+#if !defined(task_pt_regs)
+#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.regs)
+#endif
+#endif
%}
/**
diff --git a/tapset/conversions.stp b/tapset/conversions.stp
index 70725e9d..31b16821 100644
--- a/tapset/conversions.stp
+++ b/tapset/conversions.stp
@@ -120,6 +120,8 @@ function user_string_n2:string (addr:long, n:long, err_msg:string) %{ /* pure */
(char __user *) (uintptr_t) THIS->addr,
len) < 0)
strlcpy(THIS->__retvalue, THIS->err_msg, MAXSTRINGLEN);
+ else
+ THIS->__retvalue[len - 1] = '\0';
%}
function user_string_n_warn:string (addr:long, n:long) %{ /* pure */
@@ -137,7 +139,8 @@ function user_string_n_warn:string (addr:long, n:long) %{ /* pure */
(void *) (uintptr_t) THIS->addr);
_stp_warn(CONTEXT->error_buffer);
strlcpy (THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
- }
+ } else
+ THIS->__retvalue[len - 1] = '\0';
%}
function user_string_n_quoted:string (addr:long, n:long) %{ /* pure */
diff --git a/tapset/s390x/syscalls.stp b/tapset/s390x/syscalls.stp
index 07cb0577..17988ace 100644
--- a/tapset/s390x/syscalls.stp
+++ b/tapset/s390x/syscalls.stp
@@ -45,19 +45,21 @@ probe syscall.ipc.return = kernel.function("sys_ipc").return ? {
# long old_mmap(struct mmap_arg_struct __user *arg)
# long old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
#
-probe syscall.mmap = kernel.function("old_mmap"),
- kernel.function("old32_mmap")
+probe syscall.mmap = kernel.function("old_mmap") ?,
+ kernel.function("old32_mmap") ?,
+ kernel.function("SyS_s390_old_mmap") ?
{
name = "mmap"
- if (probefunc() == "old_mmap")
+ if ((probefunc() == "old_mmap") || (probefunc() == "SyS_s390_old_mmap"))
argstr = get_mmap_args($arg)
else
argstr = get_32mmap_args($arg)
}
-probe syscall.mmap.return = kernel.function("old_mmap").return,
- kernel.function("old32_mmap").return
+probe syscall.mmap.return = kernel.function("old_mmap").return ?,
+ kernel.function("old32_mmap").return ?,
+ kernel.function("SyS_s390_old_mmap").return ?
{
name = "mmap"
retstr = returnstr(2)
@@ -69,19 +71,21 @@ probe syscall.mmap.return = kernel.function("old_mmap").return,
# long sys_mmap2(struct mmap_arg_struct __user *arg)
# long sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
#
-probe syscall.mmap2 = kernel.function("sys_mmap2"),
- kernel.function("sys32_mmap2")
+probe syscall.mmap2 = kernel.function("sys_mmap2") ?,
+ kernel.function("sys32_mmap2") ?,
+ kernel.function("SyS_mmap2") ?
{
name = "mmap2"
- if (probefunc() == "sys_mmap2")
+ if ((probefunc() == "sys_mmap2") || (probefunc() == "SyS_mmap2"))
argstr = get_mmap_args($arg)
else
argstr = get_32mmap_args($arg)
}
-probe syscall.mmap2.return = kernel.function("sys_mmap2").return,
- kernel.function("sys32_mmap2").return
+probe syscall.mmap2.return = kernel.function("sys_mmap2").return ?,
+ kernel.function("sys32_mmap2").return ?,
+ kernel.function("SyS_mmap2").return ?
{
name = "mmap2"
retstr = returnstr(2)
diff --git a/tapsets.cxx b/tapsets.cxx
index 01b2a45b..eac69322 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2090,6 +2090,13 @@ struct dwflpp
++i;
break;
+ case DW_TAG_enumeration_type:
+ throw semantic_error ("field '"
+ + e->components[i].second
+ + "' vs. enum type "
+ + string(dwarf_diename_integrate (die) ?: "<anonymous type>"),
+ e->tok);
+ break;
case DW_TAG_base_type:
throw semantic_error ("field '"
+ e->components[i].second
@@ -2939,7 +2946,7 @@ dwflpp::has_single_line_record (dwarf_query * q, char const * srcfile, int linen
* only picks up top level stuff (i.e. nothing in a lower scope) */
int
dwflpp::iterate_over_globals (int (* callback)(Dwarf_Die *, void *),
- void * data)
+ void * data)
{
int rc = DWARF_CB_OK;
Dwarf_Die die;
@@ -2951,18 +2958,20 @@ dwflpp::iterate_over_globals (int (* callback)(Dwarf_Die *, void *),
if (dwarf_child(cu, &die) != 0)
return rc;
- do {
- /* We're only currently looking for structures and unions,
+ do
+ /* We're only currently looking for named types,
* although other types of declarations exist */
- if (dwarf_tag(&die) != DW_TAG_structure_type &&
- dwarf_tag(&die) != DW_TAG_union_type)
- continue;
-
- rc = (*callback)(&die, data);
- if (rc != DWARF_CB_OK)
- break;
-
- } while (dwarf_siblingof(&die, &die) == 0);
+ switch (dwarf_tag(&die))
+ {
+ case DW_TAG_base_type:
+ case DW_TAG_enumeration_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_typedef:
+ case DW_TAG_union_type:
+ rc = (*callback)(&die, data);
+ break;
+ }
+ while (rc == DWARF_CB_OK && dwarf_siblingof(&die, &die) == 0);
return rc;
}
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/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/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/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/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp
index deaf3bf8..fb263d7a 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.funtion("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} {
@@ -38,8 +38,8 @@ 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)" }
+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)" }
+if {$rc >= 1} { pass $test } else { fail "$test ($rc)" }
diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp
index 74c4d72a..374132f0 100644
--- a/testsuite/systemtap.base/cast.exp
+++ b/testsuite/systemtap.base/cast.exp
@@ -2,5 +2,5 @@ set test "cast"
set ::result_string {PID OK
PID2 OK
execname OK
-tv_sec 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 6298a06d..e2505000 100644
--- a/testsuite/systemtap.base/cast.stp
+++ b/testsuite/systemtap.base/cast.stp
@@ -25,19 +25,23 @@ probe begin
else
printf("execname \"%s\" != \"%s\"\n", name, cast_name)
- // Compare tv_sec using a generated user module
- sec = 42
- cast_sec = @cast(get_timeval(sec), "timeval", "<sys/time.h>")->tv_sec
- if (sec == cast_sec)
- println("tv_sec OK")
+ // 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("tv_sec %d != %d\n", sec, cast_sec)
+ printf("sa_data %d != %d\n", data, cast_data)
exit()
}
-function get_timeval:long(sec:long) %{
- static struct timeval mytime = {0};
- mytime.tv_sec = THIS->sec;
- THIS->__retvalue = (long)&mytime;
+%{
+#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/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp
index a22ef415..d4481db4 100644
--- a/testsuite/systemtap.base/flightrec2.exp
+++ b/testsuite/systemtap.base/flightrec2.exp
@@ -26,13 +26,12 @@ exec sleep 4
set scnt 0
set cnt1 0
# wait for log files
-spawn ls -sk1
+eval spawn stat -c %s [glob flightlog.out.*]
expect {
-timeout 100
- -re {([0-9]+) flightlog\.out\.[0-9]+} {
+ -re {[0-9]+} {
incr cnt1;
- if {$expect_out(1,string) <= 1028} {incr scnt}
- # 1024 + 4(for inode blocks?)
+ if {$expect_out(buffer) <= 1048576 } {incr scnt}
exp_continue}
timeout { fail "$test (logfile timeout)"}
}
@@ -40,12 +39,12 @@ wait
exec sleep 3
set cnt2 0
# wait for log files
-spawn ls -sk1
+eval spawn stat -c %s [glob flightlog.out.*]
expect {
-timeout 100
- -re {([0-9]+) flightlog\.out\.[0-9]+} {
+ -re {[0-9]+} {
incr cnt2;
- if {$expect_out(1,string) <= 1028} {incr scnt}
+ if {$expect_out(buffer) <= 1048576 } {incr scnt}
exp_continue}
timeout { fail "$test (logfile timeout)"}
}
@@ -57,10 +56,10 @@ if {$cnt1 == 3 && $cnt2 == 3} {
fail "$test (log file numbers ($cnt1, $cnt2))"
}
# check logfile size
-if {$scnt == 6} {
+if {$scnt == $cnt1 + $cnt2 } {
pass "$test (log file size limitation)"
} else {
- fail "$test (log file size ($scnt))"
+ fail "$test (log file size ($scnt != $cnt1 + $cnt2))"
}
exec kill -TERM $pid
# wait for exiting...
diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp
index 9d745f4b..f42c9b8e 100644
--- a/testsuite/systemtap.base/flightrec2.stp
+++ b/testsuite/systemtap.base/flightrec2.stp
@@ -1,5 +1,5 @@
-probe timer.ms(1)
+probe timer.ms(10)
{
- for (j = 0; j < 100; j++)
+ for (j = 0; j < 1000; j++)
printf("1234567890\n")
}
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..239cf6e3
--- /dev/null
+++ b/testsuite/systemtap.base/optionalprobe.stp
@@ -0,0 +1,6 @@
+#! stap
+
+# test optional probe
+
+probe foo ?, bar !, foo* ?, bar* !, 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/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/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.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/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.