David Smith [Fri, 17 Aug 2012 18:31:24 +0000 (13:31 -0500)]
Fixed PR14463 by changing error handling of utrace_control().
* runtime/stp_utrace.c (utrace_barrier): Add a 'might_sleep()' call since
it calls schedule_timeout_interruptible(), which sleeps.
* runtime/linux/task_finder2.c (__stp_utrace_attach): Ignore
EINPROGRESS errors from utrace_control() when passed UTRACE_STOP, since
that just means the task hasn't stopped yet.
* runtime/linux/task_finder.c (__stp_utrace_attach_flags): Ditto.
Chris Meek [Wed, 15 Aug 2012 19:44:55 +0000 (15:44 -0400)]
PR11659: Hook into the panic_notifier_list
This feature lets stap dump the trace buffers to the serial console on a
kernel panic. The basic functionality is there, but it could use some
tweeking including adding a summary report at the end of the dump.
Currently it only works for the relay buffer V2.
Serguei Makarov [Wed, 15 Aug 2012 15:31:59 +0000 (11:31 -0400)]
PR14313: rewrite alias suffix example in langref.tex.
The rewrite avoids possible confusion due to the fact that there is
a syscall.read.return alias defined in the tapset (which changes how
the suffix is resolved in the real code vs. in the example with
only one custom syscall.read alias).
David Smith [Wed, 15 Aug 2012 15:11:12 +0000 (10:11 -0500)]
Fix PR14026 by updating the IP before calling the inode-uprobe handler.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_inode_decls): Fix
the IP before calling the real probe handler using
uprobe_get_swbp_addr().
* buildrun.cxx (compile_pass): Added
STAPCONF_UPROBE_GET_SWBP_ADDR_EXPORTED autoconf.
* runtime/linux/runtime.h: Add kallsyms_uprobe_get_swbp_addr declaration.
* runtime/linux/uprobes-inode.c: Ditto.
* runtime/transport/transport.c (_stp_transport_init): If
STAPCONF_UPROBE_GET_SWBP_ADDR_EXPORTED isn't defined, use
kallsyms_lookup_name() to find the address of 'uprbe_get_swbp_addr'.
David Smith [Tue, 14 Aug 2012 15:38:14 +0000 (10:38 -0500)]
Improve PR14463 by avoiding sleeping in the clone handler.
* runtime/linux/task_finder2.c (__stp_tf_alloc_task_work): Change
parameter to a void pointer.
(__stp_tf_clone_worker): New function.
(__stp_utrace_task_finder_report_clone): Uses stp_task_work_add() to
call __stp_tf_clone_worker() when we can safely sleep.
Josh Stone [Tue, 14 Aug 2012 01:32:40 +0000 (18:32 -0700)]
PR14396: Truncate UTF strings silently
The UTF-16 and UTF-32 conversion functions were correctly refusing to
write a partial UTF-8 sequence into the buffer, but they were treating
that case as an error. It should just silently stop processing, so the
result is truncated just as any other string concatenation does.
* tapset/linux/conversions.stp (kernel_string_utf32): Treat only rc<0
from _stp_convert_utf32 as an error; rc==0 is truncation.
(kernel_string_utf16): Ditto.
* tapset/linux/uconversions.stp (user_string_utf32): Ditto.
(user_string_utf16): Ditto.
* testsuite/systemtap.base/utf_kernel_trunc.*: Test a broad range of
truncation points within kernel UTF strings.
* testsuite/systemtap.base/utf_user_trunc.*: Same test for userspace.
(The duplication is unfortunate, but it's not too crazy.)
Josh Stone [Mon, 13 Aug 2012 22:45:23 +0000 (15:45 -0700)]
Don't report non-git if we have an extra-version
When we're not building from git, but we do have --with-extra-version,
just let that suffice in our version strings. But when we do have a git
repo, still print the fullest information possible.
* version.h: Define STAP_EXTENDED_VERSION with this scheme.
* session.cxx, stapdyn/stapdyn.cxx, staprun/common.c: Use it.
Frank Ch. Eigler [Mon, 13 Aug 2012 00:05:46 +0000 (20:05 -0400)]
PR14460 try 1
Switch to tcl's [socket HOST PORT] facilities as a netcat client
substitute. Except tcl 8.5* doesn't speak ipv6 jive. Also, switch to
port 8079 for tests, expecting to conflict less with normal ongoings
than good old 8080.
Josh Stone [Sat, 11 Aug 2012 00:46:13 +0000 (17:46 -0700)]
PR14396: Add pretty-printing support for UTF
* dwarf_wrappers.h: Define DW_ATE_UTF if elfutils < 0.155.
* tapsets.cxx (dwarf_pretty_print::recurse_base): Print UTF with %#c
too. This will generally only work with the ASCII subset for now...
(dwarf_pretty_print::print_chars): Match strings by char/UTF encoding
types, rather than by type name, and use the byte_size to select the
correct string dereferencing function.
* testsuite/systemtap.base/utf_pretty.*: Test it!
Josh Stone [Fri, 10 Aug 2012 22:15:29 +0000 (15:15 -0700)]
PR14396: Add UTF-16/32 conversion functions
* runtime/stp_string.c (_stp_convert_utf32): New, write the given
UTF-32 code point as UTF-8 in the given buffer.
* tapset/linux/conversions.stp (kernel_string_utf32): New, read and
convert a UTF-32 string from kernel memory.
(kernel_string_utf16): Same for UTF-16, handling surrogate pairs.
(kernel_string2_utf32, kernel_string2_utf16): Same w/ custom error.
* tapset/linux/uconversions.stp: All of the above for user memory.
* testsuite/buildok/conversions*.stp: Add build tests.
* testsuite/systemtap.base/utf_*: New runtime tests.
Josh Stone [Fri, 10 Aug 2012 21:50:41 +0000 (14:50 -0700)]
loc2c-runtime.h: Add uread() and uwrite()
These are the userspace equivalents to kread() and kwrite().
For the (unused) STAPCONF_PROBE_KERNEL case, just define them as direct
equivalents. Also add in missing kderef and store_kderef the same way.
For the architecture-implemented case, they are nearly identical to
kread and kwrite, just s/kderef/uderef/. So to avoid duplication, I've
added in a layer of macro indirection to pass in the appropriate deref
function. (Nevermind that the [ku]derefs are often identical -- oh,
what a tangled web we weave...)
David Smith [Fri, 10 Aug 2012 13:39:51 +0000 (08:39 -0500)]
Improve task_finder/task_finder2 error handling.
* runtime/linux/task_finder.c (stap_start_task_finder): When we ignore
EPERM or ENOENT errors, be sure to not accidently return the ignored
error.
* runtime/linux/task_finder2.c (stap_start_task_finder): Ditto.
David Smith [Tue, 7 Aug 2012 22:32:01 +0000 (17:32 -0500)]
Fix problems with varargs macros in dyninst/io.c.
* runtime/dyninst/io.c: Convert _stp_warn(), _stp_error(),
_stp_softerror(), and _stp_dbug() from varargs macros into varargs
functions so that calling _stp_warn() (for example) with just a format
argument works correctly.
Josh Stone [Tue, 7 Aug 2012 19:24:18 +0000 (12:24 -0700)]
parse: Fix a -Werror=delete-non-virtual-dtor
CXX stap-parse.o
../parse.cxx: In destructor ‘parser::pp1_activation::~pp1_activation()’:
../parse.cxx:421:16: error: deleting object of polymorphic class type
‘parser::pp_macrodecl’ which has non-virtual destructor might cause
undefined behaviour [-Werror=delete-non-virtual-dtor]
cc1plus: all warnings being treated as errors
We need virtual ~macrodecl to destroy the inherited pp_macrodecl.
Josh Stone [Tue, 7 Aug 2012 00:46:38 +0000 (17:46 -0700)]
stapdyn: Enable map and stat types
There are a lot of kernel-isms in the map code especially, and rather
than try to rewrite all that, I've simply copied the necessary bits from
the kernel. The new pieces are mostly list and hash related.
* runtime/dyninst/alloc.c (_stp_alloc_percpu): Needs to be zeroed.
* runtime/dyninst/runtime.h: Add BITS_PER_LONG and stap_hash_seed.
Also extract various bits copied from the kernel into new files.
* runtime/dyninst/linux_types.h: Reused Linux type definitions.
* runtime/dyninst/linux_defs.h: Other various reused Linux code.
* runtime/dyninst/linux_hash.h: Direct copy of hashing from Linux.
* runtime/dyninst/ilog2.h: Linux's ilog2(), but just for constants.
* runtime/dyninst/probe_lock.h: Typedef rwlock_t on pthreads.
* runtime/map.c: Don't need sym.c, and emulate ALIGN().
* runtime/map.h: Locate ilog2, and fix NEED_MAP_LOCKS check.
Mark Wielaard [Mon, 6 Aug 2012 18:31:20 +0000 (20:31 +0200)]
PR14434 Filter out partial structs/classes.
GCC might generate a struct/class without DW_AT_declaration,
but that only contains members which have DW_AT_declaration
set. We aren't interested in those. PR14434 (GCC bug #54181).
Filter them out with a new function has_only_decl_members in dwflpp.cxx.
Add new testcase testsuite/systemtap.base/partial-class-type.exp.
Josh Stone [Mon, 6 Aug 2012 20:14:00 +0000 (13:14 -0700)]
spec: Don't use %dir for paths that are fully included
We were getting these messages from rpmbuild:
warning: File listed twice: /usr/share/systemtap/runtime
warning: File listed twice: /usr/share/systemtap/tapset
Those two paths included entirely in systemtap-devel, so the %dir
directive is redundant. However, it should claim %{_datadir}/%{name}
which those two are under.
Josh Stone [Sat, 4 Aug 2012 20:40:27 +0000 (13:40 -0700)]
PR14432: Convert stap exit() calls to exceptions
We need the opportunity to clean up after ourselves, for example
removing any temporary directories created. Calling exit() bypasses our
usual exception/RAII-based cleanups, so don't do that.
* session.h (exit_exception): New, an exception with a custom exit code.
* main.cxx (main): We can simply return here. Also catch exit_exception.
* session.cxx (systemtap_session::usage): Throw an exit_exception.
(systemtap_session::parse_cmdline): Ditto.
* util.cxx (assert_regexp_match): A runtime_error makes more sense here.
Josh Stone [Fri, 3 Aug 2012 01:56:54 +0000 (18:56 -0700)]
stapdyn: TODO updates
- Build integration is in good shape, removing
- Runtime is largely done, but some cleanup left (PR14179)
- Breaking up the tapsets is pretty much done (PR14180)
- New: really need a deref() mechanism
- New: need to rework stapdu_target
Josh Stone [Thu, 2 Aug 2012 19:38:27 +0000 (12:38 -0700)]
PR14180: Fix tapset documentation for non-root tapsets
* doc/SystemTap_Tapset_Reference/manpager: Use basenames so we can deal
with tapsets that are from a subdirectory, like tapset/linux/.
* doc/SystemTap_Tapset_Reference/tapsets.tmpl: Update !I paths for the
many tapsets that moved in commit d3110553.
* tapset/linux/context.stp: Defer <tapsetdescription> to tapset/context.stp
Serguei Makarov [Thu, 2 Aug 2012 18:04:40 +0000 (14:04 -0400)]
PR11207: search tapset folders for .stpm files.
Gathers a list of .stpm (library) files on the tapset search
path. In this patch, an index of the paths is gathered in
session.library_macro_paths, but the list is not made use of by the
preprocessor.
Josh Stone [Thu, 2 Aug 2012 17:55:57 +0000 (10:55 -0700)]
stapdyn & staprun: Use the top-level git_version.h
Yo dawg, I herd you like Makefile recursion, so I put some recursion in
your recursion so you can version while you version.
Less duplication + more recursion == win? Another option is to flatten
stapdyn and staprun Makefiles altogether into the root Makefile, but for
now, this is less invasive.
Changing the includes to ../git_version.h is not strictly necessary,
since we also have "-I..", but this way developers won't get burned by
old git_version.h files sitting in staprun/ or stapdyn/.
Josh Stone [Thu, 2 Aug 2012 17:24:42 +0000 (10:24 -0700)]
PR14378: Better @entry squashing in kprobe.function
@entry is only valid in .return, but kprobe_var_expanding_visitor was
expanding it blindly. Then kprobe_derived_probe was failing its
assertion that add_call_probe only happens with has_return. So the test
semko/entry04.stp was failing as it should, but rather ungracefully with
an "Assertion `has_return' failed" abort.
* tapsets.cxx (kprobe_var_expanding_visitor): Add a has_return member so
we know our current context.
(kprobe_var_expanding_visitor::visit_entry_op): Guard @entry expansion
on has_return, the same way dwarf_var_expanding_visitor does.
David Smith [Thu, 2 Aug 2012 15:01:23 +0000 (10:01 -0500)]
Fixed PR14427 by handling old and new task_work interface.
* runtime/linux/autoconf-utrace-via-tracepoints.c: Just includes
task_work.h to determine existence of task_work feature.
* runtime/linux/autoconf-task_work-struct.c: New file.
* buildrun.cxx (compile_pass): Add autoconf-task_work-struct test.
* runtime/linux/task_work_compatibility.h: New header that mask
differences between old task_work interface and new one.
* runtime/linux/task_finder2.c: Handle removal of 'data' parameter from
task_work struct by embedding stap_task_finder_target in
__stp_tf_task_work structure.
* runtime/stp_task_work.c: Include task_work_compatibility.h instead of
task_work.h.
* runtime/stp_utrace.c (utrace_task_alloc): Update init_task_work()
function call to compatibility function call.
Josh Stone [Thu, 2 Aug 2012 02:26:01 +0000 (19:26 -0700)]
PR14180: Doing the tapset shuffle!
Many tapsets are kernel-specific, with no applicability at all
from userspace. These have all been moved to tapset/linux/.
Some tapsets could be widely applicable, but are implemented with
kernel-specific APIs. These have been moved to tapset/linux/, and
reimplemented in tapset/dyninst/ too.
Some tapsets are generic utility functions, that don't care at
all where they're run from. These have been left in place.
Josh Stone [Tue, 31 Jul 2012 02:56:18 +0000 (19:56 -0700)]
Range-check _fildes_index_u and test it
* tapset/linux/aux_syscalls.stp: Make sure the index is 0 or 1.
* testsuite/buildok/aux_syscalls-embedded.stp: Test _fildes_index_u()
rather than the old, removed _fildes_u().
Josh Stone [Tue, 31 Jul 2012 02:34:43 +0000 (19:34 -0700)]
PR14180: Move all syscall tapsets to linux/
Moving basically all *syscall*.stp into tapset/linux/. These are all
implemented from a kernel assumption, using either kernel.function or
kprobe.function, and the supporting functions also assume that they're
being called from a kernel environment.
Josh Stone [Tue, 31 Jul 2012 00:34:02 +0000 (17:34 -0700)]
PR14180: Search for tapset in additional backend-specific paths
We already search paths in many combinations of kernel version and arch.
For each of these, search also in runtime-specific prefixes, "linux/..."
for kernel mode, and "dyninst/..." for dyninst mode. (And while we're
at it, only do kernel versioning for kernel mode.)
PR11207: support for one-line @define in macroprocessor.
Current logic for determining whether to grab a one-line or
a multi-line macro is a bit hairy but well-tested. May go through
it later with a fresh eye to streamline at least the explanatory
comments.
Josh Stone [Sat, 28 Jul 2012 16:55:10 +0000 (09:55 -0700)]
parse: Separate "empty or missing" file errors
... especially since there's a third state too: unreadable.
* parse.cxx (parser::parser): Consolidate to a single ctor.
(parse<istream>): Synthesize the name "<input>" to the parser from here.
(parse<filename>): Open the file first, check its status, and if good
only then pass the name and ifstream to the parser.
(parser::parse): Now here the file is never missing, just empty.
Josh Stone [Fri, 27 Jul 2012 21:30:31 +0000 (14:30 -0700)]
stapdyn: Try to autodetect DYNINSTAPI_RT_LIB
* stapdyn/dynutil.cxx (check_dyninst_rt): New file; Check that env
DYNINSTAPI_RT_LIB is well set, else guess a good value for it.
* stapdyn/stapdyn.cxx (main): Call check_dyninst_rt().
* stapdyn/dynsdt.cxx (main): Ditto.
* stapdyn/Makefile.am: Build dynutil.cxx and ../util.cxx.
* stapdyn/Makefile.in: Regenerate.