Abegail Jakop [Wed, 1 Oct 2014 20:49:39 +0000 (16:49 -0400)]
PR11528: new pragma "unmodified-fnargs" for embedded-c
elaborate.cxx: remove the portion in semantic_pass_opt2() that populates
a vector with unmodified function args
translate.cxx: new function that uses a new visitor to determine if the body
of a function modifies the function arguments. for embedded code, it checks
for the presence of the pure or unmodified-fnargs pragma.
translate.cxx: in ::c_assign(), when the rval is a functioncall and the
function returns a string, the retval is points to the destination.
c_unparser::visit_functioncall() handles the case where the return value
of the function is not used, by setting the destination to a tmpvar.
PR11528: pass function args as char * where possible
elaborate.cxx: store the function arguements that are not modified
within the function body
translate.cxx: change the type of unmodified, string function args
to char * and treat them as such when emitting functioncalls
Josh Stone [Fri, 12 Sep 2014 22:51:10 +0000 (15:51 -0700)]
stapdyn: use process_vm_readv/writev when possible
For script deref uses, we were using pread/pwrite on /proc/self/mem.
But thanks to CVE-2012-0056, some kernels have completely disabled
mem_write, so stapdyn guru scripts can't write memory at all. Our
testsuite failed on at_var_lvalue.exp and deref.exp in this case.
When the process_vm_readv/writev syscalls are available, we can
accomplish the same thing, and don't even need an open fd for it.
Jonathan Lebon [Fri, 12 Sep 2014 20:53:42 +0000 (16:53 -0400)]
initscript: also delete uprobes.ko during cleanup
If after cleanup we've removed all the scripts that require uprobes.ko,
then we should also delete uprobes.ko itself. It will be copied back in
the cache directory the next time a uprobes.ko dependent script is
compiled.
systemtap-initscript scripts that rely on uprobes must be configured
with the --save-uprobes option. This option saves the generated
uprobes.ko module and loads it when running the script.
The uprobes dependency information is actually available at compile time
so we can autodetect as follows:
1. Check if uprobes.ko was generated during compile
2. When uprobes.ko was generated, touch <name>.uprobes in the cache
directory.
3. Add the staprun -u option if <name>.uprobes exists
It is no longer necessary to specify the --save-uprobes option in the
initscript configuration file, although doing so allowed.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Jonathan Lebon [Fri, 12 Sep 2014 18:06:08 +0000 (14:06 -0400)]
PR17190: accept functions given with their decl_line
If the user gives a probe for a specific function, e.g.
kernel.function("vfs_read@fs/read_write.c:393")
where the vfs_read() function is declared at lineno 393, we don't
actually want to probe lineno 393 (most likely there's nothing there
anyway). We simply need to probe the function's entry point.
Jonathan Lebon [Mon, 8 Sep 2014 21:17:59 +0000 (17:17 -0400)]
nearest probes: preserve user-entered lineno in chain
This patch adds an earlier well-formed probe point in the derivation
chain of .nearest probes so that the original lineno entered is
retained during stap -l.
Martin Cermak [Wed, 10 Sep 2014 18:21:16 +0000 (20:21 +0200)]
server.exp: fix condition affecting avahi related subtests
On systemd based systems, /usr/sbin/service calls /bin/systemctl.
Unlike rhel6's /sbin/service, systemctl logs to stderr even in case
of successful service restart. Tcl's exec(), called from the as_root(),
is by default sensitive to stderr, and produced false failure.
Josh Stone [Wed, 3 Sep 2014 23:37:06 +0000 (16:37 -0700)]
Remove systemtap_session::built_uprobes
For the purpose of save_uprobes, it doesn't actually matter whether
uprobes.ko was just built or was pulled from the cache. If we have the
uprobes_path at all, go ahead and save it.
Jonathan Lebon [Wed, 3 Sep 2014 21:45:33 +0000 (17:45 -0400)]
initscript: use --save-uprobes instead of -u
Rather than masking the -u option of stap (unoptimized mode), use the
actual option which we use with stap (--save-uprobes). This will allow
us to remain backwards-compatible if we later on automate the uprobes
saving by always turning on --save-uprobes.
So now, users have to do the following if they require userspace
probing:
Stefan Hajnoczi [Wed, 3 Sep 2014 21:38:30 +0000 (17:38 -0400)]
stap: add --save-uprobes
The stap -m <name> option saves the script module. For scripts that
rely on uprobes it may also be necessary to get the uprobes module (if
it was built by stap).
The new stap --save-uprobes option saves uprobes/uprobes.ko into the
current directory.
jistone noted that the smp_call_function_single() function call
introduced in commit 590a9ae1acc47 didn't exist on 2.6.9-era kernels.
We de-optimize to plain smp_call_function() on such dinosaurs.
Josh Stone [Fri, 29 Aug 2014 22:15:47 +0000 (15:15 -0700)]
PR12333: Use 1/0 conditions instead of true/false in C
The kernel happens to declare true/false values for C to use, at least
since commit 6e21828743247 (in 2.6.19), but stapdyn's normal C runtime
doesn't have that. Use boring old 1/0 instead.
Abegail Jakop [Thu, 28 Aug 2014 19:08:59 +0000 (15:08 -0400)]
PR12333: deleting pmap specified by array slice
runtime/map.c: have iterdel() use pre-existing functions
translate.cxx: generate code to delete elements from a pmap, based on
an array slice given. rename next() that called iterdel to del_next()
staptree.cxx: cleanup of an unnecessary condition
Abegail Jakop [Tue, 26 Aug 2014 19:53:22 +0000 (15:53 -0400)]
store given pid for process probe for use by task_finder
session.cxx: replace readlink(), which did the pid validation,
with is_valid_pid()
tapsets.cxx: if given, within dwarf_builder::build store the pid
for use by uprobe_derived_probe so that task_finder associates
the probe with the pid
util.*: new function that checks if the given pid is valid. if
not, it generates an error message that can be used.
Abegail Jakop [Fri, 22 Aug 2014 20:52:33 +0000 (16:52 -0400)]
PR12333: store wildcards in array slices as NULL
parse.cxx: set the index for array slices as NULL if it's a wildcard
elaborate.cxx: account for NULL indexes. added error message in
symresolution_info::visit_arrayindex if it encounters a NULL index,
since all expressions that support wildcards dealt with separately
staptree.cxx: when printing out foreach, delete and array_in, replace
NULL indexes with "*"
translate.cxx: account for NULL indexes. don't generate a tmpvar
for a wildcard array index
Abegail Jakop [Thu, 21 Aug 2014 16:17:40 +0000 (12:17 -0400)]
PR12333" array slicing for membership test
parse.cxx: accept wildcards in the arrayindex for array_in
elaborate.cxx: new function symresolution_info::visit_array_in
that skips processing wildcards that are present in the arrayindex
translate.cxx: generate code to iterate over the array until a
match is found or until the end of the array
Abegail Jakop [Tue, 19 Aug 2014 18:12:52 +0000 (14:12 -0400)]
PR12333: array slicing for delete statements
parse.cxx: accept wildcards (*) within array indexes
elaborate.cxx: skip processing wildcards in array indexes for delete
staptree.cxx: for the varuse_collecting_visitor, don't throw an error
about no referent if the symbol is a wildcard
translate.cxx: generate code for deleting variables if the indexes match
the array slice given. Also generate code to initialize tmpvars used to
store indexes in the array slice.
runtime/map.c: new function _stp_map_iterdel that deletes the node given,
and returns the next node in the map.
Frank Ch. Eigler [Sun, 17 Aug 2014 14:55:35 +0000 (10:55 -0400)]
runtime: improve robustness of shutdown phase via flush_scheduled_work()
It has been observed that schedule_work() artifacts have the potential
to overstay their welcome during shutdown, triggering some time after
their operand data structures have been deallocated. This has shown
up most recently on 3.17-rc0 during the on-the-fly stress-testing, but
also can be observed with plain pseudo-utrace callbacks. We now add a
flush_scheduled_work() into our cargo-cult stp_synchronize_sched(),
which we now call during the on-the-fly shutdown phase too.
Normal optimized mode can make it difficult to see which stap probe
was being invoked for which C probe handler body, as identical probe
handlers are reused. This is inconvenient if one just has a kernel
crash backtrace to start from from.
* translate.cxx (emit_common_header, emit_probe): In -u mode,
eschew duplicate probe handler body elision.
Abegail Jakop [Fri, 15 Aug 2014 20:33:33 +0000 (16:33 -0400)]
PR12333: evaluating the indexes before the loop body
translate.cxx: evaluate the expressions that make up the array slice
index for foreach loops. updated c_tmpcounter::visit_foreach_loop to
account for the additional tmpvars used to store array slice indexes
David Smith [Fri, 15 Aug 2014 20:07:52 +0000 (15:07 -0500)]
Fix PR17275 by fixing testcase problems on s390x.
* testsuite/buildok/memory-all-probes.stp: Tweak test to avoid overly
broad wildcards, which can cause the test to fail on systems without
uprobes (like s390x).
* testsuite/buildok/tcp-all-probes.stp: Ditto.
David Smith [Thu, 14 Aug 2014 18:49:44 +0000 (13:49 -0500)]
Improve on-the-fly initialization code.
* translate.cxx (c_unparser::emit_probe_condition_initialize): Only output
'cond_enabled' field initialization if the probe isn't always enabled.
(translate_pass): Always initialize 'cond_enabled' to 1. This can get
overridden by the output of
c_unparser::emit_probe_condition_initialize().
Josh Stone [Tue, 12 Aug 2014 17:29:30 +0000 (10:29 -0700)]
PR17260: Use get_context to guard stp_print_flush's lock
Holding a context ensures that any probes triggered in the interim will
be considered reentrant and skipped, since such a nested probe might
have recursed on that spinlock. We faced a similar situation before
with _stp_ctl_send and all the locks it touches.
Frank Ch. Eigler [Mon, 11 Aug 2014 19:56:15 +0000 (15:56 -0400)]
statement.nearest probes followup: some docs, samples, tweakage
* NEWS: Mention it.
* man/stapprobes.3stap: Document it.
* testsuite/systemtap.examples/*: Use it.
* testsuite/systemtap.*/: Baby test it.
* dwflpp.cxx: Drop debugging statement and make a speech.
Honggyu Kim [Mon, 4 Aug 2014 13:18:40 +0000 (22:18 +0900)]
dwflpp: register statement.nearest suffix
If a line number is given in 'statement', line records in dwarf may not
be found for a given line number.
In this case, alternative line numbers were suggested and exited.
With statement.nearest suffix, a kprobe is inserted into the nearest
line number that is available in dwarf line record.
* dwflpp.cxx(dwflpp.cxx::insert_alternative_linenos): Add a new method,
Add an arg "has_nearest" in dwflpp::iterate_over_srcfile_lines
* dwflpp.h(dwflpp.cxx::insert_alternative_linenos): Ditto.
* tapsets.cxx: Add a new suffix statement.nearest
Jonathan Lebon [Mon, 11 Aug 2014 19:40:19 +0000 (15:40 -0400)]
Merge branch 'jlebon/onthefly' (PR10995)
This branch adds support for on-the-fly probes as described in PR10995.
It also includes various minor fixes as well as a new file
runtime/linux/kprobes.c which hosts kprobes-related code (rather than
being dynamically emitted from tapsets.cxx).