From e91b23bc1b375d7ffb3395aa6909713bd1f23c10 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 26 Sep 2008 16:22:43 -0400 Subject: sort arrays by value- subject to automagic foreach/printf --- ChangeLog | 4 ++++ elaborate.cxx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d62f154f..0683cce2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-09-26 Frank Ch. Eigler + + * elaborate.cxx (add_global_var_display): Implicitly sort arrays. + 2008-09-26 Frank Ch. Eigler PR 6916 diff --git a/elaborate.cxx b/elaborate.cxx index 94bfd1c5..afdc796e 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1234,7 +1234,8 @@ void add_global_var_display (systemtap_session& s) vardecl* idx_v[idx_count]; // Create a foreach loop foreach_loop* fe = new foreach_loop; - fe->sort_direction = 0; + fe->sort_direction = -1; // imply decreasing sort on value + fe->sort_column = 0; // as in foreach ([a,b,c] in array-) { } fe->limit = NULL; // Create indices for the foreach loop -- cgit From a3de5d6e615aafb9528e22db5eeb6ddc12823256 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 30 Sep 2008 16:35:13 +0200 Subject: Don't crash when reporting an error if getting alternatives fails. --- ChangeLog | 6 ++++++ tapsets.cxx | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d62f154f..ea1d51d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-30 Mark Wielaard + + * tapsets.cxx (literal_stmt_for_local): Check if alternatives can be + provided after calling dwarf_formref_die. + (literal_stmt_for_return): Likewise. + 2008-09-26 Frank Ch. Eigler PR 6916 diff --git a/tapsets.cxx b/tapsets.cxx index b1475997..a5a62c7a 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2241,7 +2241,8 @@ struct dwflpp { die = dwarf_formref_die (&attr_mem, &vardie); stringstream alternatives; - print_members(die,alternatives); + if (die != NULL) + print_members(die,alternatives); throw semantic_error("unable to find local '" + local + "'" + " near pc " + lex_cast_hex(pc) + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")"))); @@ -2317,7 +2318,8 @@ struct dwflpp { die = dwarf_formref_die (&attr_mem, vardie); stringstream alternatives; - print_members(die,alternatives); + if (die != NULL) + print_members(die,alternatives); throw semantic_error("unable to find return value" " near pc " + lex_cast_hex(pc) + (alternatives.str() == "" ? "" : (" (alternatives:" + alternatives.str () + ")"))); -- cgit From f12c75dd38c4990b9410410cc23e33004d3677ed Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 29 Sep 2008 17:58:31 +0200 Subject: Fix race condition in addr-map; simplify allocation logic --- runtime/ChangeLog | 5 +++ runtime/addr-map.c | 99 +++++++++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 46 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 6672dbb5..677b32ee 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-09-30 Tim Moore + + * addr-map.c (add_bad_addr_entry): Rewrite allocation of address + table to simplify locking and eliminate a race condition. + 2008-09-26 David Smith * task_finder.c (__STP_ATTACHED_TASK_EVENTS): Removed UTRACE_STOP, diff --git a/runtime/addr-map.c b/runtime/addr-map.c index 8231b57f..c215b744 100644 --- a/runtime/addr-map.c +++ b/runtime/addr-map.c @@ -113,64 +113,71 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, struct addr_map_entry* max_entry = 0; struct addr_map_entry* new_entry = 0; size_t existing = 0; - + + /* Loop allocating memory for a new entry in the map. */ while (1) { - size_t old_size; + size_t old_size = 0; spin_lock(&addr_map_lock); old_map = blackmap; - if (!blackmap) - { - existing = 0; - old_size = 0; - } - else + if (old_map) + old_size = old_map->size; + /* Either this is the first time through the loop, or we + allocated a map previous time, but someone has come in and + added an entry while we were sleeping. */ + if (!new_map || (new_map && new_map->size < old_size + 1)) { - min_entry = lookup_addr_aux(min_addr, blackmap); - max_entry = lookup_addr_aux(max_addr, blackmap); - if (min_entry || max_entry) + spin_unlock(&addr_map_lock); + if (new_map) { - if (existing_min) - *existing_min = min_entry; - if (existing_max) - *existing_max = max_entry; - spin_unlock(&addr_map_lock); - return 1; + kfree(new_map); + new_map = 0; } - existing = upper_bound(min_addr, old_map); - old_size = old_map->size; - } - spin_unlock(&addr_map_lock); - new_map = kmalloc(sizeof(*new_map) - + sizeof(*new_entry) * (old_size + 1), - GFP_KERNEL); - if (!new_map) - return -ENOMEM; - spin_lock(&addr_map_lock); - if (blackmap != old_map) - { - kfree(new_map); - spin_unlock(&addr_map_lock); + new_map = kmalloc(sizeof(*new_map) + + sizeof(*new_entry) * (old_size + 1), + GFP_KERNEL); + if (!new_map) + return -ENOMEM; + new_map->size = old_size + 1; continue; } - new_entry = &new_map->entries[existing]; - new_entry->min = min_addr; - new_entry->max = max_addr; - if (old_map) + } + if (!blackmap) + { + existing = 0; + } + else + { + min_entry = lookup_addr_aux(min_addr, blackmap); + max_entry = lookup_addr_aux(max_addr, blackmap); + if (min_entry || max_entry) { - memcpy(&new_map->entries, old_map->entries, - existing * sizeof(*new_entry)); - if (old_map->size > existing) - memcpy(new_entry + 1, &old_map->entries[existing + 1], - (old_map->size - existing) * sizeof(*new_entry)); + if (existing_min) + *existing_min = min_entry; + if (existing_max) + *existing_max = max_entry; + spin_unlock(&addr_map_lock); + kfree(new_map); + return 1; } - new_map->size = blackmap->size + 1; - blackmap = new_map; - spin_unlock(&addr_map_lock); - if (old_map) - kfree(old_map); - return 0; + existing = upper_bound(min_addr, old_map); + } + new_entry = &new_map->entries[existing]; + new_entry->min = min_addr; + new_entry->max = max_addr; + if (old_map) + { + memcpy(&new_map->entries, old_map->entries, + existing * sizeof(*new_entry)); + if (old_map->size > existing) + memcpy(new_entry + 1, &old_map->entries[existing + 1], + (old_map->size - existing) * sizeof(*new_entry)); } + blackmap = new_map; + spin_unlock(&addr_map_lock); + if (old_map) + kfree(old_map); + return 0; } void -- cgit From 7115de8281be8cb68880210572ba0a0141509fb9 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 14:49:43 -0400 Subject: PR6925: add more information about installing and running stap --- README | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README b/README index 6b62c772..5732cf63 100644 --- a/README +++ b/README @@ -23,12 +23,12 @@ Installation steps: Build steps: -- Install the kernel-debuginfo, kernel-[smp-]devel, gcc and libcap-devel +- Install the kernel-debuginfo, kernel-devel, gcc and dependent packages (or see below if you are building your own kernels from source). - If available, install your distribution's copy of elfutils and its - development headers/libraries. -- Or if desired, download an elfutils source release to build in +- If available, install your distribution's copy of elfutils and its + development headers/libraries. + Or if desired, download an elfutils source release to build in "bundled mode" (below), and untar it into some new directory. Or if desired, build elfutils separately one time, and install it to /usr/local. @@ -45,15 +45,36 @@ Build steps: % .../configure [other autoconf options] Or, with build it with a bundled internal copy of elfutils: % .../configure --with-elfutils=ELFUTILS-SOURCE-DIR [other autoconf options] + Consider configuring with "--enable-dejazilla" to automatically contribute to our public test result database. + Consider configuring with "--prefix=DIRECTORY" to specify an + installation directory other than /usr/local. It can be an ordinary + personal directory. + % make all % sudo make install - To run the full test suite: + To uninstall systemtap: + % sudo make uninstall + +- Run systemtap: + + To run the full test suite from the build tree. % sudo make installcheck + To run systemtap, add $prefix/bin to your $PATH, or refer to + $prefix/bin/stap directly. Some samples should be available under + $prefix/share/doc/systemtap/examples. Normally, run "stap" as root. + + If desired, create "stapdev" and "stapusr" entries in /etc/groups. + Any users in "stapdev" will be able to run systemtap as if with root + privileges. Users in "stapusr" can only launch (with "staprun") + pre-compiled probe modules (created by "stap -p4 ...") that a system + administrator copied under /lib/modules/`uname -r`/systemtap. + + Tips: - By default, systemtap looks for the debug info in these locations: -- cgit From b586f21fc0dbd1e195ece774f02334589a10ddb1 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 14:51:26 -0400 Subject: PR6925: mention the possibility of running the build tree "stap" after "make install" --- README | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README b/README index 5732cf63..13b3aa5f 100644 --- a/README +++ b/README @@ -64,9 +64,12 @@ Build steps: To run the full test suite from the build tree. % sudo make installcheck - To run systemtap, add $prefix/bin to your $PATH, or refer to - $prefix/bin/stap directly. Some samples should be available under - $prefix/share/doc/systemtap/examples. Normally, run "stap" as root. + To run systemtap after installation, add $prefix/bin to your $PATH, or + refer to $prefix/bin/stap directly. If you keep your build tree + around, you can also use the "stap" binary there. + + Some samples should be available under $prefix/share/doc/systemtap/examples. + Normally, run "stap" as root. If desired, create "stapdev" and "stapusr" entries in /etc/groups. Any users in "stapdev" will be able to run systemtap as if with root -- cgit From d90adf0dff664bfe6a7f9b7e6ba0e008ca261a40 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 30 Sep 2008 19:26:39 -0400 Subject: More README text tweaks for run options --- README | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README b/README index 13b3aa5f..b7434256 100644 --- a/README +++ b/README @@ -10,10 +10,10 @@ See the INSTALL file for generic build instructions. Prerequisites: - linux kernel with kprobes (mainline 2.6.11+ or backport) -- kernel module build environment (kernel-devel or kernel-smp-devel rpm) +- kernel module build environment (kernel-devel rpm) - kernel debugging information (kernel-debuginfo rpm) - C compiler (same as what kernel was compiled with) -- elfutils with libdwfl for debugging informatin parsing +- elfutils with libdwfl for debugging information parsing - root privileges Installation steps: @@ -61,21 +61,21 @@ Build steps: - Run systemtap: - To run the full test suite from the build tree. - % sudo make installcheck - To run systemtap after installation, add $prefix/bin to your $PATH, or refer to $prefix/bin/stap directly. If you keep your build tree around, you can also use the "stap" binary there. Some samples should be available under $prefix/share/doc/systemtap/examples. - Normally, run "stap" as root. - If desired, create "stapdev" and "stapusr" entries in /etc/groups. - Any users in "stapdev" will be able to run systemtap as if with root - privileges. Users in "stapusr" can only launch (with "staprun") - pre-compiled probe modules (created by "stap -p4 ...") that a system - administrator copied under /lib/modules/`uname -r`/systemtap. + Normally, run "stap" as root. If desired, create "stapdev" and + "stapusr" entries in /etc/groups. Any users in "stapdev" will be + able to run systemtap as if with root privileges. Users in "stapusr" + can only launch (with "staprun") pre-compiled probe modules (created + by "stap -p4 ...") that a system administrator copied under + /lib/modules/`uname -r`/systemtap. + + To run the full test suite from the build tree. + % sudo make installcheck Tips: -- cgit From c7415f95827be9b6bee3e635d0118231cdd8b638 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Wed, 1 Oct 2008 09:29:07 +1000 Subject: removed brackets in replaceables, my mistake --- .../en-US/CrossInstrumenting.xml | 6 ++-- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 32 +++++++++++----------- .../en-US/Using_SystemTap.xml | 16 +++++------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml index cf57f5b2..07280100 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml @@ -113,9 +113,9 @@ enabled=1 To build the instrumentation module, run the following command on the host system (be sure to specify the appropriate values): -stap -r [kernel version] [script] -m [module name] +stap -r kernel version script -m module name -Here, [kernel version] refers to the version of target kernel (including the architecture notation), [script] refers to the script to be converted into an instrumentation module, and [instrumentation name] is the desired name of the instrumentation module. +Here, kernel version refers to the version of target kernel (including the architecture notation), script refers to the script to be converted into an instrumentation module, and instrumentation name is the desired name of the instrumentation module. Note @@ -124,7 +124,7 @@ enabled=1 Once the the instrumentation moduleis compiled, copy it to the target system and load it using: -staprun [instrumentation] +staprun instrumentation For example, to create the instrumentation module module.ko from the SystemTap script script.stp for the target kernel 2.6.25.9-76.fc9 (on i686 architecture), use the following command: diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index 160597bf..fec9aee7 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -36,11 +36,11 @@ -probe [event], -[another event] +probe event, +another event { - [handler] + handler exit() } @@ -66,7 +66,7 @@ probe [event], - kernel.function("[function]") + kernel.function("function") The entry to the kernel function function. For example, kernel.function("sys_open") refers to the "event" that occurs when the kernel function sys_open is called by any thread in the system. To specify the return of the kernel function sys_open, append the return string to the event statement; i.e. kernel.function("sys_open").return. @@ -83,16 +83,16 @@ probe kernel.function("*@net/socket.c").return { } - syscall.[system_call] + syscall.system_call - The entry to the system call [system_call]. Similar to kernel.function, appending a return to the statement specifies the exit of the system call. For example, to specify the entry of the system call close, use syscall.close.return. + The entry to the system call system_call. Similar to kernel.function, appending a return to the statement specifies the exit of the system call. For example, to specify the entry of the system call close, use syscall.close.return. To identify what system calls are made by a specific program/command, use strace command. - module("[module]").function("[function]") + module("module").function("function") Allows you to probe functions within modules. For example: @@ -108,7 +108,7 @@ probe kernel.function("*@net/socket.c").return { } - A system's loaded modules are typically located in /lib/modules/[kernel version], where kernel version refers to the currently loaded kernel. Modules use the filename extension .ko. + A system's loaded modules are typically located in /lib/modules/kernel version, where kernel version refers to the currently loaded kernel. Modules use the filename extension .ko. @@ -160,15 +160,15 @@ probe timer.ms(4000) -timer.s([seconds]) +timer.s(seconds) -timer.us([microseconds]) +timer.us(microseconds) -timer.ns([nanoseconds]) +timer.ns(nanoseconds) -timer.hz([hertz]) +timer.hz(hertz) -timer.jiffies([jiffies]) +timer.jiffies(jiffies) @@ -238,11 +238,11 @@ probe begin -printf ("[format string]\n", [argument]) +printf ("format string\n", argument) - The [format string] region specifies how [argument] should be displayed. The format string of simply instructs SystemTap to print hello world, and contains no arguments. + The format string region specifies how argument should be displayed. The format string of simply instructs SystemTap to print hello world, and contains no arguments. @@ -411,7 +411,7 @@ probe kernel.function("*@net/socket.c").return + + To determine what kernel your system is currently using, use: + + + +uname -r + + + + You will also need to configure yum to point to a repository that houses the necessary debug RPMs. Most debugging RPMs for Red Hat Enterprise Linux 5 can be found at the following repository: + + + ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/i386/Debuginfo/ + + find any other such repository, if only for RHEL + + +
+ Deploying SystemTap + + + Once you've decided which kernels with which you need to use SystemTap with, install the following packages: + + + systemtap + systemtap-runtime + + + This will install the SystemTap suite of tools. + + + Next, you'll need to download and install the necessary debug RPMs for your kernel. The necessary debugging RPMs for the ordinary "vanilla" kernel are as follows: + + + kernel-debuginfo + kernel-debuginfo-common + kernel-devel + + +For example, if you wish to use SystemTap on kernel version 2.6.18-53.el5, then you need to download the following debugging RPMs: + + + Sample List of Debugging RPMs + + kernel-debuginfo-2.6.18-53.1.13.el5.i686.rpm + kernel-debuginfo-common-2.6.18-53.1.13.el5.i686.rpm + kernel-devel-2.6.18-53.1.13.el5.i686.rpm + + + + Install the debugging RPMs using rpm -ivh RPM or yum localinstall RPM. + + +
+ + + \ No newline at end of file -- cgit From 94c98493aea16a4ef49b2eff31cf6ca98e92fddc Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Wed, 1 Oct 2008 07:07:39 -0400 Subject: fix test suite regression due to commit e91b23bc Reported-By: mjw --- testsuite/systemtap.base/optim_arridx.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index bef4d2b4..1f3f4371 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -58,7 +58,7 @@ end /* <- end */ # locals idx0:long { -foreach ([idx0] in arr3) printf("arr3[%#d]=%#x\\n", idx0, arr3[idx0]) +foreach ([idx0] in arr3-) printf("arr3[%#d]=%#x\\n", idx0, arr3[idx0]) } end /* <- end */ { -- cgit From dd4918442a55569175bda0575f746e84c99cee58 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 1 Oct 2008 13:38:16 +0200 Subject: Adjust semok/thirtythree.stp test to pass on older kernels. --- testsuite/ChangeLog | 5 +++++ testsuite/semok/thirtythree.stp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index f3fad077..4825cd27 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-10-01 Mark Wielaard + + * semok/thirtythree.stp: Use page->mapping instead of page->inuse + as annonymous struct value (also available in older kernels). + 2008-09-26 Frank Ch. Eigler PR 6916. diff --git a/testsuite/semok/thirtythree.stp b/testsuite/semok/thirtythree.stp index d5171f66..90070370 100755 --- a/testsuite/semok/thirtythree.stp +++ b/testsuite/semok/thirtythree.stp @@ -1,5 +1,5 @@ #! stap -p2 # Per bz3016, this should get through the semantic pass without warnings. probe kernel.function("do_mpage_readpage") { - printf("\n page ->inuse %u",$page->inuse) + printf("\n page->mapping %p",$page->mapping) } -- cgit From caf566cb319004a314b09ea6fd6781941db89f8e Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 2 Oct 2008 10:31:49 +0200 Subject: fix bugs in add_bad_addr_entry --- runtime/ChangeLog | 5 +++++ runtime/addr-map.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 677b32ee..e22bee26 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2008-10-02 Tim Moore + + * addr-map.c (add_bad_addr_entry): Fix bugs in allocating a new + table and copying old entries into the new table. + 2008-09-30 Tim Moore * addr-map.c (add_bad_addr_entry): Rewrite allocation of address diff --git a/runtime/addr-map.c b/runtime/addr-map.c index c215b744..706da454 100644 --- a/runtime/addr-map.c +++ b/runtime/addr-map.c @@ -139,8 +139,9 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, if (!new_map) return -ENOMEM; new_map->size = old_size + 1; - continue; } + else + break; } if (!blackmap) { @@ -170,7 +171,7 @@ add_bad_addr_entry(unsigned long min_addr, unsigned long max_addr, memcpy(&new_map->entries, old_map->entries, existing * sizeof(*new_entry)); if (old_map->size > existing) - memcpy(new_entry + 1, &old_map->entries[existing + 1], + memcpy(new_entry + 1, &old_map->entries[existing], (old_map->size - existing) * sizeof(*new_entry)); } blackmap = new_map; -- cgit From 4125a78ae5fc99abb8606bf0eda2a08b3e2d300c Mon Sep 17 00:00:00 2001 From: ddomingo Date: Thu, 2 Oct 2008 23:07:01 +1000 Subject: new section, iotop.stp --- .../en-US/CrossInstrumenting.xml | 12 ++- .../en-US/Installation.xml | 37 ++++---- .../en-US/Introduction.xml | 2 +- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 56 ++++++----- .../en-US/SystemTap_Beginners_Guide.xml | 3 +- .../en-US/Tips_Tricks.xml | 7 +- .../en-US/Understanding_How_SystemTap_Works.xml | 12 ++- .../en-US/Useful_Scripts-disktop.xml | 22 ++--- .../en-US/Useful_Scripts-iotop.xml | 76 +++++++++++++++ .../en-US/Useful_SystemTap_Scripts.xml | 4 + .../en-US/Using_SystemTap.xml | 105 +++------------------ 11 files changed, 175 insertions(+), 161 deletions(-) create mode 100644 doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotop.xml diff --git a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml index 07280100..cc451ec4 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml @@ -77,7 +77,7 @@ Configuring a Host System and Target Systems - Configure yum on the host system to point to a repository containing the necessary debug RPMs for the target kernels. The following yum repository file (which you can add to /etc/yum.repos.d/ points to a popular debug RPM repository for Red Hat Enterprise Linux 5: + Configure yum on the host system to point to a repository containing the necessary debug RPMs for the target kernels. The following yum repository file (which you can add to /etc/yum.repos.d/ points to a popular debug RPM repository for i386 systems running Red Hat Enterprise Linux 5: [rhel-debuginfo] name=Red Hat Enterprise Linux $releasever - $basearch - Debug @@ -119,10 +119,11 @@ enabled=1 Note - To determine the version of a running kernel, run uname -r. To determine the architecture notation of a running kernel, run uname -m. + To determine the architecture notation of a running kernel, run uname -m. + -Once the the instrumentation moduleis compiled, copy it to the target system and load it using: +Once the the instrumentation module is compiled, copy it to the target system and load it using: staprun instrumentation @@ -142,6 +143,9 @@ enabled=1 Note the version of the target system's kernel on which you wish to use SystemTap. You can do this by logging onto the target system and running uname -r (assuming the system is running the kernel on which you wish to use SystemTap), or by inspecting /boot. --> - + + Important + The host system must be the same architecture as the target system in order for the instrumentation module to work. + \ No newline at end of file diff --git a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml index 92d40bc0..0ccefa3a 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml @@ -1,9 +1,9 @@ - - +
Setup and Installation required packages, installation thru yum, repos (?); possibly, a script to install all required packages @@ -14,7 +14,7 @@ - To deploy SystemTap, you need to install the SystemTap packages along with the corresponding set of debug RPMs of your kernel. This means that if your system has multiple kernels installed, and you wish to use SystemTap on more than one kernel, you will need to install the debug RPMs for each of those kernels. + To deploy SystemTap, you need to install the SystemTap packages along with the corresponding set of -devel and -debuginfo packages for your kernel. This means that if your system has multiple kernels installed, and you wish to use SystemTap on more than one kernel kernel, you will need to install the -devel and -debuginfo packages for each of those kernel versions.
Preparing For Installation @@ -29,14 +29,21 @@ uname -r + - You will also need to configure yum to point to a repository that houses the necessary debug RPMs. Most debugging RPMs for Red Hat Enterprise Linux 5 can be found at the following repository: + Most -debuginfo packages for Red Hat Enterprise Linux 5 can be found at the following link (under arch/Debuginfo, where arch is the appropriate architecture for your system: - ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/i386/Debuginfo/ + ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/ find any other such repository, if only for RHEL + + +
@@ -55,7 +62,7 @@ uname -r - Next, you'll need to download and install the necessary debug RPMs for your kernel. The necessary debugging RPMs for the ordinary "vanilla" kernel are as follows: + Next, you'll need to download and install the necessary -devel and -debuginfo packages for your kernel. The necessary -devel and -debuginfo packages for the ordinary "vanilla" kernel are as follows: @@ -65,7 +72,7 @@ uname -r kernel-devel -For example, if you wish to use SystemTap on kernel version 2.6.18-53.el5, then you need to download the following debugging RPMs: +For example, if you wish to use SystemTap on kernel version 2.6.18-53.el5, then you need to download and install the following RPMs: Sample List of Debugging RPMs @@ -76,23 +83,13 @@ uname -r - Install the debugging RPMs using rpm -ivh RPM or yum localinstall RPM. - -
- - \ No newline at end of file +
+ \ No newline at end of file diff --git a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml index b19f5e48..28abf439 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml @@ -30,7 +30,7 @@ To introduce users to SystemTap, familiarize them with its architecture, and provide setup instructions for all kernel types. - To provide pre-written SystemTap scripts for monitoring and forensic tasks, along with instructions on how to analyze their output. + To provide pre-written SystemTap scripts for monitoring detailed activity in different components of the system, along with instructions on how to analyze their output. above, Short description on the underlying goals of SystemTap_Beginners_Guide, what we want to teach users. diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index fec9aee7..b928372b 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -6,7 +6,7 @@ SystemTap Scripts - For the most part, SystemTap scripts are the foundation of each SystemTap session. SystemTap scripts instruct SystemTap on what type of information to trap, and what to do once that information is trapped. + For the most part, SystemTap scripts are the foundation of each SystemTap session. SystemTap scripts instruct SystemTap on what type of information to collect, and what to do once that information is collected. @@ -21,9 +21,12 @@ A probe's handler is also commonly referred to as a probe body.
- - In terms of application development, using events and handlers is similar to inserting print statements in a program's sequence of commands. These print statements allow you to view a history of commands executed once the program is run. + + In terms of application development, using events and handlers is similar to inserting diagnostic print statements in a program's sequence of commands. These diagnostic print statements allow you to view a history of commands executed once the program is run. + SystemTap scripts go one step further by allowing you more flexibility with regard to handlers. Events serve as the triggers for handlers to run; handlers can be specified to trap specified data and print it in a certain manner. @@ -37,16 +40,14 @@ probe event, -another event { handler - - exit() } - The exit() condition is optional; this condition safely terminates the session once the script successfully traps the required information the first time. - + Important @@ -59,9 +60,13 @@ probe event, SystemTap events can be broadly classified into two types: synchronous and asynchronous. Synchronous Events - A synchronous event occurs when any processor executes an instruction matched by the specification. This gives other events a reference point (or instruction address) from which more contextual data may be available. +A synchronous event occurs when any process executes an instruction that references a particular location in kernel code. This gives other events a reference point from which more contextual data may be available. + + + + Examples of synchronous events include: @@ -70,7 +75,7 @@ probe event, The entry to the kernel function function. For example, kernel.function("sys_open") refers to the "event" that occurs when the kernel function sys_open is called by any thread in the system. To specify the return of the kernel function sys_open, append the return string to the event statement; i.e. kernel.function("sys_open").return. - When defining functions, you can use asterisk (*) for wildcards. You can also trace the entry/exit of a function in a kernel source file. Consider the following example: + When defining functions, you can use asterisk (*) for wildcards. You can also trace the entry or exit of a function in a kernel source file. Consider the following example: Wildcards and Kernel Source Files in an Event probe kernel.function("*@net/socket.c") { } @@ -118,7 +123,8 @@ probe kernel.function("*@net/socket.c").return { } Asynchronous Events - Asynchronous events, on the other hand, do not point to any reference point. This family of probe points consists mainly of counters, timers, and similar constructs. + Asynchronous events, on the other hand, occur as instructed in the probe itself, rather than waiting for a particular instruction in kernel code to be executed by a process. This family of probe points consists mainly of counters, timers, and similar constructs. + Examples of asynchronous events include: @@ -144,19 +150,19 @@ probe kernel.function("*@net/socket.c").return { } timer events - An event that specifies a handler to be executed "after X number of milliseconds". For example: + An event that specifies a handler to be executed every specified period of time. For example: Using timer.ms probe timer.ms(4000) { - exit() + printf("hello world\n") } - is an example of a probe that allows you to terminate the script after 4000 milliseconds. Note that you can also use the following timer events: + is an example of a probe that prints hello world every 4000 milliseconds. Note that you can also use the following timer events: @@ -172,8 +178,12 @@ probe timer.ms(4000) - When used in conjunction with another probe that traps a large quantity of data, timer events allow you to limit the information your script is collecting (and printing out). + When used in conjunction with another probe that collects information that updates periodically, timer events allows you to see how that information changes over time. + @@ -231,7 +241,7 @@ probe begin printf ( ) Statements - The printf () statement is one of the simplest functions for printing data. printf () can also be used to trap data using a wide variety of SystemTap handler functions using the following format: + The printf () statement is one of the simplest functions for printing data. printf () can also be used to display data using a wide variety of SystemTap functions in the following format: @@ -288,13 +298,13 @@ hald(2360) open - Handler Functions - SystemTap supports a wide variety of handler functions that can be used as printf () arguments. uses the handler functions execname() (current process name) and pid() (current process ID). + SystemTap Functions + SystemTap supports a wide variety of functions that can be used as printf () arguments. uses the SystemTap functions execname() (current process name) and pid() (current process ID). -is "handler function" an appropriate term? +is "handler function" an appropriate term? wcohen: use "SystemTap functions" to match up language in man pages - The following is a list of commonly-used handler functions: + The following is a list of commonly-used SystemTap functions: @@ -349,7 +359,7 @@ hald(2360) open thread_indent() - This particular handler function is quite useful, providing you with a way to better organize your print results. When used with an indentation parameter (for example, -1), it allows the probe to internally store an "indentation counter" for each thread (identified by ID, as in tid). It then returns a string with some generic trace data along with an appropriate number of indentation spaces. + This particular function is quite useful, providing you with a way to better organize your print results. When used with an indentation parameter (for example, -1), it allows the probe to internally store an "indentation counter" for each thread (identified by ID, as in tid). It then returns a string with some generic trace data along with an appropriate number of indentation spaces. 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. @@ -405,9 +415,9 @@ probe kernel.function("*@net/socket.c").return --> -For more information about supported handler functions, refer to man stapfuncs. +For more information about supported SystemTap functions, refer to man stapfuncs. -will need a complete listing of supported handler functions? also, handler function descriptions seem ambiguous, please advise. +will need a complete listing of supported handler functions? also, SystemTap function descriptions seem ambiguous, please advise. + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Tips_Tricks.xml b/doc/SystemTap_Beginners_Guide/en-US/Tips_Tricks.xml index 0377c499..0327962b 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Tips_Tricks.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Tips_Tricks.xml @@ -4,11 +4,12 @@ Tips and Tricks - This chapter covers miscellaneous tips/tricks - - This is a tentative section, and will only be included if content can be provided + - This chapter covers miscellaneous tips/tricks + - This is a tentative section, and will only be included if content can be provided + - add use of exit() here + - add "basic constructs" here; i.e. using if/else, while loops, for loops, examples; if done, consider moving up to before Useful_SystemTap_Scripts.xm, after Understanding_How_SystemTap_Works.xml 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 2794901c..1fb8cfb4 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 @@ -35,16 +35,20 @@ First, SystemTap checks the script against the existing tapset library (normally in /usr/share/systemtap/tapset/ for any tapsets used. - SystemTap then translates the script to C, running the system C compiler to create a kernel module from it. + SystemTap then translates the script to C, running the system C compiler to create a kernel module from it. The tools that perform this step are contained in the systemtap package (refer to for more information). - SystemTap loads the module, then enables all the probed events by "hooking" those events into the kernel. + SystemTap loads the module, then enables all the probes (events and handlers) in the script. The tools that enable this function are deployed by the systemtap-runtime package (refer to for more information). + As the events occur, their corresponding handlers are executed. - Once the SystemTap session is terminated, the hooked events are disconnected from the kernel; afterwards, the kernel module is unloaded. + Once the SystemTap session is terminated, the probes are disconnected from the kernel; afterwards, the kernel module is unloaded. + -This sequence is driven from a single command-line program: stap. This program is SystemTap's main front-end tool. For more information about stap, refer to man stap (once SystemTap is set up on your machine). +This sequence is driven from a single command-line program: stap. This program is SystemTap's main front-end tool. For more information about stap, refer to man stap (once SystemTap is properly installed on your machine). 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 a3e3d8a7..0c191cff 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-disktop.xml @@ -3,7 +3,7 @@ ]> -
+
Summarizing Disk Read/Write Traffic @@ -73,7 +73,7 @@ probe timer.ms(5000) { } /* print top ten I/O */ foreach ([process,cmd,userid,parent,action] in io_stat- limit 10) - printf("%8d %8d %8d %25s %8s %4s %12d\n",userid,process,parent,cmd,device[process,cmd,userid,parent,action],action,io_stat[process,cmd,userid,parent,action]) + printf("%8d %8d %8d %25s %8s %4s %12d\n",userid,process,parent,cmd,device[process,cmd,userid,parent,action], action,io_stat[process,cmd,userid,parent,action]) /* clear data */ delete io_stat @@ -115,18 +115,18 @@ probe end{ <xref linkend="scriptdisktop"/> Sample Output [...] -Mon Sep 29 03:38:28 2008 , Average: 19Kb/sec, Read: 7Kb, Write: 89Kb +Mon Sep 29 03:38:28 2008 , Average: 19Kb/sec, Read: 7Kb, Write: 89Kb -UID PID PPID CMD DEVICE T BYTES -0 26319 26294 firefox sda5 W 90229 -0 2758 2757 pam_timestamp_c sda5 R 8064 -0 2885 1 cupsd sda5 W 1678 +UID PID PPID CMD DEVICE T BYTES +0 26319 26294 firefox sda5 W 90229 +0 2758 2757 pam_timestamp_c sda5 R 8064 +0 2885 1 cupsd sda5 W 1678 -Mon Sep 29 03:38:38 2008 , Average: 1Kb/sec, Read: 7Kb, Write: 1Kb +Mon Sep 29 03:38:38 2008 , Average: 1Kb/sec, Read: 7Kb, Write: 1Kb -UID PID PPID CMD DEVICE T BYTES -0 2758 2757 pam_timestamp_c sda5 R 8064 -0 2885 1 cupsd sda5 W 1678 +UID PID PPID CMD DEVICE T BYTES +0 2758 2757 pam_timestamp_c sda5 R 8064 +0 2885 1 cupsd sda5 W 1678 diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotop.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotop.xml new file mode 100644 index 00000000..fe249428 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-iotop.xml @@ -0,0 +1,76 @@ + + + +
+ Periodically Print I/O Activity + + This section describes how to monitor I/O activity on the system. + + + iotop.stp + + +global reads, writes, total_io + +probe kernel.function("vfs_read") { + reads[execname()] += $count +} + +probe kernel.function("vfs_write") { + writes[execname()] += $count +} + +# print top 10 IO processes every 5 seconds +probe timer.s(5) { + foreach (name in writes) + total_io[name] += writes[name] + foreach (name in reads) + total_io[name] += reads[name] + printf ("%16s\t%10s\t%10s\n", "Process", "KB Read", "KB Written") + foreach (name in total_io- limit 10) + printf("%16s\t%10d\t%10d\n", name, + reads[name]/1024, writes[name]/1024) + delete reads + delete writes + delete total_io + print("\n") +} + + + + + prints out the top ten executables generating I/O traffic every 5-second interval, in descending order. Its output contains the process name and the amount of data read or written by the process, in KB. For example: + + + <xref linkend="iotop"/> Sample Output + +[...] + Process KB Read KB Written + Xorg 50287 0 + staprun 3328 0 + multiload-apple 3039 23 + sshd 208 1 + floaters 14 62 + NetworkManager 15 0 + gnome-vfs-daemo 8 0 + cupsd 3 3 + sendmail 4 0 + mixer_applet2 3 0 + + Process KB Read KB Written + Xorg 51886 0 + staprun 3328 0 + multiload-apple 3039 23 + sshd 1344 4 + snmpd 90 0 + floaters 15 66 + NetworkManager 23 0 + irqbalance 16 0 + pam_timestamp_c 9 0 + sendmail 4 0 + + + + displays top I/O writes and reads within a random 10-second interval. Note that is recursive, as it also detects I/O resulting from SystemTap activity — also displays reads done by staprun. +
\ No newline at end of file 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 51fef276..03e515ff 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_SystemTap_Scripts.xml @@ -21,10 +21,14 @@ + + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml index 8b851a49..ebf71276 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Using_SystemTap.xml @@ -11,99 +11,7 @@ This chapter instructs users how to install SystemTap, and provides an introduction on how to run SystemTap scripts. - -
- Setup and Installation - - required packages, installation thru yum, repos (?); possibly, a script to install all required packages - - - - notes in ~/Desktop/SystemTap/aug21chatlog and ~/Desktop/SystemTap/noted_wcohenmeeting - - - - To deploy SystemTap, you need to install the SystemTap packages along with the corresponding set of debug RPMs of your kernel. This means that if your system has multiple kernels installed, and you wish to use SystemTap on more than one kernel, you will need to install the debug RPMs for each of those kernels. - - - Preparing For Installation - - To view what kernels and kernel versions are installed on your system, check the contents of /boot. Each installed kernel/kernel version has a corresponding vmlinuz-kernel version there. - - - - To determine what kernel your system is currently using, use: - - - -uname -r - - - - You will also need to configure yum to point to a repository that houses the necessary debug RPMs. One such repository is: - - - ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/i386/Debuginfo/ - - find any other such repository, if only for RHEL - - - - Deploying SystemTap - - - Once you've decided which kernels you need to use SystemTap with, install the following packages: - - - systemtap - systemtap-runtime - - - This will install the SystemTap suite of tools. - - - - Next, you'll need to download and install the necessary debug RPMs for your kernel. Most debugging RPMs for Red Hat Enterprise Linux 5 can be found at the following link: - - The necessary debugging RPMs are as follows: - - - kernel-debuginfo - kernel-debuginfo-common - kernel-devel - - -For example, if you wish to use SystemTap on kernel version 2.6.18-53.el5, then you need to download the following debugging RPMs: - - - Sample List of Debugging RPMs - - kernel-debuginfo-2.6.18-53.1.13.el5.i686.rpm - kernel-debuginfo-common-2.6.18-53.1.13.el5.i686.rpm - kernel-devel-2.6.18-53.1.13.el5.i686.rpm - - - - - - Install the debugging RPMs using rpm -ivh RPM or yum localinstall RPM. - - - - - Restart the system, loading the appropriate kernel at the grub screen. - - - - - - -
+
Usage @@ -118,9 +26,18 @@ uname -r - Tapsets: short intro on usage --> - SystemTap scripts are run through the command stap. stap can run SystemTap scripts from standard input or from file. Below is a list of common options available to you: + SystemTap scripts are run through the command stap. stap can run SystemTap scripts from standard input or from file. + + Important +Running SystemTap requires root privileges. As such, you need to either log in as root or configure sudo accordingly for specific users who need to run SystemTap (refer to man sudo or man visudo for more information. + + + + + Below is a list of commonly used stap options: + -- cgit From 748eea887135ac44f5c4b0a7499225d4cb2cbefe Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 3 Oct 2008 14:15:49 +0200 Subject: Adjust expected foreach ordering in global_end.exp due to commit e91b23bc. --- testsuite/ChangeLog | 4 ++++ testsuite/systemtap.base/global_end.exp | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 4825cd27..041df499 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-10-03 Mark Wielaard + + * systemtap.base/global_end.exp: Adjust expected foreach ordering. + 2008-10-01 Mark Wielaard * semok/thirtythree.stp: Use page->mapping instead of page->inuse diff --git a/testsuite/systemtap.base/global_end.exp b/testsuite/systemtap.base/global_end.exp index cd5c6f83..b6b9fd30 100644 --- a/testsuite/systemtap.base/global_end.exp +++ b/testsuite/systemtap.base/global_end.exp @@ -9,13 +9,13 @@ set ok 0 expect { -timeout 180 -re {one,0x1.*one,0x2.*two,0x1.*two,0x2} { incr ok; exp_continue } - -re {alpha."one".1.=0x1} { incr ok; exp_continue } - -re {alpha."one".2.=0x2} { incr ok; exp_continue } - -re {alpha."two".1.=0x3} { incr ok; exp_continue } -re {alpha."two".2.=0x4} { incr ok; exp_continue } + -re {alpha."two".1.=0x3} { incr ok; exp_continue } + -re {alpha."one".2.=0x2} { incr ok; exp_continue } + -re {alpha."one".1.=0x1} { incr ok; exp_continue } -re {gamma="abcdefghijklmnopqrstuvwxyz"} { incr ok; exp_continue } - -re {iota."one".="eleven"} { incr ok; exp_continue } -re {iota."two".="twelve"} { incr ok; exp_continue } + -re {iota."one".="eleven"} { incr ok; exp_continue } -re {epsilon."one",1. @count=0x4 @min=0x1 @max=0x4 @sum=0xa @avg=0x2} { incr ok; exp_continue } -re {epsilon."two",2. @count=0x4 @min=0xa @max=0x28 @sum=0x64 @avg=0x19} { incr ok; exp_continue } -re {phi @count=0x4 @min=0x1 @max=0x4 @sum=0xa @avg=0x2} { incr ok; exp_continue } -- cgit