From 2e526dabcf4b15fb102e295b282df3af54d5c9d3 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Mon, 19 Oct 2009 11:33:24 -0400 Subject: PR10799: warn on possibly uintended local-vs-global namespace collision * elaborate.cxx (find_var): Take extra token parameter. Look for cross-file global variable resolution, signal a warning. * testsuite/systemtap.examples/io/traceio2.stp: Fix it. * testsuite/systemtap.syscall/sys.stp: Fix it. * NEWS: Document it. --- testsuite/systemtap.examples/io/traceio2.stp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testsuite/systemtap.examples') diff --git a/testsuite/systemtap.examples/io/traceio2.stp b/testsuite/systemtap.examples/io/traceio2.stp index 1abea45d..797f3062 100755 --- a/testsuite/systemtap.examples/io/traceio2.stp +++ b/testsuite/systemtap.examples/io/traceio2.stp @@ -1,6 +1,6 @@ #! /usr/bin/env stap -global device_of_interest, dev +global device_of_interest probe begin { /* The following is not the most efficient way to do this. -- cgit From 9996b615a6ad49ba8adccf7c9395045016ef74e0 Mon Sep 17 00:00:00 2001 From: Eugene Teo Date: Fri, 30 Oct 2009 19:52:23 -0400 Subject: plimit: Add plimit.stp sample script --- testsuite/systemtap.examples/process/plimit.meta | 7 +++ testsuite/systemtap.examples/process/plimit.stp | 78 ++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 testsuite/systemtap.examples/process/plimit.meta create mode 100755 testsuite/systemtap.examples/process/plimit.stp (limited to 'testsuite/systemtap.examples') diff --git a/testsuite/systemtap.examples/process/plimit.meta b/testsuite/systemtap.examples/process/plimit.meta new file mode 100644 index 00000000..d5cd4e8b --- /dev/null +++ b/testsuite/systemtap.examples/process/plimit.meta @@ -0,0 +1,7 @@ +title: print resource limits +name: plimit.stp +keywords: process +subsystem: general +description: The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels. +test_check: stap -gp4 plimit.stp $$ +test_installcheck: stap -g plimit.stp $$ diff --git a/testsuite/systemtap.examples/process/plimit.stp b/testsuite/systemtap.examples/process/plimit.stp new file mode 100755 index 00000000..1a389468 --- /dev/null +++ b/testsuite/systemtap.examples/process/plimit.stp @@ -0,0 +1,78 @@ +#!/usr/bin/env stap +# plimit.stp +# Copyright (C) 2006 Red Hat, Inc., Eugene Teo +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# + +%{ + #include + #include +%} + +function getrlimit:string (rlim:long, pid:long) %{ /* pure */ + struct task_struct *p; + struct list_head *_p, *_n; + static char cur_buf[24], max_buf[24]; + long int cur, max; + + list_for_each_safe(_p, _n, ¤t->tasks) { + p = list_entry(_p, struct task_struct, tasks); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12) + cur = p->signal->rlim[THIS->rlim].rlim_cur; + max = p->signal->rlim[THIS->rlim].rlim_max; +#else + cur = p->rlim[THIS->rlim].rlim_cur; + max = p->rlim[THIS->rlim].rlim_max; +#endif + if (p->pid == (int)THIS->pid) { + if (cur == -1 && max == -1) + strcat(THIS->__retvalue, "unlimited unlimited"); + else if (cur == -1) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9s %-9ld", + "unlimited", max); + else if (max == -1) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9ld %-9s", + cur, "unlimited"); + else + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%-9ld %-9ld", + cur, max); + } + } +%} + +function task_execname_by_pid:string (pid:long) %{ /* pure */ + struct task_struct *p; + struct list_head *_p, *_n; + list_for_each_safe(_p, _n, ¤t->tasks) { + p = list_entry(_p, struct task_struct, tasks); + if (p->pid == (int)THIS->pid) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "%s", p->comm); + } +%} + +probe begin +{ + printf("%d: -%s\n", $1, task_execname_by_pid($1)) + /* include/asm-generic/resource.h */ + printf(" resource current maximum\n") + printf("coredump(blocks) %s\n", getrlimit(4, $1)) + printf("data(bytes) %s\n", getrlimit(2, $1)) + printf("max nice %s\n", getrlimit(13, $1)) + printf("file size(blocks) %s\n", getrlimit(1, $1)) + printf("pending signals %s\n", getrlimit(11, $1)) + printf("max locked memory(bytes) %s\n", getrlimit(8, $1)) + printf("max memory size(bytes) %s\n", getrlimit(5, $1)) + printf("open files %s\n", getrlimit(7, $1)) + printf("POSIX message queues(bytes) %s\n", getrlimit(12, $1)) + printf("max rt priority %s\n", getrlimit(14, $1)) + printf("stack size(bytes) %s\n", getrlimit(3, $1)) + printf("cpu time(seconds) %s\n", getrlimit(0, $1)) + printf("max user processes %s\n", getrlimit(6, $1)) + printf("virtual memory(bytes) %s\n", getrlimit(9, $1)) + printf("file locks %s\n", getrlimit(10, $1)) + + exit() +} -- cgit From 5b8642a208b614769f934c6a4ce2991658025a57 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 30 Oct 2009 19:53:03 -0400 Subject: regen sample indexes with plimit.stp --- testsuite/systemtap.examples/index.html | 3 +++ testsuite/systemtap.examples/index.txt | 7 +++++++ testsuite/systemtap.examples/keyword-index.html | 3 +++ testsuite/systemtap.examples/keyword-index.txt | 7 +++++++ 4 files changed, 20 insertions(+) (limited to 'testsuite/systemtap.examples') diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index f2b7066f..55fea0fb 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -169,6 +169,9 @@ keywords: SCHEDULER
  • process/pf2.stp - Profile kernel functions
    keywords: PROFILING

    The pf2.stp script sets up time-based sampling. Every five seconds it prints out a sorted list with the top ten kernel functions with samples.

  • +
  • process/plimit.stp - print resource limits
    +keywords: PROCESS
    +

    The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels.

  • process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints
    keywords: PROCESS SCHEDULER TIME TRACEPOINT

    The schedtimes.stp script instruments the scheduler to track the amount of time that each process spends running, sleeping, queued, and waiting for io. On exit the script prints out the accumulated time for each state of processes observed. Optionally, this script can be used with the '-c' or '-x' options to focus on a specific PID.

  • diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index e880c746..16b45aac 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -407,6 +407,13 @@ keywords: profiling samples. +process/plimit.stp - print resource limits +keywords: process + + The script prints a variety of resource limits for a given pid, like + /proc/$$/limits on recent kernels. + + process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints keywords: process scheduler time tracepoint diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index f09a20b3..1a2855e1 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -297,6 +297,9 @@ keywords: PROCESS process/forktracker.stp - Trace Creation of Processes
    keywords: PROCESS SCHEDULER

    The forktracker.stp script prints out a time-stamped entry showing each fork and exec operation on the machine. This can be useful for determine what process is creating a flurry of short-lived processes.

    +
  • process/plimit.stp - print resource limits
    +keywords: PROCESS
    +

    The script prints a variety of resource limits for a given pid, like /proc/$$/limits on recent kernels.

  • process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints
    keywords: PROCESS SCHEDULER TIME TRACEPOINT

    The schedtimes.stp script instruments the scheduler to track the amount of time that each process spends running, sleeping, queued, and waiting for io. On exit the script prints out the accumulated time for each state of processes observed. Optionally, this script can be used with the '-c' or '-x' options to focus on a specific PID.

  • diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 853198d3..6de9c330 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -605,6 +605,13 @@ keywords: process scheduler determine what process is creating a flurry of short-lived processes. +process/plimit.stp - print resource limits +keywords: process + + The script prints a variety of resource limits for a given pid, like + /proc/$$/limits on recent kernels. + + process/schedtimes.stp - Track Time Processes Spend in Various States using Tracepoints keywords: process scheduler time tracepoint -- cgit