William Cohen [Fri, 11 Dec 2015 20:49:40 +0000 (15:49 -0500)]
Ensure use of the function argument values from function entry in lwtools
On some machine such as powerpc64 and aarch64 function arguments are
passed using processor registers. The compiler is free to use those
registers how it sees fit. Thus, the register value on function return
may differ from the original argument value on function entry. To
ensure using the value from function entry the scripts use the
@entry() in the return probes.
David Smith [Fri, 11 Dec 2015 20:45:45 +0000 (14:45 -0600)]
Fix PR19358 by updating netfilter support for 4.4 kernels.
* tapset-netfilter.cxx (emit_module_decls): Handle kernel v4.4 netfilter
changes.
* runtime/linux/autoconf-netfilter-4_4.c: New autoconf test to test for
kernel v4.4 netfilter changes.
* buildrun.cxx (compile_pass): Add new autoconf test.
Josh Stone [Fri, 11 Dec 2015 03:17:56 +0000 (19:17 -0800)]
stapdyn: prepare for the dyninst 9.1 library callback change
The new API uses BPatch_object for the callback, because modules (~=CUs)
are now fully represented in shared objects too. This is better, but we
need to keep fallback code for the old API too, using module->getObject().
Josh Stone [Fri, 11 Dec 2015 03:13:51 +0000 (19:13 -0800)]
stapdyn: re-poll dyninst directly before sleeping
The poll fd comes from proccontrol, but sometimes dyninstAPI pulls events
into its own queue without handling them yet. If we then sleep in syscall
ppoll, we won't hear about those events until we hit the timeout. We can
do a quick dyninst poll first to clear those out.
Torsten Polle [Thu, 10 Dec 2015 18:56:29 +0000 (12:56 -0600)]
Add some support for older arm kernels.
* tapset/linux/arm/aux_syscalls.stp: Add support for arm kernels less than
3.7.
* tapset/linux/aux_syscalls.stp: Ditto.
* tapset/linux/arm/syscalls.stp: Add support for [nd_]syscall.execve for
arm kernels less than 3.7.
* tapset/linux/arm/nd_syscalls.stp: Ditto.
David Smith [Thu, 10 Dec 2015 15:06:33 +0000 (09:06 -0600)]
Make 2 small syscall testsuite changes for arm.
* testsuite/systemtap.syscall/stat.c: Mark fstatat64 as covered.
* testsuite/systemtap.syscall/coverage.tcl: Add a few modifications for
arm-based systems.
Zhou Wenjian [Wed, 9 Dec 2015 21:38:52 +0000 (15:38 -0600)]
Add more arithmetic and map delete test cases.
* testsuite/systemtap.base/arith.stp: Add more cases.
* testsuite/systemtap.maps/ii.stp: Ditto.
* testsuite/systemtap.maps/ii.exp: Update for new test case.
David Smith [Fri, 4 Dec 2015 20:23:17 +0000 (14:23 -0600)]
Add RHEL7.2 fixes for PR18889 so that we can probe module initializers.
* runtime/linux/kprobes.c (stapkp_prepare_kprobe): If we have
kallsyms_on_each_symbol(), just return if we don't have an address.
(stapkp_prepare_kretprobe): Ditto.
(stapkp_symbol_callback): New callback function for
kallsyms_on_each_symbol() to convert symbol_name+offset probes into
address probes. This works around a kernel bug and should be faster as
well.
(stapkp_init): Call kallsyms_on_each_symbol() when needed.
(stapkp_refresh): Ditto.
* runtime/transport/symbols.c (_stp_module_notifier): Change to the new
module refresh logic if the kernel version is 3.10 or higher.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Ditto.
* testsuite/systemtap.base/kmodule.exp: Only run the subtests that load
the test kernel module after the systemtap module is loaded on systems
that support module refreshes.
Josh Stone [Thu, 26 Nov 2015 00:31:09 +0000 (16:31 -0800)]
Add a nop_visitor, and use it for expression_is_functioncall
In expression_is_functioncall, it only cares if the immediate expression
is a functioncall, but the expression_visitor it was derived from would
fully traverse all other expressions. All it really wanted was like a
visitor-patterned dynamic_cast.
The new nop_visitor better enables this. It does nothing at all for any
node types, and then expression_is_functioncall can override just for the
functioncall it cares about.
(We haven't yet settled whether to prefer a visitor pattern like this,
or more direct virtual calls like expression::is_symbol, or just plain
dynamic_cast<>. Try to avoid the need for downcasts if possible.)
Josh Stone [Wed, 25 Nov 2015 22:10:17 +0000 (14:10 -0800)]
Remove functioncall::var_assigned_to_retval
It's unusual to have a value specific to one visitor stored in the tree
node itself. This particular value is only used by c_unparser. Make it
a c_unparser member instead, saved and restored as necessary to allow
for nested calls.
Josh Stone [Wed, 25 Nov 2015 01:12:35 +0000 (17:12 -0800)]
PR18884: skip tmps for any literal, not by tok->type
Some literal expressions get created dynamically, like const-folding an
expression of two literals. Those will probably not have a tok->type
that looks like a literal, but they're still reasonable candidates to
skip temporary storage and output directly into C.
Add a new c_assign for any tmpvar=expression, which will check for
literals to override the tmp, or else assign them as normal. Literals
are detected with a dynamic_cast of the expression, without looking at
the token at all. In many places that were roughly doing this based on
tok->type, use the new c_assign to handle it automatically.
The new test transok/literal_tmp.stp compares the PR18884 examples,
asserting that they now have *exactly* the same generated code.
Josh Stone [Tue, 24 Nov 2015 22:55:56 +0000 (14:55 -0800)]
Restrict optimization of literals in "%s\n" to streams only
This "use_print" optimization is only effective for printing to streams
with _stp_print(). Then a literal string argument to "%s\n" can just
have that literal token-pasted with the newline string. But when
printing to strings, like sprintln, that optimization isn't actually
taken, so it was getting the newline twice.
Add new tests with sprint and sprintln on string literals, then clean up
the code that does the optimization -- for streams only.
William Cohen [Tue, 24 Nov 2015 01:22:26 +0000 (20:22 -0500)]
Eliminate the use of tex(nomencl.sty) in TeX documentation files
RHEL 7 does not package the nomencl.sty file and having this style
file used in systemtap makes it difficult to build the documentation.
The only place it was being used was in the tutorial.tex and it was
not generating a useful glossary. The glossary generation of
tutorial.tex has been disabled for the time being.
Felix Lu [Mon, 23 Nov 2015 18:53:26 +0000 (13:53 -0500)]
Fix monitor mode to be compatible with the private global feature.
The synthetic functions and variables did not have a __global_
prefix, causing the symbol resolution to fail at finding them.
Commit 0c7e069fe82 assumes that there is a token for every probe
while two synthetic probes are generated in monitor mode with
null context. parse_synthetic_probe uses "<synthetic>" again
if no token is found for the probe. The __global_ prefix is shown
in monitor mode where global variables are shown so they needed
to be unmangled as done in commit 8f54215ef850c809.
* elaborate.cxx: above changes
* parse.cxx: fall back to "<synthetic>" if token is nullptr
* staprun/monitor.c: use return values of function calls
* staptree.cxx: check for token nullptr in functiondecl::printsig
The pipe used in monitor mode was not being read the moment
data was available, causing an overflow. pselect now watches
the pipe fd for data to read. The UI now cuts off the probe name
if terminal size is not wide enough.
Felix Lu [Mon, 16 Nov 2015 16:40:36 +0000 (11:40 -0500)]
PR18848: Fix json parsing error
Quotes in the probe names for the json string were not escaped to
form a valid json object. They had to be escaped once for the
systemtap parser and once more for the json parser.
* elaborate.cxx: escape quotes twice when generating json string
* staprun/monitor.c: check for correct parse result
Felix Lu [Mon, 9 Nov 2015 16:00:48 +0000 (11:00 -0500)]
PR18848: add module output scrollback, status window now refreshed
on input
Users can now use the u and d keys to scroll back and forward through
the output. The scrollback uses a moving window approach over a queue.
The status window is now updated upon input for a smoother experience.
Felix Lu [Wed, 28 Oct 2015 18:44:35 +0000 (14:44 -0400)]
PR18848: add most functionality to curses interface
Currently, a file is used to redirect stp_print output to curses window.
Previous curses interface code in mainloop got refactored into monitor.c.
* runtime/monitor.c: New file. procfs functions for stp_print redirection
* runtime/print_flush.c: Redirect stp_print to curses interface in
monitor mode
* staprun/monitor.c: New file implementing curses interface
* staprun/mainloop.c: Move code into monitor.c
* staprun/Makefile.*: Link json-c and curses library, include monitor.c
to source list
* translate.cxx: Create procfs file for stp_print redirection
Felix Lu [Thu, 15 Oct 2015 18:51:24 +0000 (14:51 -0400)]
PR18848: new command line argument -M for staprun
Pass stap --monitor command to staprun.
* buildrun.cxx: add -M argument to flags
* staprun/common.c: -M option to parse_args
* staprun/mainloop.c: add a timeout to pselect in monitor mode
to prevent blocking and allow the procfs monitor interface to
be polled.
* staprun/staprun.h: monitor extern declaration
Felix Lu [Wed, 7 Oct 2015 15:33:59 +0000 (11:33 -0400)]
PR18848: use jiffies tapset function
Switch the implementation of uptime to use the jiffies and hz tapset
functions instead of using embedded C
* elaborate.cxx: remove old embedded C function to get uptime. Added
a synthetic begin probe to obtain starting time. Synthetic variables
are now hidden in monitor mode and not reset.
* translate.cxx: remove jiffies inclusion in monitor mode.
Felix Lu [Tue, 6 Oct 2015 20:15:07 +0000 (16:15 -0400)]
PR18848: new procfs monitor mode option
Presents a procfs read interface to obtain data about the running
script and another procfs write interface to control the script
* cmdline.cxx: new "monitor" option
* cmdline.h: new field in enum
* elaborate.cxx: new functions monitor_mode_read and monitor_mode_write
synthesizes procfs probes for the interfaces
* session.cxx: new monitor flag
* session.h: new monitor flag
* translate.cxx: extra code is generated to provide statistics for
monitor mode, function emission is delayed to allow stap_probes to
be first defined
Martin Cermak [Fri, 20 Nov 2015 11:22:05 +0000 (12:22 +0100)]
Update the PR19241 fix so that 'out_fd' gets correctly handled.
This is an update to commit d879410b. Before this update, stap
in "stream mode" was using invalid output file descriptor per
https://sourceware.org/bugzilla/show_bug.cgi?id=19241#c2.
Martin Cermak [Fri, 20 Nov 2015 10:00:30 +0000 (11:00 +0100)]
Allow buildok/{rpc-all-probes,rpc-detailed} to access private var.
Tests buildok/rpc-all-probes.stp and buildok/rpc-detailed.stp are
examining '@__private30 global __rpc_create_args' array. That can
only be accessed using '--compatible=2.9' by the test script.
This approach to testing private stuff will probably need to change
in the future. For now, this update aligns buildok/{rpc-all-probes,\
rpc-detailed}.stp to other buildok tests examining private variables
or functions.
Josh Stone [Fri, 20 Nov 2015 02:01:20 +0000 (18:01 -0800)]
Remove the last visitors from c_tmpcounter
Now c_tmpcounter doesn't doesn't have any duplicated visitors at all.
It only overrides a few key virtual methods in c_unparser to get the
functionality it needs.
Josh Stone [Fri, 20 Nov 2015 00:25:22 +0000 (16:25 -0800)]
Subclass c_tmpcounter directly from c_unparser
The c_tmpcounter is meant to be a shadow of c_unparser, walking the same
walk to declare the temps that c_unparser will need. But this was done
manually in a fragile balancing act, with a lot of duplicated logic and
little to ensure it was correct unless it failed to compile at all.
Now c_tmpcounter is a subclass of c_unparser so it can be a real shadow,
truly walking the same walk via the exact same code. The normal output
is just dumped into a nulled ostream for this pass. When a var is
accessed the first time through its value(), c_tmpcounter writes its
declaration to the real ostream. A var that's created but not used will
be left out automatically, like a tmpvar that gets an override().
William Cohen [Thu, 19 Nov 2015 22:05:12 +0000 (17:05 -0500)]
Avoid using the nomencl compatible option
Some versions of nomencl such as the one on RHEL 5 are missing the
compatible option. Thus, tutorial.tex should avoid using it so the
documentation can be built.
David Smith [Thu, 19 Nov 2015 18:38:09 +0000 (12:38 -0600)]
Improve kmodule.exp by adding tests that load the module after stap.
* testsuite/systemtap.base/kmodule.exp: Add subtests that see if the same
scripts work if the module is loaded after the systemtap module is
loaded. This currently fails for non-dwarf kprobe probes (PR19216).
David Smith [Wed, 18 Nov 2015 19:03:44 +0000 (13:03 -0600)]
Refix PR18889 by switching to symbol_name+offset module probing.
* tapsets.cxx: Add symbol_name+offset support for dwarf kprobes present in
modules. This is somewhat based on work by James Bottomley from the
following email:
<https://sourceware.org/ml/systemtap/2008-q3/msg00182.html>
* runtime/transport/symbols.c (_stp_module_notifier): On kernel's >= 3.16,
use symbol_name+offset probing for modules.
* runtime/linux/kprobes.c: Switch to using symbol_name+offset probing for
modules.
David Smith [Wed, 18 Nov 2015 18:53:33 +0000 (12:53 -0600)]
Revert "PR18889 part: module-init notification via module_{load,free} tracepoints"
This reverts commit 2278079efc01124dd509241f6c6eadbd6e19cb2a. This code
will be replaced with a new method for handling probes in kernel module's
init sections.
David Smith [Wed, 18 Nov 2015 18:52:08 +0000 (12:52 -0600)]
Revert "PR18889: switch to STP_TRACEPOINT* frontend for kernel tracepoint registration"
This reverts commit 2e67c14dad1c661d2ce0b0ed218b371c1af218ba. This code
will be replaced with a different method for handling probes in kernel
module's init sections.
Martin Cermak [Wed, 18 Nov 2015 10:00:07 +0000 (11:00 +0100)]
Make the "shebang trick" work for RPM packaged testcases.
Some testcases use the "shebang trick" described in stap_run_batch()
testsuite function. Commit d2995e6f breaks this for RPM packaged
testcases by putting the absolute path to stap into the shebang.
This update reverts cb69017 update to stap_run_batch() and fixes the
specfile shebang rewriter instead, so that it only applies to
systemtap examples contained in the systemtap-client package, where
the "shebang trick" is unwelcome. With this update, testcases
contained in the systemtap-testsuite RPM remain unchanged, so that
the "shebang trick" works for them.
Josh Stone [Tue, 17 Nov 2015 23:31:00 +0000 (15:31 -0800)]
Compact print_format and its format_component
The delimiter doesn't need to be a full component -- just a simple
interned_string will do. The format_component can compact its flags and
enum fields down to a single byte each, taking it from 48 bytes on
x86_64 to just 32 bytes.