From 184b9da7621b2fe0c588801fc0a4e94f6557bdeb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 30 Jan 2009 16:08:39 -0500 Subject: reduce systemtap.log contribution by semok/twenty.stp --- testsuite/ChangeLog | 4 ++++ testsuite/semok/twenty.stp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index e374565d..d14375a3 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-01-30 Frank Ch. Eigler + + * semok/twenty.stp: Don't spew so much into systemtap.log. + 2009-01-30 Dave Brolley * lib/systemtap.exp (setup_systemtap_environment): Make sure that diff --git a/testsuite/semok/twenty.stp b/testsuite/semok/twenty.stp index 46dcefca..73dbb3bf 100755 --- a/testsuite/semok/twenty.stp +++ b/testsuite/semok/twenty.stp @@ -1,5 +1,7 @@ -#! stap -wp2 +#! /bin/sh +set -e +stap -wp2 -e ' probe kernel.function("*") {} probe module("*").function("*") {} probe kernel.function("*").call {} @@ -8,3 +10,6 @@ probe kernel.function("*").return {} probe module("*").function("*").return {} probe kernel.function("*").inline {} probe module("*").function("*").inline {} +' | wc + +# without the |wc, we'd log the humongous list of stuff stap -p2 prints -- cgit From 255b5e73f14c9fc72e5566edf595ab8df184f14f Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 30 Jan 2009 16:56:08 -0500 Subject: Correct ChangeLog date type. --- testsuite/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index d14375a3..41b99541 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -8,7 +8,7 @@ the build directory is on the path if using a server for 'make check'. Use a string to check $server_pid. -2009-01-23 Will Cohen +2009-01-30 Will Cohen * systemtap.samples/scf.stp: * systemtap.samples/scf2.stp: Remove -- cgit From 7627c52330b476c13498144cd1288be0f5869e0f Mon Sep 17 00:00:00 2001 From: William Cohen Date: Fri, 30 Jan 2009 17:00:15 -0500 Subject: Remove systemtap.samples/queue_demo.{exp|stp}. --- testsuite/ChangeLog | 5 +++++ testsuite/systemtap.samples/queue_demo.exp | 13 ------------ testsuite/systemtap.samples/queue_demo.stp | 32 ------------------------------ 3 files changed, 5 insertions(+), 45 deletions(-) delete mode 100644 testsuite/systemtap.samples/queue_demo.exp delete mode 100644 testsuite/systemtap.samples/queue_demo.stp (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 41b99541..07f2a15c 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-30 Will Cohen + + * systemtap.samples/queue_demo.exp: + * systemtap.samples/queue_demo.stp: Remove. + 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. diff --git a/testsuite/systemtap.samples/queue_demo.exp b/testsuite/systemtap.samples/queue_demo.exp deleted file mode 100644 index 49dfac05..00000000 --- a/testsuite/systemtap.samples/queue_demo.exp +++ /dev/null @@ -1,13 +0,0 @@ -set test "queue_demo" -if {![installtest_p]} { untested $test; return } - -spawn stap $srcdir/$subdir/queue_demo.stp -set ok 0 -expect { - -timeout 240 - -re {block-[^\r]*} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } -} - -if {$ok > 4 && $ok < 10} { pass "$test" } { fail "$test" } diff --git a/testsuite/systemtap.samples/queue_demo.stp b/testsuite/systemtap.samples/queue_demo.stp deleted file mode 100644 index 61a3b6d1..00000000 --- a/testsuite/systemtap.samples/queue_demo.stp +++ /dev/null @@ -1,32 +0,0 @@ - -probe begin { - qsq_start ("block-read") - qsq_start ("block-write") -} - -probe timer.ms(3500), end { - qsq_print ("block-read") - qsq_start ("block-read") - qsq_print ("block-write") - qsq_start ("block-write") -} - -probe timer.ms(10000) { exit () } - - -# synthesize queue work/service using three randomized "threads" for each queue. - -global tc -function qs_doit (thread, name) { - n = tc[thread] = (tc[thread]+1) % 3 # per-thread state counter - if (n==1) qs_wait (name) - else if (n==2) qs_run (name) - else if (n==0) qs_done (name) -} - -probe timer.ms(100).randomize(100) { qs_doit (0, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (1, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (2, "block-read") } -probe timer.ms(100).randomize(100) { qs_doit (3, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (4, "block-write") } -probe timer.ms(100).randomize(100) { qs_doit (5, "block-write") } -- cgit From 0f336e95987931dd9fd35de02deee0ce682b987a Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 1 Feb 2009 21:22:21 -0500 Subject: Add .label("label") --- testsuite/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 41b99541..9d78ebce 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-02-01 Stan Cox + + * systemtap.base/labels.exp: New. + 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. -- cgit From d44d3f7f73e2ef22694e9d2f6c48f77ba2204a59 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Sun, 1 Feb 2009 21:34:52 -0500 Subject: Add test for .label("label") --- testsuite/systemtap.base/labels.exp | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 testsuite/systemtap.base/labels.exp (limited to 'testsuite') diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp new file mode 100644 index 00000000..6c62d576 --- /dev/null +++ b/testsuite/systemtap.base/labels.exp @@ -0,0 +1,67 @@ +set test "labels" +if {![installtest_p]} {untested $test; return} + +# Try to find utrace_attach symbol in /proc/kallsyms +# copy from utrace_p5.exp +set utrace_support_found 0 +set path "/proc/kallsyms" +if {! [catch {exec grep -q utrace_attach $path} dummy]} { + set utrace_support_found 1 +} +if {$utrace_support_found == 0} { untested "$test"; return } + +# Compile a C program to use as the user-space probing target +set label_srcpath "[pwd]/labels.c" +set label_exepath "[pwd]/labels.x" +set label_flags "additional_flags=-g" +set fp [open $label_srcpath "w"] +puts $fp " +int +main () +{ + sleep(5); + int a = 0; + int b = 0; + char *c; +init_an_int: + a = 2; +init_another_int: + b = 3; + c = \"abc\"; +ptr_inited: + return 1; +} +" +close $fp + +set fp [open "[pwd]/labels.stp" "w"] +puts $fp " +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +" +close $fp + +set ok 0 + +set res [target_compile $label_srcpath $label_exepath executable $label_flags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "compiling labels.c -g" + return +} else { + pass "compiling labels.c -g" +} + +verbose -log "spawn stap -c $label_exepath [pwd]/labels.stp" +spawn stap -c $label_exepath [pwd]/labels.stp + +expect { + -timeout 180 + -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} + +wait + +if {$ok == 1} { pass "$test" } { fail "$test ($ok)" } -- cgit From 470ac2acd8a52f33e9ce020d38ea2d0881e6cc84 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 10:02:13 -0500 Subject: Merge ChangeLog conflict --- testsuite/ChangeLog | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index f44c6488..542df531 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,15 +1,12 @@ -<<<<<<< HEAD:testsuite/ChangeLog +2009-02-01 Stan Cox + + * systemtap.base/labels.exp: New. + 2009-01-30 Will Cohen * systemtap.samples/queue_demo.exp: * systemtap.samples/queue_demo.stp: Remove. -======= -2009-02-01 Stan Cox - - * systemtap.base/labels.exp: New. - ->>>>>>> 3d65f39002440cfdeeac94d7a7a6c9a7aead2e54:testsuite/ChangeLog 2009-01-30 Frank Ch. Eigler * semok/twenty.stp: Don't spew so much into systemtap.log. -- cgit From ca1d53c1c0eab03b2bf9422d645e09be7518ea4e Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 10:12:58 -0500 Subject: Remove redundant tcp_connections_wa.stp. --- testsuite/ChangeLog | 4 ++ testsuite/systemtap.samples/tcp_connections_wa.stp | 55 ---------------------- 2 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 testsuite/systemtap.samples/tcp_connections_wa.stp (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 542df531..ad2ea6fb 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-02-02 Will Cohen + + * systemtap.samples/tcp_connections_wa.stp: Remove. + 2009-02-01 Stan Cox * systemtap.base/labels.exp: New. diff --git a/testsuite/systemtap.samples/tcp_connections_wa.stp b/testsuite/systemtap.samples/tcp_connections_wa.stp deleted file mode 100644 index 4c5e2399..00000000 --- a/testsuite/systemtap.samples/tcp_connections_wa.stp +++ /dev/null @@ -1,55 +0,0 @@ -%{ -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - - -function get_eax:long () %{ - if (CONTEXT && CONTEXT->regs) - THIS->__retvalue = CONTEXT->regs->eax; - else - THIS->__retvalue = 0; -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} -probe kernel.function("tcp_accept").return { - sock = get_eax() - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} - - -- cgit From 492d227f2caa558c4fdcd4e7aae65cf32b4549cc Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 11:18:01 -0500 Subject: Revise tcp_connections.stp example and place in sysemtap.examples directory. --- testsuite/ChangeLog | 10 +++++ testsuite/systemtap.examples/index.html | 3 ++ testsuite/systemtap.examples/index.txt | 10 +++++ testsuite/systemtap.examples/keyword-index.html | 14 ++++++- testsuite/systemtap.examples/keyword-index.txt | 32 ++++++++++++++ .../network/tcp_connections.meta | 13 ++++++ .../systemtap.examples/network/tcp_connections.stp | 14 +++++++ testsuite/systemtap.samples/tcp_connections.stp | 49 ---------------------- 8 files changed, 95 insertions(+), 50 deletions(-) create mode 100644 testsuite/systemtap.examples/network/tcp_connections.meta create mode 100644 testsuite/systemtap.examples/network/tcp_connections.stp delete mode 100644 testsuite/systemtap.samples/tcp_connections.stp (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index ad2ea6fb..c8883da4 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2009-02-02 Will Cohen + + * systemtap.samples/tcp_connections.stp: Revised and moved to examples. + * systemtap.examples/network/tcp_connections.stp: + * systemtap.examples/network/tcp_connections.meta: New. + * systemtap.examples/index.html: + * systemtap.examples/index.txt: + * systemtap.examples/keyword-index.html: + * systemtap.examples/keyword-index.txt: Regenerate. + 2009-02-02 Will Cohen * systemtap.samples/tcp_connections_wa.stp: Remove. diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 87a5a50e..3395edca 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -76,6 +76,9 @@ keywords: NETWORK network/socket-trace.stp - Trace Functions called in Network Socket Code
keywords: NETWORK SOCKET

