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.
David Smith [Fri, 27 Jul 2012 17:54:54 +0000 (12:54 -0500)]
Dyninst compile fixes for 32-bit systems.
* stapdyn/dynsdt.cxx (find_sdt): Fix printf types for 64-bit longs.
(instrument_sdt): Ditto.
* stapdyn/stapdyn.cxx (instrument_uprobes): Change type from 'uint64' to
'int64', since there are only signed 64-bit long BPatch_constExpr
constructors.
Compiling a script against a 3.4 ARM kerne with uprobes support results in a
compile error because struct linux_binprm is not defined. Including
linux/binfmts.h fixes the issue.
Josh Stone [Tue, 24 Jul 2012 22:02:13 +0000 (15:02 -0700)]
stapdyn: Don't check groups for --runtime=dyninst
We don't need to assert stapdev/stapusr group membership for the dyninst
mode, as users are simply allowed to probe anything ptrace-able. The
groups only apply to our kernel runtime.
David Smith [Tue, 24 Jul 2012 14:54:51 +0000 (09:54 -0500)]
More PR13455 (signalfd/compat_signalfd support in nd_syscalls2.stp) fixes.
* tapset/nd_syscalls2.stp: Fix nd_syscall.compat_signalfd probe
alias. Also fixed a dwarf variable reference in the
__nd_syscall.compat_signalfd4 probe alias.
David Smith [Tue, 24 Jul 2012 13:13:56 +0000 (08:13 -0500)]
Fixed PR13454 by updating pipe/pipe2 support in nd_syscalls.stp.
* tapset/aux_syscalls.stp (_fildes_index_u): Renamed from _fildes_u() and
reworked to return pipe fd values (instead of a string).
* tapset/nd_syscalls2.stp: Updated nd_syscall.pipe probe alias to handle
sys_pipe2().
* testsuite/systemtap.syscall/nd_syscall.exp (syscall_kfails): Removed
kfail for pipe test.
David Smith [Mon, 23 Jul 2012 19:20:38 +0000 (14:20 -0500)]
Fixed PR13455 by updating signalfd/compat_signalfd support in nd_syscalls2.stp.
* tapset/nd_syscalls2.stp: Updated nd_syscall.signalfd probe alias to
handle sys_signalfd4(). Updated nd_syscall.compat_signalfd probe alias
to handle compat_sys_signalfd4().
* testsuite/systemtap.syscall/nd_syscall.exp (syscall_kfails): Removed
kfail for signalfd test.
PR11207 groundwork: lexer::scan() produces tok_junk instead of throwing errors.
Handling parse_errors at scan time would get too complicated when there's
a preprocessing stage between the lexer and parser (and it's no longer
clear whether a given token will be used). Hence we produce specially marked
tok_junk which store a message to use when the token is encountered at
print_error() time.
David Smith [Fri, 20 Jul 2012 20:45:39 +0000 (15:45 -0500)]
Fixed PR13453 by updating inotify support in nd_syscalls.stp.
* tapset/nd_syscalls.stp: Updated nd_syscall.inotify_add_watch() to print
the mask argument as a string. Updated nd_syscall.inotify_init probe
alias to handle sys_inotify_init1().
* testsuite/systemtap.syscall/nd_syscall.exp (syscall_kfails): Removed
inotify kfail.
David Smith [Fri, 20 Jul 2012 15:33:06 +0000 (10:33 -0500)]
Fixed PR14378 by supporting @entry() in kprobe.function().return probes.
* tapsets.cxx (gen_mapped_saved_return): Removed from the
dwarf_var_expanding_visitor class. Also renamed the global variables
prefix from '_dwarf' to '_entry' (since now dwarfless kprobe probes
support @entry()).
(dwarf_var_expanding_visitor::gen_mapped_saved_return): Just calls
gen_mapped_saved_return().
(kprobe_var_expanding_visitor): New class.
(kprobe_derived_probe::kprobe_derived_probe): Uses
kprobe_var_expanding_visitor to support @entry().
* testsuite/semko/entry04.stp: New test.
* testsuite/semok/entry04.stp: Ditto.
Fix '@operator' parsing -- strictly enforce use of '@' in identifiers.
Generally, the language makes a policy of not allowing people to use '@'
inside arbitrary identifiers. The new test case gives an example of
behaviour that was still allowed by the parser's older scheme for
preventing this.
Identifiers beginning in '@' are now reclassified as tok_operator by the lexer.
Seems it's not always possible to avoid linux/types.h for the conflict
it presents with sys/select.h. Now include linux/types.h very early, so
glibc can stomp over it with #undef and #define, rather than vice versa.
Josh Stone [Wed, 18 Jul 2012 22:05:59 +0000 (15:05 -0700)]
PR14369: Fix locating SDT w/ $vars, w/o debuginfo
While current SDT can work without debuginfo, trying to use local $vars
still requires a look into DWARF. If that debuginfo is broken or
missing (as with asm probes), then we were reporting the probe entirely
absent, instead of just the $var broken.
This is undesirable if the $var access might have been optimized away,
or was part of a @defined check that should just get 0. So now we try
using debuginfo first, but if that fails go the direct route, and bad
$vars can be resolved or error in the normal way.
Josh Stone [Wed, 18 Jul 2012 21:09:05 +0000 (14:09 -0700)]
PR13934: When SDT args don't use N@OP, split on spaces
Assembly probes are not forced to use the N@OP form. In this case, N is
inferred to be the native word size. Since we don't have a nice
delimiter, just split it on spaces. SDT-asm authors then must not put
any spaces in arguments, to avoid ambiguity.
David Smith [Wed, 18 Jul 2012 18:30:59 +0000 (13:30 -0500)]
Fixed PR11424 by using System.map data to validate dwarfless kprobe probes.
* tapsets.cxx (kprobe_builder::load_function_name_cache): New function.
(kprobe_builder::build): Use parsed System.map data to validate
kprobe.function probe names.
PR14360, PR11207: clean up wildcard code in preparation for token-based macros.
in parse.cxx:
- get rid of ate_comment, enable "a" /* comment */ "b" string gluing
- add ate_whitespace to keep track of token adjacency
- restrict wildcard handling code to parse_probe_point()
- this is now handled by keeping the component tokens of the wildcard
separate, and gluing them together (conditional on adjacency)
Chris Meek [Thu, 12 Jul 2012 14:14:48 +0000 (10:14 -0400)]
BZ802380: Fixed logic issue and resource leak - Coverity
Coverity issues caught:
REVERSE_INULL
There were some logic issues in sdt_query::setup_note_probe_entry()
with a check for whether "name" was NULL after it was dereferenced,
as well as copying a couple possibly not '\0' terminated char *'s to
strings. These should now be fixed, and work as intended.
RESOURCE_LEAK
Also, there was a resource leak with ai_tvar_base in
dwarf_var_expanding_visitor::gen_mapped_saved_return(). That should
now also be fixed.