summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--Makefile.in1
-rw-r--r--NEWS39
-rw-r--r--buildrun.cxx36
-rw-r--r--doc/Makefile.in1
-rw-r--r--doc/SystemTap_Tapset_Reference/Makefile.am6
-rw-r--r--doc/SystemTap_Tapset_Reference/Makefile.in7
-rw-r--r--doc/SystemTap_Tapset_Reference/tapsets.tmpl59
-rw-r--r--doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml20
-rwxr-xr-xdoc/Tapset_Reference_Guide/manpager.sh120
-rw-r--r--hash.cxx18
-rw-r--r--hash.h1
-rw-r--r--includes/sys/sdt.h191
-rw-r--r--initscript/README.initscript2
-rw-r--r--initscript/systemtap.in22
-rw-r--r--main.cxx21
-rw-r--r--parse.cxx6
-rw-r--r--runtime/autoconf-find-task-pid.c6
-rw-r--r--runtime/itrace.c56
-rw-r--r--runtime/loc2c-runtime.h25
-rw-r--r--runtime/staprun/common.c218
-rw-r--r--runtime/staprun/mainloop.c60
-rw-r--r--runtime/staprun/relay.c134
-rw-r--r--runtime/staprun/relay_old.c124
-rw-r--r--runtime/staprun/staprun.h29
-rw-r--r--runtime/sym.h1
-rw-r--r--runtime/task_finder.c34
-rw-r--r--runtime/task_finder_vma.c31
-rw-r--r--runtime/transport/control.c7
-rw-r--r--runtime/transport/transport.c20
-rw-r--r--runtime/transport/transport_msgs.h8
-rw-r--r--runtime/uprobes2/uprobes.c6
-rw-r--r--runtime/uprobes2/uprobes.h5
-rw-r--r--runtime/utrace_compatibility.h14
-rwxr-xr-xscripts/kernel-doc6
-rw-r--r--session.h5
-rw-r--r--stap.1.in34
-rw-r--r--stapprobes.5.in13
-rw-r--r--staprun.8.in17
-rw-r--r--systemtap.spec9
-rw-r--r--tapset/aux_syscalls.stp7
-rw-r--r--tapset/context-symbols.stp19
-rw-r--r--tapset/context-unwind.stp16
-rw-r--r--tapset/context.stp77
-rw-r--r--tapset/ioscheduler.stp20
-rw-r--r--tapset/ip.stp32
-rw-r--r--tapset/memory.stp13
-rw-r--r--tapset/networking.stp8
-rw-r--r--tapset/process.stp4
-rw-r--r--tapset/scsi.stp18
-rw-r--r--tapset/signal.stp210
-rw-r--r--tapset/socket.stp74
-rw-r--r--tapset/task.stp24
-rw-r--r--tapset/tcp.stp38
-rw-r--r--tapset/timestamp.stp6
-rw-r--r--tapset/udp.stp46
-rw-r--r--tapsets.cxx285
-rwxr-xr-xtestsuite/buildok/task-embedded.stp4
-rwxr-xr-xtestsuite/buildok/task_test.stp2
-rw-r--r--testsuite/lib/stap_run2.exp23
-rwxr-xr-xtestsuite/semok/badvar.stp7
-rwxr-xr-xtestsuite/semok/cast.stp13
-rw-r--r--testsuite/systemtap.base/cast.exp4
-rw-r--r--testsuite/systemtap.base/cast.stp22
-rw-r--r--testsuite/systemtap.base/itrace.exp7
-rw-r--r--testsuite/systemtap.base/sdt.c2
-rw-r--r--testsuite/systemtap.base/sdt.exp39
-rw-r--r--testsuite/systemtap.base/sdt.stp20
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp28
-rw-r--r--testsuite/systemtap.base/tracepoints.exp3
-rw-r--r--testsuite/systemtap.base/tracepoints.stp23
-rw-r--r--testsuite/systemtap.examples/index.html3
-rw-r--r--testsuite/systemtap.examples/index.txt13
-rw-r--r--testsuite/systemtap.examples/io/ioblktime.meta13
-rwxr-xr-xtestsuite/systemtap.examples/io/ioblktime.stp29
-rw-r--r--testsuite/systemtap.examples/keyword-index.html3
-rw-r--r--testsuite/systemtap.examples/keyword-index.txt13
-rw-r--r--testsuite/systemtap.examples/network/tcp.stp11
-rw-r--r--testsuite/systemtap.samples/ioblocktest.exp11
-rw-r--r--testsuite/systemtap.samples/ioblocktest.stp12
-rw-r--r--translate.cxx48
81 files changed, 1960 insertions, 705 deletions
diff --git a/AUTHORS b/AUTHORS
index 6a20ef72..0ed3ed04 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,7 @@
Ananth N Mavinakayanahalli
Anil Keshavamurthy
Anithra Janakiraman
+Breno Leitao
Charles Spirakis
Dan Horak
Dave Brolley
@@ -21,6 +22,8 @@ K.Prasad
Kent Sebastian
Kevin Stafford
Li Guanglei
+Lubomir Rintel
+Mahesh J Salgaonkar
Mark McLoughlin
Mark Wielaard
Martin Hunt
diff --git a/Makefile.in b/Makefile.in
index 73ef5bac..12a5e6ea 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -288,6 +288,7 @@ staplog_CPPFLAGS = @staplog_CPPFLAGS@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
diff --git a/NEWS b/NEWS
index 08705c81..7ae93675 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,44 @@
* What's new
+- Kernel tracepoints are now supported for probing predefined kernel
+ events without any debuginfo. Tracepoints incur less overhead than
+ kprobes, and context parameters are available with full type
+ information. Any kernel 2.6.28 and later should have defined
+ tracepoints. Try the following to see what's available:
+ $ stap -L 'kernel.trace("*")'
+
+- Typecasting with @cast now supports modules search paths, which is
+ useful in case there are multiple places where the type definition
+ may be found. For example:
+ @cast(sdev, "scsi_device", "kernel:scsi_mod")->sdev_state
+
+- On-file flight recorder is supported. It allows stap to record huge
+ trace log on the disk and to run in background.
+ Passing -F option with -o option runs stap in background mode. In this
+ mode, staprun is detached from console, and stap itself shows staprun's
+ pid and exits.
+ Specifying the max size and the max number of log files are also available
+ by passing -S option. This option has one or two arguments seperated by
+ a comma. The first argument is the max size of a log file in MB. If the
+ size of a log file exceeds it, stap switches to the next log file
+ automatically. The second is how many files are kept on the disk. If the
+ number of log files exceeds it, the oldest log file is removed
+ automatically. The second argument can be omitted.
+
+ For example, this will record output on log files each of them is smaller
+ than 1024MB and keep last 3 logs, in background.
+ % stap -F -o /tmp/staplog -S 1024,3 script.stp
+
+- In guru mode (-g), the kernel probing blacklist is disabled, leaving
+ only a subset - the kernel's own internal kprobe blacklist - to attempt
+ to filter out areas unsafe to probe. The differences may be enough to
+ probe more interrupt handlers.
+
+- Variables unavailable in current context may be skipped by setting a
+ session level flag with command line option --skip-badvars now available.
+ This replaces any dwarf $variable expressions that could not be resolved
+ with literal numeric zeros, along with a warning message.
+
* What's new in version 0.9
- Typecasting is now supported using the @cast operator. A script can
diff --git a/buildrun.cxx b/buildrun.cxx
index b9d648ef..6a266bd2 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -148,6 +148,7 @@ compile_pass (systemtap_session& s)
output_autoconf(s, o, "autoconf-vm-area.c", "STAPCONF_VM_AREA", NULL);
output_autoconf(s, o, "autoconf-procfs-owner.c", "STAPCONF_PROCFS_OWNER", NULL);
output_autoconf(s, o, "autoconf-alloc-percpu-align.c", "STAPCONF_ALLOC_PERCPU_ALIGN", NULL);
+ output_autoconf(s, o, "autoconf-find-task-pid.c", "STAPCONF_FIND_TASK_PID", NULL);
#if 0
/* NB: For now, the performance hit of probe_kernel_read/write (vs. our
@@ -328,7 +329,10 @@ run_pass (systemtap_session& s)
staprun_cmd += "-u ";
if (s.load_only)
- staprun_cmd += "-L ";
+ staprun_cmd += (s.output_file.empty() ? "-L " : "-D ");
+
+ if (!s.size_option.empty())
+ staprun_cmd += "-S " + s.size_option + " ";
staprun_cmd += s.tmpdir + "/" + s.module_name + ".ko";
@@ -380,21 +384,25 @@ make_tracequery(systemtap_session& s, string& name)
// dynamically pull in all tracepoint headers from include/trace/
glob_t trace_glob;
- string glob_str(s.kernel_build_tree + "/include/trace/*.h");
- glob(glob_str.c_str(), 0, NULL, &trace_glob);
- for (unsigned i = 0; i < trace_glob.gl_pathc; ++i)
+ string globs[2] = { "/include/trace/*.h", "/source/include/trace/*.h" };
+ for (unsigned z=0; z<2; z++)
{
- string header(basename(trace_glob.gl_pathv[i]));
-
- // filter out a few known "internal-only" headers
- if (header == "trace_events.h")
- continue;
- if (header.find("_event_types.h") != string::npos)
- continue;
-
- osrc << "#include <trace/" << header << ">" << endl;
+ string glob_str(s.kernel_build_tree + globs[z]);
+ glob(glob_str.c_str(), 0, NULL, &trace_glob);
+ for (unsigned i = 0; i < trace_glob.gl_pathc; ++i)
+ {
+ string header(basename(trace_glob.gl_pathv[i]));
+
+ // filter out a few known "internal-only" headers
+ if (header == "trace_events.h")
+ continue;
+ if (header.find("_event_types.h") != string::npos)
+ continue;
+
+ osrc << "#include <trace/" << header << ">" << endl;
+ }
+ globfree(&trace_glob);
}
- globfree(&trace_glob);
// finish up the module source
osrc << "#endif /* CONFIG_TRACEPOINTS */" << endl;
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 93753666..e23a6699 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -163,6 +163,7 @@ staplog_CPPFLAGS = @staplog_CPPFLAGS@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
PDF_FILES = tutorial.pdf langref.pdf
diff --git a/doc/SystemTap_Tapset_Reference/Makefile.am b/doc/SystemTap_Tapset_Reference/Makefile.am
index 9e7d2069..68dfd971 100644
--- a/doc/SystemTap_Tapset_Reference/Makefile.am
+++ b/doc/SystemTap_Tapset_Reference/Makefile.am
@@ -2,7 +2,7 @@
## process this file with automake to produce Makefile.in
DOC_INSTALL_DIR = $(DESTDIR)$(datadir)/doc/systemtap
-MAN_INSTALL_DIR = $(DESTDIR)$(mandir)/man5
+MAN_INSTALL_DIR = $(DESTDIR)$(mandir)/man3stap
HTML_INSTALL_DIR = $(DESTDIR)$(datadir)/doc/systemtap/tapsets
@@ -36,7 +36,7 @@ tapsets.pdf: tapsets.xml
xmlto pdf tapsets.xml
stamp-mandocs: tapsets.xml
- xmlto man -o man5 tapsets.xml
+ xmlto man -o man3stap tapsets.xml
touch stamp-mandocs
#FIXME need to figure out where to install things appropriately
@@ -45,7 +45,7 @@ install-data-hook:
$(MKDIR_P) $(DOC_INSTALL_DIR)
$(INSTALL_DATA) tapsets.pdf $(DOC_INSTALL_DIR)
$(MKDIR_P) $(MAN_INSTALL_DIR)
- $(INSTALL_DATA) man5/* $(MAN_INSTALL_DIR)
+ $(INSTALL_DATA) man3stap/* $(MAN_INSTALL_DIR)
$(MKDIR_P) $(HTML_INSTALL_DIR)
$(INSTALL_DATA) tapsets/* $(HTML_INSTALL_DIR)
endif
diff --git a/doc/SystemTap_Tapset_Reference/Makefile.in b/doc/SystemTap_Tapset_Reference/Makefile.in
index 84d2114c..2f8a5294 100644
--- a/doc/SystemTap_Tapset_Reference/Makefile.in
+++ b/doc/SystemTap_Tapset_Reference/Makefile.in
@@ -166,10 +166,11 @@ staplog_CPPFLAGS = @staplog_CPPFLAGS@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
DOC_INSTALL_DIR = $(DESTDIR)$(datadir)/doc/systemtap
-MAN_INSTALL_DIR = $(DESTDIR)$(mandir)/man5
+MAN_INSTALL_DIR = $(DESTDIR)$(mandir)/man3stap
HTML_INSTALL_DIR = $(DESTDIR)$(datadir)/doc/systemtap/tapsets
SRCTREE = $(abs_top_srcdir)/
DOCPROC = $(abs_builddir)/docproc
@@ -429,7 +430,7 @@ uninstall-am:
@BUILD_REFDOCS_TRUE@ xmlto pdf tapsets.xml
@BUILD_REFDOCS_TRUE@stamp-mandocs: tapsets.xml
-@BUILD_REFDOCS_TRUE@ xmlto man -o man5 tapsets.xml
+@BUILD_REFDOCS_TRUE@ xmlto man -o man3stap tapsets.xml
@BUILD_REFDOCS_TRUE@ touch stamp-mandocs
#FIXME need to figure out where to install things appropriately
@@ -438,7 +439,7 @@ uninstall-am:
@BUILD_REFDOCS_TRUE@ $(MKDIR_P) $(DOC_INSTALL_DIR)
@BUILD_REFDOCS_TRUE@ $(INSTALL_DATA) tapsets.pdf $(DOC_INSTALL_DIR)
@BUILD_REFDOCS_TRUE@ $(MKDIR_P) $(MAN_INSTALL_DIR)
-@BUILD_REFDOCS_TRUE@ $(INSTALL_DATA) man5/* $(MAN_INSTALL_DIR)
+@BUILD_REFDOCS_TRUE@ $(INSTALL_DATA) man3stap/* $(MAN_INSTALL_DIR)
@BUILD_REFDOCS_TRUE@ $(MKDIR_P) $(HTML_INSTALL_DIR)
@BUILD_REFDOCS_TRUE@ $(INSTALL_DATA) tapsets/* $(HTML_INSTALL_DIR)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/doc/SystemTap_Tapset_Reference/tapsets.tmpl b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
index 798cfb3b..21706ea2 100644
--- a/doc/SystemTap_Tapset_Reference/tapsets.tmpl
+++ b/doc/SystemTap_Tapset_Reference/tapsets.tmpl
@@ -5,23 +5,10 @@
<book id="TapsetRef">
<bookinfo>
<title>SystemTap Tapset Reference Manual</title>
-
- <authorgroup>
- <author>
- <firstname>William</firstname>
- <surname>Cohen</surname>
- <contrib></contrib>
- <affiliation>
- <address>
- <email>wcohen@redhat.com</email>
- </address>
- </affiliation>
- </author>
- </authorgroup>
<copyright>
- <year>2008, 2009</year>
- <holder>Red Hat, Inc.</holder>
+ <year>2008-2009</year>
+ <holder>Red Hat, Inc. and others</holder>
</copyright>
<legalnotice>
@@ -117,8 +104,8 @@
<title>Context Functions</title>
<para>
The context functions provide additional information about where
- the event occurred.
- These functions can provide information such as a backtrace
+ an event occurred.
+ These functions can provide information such as a backtrace to
where the event occured
and the current register values for the processor.
</para>
@@ -132,22 +119,26 @@
<para>
Each timestamp function returns a value to indicate when
a function is executed.
- Thus, these returned values can be used to indicate
- when an event occurs, provide an ordering for events, or compute
- the amount of time elapsed between to time stamps.
+ These returned values can then be used to indicate
+ when an event occurred, provide an ordering for events, or compute
+ the amount of time elapsed between two time stamps.
</para>
!Itapset/timestamp.stp
</chapter>
<chapter id="memory_stp">
<title>Memory Tapset</title>
+ <para>
+ This family of probe points is used to probe memory-related events.
+ It contains the following probe points:
+ </para>
!Itapset/memory.stp
</chapter>
<chapter id="iosched.stp">
<title>IO Scheduler Tapset</title>
<para>
- This family of probe points is used to probe the IO scheduler activities.
+ This family of probe points is used to probe IO scheduler activities.
It contains the following probe points:
</para>
!Itapset/ioscheduler.stp
@@ -156,7 +147,7 @@
<chapter id="scsi.stp">
<title>SCSI Tapset</title>
<para>
- This family of probe points is used to probe the SCSI activities.
+ This family of probe points is used to probe SCSI activities.
It contains the following probe points:
</para>
!Itapset/scsi.stp
@@ -166,11 +157,12 @@
<title>Networking Tapset</title>
<para>
This family of probe points is used to probe the activities of
- the network device, TCP layer, and UDP layer.
+ the network device and protocol layers.
</para>
!Itapset/networking.stp
!Itapset/tcp.stp
!Itapset/udp.stp
+!Itapset/ip.stp
</chapter>
<chapter id="socket.stp">
@@ -181,29 +173,10 @@
</para>
!Itapset/socket.stp
</chapter>
-<!--
- <chapter id="tcp.stp">
- <title>TCP Tapset</title>
- <para>
- This family of probe points is used to probe TCP layer activities.
- It contains the following probe points:
- </para>
-
- </chapter>
-
- <chapter id="upd.stp">
- <title>UDP Tapset</title>
- <para>
- This family of probe points is used to probe UDP layer activities.
- It contains the following probe points:
- </para>
-
- </chapter>
--->
<chapter id="process.stp">
<title>Process Tapset</title>
<para>
- This family of probe points is used to probe the process activities.
+ This family of probe points is used to probe process-related activities.
It contains the following probe points:
</para>
!Itapset/process.stp
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 555fa7e6..d497eae6 100644
--- a/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
+++ b/doc/Tapset_Reference_Guide/en-US/Tapset_Dev_Guide.xml
@@ -62,11 +62,13 @@
beginning of those functions:
</para>
+<para>
<programlisting>
probe process.exec = kernel.function("do_execve"),
kernel.function("compat_do_execve")
{<replaceable>probe body</replaceable>}
</programlisting>
+</para>
<para>
Try to place probes on stable interfaces (i.e., functions
@@ -102,6 +104,7 @@ kernel.function("compat_do_execve")
defined in <filename>task.stp</filename>.
</para>
+<para>
<programlisting>
probe process.create = kernel.function("copy_process").return
{
@@ -109,6 +112,7 @@ probe process.create = kernel.function("copy_process").return
new_pid = task_pid(task)
}
</programlisting>
+</para>
<para>
It is not advisable to write probes for every function. Most SystemTap users
@@ -191,6 +195,7 @@ probe process.create = kernel.function("copy_process").return
The specified format for documenting tapsets is as follows:
</para>
+<para>
<programlisting>
/**
* probe tapset.name - Short summary of what the tapset does.
@@ -209,9 +214,11 @@ probe process.create = kernel.function("copy_process").return
* A paragraph that will appear under the heading "Header".
**/
</programlisting>
-
+</para>
+
<para>For example:</para>
+<para>
<programlisting>
/**
* probe vm.write_shared_copy- Page copy for shared page write.
@@ -226,17 +233,21 @@ probe process.create = kernel.function("copy_process").return
* always preceded by a <command>vm.shared_write</command>.
**/
</programlisting>
+</para>
-<para>To override the automatically-generated <command>Synopsis</command> content, use:
+<para>To override the automatically-generated <command>Synopsis</command> content, use:</para>
+<para>
<programlisting>
* Synopsis:
- * <programlisting>Synopsis string</programlisting>
+ * <replaceable>New Synopsis string</replaceable>
*
</programlisting>
+</para>
<para>For example:</para>
+<para>
<programlisting>
/**
* probe signal.handle - Fires when the signal handler is invoked
@@ -247,6 +258,7 @@ probe process.create = kernel.function("copy_process").return
* sigset_t *oldset, struct pt_regs * regs)&lt;/programlisting>
*/
</programlisting>
+</para>
<para>
It is recommended that you use the <command>&lt;programlisting&gt;</command> tag in
@@ -264,7 +276,7 @@ probe process.create = kernel.function("copy_process").return
<listitem><para><command>emphasis</command></para></listitem>
<listitem><para><command>programlisting</command></para></listitem>
<listitem><para><command>remark</command> (tagged strings will appear in Publican beta
- builds of the document.</para></listitem>
+ builds of the document)</para></listitem>
</itemizedlist>
diff --git a/doc/Tapset_Reference_Guide/manpager.sh b/doc/Tapset_Reference_Guide/manpager.sh
new file mode 100755
index 00000000..0051d208
--- /dev/null
+++ b/doc/Tapset_Reference_Guide/manpager.sh
@@ -0,0 +1,120 @@
+#!/bin/bash
+# This script builds the man pages from comments in tapsets. As such, the man page content
+# generated herein should be in sync with Tapset Reference Guide
+
+# cleanup
+rm -rf man_pages
+
+# create working directory
+mkdir workingdir ;
+
+# create list of man pages to generate
+cat ../SystemTap_Tapset_Reference/tapsets.tmpl | grep ^\!Itapset > manpageus ;
+sed -i -e 's/\!Itapset\///g' manpageus ;
+
+# copy list of man pages into working directory
+for i in `cat manpageus` ; do cp ../../tapset/$i workingdir ; done ;
+
+# enter workdir
+cd workingdir ;
+
+# copy tapsetdescriptions, then clean
+for i in `cat ../manpageus`; do
+sed -n '/\/\/ <tapsetdescription>/,/\/\/ <\/tapsetdescription>/ s/.*/&/w temp' < $i ;
+mv temp $i.tapsetdescription ;
+sed -i -e 's/\/\/ <tapsetdescription>//g' $i.tapsetdescription ;
+sed -i -e 's/\/\/ <\/tapsetdescription>//g' $i.tapsetdescription ;
+sed -i -e 's/\/\///g' $i.tapsetdescription ;
+done
+
+# strip all tapset files to just comments; but all comments must be exactly 1 space before and after "*"
+for i in `cat ../manpageus` ; do sed -i -e 's/^ \*/ \*/g' $i;
+sed -i -e 's/^ \* / \* /g' $i;
+# mark the start of each probe entry (sub "/**")
+perl -p -i -e 's|^/\*\*| *probestart|g' $i;
+sed -i -e '/^ \*/!d' $i;
+# rename all tapsets (remove .stp filename suffix), create templates
+echo $i > tempname ;
+sed -i -e 's/.stp//g' tempname ;
+mv $i `cat tempname` ; mv tempname $i ;
+done ;
+
+# create man page headers
+for i in `ls | grep -v .stp | grep -v tapsetdescription` ; do
+#echo ".\" -*- nroff -*-" >> $i.template ;
+echo ".TH STAPPROBES."$i" 5 @DATE@ "IBM"" >> $i.template ;
+echo ".SH NAME" >> $i.template ;
+echo "stapprobes."`cat $i.stp`" \- systemtap "`cat $i.stp`" probe points" >> $i.template ;
+echo " " >> $i.template ;
+echo ".SH DESCRIPTION" >> $i.template ;
+cat $i.stp.tapsetdescription >> $i.template ;
+echo " " >> $i.template ;
+echo ".SH PROBES" >> $i.template ;
+echo ".br" >> $i.template ;
+echo ".P" >> $i.template ;
+echo ".TP" >> $i.template ;
+done
+
+# MOST IMPORTANT: clean man page body!
+sed -i -e 's/\.stp$//g' ../manpageus ;
+for i in `cat ../manpageus` ;
+do mv $i $i.tmp ;
+perl -p -i -e 's| \* sfunction|.BR|g' $i.tmp ;
+perl -p -i -e 's| \* probe|.BR|g' $i.tmp ;
+perl -p -i -e 's| -|\ninitlinehere|g' $i.tmp ;
+perl -p -i -e 's|^initlinehere([^\n]*)\n|$1\n |g' $i.tmp ;
+perl -p -i -e 's| \* @([^:]*):|\n.I $1:\n|g' $i.tmp ;
+perl -p -i -e 's| \* ([^:]*):|\n.BR $1:\n|g' $i.tmp ;
+perl -p -i -e 's| \* ||g' $i.tmp
+perl -p -i -e 's|\*probestart|\n.P\n.TP|g' $i.tmp ;
+perl -p -i -e 's|\.I|\n.I|g' $i.tmp ;
+# remove empty lines
+sed -i -e '/^$/d' $i.tmp ;
+sed -i -e '/^$/d' $i.tmp ;
+sed -i -e 's/^[ \t]*//g' $i.tmp ;
+# process Description headers
+perl -p -i -e 's|^\*[^/]|\n.BR Description:\n|g' $i.tmp ;
+perl -p -i -e 'undef $/;s|\.BR Description:\n\.BR|.BR|g' $i.tmp ;
+perl -p -i -e 'undef $/;s|\.BR Description:\n\*\/||g' $i.tmp ;
+# process Argument headers
+perl -p -i -e 'undef $/;s|\n\n.I|\n.br\n.BR Arguments:\n.I|g' $i.tmp ;
+# clean up formatting of arguments
+perl -p -i -e 's|^.I([^:]*:)|\n.br\n.br\n.IR$1\n.br\n\t|g' $i.tmp ;
+done
+
+# make tags work
+for i in `cat ../manpageus` ; do
+perl -p -i -e 's|</[^>]*>([^.])|$1\n|g' $i.tmp ;
+perl -p -i -e 's|<[^>]*>|\n.B |g' $i.tmp ;
+# the previous two statements create excess empty lines, remove some of them
+sed -i -e '/^$/d' $i.tmp ;
+# increase whitespace between some headers
+perl -p -i -e 's|^\.BR ([^:]*:)|\n.br\n.BR $1\n.br\n|g' $i.tmp
+done
+
+# generate footer template
+echo ".SH SEE ALSO" >> footer
+echo ".IR stap (1)," >> footer
+echo ".IR stapprobes (5)," >> footer
+for i in `cat ../manpageus`; do echo ".IR stapprobes."$i" (5)," >> footer ; done
+
+# assemble parts
+for i in `cat ../manpageus`; do
+cat $i.template >> stapprobes.$i.5 ;
+cat $i.tmp >> stapprobes.$i.5 ;
+cat footer >> stapprobes.$i.5 ;
+# final polish
+sed -i -e 's/\*\/$//g' stapprobes.$i.5 ;
+done
+
+# cleanup
+for i in `ls | grep -v 'stapprobes.*.5'` ; do
+rm $i ;
+done
+
+rm ../manpageus ;
+cd ..
+mv workingdir man_pages
+echo " "
+echo "Finished! man pages generated in ./man_pages."
+echo " " \ No newline at end of file
diff --git a/hash.cxx b/hash.cxx
index 61caa356..b8d5a0e4 100644
--- a/hash.cxx
+++ b/hash.cxx
@@ -237,4 +237,22 @@ find_hash (systemtap_session& s, const string& script)
find_script_hash(s, script, base);
}
+
+void
+find_tracequery_hash (systemtap_session& s)
+{
+ hash h;
+ get_base_hash(s, h);
+
+ // The basic hash should be good enough for the tracepoint query module
+
+ // Get the directory path to store our cached module
+ string result, hashdir;
+ h.result(result);
+ if (!create_hashdir(s, result, hashdir))
+ return;
+
+ s.tracequery_path = hashdir + "/tracequery_" + result + ".ko";
+}
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
diff --git a/hash.h b/hash.h
index d386ad03..0fe95e27 100644
--- a/hash.h
+++ b/hash.h
@@ -35,5 +35,6 @@ public:
};
void find_hash (systemtap_session& s, const std::string& script);
+void find_tracequery_hash (systemtap_session& s);
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h
index dc2950f0..3da4ff66 100644
--- a/includes/sys/sdt.h
+++ b/includes/sys/sdt.h
@@ -13,124 +13,98 @@
#include <string.h>
#include <sys/types.h>
-#if _LP64
-#define STAP_PROBE_STRUCT_ARG(arg) \
- __uint64_t arg
-#else
-#define STAP_PROBE_STRUCT_ARG(arg) \
- long arg __attribute__ ((aligned(8)))
-#endif
+#define STAP_PROBE_DATA_(probe,dataop) \
+ __asm__ volatile (".section .probes\n" \
+ "\t.align 8\n" \
+ "1:\n\t.asciz " #probe "\n" \
+ "\t.align 4\n" \
+ "\t.int 0x31425250\n" \
+ "\t.align 8\n" \
+ "\t" #dataop " 1b\n" \
+ "\t.align 8\n" \
+ "\t" #dataop " 2f\n" \
+ "\t.previous\n")
-#define STAP_SENTINEL 0x31425250
-
-#define STAP_PROBE_STRUCT(probe,argc) \
-struct _probe_ ## probe \
-{ \
- int probe_type; \
- STAP_PROBE_STRUCT_ARG (probe_name); \
- STAP_PROBE_STRUCT_ARG (probe_arg); \
-}; \
-static char probe ## _ ## probe_name [] \
- __attribute__ ((section (".probes"))) \
- = #probe; \
-__extension__ static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(size_t)& probe ## _ ## probe_name[0],argc};
-
-/* The goto _probe_ prevents the label from "drifting" */
-#define STAP_LABEL_REF(probe, label) \
- if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
- goto label;
-
-/* These baroque macros are used to create a unique label */
-#define STAP_CONCAT(a,b) a ## b
-#define STAP_LABEL_PREFIX(p) _stapprobe1_ ## p
-/* __COUNTER__ is not present in gcc 4.1 */
-#if __GNUC__ == 4 && __GNUC_MINOR__ >= 3
-#define STAP_COUNTER STAP_CONCAT(__,COUNTER__)
+#if _LP64
+#define STAP_PROBE_DATA(probe) \
+ STAP_PROBE_DATA_(#probe,.quad)
#else
-#define STAP_COUNTER STAP_CONCAT(__,LINE__)
+#define STAP_PROBE_DATA(probe) \
+ STAP_PROBE_DATA_(#probe,.long)
#endif
-#define STAP_LABEL(a,b) STAP_CONCAT(a,b)
-#define STAP_PROBE_(probe,label) \
+#define STAP_PROBE_(probe) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
- STAP_LABEL_REF(probe,label); \
-label: \
- __asm__ volatile ("nop"); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop"); \
} while (0)
-#define STAP_PROBE1_(probe,label,parm1) \
+#define STAP_PROBE1_(probe,parm1) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
-label: \
- __asm__ volatile ("nop /* %0 */" :: "X"( arg1)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 */" :: "X"(arg1)); \
} while (0)
-#define STAP_PROBE2_(probe,label,parm1,parm2) \
+#define STAP_PROBE2_(probe,parm1,parm2) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
-label: \
- __asm__ volatile ("nop /* %0 %1 */" :: "X"(arg1), "X"(arg2)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 */" :: "X"(arg1), "X"(arg2)); \
} while (0)
-#define STAP_PROBE3_(probe,label,parm1,parm2,parm3) \
+#define STAP_PROBE3_(probe,parm1,parm2,parm3) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
-label: \
- __asm__ volatile ("nop /* %0 %1 %2 */" :: "X"(arg1), "X"(arg2), "X"(arg3)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 */" :: "X"(arg1), "X"(arg2), "X"(arg3)); \
} while (0)
-#define STAP_PROBE4_(probe,label,parm1,parm2,parm3,parm4) \
+#define STAP_PROBE4_(probe,parm1,parm2,parm3,parm4) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile __typeof__((parm4)) arg4 __attribute__ ((unused)) = parm4; \
-label: \
- __asm__ volatile ("nop /* %0 %1 %2 %3 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4)); \
} while (0)
-#define STAP_PROBE5_(probe,label,parm1,parm2,parm3,parm4,parm5) \
+#define STAP_PROBE5_(probe,parm1,parm2,parm3,parm4,parm5) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile __typeof__((parm4)) arg4 __attribute__ ((unused)) = parm4; \
volatile __typeof__((parm5)) arg5 __attribute__ ((unused)) = parm5; \
-label: \
- __asm__ volatile ("nop /* %0 %1 %2 %3 %4 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5)); \
} while (0)
-#define STAP_PROBE6_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6) \
+#define STAP_PROBE6_(probe,parm1,parm2,parm3,parm4,parm5,parm6) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
volatile __typeof__((parm4)) arg4 __attribute__ ((unused)) = parm4; \
volatile __typeof__((parm5)) arg5 __attribute__ ((unused)) = parm5; \
volatile __typeof__((parm6)) arg6 __attribute__ ((unused)) = parm6; \
-label: \
- __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 %5 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6)); \
} while (0)
-#define STAP_PROBE7_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
+#define STAP_PROBE7_(probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -138,14 +112,13 @@ do { \
volatile __typeof__((parm5)) arg5 __attribute__ ((unused)) = parm5; \
volatile __typeof__((parm6)) arg6 __attribute__ ((unused)) = parm6; \
volatile __typeof__((parm7)) arg7 __attribute__ ((unused)) = parm7; \
-label: \
- __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 %5 %6 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7)); \
} while (0)
-#define STAP_PROBE8_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
+#define STAP_PROBE8_(probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -154,14 +127,13 @@ do { \
volatile __typeof__((parm6)) arg6 __attribute__ ((unused)) = parm6; \
volatile __typeof__((parm7)) arg7 __attribute__ ((unused)) = parm7; \
volatile __typeof__((parm8)) arg8 __attribute__ ((unused)) = parm8; \
-label: \
- __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8)); \
} while (0)
-#define STAP_PROBE9_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
+#define STAP_PROBE9_(probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -171,14 +143,13 @@ do { \
volatile __typeof__((parm7)) arg7 __attribute__ ((unused)) = parm7; \
volatile __typeof__((parm8)) arg8 __attribute__ ((unused)) = parm8; \
volatile __typeof__((parm9)) arg9 __attribute__ ((unused)) = parm9; \
-label: \
- __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 %8 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9)); \
} while (0)
-#define STAP_PROBE10_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
+#define STAP_PROBE10_(probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
do { \
- STAP_PROBE_STRUCT(probe,(size_t)&& label) \
volatile __typeof__((parm1)) arg1 __attribute__ ((unused)) = parm1; \
volatile __typeof__((parm2)) arg2 __attribute__ ((unused)) = parm2; \
volatile __typeof__((parm3)) arg3 __attribute__ ((unused)) = parm3; \
@@ -189,33 +160,33 @@ do { \
volatile __typeof__((parm8)) arg8 __attribute__ ((unused)) = parm8; \
volatile __typeof__((parm9)) arg9 __attribute__ ((unused)) = parm9; \
volatile __typeof__((parm10)) arg10 __attribute__ ((unused)) = parm10; \
-label: \
- __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9), "X"(arg10)); \
- STAP_LABEL_REF(probe,label); \
+ STAP_PROBE_DATA(probe); \
+ __asm__ volatile ("2:\n" \
+ "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9), "X"(arg10)); \
} while (0)
#define STAP_PROBE(provider,probe) \
- STAP_PROBE_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER))
-#define STAP_PROBE1(provider,probe,...) \
- STAP_PROBE1_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE2(provider,probe,...) \
- STAP_PROBE2_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE3(provider,probe,...) \
- STAP_PROBE3_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE4(provider,probe,...) \
- STAP_PROBE4_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE5(provider,probe,...) \
- STAP_PROBE5_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE6(provider,probe,...) \
- STAP_PROBE6_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE7(provider,probe,...) \
- STAP_PROBE7_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE8(provider,probe,...) \
- STAP_PROBE8_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE9(provider,probe,...) \
- STAP_PROBE9_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
-#define STAP_PROBE10(provider,probe,...) \
- STAP_PROBE10_(probe,STAP_LABEL(STAP_LABEL_PREFIX(probe),STAP_COUNTER),__VA_ARGS__)
+ STAP_PROBE_(probe)
+#define STAP_PROBE1(provider,probe,parm1) \
+ STAP_PROBE1_(probe,(parm1))
+#define STAP_PROBE2(provider,probe,parm1,parm2) \
+ STAP_PROBE2_(probe,(parm1),(parm2))
+#define STAP_PROBE3(provider,probe,parm1,parm2,parm3) \
+ STAP_PROBE3_(probe,(parm1),(parm2),(parm3))
+#define STAP_PROBE4(provider,probe,parm1,parm2,parm3,parm4) \
+ STAP_PROBE4_(probe,(parm1),(parm2),(parm3),(parm4))
+#define STAP_PROBE5(provider,probe,parm1,parm2,parm3,parm4,parm5) \
+ STAP_PROBE5_(probe,(parm1),(parm2),(parm3),(parm4),(parm5))
+#define STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6) \
+ STAP_PROBE6_(probe,(parm1),(parm2),(parm3),(parm4),(parm5),(parm6))
+#define STAP_PROBE7(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
+ STAP_PROBE7_(probe,(parm1),(parm2),(parm3),(parm4),(parm5),(parm6),(parm7))
+#define STAP_PROBE8(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
+ STAP_PROBE8_(probe,(parm1),(parm2),(parm3),(parm4),(parm5),(parm6),(parm7),(parm8))
+#define STAP_PROBE9(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
+ STAP_PROBE9_(probe,(parm1),(parm2),(parm3),(parm4),(parm5),(parm6),(parm7),(parm8),(parm9))
+#define STAP_PROBE10(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
+ STAP_PROBE10_(probe,(parm1),(parm2),(parm3),(parm4),(parm5),(parm6),(parm7),(parm8),(parm9),(parm10))
#define DTRACE_PROBE(provider,probe) \
STAP_PROBE(provider,probe)
diff --git a/initscript/README.initscript b/initscript/README.initscript
index f566cf71..ee11f3be 100644
--- a/initscript/README.initscript
+++ b/initscript/README.initscript
@@ -1,5 +1,5 @@
Systemtap initscript
-Version 0.2
+Version 0.2.1
Author: Masami Hiramatsu <mhiramat@redhat.com>
INDEX
diff --git a/initscript/systemtap.in b/initscript/systemtap.in
index eaa1d969..918455d6 100644
--- a/initscript/systemtap.in
+++ b/initscript/systemtap.in
@@ -287,7 +287,7 @@ stap_getopt () { # opts
# TODO: support quoted options
getopt -s bash -u \
-l 'kelf,kmap::,ignore-vmlinux,ignore-dwarf,vp:' \
- -o 'hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:F' -- $@
+ -o 'hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:FS:' -- $@
ret=$?
[ $ret -ne 0 ] && slog "Failed to parse parameters. ($@)"
return $ret
@@ -301,9 +301,9 @@ get_compile_opts () { # opts
for o in $opts; do
if [ $skip -ne 0 ]; then skip=0; continue; fi
case $o in
- -p|-m|-r|-c|-x|-e|-s|-o)
+ -p|-m|-r|-c|-x|-e|-s|-o|-S)
skip=1 ;;
- -h|-V|-k)
+ -h|-V|-k|-F)
;;
*)
echo -n $o" " ;;
@@ -312,14 +312,16 @@ get_compile_opts () { # opts
}
get_run_opts () { # normalized_opts
- local opts o show
+ local opts o show mode
opts=`stap_getopt $*`
[ $? -ne 0 ] && return 1
+ mode='-L'
show=0
for o in $opts; do
case $o in
- -c|-x|-s|-o)
+ -c|-x|-s|-o|-S)
[ $o == '-s' ] && o='-b'
+ [ $o == '-o' ] && mode='-D'
echo -n $o" "
show=1
;;
@@ -331,6 +333,7 @@ get_run_opts () { # normalized_opts
;;
esac
done
+ echo -n $mode
}
prepare_cache_dir () {
@@ -461,11 +464,12 @@ start_script () { # script
return 1
fi
pushd "$tmpdir" &> /dev/null
- logex $STAPRUN -L $opts "$CACHE_PATH/$s.ko"
+ eval log \"Exec: $STAPRUN $opts $CACHE_PATH/$s.ko\"
+ $STAPRUN $opts "$CACHE_PATH/$s.ko" 2>> "$LOG_FILE" > ./pid
ret=$?
+ [ x`cat ./pid` = x ] && echo 0 > ./pid
if [ $ret -eq 0 ]; then
- # TODO: store daemon pid after supporting on-file flight recorder
- echo 0 > "$STAT_PATH/$s"
+ logex cp -f ./pid "$STAT_PATH/$s"
fi
popd &> /dev/null
rm -rf "$tmpdir"
@@ -524,7 +528,7 @@ stop_script () { # script
p=`get_daemon_pid $1`
if [ $p -ne 0 ]; then
- logex killall -TERM $p
+ logex kill -TERM $p
else
logex $STAPRUN -d "$1"
fi
diff --git a/main.cxx b/main.cxx
index b494ba2b..cdcae41a 100644
--- a/main.cxx
+++ b/main.cxx
@@ -108,10 +108,14 @@ usage (systemtap_session& s, int exitcode)
<< " " << s.kernel_build_tree << endl
<< " -m MODULE set probe module name, instead of " << endl
<< " " << s.module_name << endl
- << " -o FILE send script output to file, instead of stdout" << endl
+ << " -o FILE send script output to file, instead of stdout. This supports" << endl
+ << " a subset of strftime(3) (%%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k," << endl
+ << " %l,%M,%S,%R,%T,%u,%w) for FILE." << endl
<< " -c CMD start the probes, run CMD, and exit when it finishes" << endl
<< " -x PID sets target() to PID" << endl
- << " -F load module and start probes, then detach" << endl
+ << " -F run as on-file flight recorder with -o." << endl
+ << " run as on-memory flight recorder without -o." << endl
+ << " -S size[,n] set maximum of the size and the number of files." << endl
<< " -d OBJECT add unwind/symbol data for OBJECT file";
if (s.unwindsym_modules.size() == 0)
clog << endl;
@@ -134,6 +138,8 @@ usage (systemtap_session& s, int exitcode)
#endif
// Formerly present --ignore-{vmlinux,dwarf} options are for testsuite use
// only, and don't belong in the eyesight of a plain user.
+ << " --skip-badvars" << endl
+ << " overlook context of bad $ variables" << endl
<< endl
;
@@ -431,16 +437,18 @@ main (int argc, char * const argv [])
#define LONG_OPT_IGNORE_VMLINUX 3
#define LONG_OPT_IGNORE_DWARF 4
#define LONG_OPT_VERBOSE_PASS 5
+#define LONG_OPT_SKIP_BADVARS 6
// NB: also see find_hash(), usage(), switch stmt below, stap.1 man page
static struct option long_options[] = {
{ "kelf", 0, &long_opt, LONG_OPT_KELF },
{ "kmap", 2, &long_opt, LONG_OPT_KMAP },
{ "ignore-vmlinux", 0, &long_opt, LONG_OPT_IGNORE_VMLINUX },
{ "ignore-dwarf", 0, &long_opt, LONG_OPT_IGNORE_DWARF },
+ { "skip-badvars", 0, &long_opt, LONG_OPT_SKIP_BADVARS },
{ "vp", 1, &long_opt, LONG_OPT_VERBOSE_PASS },
{ NULL, 0, NULL, 0 }
};
- int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:F",
+ int grc = getopt_long (argc, argv, "hVMvtp:I:e:o:R:r:m:kgPc:x:D:bs:uqwl:d:L:FS:",
long_options, NULL);
if (grc < 0)
break;
@@ -624,6 +632,10 @@ main (int argc, char * const argv [])
s.macros.push_back (string (optarg));
break;
+ case 'S':
+ s.size_option = string (optarg);
+ break;
+
case 'q':
s.tapset_compile_coverage = true;
break;
@@ -698,6 +710,9 @@ main (int argc, char * const argv [])
// NB: we don't do this: s.last_pass = strlen(optarg);
break;
}
+ case LONG_OPT_SKIP_BADVARS:
+ s.skip_badvars = true;
+ break;
default:
cerr << "Internal error parsing command arguments." << endl;
usage(s, 1);
diff --git a/parse.cxx b/parse.cxx
index ac7e652c..a26d594c 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -2341,6 +2341,12 @@ parser::parse_symbol ()
cop->operand = parse_expression ();
expect_op(",");
expect_unknown(tok_string, cop->type);
+ // types never start with "struct<space>" or "union<space>",
+ // so gobble it up.
+ if (cop->type.compare(0, 7, "struct ") == 0)
+ cop->type = cop->type.substr(7);
+ if (cop->type.compare(0, 6, "union ") == 0)
+ cop->type = cop->type.substr(6);
if (peek_op (","))
{
next();
diff --git a/runtime/autoconf-find-task-pid.c b/runtime/autoconf-find-task-pid.c
new file mode 100644
index 00000000..549d5ac3
--- /dev/null
+++ b/runtime/autoconf-find-task-pid.c
@@ -0,0 +1,6 @@
+#include <linux/sched.h>
+
+void foo (pid_t k) {
+ struct task_struct *tsk = find_task_by_pid (k);
+ (void) tsk;
+}
diff --git a/runtime/itrace.c b/runtime/itrace.c
index ed32b0bc..618cbff0 100644
--- a/runtime/itrace.c
+++ b/runtime/itrace.c
@@ -1,6 +1,7 @@
/*
* user space instruction tracing
* Copyright (C) 2005, 2006, 2007, 2008, 2009 IBM Corp.
+ * Copyright (C) 2009 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
@@ -17,8 +18,15 @@
#include <linux/sched.h>
#include <linux/rcupdate.h>
#include <linux/utrace.h>
+
+/* PR9974: Adapt to struct renaming. */
+#ifdef UTRACE_API_VERSION
+#define utrace_attached_engine utrace_engine
+#endif
+
#include <asm/string.h>
#include "uprobes/uprobes.h"
+#include "utrace_compatibility.h"
#ifndef put_task_struct
#define put_task_struct(t) \
@@ -55,7 +63,7 @@ struct itrace_info {
struct list_head link;
};
-static u32 debug = 1;
+static u32 debug = 0 /* 1 */;
static LIST_HEAD(usr_itrace_info);
static spinlock_t itrace_lock;
@@ -118,10 +126,15 @@ static int __access_process_vm(struct task_struct *tsk, unsigned long addr, void
return buf - old_buf;
}
+#ifdef UTRACE_ORIG_VERSION
+static u32 usr_itrace_report_quiesce(struct utrace_attached_engine *engine,
+ struct task_struct *tsk)
+#else
static u32 usr_itrace_report_quiesce(enum utrace_resume_action action,
struct utrace_attached_engine *engine,
struct task_struct *tsk,
unsigned long event)
+#endif
{
int status;
struct itrace_info *ui;
@@ -129,10 +142,23 @@ static u32 usr_itrace_report_quiesce(enum utrace_resume_action action,
ui = rcu_dereference(engine->data);
WARN_ON(!ui);
+#ifdef UTRACE_ORIG_VERSION
+ return (ui->step_flag); // XXX XXX XXX
+#else
return (event == 0 ? ui->step_flag : UTRACE_RESUME);
+#endif
}
+#ifdef UTRACE_ORIG_VERSION
+static u32 usr_itrace_report_signal(
+ struct utrace_attached_engine *engine,
+ struct task_struct *tsk,
+ struct pt_regs *regs,
+ u32 action, siginfo_t *info,
+ const struct k_sigaction *orig_ka,
+ struct k_sigaction *return_ka)
+#else
static u32 usr_itrace_report_signal(u32 action,
struct utrace_attached_engine *engine,
struct task_struct *tsk,
@@ -140,6 +166,7 @@ static u32 usr_itrace_report_signal(u32 action,
siginfo_t *info,
const struct k_sigaction *orig_ka,
struct k_sigaction *return_ka)
+#endif
{
struct itrace_info *ui;
u32 return_flags;
@@ -174,16 +201,31 @@ static u32 usr_itrace_report_signal(u32 action,
return return_flags;
}
+
+
+#ifdef UTRACE_ORIG_VERSION
+static u32 usr_itrace_report_clone(
+ struct utrace_attached_engine *engine,
+ struct task_struct *parent,
+ unsigned long clone_flags,
+ struct task_struct *child)
+#else
static u32 usr_itrace_report_clone(enum utrace_resume_action action,
struct utrace_attached_engine *engine,
struct task_struct *parent, unsigned long clone_flags,
struct task_struct *child)
+#endif
{
return UTRACE_RESUME;
}
+#ifdef UTRACE_ORIG_VERSION
+static u32 usr_itrace_report_death(struct utrace_attached_engine *e,
+ struct task_struct *tsk)
+#else
static u32 usr_itrace_report_death(struct utrace_attached_engine *e,
struct task_struct *tsk, bool group_dead, int signal)
+#endif
{
struct itrace_info *ui = rcu_dereference(e->data);
WARN_ON(!ui);
@@ -275,8 +317,13 @@ static int usr_itrace_init(int single_step, pid_t tid, struct stap_itrace_probe
struct itrace_info *ui;
struct task_struct *tsk;
+ spin_lock_init(&itrace_lock);
rcu_read_lock();
+#ifdef STAPCONF_FIND_TASK_PID
+ tsk = find_task_by_pid(tid);
+#else
tsk = find_task_by_vpid(tid);
+#endif
if (!tsk) {
printk(KERN_ERR "usr_itrace_init: Cannot find process %d\n", tid);
rcu_read_unlock();
@@ -293,11 +340,6 @@ static int usr_itrace_init(int single_step, pid_t tid, struct stap_itrace_probe
put_task_struct(tsk);
rcu_read_unlock();
- spin_lock_init(&itrace_lock);
-
- /* set initial state */
- spin_lock(&itrace_lock);
- spin_unlock(&itrace_lock);
printk(KERN_INFO "usr_itrace_init: completed for tid = %d\n", tid);
return 0;
@@ -314,7 +356,6 @@ void static remove_usr_itrace_info(struct itrace_info *ui)
if (debug)
printk(KERN_INFO "remove_usr_itrace_info: tid=%d\n", ui->tid);
- spin_lock(&itrace_lock);
if (ui->tsk && ui->engine) {
status = utrace_control(ui->tsk, ui->engine, UTRACE_DETACH);
if (status < 0 && status != -ESRCH && status != -EALREADY)
@@ -322,6 +363,7 @@ void static remove_usr_itrace_info(struct itrace_info *ui)
"utrace_control(UTRACE_DETACH) returns %d\n",
status);
}
+ spin_lock(&itrace_lock);
list_del(&ui->link);
spin_unlock(&itrace_lock);
kfree(ui);
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h
index 0af19edc..16ddb950 100644
--- a/runtime/loc2c-runtime.h
+++ b/runtime/loc2c-runtime.h
@@ -186,37 +186,34 @@
*/
#define kread(ptr) ({ \
- typeof(*(ptr)) _v; \
- if (probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \
- DEREF_FAULT(ptr); \
+ typeof(*(ptr)) _v = 0; \
+ if (lookup_bad_addr((unsigned long)(ptr)) || \
+ probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \
+ DEREF_FAULT(ptr); \
_v; \
})
#define kwrite(ptr, value) ({ \
typeof(*(ptr)) _v; \
_v = (typeof(*(ptr)))(value); \
- if (probe_kernel_write((void *)(ptr), (void *)&_v, sizeof(*(ptr)))) \
- STORE_DEREF_FAULT(ptr); \
+ if (lookup_bad_addr((unsigned long)addr) || \
+ probe_kernel_write((void *)(ptr), (void *)&_v, sizeof(*(ptr)))) \
+ STORE_DEREF_FAULT(ptr); \
})
#define deref(size, addr) ({ \
- intptr_t _i; \
- if (lookup_bad_addr((unsigned long)addr)) \
- __deref_bad(); \
+ intptr_t _i = 0; \
switch (size) { \
case 1: _i = kread((u8 *)(addr)); break; \
case 2: _i = kread((u16 *)(addr)); break; \
case 4: _i = kread((u32 *)(addr)); break; \
case 8: _i = kread((u64 *)(addr)); break; \
default: __deref_bad(); \
- /* uninitialized _i should also be caught by -Werror */ \
} \
_i; \
})
#define store_deref(size, addr, value) ({ \
- if (lookup_bad_addr((unsigned long)addr)) \
- __store_deref_bad(); \
switch (size) { \
case 1: kwrite((u8 *)(addr), (value)); break; \
case 2: kwrite((u16 *)(addr), (value)); break; \
@@ -237,7 +234,7 @@ extern void __store_deref_bad(void);
({ \
int _bad = 0; \
u8 _b; u16 _w; u32 _l; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \
@@ -277,7 +274,7 @@ extern void __store_deref_bad(void);
({ \
int _bad = 0; \
u8 _b; u16 _w; u32 _l; u64 _q; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \
@@ -394,7 +391,7 @@ extern void __store_deref_bad(void);
#define deref(size, addr) \
({ \
int _bad = 0; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index fd16b4b8..8200ec9d 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -27,6 +27,9 @@ int attach_mod;
int delete_mod;
int load_only;
int need_uprobes;
+int daemon_mode;
+off_t fsize_max;
+int fnum_max;
/* module variables */
char *modname = NULL;
@@ -35,9 +38,132 @@ char *modoptions[MAXMODOPTIONS];
int control_channel = -1; /* NB: fd==0 possible */
+static char path_buf[PATH_MAX];
+static char *get_abspath(char *path)
+{
+ int len;
+ if (path[0] == '/')
+ return path;
+
+ len = strlen(getcwd(path_buf, PATH_MAX));
+ if (len + 2 + strlen(path) >= PATH_MAX)
+ return NULL;
+ path_buf[len] = '/';
+ strcpy(&path_buf[len + 1], path);
+ return path_buf;
+}
+
+int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t)
+{
+ char *c = buf;
+ const char *c2 = fmt, *end = buf + max;
+ int ret, num;
+ struct tm tm;
+ if (buf == NULL || fmt == NULL || max <= 1)
+ return -EINVAL;
+ localtime_r(&t, &tm);
+
+ while (*c2 != '\0'){
+ if (c + 1 >= end)
+ return -EINVAL;
+ if (*c2 != '%') {
+ *c++ = *c2++;
+ continue;
+ }
+ c2++;
+ switch (*c2++) {
+ case '%':
+ *c++ = '%';
+ break;
+ case 'Y':
+ num = tm.tm_year + 1900;
+ goto numbering;
+ case 'y':
+ num = tm.tm_year % 100;
+ goto numbering02;
+ case 'C':
+ num = ((tm.tm_year + 1900 - 1) / 100) + 1;
+ goto numbering;
+ case 'm':
+ num = tm.tm_mon + 1;
+ goto numbering02;
+ case 'd':
+ num = tm.tm_mday;
+ goto numbering02;
+ case 'e':
+ num = tm.tm_mday;
+ goto numbering;
+ case 'F':
+ ret = snprintf(c, end - c, "%d-%02d-%02d",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+ if (ret < 0) return ret;
+ c += ret;
+ break;
+ case 'H':
+ num = tm.tm_hour;
+ goto numbering02;
+ case 'I':
+ num = tm.tm_hour % 12;
+ if (num == 0) num = 12;
+ goto numbering02;
+ case 'j':
+ ret = snprintf(c, end - c, "%03d", tm.tm_yday);
+ if (ret < 0) return ret;
+ c += ret;
+ break;
+ case 'k':
+ num = tm.tm_hour;
+ goto numbering;
+ case 'l':
+ num = tm.tm_hour % 12;
+ if (num == 0) num = 12;
+ goto numbering;
+ case 'M':
+ num = tm.tm_min;
+ goto numbering02;
+ case 'S':
+ num = tm.tm_sec;
+ goto numbering02;
+ case 'R':
+ ret = snprintf(c, end - c, "%02d:%02d",
+ tm.tm_hour, tm.tm_min);
+ if (ret < 0) return ret;
+ c += ret;
+ break;
+ case 'T':
+ ret = snprintf(c, end - c, "%02d:%02d:%02d",
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ if (ret < 0) return ret;
+ c += ret;
+ break;
+ case 'u':
+ num = tm.tm_wday == 0 ? 7 : tm.tm_wday;
+ goto numbering;
+ case 'w':
+ num = tm.tm_wday;
+ goto numbering;
+ default:
+ return -EINVAL;
+ }
+ continue;
+numbering:
+ ret = snprintf(c, end - c, "%d", num);
+ if (ret < 0) return ret;
+ c += ret;
+ continue;
+numbering02:
+ ret = snprintf(c, end - c, "%02d", num);
+ if (ret < 0) return ret;
+ c += ret;
+ }
+ *c = '\0';
+ return c - buf;
+}
+
void parse_args(int argc, char **argv)
{
int c;
+ char *s;
/* Initialize option variables. */
verbose = 0;
@@ -49,8 +175,11 @@ void parse_args(int argc, char **argv)
delete_mod = 0;
load_only = 0;
need_uprobes = 0;
+ daemon_mode = 0;
+ fsize_max = 0;
+ fnum_max = 0;
- while ((c = getopt(argc, argv, "ALuvb:t:dc:o:x:")) != EOF) {
+ while ((c = getopt(argc, argv, "ALuvb:t:dc:o:x:S:D")) != EOF) {
switch (c) {
case 'u':
need_uprobes = 1;
@@ -85,11 +214,38 @@ void parse_args(int argc, char **argv)
case 'L':
load_only = 1;
break;
+ case 'D':
+ daemon_mode = 1;
+ break;
+ case 'S':
+ fsize_max = strtoul(optarg, &s, 10);
+ fsize_max <<= 20;
+ if (s[0] == ',')
+ fnum_max = (int)strtoul(&s[1], &s, 10);
+ if (s[0] != '\0') {
+ err("Invalid file size option '%s'.\n", optarg);
+ usage(argv[0]);
+ }
+ break;
default:
usage(argv[0]);
}
}
-
+ if (outfile_name) {
+ char tmp[PATH_MAX];
+ int ret;
+ outfile_name = get_abspath(outfile_name);
+ if (outfile_name == NULL) {
+ err("File name is too long.\n");
+ usage(argv[0]);
+ }
+ ret = stap_strfloctime(tmp, PATH_MAX - 18, /* = _cpuNNN.SSSSSSSSSS */
+ outfile_name, time(NULL));
+ if (ret < 0) {
+ err("Filename format is invalid or too long.\n");
+ usage(argv[0]);
+ }
+ }
if (attach_mod && load_only) {
err("You can't specify the '-A' and '-L' options together.\n");
usage(argv[0]);
@@ -118,18 +274,41 @@ void parse_args(int argc, char **argv)
err("You can't specify the '-c' and '-x' options together.\n");
usage(argv[0]);
}
+
+ if (daemon_mode && load_only) {
+ err("You can't specify the '-D' and '-L' options together.\n");
+ usage(argv[0]);
+ }
+ if (daemon_mode && delete_mod) {
+ err("You can't specify the '-D' and '-d' options together.\n");
+ usage(argv[0]);
+ }
+ if (daemon_mode && target_cmd) {
+ err("You can't specify the '-D' and '-c' options together.\n");
+ usage(argv[0]);
+ }
+ if (daemon_mode && outfile_name == NULL) {
+ err("You have to specify output FILE with '-D' option.\n");
+ usage(argv[0]);
+ }
+ if (outfile_name == NULL && fsize_max != 0) {
+ err("You have to specify output FILE with '-S' option.\n");
+ usage(argv[0]);
+ }
}
void usage(char *prog)
{
- err("\n%s [-v] [-c cmd ] [-x pid] [-u user]\n"
- "\t[-A|-L] [-b bufsize] [-o FILE] MODULE [module-options]\n", prog);
+ err("\n%s [-v] [-c cmd ] [-x pid] [-u user] [-A|-L|-d]\n"
+ "\t[-b bufsize] [-o FILE [-D] [-S size[,N]]] MODULE [module-options]\n", prog);
err("-v Increase verbosity.\n");
err("-c cmd Command \'cmd\' will be run and staprun will\n");
err(" exit when it does. The '_stp_target' variable\n");
err(" will contain the pid for the command.\n");
err("-x pid Sets the '_stp_target' variable to pid.\n");
- err("-o FILE Send output to FILE.\n");
+ err("-o FILE Send output to FILE. This supports a subset of\n");
+ err(" strftime(3) (%%%%,%%C,%%Y,%%y,%%m,%%d,%%e,%%F,%%H,%%I\n");
+ err(" %%j,%%k,%%l,%%M,%%S,%%R,%%T,%%u,%%w) for FILE.\n");
err("-b buffer size The systemtap module specifies a buffer size.\n");
err(" Setting one here will override that value. The\n");
err(" value should be an integer between 1 and 4095 \n");
@@ -140,6 +319,14 @@ void usage(char *prog)
err("-d Delete a module. Only detached or unused modules\n");
err(" the user has permission to access will be deleted. Use \"*\"\n");
err(" (quoted) to delete all unused modules.\n");
+ err("-D Run in background. This requires '-o' option.\n");
+ err("-S size[,N] Switches output file to next file when the size\n");
+ err(" of file reaches the specified size. The value\n");
+ err(" should be an integer greater than 1 which is\n");
+ err(" assumed to be the maximum file size in MB.\n");
+ err(" When the number of output files reaches N, it\n");
+ err(" switches to the first output file. You can omit\n");
+ err(" the second argument.\n");
err("MODULE can be either a module name or a module path. If a\n");
err("module name is used, it is looked for in the following\n");
err("directory: /lib/modules/`uname -r`/systemtap\n");
@@ -344,3 +531,24 @@ int send_request(int type, void *data, int len)
if (rc < 0) return rc;
return (rc != len+4);
}
+
+#include <stdarg.h>
+
+static int use_syslog = 0;
+
+void eprintf(const char *fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ if (use_syslog)
+ vsyslog(LOG_ERR, fmt, va);
+ else
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+}
+
+void switch_syslog(const char *name)
+{
+ openlog(name, LOG_PID, LOG_DAEMON);
+ use_syslog = 1;
+}
diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c
index 29eb4f1f..c80bbba4 100644
--- a/runtime/staprun/mainloop.c
+++ b/runtime/staprun/mainloop.c
@@ -318,6 +318,41 @@ int init_stapio(void)
if (target_cmd)
start_cmd();
+ /* Run in background */
+ if (daemon_mode) {
+ pid_t pid;
+ int ret;
+ dbug(2, "daemonizing stapio\n");
+
+ /* daemonize */
+ ret = daemon(0, 1); /* don't close stdout at this time. */
+ if (ret) {
+ err("Failed to daemonize stapio\n");
+ return -1;
+ }
+
+ /* change error messages to syslog. */
+ switch_syslog("stapio");
+
+ /* show new pid */
+ pid = getpid();
+ fprintf(stdout, "%d\n", pid);
+ fflush(stdout);
+
+ /* redirect all outputs to /dev/null */
+ ret = open("/dev/null", O_RDWR);
+ if (ret < 0) {
+ err("Failed to open /dev/null\n");
+ return -1;
+ }
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+ dup2(ret, STDOUT_FILENO);
+ dup2(ret, STDERR_FILENO);
+ close(ret);
+ }
+
return 0;
}
@@ -454,21 +489,14 @@ int stp_main_loop(void)
switch (type) {
#ifdef STP_OLD_TRANSPORT
case STP_REALTIME_DATA:
- {
- ssize_t bw = write(out_fd[0], data, nb);
- if (bw >= 0 && bw != nb) {
- nb = nb - bw;
- bw = write(out_fd[0], data, nb);
- }
- if (bw != nb) {
- _perr("write error (nb=%ld)", (long)nb);
- cleanup_and_exit(0);
- }
- break;
+ if (write_realtime_data(data, nb)) {
+ _perr("write error (nb=%ld)", (long)nb);
+ cleanup_and_exit(0);
}
+ break;
#endif
case STP_OOB_DATA:
- fputs((char *)data, stderr);
+ eprintf("%s", (char *)data);
break;
case STP_EXIT:
{
@@ -477,6 +505,14 @@ int stp_main_loop(void)
cleanup_and_exit(0);
break;
}
+ case STP_REQUEST_EXIT:
+ {
+ /* module asks us to start exiting, so send STP_EXIT */
+ dbug(2, "got STP_REQUEST_EXIT\n");
+ int32_t rc, btype = STP_EXIT;
+ rc = write(control_channel, &btype, sizeof(btype));
+ break;
+ }
case STP_START:
{
struct _stp_msg_start *t = (struct _stp_msg_start *)data;
diff --git a/runtime/staprun/relay.c b/runtime/staprun/relay.c
index 19621933..50f295b5 100644
--- a/runtime/staprun/relay.c
+++ b/runtime/staprun/relay.c
@@ -17,6 +17,9 @@ static pthread_t reader[NR_CPUS];
static int relay_fd[NR_CPUS];
static int bulkmode = 0;
static volatile int stop_threads = 0;
+static time_t *time_backlog[NR_CPUS];
+static int backlog_order=0;
+#define BACKLOG_MASK ((1 << backlog_order) - 1)
/*
* ppoll exists in glibc >= 2.4
@@ -44,6 +47,90 @@ static int ppoll(struct pollfd *fds, nfds_t nfds,
}
#endif
+int init_backlog(int cpu)
+{
+ int order = 0;
+ if (!fnum_max)
+ return 0;
+ while (fnum_max >> order) order++;
+ if (fnum_max == 1<<(order-1)) order--;
+ time_backlog[cpu] = (time_t *)calloc(1<<order, sizeof(time_t));
+ if (time_backlog[cpu] == NULL) {
+ _err("Memory allocation failed\n");
+ return -1;
+ }
+ backlog_order = order;
+ return 0;
+}
+
+void write_backlog(int cpu, int fnum, time_t t)
+{
+ time_backlog[cpu][fnum & BACKLOG_MASK] = t;
+}
+
+time_t read_backlog(int cpu, int fnum)
+{
+ return time_backlog[cpu][fnum & BACKLOG_MASK];
+}
+
+int make_outfile_name(char *buf, int max, int fnum, int cpu, time_t t)
+{
+ int len;
+ len = stap_strfloctime(buf, max, outfile_name, t);
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ return -1;
+ }
+ if (bulkmode) {
+ /* special case: for testing we sometimes want to write to /dev/null */
+ if (strcmp(outfile_name, "/dev/null") == 0) {
+ strcpy(buf, "/dev/null");
+ } else {
+ if (snprintf_chk(&buf[len], PATH_MAX - len,
+ "_cpu%d.%d", cpu, fnum))
+ return -1;
+ }
+ } else {
+ /* stream mode */
+ if (snprintf_chk(&buf[len], PATH_MAX - len, ".%d", fnum))
+ return -1;
+ }
+ return 0;
+}
+
+static int open_outfile(int fnum, int cpu, int remove_file)
+{
+ char buf[PATH_MAX];
+ time_t t;
+ if (!outfile_name) {
+ _err("-S is set without -o. Please file a bug report.\n");
+ return -1;
+ }
+
+ time(&t);
+ if (fnum_max) {
+ if (remove_file) {
+ /* remove oldest file */
+ if (make_outfile_name(buf, PATH_MAX, fnum - fnum_max,
+ cpu, read_backlog(cpu, fnum - fnum_max)) < 0)
+ return -1;
+ remove(buf); /* don't care */
+ }
+ write_backlog(cpu, fnum, t);
+ }
+
+ if (make_outfile_name(buf, PATH_MAX, fnum, cpu, t) < 0)
+ return -1;
+ out_fd[cpu] = open (buf, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ if (out_fd[cpu] < 0) {
+ perr("Couldn't open output file %s", buf);
+ return -1;
+ }
+ if (set_clexec(out_fd[cpu]) < 0)
+ return -1;
+ return 0;
+}
+
/**
* reader_thread - per-cpu channel buffer reader
*/
@@ -57,6 +144,9 @@ static void *reader_thread(void *data)
struct timespec tim = {.tv_sec=0, .tv_nsec=200000000}, *timeout = &tim;
sigset_t sigs;
struct sigaction sa;
+ off_t wsize = 0;
+ int fnum = 0;
+ int remove_file = 0;
sigemptyset(&sigs);
sigaddset(&sigs,SIGUSR2);
@@ -99,6 +189,19 @@ static void *reader_thread(void *data)
}
}
while ((rc = read(relay_fd[cpu], buf, sizeof(buf))) > 0) {
+ wsize += rc;
+ /* Switching file */
+ if (fsize_max && wsize > fsize_max) {
+ close(out_fd[cpu]);
+ fnum++;
+ if (fnum_max && fnum == fnum_max)
+ remove_file = 1;
+ if (open_outfile(fnum, cpu, remove_file) < 0) {
+ perr("Couldn't open file for cpu %d, exiting.", cpu);
+ return(NULL);
+ }
+ wsize = 0;
+ }
if (write(out_fd[cpu], buf, rc) != rc) {
perr("Couldn't write to output %d for cpu %d, exiting.", out_fd[cpu], cpu);
return(NULL);
@@ -116,7 +219,7 @@ static void *reader_thread(void *data)
*/
int init_relayfs(void)
{
- int i;
+ int i, len;
struct statfs st;
char rqbuf[128];
char buf[PATH_MAX], relay_filebase[PATH_MAX];
@@ -163,14 +266,29 @@ int init_relayfs(void)
return -1;
}
- if (bulkmode) {
+ if (fsize_max) {
+ /* switch file mode */
+ for (i = 0; i < ncpus; i++) {
+ if (init_backlog(i) < 0)
+ return -1;
+ if (open_outfile(0, i, 0) < 0)
+ return -1;
+ }
+ } else if (bulkmode) {
for (i = 0; i < ncpus; i++) {
if (outfile_name) {
/* special case: for testing we sometimes want to write to /dev/null */
if (strcmp(outfile_name, "/dev/null") == 0) {
strcpy(buf, "/dev/null");
} else {
- if (sprintf_chk(buf, "%s_%d", outfile_name, i))
+ len = stap_strfloctime(buf, PATH_MAX,
+ outfile_name, time(NULL));
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ return -1;
+ }
+ if (snprintf_chk(&buf[len],
+ PATH_MAX - len, "_%d", i))
return -1;
}
} else {
@@ -189,9 +307,15 @@ int init_relayfs(void)
} else {
/* stream mode */
if (outfile_name) {
- out_fd[0] = open (outfile_name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ len = stap_strfloctime(buf, PATH_MAX,
+ outfile_name, time(NULL));
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ return -1;
+ }
+ out_fd[0] = open (buf, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (out_fd[0] < 0) {
- perr("Couldn't open output file %s", outfile_name);
+ perr("Couldn't open output file %s", buf);
return -1;
}
if (set_clexec(out_fd[i]) < 0)
diff --git a/runtime/staprun/relay_old.c b/runtime/staprun/relay_old.c
index bd746f19..ef8fd0da 100644
--- a/runtime/staprun/relay_old.c
+++ b/runtime/staprun/relay_old.c
@@ -23,6 +23,14 @@ static int bulkmode = 0;
unsigned subbuf_size = 0;
unsigned n_subbufs = 0;
+struct switchfile_ctrl_block {
+ off_t wsize;
+ int fnum;
+ int rmfile;
+};
+
+static struct switchfile_ctrl_block global_scb = {0, 0, 0};
+
/* per-cpu buffer info */
static struct buf_status
{
@@ -70,6 +78,41 @@ void close_oldrelayfs(int detach)
close_relayfs_files(i);
}
+static int open_oldoutfile(int fnum, int cpu, int remove_file)
+{
+ char buf[PATH_MAX];
+ time_t t;
+ if (outfile_name) {
+ time(&t);
+ if (fnum_max) {
+ if (remove_file) {
+ /* remove oldest file */
+ if (make_outfile_name(buf, PATH_MAX, fnum - fnum_max,
+ cpu, read_backlog(cpu, fnum - fnum_max)) < 0)
+ return -1;
+ remove(buf); /* don't care */
+ }
+ write_backlog(cpu, fnum, t);
+ }
+ if (make_outfile_name(buf, PATH_MAX, fnum, cpu, t) < 0)
+ return -1;
+ } else if (bulkmode) {
+ if (sprintf_chk(buf, "stpd_cpu%d.%d", cpu, fnum))
+ return -1;
+ } else { /* stream mode */
+ out_fd[cpu] = STDOUT_FILENO;
+ return 0;
+ }
+
+ out_fd[cpu] = open (buf, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ if (out_fd[cpu] < 0) {
+ perr("Couldn't open output file %s", buf);
+ return -1;
+ }
+ if (set_clexec(out_fd[cpu]) < 0)
+ return -1;
+ return 0;
+}
/**
* open_relayfs_files - open and mmap buffer and open output file.
* Returns -1 on unexpected failure, 0 if file not found, 1 on success.
@@ -104,18 +147,31 @@ static int open_relayfs_files(int cpu, const char *relay_filebase, const char *p
return -1;
}
+ if (fsize_max) {
+ if (init_backlog(cpu) < 0)
+ goto err2;
+ if (open_oldoutfile(0, cpu, 0) < 0)
+ goto err2;
+ goto opened;
+ }
if (outfile_name) {
/* special case: for testing we sometimes want to
* write to /dev/null */
if (strcmp(outfile_name, "/dev/null") == 0) {
strcpy(tmp, "/dev/null");
} else {
- if (sprintf_chk(tmp, "%s_%d", outfile_name, cpu))
- goto err1;
+ int len;
+ len = stap_strfloctime(tmp, PATH_MAX, outfile_name, time(NULL));
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ goto err2;
+ }
+ if (snprintf_chk(&tmp[len], PATH_MAX - len, "_%d", cpu))
+ goto err2;
}
} else {
if (sprintf_chk(tmp, "stpd_cpu%d", cpu))
- goto err1;
+ goto err2;
}
if((percpu_tmpfile[cpu] = fopen(tmp, "w+")) == NULL) {
@@ -126,6 +182,7 @@ static int open_relayfs_files(int cpu, const char *relay_filebase, const char *p
perr("Couldn't open output file %s", tmp);
goto err2;
}
+opened:
total_bufsize = subbuf_size * n_subbufs;
relay_buffer[cpu] = mmap(NULL, total_bufsize, PROT_READ,
@@ -155,7 +212,8 @@ err1:
/**
* process_subbufs - write ready subbufs to disk
*/
-static int process_subbufs(struct _stp_buf_info *info)
+static int process_subbufs(struct _stp_buf_info *info,
+ struct switchfile_ctrl_block *scb)
{
unsigned subbufs_ready, start_subbuf, end_subbuf, subbuf_idx, i;
int len, cpu = info->cpu;
@@ -173,6 +231,18 @@ static int process_subbufs(struct _stp_buf_info *info)
padding = *((unsigned *)subbuf_ptr);
subbuf_ptr += sizeof(padding);
len = (subbuf_size - sizeof(padding)) - padding;
+ scb->wsize += len;
+ if (fsize_max && scb->wsize > fsize_max) {
+ fclose(percpu_tmpfile[cpu]);
+ scb->fnum ++;
+ if (fnum_max && scb->fnum == fnum_max)
+ scb->rmfile = 1;
+ if (open_oldoutfile(scb->fnum, cpu, scb->rmfile) < 0) {
+ perr("Couldn't open file for cpu %d, exiting.", cpu);
+ exit(1);
+ }
+ scb->wsize = 0;
+ }
if (len) {
if (fwrite_unlocked (subbuf_ptr, len, 1, percpu_tmpfile[cpu]) != 1) {
_perr("Couldn't write to output file for cpu %d, exiting:", cpu);
@@ -196,6 +266,7 @@ static void *reader_thread(void *data)
struct _stp_consumed_info consumed_info;
unsigned subbufs_consumed;
cpu_set_t cpu_mask;
+ struct switchfile_ctrl_block scb = {0, 0, 0};
CPU_ZERO(&cpu_mask);
CPU_SET(cpu, &cpu_mask);
@@ -217,7 +288,7 @@ static void *reader_thread(void *data)
}
rc = read(proc_fd[cpu], &status[cpu].info, sizeof(struct _stp_buf_info));
- subbufs_consumed = process_subbufs(&status[cpu].info);
+ subbufs_consumed = process_subbufs(&status[cpu].info, &scb);
if (subbufs_consumed) {
if (subbufs_consumed > status[cpu].max_backlog)
status[cpu].max_backlog = subbufs_consumed;
@@ -233,6 +304,33 @@ static void *reader_thread(void *data)
}
/**
+ * write_realtime_data - write realtime data packet to disk
+ */
+int write_realtime_data(void *data, ssize_t nb)
+{
+ ssize_t bw;
+ global_scb.wsize += nb;
+ if (fsize_max && global_scb.wsize > fsize_max) {
+ close(out_fd[0]);
+ global_scb.fnum++;
+ if (fnum_max && global_scb.fnum == fnum_max)
+ global_scb.rmfile = 1;
+ if (open_oldoutfile(global_scb.fnum, 0,
+ global_scb.rmfile) < 0) {
+ perr("Couldn't open file, exiting.");
+ return -1;
+ }
+ global_scb.wsize = 0;
+ }
+ bw = write(out_fd[0], data, nb);
+ if (bw >= 0 && bw != nb) {
+ nb = nb - bw;
+ bw = write(out_fd[0], data, nb);
+ }
+ return bw != nb;
+}
+
+/**
* init_relayfs - create files and threads for relayfs processing
*
* Returns 0 if successful, negative otherwise
@@ -249,10 +347,22 @@ int init_oldrelayfs(void)
bulkmode = 1;
if (!bulkmode) {
+ int len;
+ char tmp[PATH_MAX];
+ if (fsize_max) {
+ if (init_backlog(0))
+ return -1;
+ return open_oldoutfile(0, 0, 0);
+ }
if (outfile_name) {
- out_fd[0] = open (outfile_name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
+ len = stap_strfloctime(tmp, PATH_MAX, outfile_name, time(NULL));
+ if (len < 0) {
+ err("Invalid FILE name format\n");
+ return -1;
+ }
+ out_fd[0] = open (tmp, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (out_fd[0] < 0 || set_clexec(out_fd[0]) < 0) {
- perr("Couldn't open output file '%s'", outfile_name);
+ perr("Couldn't open output file '%s'", tmp);
return -1;
}
} else
diff --git a/runtime/staprun/staprun.h b/runtime/staprun/staprun.h
index 84cf63fc..acc533b2 100644
--- a/runtime/staprun/staprun.h
+++ b/runtime/staprun/staprun.h
@@ -9,7 +9,7 @@
*
* Copyright (C) 2005-2008 Red Hat Inc.
*/
-
+#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
@@ -33,31 +33,35 @@
#include <sys/wait.h>
#include <sys/statfs.h>
#include <linux/version.h>
+#include <syslog.h>
/* Include config.h to pick up dependency for --prefix usage. */
#include "config.h"
-#define dbug(level, args...) {if (verbose>=level) {fprintf(stderr,"%s:%s:%d ",__name__,__FUNCTION__, __LINE__); fprintf(stderr,args);}}
+extern void eprintf(const char *fmt, ...);
+extern void switch_syslog(const char *name);
+
+#define dbug(level, args...) do {if (verbose>=level) {eprintf("%s:%s:%d ",__name__,__FUNCTION__, __LINE__); eprintf(args);}} while (0)
extern char *__name__;
/* print to stderr */
-#define err(args...) fprintf(stderr,args)
+#define err(args...) eprintf(args)
/* better perror() */
#define perr(args...) do { \
int _errno = errno; \
- fputs("ERROR: ", stderr); \
- fprintf(stderr, args); \
- fprintf(stderr, ": %s\n", strerror(_errno)); \
+ eprintf("ERROR: "); \
+ eprintf(args); \
+ eprintf(": %s\n", strerror(_errno)); \
} while (0)
/* Error messages. Use these for serious errors, not informational messages to stderr. */
-#define _err(args...) do {fprintf(stderr,"%s:%s:%d: ERROR: ",__name__, __FUNCTION__, __LINE__); fprintf(stderr,args);} while(0)
+#define _err(args...) do {eprintf("%s:%s:%d: ERROR: ",__name__, __FUNCTION__, __LINE__); eprintf(args);} while(0)
#define _perr(args...) do { \
int _errno = errno; \
_err(args); \
- fprintf(stderr, ": %s\n", strerror(_errno)); \
+ eprintf(": %s\n", strerror(_errno)); \
} while (0)
#define overflow_error() _err("Internal buffer overflow. Please file a bug report.\n")
@@ -113,7 +117,12 @@ int init_relayfs(void);
void close_relayfs(void);
int init_oldrelayfs(void);
void close_oldrelayfs(int);
+int write_realtime_data(void *data, ssize_t nb);
void setup_signals(void);
+int make_outfile_name(char *buf, int max, int fnum, int cpu, time_t t);
+int init_backlog(int cpu);
+void write_backlog(int cpu, int fnum, time_t t);
+time_t read_backlog(int cpu, int fnum);
/* staprun_funcs.c */
void setup_staprun_signals(void);
const char *moderror(int err);
@@ -125,6 +134,7 @@ void start_symbol_thread(void);
void stop_symbol_thread(void);
/* common.c functions */
+int stap_strfloctime(char *buf, size_t max, const char *fmt, time_t t);
void parse_args(int argc, char **argv);
void usage(char *prog);
void parse_modpath(const char *);
@@ -153,6 +163,9 @@ extern int attach_mod;
extern int delete_mod;
extern int load_only;
extern int need_uprobes;
+extern int daemon_mode;
+extern off_t fsize_max;
+extern int fnum_max;
/* getopt variables */
extern char *optarg;
diff --git a/runtime/sym.h b/runtime/sym.h
index e642cab4..586b10ca 100644
--- a/runtime/sym.h
+++ b/runtime/sym.h
@@ -25,6 +25,7 @@ struct _stp_section {
struct _stp_module {
const char* name;
+ const char* path; /* canonical path used for runtime matching. */
struct _stp_section *sections;
unsigned num_sections;
diff --git a/runtime/task_finder.c b/runtime/task_finder.c
index 9db713c3..3f4908cb 100644
--- a/runtime/task_finder.c
+++ b/runtime/task_finder.c
@@ -6,6 +6,12 @@
#endif
#include <linux/utrace.h>
+
+/* PR9974: Adapt to struct renaming. */
+#ifdef UTRACE_API_VERSION
+#define utrace_attached_engine utrace_engine
+#endif
+
#include <linux/list.h>
#include <linux/binfmts.h>
#include <linux/mount.h>
@@ -55,7 +61,6 @@ typedef int (*stap_task_finder_vm_callback)(struct stap_task_finder_target *tgt,
unsigned long vm_end,
unsigned long vm_pgoff);
-#ifdef DEBUG_TASK_FINDER_VMA
static int __stp_tf_vm_cb(struct stap_task_finder_target *tgt,
struct task_struct *tsk,
int map_p, char *vm_path,
@@ -63,21 +68,32 @@ static int __stp_tf_vm_cb(struct stap_task_finder_target *tgt,
unsigned long vm_end,
unsigned long vm_pgoff)
{
+ int i;
+#ifdef DEBUG_TASK_FINDER_VMA
_stp_dbug(__FUNCTION__, __LINE__,
"vm_cb: tsk %d:%d path %s, start 0x%08lx, end 0x%08lx, offset 0x%lx\n",
tsk->pid, map_p, vm_path, vm_start, vm_end, vm_pgoff);
+#endif
if (map_p) {
- // FIXME: What should we do with vm_path? We can't save
- // the vm_path pointer itself, but we don't have any
- // storage space allocated to save it in...
- stap_add_vma_map_info(tsk, vm_start, vm_end, vm_pgoff);
+ struct _stp_module *module = NULL;
+ if (vm_path != NULL)
+ for (i = 0; i < _stp_num_modules; i++)
+ if (strcmp(vm_path, _stp_modules[i]->path) == 0)
+ {
+#ifdef DEBUG_TASK_FINDER_VMA
+ _stp_dbug(__FUNCTION__, __LINE__,
+ "vm_cb: matched path %s to module\n", vm_path);
+#endif
+ module = _stp_modules[i];
+ break;
+ }
+ stap_add_vma_map_info(tsk, vm_start, vm_end, vm_pgoff, module);
}
else {
stap_remove_vma_map_info(tsk, vm_start, vm_end, vm_pgoff);
}
return 0;
}
-#endif
struct stap_task_finder_target {
/* private: */
@@ -1016,6 +1032,7 @@ __stp_utrace_task_finder_target_syscall_entry(enum utrace_resume_action action,
static void
__stp_call_vm_callbacks_with_vma(struct stap_task_finder_target *tgt,
struct task_struct *tsk,
+ int map_p,
struct vm_area_struct *vma)
{
char *mmpath_buf;
@@ -1042,7 +1059,7 @@ __stp_call_vm_callbacks_with_vma(struct stap_task_finder_target *tgt,
rc, (int)tsk->pid);
}
else {
- __stp_call_vm_callbacks(tgt, tsk, 1, mmpath,
+ __stp_call_vm_callbacks(tgt, tsk, map_p, mmpath,
vma->vm_start, vma->vm_end,
(vma->vm_pgoff << PAGE_SHIFT));
}
@@ -1135,7 +1152,7 @@ __stp_utrace_task_finder_target_syscall_exit(enum utrace_resume_action action,
down_read(&mm->mmap_sem);
vma = __stp_find_file_based_vma(mm, rv);
if (vma != NULL) {
- __stp_call_vm_callbacks_with_vma(tgt, tsk, vma);
+ __stp_call_vm_callbacks_with_vma(tgt, tsk, 0, vma);
}
up_read(&mm->mmap_sem);
mmput(mm);
@@ -1208,6 +1225,7 @@ __stp_utrace_task_finder_target_syscall_exit(enum utrace_resume_action action,
&& vma->vm_end <= entry->vm_end) {
__stp_call_vm_callbacks_with_vma(tgt,
tsk,
+ 1,
vma);
if (vma->vm_end >= entry->vm_end)
break;
diff --git a/runtime/task_finder_vma.c b/runtime/task_finder_vma.c
index 4dce4be8..83b206e5 100644
--- a/runtime/task_finder_vma.c
+++ b/runtime/task_finder_vma.c
@@ -25,6 +25,9 @@ struct __stp_tf_vma_entry {
unsigned long vm_end;
unsigned long vm_pgoff;
// Is that enough? Should we store a dcookie for vm_file?
+
+ // Module that this vma entry is mapped from, if any.
+ struct _stp_module *module;
};
static struct __stp_tf_vma_entry
@@ -200,7 +203,6 @@ __stp_tf_get_vma_map_entry_internal(struct task_struct *tsk,
hlist_for_each_entry(entry, node, head, hlist) {
if (tsk->pid == entry->pid
&& vm_start == entry->addr) {
- mutex_unlock(&__stp_tf_vma_mutex);
return entry;
}
}
@@ -211,7 +213,8 @@ __stp_tf_get_vma_map_entry_internal(struct task_struct *tsk,
// Add the vma info to the vma map hash table.
static int
stap_add_vma_map_info(struct task_struct *tsk, unsigned long vm_start,
- unsigned long vm_end, unsigned long vm_pgoff)
+ unsigned long vm_end, unsigned long vm_pgoff,
+ struct _stp_module *module)
{
struct hlist_head *head;
struct hlist_node *node;
@@ -242,6 +245,7 @@ stap_add_vma_map_info(struct task_struct *tsk, unsigned long vm_start,
entry->vm_start = vm_start;
entry->vm_end = vm_end;
entry->vm_pgoff = vm_pgoff;
+ entry->module = module;
head = &__stp_tf_vma_map[__stp_tf_vma_map_hash(tsk)];
hlist_add_head(&entry->hlist, head);
@@ -305,3 +309,26 @@ stap_find_vma_map_info(struct task_struct *tsk, unsigned long vm_addr,
mutex_unlock(&__stp_tf_vma_mutex);
return rc;
}
+
+// Get vma_entry of the address (vm_start/vm_end) if the vma is
+// present in the vma hash table containing.
+// Returns NULL if not present.
+static struct __stp_tf_vma_entry *
+__stp_tf_get_vma_entry_addr(struct task_struct *tsk, unsigned long addr)
+{
+ struct hlist_head *head;
+ struct hlist_node *node;
+ struct __stp_tf_vma_entry *entry;
+
+ mutex_lock(&__stp_tf_vma_mutex);
+ head = &__stp_tf_vma_map[__stp_tf_vma_map_hash(tsk)];
+ hlist_for_each_entry(entry, node, head, hlist) {
+ if (tsk->pid == entry->pid
+ && addr >= entry->vm_start && addr < entry->vm_end) {
+ mutex_unlock(&__stp_tf_vma_mutex);
+ return entry;
+ }
+ }
+ mutex_unlock(&__stp_tf_vma_mutex);
+ return NULL;
+}
diff --git a/runtime/transport/control.c b/runtime/transport/control.c
index edde244d..680d7306 100644
--- a/runtime/transport/control.c
+++ b/runtime/transport/control.c
@@ -13,6 +13,8 @@ static _stp_mempool_t *_stp_pool_q;
static struct list_head _stp_ctl_ready_q;
static DEFINE_SPINLOCK(_stp_ctl_ready_lock);
+static void _stp_cleanup_and_exit(int send_exit);
+
static ssize_t _stp_ctl_write_cmd(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
u32 type;
@@ -46,7 +48,7 @@ static ssize_t _stp_ctl_write_cmd(struct file *file, const char __user *buf, siz
}
break;
case STP_EXIT:
- _stp_exit_flag = 1;
+ _stp_cleanup_and_exit(1);
break;
case STP_BULK:
#ifdef STP_BULKMODE
@@ -93,6 +95,9 @@ static void _stp_ctl_write_dbug(int type, void *data, int len)
case STP_TRANSPORT:
_dbug("sending STP_TRANSPORT\n");
break;
+ case STP_REQUEST_EXIT:
+ _dbug("sending STP_REQUEST_EXIT\n");
+ break;
default:
_dbug("ERROR: unknown message type: %d\n", type);
break;
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index 7fcebd42..762c0a92 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -25,7 +25,6 @@ static struct utt_trace *_stp_utt = NULL;
static unsigned int utt_seq = 1;
static int _stp_probes_started = 0;
static pid_t _stp_target = 0;
-static int _stp_exit_called = 0;
static int _stp_exit_flag = 0;
#include "control.h"
#ifdef STP_OLD_TRANSPORT
@@ -89,13 +88,14 @@ static void _stp_handle_start(struct _stp_msg_start *st)
/* when someone does /sbin/rmmod on a loaded systemtap module. */
static void _stp_cleanup_and_exit(int send_exit)
{
- if (!_stp_exit_called) {
+ static int called = 0;
+ if (!called) {
int failures;
dbug_trans(1, "cleanup_and_exit (%d)\n", send_exit);
_stp_exit_flag = 1;
/* we only want to do this stuff once */
- _stp_exit_called = 1;
+ called = 1;
if (_stp_probes_started) {
dbug_trans(1, "calling probe_exit\n");
@@ -119,6 +119,18 @@ static void _stp_cleanup_and_exit(int send_exit)
}
}
+static void _stp_request_exit(void)
+{
+ static int called = 0;
+ if (!called) {
+ /* we only want to do this once */
+ called = 1;
+ dbug_trans(1, "ctl_send STP_REQUEST_EXIT\n");
+ _stp_ctl_send(STP_REQUEST_EXIT, NULL, 0);
+ dbug_trans(1, "done with ctl_send STP_REQUEST_EXIT\n");
+ }
+}
+
/*
* Called when stapio closes the control channel.
*/
@@ -169,7 +181,7 @@ static void _stp_work_queue(void *data)
/* if exit flag is set AND we have finished with probe_start() */
if (unlikely(_stp_exit_flag && _stp_probes_started))
- _stp_cleanup_and_exit(1);
+ _stp_request_exit();
if (likely(_stp_attached))
queue_delayed_work(_stp_wq, &_stp_work, STP_WORK_TIMER);
}
diff --git a/runtime/transport/transport_msgs.h b/runtime/transport/transport_msgs.h
index 596f4925..0d9a5983 100644
--- a/runtime/transport/transport_msgs.h
+++ b/runtime/transport/transport_msgs.h
@@ -21,19 +21,20 @@ struct _stp_trace {
enum
{
STP_START,
- STP_EXIT,
+ STP_EXIT,
STP_OOB_DATA,
STP_SYSTEM,
STP_TRANSPORT,
STP_CONNECT,
- STP_DISCONNECT,
+ STP_DISCONNECT,
STP_BULK,
STP_READY,
- STP_RELOCATION,
+ STP_RELOCATION,
/** deprecated STP_OLD_TRANSPORT **/
STP_BUF_INFO,
STP_SUBBUFS_CONSUMED,
STP_REALTIME_DATA,
+ STP_REQUEST_EXIT,
STP_MAX_CMD
};
@@ -52,6 +53,7 @@ static const char *_stp_command_name[] = {
"STP_BUF_INFO",
"STP_SUBBUFS_CONSUMED",
"STP_REALTIME_DATA",
+ "STP_REQUEST_EXIT",
};
#endif /* DEBUG_TRANS */
diff --git a/runtime/uprobes2/uprobes.c b/runtime/uprobes2/uprobes.c
index af187fc9..a0e9f2fe 100644
--- a/runtime/uprobes2/uprobes.c
+++ b/runtime/uprobes2/uprobes.c
@@ -29,6 +29,12 @@
#include <linux/utrace.h>
#include <linux/regset.h>
#define UPROBES_IMPLEMENTATION 1
+
+/* PR9974: Adapt to struct renaming. */
+#ifdef UTRACE_API_VERSION
+#define utrace_attached_engine utrace_engine
+#endif
+
#include "uprobes.h"
#include <linux/tracehook.h>
#include <linux/mm.h>
diff --git a/runtime/uprobes2/uprobes.h b/runtime/uprobes2/uprobes.h
index 11d01f5c..112e29e2 100644
--- a/runtime/uprobes2/uprobes.h
+++ b/runtime/uprobes2/uprobes.h
@@ -23,6 +23,11 @@
#include <linux/types.h>
#include <linux/list.h>
+/* Adapt to struct renaming. */
+#ifdef UTRACE_API_VERSION
+#define utrace_attached_engine utrace_engine
+#endif
+
struct pt_regs;
enum uprobe_type {
diff --git a/runtime/utrace_compatibility.h b/runtime/utrace_compatibility.h
index 00b841d2..5521a5c2 100644
--- a/runtime/utrace_compatibility.h
+++ b/runtime/utrace_compatibility.h
@@ -1,6 +1,6 @@
/*
* utrace compatibility defines and inlines
- * Copyright (C) 2008 Red Hat Inc.
+ * Copyright (C) 2008-2009 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
@@ -13,6 +13,11 @@
#include <linux/utrace.h>
+/* PR9974: Adapt to struct renaming. */
+#ifdef UTRACE_API_VERSION
+#define utrace_attached_engine utrace_engine
+#endif
+
#ifdef UTRACE_ACTION_RESUME
/*
@@ -28,6 +33,8 @@ enum utrace_resume_action {
UTRACE_STOP = UTRACE_ACTION_QUIESCE,
UTRACE_RESUME = UTRACE_ACTION_RESUME,
UTRACE_DETACH = UTRACE_ACTION_DETACH,
+ UTRACE_SINGLESTEP = UTRACE_ACTION_SINGLESTEP,
+ UTRACE_BLOCKSTEP = UTRACE_ACTION_BLOCKSTEP,
};
static inline struct utrace_attached_engine *
@@ -48,6 +55,11 @@ utrace_control(struct task_struct *target,
case UTRACE_STOP:
return utrace_set_flags(target, engine,
(engine->flags | UTRACE_ACTION_QUIESCE));
+ case UTRACE_SINGLESTEP:
+ case UTRACE_BLOCKSTEP:
+ return utrace_set_flags(target, engine,
+ engine->flags | action);
+
default:
return -EINVAL;
}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index add4ba3c..92178910 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -981,7 +981,7 @@ sub output_probe_xml(%) {
print "</refentryinfo>\n";
print "<refmeta>\n";
print " <refentrytitle><phrase>".$args{'probe'}."</phrase></refentrytitle>\n";
- print " <manvolnum>5</manvolnum>\n";
+ print " <manvolnum>3stap</manvolnum>\n";
# print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
print "</refmeta>\n";
print "<refnamediv>\n";
@@ -1039,7 +1039,7 @@ sub output_sfunction_xml(%) {
print "</refentryinfo>\n";
print "<refmeta>\n";
print " <refentrytitle><phrase>".$args{'sfunction'}."</phrase></refentrytitle>\n";
- print " <manvolnum>5</manvolnum>\n";
+ print " <manvolnum>3stap</manvolnum>\n";
# print " <refmiscinfo class=\"version\">" . $kernelversion . "</refmiscinfo>\n";
print "</refmeta>\n";
print "<refnamediv>\n";
@@ -1774,7 +1774,7 @@ sub create_sparameterlist($$$) {
my $param;
foreach my $arg (split($splitter, $args)) {
- if ($arg =~ m/s*([\w]+)\s*:?\s*([\w]*)/) {
+ if ($arg =~ m/\s*([\w]+)\s*:?\s*([\w]*)/) {
$param = $1;
$type = $2;
push_parameter($param, $type, $file);
diff --git a/session.h b/session.h
index bc99385b..cbbae6b2 100644
--- a/session.h
+++ b/session.h
@@ -90,6 +90,7 @@ struct systemtap_session
std::string module_name;
std::string stapconf_name;
std::string output_file;
+ std::string size_option;
std::string cmd;
int target_pid;
int last_pass;
@@ -116,6 +117,7 @@ struct systemtap_session
std::string cache_path;
std::string hash_path;
std::string stapconf_path;
+ std::string tracequery_path;
// dwarfless operation
bool consult_symtab;
@@ -123,6 +125,9 @@ struct systemtap_session
bool ignore_vmlinux;
bool ignore_dwarf;
+ // Skip bad $ vars
+ bool skip_badvars;
+
// temporary directory for module builds etc.
// hazardous - it is "rm -rf"'d at exit
std::string tmpdir;
diff --git a/stap.1.in b/stap.1.in
index 546bebb8..c562c8b7 100644
--- a/stap.1.in
+++ b/stap.1.in
@@ -175,7 +175,9 @@ even if they do not have an explicit probe placed into them.
.TP
.BI \-o " FILE"
Send standard output to named file. In bulk mode, percpu files will
-start with FILE_ followed by the cpu number.
+start with FILE_ (FILE_cpu with -F) followed by the cpu number.
+This supports a subset of strftime(3) (%%, %C, %Y, %y, %m, %d, %e, %F,
+%H, %I, %j, %l, %M, %S, %R, %T, %u, %w) for FILE.
.TP
.BI \-c " CMD"
Start the probes, run CMD, and exit when CMD finishes.
@@ -193,8 +195,18 @@ and aliases.
Similar to "-l", but list probe points and script-level local variables.
.TP
.BI \-F
-Load module and start probes, then detach from the module leaving the
-probes running.
+Without -o option, load module and start probes, then detach from the module
+leaving the probes running.
+With -o option, run staprun in background as a daemon and show it's pid.
+.TP
+.BI \-S " size[,N]"
+Sets the maximum size of output file and the maximum number of output files.
+If the size of output file will exceed
+.B size
+, systemtap switches output file to the next file. And if the number of
+output files exceed
+.B N
+, systemtap removes the oldest output file. You can omit the second argument.
.TP
.B \-\-kelf
For names and addresses of functions to probe,
@@ -230,6 +242,9 @@ nor the kernel debugging information can be found.
.TP
.B \-\-ignore\-dwarf
For testing, act as though vmlinux and modules lack debugging information.
+.TP
+.B \-\-skip\-badvars
+Ignore out of context variables and substitute with literal 0.
.SH ARGUMENTS
@@ -773,10 +788,12 @@ and dereference the
.I member
value. The optional
.I module
-tells the translator where to look for information about that type. If
-the module is not specified, it will default either to the probe module
-for dwarf probes, or to "kernel" for functions and all other probes
-types.
+tells the translator where to look for information about that type.
+Multiple modules may be specified as a list with
+.IR :
+separators. If the module is not specified, it will default either to
+the probe module for dwarf probes, or to "kernel" for functions and all
+other probes types.
.PP
When in guru mode, the translator will also allow scripts to assign new
values to members of typecasted pointers.
@@ -1041,7 +1058,8 @@ means that the first error will exit the script.
MAXSKIPPED
Maximum number of skipped probes before an exit is triggered, default 100.
Running systemtap with \-t (timing) mode gives more details about skipped
-probes.
+probes. With the default \-DINTERRUPTIBLE=1 setting, probes skipped due to
+reentrancy are not accumulated against this limit.
.TP
MINSTACKSPACE
Minimum number of free kernel stack bytes required in order to
diff --git a/stapprobes.5.in b/stapprobes.5.in
index 70d045c4..f4a872cb 100644
--- a/stapprobes.5.in
+++ b/stapprobes.5.in
@@ -407,8 +407,10 @@ process.syscall
process(PID).syscall.return
process("PATH").syscall.return
process.syscall.return
-process(PID).itrace
-process("PATH").itrace
+process(PID).insn
+process("PATH").insn
+process(PID).insn.block
+process("PATH").insn.block
process("PATH").mark("LABEL")
.ESAMPLE
.PP
@@ -443,8 +445,11 @@ in the
.BR $return
context variable.
A
-.B .itrace
-probe gets called for every single step of the process described by PID or PATH.
+.B .insn
+probe gets called for every single-stepped instruction of the process described by PID or PATH.
+A
+.B .insn.block
+probe gets called for every block-stepped instruction of the process described by PID or PATH.
A
.B .mark
probe gets called via a static probe which is defined in the
diff --git a/staprun.8.in b/staprun.8.in
index c7e77dc4..01ef2320 100644
--- a/staprun.8.in
+++ b/staprun.8.in
@@ -52,7 +52,10 @@ The '_stp_target' variable will be set to PID.
.TP
.B \-o FILE
Send output to FILE. If the module uses bulk mode, the output will
-be in percpu files FILE_x where 'x' is the cpu number.
+be in percpu files FILE_x(FILE_cpux in backgroud and bulk mode)
+where 'x' is the cpu number. This supports a subset of strftime(3)
+(%%, %C, %Y, %y, %m, %d, %e, %F, %H, %I, %j, %l, %M, %S, %R, %T, %u, %w)
+for FILE.
.TP
.B \-b BUFFER_SIZE
The systemtap module will specify a buffer size.
@@ -73,6 +76,18 @@ Attach to loaded systemtap module.
Delete a module. Only detached or unused modules
the user has permission to access will be deleted. Use "*"
(quoted) to delete all unused modules.
+.TP
+.BI \-D
+Run staprun in background as a daemon and show it's pid.
+.TP
+.BI \-S " size[,N]"
+Sets the maximum size of output file and the maximum number of output files.
+If the size of output file will exceed
+.B size
+, systemtap switches output file to the next file. And if the number of
+output files exceed
+.B N
+, systemtap removes the oldest output file. You can omit the second argument.
.SH ARGUMENTS
.B MODULE
diff --git a/systemtap.spec b/systemtap.spec
index 7277f92a..540a9d93 100644
--- a/systemtap.spec
+++ b/systemtap.spec
@@ -1,4 +1,3 @@
-%{!?release: %define release 1}
%{!?with_sqlite: %define with_sqlite 1}
%{!?with_docs: %define with_docs 1}
%{!?with_crash: %define with_crash 0}
@@ -6,9 +5,9 @@
%{!?elfutils_version: %define elfutils_version 0.127}
Name: systemtap
-# for version, see also configure.ac
Version: 0.9
-Release: %{release}%{?dist}
+Release: 3%{?dist}
+# for version, see also configure.ac
Summary: Instrumentation System
Group: Development/System
License: GPLv2+
@@ -246,6 +245,7 @@ exit 0
%if %{with_docs}
%doc docs.installed/*.pdf
%doc docs.installed/tapsets
+%{_mandir}/man3stap/*
%endif
%{_bindir}/stap
@@ -317,6 +317,9 @@ exit 0
%changelog
+* Wed Mar 18 2009 Will Cohen <wcohen@redhat.com> - 0.9-2
+- Add location of man pages.
+
* Tue Feb 17 2009 Frank Ch. Eigler <fche@redhat.com> - 0.9-1
- Upstream release.
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp
index d2e43903..87ea4e04 100644
--- a/tapset/aux_syscalls.stp
+++ b/tapset/aux_syscalls.stp
@@ -322,17 +322,10 @@ function _struct_sockaddr_u:string(uaddr:long, len:long)
}
else if ((sa->sa_family == AF_PACKET)&&(len == sizeof(struct sockaddr_ll)))
{
- /* FIXME. This needs tested */
struct sockaddr_ll *sll = (struct sockaddr_ll *)buf;
-#if defined(__powerpc__) || defined(__ia64__) || defined(__s390x__)
- snprintf(str, strlen, "{AF_PACKET, proto=%d, ind=%d, hatype=%d, pkttype=%d, halen=%d, addr=0x%lx}",
- (int)sll->sll_protocol, sll->sll_ifindex, (int)sll->sll_hatype, (int)sll->sll_pkttype,
- (int)sll->sll_halen, *(uint64_t *)sll->sll_addr);
-#else
snprintf(str, strlen, "{AF_PACKET, proto=%d, ind=%d, hatype=%d, pkttype=%d, halen=%d, addr=0x%llx}",
(int)sll->sll_protocol, sll->sll_ifindex, (int)sll->sll_hatype, (int)sll->sll_pkttype,
(int)sll->sll_halen, *(uint64_t *)sll->sll_addr);
-#endif
}
else
{
diff --git a/tapset/context-symbols.stp b/tapset/context-symbols.stp
index 46eab841..a3aae408 100644
--- a/tapset/context-symbols.stp
+++ b/tapset/context-symbols.stp
@@ -6,7 +6,11 @@
// 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.
-
+// <tapsetdescription>
+// Context functions provide additional information about where an event occurred. These functions can
+//provide information such as a backtrace to where the event occured and the current register values for the
+//processor.
+// </tapsetdescription>
%{
#ifndef STP_NEED_SYMBOL_DATA
#define STP_NEED_SYMBOL_DATA 1
@@ -14,12 +18,13 @@
%}
// weirdness with print_stack, argument appears in build as undescribed
/**
- * sfunction print_stack - Print out stack from string
+ * sfunction print_stack - Print out stack from string.
* @stk: String with list of hexidecimal addresses. (FIXME)
*
* Perform a symbolic lookup of the addresses in the given string,
- * which is assumed to be the result of a prior call to
+ * which is assumed to be the result of a prior call to
* <command>backtrace()</command>.
+ *
* Print one line per address, including the address, the
* name of the function containing the address, and an estimate of
* its position within that function. Return nothing.
@@ -36,9 +41,7 @@ function print_stack(stk:string) %{
%}
/**
- * sfunction probefunc - Function probed
- *
- * Return the probe point's function name, if known.
+ * sfunction probefunc - Return the probe point's function name, if known.
*/
function probefunc:string () %{ /* pure */
char *ptr, *start;
@@ -72,9 +75,7 @@ function probefunc:string () %{ /* pure */
%}
/**
- * sfunction probemod - Module probed
- *
- * Return the probe point's module name, if known.
+ * sfunction probemod - Return the probe point's module name, if known.
*/
function probemod:string () %{ /* pure */
char *ptr, *start;
diff --git a/tapset/context-unwind.stp b/tapset/context-unwind.stp
index a0836ed6..90d4e0f4 100644
--- a/tapset/context-unwind.stp
+++ b/tapset/context-unwind.stp
@@ -6,7 +6,11 @@
// 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.
-
+// <tapsetdescription>
+// Context functions provide additional information about where an event occurred. These functions can
+//provide information such as a backtrace to where the event occured and the current register values for the
+//processor.
+// </tapsetdescription>
%{
#ifndef STP_NEED_UNWIND_DATA
#define STP_NEED_UNWIND_DATA 1
@@ -19,7 +23,7 @@
/**
* sfunction print_backtrace - Print stack back trace
*
- * Equivalent to <command>print_stack(backtrace())</command>,
+ * Equivalent to <command>print_stack(backtrace())</command>,
* except that deeper stack nesting may be supported. Return nothing.
*/
function print_backtrace () %{
@@ -33,8 +37,8 @@ function print_backtrace () %{
/**
* sfunction backtrace - Hex backtrace of current stack
*
- * Return a string of hex addresses that are a backtrace of the
- * stack. It may be truncated due to maximum string length.
+ * Return a string of hex addresses that are a backtrace of the
+ * stack. Output may be truncated as per maximum string length.
*/
function backtrace:string () %{ /* pure */
if (CONTEXT->regs)
@@ -46,7 +50,7 @@ function backtrace:string () %{ /* pure */
/**
* sfunction caller - Return name and address of calling function
*
- * Return the address and name of the calling function.
+ * Return the address and name of the calling function.
* <emphasis>Works only for return probes at this time.</emphasis>
*/
function caller:string() %{ /* pure */
@@ -60,7 +64,7 @@ function caller:string() %{ /* pure */
/**
* sfunction caller_addr - Return caller address
*
- * Return the address of the calling function.
+ * Return the address of the calling function.
* <emphasis> Works only for return probes at this time.</emphasis>
*/
function caller_addr:long () %{ /* pure */
diff --git a/tapset/context.stp b/tapset/context.stp
index 7fd961c8..9f4be0e6 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -6,7 +6,11 @@
// 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.
-
+// <tapsetdescription>
+// Context functions provide additional information about where an event occurred. These functions can
+//provide information such as a backtrace to where the event occured and the current register values for the
+//processor.
+// </tapsetdescription>
/**
* sfunction print_regs - Print a register dump.
*/
@@ -17,37 +21,28 @@ function print_regs () %{
%}
/**
- * sfunction execname - Execname of current processes
- *
- * Return the name of the current process.
+ * sfunction execname - Returns the execname of a target process (or group of processes).
*/
function execname:string () %{ /* pure */
strlcpy (THIS->__retvalue, current->comm, MAXSTRINGLEN);
%}
/**
- * sfunction pid - Process ID of current process
- *
- *
- * Return the id of the current process.
+ * sfunction pid - Returns the ID of a target process.
*/
function pid:long () %{ /* pure */
THIS->__retvalue = current->tgid;
%}
/**
- * sfunction tid - Thread ID of current process
- *
- * Return the id of the current thread.
+ * sfunction tid - Returns the thread ID of a target process.
*/
function tid:long () %{ /* pure */
THIS->__retvalue = current->pid;
%}
/**
- * sfunction ppid - Parent Process ID of current process
- *
- * Return the id of the parent process.
+ * sfunction ppid - Returns the process ID of a target process's parent process.
*/
function ppid:long () %{ /* pure */
#if defined(STAPCONF_REAL_PARENT)
@@ -58,9 +53,7 @@ function ppid:long () %{ /* pure */
%}
/**
- * sfunction pexecname - Execname of the parent process.
- *
- * Return the name of the parent process.
+ * sfunction pexecname - Returns the execname of a target process's parent process.
*/
function pexecname:string () %{ /* pure */
#if defined(STAPCONF_REAL_PARENT)
@@ -71,9 +64,7 @@ function pexecname:string () %{ /* pure */
%}
/**
- * sfunction gid - Group ID of current process
- *
- * Return the gid of the current process.
+ * sfunction gid - Returns the group ID of a target process.
*/
function gid:long () %{ /* pure */
#ifdef STAPCONF_TASK_UID
@@ -84,9 +75,7 @@ function gid:long () %{ /* pure */
%}
/**
- * sfunction egid - Effective gid of the current process.
- *
- * Return the effective gid of the current process.
+ * sfunction egid - Returns the effective gid of a target process.
*/
function egid:long () %{ /* pure */
#ifdef STAPCONF_TASK_UID
@@ -97,9 +86,7 @@ function egid:long () %{ /* pure */
%}
/**
- * sfunction uid -User ID of the current process.
- *
- * Return the uid of the current process.
+ * sfunction uid - Returns the user ID of a target process.
*/
function uid:long () %{ /* pure */
#ifdef STAPCONF_TASK_UID
@@ -110,9 +97,7 @@ function uid:long () %{ /* pure */
%}
/**
- * sfunction euid - Effective User ID of the current process.
- *
- * Return the effective uid of the current process.
+ * sfunction euid - Return the effective uid of a target process.
*/
function euid:long () %{ /* pure */
#ifdef STAPCONF_TASK_UID
@@ -128,26 +113,24 @@ function cpuid:long () %{ /* pure */
%}
/**
- * sfunction cpu - The current cpu number.
- *
- * Return the current cpu number.
+ * sfunction cpu - Returns the current cpu number.
*/
function cpu:long () %{ /* pure */
THIS->__retvalue = smp_processor_id();
%}
/**
- * sfunction pp - Current probe point
- *
- * Return the probe point associated with the currently running
- * probe handler, including alias and wildcard expansion effects.
+ * sfunction pp - Return the probe point associated with the currently running probe handler,
+ * including alias and wildcard expansion effects
+ * Context:
+ * The current probe point.
*/
function pp:string () %{ /* pure */
strlcpy (THIS->__retvalue, CONTEXT->probe_point, MAXSTRINGLEN);
%}
/**
- * sfunction registers_valid - Register information valid
+ * sfunction registers_valid - Determines validity of <command>register()</command> and <command>u_register()</command> in current context.
*
* Return 1 if register() and u_register() can be used
* in the current context, or 0 otherwise.
@@ -159,7 +142,7 @@ function registers_valid:long () %{ /* pure */
%}
/**
- * sfunction user_mode - User Mode
+ * sfunction user_mode - Determines if probe point occurs in user-mode.
*
* Return 1 if the probe point occurred in user-mode.
*/
@@ -176,7 +159,7 @@ function user_mode:long () %{ /* pure */ /* currently a user-mode address? */
%}
/**
- * sfunction is_return - Is return probe
+ * sfunction is_return - Determines if probe point is a return probe.
*
* Return 1 if the probe point is a return probe.
* <emphasis>Deprecated.</emphasis>
@@ -189,9 +172,7 @@ function is_return:long () %{ /* pure */
%}
/**
- * sfunction target - Target pid
- *
- * Return the pid of the target process.
+ * sfunction target - Return the process ID of the target process.
*/
function target:long () %{ /* pure */
THIS->__retvalue = _stp_target;
@@ -220,18 +201,16 @@ function stp_pid:long () %{ /* pure */
%}
/**
- * sfunction stack_size - Size of kernel stack
- *
- * Return the size of the kernel stack.
+ * sfunction stack_size - Return the size of the kernel stack.
*/
function stack_size:long () %{ /* pure */
THIS->__retvalue = THREAD_SIZE;
%}
/**
- * sfunction stack_used - Current amount of kernel stack used
+ * sfunction stack_used - Returns the amount of kernel stack used.
*
- * Return how many bytes are currently used in the kernel stack.
+ * Determines how many bytes are currently used in the kernel stack.
*/
function stack_used:long () %{ /* pure */
char a;
@@ -239,9 +218,9 @@ function stack_used:long () %{ /* pure */
%}
/**
- * sfunction stack_unused - Amount of kernel stack currently available
+ * sfunction stack_unused - Returns the amount of kernel stack currently available.
*
- * Return how many bytes are currently available in the kernel stack.
+ * Determines how many bytes are currently available in the kernel stack.
*/
function stack_unused:long () %{ /* pure */
char a;
diff --git a/tapset/ioscheduler.stp b/tapset/ioscheduler.stp
index d7a71aca..a79ae752 100644
--- a/tapset/ioscheduler.stp
+++ b/tapset/ioscheduler.stp
@@ -5,15 +5,17 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe IO scheduler activities.
+// </tapsetdescription>
%{
#include <linux/blkdev.h>
#include <linux/elevator.h>
%}
/**
- * probe ioscheduler.elv_next_request - Retrieve request from request queue
- * @elevator_name: The elevator name
+ * probe ioscheduler.elv_next_request - Fires when a request is retrieved from the request queue
+ * @elevator_name: The type of I/O elevator currently enabled
*/
probe ioscheduler.elv_next_request
= kernel.function("elv_next_request")
@@ -26,7 +28,7 @@ probe ioscheduler.elv_next_request
}
/**
- * probe ioscheduler.elv_next_request.return - Return from retrieving a request
+ * probe ioscheduler.elv_next_request.return - Fires when a request retrieval issues a return signal
* @req: Address of the request
* @req_flags: Request flags
* @disk_major: Disk major number of the request
@@ -58,14 +60,14 @@ probe ioscheduler.elv_next_request.return
}
/**
- * probe ioscheduler.elv_add_request - Add a request into request queue
- * @elevator_name: The elevator name
+ * probe ioscheduler.elv_add_request - A request was added to the request queue
+ * @elevator_name: The type of I/O elevator currently enabled
* @req: Address of the request
* @req_flags: Request flags
* @disk_major: Disk major number of the request
* @disk_minor: Disk minor number of the request
*/
-/* when a request is added to the request queue */
+// when a request is added to the request queue
probe ioscheduler.elv_add_request
= kernel.function("__elv_add_request")
{
@@ -96,8 +98,8 @@ probe ioscheduler.elv_add_request
}
/**
- * probe ioscheduler.elv_completed_request - Request is completed
- * @elevator_name: The elevator name
+ * probe ioscheduler.elv_completed_request - Fires when a request is completed
+ * @elevator_name: The type of I/O elevator currently enabled
* @req: Address of the request
* @req_flags: Request flags
* @disk_major: Disk major number of the request
diff --git a/tapset/ip.stp b/tapset/ip.stp
new file mode 100644
index 00000000..1e2e263c
--- /dev/null
+++ b/tapset/ip.stp
@@ -0,0 +1,32 @@
+// IP tapset
+// Copyright (C) 2009, IBM Inc.
+// Author : Breno Leitao <leitao@linux.vnet.ibm.com>
+//
+// This file is free software. You can redistribute it and/or modify it under
+// the terms of the GNU General Public License (GPL), version 2.
+//
+// Based on previous work done by Arnaldo Carvalho de Melo <acme@redhat.com>
+
+/**
+ * sfunction ip_ntop - returns a string representation from an integer IP number
+ * @addr: the ip represented as an integer
+ */
+function ip_ntop:string (addr:long)
+%{
+ __be32 ip;
+
+ ip = THIS->addr;
+ snprintf(THIS->__retvalue, MAXSTRINGLEN, NIPQUAD_FMT, NIPQUAD(ip));
+%}
+
+/* return the source IP address for a given sock */
+function __ip_sock_saddr:long (sock:long)
+{
+ return @cast(sock, "inet_sock")->saddr
+}
+
+/* return the destination IP address for a given sock */
+function __ip_sock_daddr:long (sock:long)
+{
+ return @cast(sock, "inet_sock")->daddr
+}
diff --git a/tapset/memory.stp b/tapset/memory.stp
index 961cca38..83875aa4 100644
--- a/tapset/memory.stp
+++ b/tapset/memory.stp
@@ -6,6 +6,9 @@
// 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.
+// <tapsetdescription>
+// This family of probe points is used to probe memory-related events.
+// </tapsetdescription>
%{
#include <linux/mm.h>
%}
@@ -53,7 +56,7 @@ function vm_fault_contains:long (value:long, test:long)
/**
* probe vm.pagefault - Records that a page fault occurred.
* @address: The address of the faulting memory access; i.e. the address that caused the page fault.
- * @write_access: Indicates whether this was a write or read access; <command>1</command> indicates a write,
+ * @write_access: Indicates whether this was a write or read access; <command>1</command> indicates a write,
* while <command>0</command> indicates a read.
*
* Context: The process which triggered the fault
@@ -97,7 +100,7 @@ function addr_to_node:long(addr:long) %{ /* pure */
}
%}
-/* Return whether a page to be copied is a zero page. */
+// Return whether a page to be copied is a zero page.
function _IS_ZERO_PAGE:long(from:long, vaddr:long) %{ /* pure */
THIS->__retvalue = (THIS->from == (long) ZERO_PAGE(THIS->vaddr));
%}
@@ -110,8 +113,8 @@ function _IS_ZERO_PAGE:long(from:long, vaddr:long) %{ /* pure */
* Context:
* The context is the process attempting the write.
*
- * Fires when a process attempts to write to a shared page.
- * If a copy is necessary, this will be followed by a
+ * Fires when a process attempts to write to a shared page.
+ * If a copy is necessary, this will be followed by a
* <command>vm.write_shared_copy</command>.
*/
probe vm.write_shared = kernel.function("do_wp_page") {
@@ -119,7 +122,7 @@ probe vm.write_shared = kernel.function("do_wp_page") {
}
/**
- * probe vm.write_shared_copy- Page copy for shared page write.
+ * probe vm.write_shared_copy - Page copy for shared page write.
* @address: The address of the shared write.
* @zero: Boolean indicating whether it is a zero page
* (can do a clear instead of a copy).
diff --git a/tapset/networking.stp b/tapset/networking.stp
index a147441a..f6d78536 100644
--- a/tapset/networking.stp
+++ b/tapset/networking.stp
@@ -5,7 +5,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe the activities of the network device.
+// </tapsetdescription>
/**
* probe netdev.receive - Data recieved from network device.
* @dev_name: The name of the device. e.g: eth0, ath1.
@@ -49,7 +51,7 @@
///
/// </variablelist>
///</para>
-/* Main device receive routine, be called when packet arrives on network device */
+// Main device receive routine, be called when packet arrives on network device
probe netdev.receive
= kernel.function("netif_receive_skb")
{
@@ -67,7 +69,7 @@ probe netdev.receive
* @truesize: The size of the the data to be transmitted.
*
*/
-/* Queue a buffer for transmission to a network device */
+// Queue a buffer for transmission to a network device
probe netdev.transmit
= kernel.function("dev_queue_xmit")
{
diff --git a/tapset/process.stp b/tapset/process.stp
index ca49aa67..e39f740a 100644
--- a/tapset/process.stp
+++ b/tapset/process.stp
@@ -5,7 +5,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe process-related activities.
+// </tapsetdescription>
function _IS_ERR:long(ptr:long) %{ /* pure */
THIS->__retvalue = IS_ERR((const void *)(long)THIS->ptr);
diff --git a/tapset/scsi.stp b/tapset/scsi.stp
index 6d332e8b..e1457739 100644
--- a/tapset/scsi.stp
+++ b/tapset/scsi.stp
@@ -5,7 +5,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe SCSI activities.
+// </tapsetdescription>
%{
#include <linux/types.h>
#include <scsi/scsi_cmnd.h>
@@ -21,7 +23,7 @@
* @disk_minor: The minor number of the disk (-1 if no information)
* @device_state: The current state of the device.
*/
-/* FIXME describe the device_state */
+// FIXME describe the device_state
probe scsi.ioentry
= module("scsi_mod").function("scsi_prep_fn@drivers/scsi/scsi_lib.c")?,
kernel.function("scsi_prep_fn@drivers/scsi/scsi_lib.c")?
@@ -44,9 +46,9 @@ probe scsi.ioentry
* @lun: The lun number
* @dev_id: The scsi device id
* @device_state: The current state of the device.
- * @data_direction: The data_direction specifies whether this command is from/to
- * the device. 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE),
- * 2 (DMA_FROM_DEVICE), 3 (DMA_NONE)
+ * @data_direction: The data_direction specifies whether this command is from/to the device.
+ * 0 (DMA_BIDIRECTIONAL), 1 (DMA_TO_DEVICE),
+ * 2 (DMA_FROM_DEVICE), 3 (DMA_NONE)
* @request_buffer: The request buffer address
* @req_bufflen: The request buffer length
*/
@@ -79,7 +81,7 @@ probe scsi.iodispatching
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @data_direction: The data_direction specifies whether this command is
- * from/to the device.
+ * from/to the device.
*/
probe scsi.iodone
= module("scsi_mod").function("scsi_done@drivers/scsi/scsi.c")?,
@@ -104,10 +106,10 @@ probe scsi.iodone
* @dev_id: The scsi device id
* @device_state: The current state of the device
* @data_direction: The data_direction specifies whether this command is from/to
- * the device
+ * the device
* @goodbytes: The bytes completed.
*/
-/* mid-layer processes the completed IO */
+// mid-layer processes the completed IO
probe scsi.iocompleted
= module("scsi_mod").function("scsi_io_completion@drivers/scsi/scsi_lib.c")?,
kernel.function("scsi_io_completion@drivers/scsi/scsi_lib.c")?
diff --git a/tapset/signal.stp b/tapset/signal.stp
index 8fb6fe57..e8470a9c 100644
--- a/tapset/signal.stp
+++ b/tapset/signal.stp
@@ -8,16 +8,17 @@
// Public License (GPL); either version 2, or (at your option) any
// later version.
//
-// Note : Since there are so many signals sent to processes at any give
-// point, it's better to filter the information according to the
-// requirements. For example, filter only for a particular signal
-// (if sig==2) or filter only for a particular process
-// (if pid_name==stap).
//
-
+// <tapsetdescription>
+// This family of probe points is used to probe signal activities.
+// Since there are so many signals sent to processes at any given
+// point, it is advisable to filter the information according to the
+// requirements. For example, filter only for a particular signal
+// (if sig==2) or for a particular process (if pid_name==stap).
+// </tapsetdescription>
/**
- * probe signal.send- Fires when a system call or kernel function sends a signal to a process.
+ * probe signal.send - Signal being sent to a process
* Arguments:
* @sig: The number of the signal
* @sig_name: A string representation of the signal
@@ -27,9 +28,10 @@
* @task: A task handle to the signal recipient
* @sinfo: The address of <command>siginfo</command> struct
* @shared: Indicates whether the signal is shared by the thread group
- * @send2queue- Indicates whether the signal is sent to an existing <command>sigqueue</command>
+ * @send2queue: Indicates whether the signal is sent to an existing
+ * <command>sigqueue</command>
* @name: The name of the function used to send out the signal
- *
+ *
* Context:
* The signal's sender.
*
@@ -114,42 +116,41 @@ probe _signal.send.part3 = kernel.function("send_sigqueue")
}
/**
- * probe signal.send.return - Fires when a signal sent to a process returns.
+ * probe signal.send.return - Signal being sent to a process completed
* @retstr: The return value to either <command>__group_send_sig_info</command>,
- * <command>specific_send_sig_info</command>, or <command>send_sigqueue</command>.
- * Refer to the Description of this probe for more information about the return
- * values of each function call.
+ * <command>specific_send_sig_info</command>,
+ * or <command>send_sigqueue</command>
* @shared: Indicates whether the sent signal is shared by the thread group.
- * @send2queue: Indicates whether the sent signal was sent to an existing <command>sigqueue</command>
- * @name: The name of the function used to send out the signal.
- *
+ * @send2queue: Indicates whether the sent signal was sent to an
+ * existing <command>sigqueue</command>
+ * @name: The name of the function used to send out the signal
+ *
* Context:
* The signal's sender. <remark>(correct?)</remark>
- *
+ *
* Possible <command>__group_send_sig_info</command> and
* <command>specific_send_sig_info</command> return values are as follows;
*
- * <command>0</command> - The signal is sucessfully sent to a process,
+ * <command>0</command> -- The signal is sucessfully sent to a process,
* which means that
* <1> the signal was ignored by the receiving process,
* <2> this is a non-RT signal and the system already has one queued, and
* <3> the signal was successfully added to the <command>sigqueue</command> of the receiving process.
*
- * <command>-EAGAIN</command> - The <command>sigqueue</command> of the receiving process is
+ * <command>-EAGAIN</command> -- The <command>sigqueue</command> of the receiving process is
* overflowing, the signal was RT, and the signal was sent by a user using something other
- * than <command>kill()</command>
- *
+ * than <command>kill()</command>.
+ *
* Possible <command>send_group_sigqueue</command> and
* <command>send_sigqueue</command> return values are as follows;
- *
- * <command>0</command> - The signal was either sucessfully added into the
+ *
+ * <command>0</command> -- The signal was either sucessfully added into the
* <command>sigqueue</command> of the receiving process, or a <command>SI_TIMER</command> entry is already
* queued (in which case, the overrun count will be simply incremented).
*
- * <command>1</command> - The signal was ignored by the receiving process.
- *
+ * <command>1</command> -- The signal was ignored by the receiving process.
*
- * <command>-1</command> - (<command>send_sigqueue</command> only) The task was marked
+ * <command>-1</command> -- (<command>send_sigqueue</command> only) The task was marked
* <command>exiting</command>, allowing * <command>posix_timer_event</command> to redirect it to the group
* leader.
*
@@ -232,7 +233,7 @@ probe _signal.send.part3.return = kernel.function("send_sigqueue").return
}
/**
- * probe signal.checkperm - Fires when a permission check is performed on a sent signal
+ * probe signal.checkperm - Check being performed on a sent signal
* @sig: The number of the signal
* @sig_name: A string representation of the signal
* @sig_pid: The PID of the process receiving the signal
@@ -240,7 +241,8 @@ probe _signal.send.part3.return = kernel.function("send_sigqueue").return
* @si_code: Indicates the signal type
* @task: A task handle to the signal recipient
* @sinfo: The address of the <command>siginfo</command> structure
- * @name: Name of the probe point; default value is <command>signal.checkperm</command>
+ * @name: Name of the probe point; default value is
+ * <command>signal.checkperm</command>
*/
probe signal.checkperm = kernel.function("check_kill_permission")
{
@@ -261,6 +263,12 @@ probe signal.checkperm = kernel.function("check_kill_permission")
si_code="SI_USER or SI_TIMER or SI_ASYNCIO"
}
+/**
+ * probe signal.checkperm.return - Check performed on a sent signal completed
+ * @name: Name of the probe point; default value is
+ * <command>signal.checkperm</command>
+ * @retstr: Return value as a string
+ */
probe signal.checkperm.return = kernel.function("check_kill_permission").return
{
name = "signal.checkperm"
@@ -269,15 +277,15 @@ probe signal.checkperm.return = kernel.function("check_kill_permission").return
/**
- * probe signal.wakeup - Wakes up a sleeping process, making it ready for new active signals
- * @sig_pid: The PID of the process you wish to wake
- * @pid_name: Name of the process you wish to wake
- * @resume: Indicates whether to wake up a task in a <command>STOPPED</command> or
- * <command>TRACED</command> state
+ * probe signal.wakeup - Sleeping process being wakened for signal
+ * @sig_pid: The PID of the process to wake
+ * @pid_name: Name of the process to wake
+ * @resume: Indicates whether to wake up a task in a
+ * <command>STOPPED</command> or <command>TRACED</command> state
* @state_mask: A string representation indicating the mask
- * of task states you wish to wake. Possible values are <command>TASK_INTERRUPTIBLE</command>,
- * <command>TASK_STOPPED</command>, <command>TASK_TRACED</command>,
- * and <command>TASK_INTERRUPTIBLE</command>.
+ * of task states to wake. Possible values are
+ * <command>TASK_INTERRUPTIBLE</command>, <command>TASK_STOPPED</command>,
+ * <command>TASK_TRACED</command>, and <command>TASK_INTERRUPTIBLE</command>.
*/
probe signal.wakeup = kernel.function("signal_wake_up")
{
@@ -293,8 +301,7 @@ probe signal.wakeup = kernel.function("signal_wake_up")
/**
- * probe signal.check_ignored - Fires when a system call or kernel function checks whether a
- * signal was ignored or not
+ * probe signal.check_ignored - Checking to see signal is ignored
* @sig_pid: The PID of the process receiving the signal
* @pid_name: Name of the process receiving the signal
* @sig: The number of the signal
@@ -308,6 +315,12 @@ probe signal.check_ignored = kernel.function("sig_ignored")
sig_name = _signal_name($sig)
}
+/**
+ * probe signal.check_ignored.return - Check to see signal is ignored completed
+ * @name: Name of the probe point; default value is
+ * <command>signal.checkperm</command>
+ * @retstr: Return value as a string
+ */
probe signal.check_ignored.return = kernel.function("sig_ignored").return ?
{
name = "sig_ignored"
@@ -333,8 +346,7 @@ probe signal.handle_stop = kernel.function("handle_stop_signal")
/**
- * probe signal.force_segv - Fires when a system call, kernel function, or process sent a
- * <command>SIGSEGV</command> as a result of problems it encountered while handling a received signal
+ * probe signal.force_segv - Forcing send of <command>SIGSEGV</command>
* @sig_pid: The PID of the process receiving the signal
* @pid_name: Name of the process receiving the signal
* @sig: The number of the signal
@@ -360,6 +372,12 @@ probe _signal.force_segv.part2 = kernel.function("force_sigsegv_info") ?
sig_name = _signal_name($sig)
}
+/**
+ * probe signal.force_segv.return - Forcing send of <command>SIGSEGV</command> complete
+ * @name: Name of the probe point; default value is
+ * <command>force_sigsegv</command>
+ * @retstr: Return value as a string
+ */
probe signal.force_segv.return =
kernel.function("force_sigsegv").return,
kernel.function("force_sigsegv_info").return ?
@@ -370,9 +388,8 @@ probe signal.force_segv.return =
/**
- * probe signal.syskill - Fires when the kernel function <command>sys_kill</command>
- * sends a kill signal to a process
- * @pid: The PID of the process receiving the kill signal
+ * probe signal.syskill - Sending kill signal to a process
+ * @pid: The PID of the process receiving the signal
* @sig: The specific signal sent to the process
*/
probe signal.syskill = syscall.kill
@@ -380,33 +397,43 @@ probe signal.syskill = syscall.kill
sig_name = _signal_name($sig)
}
+/**
+ * probe signal.syskill.return - Sending kill signal completed
+ */
probe signal.syskill.return = syscall.kill.return
{
}
+
/**
- * probe signal.sys_tkill - Fires when <command>tkill</command> sends a kill signal
- * to a process that is part of a thread group
+ * probe signal.sys_tkill - Sending a kill signal to a thread
* @pid: The PID of the process receiving the kill signal
* @sig: The specific signal sent to the process
+ * @sig_name: The specific signal sent to the process
+ *
* The <command>tkill</command> call is analogous to <command>kill(2)</command>,
* except that it also allows a process within a specific thread group to
- * be targetted. Such processes are targetted through their unique thread IDs (TID).
+ * be targetted. Such processes are targetted through their unique
+ * thread IDs (TID).
*/
probe signal.systkill = syscall.tkill
{
sig_name = _signal_name($sig)
}
+/**
+ * probe signal.systkill.return - Sending kill signal to a thread completed
+ */
probe signal.systkill.return = syscall.tkill.return
{
}
/**
- * probe signal.sys_tgkill - Fires when the kernel function <command>tgkill</command>
- * sends a kill signal to a specific thread group
+ * probe signal.sys_tgkill - Sending kill signal to a thread group
* @pid: The PID of the thread receiving the kill signal
* @tgid: The thread group ID of the thread receiving the kill signal
* @sig: The specific kill signal sent to the process
+ * @sig_name: A string representation of the signal
+ *
* The <command>tgkill</command> call is similar to <command>tkill</command>,
* except that it also allows the caller to specify the thread group ID of
* the thread to be signalled. This protects against TID reuse.
@@ -416,12 +443,15 @@ probe signal.systgkill = syscall.tgkill
sig_name = _signal_name($sig)
}
+/**
+ * probe signal.sys_tgkill.return - Sending kill signal to a thread group completed
+ */
probe signal.systgkill.return = syscall.tgkill.return
{
}
/**
- * probe signal.send_sig_queue - Fires when a signal is queued to a process
+ * probe signal.send_sig_queue - Queuing a signal to a process
* @sig: The queued signal
* @sig_name: A string representation of the signal
* @sig_pid: The PID of the process to which the signal is queued
@@ -439,6 +469,10 @@ probe signal.send_sig_queue =
sigqueue_addr = $q
}
+/**
+ * probe signal.send_sig_queue.return - Queuing a signal to a process completed
+ * @retstr: Return value as a string
+ */
probe signal.send_sig_queue.return =
kernel.function("send_sigqueue").return,
kernel.function("send_group_sigqueue").return ?
@@ -448,25 +482,25 @@ probe signal.send_sig_queue.return =
/**
- * probe signal.pending - Fires when the <command>SIGPENDING</command> system call is used;
- * this normally occurs when the <command>do_sigpending</command> kernel function is executed
- * @sigset_add: The address of the user-space signal set (<command>sigset_t</command>)
- * @sigset_size: The size of the user-space signal set.
- *
- * Synopsis:
- * <programlisting>long do_sigpending(void __user *set, unsigned long sigsetsize)</programlisting>
+ * probe signal.pending - Examining pending signal
+ * @sigset_add: The address of the user-space signal set
+ * (<command>sigset_t</command>)
+ * @sigset_size: The size of the user-space signal set
*
* This probe is used to examine a set of signals pending for delivery
- * to a specific thread.
+ * to a specific thread. This normally occurs when the
+ * <command>do_sigpending</command> kernel function is executed.
*/
-// long do_sigpending(void __user *set, unsigned long sigsetsize)
-
probe signal.pending = kernel.function("do_sigpending")
{
sigset_add=$set
sigset_size=$sigsetsize
}
+/**
+ * probe signal.pending.return - Examination of pending signal completed
+ * @retstr: Return value as a string
+ */
probe signal.pending.return = kernel.function("do_sigpending").return
{
retstr = returnstr(1)
@@ -474,22 +508,17 @@ probe signal.pending.return = kernel.function("do_sigpending").return
/**
- * probe signal.handle - Fires when the signal handler is invoked
+ * probe signal.handle - Signal handler being invoked
* @sig: The signal number that invoked the signal handler
* @sinfo: The address of the <command>siginfo</command> table
- * @sig_code: The <command>si_code</command> value of the <command>siginfo</command> signal
- * @ka_addr: The address of the <command>k_sigaction</command> table associated with the signal
+ * @sig_code: The <command>si_code</command> value of the
+ * <command>siginfo</command> signal
+ * @ka_addr: The address of the <command>k_sigaction</command> table
+ * associated with the signal
* @oldset_addr: The address of the bitmask array of blocked signals
* @regs: The address of the kernel-mode stack area
* @sig_mode: Indicates whether the signal was a user-mode or kernel-mode signal
- *
- * Synopsis:
- * <programlisting>static int handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
- * sigset_t *oldset, struct pt_regs * regs)</programlisting>
*/
-//static int handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
-// sigset_t *oldset, struct pt_regs * regs)
-
probe signal.handle = kernel.function("handle_signal")
{
sig = $sig
@@ -508,6 +537,10 @@ probe signal.handle = kernel.function("handle_signal")
sig_mode = "Kernel Mode Signal"
}
+/**
+ * probe signal.handle.return - Signal handler invocation completed
+ * @retstr: Return value as a string
+ */
probe signal.handle.return = kernel.function("handle_signal").return ?
{
retstr = returnstr(1)
@@ -515,11 +548,12 @@ probe signal.handle.return = kernel.function("handle_signal").return ?
/**
- * probe signal.do_action - Initiates a trace when a thread is about to examine
- * and change a signal action
+ * probe signal.do_action - Examining or changing a signal action
* @sig: The signal to be examined/changed
- * @sigact_addr: The address of the new <command>sigaction</command> struct associated with the signal
- * @oldsigact_addr: The address of the old <command>sigaction</command> struct associated with the signal
+ * @sigact_addr: The address of the new <command>sigaction</command>
+ * struct associated with the signal
+ * @oldsigact_addr: The address of the old <command>sigaction</command>
+ * struct associated with the signal
* @sa_handler: The new handler of the signal
* @sa_mask: The new mask of the signal
*/
@@ -535,6 +569,10 @@ probe signal.do_action = kernel.function("do_sigaction")
}
}
+/**
+ * probe signal.do_action.return - Examining or changing a signal action completed
+ * @retstr: Return value as a string
+ */
probe signal.do_action.return = kernel.function("do_sigaction").return
{
retstr = returnstr(1)
@@ -554,16 +592,17 @@ function __get_action_mask:long(act:long) %{ /* pure */
/**
- * probe signal.procmask - Initiates a trace when a thread is about to examine and change blocked signals
+ * probe signal.procmask - Examining or changing blocked signals
* @how: Indicates how to change the blocked signals; possible values are
* <command>SIG_BLOCK=0</command> (for blocking signals),
* <command>SIG_UNBLOCK=1</command> (for unblocking signals), and
* <command>SIG_SETMASK=2</command> for setting the signal mask.
- * @sigset_addr: The address of the signal set (<command>sigset_t</command>) to be implemented
- * @oldsigset_addr: The old address of the signal set (<command>sigset_t</command>)
- * @sigset: The actual value to be set for <command>sigset_t</command> <remark>(correct?)</remark>
- * Synopsis:
- * <programlisting>int sigprocmask(int how, sigset_t *set, sigset_t *oldset)</programlisting>
+ * @sigset_addr: The address of the signal set (<command>sigset_t</command>)
+ * to be implemented
+ * @oldsigset_addr: The old address of the signal set
+ * (<command>sigset_t</command>)
+ * @sigset: The actual value to be set for <command>sigset_t</command>
+ * <remark>(correct?)</remark>
*/
probe signal.procmask = kernel.function("sigprocmask")
{
@@ -591,16 +630,13 @@ probe signal.procmask.return = kernel.function("sigprocmask").return
/**
- * probe signal.flush - Fires when all pending signals for a task are flushed
+ * probe signal.flush - Flusing all pending signals for a task
* @task: The task handler of the process performing the flush
- * @sig_pid: The PID of the process associated with the task performing the flush
- * @pid_name: The name of the process associated with the task performing the flush
- *
- * Synopsis:
- * <programlisting>void flush_signals(struct task_struct *t)</programlisting>
+ * @sig_pid: The PID of the process associated with the task
+ * performing the flush
+ * @pid_name: The name of the process associated with the task
+ * performing the flush
*/
-//void flush_signals(struct task_struct *t)
-
probe signal.flush = kernel.function("flush_signals")
{
task = $t
diff --git a/tapset/socket.stp b/tapset/socket.stp
index 3271d4f7..0f01b8d4 100644
--- a/tapset/socket.stp
+++ b/tapset/socket.stp
@@ -5,7 +5,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe socket activities.
+// </tapsetdescription>
%{
#include <net/sock.h>
#include <asm/bitops.h>
@@ -65,8 +67,8 @@ probe socket.receive = socket.recvmsg.return,
### FUNCTION SPECIFIC SEND/RECEIVE PROBES ###
-/*
- * probe socket.sendmsg - Message being sent on socket
+/**
+ * probe socket.sendmsg - Message is currently being sent on a socket.
* @name: Name of this probe
* @size: Message size in bytes
* @protocol: Protocol value
@@ -93,7 +95,7 @@ probe socket.sendmsg = kernel.function ("sock_sendmsg")
}
/**
- * probe socket.sendmsg.return - Return from Message being sent on socket
+ * probe socket.sendmsg.return - Return from <command>socket.sendmsg</command>.
* @name: Name of this probe
* @size: Size of message sent (in bytes) or error code if success = 0
* @protocol: Protocol value
@@ -149,7 +151,7 @@ probe socket.recvmsg = kernel.function ("sock_recvmsg")
type = $sock->type
}
-/*
+/**
* probe socket.recvmsg.return - Return from Message being received on socket
* @name: Name of this probe
* @size: Size of message received (in bytes) or error code if success = 0
@@ -196,14 +198,14 @@ probe socket.recvmsg.return = kernel.function ("sock_recvmsg").return
* Fires at the beginning of sending a message on a socket
* via the sock_aio_write() function
*/
-/*
- * 2.6.9~2.6.15:
- * static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t size, loff_t pos);
- * 2.6.16~2.6.18:
- * static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t count, loff_t pos);
- * 2.6.19~2.6.26:
- * static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos);
- */
+//
+// 2.6.9~2.6.15:
+// static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t size, loff_t pos);
+// 2.6.16~2.6.18:
+// static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t count, loff_t pos);
+// 2.6.19~2.6.26:
+// static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos);
+
probe socket.aio_write = kernel.function ("sock_aio_write")
{
name = "socket.aio_write"
@@ -270,14 +272,14 @@ probe socket.aio_write.return = kernel.function ("sock_aio_write").return
* Fires at the beginning of receiving a message on a socket
* via the sock_aio_read() function
*/
-/*
- * 2.6.9~2.6.15:
- * static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t size, loff_t pos);
- * 2.6.16~2.6.18:
- * static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t count, loff_t pos);
- * 2.6.19~2.6.26:
- * static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos);
- */
+//
+// 2.6.9~2.6.15:
+// static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t size, loff_t pos);
+// 2.6.16~2.6.18:
+// static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, size_t count, loff_t pos);
+// 2.6.19~2.6.26:
+// static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos);
+
probe socket.aio_read = kernel.function ("sock_aio_read")
{
name = "socket.aio_read"
@@ -541,18 +543,16 @@ probe socket.close.return = kernel.function ("sock_release").return
####### PROTOCOL HELPER FUNCTIONS ########
-/*
- * sock_prot_num2str
- * Given a protocol number, return a string representation.
+/**
+ * sfunction sock_prot_num2str - Given a protocol number, return a string representation.
*/
function sock_prot_num2str:string (proto:long)
{
return (proto in _prot_num2str ? _prot_num2str[proto] : "UNDEF")
}
-/*
- * sock_prot_str2num
- * Given a protocol name (string), return the corresponding protocol number.
+/**
+ * sfunction sock_prot_str2num - Given a protocol name (string), return the corresponding protocol number.
*/
function sock_prot_str2num:long (proto:string)
{
@@ -561,18 +561,16 @@ function sock_prot_str2num:long (proto:string)
######### PROTOCOL FAMILY HELPER FUNCTIONS ###########
-/*
- * sock_fam_num2str
- * Given a protocol family number, return a string representation.
+/**
+ * sfunction sock_fam_num2str - Given a protocol family number, return a string representation.
*/
function sock_fam_num2str:string (family:long)
{
return (family in _fam_num2str ? _fam_num2str[family] : "UNDEF")
}
-/*
- * sock_fam_str2num
- * Given a protocol family name (string), return the corresponding
+/**
+ * sfunction sock_fam_str2num - Given a protocol family name (string), return the corresponding
* protocol family number.
*/
function sock_fam_str2num:long (family:string)
@@ -582,18 +580,16 @@ function sock_fam_str2num:long (family:string)
######### SOCKET STATE HELPER FUNCTIONS ##########
-/*
- * sock_state_num2str
- * Given a socket state number, return a string representation.
+/**
+ * sfunction sock_state_num2str - Given a socket state number, return a string representation.
*/
function sock_state_num2str:string (state:long)
{
return (state in _state_num2str ? _state_num2str[state] : "UNDEF")
}
-/*
- * sock_state_str2num
- * Given a socket state string, return the corresponding state number.
+/**
+ * sfunction sock_state_str2num - Given a socket state string, return the corresponding state number.
*/
function sock_state_str2num:long (state:string)
{
diff --git a/tapset/task.stp b/tapset/task.stp
index 07337156..f1a10b0a 100644
--- a/tapset/task.stp
+++ b/tapset/task.stp
@@ -63,6 +63,30 @@ function task_pid:long (task:long)
}
+// Return the task of the given process id
+function pid2task:long (pid:long) %{ /* pure */
+ struct task_struct *t = NULL;
+ pid_t t_pid = (pid_t)(long)THIS->pid;
+ rcu_read_lock();
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
+ t = find_task_by_vpid (t_pid);
+#else
+ t = find_task_by_pid (t_pid);
+#endif
+ rcu_read_unlock();
+ THIS->__retvalue = (long)t;
+ CATCH_DEREF_FAULT();
+%}
+
+// Return the name of the given process id
+function pid2execname:string (pid:long) {
+ tsk = pid2task(pid)
+ if (tsk)
+ return task_execname(tsk)
+ return ""
+}
+
+
// Return the thread id of the given task
function task_tid:long (task:long)
{
diff --git a/tapset/tcp.stp b/tapset/tcp.stp
index 995d6abc..bb96b0cb 100644
--- a/tapset/tcp.stp
+++ b/tapset/tcp.stp
@@ -7,7 +7,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe events that occur in the TCP layer,
+// </tapsetdescription>
%{
#include <linux/version.h>
#include <net/sock.h>
@@ -71,6 +73,16 @@ function tcp_ts_get_info_state:long(sock:long)
CATCH_DEREF_FAULT();
%}
+/* return the TCP destination port for a given sock */
+function __tcp_sock_dport:long (sock:long){
+ return @cast(sock, "inet_sock")->dport
+}
+
+/* return the TCP source port for a given sock */
+function __tcp_sock_sport:long (sock:long){
+ return @cast(sock, "inet_sock")->sport
+}
+
global sockstate[13], sockstate_init_p
function tcp_sockstate_str:string (state:long) {
if (! sockstate_init_p) {
@@ -180,6 +192,10 @@ probe tcp.sendmsg.return = kernel.function("tcp_sendmsg").return {
* @name: Name of this probe
* @sock: Network socket
* @size: Number of bytes to be 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
* Context:
* The process which receives a tcp message
*/
@@ -187,12 +203,20 @@ probe tcp.recvmsg = kernel.function("tcp_recvmsg") {
name = "tcp.recvmsg"
sock = $sk
size = $len
+ saddr = ip_ntop(__ip_sock_saddr($sk))
+ daddr = ip_ntop(__ip_sock_daddr($sk))
+ sport = __tcp_sock_sport($sk)
+ dport = __tcp_sock_dport($sk)
}
/**
* probe tcp.recvmsg.return - Receiving TCP message complete
* @name: Name of this probe
* @size: Number of bytes received or error code if an error occurred.
+ * @saddr: A string representing the source IP address
+ * @daddr: A string representing the destination IP address
+ * @sport: TCP source port
+ * @dport: TCP destination port
*
* Context:
* The process which receives a tcp message
@@ -200,6 +224,10 @@ probe tcp.recvmsg = kernel.function("tcp_recvmsg") {
probe tcp.recvmsg.return = kernel.function("tcp_recvmsg").return {
name = "tcp.recvmsg"
size = $return
+ saddr = ip_ntop(__ip_sock_saddr($sk))
+ daddr = ip_ntop(__ip_sock_daddr($sk))
+ sport = __tcp_sock_sport($sk)
+ dport = __tcp_sock_dport($sk)
}
/**
@@ -207,6 +235,10 @@ probe tcp.recvmsg.return = kernel.function("tcp_recvmsg").return {
* @name: Name of this probe
* @sock: Network socket
* @flags: TCP flags (e.g. FIN, etc)
+ * @saddr: A string representing the source IP address
+ * @daddr: A string representing the destination IP address
+ * @sport: TCP source port
+ * @dport: TCP destination port
*
* Context:
* The process which disconnects tcp
@@ -215,6 +247,10 @@ probe tcp.disconnect = kernel.function("tcp_disconnect") {
name = "tcp.disconnect"
sock = $sk
flags = $flags
+ saddr = ip_ntop(__ip_sock_saddr($sk))
+ daddr = ip_ntop(__ip_sock_daddr($sk))
+ sport = __tcp_sock_sport($sk)
+ dport = __tcp_sock_dport($sk)
}
/**
diff --git a/tapset/timestamp.stp b/tapset/timestamp.stp
index ce8f7558..0b9d350a 100644
--- a/tapset/timestamp.stp
+++ b/tapset/timestamp.stp
@@ -6,7 +6,11 @@
// 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.
-
+// <tapsetdescription>
+// Each timestamp function returns a value to indicate when a function is executed. These
+//returned values can then be used to indicate when an event occurred, provide an ordering for events,
+//or compute the amount of time elapsed between two time stamps.
+// </tapsetdescription>
/**
* sfunction get_cycles - Processor cycle count.
*
diff --git a/tapset/udp.stp b/tapset/udp.stp
index 707cf77d..2255074a 100644
--- a/tapset/udp.stp
+++ b/tapset/udp.stp
@@ -5,7 +5,9 @@
// 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.
-
+// <tapsetdescription>
+// This family of probe points is used to probe events that occur in the UDP layer.
+// </tapsetdescription>
%{
#include <linux/version.h>
#include <net/sock.h>
@@ -15,12 +17,12 @@
/**
* probe udp.sendmsg - Fires whenever a process sends a UDP message
- * @name: Name of this probe
- * @sock: Network socket
- * @size: Number of bytes to send
+ * @name: The name of this probe
+ * @sock: Network socket used by the process
+ * @size: Number of bytes sent by the process
*
* Context:
- * The process which sends a udp message
+ * The process which sent a UDP message
*/
probe udp.sendmsg = kernel.function("udp_sendmsg") {
name = "udp.sendmsg"
@@ -30,11 +32,11 @@ probe udp.sendmsg = kernel.function("udp_sendmsg") {
/**
* probe udp.sendmsg.return - Fires whenever an attempt to send a UDP message is completed
- * @name: Name of this probe
- * @size: Number of bytes sent
+ * @name: The name of this probe
+ * @size: Number of bytes sent by the process
*
* Context:
- * The process which sends a udp message
+ * The process which sent a UDP message
*/
probe udp.sendmsg.return = kernel.function("udp_sendmsg").return {
name = "udp.sendmsg"
@@ -43,12 +45,12 @@ probe udp.sendmsg.return = kernel.function("udp_sendmsg").return {
/**
* probe udp.recvmsg - Fires whenever a UDP message is received
- * @name: Name of this probe
- * @sock: Network socket
- * @size: Number of bytes received
+ * @name: The name of this probe
+ * @sock: Network socket used by the process
+ * @size: Number of bytes received by the process
*
* Context:
- * The process which receives a udp message
+ * The process which received a UDP message
*/
probe udp.recvmsg = kernel.function("udp_recvmsg") {
name = "udp.recvmsg"
@@ -57,12 +59,12 @@ probe udp.recvmsg = kernel.function("udp_recvmsg") {
}
/**
- * probe udp.recvmsg.return - An attempt to receive a UDP message received has been completed
- * @name: Name of this probe
- * @size: Number of bytes received
+ * probe udp.recvmsg.return - Fires whenever an attempt to receive a UDP message received is completed
+ * @name: The name of this probe
+ * @size: Number of bytes received by the process
*
* Context:
- * The process which receives a udp message
+ * The process which received a UDP message
*/
probe udp.recvmsg.return = kernel.function("udp_recvmsg").return {
name = "udp.recvmsg"
@@ -70,13 +72,13 @@ probe udp.recvmsg.return = kernel.function("udp_recvmsg").return {
}
/**
- * probe udp.disconnect - A process requests for UPD to be UDP disconnected
- * @name: Name of this probe
- * @sock: Network socket
+ * probe udp.disconnect - Fires when a process requests for a UDP disconnection
+ * @name: The name of this probe
+ * @sock: Network socket used by the process
* @flags: Flags (e.g. FIN, etc)
*
* Context:
- * The process which disconnects UDP
+ * The process which requests a UDP disconnection
*/
probe udp.disconnect = kernel.function("udp_disconnect") {
name = "udp.disconnect"
@@ -86,11 +88,11 @@ probe udp.disconnect = kernel.function("udp_disconnect") {
/**
* probe udp.disconnect.return - UDP has been disconnected successfully
- * @name: Name of this probe
+ * @name: The name of this probe
* @ret: Error code (0: no error)
*
* Context:
- * The process which disconnects udp
+ * The process which requested a UDP disconnection
*/
probe udp.disconnect.return = kernel.function("udp_disconnect").return {
name = "udp.disconnect"
diff --git a/tapsets.cxx b/tapsets.cxx
index b1d0b04e..e9ade595 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -18,6 +18,7 @@
#include "buildrun.h"
#include "dwarf_wrappers.h"
#include "auto_free.h"
+#include "hash.h"
#include <cstdlib>
#include <algorithm>
@@ -206,7 +207,9 @@ common_probe_entryfn_prologue (translator_output* o, string statestr,
o->newline() << "c = per_cpu_ptr (contexts, smp_processor_id());";
o->newline() << "if (atomic_inc_return (& c->busy) != 1) {";
- o->newline(1) << "atomic_inc (& skipped_count);";
+ o->newline(1) << "#if !INTERRUPTIBLE";
+ o->newline() << "atomic_inc (& skipped_count);";
+ o->newline() << "#endif";
o->newline() << "#ifdef STP_TIMING";
o->newline() << "atomic_inc (& skipped_count_reentrant);";
o->newline() << "#ifdef DEBUG_REENTRANCY";
@@ -3521,9 +3524,17 @@ dwarf_query::blacklisted_p(const string& funcname,
if (! (goodfn && goodfile))
{
- if (sess.verbose>1)
- clog << " skipping - blacklisted";
- return true;
+ if (sess.guru_mode)
+ {
+ if (sess.verbose>1)
+ clog << " guru mode enabled - ignoring blacklist";
+ }
+ else
+ {
+ if (sess.verbose>1)
+ clog << " skipping - blacklisted";
+ return true;
+ }
}
// This probe point is not blacklisted.
@@ -4842,18 +4853,31 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e)
}
catch (const semantic_error& er)
{
- // We suppress this error message, and pass the unresolved
- // target_symbol to the next pass. We hope that this value ends
- // up not being referenced after all, so it can be optimized out
- // quietly.
- provide (e);
- semantic_error* saveme = new semantic_error (er); // copy it
- saveme->tok1 = e->tok; // XXX: token not passed to q.dw code generation routines
- // NB: we can have multiple errors, since a $target variable
- // may be expanded in several different contexts:
- // function ("*") { $var }
- saveme->chain = e->saved_conversion_error;
- e->saved_conversion_error = saveme;
+ if (!q.sess.skip_badvars)
+ {
+ // We suppress this error message, and pass the unresolved
+ // target_symbol to the next pass. We hope that this value ends
+ // up not being referenced after all, so it can be optimized out
+ // quietly.
+ provide (e);
+ semantic_error* saveme = new semantic_error (er); // copy it
+ saveme->tok1 = e->tok; // XXX: token not passed to q.dw code generation routines
+ // NB: we can have multiple errors, since a $target variable
+ // may be expanded in several different contexts:
+ // function ("*") { $var }
+ saveme->chain = e->saved_conversion_error;
+ e->saved_conversion_error = saveme;
+ }
+ else
+ {
+ // Upon user request for ignoring context, the symbol is replaced
+ // with a literal 0 and a warning message displayed
+ literal_number* ln_zero = new literal_number (0);
+ ln_zero->tok = e->tok;
+ provide (ln_zero);
+ q.sess.print_warning ("Bad variable being substituted with literal 0",
+ e->tok);
+ }
delete fdecl;
delete ec;
return;
@@ -5004,7 +5028,7 @@ void dwarf_cast_expanding_visitor::visit_cast_op (cast_op* e)
// split the module string by ':' for alternatives
size_t mod_begin = mod_end + 1;
mod_end = e->module.find(':', mod_begin);
- string module = e->module.substr(mod_begin, mod_end);
+ string module = e->module.substr(mod_begin, mod_end - mod_begin);
// NB: This uses '/' to distinguish between kernel modules and userspace,
// which means that userspace modules won't get any PATH searching.
@@ -5046,7 +5070,8 @@ void dwarf_cast_expanding_visitor::visit_cast_op (cast_op* e)
// cast_op to the next pass. We hope that this value ends
// up not being referenced after all, so it can be optimized out
// quietly.
- semantic_error* er = new semantic_error ("type definition not found", e->tok);
+ string msg = "type definition '" + e->type + "' not found";
+ semantic_error* er = new semantic_error (msg, e->tok);
// NB: we can have multiple errors, since a @cast
// may be expanded in several different contexts:
// function ("*") { @cast(...) }
@@ -6227,6 +6252,9 @@ task_finder_derived_probe_group::emit_module_exit (systemtap_session& s)
// ------------------------------------------------------------------------
+static string TOK_INSN("insn");
+static string TOK_BLOCK("block");
+
struct itrace_derived_probe: public derived_probe
{
bool has_path;
@@ -6301,7 +6329,7 @@ struct itrace_builder: public derived_probe_builder
// XXX: PR 6445 needs !has_path && !has_pid support
assert (has_path || has_pid);
- single_step = 1;
+ single_step = ! has_null_param (parameters, TOK_BLOCK);
// If we have a path, we need to validate it.
if (has_path)
@@ -7159,10 +7187,8 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
// Emit a "fake" probe decl that is really a hook for to get
// our vm_callback called.
string path = it->first;
- s.op->newline() << "#ifdef DEBUG_TASK_FINDER_VMA";
emit_vm_callback_probe_decl (s, true, path, (int64_t)0,
"__stp_tf_vm_cb");
- s.op->newline() << "#endif";
for (unsigned i = 0; i < it->second.size(); i++)
{
@@ -7180,10 +7206,8 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s)
{
// Emit a "fake" probe decl that is really a hook for to get
// our vm_callback called.
- s.op->newline() << "#ifdef DEBUG_TASK_FINDER_VMA";
emit_vm_callback_probe_decl (s, false, "", it->first,
"__stp_tf_vm_cb");
- s.op->newline() << "#endif";
for (unsigned i = 0; i < it->second.size(); i++)
{
@@ -9221,10 +9245,10 @@ mark_builder::build(systemtap_session & sess,
struct tracepoint_arg
{
- string name, c_type;
- bool used, isptr;
+ string name, c_type, typecast;
+ bool usable, used, isptr;
Dwarf_Die type_die;
- tracepoint_arg(): used(false), isptr(false) {}
+ tracepoint_arg(): usable(false), used(false), isptr(false) {}
};
struct tracepoint_derived_probe: public derived_probe
@@ -9276,7 +9300,7 @@ tracepoint_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e)
// search for a tracepoint parameter matching this name
tracepoint_arg *arg = NULL;
for (unsigned i = 0; i < args.size(); ++i)
- if (args[i].name == argname)
+ if (args[i].usable && args[i].name == argname)
{
arg = &args[i];
arg->used = true;
@@ -9324,6 +9348,9 @@ tracepoint_var_expanding_visitor::visit_target_symbol_arg (target_symbol* e)
if (lvalue && (!dw.sess.guru_mode || e->components.empty()))
throw semantic_error("write to tracepoint variable '" + e->base_name
+ "' not permitted", e->tok);
+ // XXX: if a struct/union arg is passed by value, then writing to its fields
+ // is also meaningless until you dereference past a pointer member. It's
+ // harder to detect and prevent that though...
if (e->components.empty())
{
@@ -9495,6 +9522,8 @@ tracepoint_var_expanding_visitor::visit_target_symbol_context (target_symbol* e)
for (unsigned i = 0; i < args.size(); ++i)
{
+ if (!args[i].usable)
+ continue;
if (i > 0)
pf->raw_components += " ";
pf->raw_components += args[i].name;
@@ -9577,32 +9606,39 @@ tracepoint_derived_probe::tracepoint_derived_probe (systemtap_session& s,
static bool
dwarf_type_name(Dwarf_Die& type_die, string& c_type)
{
- // if this die has a direct name, then we're done
- const char *diename = dwarf_diename_integrate(&type_die);
- if (diename != NULL)
+ // if we've gotten down to a basic type, then we're done
+ bool done = true;
+ switch (dwarf_tag(&type_die))
{
- switch (dwarf_tag(&type_die))
- {
- case DW_TAG_structure_type:
- c_type.append("struct ");
- break;
- case DW_TAG_union_type:
- c_type.append("union ");
- break;
- }
- c_type.append(diename);
+ case DW_TAG_structure_type:
+ c_type.append("struct ");
+ break;
+ case DW_TAG_union_type:
+ c_type.append("union ");
+ break;
+ case DW_TAG_typedef:
+ case DW_TAG_base_type:
+ break;
+ default:
+ done = false;
+ break;
+ }
+ if (done)
+ {
+ c_type.append(dwarf_diename_integrate(&type_die));
return true;
}
// otherwise, this die is a type modifier.
// recurse into the referent type
+ // if it can't be named, just call it "void"
Dwarf_Attribute subtype_attr;
Dwarf_Die subtype_die;
if (!dwarf_attr_integrate(&type_die, DW_AT_type, &subtype_attr)
|| !dwarf_formref_die(&subtype_attr, &subtype_die)
|| !dwarf_type_name(subtype_die, c_type))
- return false;
+ c_type = "void";
const char *suffix = NULL;
switch (dwarf_tag(&type_die))
@@ -9623,33 +9659,47 @@ dwarf_type_name(Dwarf_Die& type_die, string& c_type)
return false;
}
c_type.append(suffix);
+
+ // XXX HACK! The va_list isn't usable as found in the debuginfo...
+ if (c_type == "struct __va_list_tag*")
+ c_type = "va_list";
+
return true;
}
static bool
-resolve_tracepoint_arg_type(Dwarf_Die& type_die, bool& isptr)
+resolve_tracepoint_arg_type(tracepoint_arg& arg)
{
Dwarf_Attribute type_attr;
- switch (dwarf_tag(&type_die))
+ switch (dwarf_tag(&arg.type_die))
{
case DW_TAG_typedef:
case DW_TAG_const_type:
case DW_TAG_volatile_type:
// iterate on the referent type
- return (dwarf_attr_integrate(&type_die, DW_AT_type, &type_attr)
- && dwarf_formref_die(&type_attr, &type_die)
- && resolve_tracepoint_arg_type(type_die, isptr));
+ return (dwarf_attr_integrate(&arg.type_die, DW_AT_type, &type_attr)
+ && dwarf_formref_die(&type_attr, &arg.type_die)
+ && resolve_tracepoint_arg_type(arg));
case DW_TAG_base_type:
// base types will simply be treated as script longs
- isptr = false;
+ arg.isptr = false;
return true;
case DW_TAG_pointer_type:
- // pointers can be either script longs,
- // or dereferenced with their referent type
- isptr = true;
- return (dwarf_attr_integrate(&type_die, DW_AT_type, &type_attr)
- && dwarf_formref_die(&type_attr, &type_die));
+ // pointers can be treated as script longs,
+ // and if we know their type, they can also be dereferenced
+ if (dwarf_attr_integrate(&arg.type_die, DW_AT_type, &type_attr)
+ && dwarf_formref_die(&type_attr, &arg.type_die))
+ arg.isptr = true;
+ arg.typecast = "(intptr_t)";
+ return true;
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ // for structs/unions which are passed by value, we turn it into
+ // a pointer that can be dereferenced.
+ arg.isptr = true;
+ arg.typecast = "(intptr_t)&";
+ return true;
default:
// should we consider other types too?
return false;
@@ -9673,12 +9723,12 @@ tracepoint_derived_probe::build_args(dwflpp& dw, Dwarf_Die& func_die)
Dwarf_Attribute type_attr;
if (!dwarf_attr_integrate (&arg, DW_AT_type, &type_attr)
|| !dwarf_formref_die (&type_attr, &tparg.type_die)
- || !dwarf_type_name(tparg.type_die, tparg.c_type)
- || !resolve_tracepoint_arg_type(tparg.type_die, tparg.isptr))
+ || !dwarf_type_name(tparg.type_die, tparg.c_type))
throw semantic_error ("cannot get type of tracepoint '"
+ tracepoint_name + "' parameter '"
+ tparg.name + "'");
+ tparg.usable = resolve_tracepoint_arg_type(tparg);
args.push_back(tparg);
if (sess.verbose > 4)
clog << "found parameter for tracepoint '" << tracepoint_name
@@ -9691,8 +9741,9 @@ tracepoint_derived_probe::build_args(dwflpp& dw, Dwarf_Die& func_die)
void
tracepoint_derived_probe::printargs(std::ostream &o) const
{
- for (unsigned i = 0; i < args.size(); ++i)
- o << " $" << args[i].name << ":" << args[i].c_type;
+ for (unsigned i = 0; i < args.size(); ++i)
+ if (args[i].usable)
+ o << " $" << args[i].name << ":" << args[i].c_type;
}
void
@@ -9719,14 +9770,19 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s)
if (probes.empty())
return;
- s.op->newline() << "/* ---- tracepointer probes ---- */";
+ s.op->newline() << "/* ---- tracepoint probes ---- */";
+ s.op->newline();
for (unsigned i = 0; i < probes.size(); ++i)
{
tracepoint_derived_probe *p = probes[i];
- s.op->newline();
+
+ // emit a separate entry function for each probe, since tracepoints
+ // don't provide any sort of context pointer.
s.op->newline() << "#include <" << p->header << ">";
s.op->newline() << "static void enter_tracepoint_probe_" << i << "(";
+ if (p->args.size() == 0)
+ s.op->line() << "void";
for (unsigned j = 0; j < p->args.size(); ++j)
{
if (j > 0)
@@ -9745,15 +9801,45 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s)
{
s.op->newline() << "c->locals[0]." << p->name << ".__tracepoint_arg_"
<< p->args[j].name << " = (int64_t)";
- if (p->args[j].isptr)
- s.op->line() << "(intptr_t)";
+ s.op->line() << p->args[j].typecast;
s.op->line() << "__tracepoint_arg_" << p->args[j].name << ";";
}
s.op->newline() << p->name << " (c);";
common_probe_entryfn_epilogue (s.op);
s.op->newline(-1) << "}";
+
+ // emit normalized registration functions
+ s.op->newline() << "static int register_tracepoint_probe_" << i << "(void) {";
+ s.op->newline(1) << "return register_trace_" << p->tracepoint_name
+ << "(enter_tracepoint_probe_" << i << ");";
+ s.op->newline(-1) << "}";
+
+ // NB: we're not prepared to deal with unreg failures. However, failures
+ // can only occur if the tracepoint doesn't exist (yet?), or if we
+ // weren't even registered. The former should be OKed by the initial
+ // registration call, and the latter is safe to ignore.
+ s.op->newline() << "static void unregister_tracepoint_probe_" << i << "(void) {";
+ s.op->newline(1) << "(void) unregister_trace_" << p->tracepoint_name
+ << "(enter_tracepoint_probe_" << i << ");";
+ s.op->newline(-1) << "}";
s.op->newline();
}
+
+ // emit an array of registration functions for easy init/shutdown
+ s.op->newline() << "static struct stap_tracepoint_probe {";
+ s.op->newline(1) << "int (*reg)(void);";
+ s.op->newline(0) << "void (*unreg)(void);";
+ s.op->newline(-1) << "} stap_tracepoint_probes[] = {";
+ s.op->indent(1);
+ for (unsigned i = 0; i < probes.size(); ++i)
+ {
+ s.op->newline () << "{";
+ s.op->line() << " .reg=&register_tracepoint_probe_" << i << ",";
+ s.op->line() << " .unreg=&unregister_tracepoint_probe_" << i;
+ s.op->line() << " },";
+ }
+ s.op->newline(-1) << "};";
+ s.op->newline();
}
@@ -9764,28 +9850,14 @@ tracepoint_derived_probe_group::emit_module_init (systemtap_session &s)
return;
s.op->newline() << "/* init tracepoint probes */";
-
- // We can't use a simple runtime loop because the probe registration
- // functions are distinct inlines. Instead, this will generate nesting as
- // deep as the number of probe points. Gotos are also possible, but the end
- // result is the same.
-
- for (unsigned i = 0; i < probes.size(); ++i)
- {
- s.op->newline() << "if (!rc) {";
- s.op->newline(1) << "probe_point = "
- << lex_cast_qstring (*probes[i]->sole_location()) << ";";
- s.op->newline() << "rc = register_trace_" << probes[i]->tracepoint_name
- << "(enter_tracepoint_probe_" << i << ");";
- }
-
- for (unsigned i = probes.size() - 1; i < probes.size(); --i)
- {
- s.op->newline() << "if (rc)";
- s.op->newline(1) << "unregister_trace_" << probes[i]->tracepoint_name
- << "(enter_tracepoint_probe_" << i << ");";
- s.op->newline(-2) << "}";
- }
+ s.op->newline() << "for (i=0; i<" << probes.size() << "; i++) {";
+ s.op->newline(1) << "rc = stap_tracepoint_probes[i].reg();";
+ s.op->newline() << "if (rc) {";
+ s.op->newline(1) << "for (j=i-1; j>=0; j--)"; // partial rollback
+ s.op->newline(1) << "stap_tracepoint_probes[j].unreg();";
+ s.op->newline(-1) << "break;"; // don't attempt to register any more probes
+ s.op->newline(-1) << "}";
+ s.op->newline(-1) << "}";
// This would be technically proper (on those autoconf-detectable
// kernels that include this function in tracepoint.h), however we
@@ -9804,10 +9876,10 @@ tracepoint_derived_probe_group::emit_module_exit (systemtap_session& s)
if (probes.empty())
return;
- s.op->newline() << "/* deregister tracepointer probes */";
- for (unsigned i = 0; i < probes.size(); ++i)
- s.op->newline() << "unregister_trace_" << probes[i]->tracepoint_name
- << "(enter_tracepoint_probe_" << i << ");";
+ s.op->newline() << "/* deregister tracepoint probes */";
+ s.op->newline() << "for (i=0; i<" << probes.size() << "; i++)";
+ s.op->newline(1) << "stap_tracepoint_probes[i].unreg();";
+ s.op->indent(-1);
// Not necessary: see above.
@@ -9922,12 +9994,43 @@ tracepoint_builder::init_dw(systemtap_session& s)
if (dw != NULL)
return true;
+ if (s.use_cache)
+ {
+ // see if the cached module exists
+ find_tracequery_hash(s);
+ if (!s.tracequery_path.empty())
+ {
+ int fd = open(s.tracequery_path.c_str(), O_RDONLY);
+ if (fd != -1)
+ {
+ if (s.verbose > 2)
+ clog << "Pass 2: using cached " << s.tracequery_path << endl;
+
+ dw = new dwflpp(s);
+ dw->setup_user(s.tracequery_path);
+ close(fd);
+ return true;
+ }
+ }
+ }
+
+ // no cached module, time to make it
string tracequery_ko;
int rc = make_tracequery(s, tracequery_ko);
if (rc != 0)
return false;
- // TODO cache tracequery.ko
+ if (s.use_cache)
+ {
+ // try to save tracequery in the cache
+ if (s.verbose > 2)
+ clog << "Copying " << tracequery_ko
+ << " to " << s.tracequery_path << endl;
+ if (copy_file(tracequery_ko.c_str(),
+ s.tracequery_path.c_str()) != 0)
+ cerr << "Copy failed (\"" << tracequery_ko << "\" to \""
+ << s.tracequery_path << "\"): " << strerror(errno) << endl;
+ }
dw = new dwflpp(s);
dw->setup_user(tracequery_ko);
@@ -10744,9 +10847,13 @@ register_standard_tapsets(systemtap_session & s)
->bind(new utrace_builder ());
// itrace user-space probes
- s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace")
+ s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_INSN)
+ ->bind(new itrace_builder ());
+ s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_INSN)
+ ->bind(new itrace_builder ());
+ s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_INSN)->bind(TOK_BLOCK)
->bind(new itrace_builder ());
- s.pattern_root->bind_num(TOK_PROCESS)->bind("itrace")
+ s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_INSN)->bind(TOK_BLOCK)
->bind(new itrace_builder ());
// marker-based parts
diff --git a/testsuite/buildok/task-embedded.stp b/testsuite/buildok/task-embedded.stp
index 4d1f5300..d35f3e0d 100755
--- a/testsuite/buildok/task-embedded.stp
+++ b/testsuite/buildok/task-embedded.stp
@@ -14,6 +14,8 @@ probe begin {
task_nice (0) +
task_cpu (0) +
task_open_file_handles (0) +
- task_max_file_handles (0))
+ task_max_file_handles (0) +
+ pid2task(0))
print (task_execname (0))
+ print (pid2execname (0))
}
diff --git a/testsuite/buildok/task_test.stp b/testsuite/buildok/task_test.stp
index c8da7da5..792f96ea 100755
--- a/testsuite/buildok/task_test.stp
+++ b/testsuite/buildok/task_test.stp
@@ -16,5 +16,7 @@ probe begin {
log(sprint(task_cpu(c)))
log(sprint(task_open_file_handles(c)))
log(sprint(task_max_file_handles(c)))
+ log(sprint(pid2task(pid())))
+ log(sprint(pid2execname(pid())))
exit()
}
diff --git a/testsuite/lib/stap_run2.exp b/testsuite/lib/stap_run2.exp
index cb1c6615..d1f02c83 100644
--- a/testsuite/lib/stap_run2.exp
+++ b/testsuite/lib/stap_run2.exp
@@ -10,12 +10,27 @@
proc stap_run2 { TEST_NAME args } {
# zap the srcdir prefix
- set test_file_name $TEST_NAME
+ set TEST_FILE $TEST_NAME
set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""]
-
+ if {[llength $args] == 0} {
+ stap_run3 $TEST_NAME $TEST_FILE
+ } else {
+ stap_run3 $TEST_NAME $TEST_FILE $args
+ }
+}
+
+# stap_run3 TEST_NAME TEST_FILE
+# TEST_NAME is the name of the test as shown in PASS/FAIL/SKIPPED messages.
+# TEST_FILE is the path to the current test
+# Additional arguments are passed to stap as-is.
+#
+# global result_string must be set to the expected output
+
+proc stap_run3 { TEST_NAME TEST_FILE args } {
if {[info procs installtest_p] != "" && ![installtest_p]} { untested $TEST_NAME; return }
-
- set cmd [concat stap $args $test_file_name]
+
+ set cmd [concat stap $TEST_FILE $args]
+ send_log "executing: $cmd\n"
catch {eval exec $cmd} res
set n 0
diff --git a/testsuite/semok/badvar.stp b/testsuite/semok/badvar.stp
new file mode 100755
index 00000000..b3bd2d67
--- /dev/null
+++ b/testsuite/semok/badvar.stp
@@ -0,0 +1,7 @@
+#! stap --skip-badvars
+
+probe syscall.read {
+ if ($foo == 0)
+ printf ("Voila! It works..\n")
+ exit ()
+}
diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp
new file mode 100755
index 00000000..93da18ef
--- /dev/null
+++ b/testsuite/semok/cast.stp
@@ -0,0 +1,13 @@
+#! stap -p2
+
+probe begin {
+ // basic @cast test, with and without specifying kernel
+ println(@cast(0, "task_struct")->tgid)
+ println(@cast(0, "task_struct", "kernel")->tgid)
+
+ // check module-search paths
+ println(@cast(0, "task_struct", "foo:kernel:bar")->tgid)
+
+ // would be nice to test usermode @cast too,
+ // but who knows what debuginfo is installed...
+}
diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp
new file mode 100644
index 00000000..df3246e8
--- /dev/null
+++ b/testsuite/systemtap.base/cast.exp
@@ -0,0 +1,4 @@
+set test "cast"
+set ::result_string {PID OK
+execname OK}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp
new file mode 100644
index 00000000..bec0cc9b
--- /dev/null
+++ b/testsuite/systemtap.base/cast.stp
@@ -0,0 +1,22 @@
+probe begin
+{
+ curr = task_current()
+
+ // Compare PIDs
+ pid = pid()
+ cast_pid = @cast(curr, "task_struct")->tgid
+ if (pid == cast_pid)
+ println("PID OK")
+ else
+ printf("PID %d != %d\n", pid, cast_pid)
+
+ // Compare execnames
+ name = execname()
+ cast_name = kernel_string(@cast(curr, "task_struct")->comm)
+ if (name == cast_name)
+ println("execname OK")
+ else
+ printf("execname \"%s\" != \"%s\"\n", name, cast_name)
+
+ exit()
+}
diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp
index f19af977..e215bfe7 100644
--- a/testsuite/systemtap.base/itrace.exp
+++ b/testsuite/systemtap.base/itrace.exp
@@ -1,8 +1,5 @@
# itrace test
-# temporarily disabled
-return
-
# Initialize variables
set utrace_support_found 0
@@ -11,7 +8,7 @@ set exepath "[pwd]/ls_[pid]"
set itrace1_script {
global instrs = 0
probe begin { printf("systemtap starting probe\n") }
- probe process("%s").itrace
+ probe process("%s").insn
{
instrs += 1
if (instrs == 5)
@@ -28,7 +25,7 @@ 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)
+ probe process("%s").insn if (itrace_on)
{
instrs += 1
if (instrs == 5)
diff --git a/testsuite/systemtap.base/sdt.c b/testsuite/systemtap.base/sdt.c
index 46f68664..7c7398e5 100644
--- a/testsuite/systemtap.base/sdt.c
+++ b/testsuite/systemtap.base/sdt.c
@@ -65,5 +65,7 @@ main (int argc, char **argv)
call8(a, b, c, d, e, f, g, h);
call9(a, b, c, d, e, f, g, h, i);
call10(a, b, c, d, e, f, g, h, i, j);
+ (void) argv;
+ (void) argc;
return 0;
}
diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp
index 09aaaf8d..46fa5a28 100644
--- a/testsuite/systemtap.base/sdt.exp
+++ b/testsuite/systemtap.base/sdt.exp
@@ -10,54 +10,61 @@ set ::result_string {1
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10}
-set extra_flags {{""} {additional_flags=-ansi}}
+set extra_flags {{""} {additional_flags=-std=gnu89} {additional_flags=-ansi} {additional_flags=-pedantic} {additional_flags=-ansi additional_flags=-pedantic} {additional_flags=-O2} {additional_flags="-O3"}}
# Iterate extra_flags, trying each with C and C++
for {set i 0} {$i < [llength $extra_flags]} {incr i} {
+set extra_flag [lindex $extra_flags $i]
+set testprog "sdt.c.exe.$i"
+
# C
set test_flags "additional_flags=-g"
set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys"
-set test_flags "$test_flags additional_flags=-std=gnu89"
set test_flags "$test_flags additional_flags=-Wall"
-set test_flags "$test_flags additional_flags=-Wdeclaration-after-statement"
+set test_flags "$test_flags additional_flags=-Wextra"
set test_flags "$test_flags additional_flags=-Werror"
-set res [target_compile $srcdir/$subdir/$test.c $test.prog executable [concat $test_flags " " [lindex $extra_flags $i]]]
+set saveidx 0
+
+set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"]
if { $res != "" } {
verbose "target_compile failed: $res" 2
- fail "compiling $test.c"
- return
+ fail "compiling $test.c $extra_flag"
+ untested "$test $extra_flag"
+ continue
} else {
- pass "compiling $test.c"
+ pass "compiling $test.c $extra_flag"
}
if {[installtest_p]} {
- stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog
+ stap_run3 "$test $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog
} else {
- untested "$test"
+ untested "$test $extra_flag"
}
# C++
+set testprog "sdt.cxx.exe.$i"
+
set test_flags "additional_flags=-g"
set test_flags "$test_flags additional_flags=-I$srcdir/../includes/sys"
set test_flags "$test_flags additional_flags=-Wall"
set test_flags "$test_flags additional_flags=-Werror"
set test_flags "$test_flags additional_flags=-x additional_flags=c++"
-set res [target_compile $srcdir/$subdir/$test.c $test.prog executable [concat $test_flags [lindex $extra_flags $i]]]
+set res [target_compile $srcdir/$subdir/$test.c $testprog executable "$test_flags $extra_flag"]
if { $res != "" } {
verbose "target_compile failed: $res" 2
- fail "compiling $test.c"
- return
+ fail "compiling $test.c c++ $extra_flag"
+ untested "$test $extra_flag"
+ continue
} else {
- pass "compiling $test.c"
+ pass "compiling $test.c c++ $extra_flag"
}
if {[installtest_p]} {
- stap_run2 $srcdir/$subdir/$test.stp -c ./$test.prog
+ stap_run3 "$test c++ $extra_flag" $srcdir/$subdir/$test.stp $testprog -c ./$testprog
} else {
- untested "$test"
+ untested "$test c++ $extra_flag"
}
}
-catch {exec rm -f $test.prog}
diff --git a/testsuite/systemtap.base/sdt.stp b/testsuite/systemtap.base/sdt.stp
index 1f075bca..5df1fdc9 100644
--- a/testsuite/systemtap.base/sdt.stp
+++ b/testsuite/systemtap.base/sdt.stp
@@ -1,49 +1,49 @@
-probe process("sdt.prog").mark("mark_a")
+probe process(@1).mark("mark_a")
{
printf("%d\n", $arg1);
}
-probe process("sdt.prog").mark("mark_b")
+probe process(@1).mark("mark_b")
{
printf("%d %d\n", $arg1, $arg2);
}
-probe process("sdt.prog").mark("mark_c")
+probe process(@1).mark("mark_c")
{
printf("%d %d %d\n", $arg1, $arg2, $arg3);
}
-probe process("sdt.prog").mark("mark_d")
+probe process(@1).mark("mark_d")
{
printf("%d %d %d %d\n", $arg1, $arg2, $arg3, $arg4);
}
-probe process("sdt.prog").mark("mark_e")
+probe process(@1).mark("mark_e")
{
printf("%d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5);
}
-probe process("sdt.prog").mark("mark_f")
+probe process(@1).mark("mark_f")
{
printf("%d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
}
-probe process("sdt.prog").mark("mark_g")
+probe process(@1).mark("mark_g")
{
printf("%d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
}
-probe process("sdt.prog").mark("mark_h")
+probe process(@1).mark("mark_h")
{
printf("%d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);
}
-probe process("sdt.prog").mark("mark_i")
+probe process(@1).mark("mark_i")
{
printf("%d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9);
}
-probe process("sdt.prog").mark("mark_j")
+probe process(@1).mark("mark_j")
{
printf("%d %d %d %d %d %d %d %d %d %d\n", $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9, $arg10);
}
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index a4bd5e2c..e407440e 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -1,5 +1,4 @@
-
-set test "sduprobes"
+set test "static_uprobes"
# Compile a C program to use as the user-space probing target
set sup_srcpath "[pwd]/static_uprobes.c"
@@ -104,7 +103,11 @@ if {[installtest_p]} {
set sdtdir $srcdir/../includes
}
-set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I."
+set sup_flags "additional_flags=-I$srcdir/../includes/sys"
+set sup_flags "$sup_flags additional_flags=-I$sdtdir"
+set sup_flags "$sup_flags additional_flags=-g"
+set sup_flags "$sup_flags additional_flags=-O"
+set sup_flags "$sup_flags additional_flags=-I."
set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
@@ -115,9 +118,7 @@ if { $res != "" } {
pass "$test compiling C -g"
}
-spawn mv $sup_srcpath "[pwd]/static_uprobes.cc"
-set sup_srcpath "[pwd]/static_uprobes.cc"
-set sup_flags "$sup_flags c++"
+set sup_flags "$sup_flags additional_flags=-x additional_flags=c++"
set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
@@ -163,9 +164,9 @@ if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" }
set ok 0
-# spawn objcopy -R .probes $supcplus_exepath $sup_exepath
-verbose -log "cp $supcplus_exepath $sup_exepath"
-spawn cp $supcplus_exepath $sup_exepath
+# Test setting a probe without .probes using only dwarf label info
+verbose -log "objcopy -R .probes $supcplus_exepath $sup_exepath"
+spawn objcopy -R .probes $supcplus_exepath $sup_exepath
verbose -log "spawn stap -c $sup_exepath $sup_stppath"
spawn stap -c $sup_exepath $sup_stppath
expect {
@@ -180,9 +181,10 @@ expect {
wait
-if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" }
+# we now generate the probes via asm so there is no label debug info
+if {$ok == 5} { pass "$test C++" } { xfail "$test C++ ($ok)" }
-# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath}
+if { $verbose == 0 } {
+catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath}
+}
-# It's not so important to clean up, and it's unhelpful if
-# one needs to diagnose a test failure.
diff --git a/testsuite/systemtap.base/tracepoints.exp b/testsuite/systemtap.base/tracepoints.exp
new file mode 100644
index 00000000..bea461c4
--- /dev/null
+++ b/testsuite/systemtap.base/tracepoints.exp
@@ -0,0 +1,3 @@
+set test "tracepoints"
+set ::result_string {tracepoints OK}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.base/tracepoints.stp b/testsuite/systemtap.base/tracepoints.stp
new file mode 100644
index 00000000..bdb4d730
--- /dev/null
+++ b/testsuite/systemtap.base/tracepoints.stp
@@ -0,0 +1,23 @@
+// This checks that we can compile and register every tracepoint
+// we can find, along with all of their context variables.
+global hits
+probe all_tracepoints = kernel.trace("*")
+{
+ if ($$name . $$vars . $$parms == "")
+ next
+
+ // Allow it to quit once we hit our hundredth tracepoint
+ if (++hits < 100)
+ next
+}
+
+// If there aren't any tracepoints in the kernel,
+// we use "begin" instead to quit right away.
+probe all_tracepoints!, begin {
+ println("tracepoints OK")
+ exit()
+}
+
+// give hits a use so there's no warning
+// when we don't have tracepoints
+probe never { hits++ }
diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html
index 7b76baa1..0f4b2572 100644
--- a/testsuite/systemtap.examples/index.html
+++ b/testsuite/systemtap.examples/index.html
@@ -58,6 +58,9 @@ keywords: <a href="keyword-index.html#DISK">DISK</a> <br>
<li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br>
<p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li>
+<li><a href="io/ioblktime.stp">io/ioblktime.stp</a> - Average Time Block IO Requests Spend in Queue <br>
+keywords: <a href="keyword-index.html#IO">IO</a> <br>
+<p>The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script compute the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.</p></li>
<li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
<p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li>
diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt
index fdcd3b31..e31baf4f 100644
--- a/testsuite/systemtap.examples/index.txt
+++ b/testsuite/systemtap.examples/index.txt
@@ -52,6 +52,19 @@ keywords: io backtrace
list from most common to least common backtrace.
+io/ioblktime.stp - Average Time Block IO Requests Spend in Queue
+keywords: io
+
+ The ioblktime.stp script tracks the amount of time that each block IO
+ requests spend waiting for completion. The script compute the average
+ time waiting time for block IO per device and prints list every 10
+ seconds. In some cases there can be too many oustanding block IO
+ operations and the script may exceed the default number of
+ MAXMAPENTRIES allowed. In this case the allowed number can be
+ increased with "-DMAXMAPENTRIES=10000" option on the stap command
+ line.
+
+
io/iostats.stp - List Executables Reading and Writing the Most Data
keywords: io profiling
diff --git a/testsuite/systemtap.examples/io/ioblktime.meta b/testsuite/systemtap.examples/io/ioblktime.meta
new file mode 100644
index 00000000..18a8b168
--- /dev/null
+++ b/testsuite/systemtap.examples/io/ioblktime.meta
@@ -0,0 +1,13 @@
+title: Average Time Block IO Requests Spend in Queue
+name: ioblktime.stp
+version: 1.0
+author: William Cohen
+keywords: io
+subsystem: kernel
+status: production
+exit: user-controlled
+output: sorted-list
+scope: system-wide
+description: The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script computes the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.
+test_check: stap -p4 ioblktime.stp
+test_installcheck: stap ioblktime.stp -c "sleep 1"
diff --git a/testsuite/systemtap.examples/io/ioblktime.stp b/testsuite/systemtap.examples/io/ioblktime.stp
new file mode 100755
index 00000000..5ff59cf7
--- /dev/null
+++ b/testsuite/systemtap.examples/io/ioblktime.stp
@@ -0,0 +1,29 @@
+#! /usr/bin/env stap
+
+global req_time, etimes
+
+probe ioblock.request
+{
+ req_time[$bio] = gettimeofday_us()
+}
+
+probe ioblock.end
+{
+ t = gettimeofday_us()
+ s = req_time[$bio]
+ delete req_time[$bio]
+ if (s) {
+ etimes[devname, bio_rw_str(rw)] <<< t - s
+ }
+}
+
+probe timer.s(10), end {
+ printf("\033[2J\033[1;1H") /* clear screen */
+ printf("%10s %3s %10s %10s %10s\n",
+ "device", "rw", "total (us)", "count", "avg (us)")
+ foreach ([dev,rw] in etimes - limit 20) {
+ printf("%10s %3s %10d %10d %10d\n", dev, rw,
+ @sum(etimes[dev,rw]), @count(etimes[dev,rw]), @avg(etimes[dev,rw]))
+ }
+ delete etimes
+}
diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html
index b3ea0943..75768709 100644
--- a/testsuite/systemtap.examples/keyword-index.html
+++ b/testsuite/systemtap.examples/keyword-index.html
@@ -102,6 +102,9 @@ keywords: <a href="keyword-index.html#INTERRUPT">INTERRUPT</a> <a href="keyword-
<li><a href="io/io_submit.stp">io/io_submit.stp</a> - Tally Reschedule Reason During AIO io_submit Call<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#BACKTRACE">BACKTRACE</a> <br>
<p>When a reschedule occurs during an AIO io_submit call, accumulate the traceback in a histogram. When the script exits prints out a sorted list from most common to least common backtrace.</p></li>
+<li><a href="io/ioblktime.stp">io/ioblktime.stp</a> - Average Time Block IO Requests Spend in Queue <br>
+keywords: <a href="keyword-index.html#IO">IO</a> <br>
+<p>The ioblktime.stp script tracks the amount of time that each block IO requests spend waiting for completion. The script compute the average time waiting time for block IO per device and prints list every 10 seconds. In some cases there can be too many oustanding block IO operations and the script may exceed the default number of MAXMAPENTRIES allowed. In this case the allowed number can be increased with "-DMAXMAPENTRIES=10000" option on the stap command line.</p></li>
<li><a href="io/iostats.stp">io/iostats.stp</a> - List Executables Reading and Writing the Most Data<br>
keywords: <a href="keyword-index.html#IO">IO</a> <a href="keyword-index.html#PROFILING">PROFILING</a> <br>
<p> The iostat.stp script measures the amount of data successfully read and written by all the executables on the system. The output is sorted from most greatest sum of bytes read and written by an executable to the least. The output contains the count of operations (opens, reads, and writes), the totals and averages for the number of bytes read and written.</p></li>
diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt
index 5f382e75..d3a9617f 100644
--- a/testsuite/systemtap.examples/keyword-index.txt
+++ b/testsuite/systemtap.examples/keyword-index.txt
@@ -125,6 +125,19 @@ keywords: io backtrace
list from most common to least common backtrace.
+io/ioblktime.stp - Average Time Block IO Requests Spend in Queue
+keywords: io
+
+ The ioblktime.stp script tracks the amount of time that each block IO
+ requests spend waiting for completion. The script compute the average
+ time waiting time for block IO per device and prints list every 10
+ seconds. In some cases there can be too many oustanding block IO
+ operations and the script may exceed the default number of
+ MAXMAPENTRIES allowed. In this case the allowed number can be
+ increased with "-DMAXMAPENTRIES=10000" option on the stap command
+ line.
+
+
io/iostats.stp - List Executables Reading and Writing the Most Data
keywords: io profiling
diff --git a/testsuite/systemtap.examples/network/tcp.stp b/testsuite/systemtap.examples/network/tcp.stp
new file mode 100644
index 00000000..ebe72a1c
--- /dev/null
+++ b/testsuite/systemtap.examples/network/tcp.stp
@@ -0,0 +1,11 @@
+//A simple TCP tapset example
+
+probe begin {
+ printf("Expected IP 7.91.205.21 .... %s\n", ip_ntop(123456789))
+ printf("Expected IP 58.222.104.177 .... %s\n", ip_ntop(987654321))
+ printf("Expected IP 9.3.191.111 ... %s\n", ip_ntop(151240559))
+}
+
+probe tcp.recvmsg {
+ printf("received a message from %s on port %d from port %d\n", saddr, dport, sport)
+}
diff --git a/testsuite/systemtap.samples/ioblocktest.exp b/testsuite/systemtap.samples/ioblocktest.exp
deleted file mode 100644
index b5ab54c7..00000000
--- a/testsuite/systemtap.samples/ioblocktest.exp
+++ /dev/null
@@ -1,11 +0,0 @@
-# Test the functionality of the various ioblock probes.
-
-set test "ioblocktest"
-
-proc sleep_ten_secs {} {
- after 10000;
- return 0;
-}
-
-set output_string "ioblock: \\S+\t\\d+\t\[RW]\t\[01]\r\n"
-stap_run $srcdir/$subdir/$test.stp sleep_ten_secs $output_string
diff --git a/testsuite/systemtap.samples/ioblocktest.stp b/testsuite/systemtap.samples/ioblocktest.stp
deleted file mode 100644
index f8a1c568..00000000
--- a/testsuite/systemtap.samples/ioblocktest.stp
+++ /dev/null
@@ -1,12 +0,0 @@
-#! stap
-global teststr
-probe begin { println("systemtap starting probe") }
-
-probe ioblock.request, ioblock.end {
- teststr = sprintf("ioblock: %s\t%d\t%s\t%d\n", devname, sector,
- bio_rw_str(rw), bio_rw_num(rw))
-}
-probe end {
- println("systemtap ending probe")
- printf("%s", teststr)
-}
diff --git a/translate.cxx b/translate.cxx
index 17c37dc3..40bb82c2 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -867,12 +867,10 @@ c_unparser::emit_common_header ()
o->newline() << "static atomic_t session_state = ATOMIC_INIT (STAP_SESSION_STARTING);";
o->newline() << "static atomic_t error_count = ATOMIC_INIT (0);";
o->newline() << "static atomic_t skipped_count = ATOMIC_INIT (0);";
- o->newline() << "#ifdef STP_TIMING";
o->newline() << "static atomic_t skipped_count_lowstack = ATOMIC_INIT (0);";
o->newline() << "static atomic_t skipped_count_reentrant = ATOMIC_INIT (0);";
o->newline() << "static atomic_t skipped_count_uprobe_reg = ATOMIC_INIT (0);";
o->newline() << "static atomic_t skipped_count_uprobe_unreg = ATOMIC_INIT (0);";
- o->newline() << "#endif";
o->newline();
o->newline() << "struct context {";
o->newline(1) << "atomic_t busy;";
@@ -1360,9 +1358,10 @@ c_unparser::emit_module_exit ()
o->newline() << "#endif";
}
- // print final error/reentrancy counts if non-zero
+ // print final error/skipped counts if non-zero
o->newline() << "if (atomic_read (& skipped_count) || "
- << "atomic_read (& error_count)) {";
+ << "atomic_read (& error_count) || "
+ << "atomic_read (& skipped_count_reentrant)) {"; // PR9967
o->newline(1) << "_stp_warn (\"Number of errors: %d, "
<< "skipped probes: %d\\n\", "
<< "(int) atomic_read (& error_count), "
@@ -4497,17 +4496,35 @@ dump_unwindsyms (Dwfl_Module *m,
// see https://bugzilla.redhat.com/show_bug.cgi?id=465872
// and http://sourceware.org/ml/systemtap/2008-q4/msg00579.html
#ifdef _ELFUTILS_PREREQ
-#if _ELFUTILS_PREREQ(0,138)
+ #if _ELFUTILS_PREREQ(0,138)
// Let's standardize to the buggy "end of build-id bits" behavior.
build_id_vaddr += build_id_len;
+ #endif
+ #if !_ELFUTILS_PREREQ(0,141)
+ #define NEED_ELFUTILS_BUILDID_WORKAROUND
+ #endif
+#else
+ #define NEED_ELFUTILS_BUILDID_WORKAROUND
#endif
+
+ // And check for another workaround needed.
+ // see https://bugzilla.redhat.com/show_bug.cgi?id=489439
+ // and http://sourceware.org/ml/systemtap/2009-q1/msg00513.html
+#ifdef NEED_ELFUTILS_BUILDID_WORKAROUND
+ if (build_id_vaddr < base && dwfl_module_relocations (m) == 1)
+ {
+ GElf_Addr main_bias;
+ dwfl_module_getelf (m, &main_bias);
+ build_id_vaddr += main_bias;
+ }
#endif
- if (c->session.verbose > 1) {
- clog << "Found build-id in " << name
- << ", length " << build_id_len;
- clog << ", end at 0x" << hex << build_id_vaddr
- << dec << endl;
- }
+ if (c->session.verbose > 1)
+ {
+ clog << "Found build-id in " << name
+ << ", length " << build_id_len;
+ clog << ", end at 0x" << hex << build_id_vaddr
+ << dec << endl;
+ }
}
// Look up the relocation basis for symbols
@@ -4682,6 +4699,15 @@ 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";
+
c->output << ".dwarf_module_base = 0x" << hex << base << dec << ", \n";
if (unwind != NULL)