summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in8
-rw-r--r--NEWS33
-rwxr-xr-xconfigure4
-rw-r--r--configure.ac2
-rw-r--r--doc/SystemTap_Beginners_Guide/en-US/References.xml2
-rw-r--r--doc/SystemTap_Tapset_Reference/tapsets.tmpl6
-rw-r--r--doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml4
-rwxr-xr-xdtrace2
-rw-r--r--elaborate.cxx3
-rw-r--r--man/stapprobes.kprocess.3stap.in (renamed from man/stapprobes.process.3stap.in)22
-rw-r--r--runtime/loc2c-runtime.h11
-rw-r--r--runtime/sym.c27
-rw-r--r--runtime/sym.h1
-rw-r--r--tapset/DEVGUIDE6
-rw-r--r--tapset/ip.stp46
-rw-r--r--tapset/kprocess.stp (renamed from tapset/process.stp)30
-rw-r--r--tapset/tcp.stp94
-rw-r--r--tapsets.cxx49
-rwxr-xr-xtestsuite/buildok/process-all-probes.stp12
-rwxr-xr-xtestsuite/buildok/process_test.stp12
-rw-r--r--testsuite/systemtap.base/bitfield.exp3
-rw-r--r--testsuite/systemtap.base/bitfield.stp46
-rw-r--r--testsuite/systemtap.base/labels.exp15
-rw-r--r--testsuite/systemtap.examples/index.html3
-rw-r--r--testsuite/systemtap.examples/index.txt8
-rw-r--r--testsuite/systemtap.examples/keyword-index.html6
-rw-r--r--testsuite/systemtap.examples/keyword-index.txt16
-rw-r--r--testsuite/systemtap.examples/network/tcpdumplike.meta12
-rwxr-xr-xtestsuite/systemtap.examples/network/tcpdumplike.stp14
-rwxr-xr-xtestsuite/systemtap.examples/process/proc_snoop.stp12
-rw-r--r--testsuite/systemtap.stress/whitelist.exp1
-rw-r--r--translate.cxx58
34 files changed, 441 insertions, 130 deletions
diff --git a/AUTHORS b/AUTHORS
index 0ed3ed04..a6e54c7b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,5 @@
Ananth N Mavinakayanahalli
+Andre Detsch
Anil Keshavamurthy
Anithra Janakiraman
Breno Leitao
diff --git a/Makefile.am b/Makefile.am
index b4d97e9a..f5fedae1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@ stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap \
staprun.8 \
man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap \
man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap \
-man/stapprobes.pagefault.3stap man/stapprobes.process.3stap \
+man/stapprobes.pagefault.3stap man/stapprobes.kprocess.3stap \
man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap \
man/stapprobes.signal.3stap man/stapprobes.socket.3stap \
man/stapprobes.tcp.3stap man/stapprobes.udp.3stap
diff --git a/Makefile.in b/Makefile.in
index 42bdec7c..a953be51 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -64,7 +64,7 @@ DIST_COMMON = INSTALL NEWS README AUTHORS $(srcdir)/Makefile.in \
$(top_srcdir)/man/stapprobes.nfs.3stap.in \
$(top_srcdir)/man/stapprobes.nfsd.3stap.in \
$(top_srcdir)/man/stapprobes.pagefault.3stap.in \
- $(top_srcdir)/man/stapprobes.process.3stap.in \
+ $(top_srcdir)/man/stapprobes.kprocess.3stap.in \
$(top_srcdir)/man/stapprobes.rpc.3stap.in \
$(top_srcdir)/man/stapprobes.scsi.3stap.in \
$(top_srcdir)/man/stapprobes.signal.3stap.in \
@@ -85,7 +85,7 @@ CONFIG_CLEAN_FILES = stap.1 stapprobes.3stap stapfuncs.3stap \
stapvars.3stap stapex.3stap staprun.8 stap-server.8 \
man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap \
man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap \
- man/stapprobes.pagefault.3stap man/stapprobes.process.3stap \
+ man/stapprobes.pagefault.3stap man/stapprobes.kprocess.3stap \
man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap \
man/stapprobes.signal.3stap man/stapprobes.socket.3stap \
man/stapprobes.tcp.3stap man/stapprobes.udp.3stap \
@@ -303,7 +303,7 @@ man_MANS = stap.1 stapprobes.3stap stapfuncs.3stap stapvars.3stap \
stapex.3stap staprun.8 man/stapprobes.iosched.3stap \
man/stapprobes.netdev.3stap man/stapprobes.nfs.3stap \
man/stapprobes.nfsd.3stap man/stapprobes.pagefault.3stap \
- man/stapprobes.process.3stap man/stapprobes.rpc.3stap \
+ man/stapprobes.kprocess.3stap man/stapprobes.rpc.3stap \
man/stapprobes.scsi.3stap man/stapprobes.signal.3stap \
man/stapprobes.socket.3stap man/stapprobes.tcp.3stap \
man/stapprobes.udp.3stap $(am__append_1)
@@ -457,7 +457,7 @@ man/stapprobes.nfsd.3stap: $(top_builddir)/config.status $(top_srcdir)/man/stapp
cd $(top_builddir) && $(SHELL) ./config.status $@
man/stapprobes.pagefault.3stap: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.pagefault.3stap.in
cd $(top_builddir) && $(SHELL) ./config.status $@
-man/stapprobes.process.3stap: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.process.3stap.in
+man/stapprobes.kprocess.3stap: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.kprocess.3stap.in
cd $(top_builddir) && $(SHELL) ./config.status $@
man/stapprobes.rpc.3stap: $(top_builddir)/config.status $(top_srcdir)/man/stapprobes.rpc.3stap.in
cd $(top_builddir) && $(SHELL) ./config.status $@
diff --git a/NEWS b/NEWS
index 96e14b70..37a424d8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
* What's new
+- The overlapping process.* tapsets are now separated. Those probe points
+ documented in stapprobes(3stap) remain the same. Those that were formerly
+ in stapprobes.process(3stap) have been renamed to kprocess, to reflect
+ their kernel perspective on processes.
+
- The --skip-badvars option now also suppresses run-time error
messages that would otherwise result from erroneous memory accesses.
Such accesses can originate from $context expressions fueled by
@@ -7,20 +12,20 @@
* What's new in version 0.9.5
- - New probes process().insn and process().insn.block that allows
- inspection of the process after each instruction or block of
- instructions executed. So to count the total number of instructions
- a process executes during a run do something like:
- $ stap -e 'global steps; probe process("/bin/ls").insn {steps++}
- probe end {printf("Total instructions: %d\n", steps);}' \
- -c /bin/ls
- This feature can slow down execution of a process somewhat.
-
- - Systemtap probes and function man pages extracted from the tapsets
- are now available under 3stap. To show the page for probe vm.pagefault
- or the stap function pexecname do:
- $ man 3stap vm.pagefault
- $ man 3stap pexecname
+- New probes process().insn and process().insn.block that allows
+ inspection of the process after each instruction or block of
+ instructions executed. So to count the total number of instructions
+ a process executes during a run do something like:
+ $ stap -e 'global steps; probe process("/bin/ls").insn {steps++}
+ probe end {printf("Total instructions: %d\n", steps);}' \
+ -c /bin/ls
+ This feature can slow down execution of a process somewhat.
+
+- Systemtap probes and function man pages extracted from the tapsets
+ are now available under 3stap. To show the page for probe vm.pagefault
+ or the stap function pexecname do:
+ $ man 3stap vm.pagefault
+ $ man 3stap pexecname
- Kernel tracepoints are now supported for probing predefined kernel
events without any debuginfo. Tracepoints incur less overhead than
diff --git a/configure b/configure
index 03763d5a..852dc786 100755
--- a/configure
+++ b/configure
@@ -8074,7 +8074,7 @@ _ACEOF
ac_config_headers="$ac_config_headers config.h:config.in"
-ac_config_files="$ac_config_files Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap staprun.8 stap-server.8 man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap man/stapprobes.pagefault.3stap man/stapprobes.process.3stap man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap man/stapprobes.signal.3stap man/stapprobes.socket.3stap man/stapprobes.tcp.3stap man/stapprobes.udp.3stap initscript/systemtap"
+ac_config_files="$ac_config_files Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap staprun.8 stap-server.8 man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap man/stapprobes.pagefault.3stap man/stapprobes.kprocess.3stap man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap man/stapprobes.signal.3stap man/stapprobes.socket.3stap man/stapprobes.tcp.3stap man/stapprobes.udp.3stap initscript/systemtap"
@@ -8776,7 +8776,7 @@ do
"man/stapprobes.nfs.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.nfs.3stap" ;;
"man/stapprobes.nfsd.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.nfsd.3stap" ;;
"man/stapprobes.pagefault.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.pagefault.3stap" ;;
- "man/stapprobes.process.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.process.3stap" ;;
+ "man/stapprobes.kprocess.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.kprocess.3stap" ;;
"man/stapprobes.rpc.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.rpc.3stap" ;;
"man/stapprobes.scsi.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.scsi.3stap" ;;
"man/stapprobes.signal.3stap") CONFIG_FILES="$CONFIG_FILES man/stapprobes.signal.3stap" ;;
diff --git a/configure.ac b/configure.ac
index ee8ae61f..a953e156 100644
--- a/configure.ac
+++ b/configure.ac
@@ -356,7 +356,7 @@ dnl Don't use this directly (when not given it is set to NONE).
AC_DEFINE_UNQUOTED(STAP_PREFIX, "$prefix", [configure prefix location])
AC_CONFIG_HEADERS([config.h:config.in])
-AC_CONFIG_FILES(Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap staprun.8 stap-server.8 man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap man/stapprobes.pagefault.3stap man/stapprobes.process.3stap man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap man/stapprobes.signal.3stap man/stapprobes.socket.3stap man/stapprobes.tcp.3stap man/stapprobes.udp.3stap initscript/systemtap)
+AC_CONFIG_FILES(Makefile doc/Makefile doc/SystemTap_Tapset_Reference/Makefile stap.1 stapprobes.3stap stapfuncs.3stap stapvars.3stap stapex.3stap staprun.8 stap-server.8 man/stapprobes.iosched.3stap man/stapprobes.netdev.3stap man/stapprobes.nfs.3stap man/stapprobes.nfsd.3stap man/stapprobes.pagefault.3stap man/stapprobes.kprocess.3stap man/stapprobes.rpc.3stap man/stapprobes.scsi.3stap man/stapprobes.signal.3stap man/stapprobes.socket.3stap man/stapprobes.tcp.3stap man/stapprobes.udp.3stap initscript/systemtap)
AC_CONFIG_SUBDIRS(testsuite)
AC_CONFIG_FILES([run-stap], [chmod +x run-stap])
AC_CONFIG_FILES([run-staprun], [chmod +x run-staprun])
diff --git a/doc/SystemTap_Beginners_Guide/en-US/References.xml b/doc/SystemTap_Beginners_Guide/en-US/References.xml
index ff993df2..6ab74f17 100644
--- a/doc/SystemTap_Beginners_Guide/en-US/References.xml
+++ b/doc/SystemTap_Beginners_Guide/en-US/References.xml
@@ -43,7 +43,7 @@
The <filename>stapprobes</filename> man page enumerates a variety of probe points supported by SystemTap, along with additional aliases
defined by the SystemTap tapset library. The bottom of the man page includes a list of other man pages
enumerating similar probe points for specific system components, such as
- <filename>stapprobes.scsi</filename>, <filename>stapprobes.process</filename>,
+ <filename>stapprobes.scsi</filename>, <filename>stapprobes.kprocess</filename>,
<filename>stapprobes.signal</filename>, etc.
</para>
</listitem>
diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
index b7c0713b..19a8e02f 100644
--- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl
+++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
@@ -181,13 +181,13 @@
</para>
!Itapset/socket.stp
</chapter>
- <chapter id="process.stp">
- <title>Process Tapset</title>
+ <chapter id="kprocess.stp">
+ <title>Kernel Process Tapset</title>
<para>
This family of probe points is used to probe process-related activities.
It contains the following probe points:
</para>
-!Itapset/process.stp
+!Itapset/kprocess.stp
</chapter>
<chapter id="signal.stp">
<title>Signal Tapset</title>
diff --git a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
index d497eae6..293a0dc3 100644
--- a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
+++ b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
@@ -64,7 +64,7 @@
<para>
<programlisting>
-probe process.exec = kernel.function("do_execve"),
+probe kprocess.exec = kernel.function("do_execve"),
kernel.function("compat_do_execve")
{<replaceable>probe body</replaceable>}
</programlisting>
@@ -106,7 +106,7 @@ kernel.function("compat_do_execve")
<para>
<programlisting>
-probe process.create = kernel.function("copy_process").return
+probe kprocess.create = kernel.function("copy_process").return
{
task = $return
new_pid = task_pid(task)
diff --git a/dtrace b/dtrace
index fd7b4b99..ca95b678 100755
--- a/dtrace
+++ b/dtrace
@@ -94,7 +94,7 @@ class provider:
########################################################################
def usage ():
- print "Usage " + sys.argv[0] + "[-h | -G] -s File.d -o File {Files}"
+ print "Usage " + sys.argv[0] + " [-h | -G] -s File.d -o File {Files}"
sys.exit(1)
def open_file (arg):
diff --git a/elaborate.cxx b/elaborate.cxx
index 323261c7..b760173f 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -2433,7 +2433,8 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p)
p->body = duv.require(p->body, true);
if (p->body == 0)
{
- if (! s.suppress_warnings)
+ if (! s.suppress_warnings
+ && ! s.timing) // PR10070
s.print_warning ("side-effect-free probe '" + p->name + "'", p->tok);
p->body = new null_statement();
diff --git a/man/stapprobes.process.3stap.in b/man/stapprobes.kprocess.3stap.in
index aa8089e8..4f5e7903 100644
--- a/man/stapprobes.process.3stap.in
+++ b/man/stapprobes.kprocess.3stap.in
@@ -1,7 +1,7 @@
.\" -*- nroff -*-
-.TH STAPPROBES.PROCESS 3stap @DATE@ "Intel, IBM"
+.TH STAPPROBES.KPROCESS 3stap @DATE@ "Intel, IBM"
.SH NAME
-stapprobes.process \- systemtap process probe points
+stapprobes.kprocess \- systemtap kernel process probe points
.\" macros
.de SAMPLE
@@ -18,12 +18,12 @@ stapprobes.process \- systemtap process probe points
.SH DESCRIPTION
-This family of probe points is used to probe the process activities.
+This family of probe points is used to probe the kernel's process activities.
It contains the following probe points:
.P
.TP
-.B process.create
+.B kprocess.create
Fires whenever a new process is successfully created, either as a
result of one of the fork syscall variants, or a new kernel thread.
@@ -38,7 +38,7 @@ result of one of the fork syscall variants, or a new kernel thread.
.P
.TP
-.B process.start
+.B kprocess.start
Fires immediately before a new process begins execution.
@@ -48,7 +48,7 @@ Fires immediately before a new process begins execution.
.P
.TP
-.B process.exec
+.B kprocess.exec
Fires whenever a process attempts to exec to a new program
@@ -59,7 +59,7 @@ Fires whenever a process attempts to exec to a new program
.P
.TP
-.B process.exec_complete
+.B kprocess.exec_complete
Fires at the completion of an exec call
@@ -73,10 +73,10 @@ Fires at the completion of an exec call
.P
.TP
-.B process.exit
+.B kprocess.exit
Fires when a process terminates. This will always be followed by a
-process.release, though the latter may be delayed if the process
+kprocess.release, though the latter may be delayed if the process
waits in a zombie state.
.B Arguments:
@@ -86,10 +86,10 @@ waits in a zombie state.
.P
.TP
-.B process.release
+.B kprocess.release
Fires when a process is released from the kernel. This always
-follows a process.exit, though it may be delayed somewhat if the
+follows a kprocess.exit, though it may be delayed somewhat if the
process waits in a zombie state.
.B Arguments:
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h
index eaf47cad..620e1615 100644
--- a/runtime/loc2c-runtime.h
+++ b/runtime/loc2c-runtime.h
@@ -29,11 +29,12 @@
& (((__typeof (base)) 1 << (nbits)) - 1))
#define store_bitfield(target, base, higherbits, nbits) \
- target = (target \
- &~ ((((__typeof (base)) 1 << (nbits)) - 1) \
- << (sizeof (base) * 8 - (higherbits) - (nbits))) \
- | ((__typeof (base)) (base) \
- << (sizeof (base) * 8 - (higherbits) - (nbits))))
+ target = ((target \
+ &~ ((((__typeof (target)) 1 << (nbits)) - 1) \
+ << (sizeof (target) * 8 - (higherbits) - (nbits)))) \
+ | ((((__typeof (target)) (base)) \
+ & (((__typeof (target)) 1 << (nbits)) - 1)) \
+ << (sizeof (target) * 8 - (higherbits) - (nbits))))
/* Given a DWARF register number, fetch its intptr_t (long) value from the
diff --git a/runtime/sym.c b/runtime/sym.c
index a2cdd0ff..f6f97ac2 100644
--- a/runtime/sym.c
+++ b/runtime/sym.c
@@ -136,9 +136,7 @@ static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr,
struct _stp_section **sec)
{
void *user = NULL;
- struct _stp_module *m = NULL;
unsigned midx = 0;
- unsigned long closest_section_offset = ~0;
// Try vma matching first if task given.
if (task)
@@ -149,8 +147,9 @@ static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr,
NULL, &user) == 0)
if (user != NULL)
{
- m = (struct _stp_module *)user;
- *sec = &m->sections[0]; // XXX check actual section and relocate
+ struct _stp_module *m = (struct _stp_module *)user;
+ if (sec)
+ *sec = &m->sections[0]; // XXX check actual section and relocate
dbug_sym(1, "found section %s in module %s at 0x%lx\n",
m->sections[0].name, m->name, vm_start);
if (strcmp(".dynamic", m->sections[0].name) == 0)
@@ -164,21 +163,19 @@ static struct _stp_module *_stp_mod_sec_lookup(unsigned long addr,
unsigned secidx;
for (secidx = 0; secidx < _stp_modules[midx]->num_sections; secidx++)
{
- unsigned long this_section_addr;
- unsigned long this_section_offset;
- this_section_addr = _stp_modules[midx]->sections[secidx].addr;
- if (addr < this_section_addr) continue;
- this_section_offset = addr - this_section_addr;
- if (this_section_offset < closest_section_offset)
- {
- closest_section_offset = this_section_offset;
- m = _stp_modules[midx];
+ unsigned long sec_addr;
+ unsigned long sec_size;
+ sec_addr = _stp_modules[midx]->sections[secidx].addr;
+ sec_size = _stp_modules[midx]->sections[secidx].size;
+ if (addr >= sec_addr && addr < sec_addr + sec_size)
+ {
if (sec)
- *sec = & m->sections[secidx];
+ *sec = & _stp_modules[midx]->sections[secidx];
+ return _stp_modules[midx];
}
}
}
- return m;
+ return NULL;
}
diff --git a/runtime/sym.h b/runtime/sym.h
index 586b10ca..80c334fb 100644
--- a/runtime/sym.h
+++ b/runtime/sym.h
@@ -18,6 +18,7 @@ struct _stp_symbol {
struct _stp_section {
const char *name;
unsigned long addr; /* XXX: belongs in per-address-space tables */
+ unsigned long size; /* length of the address space module covers. */
struct _stp_symbol *symbols; /* ordered by address */
unsigned num_symbols;
};
diff --git a/tapset/DEVGUIDE b/tapset/DEVGUIDE
index e6bc3fb8..693521a8 100644
--- a/tapset/DEVGUIDE
+++ b/tapset/DEVGUIDE
@@ -59,8 +59,8 @@ For example, process execs can occur in either the do_execve() or the
compat_do_execve() functions. The following alias inserts probes at the
beginning of those functions:
-probe process.exec = kernel.function("do_execve"),
- kernel.function("compat_do_execve") {
+probe kprocess.exec = kernel.function("do_execve"),
+ kernel.function("compat_do_execve") {
< probe body >
}
@@ -87,7 +87,7 @@ process is retrieved by calling task_pid() and passing it the task_struct
pointer. In this case, the auxiliary function is an embedded C function
that's defined in the task tapset (task.stp).
-probe process.create = kernel.function("copy_process").return {
+probe kprocess.create = kernel.function("copy_process").return {
task = $return
new_pid = task_pid(task)
}
diff --git a/tapset/ip.stp b/tapset/ip.stp
index 1e2e263c..299d88d2 100644
--- a/tapset/ip.stp
+++ b/tapset/ip.stp
@@ -7,6 +7,10 @@
//
// Based on previous work done by Arnaldo Carvalho de Melo <acme@redhat.com>
+%{
+#include <linux/skbuff.h>
+%}
+
/**
* sfunction ip_ntop - returns a string representation from an integer IP number
* @addr: the ip represented as an integer
@@ -30,3 +34,45 @@ function __ip_sock_daddr:long (sock:long)
{
return @cast(sock, "inet_sock")->daddr
}
+
+/* Get the IP header for recent (> 2.6.21) kernels */
+function __get_skb_iphdr_new:long(skb:long)
+%{ /* pure */
+ struct sk_buff *skb;
+ skb = (struct sk_buff *)(long)THIS->skb;
+ /* as done by skb_network_header() */
+ #ifdef NET_SKBUFF_DATA_USES_OFFSET
+ THIS->__retvalue = (long)(kread(&(skb->head)) + kread(&(skb->network_header)));
+ #else
+ THIS->__retvalue = (long)kread(&(skb->network_header));
+ #endif
+ CATCH_DEREF_FAULT();
+%}
+
+/* Get the IP header from a sk_buff struct */
+function __get_skb_iphdr:long(skb:long){
+%( kernel_v < "2.6.21" %?
+ iphdr = @cast(skb, "sk_buff")->nh->raw
+ return iphdr
+%:
+ return __get_skb_iphdr_new(skb)
+%)
+}
+
+/* return the source next layer protocol for a given sk_buff structure */
+function __ip_skb_proto:long (iphdr)
+{
+ return @cast(iphdr, "iphdr")->protocol
+}
+
+/* return the source IP address for a given sk_buff structure */
+function __ip_skb_saddr:long (iphdr)
+{
+ return @cast(iphdr, "iphdr")->saddr
+}
+
+/* return the destination IP address for a given skb */
+function __ip_skb_daddr:long (iphdr)
+{
+ return @cast(iphdr, "iphdr")->daddr
+}
diff --git a/tapset/process.stp b/tapset/kprocess.stp
index e39f740a..316e03ce 100644
--- a/tapset/process.stp
+++ b/tapset/kprocess.stp
@@ -1,4 +1,4 @@
-// process tapset
+// kernel process tapset
// Copyright (C) 2006 Intel Corporation.
//
// This file is part of systemtap, and is free software. You can
@@ -15,7 +15,7 @@ function _IS_ERR:long(ptr:long) %{ /* pure */
/**
- * probe process.create - Fires whenever a new process is successfully created
+ * probe kprocess.create - Fires whenever a new process is successfully created
* @new_pid: The PID of the newly created process
*
* Context:
@@ -24,7 +24,7 @@ function _IS_ERR:long(ptr:long) %{ /* pure */
* Fires whenever a new process is successfully created, either as a result of
* <command>fork</command> (or one of its syscall variants), or a new kernel thread.
*/
-probe process.create = kernel.function("copy_process").return {
+probe kprocess.create = kernel.function("copy_process").return {
task = $return
if (_IS_ERR(task)) next
new_pid = task_pid(task)
@@ -32,7 +32,7 @@ probe process.create = kernel.function("copy_process").return {
/**
- * probe process.start - Starting new process
+ * probe kprocess.start - Starting new process
*
* Context:
* Newly created process.
@@ -40,11 +40,11 @@ probe process.create = kernel.function("copy_process").return {
* Fires immediately before a new process begins execution.
*
*/
-probe process.start = kernel.function("schedule_tail") { }
+probe kprocess.start = kernel.function("schedule_tail") { }
/**
- * probe process.exec - Attempt to exec to a new program
+ * probe kprocess.exec - Attempt to exec to a new program
* @filename: The path to the new executable
*
* Context:
@@ -52,7 +52,7 @@ probe process.start = kernel.function("schedule_tail") { }
*
* Fires whenever a process attempts to exec to a new program.
*/
-probe process.exec =
+probe kprocess.exec =
kernel.function("do_execve"),
kernel.function("compat_do_execve") ?
{
@@ -61,7 +61,7 @@ probe process.exec =
/**
- * probe process.exec_complete - Return from exec to a new program
+ * probe kprocess.exec_complete - Return from exec to a new program
* @errno: The error number resulting from the exec
* @success: A boolean indicating whether the exec was successful
*
@@ -71,7 +71,7 @@ probe process.exec =
*
* Fires at the completion of an exec call.
*/
-probe process.exec_complete =
+probe kprocess.exec_complete =
kernel.function("do_execve").return,
kernel.function("compat_do_execve").return ?
{
@@ -81,23 +81,23 @@ probe process.exec_complete =
/**
- * probe process.exit - Exit from process
+ * probe kprocess.exit - Exit from process
* @code: The exit code of the process
*
* Context:
* The process which is terminating.
*
* Fires when a process terminates. This will always be followed by a
- * process.release, though the latter may be delayed if the process waits in a
+ * kprocess.release, though the latter may be delayed if the process waits in a
* zombie state.
*/
-probe process.exit = kernel.function("do_exit") {
+probe kprocess.exit = kernel.function("do_exit") {
code = $code
}
/**
- * probe process.release - Process released
+ * probe kprocess.release - Process released
* @task: A task handle to the process being released
* @pid: PID of the process being released
*
@@ -106,10 +106,10 @@ probe process.exit = kernel.function("do_exit") {
* termination, else the context of the process itself.
*
* Fires when a process is released from the kernel. This always follows a
- * process.exit, though it may be delayed somewhat if the process waits in a
+ * kprocess.exit, though it may be delayed somewhat if the process waits in a
* zombie state.
*/
-probe process.release = kernel.function("release_task") {
+probe kprocess.release = kernel.function("release_task") {
task = $p
pid = $p->pid;
}
diff --git a/tapset/tcp.stp b/tapset/tcp.stp
index bb96b0cb..2c5dce7e 100644
--- a/tapset/tcp.stp
+++ b/tapset/tcp.stp
@@ -15,6 +15,7 @@
#include <net/sock.h>
#include <net/tcp.h>
#include <net/ip.h>
+#include <linux/skbuff.h>
%}
// Get retransmission timeout in usecs. RTO is initialized from default
@@ -78,6 +79,70 @@ function __tcp_sock_dport:long (sock:long){
return @cast(sock, "inet_sock")->dport
}
+/* returns the TCP header for recent (<2.6.21) kernel */
+function __get_skb_tcphdr_new:long(skb:long)
+%{ /* pure */
+ struct sk_buff *skb;
+ skb = (struct sk_buff *)(long)THIS->skb;
+ /* as done by skb_transport_header() */
+ #ifdef NET_SKBUFF_DATA_USES_OFFSET
+ THIS->__retvalue = (long)(kread(&(skb->head)) + kread(&(skb->transport_header)));
+ #else
+ THIS->__retvalue = (long)kread(&(skb->transport_header));
+ #endif
+ CATCH_DEREF_FAULT();
+%}
+
+/* returns the TCP header for a given sk_buff structure */
+function __get_skb_tcphdr:long(skb:long){
+%( kernel_v < "2.6.21" %?
+ tcphdr = @cast(skb, "sk_buff")->h->raw
+ return tcphdr
+%:
+ return __get_skb_tcphdr_new(skb)
+%)
+}
+
+/* returns TCP URG flag for a given sk_buff structure */
+function __tcp_skb_urg:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->urg
+}
+
+/* returns TCP ACK flag for a given sk_buff structure */
+function __tcp_skb_ack:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->ack
+}
+
+/* returns TCP PSH flag for a given sk_buff structure */
+function __tcp_skb_psh:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->psh
+}
+
+/* returns TCP RST flag for a given sk_buff structure */
+function __tcp_skb_rst:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->rst
+}
+
+/* returns TCP SYN flag for a given sk_buff structure */
+function __tcp_skb_syn:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->syn
+}
+
+/* returns TCP FIN flag for a given sk_buff structure */
+function __tcp_skb_fin:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->fin
+}
+
+/* returns TCP source port for a given sk_buff structure */
+function __tcp_skb_sport:long (tcphdr){
+ return ntohs(@cast(tcphdr, "tcphdr")->source)
+}
+
+/* returns TCP destination port for a given sk_buff structure */
+function __tcp_skb_dport:long (tcphdr){
+ return @cast(tcphdr, "tcphdr")->dest
+}
+
/* return the TCP source port for a given sock */
function __tcp_sock_sport:long (sock:long){
return @cast(sock, "inet_sock")->sport
@@ -300,3 +365,32 @@ probe tcp.setsockopt.return = kernel.function("tcp_setsockopt").return {
ret = $return
}
+/**
+ * probe tcp.receive - Called when a TCP packet is received
+ * @saddr: A string representing the source IP address
+ * @daddr: A string representing the destination IP address
+ * @sport: TCP source port
+ * @dport: TCP destination port
+ * @urg: TCP URG flag
+ * @ack: TCP ACK flag
+ * @psh: TCP PSH flag
+ * @rst: TCP RST flag
+ * @syn: TCP SYN flag
+ * @fin: TCP FIN flag
+ */
+probe tcp.receive = kernel.function("tcp_v4_rcv") {
+ iphdr = __get_skb_iphdr($skb)
+ saddr = ip_ntop(__ip_skb_saddr(iphdr))
+ daddr = ip_ntop(__ip_skb_daddr(iphdr))
+ protocol = __ip_skb_proto(iphdr)
+
+ tcphdr = __get_skb_tcphdr($skb)
+ dport = __tcp_skb_dport(tcphdr)
+ sport = __tcp_skb_sport(tcphdr)
+ urg = __tcp_skb_urg(tcphdr)
+ ack = __tcp_skb_ack(tcphdr)
+ psh = __tcp_skb_psh(tcphdr)
+ rst = __tcp_skb_rst(tcphdr)
+ syn = __tcp_skb_syn(tcphdr)
+ fin = __tcp_skb_fin(tcphdr)
+}
diff --git a/tapsets.cxx b/tapsets.cxx
index 2316a777..c63151e1 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1339,8 +1339,12 @@ struct dwflpp
}
void
- iterate_over_cu_labels (string label_val, string function, Dwarf_Die *cu,
- void *data,
+ iterate_over_cu_labels (string label_val,
+ string function,
+ Dwarf_Die *cu,
+ vector<derived_probe *> & results,
+ probe_point *base_loc,
+ void *data,
void (* callback)(const string &,
const char *,
int,
@@ -1375,7 +1379,7 @@ struct dwflpp
function_name = name;
default:
if (dwarf_haschildren (&die))
- iterate_over_cu_labels (label_val, function, &die, q, callback);
+ iterate_over_cu_labels (label_val, function, &die, results, base_loc, q, callback);
continue;
}
@@ -1420,8 +1424,13 @@ struct dwflpp
int nscopes = 0;
nscopes = dwarf_getscopes_die (&die, &scopes);
if (nscopes > 1)
- callback(function_name.c_str(), file,
- (int)dline, &scopes[1], stmt_addr, q);
+ {
+ callback(function_name.c_str(), file,
+ (int)dline, &scopes[1], stmt_addr, q);
+ if (sess.listing_mode)
+ results.back()->locations[0]->components.push_back
+ (new probe_point::component(TOK_LABEL, new literal_string (name)));
+ }
}
}
while (dwarf_siblingof (&die, &die) == 0);
@@ -1997,7 +2006,7 @@ struct dwflpp
Dwarf_Die *die_mem,
Dwarf_Attribute *attr_mem)
{
- Dwarf_Die *die = die_mem;
+ Dwarf_Die *die = NULL;
Dwarf_Die struct_die;
Dwarf_Attribute temp_attr;
@@ -2006,6 +2015,9 @@ struct dwflpp
if (vardie)
*die_mem = *vardie;
+ if (e->components.empty())
+ return die_mem;
+
static unsigned int func_call_level ;
static unsigned int dwarf_error_flag ; // indicates current error is dwarf error
static unsigned int dwarf_error_count ; // keeps track of no of dwarf errors
@@ -2022,6 +2034,7 @@ struct dwflpp
obstack_printf (pool, "c->last_stmt = %s;", lex_cast_qstring(piece).c_str());
#endif
+ die = die ? dwarf_formref_die (attr_mem, die_mem) : die_mem;
const int typetag = dwarf_tag (die);
switch (typetag)
{
@@ -2179,7 +2192,6 @@ struct dwflpp
/* Now iterate on the type in DIE's attribute. */
if (dwarf_attr_integrate (die, DW_AT_type, attr_mem) == NULL)
throw semantic_error ("cannot get type of field: " + string(dwarf_errmsg (-1)), e->tok);
- die = dwarf_formref_die (attr_mem, die_mem);
}
return die;
}
@@ -2425,13 +2437,12 @@ struct dwflpp
/* Translate the ->bar->baz[NN] parts. */
- Dwarf_Die die_mem, *die = NULL;
- die = dwarf_formref_die (&attr_mem, &die_mem);
+ Dwarf_Die die_mem, *die = dwarf_formref_die (&attr_mem, &die_mem);
die = translate_components (&pool, &tail, pc, e,
die, &die_mem, &attr_mem);
if(!die)
{
- die = dwarf_formref_die (&attr_mem, &vardie);
+ die = dwarf_formref_die (&attr_mem, &die_mem);
stringstream alternatives;
if (die != NULL)
print_members(die,alternatives);
@@ -2507,17 +2518,19 @@ struct dwflpp
/* Translate the ->bar->baz[NN] parts. */
Dwarf_Attribute attr_mem;
- Dwarf_Attribute *attr = dwarf_attr (scope_die, DW_AT_type, &attr_mem);
-
- Dwarf_Die vardie_mem;
- Dwarf_Die *vardie = dwarf_formref_die (attr, &vardie_mem);
+ if (dwarf_attr_integrate (scope_die, DW_AT_type, &attr_mem) == NULL)
+ throw semantic_error("failed to retrieve return value type attribute for "
+ + string(dwarf_diename(scope_die) ?: "<unknown>")
+ + "(" + string(dwarf_diename(cu) ?: "<unknown>")
+ + ")",
+ e->tok);
- Dwarf_Die die_mem, *die = NULL;
+ Dwarf_Die die_mem, *die = dwarf_formref_die (&attr_mem, &die_mem);
die = translate_components (&pool, &tail, pc, e,
- vardie, &die_mem, &attr_mem);
+ die, &die_mem, &attr_mem);
if(!die)
{
- die = dwarf_formref_die (&attr_mem, vardie);
+ die = dwarf_formref_die (&attr_mem, &die_mem);
stringstream alternatives;
if (die != NULL)
print_members(die,alternatives);
@@ -4121,7 +4134,7 @@ query_cu (Dwarf_Die * cudie, void * arg)
{
// If we have a pattern string with target *label*, we
// have to look at labels in all the matched srcfiles.
- q->dw.iterate_over_cu_labels (q->label_val, q->function, q->dw.cu, q, query_statement);
+ q->dw.iterate_over_cu_labels (q->label_val, q->function, q->dw.cu, q->results, q->base_loc, q, query_statement);
}
else
{
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/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/labels.exp b/testsuite/systemtap.base/labels.exp
index 268bb320..88ed4619 100644
--- a/testsuite/systemtap.base/labels.exp
+++ b/testsuite/systemtap.base/labels.exp
@@ -55,8 +55,23 @@ if { $res != "" } {
pass "compiling labels.c -g"
}
+# list of labels
+
+spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")"
+
+wait
+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
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
index 3287458a..a03b8dcc 100644
--- a/testsuite/systemtap.examples/index.html
+++ b/testsuite/systemtap.examples/index.html
@@ -97,6 +97,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>
<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>
diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt
index d538d760..d24232e7 100644
--- a/testsuite/systemtap.examples/index.txt
+++ b/testsuite/systemtap.examples/index.txt
@@ -182,6 +182,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.
+
+
process/errsnoop.stp - tabulate system call errors
keywords: process syscall
diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html
index 2254fd25..e65ed19d 100644
--- a/testsuite/systemtap.examples/keyword-index.html
+++ b/testsuite/systemtap.examples/keyword-index.html
@@ -159,6 +159,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>
@@ -288,6 +291,9 @@ keywords: <a href="keyword-index.html#TRACE">TRACE</a> <a href="keyword-index.ht
<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 8fd8e0d8..40b5276f 100644
--- a/testsuite/systemtap.examples/keyword-index.txt
+++ b/testsuite/systemtap.examples/keyword-index.txt
@@ -281,6 +281,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
@@ -597,6 +605,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/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/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.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/translate.cxx b/translate.cxx
index a22e9a5b..d81287ee 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -4532,9 +4532,14 @@ dump_unwindsyms (Dwfl_Module *m,
}
}
- // Use end as sanity check when resolving symbol addresses.
- Dwarf_Addr end;
- dwfl_module_info (m, NULL, NULL, &end, NULL, NULL, NULL, NULL);
+ // Get the canonical path of the main file for comparison at runtime.
+ // When given directly by the user through -d or in case of the kernel
+ // name and path might differ. path should be used for matching.
+ // Use end as sanity check when resolving symbol addresses and to
+ // calculate size for .dynamic and .absolute sections.
+ const char *mainfile;
+ Dwarf_Addr start, end;
+ dwfl_module_info (m, NULL, &start, &end, NULL, NULL, &mainfile, NULL);
// Look up the relocation basis for symbols
int n = dwfl_module_relocations (m);
@@ -4545,7 +4550,8 @@ dump_unwindsyms (Dwfl_Module *m,
// XXX: unfortunate duplication with tapsets.cxx:emit_address()
typedef map<Dwarf_Addr,const char*> addrmap_t; // NB: plain map, sorted by address
- vector<string> seclist; // encountered relocation bases (section names)
+ vector<pair<string,unsigned> > seclist; // encountered relocation bases
+ // (section names and sizes)
map<unsigned, addrmap_t> addrmap; // per-relocation-base sorted addrmap
Dwarf_Addr extra_offset = 0;
@@ -4588,11 +4594,11 @@ dump_unwindsyms (Dwfl_Module *m,
|| sym.st_value < base)) // before first section.
{
Dwarf_Addr sym_addr = sym.st_value;
+ Dwarf_Addr save_addr = sym_addr;
const char *secname = NULL;
if (n > 0) // only try to relocate if there exist relocation bases
{
- Dwarf_Addr save_addr = sym_addr;
int ki = dwfl_module_relocate_address (m, &sym_addr);
dwfl_assert ("dwfl_module_relocate_address", ki >= 0);
secname = dwfl_module_relocation_info (m, ki, NULL);
@@ -4645,10 +4651,31 @@ dump_unwindsyms (Dwfl_Module *m,
// Compute our section number
unsigned secidx;
for (secidx=0; secidx<seclist.size(); secidx++)
- if (seclist[secidx]==secname) break;
+ if (seclist[secidx].first==secname) break;
if (secidx == seclist.size()) // new section name
- seclist.push_back (secname);
+ {
+ // absolute, dynamic or kernel have just one relocation
+ // section, which covers the whole module address range.
+ unsigned size;
+ if (secidx == 0
+ && (n == 0
+ || (n == 1
+ && (strcmp(secname, ".dynamic") == 0
+ || strcmp(secname, "_stext") == 0))))
+ size = end - start;
+ else
+ {
+ Dwarf_Addr b;
+ Elf_Scn *scn;
+ GElf_Shdr *shdr, shdr_mem;
+ scn = dwfl_module_address_section (m, &save_addr, &b);
+ assert (scn != NULL);
+ shdr = gelf_getshdr(scn, &shdr_mem);
+ size = shdr->sh_size;
+ }
+ seclist.push_back (make_pair(secname,size));
+ }
(addrmap[secidx])[sym_addr] = name;
}
@@ -4709,12 +4736,17 @@ dump_unwindsyms (Dwfl_Module *m,
}
c->output << "static struct _stp_section _stp_module_" << stpmod_idx<< "_sections[] = {\n";
+ // For the kernel, executables (ET_EXEC) or shared libraries (ET_DYN)
+ // there is just one section that covers the whole address space of
+ // the module. For kernel modules (ET_REL) there can be multiple
+ // sections that get relocated separately.
for (unsigned secidx = 0; secidx < seclist.size(); secidx++)
{
c->output << "{\n"
- << ".name = " << lex_cast_qstring(seclist[secidx]) << ",\n"
+ << ".name = " << lex_cast_qstring(seclist[secidx].first) << ",\n"
+ << ".size = 0x" << hex << seclist[secidx].second << dec << ",\n"
<< ".symbols = _stp_module_" << stpmod_idx << "_symbols_" << secidx << ",\n"
- << ".num_symbols = sizeof(_stp_module_" << stpmod_idx << "_symbols_" << secidx << ")/sizeof(struct _stp_symbol)\n"
+ << ".num_symbols = " << addrmap[secidx].size() << "\n"
<< "},\n";
}
c->output << "};\n";
@@ -4722,11 +4754,6 @@ dump_unwindsyms (Dwfl_Module *m,
c->output << "static struct _stp_module _stp_module_" << stpmod_idx << " = {\n";
c->output << ".name = " << lex_cast_qstring (modname) << ", \n";
- // Get the canonical path of the main file for comparison at runtime.
- // When given directly by the user through -d or in case of the kernel
- // name and path might differ. path should be used for matching.
- const char *mainfile;
- dwfl_module_info (m, NULL, NULL, NULL, NULL, NULL, &mainfile, NULL);
mainfile = canonicalize_file_name(mainfile);
c->output << ".path = " << lex_cast_qstring (mainfile) << ",\n";
@@ -4861,7 +4888,8 @@ emit_symbol_data (systemtap_session& s)
{
NULL, /* dwfl_linux_kernel_find_elf, */
dwfl_standard_find_debuginfo,
- dwfl_offline_section_address,
+ NULL, /* ET_REL not supported for user space, only ET_EXEC and ET_DYN.
+ dwfl_offline_section_address, */
(char **) & debuginfo_path
};