From 14f0bb1853f944681823fbc72460f6eac6b58f2d Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Sun, 7 Mar 2010 21:13:39 -0500 Subject: new sample: varwatch --- testsuite/systemtap.examples/general/varwatch.meta | 6 ++++ testsuite/systemtap.examples/general/varwatch.stp | 28 ++++++++++++++++ testsuite/systemtap.examples/index.html | 8 ++--- testsuite/systemtap.examples/index.txt | 20 ++++++------ testsuite/systemtap.examples/io/ttyspy.meta | 2 +- testsuite/systemtap.examples/keyword-index.html | 23 ++++++------- testsuite/systemtap.examples/keyword-index.txt | 38 ++++++++++------------ 7 files changed, 77 insertions(+), 48 deletions(-) create mode 100644 testsuite/systemtap.examples/general/varwatch.meta create mode 100644 testsuite/systemtap.examples/general/varwatch.stp (limited to 'testsuite/systemtap.examples') diff --git a/testsuite/systemtap.examples/general/varwatch.meta b/testsuite/systemtap.examples/general/varwatch.meta new file mode 100644 index 00000000..3d876bb1 --- /dev/null +++ b/testsuite/systemtap.examples/general/varwatch.meta @@ -0,0 +1,6 @@ +title: Watch a variable changing value in a thread. +name: varwatch.stp +keywords: monitoring +description: This script places a set of probes (specified by $1), each of which monitors the state of some context $variable expression (specified by $2). Whenever the value changes, with respect to the active thread, the event is traced. +test_check: stap -wp4 varwatch.stp 'kernel.statement("do_sys_open@fs/open.c:*")' '$$vars' +test_installcheck: stap -w varwatch.stp 'kernel.statement("do_sys_open@fs/open.c:*")' '$$vars' -c "sleep 0.2" diff --git a/testsuite/systemtap.examples/general/varwatch.stp b/testsuite/systemtap.examples/general/varwatch.stp new file mode 100644 index 00000000..845ca166 --- /dev/null +++ b/testsuite/systemtap.examples/general/varwatch.stp @@ -0,0 +1,28 @@ +#! /usr/bin/env stap + +global var, varerr + +probe $1 { + t=tid() # or t=0 for thread-agnostic checking + if (@defined($2)) { + try { + newvar = $2; + if (var[t] != newvar) { + printf("%s %s changed in thread %d from %s to %s\n", pp(), @2, t, sprint(var[t]), sprint(newvar)); + var[t] = newvar; + } + } catch { varerr ++ } # error during $2 resolution or perhaps var[] assignment + } +} + +probe kprocess.release { # if using per-thread checking + delete var[$p->pid] # thread +} + +probe never { + var[0]="" # assigns a type to var in case no probes match $1 above +} + +probe error,end { + if (varerr) printf("%s %s access errors: %d", @1, @2, varerr); +} diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 1bcfff5e..e241f11f 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -58,6 +58,9 @@ keywords: SIMPLE
  • general/para-callgraph.stp - Callgraph tracing with arguments
    keywords: TRACE CALLGRAPH

    Print a timed per-thread callgraph, complete with function parameters and return values. The first parameter names the function probe points to trace. The optional second parameter names the probe points for trigger functions, which acts to enable tracing for only those functions that occur while the current thread is nested within the trigger.

  • +
  • general/varwatch.stp - Watch a variable changing value in a thread.
    +keywords: MONITORING
    +

    This script places a set of probes (specified by $1), each of which monitors the state of some context $variable expression (specified by $2). Whenever the value changes, with respect to the active thread, the event is traced.

  • interrupt/interrupts-by-dev.stp - Record interrupts on a per-device basis.
    keywords: INTERRUPT

    The interrupts-by-dev.stp script profiles interrupts received by each device per 100 ms.

  • @@ -91,9 +94,6 @@ keywords: IO
  • io/mbrwatch.stp - Monitor read/write of MBR (boot sector) area of block devices
    keywords: IO MONITORING

    The mbrwatch.stp script reports any attempted reads/writes of the first few sectors of a raw block device.

  • -
  • io/nfs_func_log.stp - Print Log of NFS Functions Used
    -keywords: IO
    -

    The nfs_func_log.stp script logs the uses of NFS functions in the kernel. The output is a trace. Each line contains the time stamp, the process name, and the process number followed by the function name.

  • io/nfs_func_users.stp - Tally the Number of NFS Functions Used by Each Process
    keywords: IO PROFILING

    The nfs_func_users.stp script counts the uses of NFS functions in the kernel on a per process bases. The output is sorted from the process with the greatest number of NFS functions called to the least. The output contains the executable name, the process number, and the total number of NFS functions called by the process.

  • @@ -104,7 +104,7 @@ keywords: IO
    keywords: IO

    Print out the executable name and process number as reads and writes to the specified device occur.

  • io/ttyspy.stp - Monitor tty typing.
    -keywords: IO TTY PER-PROCESS MONITOR
    +keywords: IO TTY PER-PROCESS MONITORING

    The ttyspy.stp script uses tty_audit hooks to monitor recent typing activity on the system, printing a scrolling record of recent keystrokes, on a per-tty basis.

  • locks/bkl.stp - Tracing Contention on Big Kernel Lock (BKL)
    keywords: LOCKING
    diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index a0cdc9c3..d0fd5926 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -50,6 +50,15 @@ keywords: trace callgraph the trigger. +general/varwatch.stp - Watch a variable changing value in a thread. +keywords: monitoring + + This script places a set of probes (specified by $1), each of which + monitors the state of some context $variable expression (specified by + $2). Whenever the value changes, with respect to the active thread, + the event is traced. + + interrupt/interrupts-by-dev.stp - Record interrupts on a per-device basis. keywords: interrupt @@ -156,15 +165,6 @@ keywords: io monitoring first few sectors of a raw block device. -io/nfs_func_log.stp - Print Log of NFS Functions Used -keywords: io - - The nfs_func_log.stp script logs the uses of NFS functions in the - kernel. The output is a trace. Each line contains the time stamp, - the process name, and the process number followed by the function - name. - - io/nfs_func_users.stp - Tally the Number of NFS Functions Used by Each Process keywords: io profiling @@ -190,7 +190,7 @@ keywords: io io/ttyspy.stp - Monitor tty typing. -keywords: io tty per-process monitor +keywords: io tty per-process monitoring The ttyspy.stp script uses tty_audit hooks to monitor recent typing activity on the system, printing a scrolling record of recent diff --git a/testsuite/systemtap.examples/io/ttyspy.meta b/testsuite/systemtap.examples/io/ttyspy.meta index ea1c9040..b171fad4 100644 --- a/testsuite/systemtap.examples/io/ttyspy.meta +++ b/testsuite/systemtap.examples/io/ttyspy.meta @@ -1,6 +1,6 @@ title: Monitor tty typing. name: ttyspy.stp -keywords: io tty per-process monitor +keywords: io tty per-process monitoring description: The ttyspy.stp script uses tty_audit hooks to monitor recent typing activity on the system, printing a scrolling record of recent keystrokes, on a per-tty basis. test_support: stap -l 'kernel.function("tty_audit_add_data")' test_check: stap -gp4 ttyspy.stp diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 40f2f1d6..a1f5a3c3 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -39,7 +39,7 @@

    Examples by Keyword

    -

    ALLOCATOR AUTOFS BACKTRACE BUFFER CALLGRAPH CPU DEVICE DISK FILES FILESYSTEM FORMAT FREE FUNCTIONS FUTEX GRAPH HACK INTERRUPT IO LOCKING MEMORY MONITOR MONITORING NETWORK NFS NUMA PER-PROCESS PROCESS PROFILING READ SCHEDULER SCSI SIGNALS SIMPLE SLAB SLEEP SOCKET STATISTICS SYSCALL TCP TIME TRACE TRACEPOINT TRAFFIC TTY USE WAIT4 WRITE

    +

    ALLOCATOR AUTOFS BACKTRACE BUFFER CALLGRAPH CPU DEVICE DISK FILES FILESYSTEM FORMAT FREE FUNCTIONS FUTEX GRAPH HACK INTERRUPT IO LOCKING MEMORY MONITORING NETWORK NFS NUMA PER-PROCESS PROCESS PROFILING READ SCHEDULER SCSI SIGNALS SIMPLE SLAB SLEEP SOCKET STATISTICS SYSCALL TCP TIME TRACE TRACEPOINT TRAFFIC TTY USE WAIT4 WRITE

    ALLOCATOR

    -

    MONITOR

    -

    MONITORING

    NETWORK