Jonathan Lebon [Wed, 26 Mar 2014 17:56:20 +0000 (13:56 -0400)]
initscript: skip dracut stap module by default
We previously always enabled the dracut stap module as long as there
were scripts to include. This can lead to issues since the params.conf
file may be obsolete/not in sync e.g. during a kernel update. We now
make the module an opt-in feature, and make the initscript explicit
specify its inclusion.
Jonathan Lebon [Wed, 26 Mar 2014 15:39:11 +0000 (11:39 -0400)]
initscript: use new-kernel-pkg after dracut
With this patch, we now also call new-kernel-pkg --update after creating
the new image so that the bootloader is updated if need be (see also
BZ1051649#c9).
This patch also includes some polishing re. console log output.
David Smith [Wed, 26 Mar 2014 14:43:23 +0000 (09:43 -0500)]
Replace _sendflags_str() and _recvflags_str() with _msg_flags_str().
* tapset/linux/aux_syscalls.stp (_msg_flags_str): New function to replace
_sendflags_str() and _recvflags_str().
(_sendflags_str): Deprecated and reimplemented with _msg_flags_str().
(_recvflags_str): Ditto.
* tapset/linux/syscalls2.stp: Replace _sendflags_str() and
_recvflags_str() with _msg_flags_str().
* tapset/linux/nd_syscalls2.stp: Ditto.
* testsuite/buildok/aux_syscalls-embedded.stp: Test _msg_flags_str().
* NEWS: Mention deprecations.
Josh Stone [Wed, 26 Mar 2014 00:04:00 +0000 (17:04 -0700)]
Minor testsuite tweaks for stapdyn
- global_end: Allow for zero time (i.e. less than 1 microsecond), and
don't double the _dyninst test suffix.
- process_by_cmd: Add an "int rc" just to give distinct IPs between
function start and the first mark, so we don't need to worry about
determinism of the probe order. (stapdyn was hitting the mark first.)
- suppress-time-limit: Expect the WARNING messages too, because stapdyn
often has them mixed with the normal script output.
Josh Stone [Tue, 25 Mar 2014 20:46:57 +0000 (13:46 -0700)]
socktop: Make sure *_str are always known as strings
The new removal of unreachable code meant socktop might remove its whole
filter setup, and all the related variables are left with unknown type.
They would typically be pruned away just fine, but socktop also has a
probe never with print statements to avoid autoprint. Changing those to
log() lets stap always know they are strings.
Josh Stone [Tue, 25 Mar 2014 20:43:29 +0000 (13:43 -0700)]
Tighten a semok/doubleglob.stp pattern
With 't**es(1)', we only intended to match 'timer.jiffies(1), but we
also matched a 'tcp[...].callees(1)' on accident. This odd instance has
some issues in variable expansion, so we should just avoid it. Using
'ti**es(1)' gets back to the original intent of the test.
Josh Stone [Tue, 25 Mar 2014 18:22:43 +0000 (11:22 -0700)]
Remove code that follows unconditional control statements
When a block contains return, next, break, or continue, any following
statements are unreachable. Warn and remove them.
This replaces tapset-perfmon's statement_counter, which didn't know
enough to deal with blocks like '{ { } }' that arise from perf aliases.
Now it just inserts a 'next', and the later optimization passes can
figure this out in a very generic way.
Josh Stone [Fri, 21 Mar 2014 18:46:03 +0000 (11:46 -0700)]
Read the perf process from -c during pass2
When a bare .process is used, it's value is inferred from -c CMD. This
must be checked during pass2, or else a changed -c CMD will not trigger
a hash change, and an incorrect cached module will be used.
This patch also unifies the wordexp argv[0] parsing of -c CMD into a
shared systemtap_session::cmd_file().
Josh Stone [Fri, 21 Mar 2014 18:39:42 +0000 (11:39 -0700)]
PR14223: Allow perf probes for mere @stapdev mortals
Even though we're using the kernel interface, perf checks CAP_SYS_ADMIN,
which our mere @stapdev user may not have. By running via a workqueue,
we'll be in an events/X kernel thread with sufficient privileges.
Jonathan Lebon [Sat, 22 Mar 2014 04:50:53 +0000 (00:50 -0400)]
semantic_error: also print source of error
When printing semantic_errors at high verbosity (-vv), it can be useful
to also know where the error came from. That information is already made
available through the errsrc member of semantic_error (initially
implemented for dup-error elimination).
We also change the ERRSRC macro to use __FILE__ rather than __FUNCTION__
to be not only more informative, but more foolproof (e.g. two errors
thrown from identically named functions at identical lines in separate
files before would have been considered equivalent by the dup-error
elimination).
The final result is e.g. something like this:
semantic error: unresolved type : identifier 'ActiveOpens' at :22:8
thrown from: elaborate.cxx:5239
source: global ActiveOpens
^
Josh Stone [Sat, 22 Mar 2014 00:32:06 +0000 (17:32 -0700)]
testsuite: big cleanup of sdt_misc types
- Use a central check() function throughout, so tests and messages are
easily uniform. Prefix the PASS/FAIL messages with "sdt_types" so
they are easily distinguishable from dejagnu PASS/FAIL in the log.
- Adjust most constants to test the bounds of their types.
- Add unsigned char and unsigned long long.
- Tighten the expect patterns to exactly one line at a time, and
increment $notok for extra lines (like WARNINGs).
Josh Stone [Fri, 21 Mar 2014 22:09:53 +0000 (15:09 -0700)]
testsuite: big cleanup of sdt_asm
- Use a central check() function throughout, so tests and messages are
easily uniform. Prefix the PASS/FAIL messages with "sdt_asm" so they
are easily distinguishable from dejagnu PASS/FAIL in the log.
- Save and restore SP when when changing it in sdt_asm.S, and prepare
the stack and return value at the end for a clean exit.
- Skip mark("*sp") for --runtime=dyninst, because it's not prepared to
deal with that bad stack state.
- Tighten the expect patterns to exactly one line at a time, and
increment $notok for extra lines (like WARNINGs).
Josh Stone [Fri, 21 Mar 2014 19:12:52 +0000 (12:12 -0700)]
Let synthesized end probes use foreach values again
When these were moved to parse_synthetic_probe, I neglected to maintain
use of the "foreach (val = ...)" syntax. Add this back in, and update
optim_arridx.exp to expect the internal underscored names.
Josh Stone [Thu, 20 Mar 2014 23:23:34 +0000 (16:23 -0700)]
PR16730 addendum, link java method probes to the user
After commit ede0102cfd22, the java method probes that were built using
parse_synthetic_probe don't look like they come from the user's script
anymore, so the listing mode skips them. Since the mark probe is the
one containing the user's code, link its probe->base back to the user.
Also move the test in printscript a bit so verbose diagnostics are still
printed, to help with issues like this.
There's no need to catch recursive_expansion_error since
try_suffix_expansion() rethrows it as a semantic_error. If it did
rethrow it as a recursive_expansion_error (which might have been the
original intent), the errors would have been printed as:
recursive loop in alias expansion...
while resolving probe point...
no match
Rather, it is printed as follow:
while resolving probe point...
recursive loop in alias expansion...
which kills the 'no match' msg and is more in line with what we do for
other errors (i.e. having the 'while resolving probe point' msg first).
Jonathan Lebon [Thu, 20 Mar 2014 20:12:27 +0000 (16:12 -0400)]
RHBZ1065757: don't delete objects that are in use
Catching a semantic_error does not mean that nothing was derived. This
can occur in the case of probe aliases, where the first alias_name was
derived, but the second wasn't. In those cases, the first derived probe
uses those created objects, so corruption may result if we delete them.
We instead rely on the size of the results vector to determine if it is
safe to delete the objects.
David Smith [Thu, 20 Mar 2014 18:52:30 +0000 (13:52 -0500)]
PR16716 partial fix: Better types in 'syscall.{getsockname,getsockopt}'.
* tapset/linux/syscalls.stp: Fix types in 'syscall.getsockname' and
'syscall.getsockopt'.
* tapset/linux/aux_syscalls.stp (_stp_lookup_str): Move to the top of the
file so that it can be called earlier.
(_stp_lookup_or_str): Ditto.
(_sockopt_optname_str): Convert to use _stp_lookup_or_str(). Update list
of values handled.
(_sockopt_level_str): Ditto.
* testsuite/systemtap.syscall/getsockname.c: New test case.
* testsuite/systemtap.syscall/getsockopt.c: Ditto.
David Smith [Wed, 19 Mar 2014 18:25:38 +0000 (13:25 -0500)]
PR16716 partial fix: Better types in 'syscall.{getpeername,getrusage}'.
* tapset/linux/syscalls.stp: Fix types in 'syscall.getpeername'. Add
better 'compat' support to 'syscall.getrusage' and fix types.
* tapset/linux/nd_syscalls.stp: Add better 'compat' support to
'nd_syscall.getrusage'.
* tapset/linux/aux_syscalls.stp (_rusage_who_str): Add support for
decoding 'RUSAGE_THREAD'.
* testsuite/systemtap.syscall/getpeername.c: New test case.
* testsuite/systemtap.syscall/getrusage.c: Ditto.
The 'kernel_dwfl' and 'user_dwfl' references kept for caching purposes
in setupdwfl.cxx were causing the Dwfl object to never actually be
released, which in turn resulted in multiple files remaining open beyond
pass-3.
David Smith [Wed, 19 Mar 2014 15:32:51 +0000 (10:32 -0500)]
PR16716 partial fix: Better types in 'syscall.{getitimer,setitimer}.
* tapset/linux/syscalls.stp: Fix argument types in 'syscall.getitimer' and
'syscall.compat_getitimer'.
* tapset/linux/syscalls2.stp: Fix argument types in 'syscall.setitimer' and
'syscall.compat_setitimer'.
* testsuite/systemtap.syscall/getitimer.c: New test case.
* testsuite/systemtap.syscall/setitimer.c: Ditto.
David Smith [Tue, 18 Mar 2014 21:23:19 +0000 (16:23 -0500)]
PR16716 partial fix: Better types in 'syscall.connect'.
* tapset/linux/syscalls.stp: Fix argument types in 'syscall.connect'.
* tapset/linux/nd_syscalls.stp: Ditto.
* testsuite/systemtap.syscall/socket.c: New test case.
Mark Wielaard [Mon, 17 Mar 2014 21:05:33 +0000 (22:05 +0100)]
symbol_table::get_from_elf use dwfl_module_getsym_info if available.
dwfl_module_getsym does adjust the sym.st_value but doesn't try to resolve
it to a function address. dwfl_module_getsym_info leaves the st_value in
tact (no adjustment applied) and also returns the fully resolved address.
This matters for architectures that use function descriptors where we
want the actual function entry address and not just the address in the
function decriptor table (like .odp on ppc64).
David Smith [Mon, 17 Mar 2014 16:19:19 +0000 (11:19 -0500)]
Fix PR16718 by making _stp_copy_from_user() more robust.
* runtime/linux/copy.c (_stp_copy_from_user): On failure, don't bother to
clear out the destination buffer (since we can't be sure the number of
bytes to copy is valid).
* tapset-procfs.cxx (procfs_var_expanding_visitor::visit_target_symbol):
When generating code that calls _ stp_copy_from_user(), be sure to
handle failure properly.
Jonathan Lebon [Fri, 14 Mar 2014 15:21:23 +0000 (11:21 -0400)]
PR16473: always expand $$vars/$$parms/etc...
Probe points such as process.function("*") will aggregate both DWARF
functions as well as symtab-only functions. For the latter, we do not
have any debugging info available and thus no access to context
variables. We thus expand $$vars/$$parms/etc... to empty strings (this
was already added for a subset of cases in commit b78a0fb, PR15999).
Note however, that we still complain loudly if the user tries to
[pretty-]print a specific context $var.
To do this, we simply allow the dwarf_expanding_visitor to always do its
pass, no matter whether scope_die is valid. As per the previous commit,
e.g. $$vars will be expanded, while $var will be left unresolved.
I kept the brackets on rather than unindenting to keep the parent scope
less polluted.
Jonathan Lebon [Fri, 14 Mar 2014 15:13:42 +0000 (11:13 -0400)]
PR15999: strengthen null die checking
In commit b78a0fb, we allow $$vars/$$param/$$locals/$$return to expand
to an empty string if the scope_die is missing, such as is the case for
symtab-derived functions.
This patch ensures that we do not try to resolve normal context
variables, such as $var or $return, which absolutely require a
scope_die, and for which we previously SIGABRT'ed.
We also strengthen getscopes(), which only pointer-checked the
scope_die, rather than using null_die() to value-check it.
If a new server to be trusted was selected by address + port,
and there was no avahi assistance available, or the server was not known
to avahi, its certificate was not added to the database of
trusted servers. This was because the client mishandled the
case of an empty certificate serial number and acted as if
the new server was already trusted.
Fix this by not searching the NSS database of trusted certificates
for a match against an empty certificate serial number.
Dave Brolley [Wed, 12 Mar 2014 18:31:38 +0000 (14:31 -0400)]
PR 16645: Unhelpful feedback when stap fails
Under some conditions, stap automatically sets options which
have not been explicitely set, in an attempt to succeed where
it is known that translation would fail without these settings.
Examples are the automatic setting of the --privilege level and
the automatic request for translation via a compile-server for
unprivileged users.
In these cases, when translation still fails it would be helpful
to the user to explain what settings were changed automatically
and why.
It is also helpful to point the user at the appropriate documention
when futher configuration/setup on his part is required.
This change does the above for --privilege and --use-server.
Jonathan Lebon [Wed, 12 Mar 2014 15:10:32 +0000 (11:10 -0400)]
library probes: fix process path in listing mode
Previously, doing stap -l process("exe").library("*").function("myfunc")
would result in listings where the library field had the fully resolved
path, yet the process path retained the user-entered value.
With this commit, we override the user-entered value of process for the
absolute path, so that listing mode also shows it.
Jonathan Lebon [Thu, 6 Mar 2014 15:27:17 +0000 (10:27 -0500)]
callee probes: truly improve derivation for better listing
The previous attempt to do this (commit 80a63be) was hacky and was thus
reverted (see previous commit). In this commit, we try to do it
properly.
--- original commit msg ---
Previously, doing stap -L for function("foo").callee("*") would result
in listings directly for function("bar1"), function("bar2"), etc...
With this patch, we add an intermediate step in the derivation chain:
function("foo").callee("*") --> function("foo").callee("bar1")
This will cause -L to display this derivation instead, which is closer
to what users would expect for a function("foo").* probe.
To achieve this, we do three things:
1. We make func_info and inline_instance_info subclasses of a single
base_func_info class for uniform treatment when called from
query_cu() as well as cleaner passing of name/file/line/addr between
iterate_over_callees() and query_callee(). This can also help in
other cases (to be assessed...).
2. We remember and pass down the caller information in
iterate_over_callees(), so that query_callee() has it on hand when
creating the .function component.
3. In query_callee(), we create an intermediate probe point and a new
dwarf_query based on that probe point to create the final derived
probe.
David Smith [Wed, 12 Mar 2014 17:19:44 +0000 (12:19 -0500)]
If the syscall gate macros fail, just skip the probe.
* tapset/linux/syscalls.stpm (__syscall_gate): If _stp_syscall_nr() fails,
just skip this probe, since that probably means we're in kernel
context.
(__syscall_gate2): Ditto.
(__syscall_compat_gate): Ditto.
David Smith [Wed, 12 Mar 2014 14:07:58 +0000 (09:07 -0500)]
Improve task_finder/utrace shutdown.
* runtime/stp_utrace.c (utrace_exit): Move the call to
stp_task_work_exit() up above the calls to free the kmem caches. This
make sure any running task work items don't have the memory freed out
from under them.
* runtime/linux/task_finder2.c (__stp_task_finder_cleanup): Move
utrace_shutdown() call into stap_stop_task_finder().
(stap_stop_task_finder): Call utrace_shutdown() directly. Wait to make
sure all tracepoint probes are finished.
David Smith [Tue, 11 Mar 2014 21:24:55 +0000 (16:24 -0500)]
Only require a specific kernel if we're installing on RHEL4.
* systemtap.spec: Only have a kernel version requirement if we're doing a
RHEL4 build. The RHEL5+ and Fedora minimum kernel versions are past our
minimum kernel version. This change will help container versions of
Fedora that don't have a kernel installed.
Stan Cox [Tue, 11 Mar 2014 20:10:06 +0000 (16:10 -0400)]
Updates for python 3.3
* (celsius-bt.stp,celsius-var.stp): Don't to use the same script for
python2 and python3
* python.exp: Create python2/python3 versions of above.
* python2.stp (python2_backtrace, python2_get_variable): New.
* python3.stp (get_unicode, p3_get_dict_hash, p3_get_dict_key)
(p3_get_dict_value): Changes for python 3.3
(python3_backtrace, python3_get_variable): New.
Josh Stone [Tue, 11 Mar 2014 17:01:43 +0000 (10:01 -0700)]
BZ1073605 addendum, don't blacklist empty matches
For example, plt and symtab function probes have an empty filename, but
they should not be blocked for that. This patch adds an impossible ".^"
pattern as a placeholder in those blacklist patterns that aren't used
yet. Also add semok/semko tests to be sure probing "_start" is allowed
on entry but not on return.
Torsten Polle [Fri, 7 Mar 2014 20:39:31 +0000 (14:39 -0600)]
Fix: stap/staprun deadlocks when probing ends.
stap_stop_task_finder() exits utrace through utrace_exit(). At that
time, there might be outstanding task workers. Hence, waiting for
exiting the task work waits forever. Therefore exiting the task work
is done after canceling all task workers.
Lukas Berk [Fri, 7 Mar 2014 18:31:03 +0000 (13:31 -0500)]
Robustify stapbm javapid check for integers
*java/stapbm.in - previously the [[:digits:]] check would fail
if there was a digit mixed in the process name, such
as 'foo3bar'. Now this condition catches anything but
an integer.
Josh Stone [Thu, 6 Mar 2014 20:04:00 +0000 (12:04 -0800)]
Start using the parser for complicated code blocks
Sometimes we synthesize code to add to the user's script, and currently
this is done by manually building staptree components. This is error
prone, and we should let the parser do it when possible. This first
commit updates the automatic global-variable display to use the parser.
* staptree.h (struct stapfile): Add a synthetic flag.
* parse.cxx (lexer::set_current_token_chain): New, remember a token for
chaining synthetic code back to its origin.
(lexer::input_peek): Set the chained token.
(parser::parse_synthetic_probe): Directly parse a synthetic probe.
(parse_synthetic_probe): Expose this capability to the world.
* elaborate.cxx (add_global_var_display): Rewrite the synthetic end
probes as plain strings, then fed to the parser.
(symresolution_info::find_var): Don't warn about cross-file globals
from synthetic code.
* session.cxx (systemtap_session::print_error_source): Follow tok->chain
for all errors, not just macro parse_errors.
Lukas Berk [Thu, 6 Mar 2014 16:46:01 +0000 (11:46 -0500)]
PR16666: added strip -g testcase for symtab functionality
* minidebuginfo.exp - add new testcase, compile with debuginfo and
'strip -g' the resulting bin
* minidebuginfo.stp - change probe point to not explicitly list process
for reuse on new testcase
Jonathan Lebon [Wed, 5 Mar 2014 22:06:05 +0000 (17:06 -0500)]
callee.exp: adjust test for new listing and clean up
We fix the regexes for listing mode since they're now different (see
previous commit). We also fix the interface of expect_list and
expect_probe to be more intuitive (i.e. list the caller before the
callee).