David Smith [Fri, 2 Dec 2016 16:45:45 +0000 (10:45 -0600)]
Improve python probe listing.
* python/stap-resolve-module-function.py (_find_wildcarded_modules): Just
ignore C builtin modules and C extensions instead of raising errors.
(resolve_patterns): Don't clear the returned list of matches between
wildcards.
David Smith [Thu, 1 Dec 2016 18:55:25 +0000 (12:55 -0600)]
Fix listing python probes.
* tapset-python.cxx (python_builder::build): Fix listing python probes by
marking the new location as well formed and using it in all the correct
places.
David Smith [Wed, 30 Nov 2016 16:53:38 +0000 (10:53 -0600)]
Add support for python target variable numeric array indexing.
* tapset-python.cxx (python_var_expanding_visitor::visit_target_symbol):
Add support for numeric array indexing.
* tapset/python2.stp (Py2Dict_GetItem_FromLong): New function.
(Py2Object_Repr): Add variant of Py2Object_Repr() that takes a numeric
index.
(python2_get_variable): Add variant of python2_get_variable() that takes
a numeric index.
* tapset/python3.stp (Py3Dict_GetItem_FromLong): New function.
(Py3Object_Repr): Add variant of Py3Object_Repr() that takes a numeric
index.
(python3_get_variable): Add variant of python3_get_variable() that takes
a numeric index.
David Smith [Tue, 29 Nov 2016 21:29:09 +0000 (15:29 -0600)]
Add support for getting simple python target variables in probes.
* tapset-python.cxx (python_var_expanding_visitor::visit_target_symbol):
Add support for getting simple python target variables.
(python_builder::build): Add small compile fix for RHEL7 and update
comments.
* tapset/python2.stp (python2_get_variable): New function.
* tapset/python3.stp (Py3Dict_GetItem): Add support for python 3
dictionaries.
(Py3Dict_Repr): Ditto.
(Py3Object_Repr): Simplify and add support for dictionaries.
(python3_get_variable): New function.
* session.cxx (systemtap_session::version): Report python2 and python3
probe support.
* tapset/linux/syscalls.stpm (__pointer): On 32-bit platforms, return a
32-bit value.
Martin Cermak [Tue, 29 Nov 2016 13:33:05 +0000 (14:33 +0100)]
Fix PR20820 by making optim_stats.exp smaller.
Avoid "soft lockups" generated by optim_stats.exp by lowering
its cpu load down. Avoid division by zero caused by rounding
errors by numerical scaling. Introduce per-arch tresholds.
Move the testcase description from optim_stats1.stp to
optim_stats.exp.
Martin Cermak [Wed, 23 Nov 2016 18:45:10 +0000 (19:45 +0100)]
Fix the boot time probing feature for RHEL6 and Fedora19+ systems.
Before this fix, the boot time probing feature was proved working
on RHEL7. This patch adds a few little fixes making the feature
work on RHEL6 and Fedora19+ systems. Changes:
configure.ac: Make the dracut bin dir configurable at the configure
time. This is because of Fedora systems that have the dracut binary
located in /usr/bin rather than /sbin which is the typical location
for RHEL. Also mark initscript/99stap/{install,check} as AC config
files.
initscript/99stap/{install,check}.in: These files are bodies of the
install() and check() functions defined in module-setup.sh extracted
into standalone executable shell scripts. The older dracut shipped
with RHEL6 expects these bits right there.
initscript/99stap/start-staprun.sh: Don't create the pid file at this
stage. This script runs very early at the "cmdline" dracut hoo time.
At this time, RHEL7 systems offer writable /run directory, so that
the pid file can be stored there, but RHEL6 systems do not have a
writable place like that. Rhel6 only has /dev writable at that
stage, but misusing /dev for the pid file purposes wouldn't be clean.
So we use a mechanism based on /proc cescribed below instead.
initscript/systemtap.in: Don't move over any pid files from
/var/run/systemtap, because we stopped creating pid files at the
boot time per above. Instead we use stap -E to add a probe
advertising the running service in /proc/systemtap.
systemtap.spec: A few simple changes making the boot time probing
feature work on RHEL6 and Fedora19 systems.
David Smith [Mon, 21 Nov 2016 18:11:10 +0000 (12:11 -0600)]
Added support for python dictionaries to tapset/python2.stp.
* tapset/python2.stp (Py2Dict_GetItem): New function.
(Py2DictEntry_Repr): Ditto.
(Py2Dict_Repr): Ditto.
(Py2Object_Repr): Added dict support and simplified a bit.
Frank Ch. Eigler [Thu, 17 Nov 2016 16:52:33 +0000 (11:52 -0500)]
PR20821/PR14924: further gradual deprecation of .return { $var } use
* tapsets.cxx (var_expanding_visitor::visit_defined_op): Don't crash
if something weird is nested beneath @defined(...) that throws a
semantic error.
(visit_target_symbol_saved_return): Use save_and_restore<> object
instead of manual save/restore steps.
(dwarf_derived_probe ctor): Ditto.
(visit_entry_op): Ditto. Also, detect nestedness in @defined()
to trigger operand expansion attempt. This is tricky.
* main.cxx (passes_0_4): If -vvv, then pretty-print the script even
if erroneous, to see aftereffects of optimization, $var expansion
etc.
* staptree.cxx (vardecl::printsig): Some synthetic globals don't have
unmangled names, so print their normal name as a fallback.
* elaborate.cxx (visit_perf_op): note that @defined(@perf("junk"))
returns the literal 1. (Recently, it merely crashed the translator
in a .return probe.)
* testsuite/buildok/fortyfour.stp: New test case.
Martin Cermak [Fri, 18 Nov 2016 15:12:36 +0000 (16:12 +0100)]
Fix PR14924 by warning when not using @entry($var) in a return probe.
tapsets.cxx: Show warning when a $var gets used in a return probe
instead of @return($var). Allow the @defined(@entry()) construct.
tapset/linux/*: Use @entry() in return probes.
testsuite/systemtap.base/at_var.exp: Use -w to suppress the newly added
warning in tests that basically check that $var == @entry($var) in a
return probe.
Frank Ch. Eigler [Thu, 17 Nov 2016 11:12:59 +0000 (06:12 -0500)]
translator pass-3: close auxiliary_outputs[] after we're done with them
Otherwise we hang onto potentially dozens of unnecessary fds into
pass4. It is messy that a translator_output doesn't necessarily take
an fstream, and can write to a generic ostream, so we can only close
in the former case.
Cody Santing [Wed, 16 Nov 2016 18:40:16 +0000 (13:40 -0500)]
Update sample command to take multiple keywords
* NEWS: Added a small mention of the new sample command.
* interactive.cxx: Sample now accepts FTS full-text index query statements rather than just one keyword.
* testsuite/systemtap.examples/examples-index-gen.pl: Update to now use the new virtual table.
* testsuite/systemtap.examples/metadatabase.db: New virtual table created that uses FTS3.
David Smith [Fri, 11 Nov 2016 19:37:59 +0000 (13:37 -0600)]
Add support for getting python 2 and python 3 backtraces.
* tapset-python.cxx
(python_functioncall_expanding_visitor::visit_functioncall): New function.
(python_builder::build): Use the new
python_functioncall_expanding_visitor class to expand/replace python
backtrace requests in the probe body.
* tapset/python2.stp: New file.
* tapset/python3.stp: New file.
Cody Santing [Fri, 11 Nov 2016 16:47:49 +0000 (11:47 -0500)]
New example script socket-events.stp
* general/socket-events.meta: Associated meta file
* general/socket-events.stp: Tracks life cycle and syscall events of all sockets of a specified PID.
* index.html: Automatically updated using perl script to include information on new example.
* index.txt: Same
* keyword-index.html: Same
* keyword-index.txt: Same
* metadatabase.db: Same
David Smith [Thu, 10 Nov 2016 15:59:16 +0000 (09:59 -0600)]
Fix PR20735 by updating kprobes.c to avoid a soft lockup.
* runtime/linux/kprobes.c: Instead of grabbing the module mutex around
calling kallsyms_on_each_symbol(), just disable/enable preemption
instead to avoid a soft lockup.
Regressions in the testsuite indicated the first approach was not
sufficient. user_scripts include testsuite-supplied -E fragments,
which of course don't look at $*, and thus aren't appropriate for
end-of-file-parse judgement.
Switch instead to a session-stored used_args[] vector, and include a
special hack to account for tapset/argv.stp, which is the only
tapset-resident user of command line arguments. (An end-user script
that happens to require the argv.stp tapset should get credit for
using all $* parameters, even if it doesn't mention them literally.)
David Smith [Wed, 2 Nov 2016 18:41:04 +0000 (13:41 -0500)]
Get python 2 and python 3 probes hooked up to their handlers.
* tapset-python.cxx (build): Combine a good bit of the python2 vs. python3
logic. Add code to the synthetic probe to reject probe hits that aren't
for this actual probe. Link in the user's probe to the synthetic probe.
* python/HelperSDT/_HelperSDT.c (trace_callback): Pass the module name in
the marker.
(PyInit__HelperSDT): Fix the init function name for python 3.
* python/HelperSDT/__init__.py: Fix importing the C module for python
3. Save the module name and pass it to the C extension module.
* python/Makefile.am: Fix python 3 building.
* python/Makefile.in: Regenerated.
* configure.ac: Fix variable names.
* configure: Regenerated.
David Smith [Thu, 27 Oct 2016 18:11:14 +0000 (13:11 -0500)]
Export a value with every python breakpoint which gets returned.
* python/HelperSDT/__init__.py: Expect a 'key' value for every breakpoint and
return that value when a breakpoint is hit.
* python/HelperSDT/_HelperSDT.c (trace_callback): Expect an index value
and put that value in the marker.
* tapset-python.cxx (python_derived_probe_group::emit_module_decls):
Output an index value with each breakpoint.
David Smith [Tue, 25 Oct 2016 17:32:36 +0000 (12:32 -0500)]
Handle multiple python probes at the same location.
* python/HelperSDT/__init__.py (Dispatcher.pytrace_dispatch): Handle
multiple breakpoints at the same breakpoint location.
(Dispatcher.do_b): Make sure the line number field is numeric. Clear the
line number field if we've got a return break.
* tapset-python.cxx (python_builder::build): Add newlines to debug prints.
David Smith [Mon, 24 Oct 2016 20:59:00 +0000 (15:59 -0500)]
Read the list of python breakpoints from the systemtap module's procfs file.
* python/HelperSDT/__init__.py (Dispatcher.__init__): Read the list of
breakpoint commands from the procfs file exported by systemtap.
(do_b): New function
* staprun/staprun_funcs.c (insert_module): Export an environment variable
called 'SYSTEMTAP_MODULE' with the name of the inserted module.
* tapset-python.cxx (python_builder::resolve): Fix syntax.
David Smith [Fri, 21 Oct 2016 17:51:01 +0000 (12:51 -0500)]
Differentiate between python line number probes and function call probes.
* python/stap-resolve-module-function.py (resolve_patterns): Differentiate
between line number probes and function call probes.
* tapset-python.cxx (python_builder::resolve): Handle the 'call' flag
coming back from stap-resolve-module-function.py.
(python_builder::build): If needed, synthesize a new 'call' component.
David Smith [Fri, 21 Oct 2016 15:50:34 +0000 (10:50 -0500)]
Fix stap-resolve-module-function.py to handle relative paths with wildcards.
* python/stap-resolve-module-function.py (resolve_patterns): Fix searching
for wildcarded paths by appending the result of glob() onto the list
(instead of replacing the list with the result of glob()).
David Smith [Thu, 20 Oct 2016 18:44:56 +0000 (13:44 -0500)]
Fix stap-resolve-module-function.py to handle relative paths.
* python/stap-resolve-module-function.py (_get_default_search_path): New
function.
(_find_wildcarded_modules): Use _get_default_search_path() instead of
sys.path, which doesn't include the current working directory.
(_find_wildcarded_modules): Ditto.
David Smith [Wed, 19 Oct 2016 18:44:17 +0000 (13:44 -0500)]
Use the python executable names found by configure when running a script.
* tapset-python.cxx (python_builder::resolve): Use the python executable
names found by configure when running the stap-resolve-module-function.py
script.
mips: tapsets.cxx: add dwarf register definitions for SDT uprobes
Depending on the optimisations used, the compiler may generate either
numeric register definitions or typical aliases, so define both.
Since MIPS register names start with a dollar '$', add an escape
sequence to the register names when creating regname regular
expressions.
Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Martin Cermak [Wed, 5 Oct 2016 06:59:42 +0000 (08:59 +0200)]
Introduce runtime optimizations for statistical computations per PR10234.
This update improves the performance of systemtap runtime statistical
computations by optimizing out unneeded parts of the __stp_stat_add()
function. It is based on parametrizing and inlining it. The stap
translator now generates _stp_stat_add(), or _stp_pmap_add_*() calls
that have additional "optimization" parameters respective to stats
in use for given global. GCC uses this for optimizing the inlined
__stp_stat_add() calls.
The optimization effect significantly depends on compiler version,
platform architecture, and the stat operators being used for given
global. At the moment, the available stat operators are @count,
@sum, @min, @max, @avg, and @variance. The most computionally
expensive is @variance. The effect of optimizing @variance is
significant. Other stat operators are computionally chap and so
the effect of their optimizations is relatively low.
Using gcc-6.2.1-1.fc26.x86_64, the @count, @sum, @min, and @max
optimizations brings approximately 8% run time shrinkage. The
@variance optimization shrinkage is up to 70% using this compiler.
For other architectures, namely for power, the optimization is less
effective.
runtime/map-gen.c: Pass the additional optimization parameters through
the map API generator macros.
runtime/map.c: Modify _new_map_set_stat() to accept optimization
additional parameters.
runtime/map.h: Ditto.
runtime/pmap-gen.c: Pass the additional optimization parameters to
__stp_map_set*() and to _stp_pmap_add*().
runtime/stat-common.c: Add optimization params to __stp_stat_add().
runtime/stat.c: Add optimization params to _stp_stat_add().
tapsets.cxx: Generate parametrized calls to the runtime.
translate.cxx: Ditto.
testsuite/systemtap.base/optim_stats*: New testcase.
* Makefile.am: Updated using autoreconf in order to make DOCDIR available for interactive.cxx.
* Makefile.in: same
* doc/beginners/Makefile.in: same
* interactive.cxx: Added sample command, uses sqlite3.h.
* java/Makefile.in:: Updated using autoreconf in order to make DOCDIR available.
* testsuite/systemtap.examples/README: Added a small note about needing perl DBI to rerun perl script.
* testsuite/systemtap.examples/examples-index-gen.pl: As documentation files are generated, SQLite table is now populated with meta data.
* testsuite/systemtap.examples/index.html: Automatically updated documentation for new example after running perl script.
* testsuite/systemtap.examples/index.txt: same
* testsuite/systemtap.examples/keywords-index.html: same
* testsuite/systemtap.examples/keywords-index.txt: same
* testsuite/systemtap.examples/metadatabase.db: New database file that stores meta table.
David Smith [Mon, 19 Sep 2016 19:58:46 +0000 (14:58 -0500)]
Another PR20589 fix by updating user_buffer_quoted[_error]().
* tapset/uconversions.stp (user_buffer_quoted): Validate the
'outlen' parameter, ensuring it is between 0 and MAXSTRINGLEN.
(user_buffer_quoted_error): Ditto.
* tapset/linux/conversions.stp (kernel_buffer_quoted): Fix use of outlen.
* testsuite/buildok/conversions.stp: Move uconversion tests to
uconversions.stp and update list of functions tested.
* testsuite/buildok/uconversions.stp: New file.
David Smith [Thu, 15 Sep 2016 21:28:47 +0000 (16:28 -0500)]
Added autoconf logic to search for python version 2 and 3.
* configure.ac: Add code to search for python version 2 and 3. Change the
'--with-python3' option to check and make sure python version 3 is
installed on the system.
* dtrace.in: Updated method to select preferred version of python.
* Makefile.in: Regenerated.
* configure: Ditto
* doc/Makefile.in: Ditto
* doc/SystemTap_Tapset_Reference/Makefile.in: Ditto
* doc/beginners/Makefile.in: Ditto
* java/Makefile.in: Ditto
* man/Makefile.in: Ditto
* man/cs/Makefile.in: Ditto
* python/Makefile.in: Ditto
* stapdyn/Makefile.in: Ditto
* staprun/Makefile.in: Ditto
It was reported that one version of oracle db has unwind tables in
excess of 24MB in size, and the prior stap limit of 16MB precludes
backtracing through it.
David Smith [Tue, 13 Sep 2016 19:30:00 +0000 (14:30 -0500)]
Rename the '--with-python' configure option to '--with-python2'.
* configure.ac: Rename the '--with-python' configure option to
'--with-python2' (and all the associated variables).
* tapset-python.cxx (register_tapset_python): Handle renamed 'HAVE_PYTHON'
to 'HAVE_PYTHON2' defined. Split python probe support into
'HAVE_PYTHON2' and 'HAVE_PYTHON3' sections.
* config.in: Ditto.
* configure: Ditto.
Martin Cermak [Tue, 13 Sep 2016 08:56:14 +0000 (10:56 +0200)]
Fix PR20599 by only updating needed members of statistic_decl.
After introducing @variance in commit 63ead7fa, stat_ops and
bit_shift need to be tracked within the statistic_decl. Before
this update, new histogram always rewrote these new members,
which was causing the problem described in PR20599.
elaborate.cxx: Only rewrite type, linear_low, linear_high, and
linear_step, when binding new histogram with a global.
Martin Cermak [Tue, 13 Sep 2016 08:33:09 +0000 (10:33 +0200)]
Fix PR20597 and move @avg() calculations out of runtime.
Revert those parts of commit 63ead7f, that introduce new "avg"
member of the struct stat_data and move computations of @avg()
from the code directly emitted by the translator to the runtime.
The goal of this update is both to fix PR20597, and to speed up
the runtime. Note that @variance() calculations are based on the
avg too, but the variance vehicle carries its own avg_s, which is
an average scaled by certain bit_shift for numerical precision
improvement purpose. Variance calculations are optimized out if
unneeded.
So after this change, @avg computations should be as fast as they
were before @variance has been introduced in commit 63ead7f.
elaborate.cxx: Calculate @avg based on sum and count.
translate.cxx: Ditto.
runtime/map.c: Ditto, plus remove the online @avg calculations.
runtime/stat.c: Remove online @avg calculations.
runtime/stat.h: Drop the 'avg' member from the struct stat_data.
David Smith [Mon, 12 Sep 2016 20:53:46 +0000 (15:53 -0500)]
Revert last change to flightrec*.exp testcases and add comments.
* testsuite/systemtap.base/flightrec1.exp: Revert last commit and add
comments explaining what is going on. We expect the original 'stap'
command to finish and leave stapio running in the background.
* testsuite/systemtap.base/flightrec2.exp: Ditto.
* testsuite/systemtap.base/flightrec3.exp: Ditto.
* testsuite/systemtap.base/flightrec4.exp: Ditto.
* testsuite/systemtap.base/flightrec5.exp: Ditto.