David Smith [Thu, 19 Dec 2013 19:05:15 +0000 (13:05 -0600)]
PR16207 partial fix: Fix the 'mount' [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls2.stp: Add 'sys_oldumount' support to the
syscall.umount probe. Don't allow syscall nesting in syscall.umount.
* tapset/linux/nd_syscalls2.stp: Ditto.
Jonathan Lebon [Fri, 13 Dec 2013 21:37:57 +0000 (16:37 -0500)]
PR16326: fix client.exp and simplify it
The client.exp testcase can now (again) work with other stap-servers
running. This patch also significantly simplifies the code by
introducing a few array utility procedures.
Frank Ch. Eigler [Mon, 16 Dec 2013 18:38:39 +0000 (13:38 -0500)]
kernel tracepoints: bring up-to-date for 3.11
Added a whole bunch of other hidey-spots where kernel tracepoint
DEFINE_EVENT's were plopped in recent kernels, along with a few
incomplete-definition type workarounds.
For a virtio-serial port to be successfully installed, the domain also
requires a virtio-serial controller. When doing 'stapvirt port-add',
this is done automatically by libvirt. However, when using hotplugging,
stapvirt will fail if no controller is installed. Note that
virtio-serial controllers cannot be hotplugged.
Documenting this issue is a first step. Efforts are under way to make
this more transparent to the user.
Also see: https://bugzilla.redhat.com/show_bug.cgi?id=1020500#c34
David Smith [Thu, 12 Dec 2013 16:47:52 +0000 (10:47 -0600)]
Simplify sendfile.c test program for use on an NFS partition.
* testsuite/systemtap.syscall/sendfile.c: Simplify testcase. Originally
when compiled 32-bits on a 64-bit system and run on an NFS partition,
fstat() returns an invalid size of the newly created file. This invalid
size was verified with strace. Since we know the size of the file
anyway, just use it directly, which avoids the NFS problem.
Jonathan Lebon [Fri, 6 Dec 2013 19:50:44 +0000 (14:50 -0500)]
properly implement stapshd reload
We previously did not check the character device properly, which
resulted in all live sessions being killed during a reload. This was
especially an issue in the case of hotplugging under RHEL5/6, in which
udev can call reload multiple times even though only a single port was
hotplugged.
runtime: don't require CONFIG_KPROBES for user-space backtraces
* runtime/stack.c: Drop an unnecessary #ifdef CONFIG_KPROBES that
wrapped even pure-userspace stack-unwinding-related code, and
caused unnecessary -p4 failures.
Josh Stone [Mon, 2 Dec 2013 22:34:07 +0000 (14:34 -0800)]
Use proper set operations for symtab dupe checks
In query_symtab_func_info, rather than full set iteration to check an
address in alias_dupes, just use set::insert().second as a test. This
is what sets are designed to be algorithmically good at.
This also has the benefit of adding to alias_dupes, so duplicates within
the symbol table itself will still only be probed once. (If we didn't
want that effect, we would just use set::count() to test membership.)
Josh Stone [Mon, 2 Dec 2013 22:15:30 +0000 (14:15 -0800)]
Set git-describe --abbrev=12 for consistency and future-proofing
Git's default abbrev is 7, with smarts to disambiguate the SHA1 for that
given moment. Torvalds has recommended core.abbrev = 12 for kernel
developers to help avoid future as-yet-unknown collisions.
It becomes an issue to our scripts if this setting is not deterministic.
For instance, "make && sudo make install" will run git_version.sh with
$USER's git config, then root's config, but we don't want git_version.h
to be regenerated just for that difference.
Now our scripts use an explicit git-describe --abbrev=12 to be safe.
Jonathan Lebon [Mon, 2 Dec 2013 16:17:05 +0000 (11:17 -0500)]
stap-serverd: remember exact rc from spawned stap
Previously, stap-serverd used spawn_and_wait() to run stap and wait for
it to exit. However, the actual return code of stap was lost and never
bundled in the server response.
With this patch, spawn_and_wait() captures the child's exit rc in a
separate variable, so that we can differentiate between failure in
spawning and a nonzero exit code from the child.
So now the response/rc file holds the actual rc with which stap exited.
This makes a difference in the case of stap -l, in which we don't send a
script to the server and thus cannot rely on the presence or absence of
a compiled module in the server response to determine success.
csclient.cxx: don't print the 'via server failed' message if we're in
listing mode
Jonathan Lebon [Sat, 30 Nov 2013 16:14:25 +0000 (11:14 -0500)]
stapsh.c: fix handling of POLLIN to indicate EOF
We previously relied on POLLHUP to indicate EOF. However, it is also
possible to receive POLLIN when EOF is reached. With this patch, upon
receiving POLLIN and reading from the associated fd, if EOF is found, we
modify the polling array to indicate we're no longer interested.
Lukas Berk [Fri, 29 Nov 2013 21:34:11 +0000 (16:34 -0500)]
PR10208 Support probing weak symbols
*tapsets.cxx - Now always query the symtab (unless there is a pending interrupt
or dwarf callback error) on a function probe. We need to be careful
to check probe point's we've already resolved which will already
have full debug information and to not place another probe there.
We've removed the case of probing the symbol table on a statement probe,
as that code was written specifically for the kernel without userspace
in mind and was resolving the function the statement resided in (causing
errors in some cases).
*list.exp - Added testcase for weak symbols
*last_100_frees.stp - we use @defined($mem) here because on 64 bit systems, the
wildcard search takes us through both 64 bit and 32 bit libc
(which doesn't have debuginfo), this means the probe point
resolved from the 32 bit library has no context info
*mutex-contention.stp - ditto but for @defined($mutex) and @defined($rwlock)
Josh Stone [Tue, 26 Nov 2013 19:57:40 +0000 (11:57 -0800)]
stapdyn: Use plain CLOCK_MONOTONIC for -t timing
CLOCK_MONOTONIC_RAW has immunity to adjtime and NTP, but CLOCK_MONOTONIC
is often implemented in vdso. For simple timing, it's worth trading a
little accuracy for lower overhead.
Josh Stone [Tue, 26 Nov 2013 18:40:48 +0000 (10:40 -0800)]
stapdyn: Batch _stp_strncpy_from_user reads
In order to reduce the number of syscalls required, this strncpy now
opportunistically reads larger blocks before checking for '\0'. Reads
are kept within page boundaries to avoid running into invalid memory.
David Smith [Tue, 26 Nov 2013 16:58:22 +0000 (10:58 -0600)]
PR16207 partial fix: Fix the 'pipe' [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls.stp: Handle syscall nesting in syscall.pipe.
* tapset/linux/nd_syscalls.stp: Handle syscall nesting in
nd_syscall.pipe.
* runtime/linux/compat_unistd.h: Add __NR_compat_pipe2.
* tapset/linux/aux_syscalls.stp (_sys_pipe2_flag_str): Handle a flags
value of 0.
* testsuite/systemtap.syscall/pipe.c: Add a new test.
David Smith [Mon, 25 Nov 2013 20:00:51 +0000 (14:00 -0600)]
PR16207 partial fix: Fix the 'dup' [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls.stp: Split the syscall.dup2 probe into
syscall.dup2 and syscall.dup3.
* tapset/linux/nd_syscalls.stp: Split the nd_syscall.dup2 probe into
nd_syscall.dup2 and nd_syscall.dup3.
* runtime/linux/compat_unistd.h: Added the __NR_compat_dup3 define.
* testsuite/buildok/syscalls-detailed.stp: Added dup3 test.
* testsuite/buildok/nd_syscalls-detailed.stp: Ditto.
David Smith [Mon, 25 Nov 2013 17:03:24 +0000 (11:03 -0600)]
PR16207 partial fix: Fix the link [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls.stp: Add @__syscall_compat_gate() macro call to
syscall.linkat probe.
* tapset/linux/syscalls2.stp: Add @__syscall_compat_gate() macro call to
syscall.readlinkat and syscall.symlinkat probes.
* tapset/linux/nd_syscalls.stp: Add @__syscall_compat_gate() macro call to
nd_syscall.linkat probe.
* tapset/linux/nd_syscalls2.stp: Add @__syscall_compat_gate() macro call
to nd_syscall.readlinkat and nd_syscall.symlinkat probes.
* runtime/linux/compat_unistd.h: Added the __NR_compat_linkat,
__NR_compat_readlinkat, and __NR_compat_symlinkat defines.
* testsuite/systemtap.syscall/link.c: Updated testcase to handle syscall
probes no longer being a wrapper around other syscall probes.
David Smith [Mon, 25 Nov 2013 15:30:49 +0000 (09:30 -0600)]
PR16207 partial fix: Fix the chmod [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls.stp: Add @__syscall_compat_gate() macro call to
syscall.fchmodat, syscall.fchmodat.return, syscall.fchownat, and
syscall.fchownat.return probes.
* tapset/linux/syscalls.stp: Add @__syscall_compat_gate() macro call to
nd_syscall.fchmodat, nd_syscall.fchmodat.return, nd_syscall.fchownat,
and nd_syscall.fchownat.return probes.
* runtime/linux/compat_unistd.h: Added __NR_compat_fchmodat and
__NR_compat_fchownat defines.
* testsuite/systemtap.syscall/chmod.c: Updated testcase to handle
syscall probes no longer being a wrapper around other syscall probes.
David Smith [Fri, 22 Nov 2013 22:41:54 +0000 (16:41 -0600)]
PR16207 partial fix: Fix the access [nd_]syscall.exp tests on rawhide.
* tapset/linux/syscalls.stpm: Add @__syscall_compat_gate() macro.
* tapset/linux/syscalls.stp: Add @__syscall_compat_gate() macro call to
syscall.faccessat and syscall.faccess.return.
* tapset/linux/nd_syscalls.stp: Add @__syscall_compat_gate() macro call to
nd_syscall.faccessat and nd_syscall.faccess.return.
* testsuite/systemtap.syscall/access.c: Updated testcase to handle
access() no longer being a wrapper around faccessat().
* runtime/linux/compat_unistd.h: New file.
* tapset/linux/aux_syscalls.stp: Include compat_unistd.h.
David Smith [Fri, 22 Nov 2013 20:51:50 +0000 (14:51 -0600)]
PR15219 partial fix. The [nd_]syscall.timer_settime probes no longer nest.
* tapset/linux/syscalls2.stp: Add compat function support to
'syscall.timer_settime' and 'syscall.timer_settime.return' probes.
* tapset/linux/nd_syscalls2.stp: Add compat function support to
'nd_syscall.timer_settime' and 'nd_syscall.timer_settime.return'
probes.
* tapset/linux/aux_syscalls.stp (_struct_compat_itimerspec_u): New
function.
Aaron Tomlin [Fri, 22 Nov 2013 15:03:02 +0000 (15:03 +0000)]
Add STAP_ERROR macro
Instead of CONTEXT->last_error = "foo"; goto out; in an embedded-C
function, a newly defined macro STAP_ERROR(str) should be used.
The script can catch the exception with try { } catch { }.
Josh Stone [Wed, 20 Nov 2013 21:01:10 +0000 (13:01 -0800)]
Tighten -Wno-format-nonliteral to just where it's needed
We only have one function, stap_strfloctime(), which actually requires
relaxing this warning; the rest can and should be checked. Split this
function into its own file, and give just that the relaxed option.
Josh Stone [Wed, 20 Nov 2013 19:36:26 +0000 (11:36 -0800)]
parse: Let pp1_activation own the token rather than copying
This works around the RHEL4 compiler, which apparently doesn't see
parser::pp1_activation as a friend of token, even though parser is.
So it was failing to invoke the now-restricted copy-constructor, but
there's not really any reason for it to make a copy anyway.
Josh Stone [Wed, 20 Nov 2013 19:19:19 +0000 (11:19 -0800)]
Don't check kernel "utrace" support for dyninst
This regressed after commit d0923e365964097a2209cfc23568d5770f596bad,
which stopped reading kernel CONFIG variables at all for --dyninst.
We don't need them, but it didn't hurt much to check before.
Josh Stone [Mon, 18 Nov 2013 19:20:02 +0000 (11:20 -0800)]
PR16184: Fix sigmask decoding in the presence of TRACESYSGOOD
Commit f1e0e63bb6992df4127bc7ae7ba89be478b9c250 added SIGTRAP|0x80 to
indicate PTRACE_O_TRACESYSGOOD signals. However, _stp_sigset_str became
unpredictable, because it checks sigismember for all known signals, but
SIGTRAP|0x80 is out of the bitrange possible in a sigmask.
Now _stp_sigset_str only checks sigismember for values <= _NSIG.
Josh Stone [Sat, 16 Nov 2013 01:56:41 +0000 (17:56 -0800)]
PR10574: Fix a few pc=0 that escaped this old bug
We already checked for pc=0 in dwflpp::die_entrypc, but a couple places
didn't check the return value to notice COMDAT rejection. We also need
to check this in the simpler dwflpp::function_entrypc, and both
functions are now marked warn_unused_result.
The new testsuite/semok/nullpc.stp makes sure we don't have any pc=0 in
stap itself, which is a large enough C++ binary to sometimes have these
COMDAT-eliminated null functions.
David Smith [Fri, 15 Nov 2013 19:52:03 +0000 (13:52 -0600)]
PR15219 partial fix. Several syscall.clock_* probes longer nest.
* tapset/linux/syscalls.stp: Add __syscall_get() macro calls to
syscall.clock_nanosleep and syscall.clock_nanosleep.return to reject
nested syscalls. Added compat_sys_clock_settime support to
syscall.clock_settime and syscall.clock_settime.return.
* tapset/linux/nd_syscalls.stp: Similar changes as above.
* tapset/linux/syscalls.stpm: New file.
* tapset/linux/aux_syscalls.stp (_stp_syscall_nr): New function.
Jonathan Lebon [Fri, 15 Nov 2013 19:35:43 +0000 (14:35 -0500)]
also suggest function aliases on unresolved dwarf probes
This patch does two things:
1. It removes sym_seen and replaces it with inlined_funcs, which only
picks up inlined functions.
2. suggest_dwarf_functions() now aggregates functions from both
inlined_funcs and the module_info symtab function cache.
The net result is that (1) we're no longer storing duplicate
information, and (2) we now also suggest function aliases (which are in
the cache).
Jonathan Lebon [Wed, 13 Nov 2013 22:34:56 +0000 (17:34 -0500)]
PR16165: extend print_format::create
In an effort to restrict token creation, we change the
print_format::create() function to accept a string to denote the type of
print statement we want, rather than always deriving it from the token's
content. This allows us to skip the creation of tokens in a few places
that synthesize print statements.
- staptree.h: update print_format::create() declaration to accept new
parameter and add new member print_format_type
- staptree.cxx: update print_format::create() and use print_format_type
in print_format::print()
- elaborate.cxx: don't create token, use new parameter instead
- tapset-mark.cxx: ditto
- tapset-utrace.cxx: ditto
- tapsets.cxx: ditto
Josh Stone [Thu, 14 Nov 2013 01:46:22 +0000 (17:46 -0800)]
testsuite: Support prelink even on NFS paths
We had an issue that prelink would fail trying to restore selinux
context if the file is on NFS, e.g. for someone working in NFS $HOME.
It turns out prelink see nfs_t on the source, but isn't allowed to set
nfs_t on the destination (even though it will already be nfs_t).
Now we have a [prelink] proc for test to run prelink though a mktemp
file. The source is copied to tmp, prelinked, and copied back.
Josh Stone [Thu, 14 Nov 2013 01:04:19 +0000 (17:04 -0800)]
PR16162: Support .plt probes on prelinked libraries
There were a few bias issues in how plt addresses were handled, which
broke in the face of prelink offsets. This patch tries to standardize
how these addresses are handled.
* tapsets.cxx (query_plt_statement): New function to fix plt addresses,
both adding dwfl's elf bias and subtracting the dw bias, so it will
work with dwflpp::relocate_address like everything else.
(base_query::base_query): Leave session::consult_symtab alone!
(dwarf_query::query_module_symtab): PLT doesn't fake a path through
the symbol table anymore.
(dwarf_query::handle_query_module): Direct PLT to query_plt_statement.
(dwarf_query::add_probe_point): Remove the relocate exemption for plt.
* testsuite/systemtap.base/plt.exp: Update with a prelink test, and
refactor a lot of the test on the way.
Josh Stone [Wed, 13 Nov 2013 02:20:44 +0000 (18:20 -0800)]
stapdyn: warn on !isInstrumentable functions
The most common reason I've found that Dyninst won't allow us to
instrument a function is an indirect jump. This prevents them from
creating a control-flow graph, so they conservatively refuse.
Explicit indirect jumps are rare, like in the internals of longjmp, but
they may also occur for switches that are implemented with a jump table,
or tail calls to a vtable function, for instance.
Jonathan Lebon [Mon, 11 Nov 2013 17:19:35 +0000 (12:19 -0500)]
add mismatch_complexity
The mismatch_complexity variable allows us to only print out the most
complex kind of mismatch, and skip over simpler mismatches, in order to
keep the mismatch reporting as simple to understand as possible.
When assert_resolvability is false, mismatch_complexity simply remembers
the most complex mismatch we've met so far during each pass (e.g.
unresolved() is 0, mismatch(e) is 1, mismatch(tok, t1, t2) is 2, and
mismatch(tok, t, decl, index) is 3).
Once we turn on assert_resolvability, we check mismatch_complexity in
mismatch() and unresolved() to determine whether to print out an error
or not. If mismatch_complexity is higher than our own complexity, then
we don't print anything since we know that there is a better-suited
mismatch coming up.
Jonathan Lebon [Mon, 11 Nov 2013 17:05:42 +0000 (12:05 -0500)]
implement resolved() and mismatch() and use them
We finally complete the new function bodies. In resolved(), we add items
to the resolved_types vector, while in mismatch(), we retrieve from the
vector to print out exactly where the decl type was initially resolved.
Jonathan Lebon [Mon, 11 Nov 2013 16:34:39 +0000 (11:34 -0500)]
new resolved_type struct and mismatch/resolved functions
The resolved_type struct holds all the information about a newly
resolved decl. The token 'tok' holds where the resolution occurred, and
'index' is the position of the function-argument/array-index of the
decl.
The vector resolved_types will hold all the decls we resolve. A new
resolved() function is introduced which will add elements to the vector,
while an analogous mismatch() function will be used to report mismatches
between type and resolved decl.
* runtime/linux/uprobes-common.c (stap_uprobe_change_plus): The outer if
statement use curly braces to create a block, however the ending
curly brace ended up outside macro conditional.
David Smith [Fri, 8 Nov 2013 17:01:20 +0000 (11:01 -0600)]
Revert commit 65ddca0 since s390x can get get syscall arguments 7+.
* tapset/linux/nd_syscalls2.stp (nd_syscall.pselect7): Since the fix for
PR15913, s390x systems can get arguments 7 (and following) off the
stack. Revert commit 65ddca0 which hardcoded argument 7 to -1.
(nd_syscall.compat_pselect7): Ditto.
Josh Stone [Thu, 7 Nov 2013 23:30:42 +0000 (15:30 -0800)]
stapdyn: Tighten BPatch insertion sets
We were doing insertion sets in instrument_object_dynprobes(),
regardless of whether there was even a target match. This sometimes
triggers bad corner cases in Dyninst when the finalize tries to go do
things in a nascent process, with no action actually needed. While this
gets investigated in Dyninst, we can narrow down our insertion sets to
instrument_dynprobe_target(), where at least we know it's a match.
PR16132: staprun: fix fallback for openat/open modes for debugfs trace%d
Previous code got confused as to how many trace%d files to open and
where. Now we openat() only from the incoming staprun/stapio -F fd
directory, or open() right from /sys/kernel/debug/systemtap/..., with
no hanky panky between them.