diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | cache.cxx | 10 | ||||
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Errors.xml | 112 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Installation.xml | 20 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Introduction.xml | 4 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 36 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Understanding_How_SystemTap_Works.xml | 4 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml | 13 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-sockettrace.xml | 71 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-threadtimes.xml | 106 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml | 2 | ||||
-rw-r--r-- | doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml | 2 | ||||
-rw-r--r-- | runtime/autoconf-oneachcpu-retry.c | 8 | ||||
-rwxr-xr-x | stap-report | 10 | ||||
-rw-r--r-- | stap.1.in | 4 | ||||
-rw-r--r-- | systemtap.spec | 5 |
19 files changed, 361 insertions, 64 deletions
@@ -1,3 +1,16 @@ +2008-10-17 Frank Ch. Eigler <fche@elastic.org> + + * stap-report: Add kernel config extracts. Generate to stdout. + * Makefile.am (bin_SCRIPTS): Install it. + * systemtap.spec: Package it. + * Makefile.in: Regenerated. + +2008-10-17 Jim Keniston <jkenisto@us.ibm.com> + + PR6923 + * runtime/autoconf-oneachcpu-retry.c: Compiles successfully on + old kernels. + 2008-10-14 Kent Sebastian <ksebasti@redhat.com> * cache.cxx (cache_clean): Minor changes, mainly stylistic. diff --git a/Makefile.am b/Makefile.am index 1e356a4f..b3a4801e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,7 +14,7 @@ man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-s # see also configure.ac bin_PROGRAMS = stap staprun -bin_SCRIPTS = stap-client stap-server stap-serverd stap-find-servers stap-start-server stap-find-or-start-server stap-stop-server +bin_SCRIPTS = stap-client stap-server stap-serverd stap-find-servers stap-start-server stap-find-or-start-server stap-stop-server stap-report stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \ diff --git a/Makefile.in b/Makefile.in index 22336ec0..d43fde6f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -261,7 +261,7 @@ AM_CPPFLAGS = -DBINDIR='"$(bindir)"' -DPKGDATADIR='"${pkgdatadir}"' -DPKGLIBDIR= AM_CFLAGS = -D_GNU_SOURCE -fexceptions -Wall -Werror -Wunused -Wformat=2 -W AM_CXXFLAGS = -Wall -Werror man_MANS = stap.1 stapprobes.5 stapfuncs.5 stapvars.5 stapex.5 staprun.8 stap-server.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5 -bin_SCRIPTS = stap-client stap-server stap-serverd stap-find-servers stap-start-server stap-find-or-start-server stap-stop-server +bin_SCRIPTS = stap-client stap-server stap-serverd stap-find-servers stap-start-server stap-find-or-start-server stap-stop-server stap-report stap_SOURCES = main.cxx \ parse.cxx staptree.cxx elaborate.cxx translate.cxx \ tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \ @@ -158,11 +158,13 @@ clean_cache(systemtap_session& s) } else { - //file doesnt exist or error - if (s.verbose > 1) - clog << "Missing cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << ", I/O error or invalid content." << endl; + //file doesnt exist, create a default size + ofstream default_cache_max(cache_max_filename.c_str(), ios::out); + default_cache_max << SYSTEMTAP_CACHE_DEFAULT_MB << endl; + cache_mb_max = SYSTEMTAP_CACHE_DEFAULT_MB; - return; + if (s.verbose > 1) + clog << "Cache limit file " << s.cache_path << "/" << SYSTEMTAP_CACHE_MAX_FILENAME << " missing, creating default." << endl; } //glob for all kernel modules in the cache dir @@ -1,4 +1,5 @@ #define SYSTEMTAP_CACHE_MAX_FILENAME "cache_mb_limit" +#define SYSTEMTAP_CACHE_DEFAULT_MB 64 struct cache_ent_info { std::string path; diff --git a/doc/SystemTap_Beginners_Guide/en-US/Errors.xml b/doc/SystemTap_Beginners_Guide/en-US/Errors.xml index 21351e08..e0a61aae 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Errors.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Errors.xml @@ -7,5 +7,117 @@ <remark>By type - http://sourceware.org/systemtap/tutorial/node23.html</remark> + <para>This chapter explains the most common errors you may encounter while using SystemTap.</para> + +<section id="parsetype"> + <title>Parse and Type Errors</title> + +<para>These types of errors occur before the translation phase of a SystemTap session, i.e. before the script is translated into C.</para> + +<formalpara><title>parse error: expected <replaceable>foo</replaceable>, saw <replaceable>bar</replaceable></title> + +<para>The script contains a grammatical/typographical error. SystemTap detected type of construct that is incorrect, given the context of the probe. +</para> +</formalpara> + +<remark>need more clarification (example) on this; could not replicate. how to replicate?</remark> + +<formalpara><title>parse error: embedded code in unprivileged script</title> + + <para>The script contains unsafe constructs; in most cases, embedded C. SystemTap allows you to embed C code in a script, which is useful if there are no tapsets to suit your purposes. However, some embedded C constructs may not be safe; as such, SystemTap warns you with this error if such constructs appear in the script. <xref linkend="threadtimes"/> (from <xref linkend="threadtimessect"/>) is an example of a script that contains embedded C.</para> +</formalpara> +<para>If you are sure of the safety of any similar constructs in the script, run the script in "guru" mode by using the option <command>-g</command> (i.e. <command>stap -g <replaceable>script</replaceable></command>).</para> + +<formalpara> + <title>semantic error: type mismatch for identifier '<replaceable>foo</replaceable>' ... string vs. long</title> + +<para> + The function <command><replaceable>foo</replaceable></command> in the script used the wrong type of variable (i.e. <command>%s</command> or <command>%d</command>). This error will present itself in <xref linkend="errorvariable"/>, since the function <command>execname</command> should be referenced using <command>%s</command>, not <command>%d</command>. +</para> +</formalpara> + +<example id="errorvariable"> + <title>error-variable.stp</title> +<programlisting> +probe syscall.open +{ + printf ("%d(%d) open\n", execname(), pid()) +} +</programlisting> +</example> + +<formalpara> + <title>semantic error: unresolved type for identifier '<replaceable>foo</replaceable>'</title> +<para>TBD</para> +</formalpara> + +<formalpara> + <title>semantic error: Expecting symbol or array index expression</title> +<para>TBD</para> +</formalpara> + +</section> + +<section id="symbolerrors"> + <title>Symbol-Related Errors</title> + +<para>TBD</para> + +<formalpara> + <title>while searching for arity <replaceable>N</replaceable> function, semantic error: unresolved function call</title> +<para>TBD</para> +</formalpara> + +<formalpara> + <title>semantic error: array locals not supported:</title> + <para>TBD</para> +</formalpara> + +<formalpara> + <title>semantic error: variable ’<replaceable>foo</replaceable>’ modified during ’<replaceable>construct</replaceable>’</title> + <para>TBD</para> +</formalpara> +</section> + +<section id="probingerrors"> + <title>Probe Errors</title> + +<para>TBD</para> + +<formalpara> + <title>semantic error: probe point mismatch at position <replaceable>N</replaceable>, while resolving probe point <replaceable>foo</replaceable></title> + <para>SystemTap did not understand what the event / handler function <computeroutput><replaceable>foo</replaceable></computeroutput> refers to. This usually means that SystemTap could not find a match for <computeroutput><replaceable>foo</replaceable></computeroutput> in the tapset library.</para> +</formalpara> + +<remark>how to explain N in previous? "The divergence from the “tree” of probe point namespace is at position N (starting with zero at left)." </remark> + +<formalpara> + <title>semantic error: no match for probe point, while resolving probe point <replaceable>foo</replaceable></title> + <para>The events / handler function <computeroutput><replaceable>foo</replaceable></computeroutput> could not be resolved altogether, for a variety of reasons. This error occurs when the script contains the event <command>kernel.function("<replaceable>blah</replaceable>")</command>, and <command><replaceable>blah</replaceable></command> does not exist. In some cases, the error could also mean the script contains an invalid kernel file name or source line number.</para> +</formalpara> + +<formalpara> + <title>semantic error: unresolved target-symbol expression</title> + <para>TBD</para> +</formalpara> + +<formalpara> + <title>semantic error: libdwfl failure </title> + <para>TBD</para> +</formalpara> + +<formalpara> + <title>semantic error: cannot find foo debuginfo</title> + <para>TBD</para> +</formalpara> +<!-- +<formalpara> + <title></title> +<para></para> +</formalpara> +--> + +</section> + </chapter> diff --git a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml index 8670db59..f9c9a819 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml @@ -83,7 +83,7 @@ gpgcheck=0 </formalpara> <para> - In <xref linkend="sampleyum"/>, <replaceable>repository</replaceable> is the full URL of the repository containing the packages you wish to install. The <computeroutput>name=</computeroutput> parameter, along with the title (<computeroutput>[packages]</computeroutput>) and filename, can be set arbitrarily, as long as you use the <filename>.repo</filename> filename extension. + In <xref linkend="sampleyum"/>, <replaceable>repository</replaceable> is the full URL of the repository containing the packages you wish to install. The <computeroutput>name=</computeroutput> parameter, along with the title (<computeroutput>[packages]</computeroutput>) and filename, can be set arbitrarily. Remember to always use the <filename>.repo</filename> filename extension. </para> <!-- </step> --> @@ -118,7 +118,7 @@ As mentioned earlier in <xref linkend="using-setup"/>, <filename>kernel-debuginf <important> <title>Important</title> - <para>The version of the <filename>-devel</filename>, <filename>-debuginfo</filename> and <filename>-debuginfo-common</filename> packages must match the kernel you wish to probe with SystemTap <emphasis>exactly</emphasis>.</para> + <para>The version and architecture of the <filename>-devel</filename>, <filename>-debuginfo</filename> and <filename>-debuginfo-common</filename> packages must match the kernel you wish to probe with SystemTap <emphasis>exactly</emphasis>.</para> </important> <para> You can download the necessary packages via your web browser. Once you have downloaded the packages, install them by running <command>rpm -ivh <replaceable>package names</replaceable></command>. @@ -142,24 +142,24 @@ As mentioned earlier in <xref linkend="using-setup"/>, <filename>kernel-debuginf <title>simple.stp</title> <para> <programlisting> -probe timer.s(2) {exit()}
+probe kernel.function("vfs_read") {exit()}
</programlisting> </para> </formalpara> -<para><xref linkend="simplesimplescript"/> is a SystemTap script that simply closes after 2 seconds. To run the test, use <command>stap -v simple.stp</command>. If the SystemTap deployment was successful, you should get the following verbose output:</para> +<para><xref linkend="simplesimplescript"/> is a SystemTap script that simply exits the first time it detects a virtual file system read. If the SystemTap deployment was successful, you should get the following verbose output:</para> <screen> -Pass 1: parsed user script and 55 library script(s) in 340usr/0sys/356real ms.
-Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 10usr/10sys/7real ms.
-Pass 3: translated to C into "/tmp/stapwPJf4N/stap_166903963eb5e3849b44f0ba89d442a8_252.c" in 0usr/0sys/1real ms.
-Pass 4: compiled C into "stap_166903963eb5e3849b44f0ba89d442a8_252.ko" in 2050usr/230sys/2274real ms.
+Pass 1: parsed user script and 55 library script(s) in 340usr/10sys/380real ms.
+Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 280usr/290sys/745real ms.
+Pass 3: translated to C into "/tmp/stapS1CuuS/stap_dd516743892b10a24cd36ef327265169_323.c" in 0usr/0sys/0real ms.
+Pass 4: compiled C into "stap_dd516743892b10a24cd36ef327265169_323.ko" in 2050usr/220sys/2541real ms.
Pass 5: starting run.
-Pass 5: run completed in 30usr/220sys/2260real ms.
+Pass 5: run completed in 40usr/210sys/260real ms.
</screen> <para> - The last two lines of the output (i.e. beginning with <computeroutput>Pass 5</computeroutput> indicate that SystemTap was able to successfully create the instrumentation to probe the kernel, run the instrumentation, and close it with no errors. + The last two lines of the output (i.e. beginning with <computeroutput>Pass 5</computeroutput> indicate that SystemTap was able to successfully create the instrumentation to probe the kernel, run the instrumentation, detect the event being probed (in the case of <xref linkend="simplesimplescript"/>, a virtual file system read), and close it with no errors. </para> <!--</step> diff --git a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml index 67547bd8..36dd3c44 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml @@ -5,7 +5,7 @@ <chapter id="introduction"> <title>Introduction</title> <para> - SystemTap is a tracing and probing tool that provides users to study and monitor the activities of the operating system (particularly, the kernel) in fine detail. It provides information similar to the output of tools like <command>netstat</command>, <command>ps</command>, <command>top</command>, and <command>iostat</command>; however, SystemTap is designed to provide information that is more "granular" in nature. + SystemTap is a tracing and probing tool that allows users to study and monitor the activities of the operating system (particularly, the kernel) in fine detail. It provides information similar to the output of tools like <command>netstat</command>, <command>ps</command>, <command>top</command>, and <command>iostat</command>; however, SystemTap is designed to provide more filtering and analysis options for collected information. </para> <para> @@ -52,7 +52,7 @@ ** Short summary; when is SystemTap suitable vs other popular monitoring tools (e.g. top, Oprofile, /proc) </remark> - <para>SystemTap was originally developed as a working Linux version of <firstterm>Dtrace</firstterm>. Dtrace is a Sun Microsystems "dynamic tracing" framework that assists administrators in monitoring and troubleshooting kernel and user-space applications in real time.</para> + <para>SystemTap was originally developed as a working &PROD; version of old Linux probing tools such as <application>dprobes</application> and the Linux Trace Toolkit. Further, SystemTap can also be considered the Linux answer to <firstterm>Dtrace</firstterm>. Dtrace is a Sun Microsystems "dynamic tracing" framework that assists administrators in monitoring and troubleshooting kernel and user-space applications in real time.</para> <para>SystemTap aims to supplement the existing suite of Linux monitoring tools by providing users with the infrastructure to track kernel activity. In addition, SystemTap combines this capability with two things:</para> diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index 92dd8f1c..ced4d698 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -39,11 +39,7 @@ </para> </formalpara> <programlisting> -probe <replaceable>event</replaceable>, - -{ - <replaceable>handler</replaceable> -} +probe <replaceable>event</replaceable>, {<replaceable>handler</replaceable>} </programlisting> <!-- <para>The <replaceable>exit()</replaceable> condition is optional; this condition safely terminates the session once the script successfully collects the required information the first time.</para> @@ -84,7 +80,8 @@ probe kernel.function("*@net/socket.c").return { } </example> <para>In the previous example, the first probe's event specifies the entry of ALL functions in the kernel source file <filename>net/socket.c</filename>. The second probe specifies the exit of all those functions. Note that in this example, no handler was specified; as such, no information will be displayed.</para> - </listitem> + </listitem> + </varlistentry> <varlistentry> @@ -238,6 +235,15 @@ probe begin In <xref linkend="helloworld"/>, the event <command>begin</command> (i.e. the start of the session) triggers the handler enclosed in <command>{ }</command>, which simply prints <command>hello world</command>, then exits. </para> + +<note> + <title>Note</title> + <para> + Many SystemTap scripts, such as <xref linkend="helloworld"/>, do not contain an <command>exit()</command> handler. Such scripts need to be interrupted manually; to do so, use <keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo>. + </para> +</note> + + <formalpara id="printf"> <title>printf ( ) Statements</title> <para> @@ -271,7 +277,6 @@ printf ("<replaceable>format string</replaceable>\n", <replaceable>argument</rep <example id="syscall-open"> <title>variables-in-printf-statements.stp</title> <programlisting> -# This probe will need to be manually terminated with Ctrl-C probe syscall.open { printf ("%s(%d) open\n", execname(), pid()) @@ -364,6 +369,8 @@ hald(2360) open <para>The generic data included in the returned string includes a timestamp (number of microseconds since the most recent initial indentation), a process name, and the thread ID. This allows you to identify what functions were called, who called them, and the duration of each function call. </para> + <para>If call entries and exits immediately precede each other, it is easy to match them. However, in most cases, after a first function call entry is made several other call entries and exits may be made before the first call exits. The indentation counter helps you match an entry with its corresponding exit by indenting the next function call if it is not the exit of the previous one.</para> + <para> Consider the following example on the use of <command>thread_indent()</command>: </para> @@ -384,7 +391,7 @@ probe kernel.function("*@net/socket.c").return <screen> 0 ftp(7223): -> sys_socketcall - 1159 ftp(7223): -> sys_socket + 1159 ftp(7223): -> sys_socket 2173 ftp(7223): -> __sock_create 2286 ftp(7223): -> sock_alloc_inode 2737 ftp(7223): <- sock_alloc_inode @@ -397,7 +404,7 @@ probe kernel.function("*@net/socket.c").return 4644 ftp(7223): -> sock_map_file 4699 ftp(7223): <- sock_map_file 4715 ftp(7223): <- sock_map_fd - 4732 ftp(7223): <- sys_socket + 4732 ftp(7223): <- sys_socket 4775 ftp(7223): <- sys_socketcall </screen> @@ -409,7 +416,7 @@ probe kernel.function("*@net/socket.c").return <varlistentry> <term>name</term> <listitem> - <para>Identifies the name of a specific system call.</para> + <para>Identifies the name of a specific system call. This function can only be used in probes that use the event <command>syscall.<replaceable>system_call</replaceable></command>.</para> </listitem> </varlistentry> @@ -527,10 +534,8 @@ You can do this by using <emphasis>conditionals</emphasis> in handlers. SystemTa <listitem> <para>Format:</para> <programlisting> -{ if (<replaceable>condition</replaceable>) {<replaceable>handler</replaceable>} [else {<replaceable>handler</replaceable>}] -} </programlisting> </listitem> </varlistentry> @@ -540,9 +545,7 @@ if (<replaceable>condition</replaceable>) <listitem> <para>Format:</para> <programlisting> -{ while (<replaceable>condition</replaceable>) {<replaceable>handler</replaceable>} -} </programlisting> </listitem> </varlistentry> @@ -552,9 +555,7 @@ while (<replaceable>condition</replaceable>) {<replaceable>handler</replaceable> <listitem> <para>Format:</para> <programlisting> -{ for (<replaceable>argument1</replaceable>; <replaceable>argument2</replaceable>; <replaceable>argument3</replaceable>) {<replaceable>handler</replaceable>} -} </programlisting> </listitem> </varlistentry> @@ -589,7 +590,8 @@ probe kernel.function(@1).return { } </example> <para><xref linkend="commandlineargs"/> is similar to <xref linkend="wildcards"/>, except that it allows you to pass the kernel function to be probed as a command-line argument (as in <command>stap commandlineargs.stp <replaceable>kernel function</replaceable></command>). You can also specify the script to accept multiple command-line arguments, noting them as <command>@1</command>, <command>@2</command>, and so on, in the order they are entered by the user.</para> - + +<para>Both variable notations <command>$</command> and <command>@</command> also represent a specific variable type. Use <command>$</command> if you are expecting the user to enter an integer as a command-line argument, and <command>@</command> if you are expecting a string.</para> </section> <!-- <section id="SystemTap_Beginners_Guide-Test-Section_2_Test"> <title>Section 2 Test</title> diff --git a/doc/SystemTap_Beginners_Guide/en-US/Understanding_How_SystemTap_Works.xml b/doc/SystemTap_Beginners_Guide/en-US/Understanding_How_SystemTap_Works.xml index 1fb8cfb4..8dd1b803 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Understanding_How_SystemTap_Works.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Understanding_How_SystemTap_Works.xml @@ -82,8 +82,10 @@ <para> - Simply put, the tapset library is an abstraction layer designed to make it easier for users to define events and functions. In a manner of speaking, tapsets provide useful "aliases" for functions that users may want to specify as an event; knowing the proper alias to use is, for the most part, easier than understanding how to specify a specific kernel function. + Simply put, the tapset library is an abstraction layer designed to make it easier for users to define events and functions. In a manner of speaking, tapsets provide useful aliases for functions that users may want to specify as an event; knowing the proper alias to use is, for the most part, easier than remembering specific kernel functions that might vary between kernel versions. </para> + +<!-- understanding how to specify a specific kernel function. --> <para> Several handlers and functions in <xref linkend="systemtapscript-events"/> and <xref linkend="systemtapscript-handlers"/> are defined in tapsets. For example, <command>thread_indent()</command> is defined in <filename>indent.stp</filename>. diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml index 69877c5b..cfc76c07 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml @@ -19,19 +19,6 @@ <title>disktop.stp</title> <para> <programlisting> -#!/usr/bin/env stap -# -# Copyright (C) 2007 Oracle Corp. -# -# Get the status of reading/writing disk every 5 seconds, output top ten entries -# -# This is free software,GNU General Public License (GPL); either version 2, or (at your option) any -# later version. -# -# Usage: -# ./disktop.stp -# - global io_stat,device global read_bytes,write_bytes diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-sockettrace.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-sockettrace.xml new file mode 100644 index 00000000..43173516 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-sockettrace.xml @@ -0,0 +1,71 @@ +<?xml version='1.0'?> +<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ +]> + + + <section id="sockettracesect"> + <title>Tracing Functions Called in Network Socket Code</title> + + +<remark> + http://sourceware.org/systemtap/examples/network/socket-trace.stp +</remark> + + +<para>This section describes how to trace functions called from the kernel's <filename>net/socket.c</filename> file. This task helps you identify, in finer detail, how each process interacts with the network at the kernel level.</para> + +<formalpara id="sockettrace"> + <title>sockettrace.stp</title> +<para> +<programlisting> +probe kernel.function("*@net/socket.c").call {
+ printf ("%s -> %s\n", thread_indent(1), probefunc())
+}
+probe kernel.function("*@net/socket.c").return {
+ printf ("%s <- %s\n", thread_indent(-1), probefunc())
+}
+</programlisting> +</para> +</formalpara> + +<para><xref linkend="sockettrace"/> is identical to <xref linkend="thread_indent"/>, which was earlier used in <xref linkend="systemtapscript-handlers"/> to illustrate how <command>thread_indent()</command> works.</para> + +<example id="sockettraceoutput"> + <title><xref linkend="sockettrace"/> Sample Output</title> +<screen> +[...] +0 Xorg(3611): -> sock_poll
+3 Xorg(3611): <- sock_poll
+0 Xorg(3611): -> sock_poll
+3 Xorg(3611): <- sock_poll
+0 gnome-terminal(11106): -> sock_poll
+5 gnome-terminal(11106): <- sock_poll
+0 scim-bridge(3883): -> sock_poll
+3 scim-bridge(3883): <- sock_poll
+0 scim-bridge(3883): -> sys_socketcall
+4 scim-bridge(3883): -> sys_recv
+8 scim-bridge(3883): -> sys_recvfrom
+12 scim-bridge(3883):-> sock_from_file
+16 scim-bridge(3883):<- sock_from_file
+20 scim-bridge(3883):-> sock_recvmsg
+24 scim-bridge(3883):<- sock_recvmsg
+28 scim-bridge(3883): <- sys_recvfrom
+31 scim-bridge(3883): <- sys_recv
+35 scim-bridge(3883): <- sys_socketcall
+[...] +</screen> +</example> + +<para><xref linkend="sockettraceoutput"/> contains a 3-second excerpt of the output for <xref linkend="sockettrace"/>. Each line contains the following information, on the order that they appear:</para> + +<itemizedlist> + <listitem><para>The time delta (in microseconds) since the previous entry; i.e. the number of microseconds since the last traced function call.</para></listitem> + + <listitem><para>The process name (and its corresponding ID) that made the function call.</para></listitem> + + <listitem><para>An arrow signifying whether the call was an entry (<computeroutput><-</computeroutput>) or an exit (<computeroutput>-></computeroutput>); the indentations help you match specific function call entries with their corresponding exits.</para></listitem> + + <listitem><para>The name of the function called by the process.</para></listitem> +</itemizedlist> + </section> + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-threadtimes.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-threadtimes.xml new file mode 100644 index 00000000..ccf8f8d0 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-threadtimes.xml @@ -0,0 +1,106 @@ +<?xml version='1.0'?> +<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ +]> + + + <section id="threadtimessect"> + <title>Determining Time Spent in Kernel and User Space</title> + + +<remark> + http://sourceware.org/systemtap/examples/profiling/thread-times.stp +</remark> + + +<para>This section illustrates how to determine the amount of time any given thread is spending in either kernel or user-space.</para> + +<formalpara id="threadtimes"> + <title>threadtimes.stp</title> +<para> +<programlisting> +function pc:long () %{ /* pure */
+ if (CONTEXT->regs)
+ THIS->__retvalue = (uint64_t) REG_IP (CONTEXT->regs);
+%}
+
+function kta:long (pc:long) %{ /* pure */ /* is given PC a kernel text address? */
+#if defined (__ia64__)
+ THIS->__retvalue = ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)KERNEL_START);
+#else
+ THIS->__retvalue = ((unsigned long)REG_IP(CONTEXT->regs) >= (unsigned long)PAGE_OFFSET);
+#endif
+%}
+
+probe timer.profile {
+ tid=tid()
+ kernel_p = kta(pc())
+ if (kernel_p)
+ kticks[tid] <<< 1
+ else
+ uticks[tid] <<< 1
+ ticks <<< 1
+}
+
+global uticks, kticks, ticks
+
+global tids
+
+probe timer.s(10), end {
+ # gather all seen tids into a single array
+ foreach (tid in kticks) tids[tid] += @count(kticks[tid])
+ foreach (tid in uticks) tids[tid] += @count(uticks[tid])
+
+ allticks = @count(ticks)
+ printf ("%5s %7s %7s (of %d ticks)\n", "tid", "%user", "%kernel", allticks)
+ foreach (tid in tids- limit 20) {
+ uscaled = @count(uticks[tid])*10000/allticks
+ kscaled = @count(kticks[tid])*10000/allticks
+ printf ("%5d %3d.%02d%% %3d.%02d%%\n",
+ tid, uscaled/100, uscaled%100, kscaled/100, kscaled%100)
+ }
+ printf("\n")
+
+ delete uticks
+ delete kticks
+ delete ticks
+ delete tids
+}
+</programlisting> +</para> +</formalpara> + +<para><xref linkend="threadtimes"/> lists the top 20 processes currently taking up CPU time within a 5-second sample, along with the total number of CPU ticks made during the sample. The output of this script also notes the percentage of CPU time each process used, as well as whether that time was spent in kernel space or user space. </para> + +<para>To run <xref linkend="threadtimes"/>, you need to use the <command>-g</command> option (i.e. <command>stap -g threadtimes.stp</command>). This is because the script contains embedded C.</para> + +<para><xref linkend="threadtimesoutput"/> contains a 5-second sample of the output for <xref linkend="threadtimes"/>:</para> + +<example id="threadtimesoutput"> + <title><xref linkend="threadtimes"/> Sample Output</title> +<screen> + tid %user %kernel (of 20002 ticks)
+ 0 0.00% 87.88%
+32169 5.24% 0.03%
+ 9815 3.33% 0.36%
+ 9859 0.95% 0.00%
+ 3611 0.56% 0.12%
+ 9861 0.62% 0.01%
+11106 0.37% 0.02%
+32167 0.08% 0.08%
+ 3897 0.01% 0.08%
+ 3800 0.03% 0.00%
+ 2886 0.02% 0.00%
+ 3243 0.00% 0.01%
+ 3862 0.01% 0.00%
+ 3782 0.00% 0.00%
+21767 0.00% 0.00%
+ 2522 0.00% 0.00%
+ 3883 0.00% 0.00%
+ 3775 0.00% 0.00%
+ 3943 0.00% 0.00%
+ 3873 0.00% 0.00%
+</screen> +</example> + + </section> + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml index ecfc2341..49c10b9f 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml @@ -32,6 +32,8 @@ <xi:include href="Useful_Scripts-kernelprofiling.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="Useful_Scripts-futexes.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="Useful_Scripts-nettop.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> + <xi:include href="Useful_Scripts-sockettrace.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> + <xi:include href="Useful_Scripts-threadtimes.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <!-- <xi:include href="Useful_Scripts-Network.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="Useful_Scripts-Signals.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include href="Useful_Scripts-Syscalls.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /> diff --git a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml index 0e5b662d..43105edf 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml @@ -64,7 +64,7 @@ </varlistentry> <varlistentry> - <term>-e "<replaceable>script</replaceable></term> + <term>-e "<replaceable>script</replaceable>"</term> <listitem> <para>Run given <command><replaceable>script</replaceable></command>.</para> </listitem> diff --git a/runtime/autoconf-oneachcpu-retry.c b/runtime/autoconf-oneachcpu-retry.c index 304d9842..d4745a48 100644 --- a/runtime/autoconf-oneachcpu-retry.c +++ b/runtime/autoconf-oneachcpu-retry.c @@ -1,7 +1,13 @@ +#include <linux/stddef.h> +#include <linux/irqflags.h> #include <linux/smp.h> +static void no_op(void *arg) +{ +} + void ____autoconf_func(void) { /* Older on_each_cpu() calls had a "retry" parameter */ - (void)on_each_cpu(NULL, NULL, 0, 0); + (void)on_each_cpu(no_op, NULL, 0, 0); } diff --git a/stap-report b/stap-report index c2a5d070..e6503b31 100755 --- a/stap-report +++ b/stap-report @@ -4,8 +4,7 @@ import sys import time import subprocess -ofname = "/tmp/stapreport-" + time.strftime("%Y%m%d%H%M%S") + ".txt" -ofile = open(ofname, "w") +ofile = sys.stdout def run(command): ofile.write("== " + command + " ==\n") @@ -13,20 +12,15 @@ def run(command): p = subprocess.Popen(command, shell=True, stdout=ofile, stderr=ofile) p.wait() ofile.write("\n") - sys.stdout.write(".") - sys.stdout.flush() if __name__ == "__main__": - sys.stdout.write("Collecting data") - sys.stdout.flush() run("stap -V") run("which stap") run("ls -ald `locate -r '/stap$'` `locate -r '/staprun$'`") run("printenv | egrep '^PATH=|^LD_LIBRARY_PATH=|^SYSTEMTAP_.*='") run("gcc -v") run("uname -a") - run("dmesg | grep 'gcc'") run("dmesg | egrep 'stap|systemtap' | tail -n 10") run("cat /proc/cpuinfo | egrep 'processor|vendor_id|model name'") run(r"rpm -qa --qf %{name}-%{version}-%{release}.%{arch}\\n | egrep 'systemtap|elfutils|kernel|gcc' | sort") - print "\nPlease include the following file in your bug report:", ofname + run(r"egrep 'PROBE|TRACE|MARKER' /lib/modules/`uname -r`/build/.config | grep -v not.set | sort | fmt -w 80") @@ -870,8 +870,8 @@ directory. The cache can be limited by having the file placed in the cache directory (shown above) containing only an ASCII integer representing how many MiB the cache should not exceed. Note that this is a 'soft' limit in that the cache will be cleaned after a new entry -is added, so the cache size may temporarily exceed this limit. In the -absence of this file, cache cleaning is up to the user. +is added, so the total cache size may temporarily exceed this limit. In the +absence of this file, a default will be created with the limit set to 64MiB. .SH SAFETY AND SECURITY Systemtap is an administrative tool. It exposes kernel internal data diff --git a/systemtap.spec b/systemtap.spec index 1a967cf1..9327b4ad 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -169,9 +169,6 @@ mv $RPM_BUILD_ROOT%{_datadir}/doc/systemtap/examples examples # Fix paths in the example & testsuite scripts find examples testsuite -type f -name '*.stp' -print0 | xargs -0 sed -i -r -e '1s@^#!.+stap@#!%{_bindir}/stap@' -# To avoid perl dependency, make perl sample script non-executable -#chmod -x examples/samples/kmalloc-top - # Because "make install" may install staprun with mode 04111, the # post-processing programs rpmbuild runs won't be able to read it. # So, we change permissions so that they can read it. We'll set the @@ -207,6 +204,7 @@ exit 0 %endif %{_bindir}/stap +%{_bindir}/stap-report %{_mandir}/man1/* %{_mandir}/man5/* @@ -227,6 +225,7 @@ exit 0 %files runtime %defattr(-,root,root) %attr(4111,root,root) %{_bindir}/staprun +%{_bindir}/stap-report %{_libexecdir}/%{name} %{_mandir}/man8/staprun.8* |