William Cohen [Fri, 12 Oct 2018 19:02:03 +0000 (15:02 -0400)]
Add fallback __NR_fork define
The aarch64 architecture doesn't have a fork syscall, so the code
needs to have a fallback __NR_fork define for the code to be
successfully compiled on aarch64.
Frank Ch. Eigler [Fri, 12 Oct 2018 18:33:04 +0000 (14:33 -0400)]
RHBZ1638874 workaround: let $SYSTEMTAP_SIGN override missing secureboot hint
On some Fedora kernels, EFI SecureBoot involves activating a lockdown
mode that prevents unsigned .ko's from loading. It doesn't appear to
give any userlevel sign that this is happening, so stap couldn't
activate its secureboot / stap-server machinery.
Until the kernel does inform us properly, we let users set an
environment variable to force UEFI MOK module signing.
William Cohen [Thu, 11 Oct 2018 18:05:46 +0000 (14:05 -0400)]
Adjust eatkmydata.stp to work with the newer Linux kernels and tapsets
The revised tapsets generally do not use the dwarf-based kprobes and
kretprobes for syscalls on newer 4.17 Linux kernels. As a result
target variables are not available and guru mode will not work with
them. The eatmydata.stp example has been modified to instrument the
common do_fsync function that both syscall.fsync and syscall.fdatasync
call. The target variable and guru mode will work on this function.
William Cohen [Thu, 11 Oct 2018 17:41:20 +0000 (13:41 -0400)]
Adjust iotime.stp to work with newer Linux kernels and sysetmtap tapset
Newer systems may use the openat syscall instead of the open syscall,
so need to monitor openat syscall. The probe points used by systemtap
for the syscalls do not have the target variable available via
@entry(), so need to code up iotime.stp to explicitly store values
available on syscall entry in associative arrays to have them
available for the syscall return probes.
William Cohen [Wed, 10 Oct 2018 18:08:19 +0000 (14:08 -0400)]
Avoid using target variable and @entry() in syscall.*.return for futex examples
The update to the syscall tapsets causes SystemTap to use non-dwarf
based probe points for syscalls on linux-4.17 and newer. The
non-dwarf based syscall instrumentation does not have the target
variables available, so the @entry() operation is not going to work.
The futex examples are revised to store the needed data into
associative arrays at syscall entry and accessed that data in the
syscall return.
rhbz1629623: adapt to CONFIG_HAVE_ARCH_PREL32_RELOCATIONS tracepoint enumeration
Kernel commit 46e0c9be206fa7b (4.19-rc1) makes the mod->tracepoints_ptrs[]
contain pointer-relative-offsets instead of normal pointers.
We must follow suit to avoid a crash.
William Cohen [Thu, 27 Sep 2018 14:48:14 +0000 (10:48 -0400)]
Change the tapset file name to get matching tapset::syscall_any manpage
The automated generation of man pages uses the file name to generate
the manpage names. Adjusted the name to get a matching tapset man
page for syscall_any{.return} probe points.
William Cohen [Fri, 21 Sep 2018 02:50:16 +0000 (22:50 -0400)]
Convert the various systemtap examples to use the syscall any tapset
To make the examples cleaner use the new syscall any tapset. This avoids
exposing the systemtap internal function _stp_syscall_nr() and makes the
instrumentation look a bit more like the traditional syscall.* probe points.
William Cohen [Fri, 21 Sep 2018 00:33:17 +0000 (20:33 -0400)]
Add the syscall_any and syscall_any.return probe points
The syscall.*{.return} and np_syscall.*.{.return} end up expanding to
large amount of code that takes a signficant amount of time to
compile. The resulting kernel module also takes a fair amount of time
to install and remove the instrumentation when it starts and shuts
down. For instrumentation don't really care about the details of the
syscall arguments it would be preferable to use the sys_enter and sys_exit
tracepoints to more efficiently probe the one or two places.
Using tp_syscall.*{.return} end up generating a lot of code to
determine which of the hundreds of syscall is being used and then runs
the same handler. The syscall_any and syscall_any.return eliminate
that undesired overhead by just looking up the syscall name in a
table.
William Cohen [Mon, 17 Sep 2018 20:58:09 +0000 (16:58 -0400)]
Use sys_enter and sys_exit tracepoints in place of syscall.*{.return}
The common probe point idiom of syscall.* and syscall.*.return can be
replaced with equivalent sys_enter and sys_exit tracepoints for a
number of the example scripts. The advantages are:
-Quicker compilation of the script into instrumenation
-Smaller kernels modules for the instrumentation
-Lower overhead for probe points
This changes are not applicable to all uses use syscall.* and
syscall.*.return. The predefined variable such as argstr are not
available for the sys_enter and sys_exit trace points.
Some of the revised examples are using the internal _stp_syscall_nr())
function. A user visible version of this function should be
available.
PR23666 Fix a bug in semantic analysis of aggregate operators in foreach sorting
When aggregate operators like @count, @sum, and etc were used in the
foreach loop sorting criteria but not in the foreach loop body, then
these sorting criteria were not respected by the translator in the
generated code.
This bug affected both the kernel and dyninst runtime modes.
William Cohen [Fri, 14 Sep 2018 18:13:08 +0000 (14:13 -0400)]
Ignore the error value returned by the find command for the slowvfs.stp
Some files in /proc are unreadable by normal users. When the find
command encounters these files find returns a non-zero value on exit.
The test is just using the find to create some load and really wants
to discard the error result otherwise the install test for slowvfs.stp
will fail.
PR23160,PR14690: convert syscall.*.return aliases to @SYSC_SETRETVAL retval/retstr
Adjust all syscall.*.return aliases to a new macro for provision of new
retval, old retstr, and the temporary returnval() compatibility hack.
All hail /bin/sed, mother of /bin/ed, which made this operation bearable.
PR23160,PR14690: prep returnval() for an extra side-channel of data
To permit tracepoint-based syscall probe-aliases to provide return values
to scripts, returnval() needs an extension. This patch adds a pair of
new values to the context, conditional on version <= 4.0. (The retval
value will be the next better approach, coming in a followup patch.)
testsuite: prepare for working tp_syscall.exp suite
There were some typos in the driver .stp script that precluded
operation, and exposed a latent bug in how another .exp file
transcribed outputs into the log file.
Revert "tapset/errno.stp: learn about CONTEXT->sregs"
This reverts commit 8038562cafe852681eda1a45c02b5f76070d3dec.
jafeer and wcohen right note that this papered over the real
problem, which is that a function like returnval() has no way
of accessing tracepoint parameters like sys_exit's $ret,
even if given CONTEXT->sregs. Need to rethink.
William Cohen [Mon, 10 Sep 2018 14:39:17 +0000 (10:39 -0400)]
Use @entry() in return probes to avoid warnings
Some of the examples accessed target variable in function return probes.
This type of access is ambigious and triggers a warning. The accesses
now use @entry($target_var) to be clearer and avoid the warnings.
tracepoints: support cachefiles/fscache tracepoints
These were blocked by the typical problem of the tracepoint headers
neglecting to include the other headers that declare the types that tp
arguments use. Also noted, missing mei: tracepoints found to be not
so easy, so left it in just a comment.
David Smith [Fri, 7 Sep 2018 18:46:59 +0000 (13:46 -0500)]
Improve handling by the http server for target exe files.
* httpd/api.cxx (build_info::module_build): Use a full path with the '-r
KERNEL_DIR' stap option. If the client transferred over target
executable files, add a sysroot option that points to them.
* testsuite/systemtap.http_server/http_server.exp: Add a test that tests
non-rpm executables with an absolute path.
PR23608: rebalance arc_priorities to avoid overflow.
Within a state kernel, e.g. {0/256, 1/256} could be changed to {0/2, 1/2}
without trouble.
Otherwise, long chains like "aaaaaaaaaaaaa" can overflow the
arc_priority numerator after about 60 characters.
Steps for rebalancing procedure:
- sort the worklist by arc_priority
- create an equivalent balanced set of priorities starting by 0/0
- replace the worklist's arc_priorities in sorted order
* stapregex-dfa.h (MAKE_START_PRIORITY): new macro for priority 0/0.
* stapregex-dfa.cxx (add_kernel): use MAKE_START_PRIORITY.
(sort_priorities, sort_denominator, sort_kernel_points): new comparators.
(rebalance_priorities): new function.
(te_closure): use rebalance_priorities() on the worklist before working on it.
Stan Cox [Fri, 7 Sep 2018 03:45:33 +0000 (23:45 -0400)]
Use offset to beginning of .probes section for sdt semaphores with stapdyn.
* tapsets.cxx (sdt_query::handle_query_module): stapdyn calls
Dyninst::SymtabAPI::Symtab::fileToMemOffset for semaphores, which wants
the fileOffset parameter to be relative to the containing section.
William Cohen [Fri, 7 Sep 2018 02:59:03 +0000 (22:59 -0400)]
Avoid name collision with the existing installed python tapset files
Systemtap cannot find the files in the custom tapset if they have the
same name as the official installed tapset files. Adjusted the names
of the local python tapset files to allow systemtap to find the files
and use the contents for py2example.stp and py3example tests.
In case the syscalls.* aliases fall back to the tp_* variant, allow
the returnval() and returnstr() functions in errno.stp to also look
at the CONTEXT->sregs pt_regs. (NB: the returnstr() function
is distinct from the return_str variable set by probe aliases).
William Cohen [Wed, 5 Sep 2018 18:23:51 +0000 (14:23 -0400)]
Add _NR_* defines for syscalls that older kernels do not have
Older RHEL7 kernels do not implement syscalls for mlock2 et. al. and
there are no matching __NR_* defines for those missing syscalls.
Adding default defines so systemtap tapsets will work on these older
kernels.
Moved contents of aux2_syscall.stp to aux_syscall.stp. Since the
contents of aux2_syscall.stp are going to be used by all syscalls,
doing this will cause aux_syscall.stp to always be included and so
will the header files containing the macros that are #included in
aux_syscall.stp.
Add new Tcl/DejaGnu test module test_simple to simplify tests
Ported the handy routines is(), isnt(), like(), unlike(), ok(), nok()
from Perl's Test::Simple module over to Tcl/DejaGnu as the test_simple
module. Also added the run_cmd_2way command to this module to run
an arbitrary shell command and to fetch the stderr, stdout, and exit
code from it.
Make use of these new test helpers in the return_no_val.exp and
ternary_op.exp test files to demonstrate its usage. It makes these test
files much simpler by avoiding a lot of boilerplate Tcl code.
The remaining test files I committed recently would get updated in
separate patches just to prevent this patch from getting too large.
For user-defined stap functions which do not return any values, it can
be convenient to allow *bare* return statements to take shortcuts in
the control flow of the function body.
The parser treats a following semicolon (';') or a closing curly bracket
('}') as a terminator for such bare return statements.
Added tests to cover various cases like use of plain 'return' in a
function actually returning some values. Also added tests to make sure
the pretty-printer adds a trailing semicolon for such bare return
stateuments for various arrangements. Both the "kernel" and "dyninst"
runtimes are covered.
The new built-in tapset function abort() is similar to exit(), but it
aborts the current probe handler (and any function calls in it) immediately.
It works with both the kernel and dyninst runtimes. The bpf runtime is not
yet supported.
Unlike error(), abort() cannot be caught by try {...} catch {...}.
Similar to exit(), abort() yeilds the zero process exit code.
fche thinks it is already too late to change the current behavior of
exit(), hence this new function. And he suggests the function name abort().
Also added corresponding tests for both abort() and exit(), including
tests for probe timer.profile + abort(), as suggested by fche. The tests
cover both the kernel and dyninst runtimes wherever possible.
This new function can be disabled by the '--compatible 3.3' option. Also
added tests for this.
William Cohen [Fri, 31 Aug 2018 14:09:31 +0000 (10:09 -0400)]
Use returnval() rather than $return for various syscall tapset probes
With newer linux 4.17 kernel some of the syscall tapset return probes
do not have $return available. The example scripts have been changed
to use returnval() function instead of the missing $return.
William Cohen [Thu, 30 Aug 2018 21:17:16 +0000 (17:17 -0400)]
Use a more stable function name for running the linetimes.stp tests
There have a been a number of changes in the Linux 4.17 kernel syscall
function names and a function named sys_nanosleep no longer exists in
the newer kernels. Adjusting the tests to use similar function that
is less likely to be affected from the syscall name changes.
William Cohen [Thu, 30 Aug 2018 21:05:58 +0000 (17:05 -0400)]
Have whythefail.stp probe a function that's name has not changed
The Linux 4.17 kernel has made a number of changes in the syscall
function names. These changes caused the whythefail.stp test to fail.
Rather than probing the sys_open function which no longer exists in
the 4.17 kernels the tests are now using the do_sys_open function
which remains the same.