Josh Stone [Tue, 17 Mar 2009 01:36:44 +0000 (18:36 -0700)]
PR9951: Prevent GCC warnings in deref()
In some configurations, GCC was warning about a possible use of _v in
the deref macros. I could not reproduce the error, but the only case
where _v is not written is if lookup_bad_addr rejects the address, in
which case we will hit DEREF_FAULT and _v won't be used.
Now we're priming _v=0 anyway, so GCC has no right to complain...
Josh Stone [Tue, 17 Mar 2009 01:13:07 +0000 (18:13 -0700)]
Fix regression in tracepoint unregistration
Commit 96b030fe reorganized the tracepoint registration calls by
creating generic wrappers that return int. However, the older
tracepoint implementation (as found in RHEL5.3) returned void for unreg,
so this was failing pass-4.
Since we can't handle unregistration failures anyway, this change just
makes the generic unregister function return void instead. As noted in
the newly-added comment, it should be safe for us to ignore unreg
failures.
Mark Wielaard [Sun, 15 Mar 2009 14:29:01 +0000 (15:29 +0100)]
Move vma module tracking from pr6866 branch to master.
* tapsets.cxx (utrace_derived_probe_group::emit_module_decls):
Always emit vm callback probe for __stp_tf_vm_cb.
* runtime/task_finder.c (__stp_tf_vm_cb): Always expose, move _stp_dbug
statements under ifdef DEBUG_TASK_FINDER_VMA. Find and record
corresponding module when vm_path not NULL.
* runtime/task_finder_vma.c (struct __stp_tf_vma_entry): Add _stp_module.
(stap_add_vma_map_info): Add _stp_module argument and assign.
(__stp_tf_get_vma_entry_addr): New static function to get
the __stp_tf_vma_entry given an address.
Josh Stone [Fri, 13 Mar 2009 23:22:04 +0000 (16:22 -0700)]
Move lookup_bad_addr call in STAPCONF_PROBE_KERNEL
With most of the implementations, kread/kwrite call deref/store_deref,
and so it makes sense to have lookup_bad_addr in the latter as an
underlying address check.
However, in the STAPCONF_PROBE_KERNEL case that uses probe_kernel_read
and probe_kernel_write, the roles are reversed, so lookup_bad_addr needs
to be in kread/kwrite.
Also note that __deref_bad and __store_deref_bad should only be used in
cases that can be determined at compile time. These turn into invalid
symbols which prevent the module from loading. (They might be better
replaced with compile-time assertions.)
Josh Stone [Fri, 13 Mar 2009 00:12:38 +0000 (17:12 -0700)]
PR9947: move runtime cleanup out of the work queue
The kernel lockdep checking found a possible deadlock if a forced rmmod
tried to destroy _stp_work_queue at the same time that the work queue
was unregistering tracepoints. An unlikely scenario, but still
possible.
Now the work queue will just issue a STP_REQUEST_EXIT down to usermode,
and usermode will echo back an STP_EXIT that triggers the actual probe
cleanup. This way the unregistrations are happening in exactly the same
context as the registrations were.
Josh Stone [Thu, 12 Mar 2009 17:11:59 +0000 (10:11 -0700)]
Simplify tracepoint registrations
Instead of registering tracepoints with the deeply-nested if-tree, which
was cluttering the module_init/exit, this now emits normalized reg/unreg
functions for each tracepoint probes. Now the module_init/exit can be a
simple loop like all of the other probe types.
Josh Stone [Thu, 12 Mar 2009 03:30:58 +0000 (20:30 -0700)]
Add test to compile and run all tracepoints
This checks that kernel.trace("*") will compile, with all context
variables accessed as well. For kernels without tracepoints, it will
just hit a "begin" and quit.
This doesn't ensure that kernel.trace("*") will always find something
when it should, though...
Josh Stone [Thu, 12 Mar 2009 03:07:22 +0000 (20:07 -0700)]
Fix @cast module splitting
The new semok testcase exposed that the module splitting wasn't properly
setting substr boundaries. Instead of passing the end position, it's
supposed to pass the number of characters (end - begin). Oops.
Frank Ch. Eigler [Thu, 12 Mar 2009 02:11:09 +0000 (22:11 -0400)]
improve sdt.h compatibility and test suite
Replaced cpp VA_ARGS in sdt.h with explicit enumeration of arguments
(since with -pedantic, cpp has no varargs), and added a few more
cflags variants to the sdt.exp test case.
Rajan Arora [Wed, 11 Mar 2009 22:44:21 +0000 (18:44 -0400)]
PR 7071: Optional $context variables fix
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol):
Substitute erroneous target symbol with literal 0 if session level
flag, skip_badvars is set.
* session.h (struct systemtap_session):
New flag: skip_badvars.
* main.cxx:
Command line argument --skip-badvars added.
* stap.1.in:
Entry for new option --skip-badvars.
* NEWS:
Added blurb for new option now available.
* testsuite/semok/badvar.stp:
Test case to check added functionality.
Dave Brolley [Wed, 11 Mar 2009 16:12:16 +0000 (12:12 -0400)]
2009-03-11 Dave Brolley <brolley@redhat.com>
PR 9936
* stap-find-servers (configuration): Set timeout to 10 seconds.
(find_servers): Run avahi-browse in the background and wait for
$timeout seconds for it to finish. Kill it if it does not finish.
Use a temp file for avahi-browse output.
(match_server): Use -t $timeout on read commands.
* stap-start-server: Check for $server_pid as a running process and
for avahi-publish-service running as a child of $server_pid in order
to confirm that the server is running.
Josh Stone [Tue, 10 Mar 2009 22:46:21 +0000 (15:46 -0700)]
PR9932: use @cast module search path
The nfs, rpc, and scsi tapsets use @cast on types that may be compiled
into a kernel module or into the main kernel binary. The @cast search
path separated with colons lets us search both the kernel and the module.
For a couple of cases, I also merged sequential @casts that work just
fine as a single cast with a multiple-level dereference.
Josh Stone [Tue, 10 Mar 2009 22:32:16 +0000 (15:32 -0700)]
PR9932: add @cast module search path
Sometimes @cast()ing can fail if the type needed may or may not be
defined in a kernel module. This patch lets @cast take a colon-
separated list of modules to search for the type definition.
* tapsets.cxx (dwarf_cast_query): Simplify. Take the module and
the code result as reference parameters, and use code.empty() as
the sign that the type isn't resolved yet.
(dwarf_cast_expanding_visitor::visit_cast_op): Split e->module by
colon into substrings, and loop until the type is resolved.
Josh Stone [Tue, 10 Mar 2009 02:12:02 +0000 (19:12 -0700)]
Let -DINTERRUPTIBLE=0 mask interrupts in probes
Some time ago we loosened up the code for all probe types to allow
interrupts during the handler. However, when probing something like
kernel.trace("*"), you get a mix of probes in and out of the interrupt
path, and it becomes much more common to have probes skipped due to
interrupt reentrancy.
The common_probe_entryfn_prologue and common_probe_entryfn_epilogue
functions had an interruptible flag, but this was no longer used
anywhere. I removed this flag, but then reused the logic to check an
INTERRUPTIBLE macro instead. Now users can use -DINTERRUPTIBLE=0 to
prevent interrupt reentrancy in their script, at the cost of a bit more
overhead to toggle the interrupt mask.
Josh Stone [Tue, 10 Mar 2009 00:37:14 +0000 (17:37 -0700)]
Add tracepoint $$parms alias for $$vars
For parity with the DWARF probes, this makes tracepoints also define
$$parms, which has the same value as $$vars (since tracepoints are
missing the concept of $$locals).
Stan Cox [Sun, 8 Mar 2009 23:55:05 +0000 (19:55 -0400)]
Fix and add tests for function(".so").statement(N)
* tapsets.cxx (query_dwarf_func): die_has_pc (dwarf_haspc) does not expect a
module_start for shared objects so don't call module_address_to_global for the
statement address.
* testsuite/systemtap.base/labels.exp: Add tests for executable .statement(N),
shared object .label("L") and so .statement(N).
If stap is run with "-t -DDEBUG_REENTRANCY", additional warnings will
be printed for every reentrancy event, including the probe points of
the resident and interloper probes.
* tapsets.cxx (common_probe_entryfn_prologue): Add "new_pp" argument,
update all callers. Print reentrancy details if needed.
Josh Stone [Sat, 7 Mar 2009 03:30:39 +0000 (19:30 -0800)]
Ensure tracepoints are synchronized after unreg
The tracepoint API provides tracepoint_synchronize_unregister() as a way
to guarantee that all tracepoint handlers are inactive. This is
necessary after unregistering to allow the module to safely unload.
* tapsets.cxx (tracepoint_derived_probe_group::emit_module_init):
Call synchronize after unregistering tracepoints.
(tracepoint_derived_probe_group::emit_module_exit): Ditto.
Josh Stone [Fri, 6 Mar 2009 23:44:50 +0000 (15:44 -0800)]
Support older tracepoints using DEFINE_TRACE
At one point, the tracepoints API didn't have DECLARE_TRACE, and the
trace headers all used DEFINE_TRACE. This is what got pulled into RHEL,
so we need to support this older usage. The rest of the API stays the
same though.
* buildrun.cxx (make_tracequery): Redefine DEFINE_TRACE as well.
Josh Stone [Thu, 5 Mar 2009 05:07:54 +0000 (21:07 -0800)]
Enable tracepoint target variables
This uses a similar mechanism as marker probes for storing target
variables in locals of the probe body.
* tapsets.cxx (tracepoint_arg): Add fields to help $target access.
(tracepoint_var_expanding_visitor): Expand code to access target
variables - a $target for each tracepoint parameter, as well as
the special $$name and $$vars.
(tracepoint_derived_probe::tracepoint_derived_probe): Expand targets
(resolve_tracepoint_arg_type): Determine if a parameter is a type
that we can dereference, and store the underlying type.
(tracepoint_derived_probe::build_args): Resolve the types.
(tracepoint_derived_probe::emit_probe_context_vars): Emit $target
placeholders into the locals of the probe body.
(tracepoint_derived_probe_group::emit_module_decls): Initialize
$targets from the entry point parameters.
Josh Stone [Thu, 5 Mar 2009 04:32:22 +0000 (20:32 -0800)]
Emit code to hook up tracepoint probes
* tapsets.cxx (tracepoint_arg): New
(tracepoint_derived_probe): Add declaring header name and arg vector
(dwarf_type_name): Build a type string for a given type DIE
(tracepoint_derived_probe::build_args): Scan the function DIE for
the name and type of formal parameters required by the tracepoint.
(tracepoint_derived_probe::tracepoint_derived_probe): Call
build_args and determine the relevant header to include.
(tracepoint_derived_probe_group::emit_module_decls): For each
tracepoint, include its header and declare a probe entry point with
the right function signature.
(tracepoint_derived_probe_group::emit_module_init): Call the
registration for each tracepoint, and handle error unwinding.
(tracepoint_derived_probe_group::emit_module_exit): Unregister each.
Josh Stone [Thu, 5 Mar 2009 04:17:38 +0000 (20:17 -0800)]
Build skeleton tracepoint probes
* tapsets.cxx (tracepoint_derived_probe): Create a skeleton probe
(tracepoint_derived_probe_group): Create a skeleton group
(tracepoint_query::handle_query_func): build a probe
Josh Stone [Thu, 5 Mar 2009 03:56:02 +0000 (19:56 -0800)]
Scan tracequery.ko for tracepoints
* tapsets.cxx (tracepoint_query): Iterate over the modules, CUs, and
functions in tracequery.ko looking for our hijacked tracepoint
declarations.
(tracepoint_builder::build): Run a tracepoint_query
Josh Stone [Thu, 5 Mar 2009 03:32:25 +0000 (19:32 -0800)]
Build tracequery to scan for tracepoints
* session.h (systemtap_session): add tracepoint_derived_probes
* buildrun.cxx (make_tracequery): New - builds a kernel module that
hijacks the tracepoint declarations, so we can query debuginfo.
* buildrun.h: declare above
* tapsets.cxx (tracepoint_builder): New builder for tracepoint
probes. For now it just handles the initialization to build the
tracequery kernel module.