Martin Cermak [Thu, 8 Sep 2016 12:03:57 +0000 (14:03 +0200)]
Introduce new statistics operator @variance().
New statistics @variance() operator using the Welford's online algorithm
for per-cpu computation, and the Total Variance formula authored by
Niranjan Kamat and Arnab Nandi from the Ohio State University for the
cross-cpu aggregation.
Commit c4a048331603a3fe19c886498e957f5f2a577ed9 blacklists hcall_*
kernel tracepoints for powerpc to avoid recursive page faults and
kernel panic due to that. powerpc:hash_fault should be blacklisted
too, since, its placed in the same path of kernel code which is
invoked on a page fault.
tweak error message for exhausted-overloaded-functions
Correct the error message generated for "all functions exhausted" to
focus on the token of the function-call site, rather than whatever
inner statement was last executed before a "next".
Josh Stone [Fri, 26 Aug 2016 20:57:08 +0000 (13:57 -0700)]
dwflpp: cache CU entry PCs for pr15123_retry_addr
Previously it was calling getscopes(pc) to see if we're at the start of
the outermost function, which may be a preamble for -mfentry. But the
scopes are inside-out -- [0] is the innermost -- so inlines were
comparing against their own entry pc, then inappropriately applying the
mfentry workaround. It also assumes we're already focussed on the CU,
which may not be the case for .callee probes that expand across CUs.
And besides all that, dwarf_getscopes is an expensive traversal.
Instead, we can just keep a cached set of known entry PCs, built from
our existing cache of concrete functions, and check if possible mfentry
PCs are in that set.
Ravi Bangoria [Tue, 23 Aug 2016 11:24:28 +0000 (06:24 -0500)]
ppc64le: Fix LEP usage for probing
PPC64 ELF ABI v2 has a Global Entry Point and a Local Entry Point for
the functions. Debuginfo of ELF contains GEP which is same as entrypc
while symbol table contains GEP and offset, from which we can calculate
LEP. LEP is used to call function within single CU, when TOC pointer
update is not required. Placing a probe on LEP catches call from both
the GEP and the LEP but, by default, systemtap probes on GEP.
Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le") solve
this issue by storing LEP in symbol table and prioritizing symbol table
over debuginfo for ppc64le.
But there are few regression effect of this patch. Couple of examples
are given below.
1. If target program is compiled without optimization and user is
interested in function parameter, systemtap should probe after function
prologue. But above patch forces probe on LEP and which result in garbage
value of function parameter will get recorded.
$ make verbose=1 installcheck RUNTESTFLAGS='at_var.exp -v --debug'
...
# of expected passes 1
# of unexpected failures 1
2. Probe on shared library function with parameter is failing at Pass 2.
$ make verbose=1 installcheck RUNTESTFLAGS='exelib.exp -v --debug'
...
# of expected passes 10
# of unexpected failures 64
3. When symbol_name with offset is used to register kprobe, kernel itself
will find LEP and adds offset to it. Systemtap using LEP to find offset
is resulting in offset being added two times.
GEP + lep_offset (by systemtap) + lep_offset (by kernel)
This can be solved by calculating LEP only at a time of adding a probe.
That will make effect of LEP local to that area and won't have any
regression effect.
After applying patch:
$ make verbose=1 installcheck RUNTESTFLAGS='at_var.exp -v --debug'
...
# of expected passes 2
$ make verbose=1 installcheck RUNTESTFLAGS='exelib.exp -v --debug'
...
# of expected passes 74
Fixes: Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le") Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
[ Reported about issue with shared library ] Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Ravi Bangoria [Tue, 23 Aug 2016 11:24:27 +0000 (06:24 -0500)]
ppc64le: Store correct function entry address in symbol_table
PPC64 ELF ABI v2 has a Global Entry Point and a Local Entry Point for
the functions. Debuginfo of ELF contains GEP which is same as entrypc
while symbol table contains GEP and offset, from which we can calculate
LEP. LEP is used to call function within single CU, when TOC pointer
update is not required. Placing a probe on LEP catches call from both
the GEP and the LEP but, by default, systemtap probes on GEP.
For ppc64le, Systemtap stores LEP in symbol table and prioritize symbol
table over debuginfo. But, storing LEP in symbol table has couple of
regression effect. As LEP is only required at a time of adding a probe,
don't store it in symbol table.
No need to prioritize symbol table as well because debuginfo and symbol
table both will contain Global Entry Point.
Revert commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le")
partially.
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Felix Lu [Tue, 23 Aug 2016 13:49:57 +0000 (09:49 -0400)]
modify interactive mode load behavior
The "load" command no longer appends to the existing script. The user
is prompted if they want to overwrite the existing file if the script is
not empty.
David Smith [Thu, 18 Aug 2016 20:30:28 +0000 (15:30 -0500)]
Fix a '--rlimit-*' option problem identified by BZ1368188.
* session.cxx (systemtap_session::parse_cmdline): Improve the '--rlimit-*'
options to report an error and return if the option value isn't
specified or doesn't convert properly. If the limit can't be set,
return if the error isn't EPERM.
* man/stap.1.in: Remove confusing language in the '--rlimit-*' option
descriptions.
* testsuite/parseko/rlimit-as01.stp: New test case.
* testsuite/parseko/rlimit-as02.stp: Ditto.
* testsuite/parseko/rlimit-cpu01.stp: Ditto.
* testsuite/parseko/rlimit-cpu02.stp: Ditto.
* testsuite/parseko/rlimit-fsize01.stp: Ditto.
* testsuite/parseko/rlimit-fsize02.stp: Ditto.
* testsuite/parseko/rlimit-nproc01.stp: Ditto.
* testsuite/parseko/rlimit-nproc02.stp: Ditto.
* testsuite/parseko/rlimit-stack01.stp: Ditto.
* testsuite/parseko/rlimit-stack02.stp: Ditto.
David Smith [Thu, 18 Aug 2016 15:37:12 +0000 (10:37 -0500)]
Update procmod_watcher.stp example for more modern kernels.
* testsuite/systemtap.examples/process/procmod_watcher.stp: Update example
to report 'clone' syscalls as 'fork' syscalls (since on some
architectures like aarch64 fork() is implemented using clone()). Also
report 'exit_group' syscalls as 'exit' syscalls.
David Smith [Wed, 17 Aug 2016 17:59:07 +0000 (12:59 -0500)]
Make [nd_]syscall.sched_[gs]etaffinity probes fully optional.
* tapset/linux/syscalls2.stp (syscall.sched_getaffinity): Make fully
optional for kernels with no 'affinity' support.
(syscall.sched_setaffinity): Ditto.
* tapset/linux/nd_syscalls2.stp (nd_syscall.sched_getaffinity): Ditto.
(nd_syscall.sched_setaffinity): Ditto.
Cody Santing [Fri, 12 Aug 2016 19:03:13 +0000 (15:03 -0400)]
PR15932: printf %m/%M user variant
* man/stap.1.in: update documentation regarding %m/%M
* runtime/vsprintf.c: m/M cases in _stp_vsprint_memory now check for '#'/STP_SPECIAL flag
* testsuite/systemtap.printf/print_user_buffer.*: test case for new variant
Felix Lu [Fri, 12 Aug 2016 14:44:58 +0000 (10:44 -0400)]
some auto_path test case
* main.cxx: Check for PATH directory in all include paths.
* testsuite/systemtap.base/auto_path.exp: New testcase.
* testsuite/systemtap.base/auto_path.c: Test program.
* testsuite/systemtap.base/tapset/PATH/*: Auto path tapsets.
Martin Cermak [Fri, 12 Aug 2016 05:21:03 +0000 (07:21 +0200)]
Fix testsuite's list-unfinished makefile target
Do not only check systemtap.log in the main testsuite directory,
but also check other locations, namely the artifacts directory
used by the installcheck-parallel target.
Cody Santing [Thu, 11 Aug 2016 19:29:29 +0000 (15:29 -0400)]
Update interactive mode
* cmdline.cxx: introduce new '--interactive' switch
* cmdline.h: introduce new '--interactive' switch
* interactive.cxx: Print a few sample commands upon entering interactive mode. Add new 'help' alias, '?'.
* session.cxx: Map new '--ineractive' switch to interactive mode. When a script is not specified, new error message suggests interactive mode.
David Smith [Thu, 11 Aug 2016 16:31:28 +0000 (11:31 -0500)]
Fix(ish) for PR20433 by avoiding a fedora kernel crash.
* runtime/vma.c (_stp_vma_mmap_cb): Use _stp_strcmp() to avoid a kernel
crash.
* runtime/stp_string.c (_stp_strcmp): New function, a variant of strcmp()
that treats NULL pointers as empty strings.
* runtime/stp_string.h: Add _stp_strcmp() declaration.
Felix Lu [Tue, 9 Aug 2016 19:36:14 +0000 (15:36 -0400)]
filename based auto path tapset support
Sometimes the process name may change with new versions and the
tapset must be modified. Process probe points in the PATH directory
may now have their arguments replaced by the full file path starting
from /PATH.
* parse.cxx: Pass alias_seen flag to parse_probe_points(). Add filepath
argument to process component.
Felix Lu [Mon, 8 Aug 2016 18:48:37 +0000 (14:48 -0400)]
some function overloading optimizations
This removes some unnecessary code in the generated module.
* elaborate.cxx: Store next flag in functiondecl instead of in a set.
* staptree.h: struct functiondecl:: new has_next flag.
* translate.cxx: c_unparser::visit_functioncall - Don't generate
redundant functioncall code for overloaded functions.
David Smith [Thu, 4 Aug 2016 20:39:19 +0000 (15:39 -0500)]
Fix a couple of conversions.stp tapset problems and improve its testing.
* tapset/linux/conversions.stp (kernel_buffer_quoted): Properly print the
address as an unsigned long (instead of an unsigned int).
(kernel_buffer_quoted_error): Add the faulting address in the error
message.
* testsuite/buildok/conversions-embedded.stp: Add compile tests for
several missing functions.
Felix Lu [Thu, 28 Jul 2016 14:39:58 +0000 (10:39 -0400)]
PR10485: auto-path tapset support
This prefixes the process probes placed in the tapset/PATH/ directory
with the location of the tapset.
* main.cxx: New collect_{stp,stpm} functions for passing to nftw(). Parse all
.stp files placed in include_path[0]/PATH/. nftw() is now used instead of
globbing for tapset searching to allow recursive traversal.
* parse.h: New pf_auto_path flag.
* parse.cxx: Prefix process argument with location of tapset.
PR20423: improve 'struct {...} being accessed instead of member' message
Esp. for anonymous structures, this message was not very helpful.
The new message is much more complete:
semantic error: 'struct {...}' (include/linux/types.h:175) is being accessed instead of a member such as '->counter': operator '->' at <input>:1:81
source: probe kernel.function("dput") { println( @cast($dentry->d_inode, "struct inode")->i_count) }
^
Igor Zhbanov [Fri, 29 Jul 2016 17:51:21 +0000 (13:51 -0400)]
systemtap.spec: add systemd as BuildRequires & Requires if %{with_systemd}
It should have both "Requires: systemd" and "BuildRequires: systemd".
BuildRequires because it uses %{_unitdir} and %{_tmpfilesdir}, and
Requires because of systemctl in %post.
The dwarf_var_expanding_visitor::visit_entry_op function inherited
some old logic from expanding $var's in .function().return probes.
This logic is not approproate for the more formal way by which current
code synthesizes a .call probe to collect @entry(EXPR) values. Now we
pass the EXPR tree to the .call probe unmodified, for resolution
there, rather than in a fake non-.return context here. This makes
@entry(@perf("...")) expressions work.
David Smith [Tue, 26 Jul 2016 17:57:59 +0000 (12:57 -0500)]
Fix a locking problem in the task_finder.
* runtime/linux/task_finder.c (stap_start_task_finder): Be sure to ulock
the task if we exit early.
* runtime/linux/task_finder2.c (stap_start_task_finder): Ditto.
David Smith [Mon, 25 Jul 2016 15:24:27 +0000 (10:24 -0500)]
Improve session state and transport state handling.
* translate.cxx (emit_module_init): At the start, only set the session
state to STAP_SESSION_STARTING if we were in the
STAP_SESSION_UNINITIALIZED state. Once the session is initialized, set
the state to STAP_SESSION_RUNNING (if we're still in the
STAP_SESSION_STARTING state).
* runtime/common_session_state.h: Add new 'STAP_SESSION_UNITIALIZED' state.
* runtime/dyninst/common_session_state.h (stp_session_init): Set initial
session state to STAP_SESSION_UNITIALIZED.
* runtime/linux/common_session_state.h: Ditto.
* runtime/dyninst/linux_defs.h (atomic_cmpxchg): New function.
* runtime/transport/transport.c: Merge '_stp_start_called' and
'_stp_exit_called' flags into a single flag called
'_stp_transport_state'.
Martin Cermak [Thu, 21 Jul 2016 16:17:16 +0000 (18:17 +0200)]
Don't use as_root() to run stap within tapset_functions.exp
Most of the other as_root() in the testsuite is for stuff that
genuinely has to be root, like loading some test kernel module
that we'll probe. For running the testsuite under a regular
user, stap{user,sys,dev} group membership mechanism should be
used instead.
David Smith [Fri, 15 Jul 2016 16:14:21 +0000 (11:14 -0500)]
Fix handling of internal transport flags.
* runtime/transport/transport.c: Remove unused '_stp_transport_mutex'
mutex. Commit 440c8ee removed the mutex protection of the
'_stp_start_called' and '_stp_exit_called' flags, so those flags have
been converted to be atomics so that concurrent use of those flags see
the correct values.
David Smith [Fri, 15 Jul 2016 16:00:33 +0000 (11:00 -0500)]
Make sure the unprivileged_myproc.exp testcase kills its processes.
* testsuite/systemtap.unprivileged/unprivileged_myproc.exp: Use library
'kill' proc to make sure the test executables die.
* testsuite/lib/systemtap.exp (kill): Add 'AS_ROOT' argument, to kill the
pid as root.
Josh Stone [Sat, 9 Jul 2016 01:21:49 +0000 (18:21 -0700)]
Tweak autocast-defined interactions further
- collapse basic @defined($foo) right away.
- last-ditch collapse other @defined(expr) to 1 or 0 depending on pe_unknown.
- run that last-ditch effort *before* turning on assert_resolvability.
- only run extra dead_control_remover for optimized runs
- in var_expanding_visitor, pass *any* unchanged expr through, so they
may be decided later. (e.g. for @choose_defined ternaries)
Frank Ch. Eigler [Wed, 22 Jun 2016 15:43:33 +0000 (11:43 -0400)]
PR18079: support nested autocast / @defined
We now perform const-folding & dead-code-elision during the type
resolution loop, whenever an autocast expression gets evaluated. This
way, @defined(foo()->mm) type expressions can work as nature intended.
This requires @defined() not to be short-circuit evaluated to 0 during
a random const_folding process, so a flag is introduced to control its
preservation or collapsing. For the last (assert_resolvability) pass
in the type resolution loop, this flag is set to true, so that
genuinely unresolvable @defined($expressions) do get mapped to 0 in
time for a last elision.
Martin Cermak [Thu, 21 Jul 2016 16:17:16 +0000 (18:17 +0200)]
Don't use as_root() to run stap within tapset_functions.exp
Most of the other as_root() in the testsuite is for stuff that
genuinely has to be root, like loading some test kernel module
that we'll probe. For running the testsuite under a regular
user, stap{user,sys,dev} group membership mechanism should be
used instead.
David Smith [Fri, 15 Jul 2016 16:14:21 +0000 (11:14 -0500)]
Fix handling of internal transport flags.
* runtime/transport/transport.c: Remove unused '_stp_transport_mutex'
mutex. Commit 440c8ee removed the mutex protection of the
'_stp_start_called' and '_stp_exit_called' flags, so those flags have
been converted to be atomics so that concurrent use of those flags see
the correct values.
David Smith [Fri, 15 Jul 2016 16:00:33 +0000 (11:00 -0500)]
Make sure the unprivileged_myproc.exp testcase kills its processes.
* testsuite/systemtap.unprivileged/unprivileged_myproc.exp: Use library
'kill' proc to make sure the test executables die.
* testsuite/lib/systemtap.exp (kill): Add 'AS_ROOT' argument, to kill the
pid as root.
PR19489: Update send syscalls to use buffer_quoted
tapset/linux/nd_syscalls2.stp: send and sendto use new user_buffer_quoted function
tapset/linnux/syscalls2.stp: send and sendto use new user_buffer_quoted function
testsuite/systemtap.syscall/send.c: Update expected output of testcases
testsuite/systemtap.syscall/sendto.c:Update expected output of test cases
Josh Stone [Sat, 9 Jul 2016 01:21:49 +0000 (18:21 -0700)]
Tweak autocast-defined interactions further
- collapse basic @defined($foo) right away.
- last-ditch collapse other @defined(expr) to 1 or 0 depending on pe_unknown.
- run that last-ditch effort *before* turning on assert_resolvability.
- only run extra dead_control_remover for optimized runs
- in var_expanding_visitor, pass *any* unchanged expr through, so they
may be decided later. (e.g. for @choose_defined ternaries)
PR19489: Update probe aliases to use new *buffer_quoted functions
tapset/linux/nd_syscalls.stp: add_key uses new function
tapset/linux/nd_syscalls2.stp: pwrite, pwrite32, and write use new function
tapset/linux/syscalls.stp: add_key uses new function
tapset/linux/syscalls2.stp: pwrite and pwrite32 use new function
tapset/linux/tty.stp: write and read use new function
tapset/uconversions.stp: Update typo in documentation comments
Fix cputime_to_msecs() macro for broken android 3.0 kernels.
* tapset/linux/task_time.stp (cputime_to_msecs): Fix macro definition for
certain android kernels that have an extra semicolon on the
cputime_to_usecs() macro.
Felix Lu [Thu, 30 Jun 2016 18:54:18 +0000 (14:54 -0400)]
PR19953: netfilter packet content dumping
* tapset/linux/conversions.stp: New overloaded instance of
kernel_buffer_quoted using MAXSTRINGLEN by default.
Mark kernel_buffer* with /* pure */.
* tapset/linux/netfilter.stp: New data_str and data_hex variables
containing buffer contents.
* translate.cxx: Increase memory dump limit to PAGE_SIZE for memory
dumping sk_buff page fragments in c_unparser::visit_print.
* systemtap.examples/network/packet_contents.stp: Example script.
* systemtap.examples/network/packet_contents.txt: Example demo.
PR19489: Update user/kernel_buffer_quoted_warn tapset functions to _error
/NEWS: Include information on new functions
/tapset/linux/aux_syscalls.stp: Uses new buffer mode of _stp_text_str
/tapset/linux/conversions.stp: Update kernel_buffer_quoted_warn to _error
/tapset/uconversions.stp: Updated user_buffer_quoted_warn to _error
runtime/stp_string.c: Update _stp_text_str to handle '\0' and take a buffer flag
runtime/stp_string.h: Update _stp_text_str prototype
tapset/linux/aux_syscalls.stp: Update calls to _stp_text_str
tapset/linux/conversions.stp: Add user_buffer_quoted and _warn tapset functions
tapset/linux/syscalls2.stp: Update syscall.write to use user_buffer_quoted
tapset/string.stp: Update calls to _stp_text_str
tapset/uconversions.stp: Add kernel_buffer_quoted and _warn tapset functions
Frank Ch. Eigler [Thu, 30 Jun 2016 16:08:07 +0000 (12:08 -0400)]
PR20307: fix references to private global in tapset
Previous code could not resolve a reference to a private global
(defined in a tapset) within a probe alias (from that same tapset).
We now try matching up the mangled name in addition to the plain one
in symresolution_info::find_var() when searching the
session.library_files[].globals.
David Smith [Tue, 28 Jun 2016 15:12:25 +0000 (10:12 -0500)]
Partial 20236 fix: Add user_TYPE_error functions that throw errors.
* tapset/uconversions.stp: Add new functions 'user_TYPE_error()' (where
TYPE is 'char', 'short', 'ushort', 'int', 'long', 'ulong', 'int8',
'uint8', 'int16', 'uint16', 'int32', 'uint32', or 'int64'). These
funtions thow an error if the value to be read isn't
accessible. Reimplement 'user_TYPE()' and 'user_TYPE_warn()' functions
in terms of user_TYPE_error() functions.
* tapset/linux/aux_syscalls.stp: Replace '__user_pointer' with
'user_long_error'.
* testsuite/buildok/conversions-embedded.stp: Add tests for new functions.
Martin Cermak [Tue, 28 Jun 2016 14:25:33 +0000 (16:25 +0200)]
Don't error on missing systemtap.sum
Don't report error if systemtap.sum isn't available to tail.
This was producing optically disturbing error message e.g. in case
the testsuite got run without dejagnu installed.
Martin Cermak [Tue, 28 Jun 2016 12:21:04 +0000 (14:21 +0200)]
Implement PR12748 by providing the syscall_table tapset files.
This patch provides architecture specific syscall tables, tapset
script functions syscall_num() and syscall_name() for acessing
them, test coverage, and a script for re-generating the syscall
tables based on strace source code.
* scripts/dump-syscalls.sh: Helper script for re-generating the
syscall tables based on strace source code.
* tapset/linux/syscall_table.stp: Tapset script providing
functions syscall_num() and syscall_name().
* tapset/linux/arm/syscall_num.stp: Syscall table.
* tapset/linux/arm64/syscall_num.stp: Ditto.
* tapset/linux/i386/syscall_num.stp: Ditto.
* tapset/linux/powerpc/syscall_num.stp: Ditto.
* tapset/linux/s390/syscall_num.stp: Ditto.
* tapset/linux/x86_64/syscall_num.stp: Ditto.
* testsuite/systemtap.syscall/sys.stp: A testsuite bit.
* testsuite/systemtap.syscall/syscall.exp: Ditto.
* testsuite/systemtap.syscall/tapset/syscall.stp: Ditto.
David Smith [Mon, 27 Jun 2016 17:57:05 +0000 (12:57 -0500)]
Fix PR20298 by updating the unprivileged_embedded_C.exp test case.
* testsuite/systemtap.unprivileged/unprivileged_embedded_C.exp: Several
changes. Now only tests embedded C functions (since we can't really know
if pure script functions are privileged or not). Look for tapset files
in tapset/linux and in tapset/linux/${ARCH}. Now test all the embedded C
functions intead of a subset. Add a "transitive" test, to make sure
privileged embedded C functions can't be called by script functions.
Nikolay Borisov [Mon, 27 Jun 2016 16:46:35 +0000 (19:46 +0300)]
Add the '-p4' options when exemplifying the module compilation
Currently the example command which supposedly should compile the
instrumentation module is missing the '-p4' option, meaning that
upon running it will compile and run the module. In order to make
the command more in sync with what this particular chapter is about,
add the -p4 options so that after running the command the user gets
to copy the resulting module.
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Frank Ch. Eigler [Wed, 22 Jun 2016 15:43:33 +0000 (11:43 -0400)]
PR18079: support nested autocast / @defined
We now perform const-folding & dead-code-elision during the type
resolution loop, whenever an autocast expression gets evaluated. This
way, @defined(foo()->mm) type expressions can work as nature intended.
This requires @defined() not to be short-circuit evaluated to 0 during
a random const_folding process, so a flag is introduced to control its
preservation or collapsing. For the last (assert_resolvability) pass
in the type resolution loop, this flag is set to true, so that
genuinely unresolvable @defined($expressions) do get mapped to 0 in
time for a last elision.