The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

+
  • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
    +keywords: NETWORK TCP SOCKET
    +

    The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

  • process/futexes.stp - System-Wide Futex Contention
    keywords: SYSCALL LOCKING FUTEX

    The script watches the futex syscall on the system. On exit the futexes address, the number of contentions, and the average time for each contention on the futex are printed from lowest pid number to highest.

  • diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index 5ffc341a..ddf24471 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -109,6 +109,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + process/futexes.stp - System-Wide Futex Contention keywords: syscall locking futex diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 9ff68c8d..6c367ad7 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -39,7 +39,7 @@

    Examples by Keyword

    -

    BACKTRACE CALLGRAPH CPU DISK FUNCTIONS FUTEX GRAPH INTERRUPT IO LOCKING NETWORK PER-PROCESS PROFILING READ SCHEDULER SIGNALS SIMPLE SLEEP SOCKET SYSCALL TIME TRACE TRAFFIC USE WAIT4 WRITE

    +

    BACKTRACE CALLGRAPH CPU DISK FUNCTIONS FUTEX GRAPH INTERRUPT IO LOCKING NETWORK PER-PROCESS PROFILING READ SCHEDULER SIGNALS SIMPLE SLEEP SOCKET SYSCALL TCP TIME TRACE TRAFFIC USE WAIT4 WRITE

    BACKTRACE

    • interrupt/scf.stp - Tally Backtraces for Inter-Processor Interrupt (IPI)
      @@ -132,6 +132,9 @@ keywords: NETWORK network/socket-trace.stp - Trace Functions called in Network Socket Code
      keywords: NETWORK SOCKET

      The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

    • +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    PER-PROCESS

      @@ -198,6 +201,9 @@ keywords: SYSCALL network/socket-trace.stp - Trace Functions called in Network Socket Code
      keywords: NETWORK SOCKET

      The script instrument each of the functions inn the Linux kernel's net/socket.c file. The script prints out trace. The first element of a line is time delta in microseconds from the previous entry. This is followed by the command name and the PID. The "->" and "<-" indicates function entry and function exit, respectively. The last element of the line is the function name.

      +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    SYSCALL

      @@ -220,6 +226,12 @@ keywords: SYSCALL
      keywords: SYSCALL WAIT4

      The script watches each wait4 syscall on the system. At the end of each wait4 syscall the script prints out a line with a timestamp in microseconds, the pid, the executable name in paretheses, the "wait4:" key, the duration of the wait and the PID that the wait4 was waiting for. If the waited for PID is not specified , it is "-1".

    +

    TCP

    +
      +
    • network/tcp_connections.stp - Track Creation of Incoming TCP Connections
      +keywords: NETWORK TCP SOCKET
      +

      The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request.

    • +

    TIME

    • io/iotime.stp - Trace Time Spent in Read and Write for Files
      diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 0127f3a8..3cb0c3cf 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -204,6 +204,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = PER-PROCESS = network/nettop.stp - Periodic Listing of Processes Using Network Interfaces @@ -352,6 +362,16 @@ keywords: network socket element of the line is the function name. +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = SYSCALL = io/iotime.stp - Trace Time Spent in Read and Write for Files @@ -415,6 +435,18 @@ keywords: syscall wait4 waiting for. If the waited for PID is not specified , it is "-1". += TCP = + +network/tcp_connections.stp - Track Creation of Incoming TCP Connections +keywords: network tcp socket + + The tcp_connections.stp script prints information for each new + incoming TCP connection accepted by the computer. The information + includes the UID, the command accepting the connection, the PID of + the command, the port the connection is on, and the IP address of the + originator of the request. + + = TIME = io/iotime.stp - Trace Time Spent in Read and Write for Files diff --git a/testsuite/systemtap.examples/network/tcp_connections.meta b/testsuite/systemtap.examples/network/tcp_connections.meta new file mode 100644 index 00000000..0bc9bcb1 --- /dev/null +++ b/testsuite/systemtap.examples/network/tcp_connections.meta @@ -0,0 +1,13 @@ +title: Track Creation of Incoming TCP Connections +name: tcp_connections.stp +version: 1.0 +author: anonymous +keywords: network tcp socket +subsystem: kernel +status: production +exit: user-controlled +output: trace +scope: system-wide +description: The tcp_connections.stp script prints information for each new incoming TCP connection accepted by the computer. The information includes the UID, the command accepting the connection, the PID of the command, the port the connection is on, and the IP address of the originator of the request. +test_check: stap -p4 tcp_connections.stp +test_installcheck: stap tcp_connections.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/network/tcp_connections.stp b/testsuite/systemtap.examples/network/tcp_connections.stp new file mode 100644 index 00000000..bd2db76a --- /dev/null +++ b/testsuite/systemtap.examples/network/tcp_connections.stp @@ -0,0 +1,14 @@ +#! /usr/bin/env stap + +probe begin { + printf("%6s %16s %6s %6s %16s\n", + "UID", "CMD", "PID", "PORT", "IP_SOURCE") +} + +probe kernel.function("tcp_accept").return?, + kernel.function("inet_csk_accept").return? { + sock = $return + if (sock != 0) + printf("%6d %16s %6d %6d %16s\n", uid(), execname(), pid(), + inet_get_local_port(sock), inet_get_ip_source(sock)) +} diff --git a/testsuite/systemtap.samples/tcp_connections.stp b/testsuite/systemtap.samples/tcp_connections.stp deleted file mode 100644 index a4449b60..00000000 --- a/testsuite/systemtap.samples/tcp_connections.stp +++ /dev/null @@ -1,49 +0,0 @@ -#! stap - -%{ -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) -#define LPORT (inet->inet.num) -#define DADDR (&inet->inet.daddr) -#else -#define LPORT (inet->num) -#define DADDR (&inet->daddr) -#endif -%} - -function get_local_port:long(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - - struct inet_sock *inet = (struct inet_sock *) ptr; - THIS->__retvalue = (long long) LPORT; -%} - -function get_ip_source:string(sock) -%{ - unsigned long ptr = (unsigned long) THIS->sock; - struct inet_sock *inet = (struct inet_sock *) ptr; - unsigned char addr[4]; - memcpy(addr, DADDR, sizeof(addr)); - sprintf(THIS->__retvalue, "%d.%d.%d.%d", - addr[0], addr[1], addr[2], addr[3]); - -%} - - -probe begin { - log ("UID\tCMD\t\tPID\t\tPORT\tIP_SOURCE") -} - -probe kernel.function("tcp_accept").return { - sock = $return - if (sock != 0) - log(sprint(uid())."\t". - execname()."\t\t". - sprint(pid())."\t\t ". - sprint(get_local_port(sock))."\t". - get_ip_source(sock)) -} -- cgit From 1bf72dfea404434f954214298367817d5c591903 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Mon, 2 Feb 2009 14:21:25 -0500 Subject: Revised topsys.stp and moved to the testsuite/systemtap.examples directory. --- testsuite/ChangeLog | 10 ++++ testsuite/systemtap.examples/index.html | 3 + testsuite/systemtap.examples/index.txt | 8 +++ testsuite/systemtap.examples/keyword-index.html | 3 + testsuite/systemtap.examples/keyword-index.txt | 8 +++ testsuite/systemtap.examples/profiling/topsys.meta | 13 ++++ testsuite/systemtap.examples/profiling/topsys.stp | 24 ++++++++ testsuite/systemtap.samples/topsys.stp | 69 ---------------------- 8 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 testsuite/systemtap.examples/profiling/topsys.meta create mode 100644 testsuite/systemtap.examples/profiling/topsys.stp delete mode 100644 testsuite/systemtap.samples/topsys.stp (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index c8883da4..4c0a85a9 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2009-02-02 Will Cohen + + * systemtap.samples/topsys.stp: Revised and moved to examples. + * systemtap.examples/profiling/topsys.stp: + * systemtap.examples/profiling/topsys.meta: New. + * systemtap.examples/index.html: + * systemtap.examples/index.txt: + * systemtap.examples/keyword-index.html: + * systemtap.examples/keyword-index.txt: Regenerate. + 2009-02-02 Will Cohen * systemtap.samples/tcp_connections.stp: Revised and moved to examples. diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index 3395edca..e02ab867 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -121,6 +121,9 @@ keywords: PROFILING
    • profiling/timeout.stp - Show Processes Doing Polling Operations
      keywords: PROFILING

      The timeout.stp script is based on a blog entry (http://udrepper.livejournal.com/19041.html) mentioning a need for a tool to help developers find applications that are polling. The timeout.stp script monitors systemcall used for polling and records the systemcalls that timed out rather than returned because some action occurred. The script updates the screen once a second with the top twenty processes.

    • +
    • profiling/topsys.stp - Show Processes Doing Polling Operations
      +keywords: PROFILING
      +

      The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent.

    diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index ddf24471..0076afaa 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -243,3 +243,11 @@ keywords: profiling top twenty processes. +profiling/topsys.stp - Show Processes Doing Polling Operations +keywords: profiling + + The topsys.stp script lists out the top twenty systemcalls for the + previous 5 seconds. The output is sorted from most frequent to least + frequent. + + diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 6c367ad7..3156cc08 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -156,6 +156,9 @@ keywords: PROFILING
  • profiling/timeout.stp - Show Processes Doing Polling Operations
    keywords: PROFILING

    The timeout.stp script is based on a blog entry (http://udrepper.livejournal.com/19041.html) mentioning a need for a tool to help developers find applications that are polling. The timeout.stp script monitors systemcall used for polling and records the systemcalls that timed out rather than returned because some action occurred. The script updates the screen once a second with the top twenty processes.

  • +
  • profiling/topsys.stp - Show Processes Doing Polling Operations
    +keywords: PROFILING
    +

    The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent.

  • READ

      diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 3cb0c3cf..a940ccfa 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -266,6 +266,14 @@ keywords: profiling top twenty processes. +profiling/topsys.stp - Show Processes Doing Polling Operations +keywords: profiling + + The topsys.stp script lists out the top twenty systemcalls for the + previous 5 seconds. The output is sorted from most frequent to least + frequent. + + = READ = io/iotime.stp - Trace Time Spent in Read and Write for Files diff --git a/testsuite/systemtap.examples/profiling/topsys.meta b/testsuite/systemtap.examples/profiling/topsys.meta new file mode 100644 index 00000000..3642713d --- /dev/null +++ b/testsuite/systemtap.examples/profiling/topsys.meta @@ -0,0 +1,13 @@ +title: Show Processes Doing Polling Operations +name: topsys.stp +version: 1.0 +author: anonymous +keywords: profiling +subsystem: kernel syscalls +status: production +exit: user-controlled +output: sorted-list +scope: system-wide +description: The topsys.stp script lists out the top twenty systemcalls for the previous 5 seconds. The output is sorted from most frequent to least frequent. +test_check: stap -p4 topsys.stp +test_installcheck: stap topsys.stp -c "sleep 1" diff --git a/testsuite/systemtap.examples/profiling/topsys.stp b/testsuite/systemtap.examples/profiling/topsys.stp new file mode 100644 index 00000000..34cf826c --- /dev/null +++ b/testsuite/systemtap.examples/profiling/topsys.stp @@ -0,0 +1,24 @@ +#! /usr/bin/env stap +# +# This script continuously lists the top 20 systemcalls in the interval +# 5 seconds +# + +global syscalls_count + +probe syscall.* { + syscalls_count[name]++ +} + +function print_systop () { + printf ("%25s %10s\n", "SYSCALL", "COUNT") + foreach (syscall in syscalls_count- limit 20) { + printf("%25s %10d\n", syscall, syscalls_count[syscall]) + } + delete syscalls_count +} + +probe timer.s(5) { + print_systop () + printf("--------------------------------------------------------------\n") +} diff --git a/testsuite/systemtap.samples/topsys.stp b/testsuite/systemtap.samples/topsys.stp deleted file mode 100644 index da31c858..00000000 --- a/testsuite/systemtap.samples/topsys.stp +++ /dev/null @@ -1,69 +0,0 @@ -#! stap -g -# -# This script continuously lists the top 20 systemcalls in the interval -# of 2000 jiffies. -# - -global syscalls_count, syscalls - -function syscall_name:string () %{ - char *str, buff[80]; - char *tok; - str = buff; - strlcpy(str, CONTEXT->probe_point, sizeof(buff)); - tok = strsep(&str, "\""); - tok = strsep(&str, "@"); - sprintf(str, "%-25s", tok); - strlcpy(THIS->__retvalue, str, MAXSTRINGLEN); -%} - -function reset_maxaction () %{ - if (CONTEXT && CONTEXT->actioncount) - CONTEXT->actioncount=0; -%} - -function accumulate () { - syscall=syscall_name() - syscalls_count[syscall]++ - # I use this array to refer to syscalls_count array in - # the reset_syscalls_count. Initalize with a non-zero. - syscalls[syscall]=1 -} - - -function print_top () { - lcnt=0 - reset_maxaction () - foreach ([syscall] in syscalls_count-) { - sys_cnt = syscalls_count[syscall] - log (syscall . "\t\t\t\t" . sprint(sys_cnt)) - if (lcnt++ == 20) - break; - } - syscalls_count[lsyscall]=0 -} - -function reset_syscalls_count () { - # For some reason, I have to do this to get pass the elaboration - # phase on RHEL4 (seg fault). Under FC4, it works fine with out - # the 'dummy_init' - syscalls["dummy_init"]=0 - foreach ([sys] in syscalls) - syscalls_count[sys]=0 -} - -function print_systop () { - log ("SYSCALL \t\t\t\tCOUNT") - print_top() - reset_syscalls_count () -} - -probe kernel.function("sys_*").call { - accumulate () -} - -probe timer.jiffies(2000) { - print_systop () - log("--------------------------------------------------------------") -} - -- cgit