Josh Stone [Fri, 18 Sep 2009 01:35:12 +0000 (18:35 -0700)]
Simplify the sdt semaphore decrement in utrace
The decrement can happen at the same time that the utrace detach is
called. However, I'm concerned that this code isn't correctly handling
the case where multiple tasks may register the same probe, so for now
I've noted those places. I think task finder may have to help in fixing
this...
* tapset-utrace.cxx (utrace_derived_probe_group::emit_module_init): As
noted in uprobes-land, there's no need to tear down anything.
(utrace_derived_probe_group::emit_module_exit): Unify the detach and
semaphore decrement, and note a concern about multiple tasks.
(utrace_derived_probe_group::emit_module_decls): Note same concern.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_decls): Ditto.
(uprobe_derived_probe_group::emit_module_exit): Ditto.
Josh Stone [Thu, 17 Sep 2009 23:37:36 +0000 (16:37 -0700)]
Map std semaphores from probe->addr
Each probe needs to know the associated semaphore address, rather than
the other way around.
* session.h (sdt_semaphore_addr): Reverse the key-value types.
* tapsets.cxx (record_semaphore): Take an index to only record the
semaphore for newly added results.
(sdt_query::handle_query_module): Adjust accordingly.
(uprobe_derived_probe_group::emit_module_decls): Now it's a simple map
lookup for sdt_sem_address.
* tapset-utrace.cxx (utrace_derived_probe_group::emit_probe_decl): Ditto.
Josh Stone [Thu, 17 Sep 2009 21:42:04 +0000 (14:42 -0700)]
Remove temporaries in netdev.change_mac
As reported by dsmith, reusing temporary locals will prevent our
limited optimizer from eliminating code. I'm getting rid of these
particular locals altogether.
* tapset/networking.stp (netdev.change_mac): Don't write mac
intermediates into locals; just pass them directly to sprintf.
Mark Wielaard [Thu, 17 Sep 2009 14:59:28 +0000 (16:59 +0200)]
Add a testcase for PR10417 support for DW_OP_{stack|implicit}_value.
Currently XFAILS when gcc-vta detected, otherwise UNTESTED.
* testsuite/systemtap.base/vta-test.exp: New test harness.
* testsuite/systemtap.base/vta-test.c: New test program.
* testsuite/systemtap.base/vta-test.stp: New test script.
Mark Wielaard [Thu, 17 Sep 2009 13:06:57 +0000 (15:06 +0200)]
PR10417 Pass around attributes for supporting DW_OP_{implicit,stack}_value.
Preparation for retrieving the Dwarf_Block that holds the value of an
DW_OP_implicit_value. We need the Dwarf_Attribute that is associated with
the location expression operants. Depends on new elfutils 0.143
functionality. Recognizes, but does not yet handle the new operants
DW_OP_{implicit,stack}_value.
* loc2c.h (c_translate_location): Take an Dwarf_Attribute.
* loc2c.c (c_translate_location): Likewise and pass it on.
(location_relative): Likewise.
(location_from_address): Likewise.
(translate): Likewise and capture Dwarf_Block.
* loc2c-test.c (handle_variable): Pass in Dwarf_Attribute.
* dwflpp.cxx (translate_location): Likewise.
(literal_stmt_for_return): Pass in NULL to indicate no attribute.
Mark Wielaard [Thu, 17 Sep 2009 10:20:07 +0000 (12:20 +0200)]
PR10595 Work around uprobe2 causing selinux failures for kernel 2.6.28+.
We allocate a "fake" unlinked shmem file because anonymous
memory might not be granted execute permission when the selinux
security hooks have their way. Only do this for 2.6.28 or higher
since shmem_file_setup() isn't exported before that.
* runtime/uprobes2/uprobes.c (uprobe_setup_ssol_vma): Use shmem_file_setup
to setup the ssol vma area when using 2.6.28+.
Josh Stone [Thu, 17 Sep 2009 02:38:20 +0000 (19:38 -0700)]
PR10461: Match C++ scopes for namespaces and classes
The function spec for dwarf probes now supports scopes, so you can limit
the probes to specific namespaces or classes. Multiple scopes can be
specified, and they will be matched progressively outward.
* dwflpp.cxx (dwflpp::get_parent_scope): New, finds the containing
scopes of the specified DIE.
(dwflpp::function_scope_matches): New, checks that the scopes
containing the function all match the given scope patterns.
* tapsets.cxx (dwarf_query::parse_function_spec): Rewrite, now handles
multiple scope separators too.
(query_dwarf_func): Check that the functions scopes match.
PR10650: markup some unprivileged-safe tapset functions
Add /* unprivileged */ to a variety of tapset embedded-c functions,
together with uid-assertion-checking code as needed. This is only
an initial set, and may need to grow or shrink after further testing.
Prototyped-By: Dave Brolley <brolley@redhat.com>
* runtime/runtime.h (is_myproc, assert_is_myproc): New macros.
* runtime/addr-map.c (lookup_bad_addr): Reject if !is_myproc
in unprivileged mode.
* runtime/print.c (_stp_print_kernel_info): Add unprivileged
mode info.
* tapset/DEVGUIDE: Document /* pure */ and /* unprivileged */.
* tapset/*.stp: Add /* unprivileged */ here and there, in
questionable cases along with an assert_is_myproc().
* testsuite/systemtap.base/flightrec1.exp: Add signal file switching testcase.
* testsuite/systemtap.base/flightrec4.exp: New test for signal file switching
with file number limits.
* testsuite/systemtap.base/flightrec5.exp: New test for signal file switching
with file number limits on bulk mode.
* runtime/staprun/relay_old.c (switch_oldoutfile): New function for file
switching.
(process_subbufs): Use switch_oldoutfile.
(reader_thread): Use ppoll() instead of poll() for receiving SIGUSR2
and switch output file when receiving a signal(SIGUSR2).
(switchfile_handler): Send SIGUSR2 signal to reader threads for file
switching.
(init_oldrelayfs): Assign switchfile_handler to SIGUSR2.
Signal-based file switching support for relay/ring buffer.
* runtime/staprun/relay.c (switch_outfile): New function for file switching.
(reader_thread): Don't assign empty_handler to SIGUSR2, and switch output
file when receiving signal(SIGUSR2) on ppoll.
(switchfile_handler): Send SIGUSR2 signal to reader threads for file
switching.
(init_relayfs): Assign switchfile_handler to SIGUSR2.
* staprun.1.in: Add FILE SWITCHING BY SIGNAL section.
Mark Wielaard [Wed, 16 Sep 2009 10:22:04 +0000 (12:22 +0200)]
Clean up dwflpp::translate_location workaround for DW_AT_data_member_location.
Do the same workaround as loc2c-test.c does. Just treat a constant member
location offset as a DW_OP_plus_uconst and call c_translate_location for it.
Also Remove c_translate_add_offset.
* dwflpp.cxx (dwflpp::translate_location): Check elfutils version and only
do workaround for elfutils < 0.142.
* loc2c.h (c_translate_add_offset): Removed.
* loc2c.c (c_translate_add_offset): Likewise.
Roland McGrath [Wed, 16 Sep 2009 08:57:39 +0000 (01:57 -0700)]
Clean up loc2c-test workaround for constant DW_AT_data_member_location.
* loc2c-test.c (handle_variable): Skip the workaround for elfutils 0.142.
When doing it, use a synthetic location expression.
Never use c_translate_add_offset, which is broken.
Josh Stone [Wed, 16 Sep 2009 01:15:20 +0000 (18:15 -0700)]
Remove function comparison from label iteration
We already have filtered functions and inlines, so just iterate in each
of those to look for labels.
* dwflpp.cxx (dwflpp::iterate_over_labels): Assume that the die we're
looking at is already a matching function, and don't descend into
inlined functions in this body.
* tapsets.cxx (query_srcfile_label): Iterate through inlines too.
(query_cu): Iterate over functions and inlines instead of the CU.
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
* 'master' of ssh://sources.redhat.com/git/systemtap: (34 commits)
Update the langref copyright notice
Fix some probe examples in the language reference
Remove automatic authorization of servers started by root as trusted signers.
docs: add abnormal termination section to PROCESSING
Remove unneeded header file
Get the module to sign from -p4's stdout
Move --unprivileged support news to the top.
Firther updates to NEWS regarding signing and unprivileged users.
Authorize new certificates created for servers started by root as authorized signers.
2009-09-14 Dave Brolley <brolley@redhat.com>
Allow remaining process.* probes for unprivileged users.
Use the sched_switch tracepoint if available.
PR10608: mark test cases untested once compilation failed
Make check.exp not sleep so much in test_installcheck.
Make tracepoints.exp test more efficient by running as one giant script.
Only test highest optimization for exelib.exp test.
Replace small exelib.exp testcases with one jumbo testcase.
Remove duplicate uprobe_derived_probe code
Add semaphores for use with the forthcoming sdt marker checks.
Add actual pc address to semantic error about inaccessible variables.
...
PR10642: fix wildcard-driven quadratic explosion of .return $$parms probes
For $variables listed in .return probes, a synthetic probe is being
created, for saving the named variable values at function entry. However,
the probe point for this synthetic probe was copied naively, so that
several problems could occur:
- if the original probe point contained wildcards, then each synthetic one
also did, and was therefore multiply derived later
- if the probe point referred to a multiply instantiated function, the
synthetic one was not directly identified with it (at the dwarf_addr level)
Now the synthetic probe is created more carefully, bypassing any further
derivation/expansion processing steps.
* tapsets.cxx (dwarf_var_expanding_visitor): Change add_probe to
add_call_probe field.
(visit_target_symbol_saved_return): Store only the body of the
synthetic probe.
(dwarf_derived_probe ctor): Create intimately related dwarf_derived_probe
for synthetic probe.
(uprobe_derived_probe ctor): Ditto.
Josh Stone [Tue, 15 Sep 2009 19:46:22 +0000 (12:46 -0700)]
Fix some probe examples in the language reference
* doc/langref.tex (section{Components of a SystemTap script}): Use
.call/.return for the example of tracing function entry/exit. Also
mention "-l" for listing probeable functions.
(subsection{Embedded C functions}): Close the examples with '%}'.
Josh Stone [Tue, 15 Sep 2009 00:43:51 +0000 (17:43 -0700)]
Get the module to sign from -p4's stdout
The saved stdout should have the exact name of the generated module,
which is better than using a recursive find to locate it. Tracepoints
and @cast may generate additional .ko's which we don't want to confuse
with the real deal.
* stap-server (create_response): grep stdout for the module name.
Mark Wielaard [Sun, 13 Sep 2009 21:37:28 +0000 (23:37 +0200)]
Make tracepoints.exp test more efficient by running as one giant script.
When there are lots of tracepoints in the kernel running a script
for each one individually can take several minutes. So run them all
in one giant script at the same time. Also increase timeout for
the stap -l collection step since with an empty cache that might
take more than the default 10 seconds.
* testsuite/systemtap.base/tracepoints.exp: Increase default timeout.
Collect all script fragments and run them as one.
Mark Wielaard [Sun, 13 Sep 2009 20:22:05 +0000 (22:22 +0200)]
Replace small exelib.exp testcases with one jumbo testcase.
Merge lib, mark, uname and ustack stp and tcl scripts into one large
libmarkunamestack stp and tcl script. But keep the individual tests
in case the large test fails and one wants to debug the individual steps.
Takes test time for exelib.exp down from 700 seconds to 200 seconds.
* testsuite/systemtap.exelib/libmarkunamestack.stp: New large stp script.
* testsuite/systemtap.exelib/libmarkunamestack.tcl: New large tcl script.
* testsuite/systemtap.exelib/exelib.exp: Use libmarkunamestack.
Josh Stone [Fri, 11 Sep 2009 21:58:50 +0000 (14:58 -0700)]
Remove duplicate uprobe_derived_probe code
Much of uprobe_derived_probe is a straight copy of dwarf_derived_probe,
and some of the comments even acknowledge this. I'm instead making this
an inheritance, so the duplication can be chopped away.
* tapsets.cxx (struct dwarf_derived_probe): Reorganize for inheritance.
(dwarf_derived_probe::dwarf_derived_probe): Adapt to handle process.
(struct uprobe_derived_probe): Inherit from dwarf_derived_probe and
remove duplicate members and methods.
(uprobe_derived_probe::emit_module_decls): Member name changes.
Josh Stone [Fri, 11 Sep 2009 00:06:11 +0000 (17:06 -0700)]
PR10594 cont'd: Use parent die cache for variable lookup
Variable lookup is usually done through the scopes from dwarf_getscopes
at a particular pc. This requires an expensive traversal to find the
inner-most die containing the pc. For cases where that containing die
is known, e.g. at a particular function entry, we can do much better
with our die_parent_cache.
This may also help get more accurate variable scopes in cases where
multiple dies contain a pc and the innermost isn't what we're trying to
probe. For example, an inlined call chain of foo->bar->baz may all have
the same entry pc, but if the probe was on function("bar"), we would
want the variables in bar's scope, not baz's.
* dwflpp.h (struct dwflpp): Remove pc_cached_scopes, num_cached_scopes,
and cached_scopes, as they are now remembered by the caller.
* dwflpp.cxx (dwflpp::getscopes): New - the DIE version uses the parent
cache, and the pc version just defers to dwarf_getscopes.
(dwflpp::print_locals, literal_stmt_for_local): Take a scopes vector.
(dwflpp::find_variable_and_frame_base): Take a scopes vector from the
caller instead of computing it every time.
(dwflpp::dwarf_getscopes_cached): Removed.
* tapsets.cxx (dwarf_var_expanding_visitor::getscopes): New cached
lookup function which gets the scopes from the DIE if possible.
(dwarf_var_expanding_visitor::visit_target_symbol): Call getscopes.
Josh Stone [Wed, 9 Sep 2009 22:45:28 +0000 (15:45 -0700)]
PR10594: Provide a cached dwarf_getscopes_die
This avoids repeated DIE traversal by caching all parents on the first
call, so future calls are just a simple walk up parent links.
* dwflpp.cxx (dwflpp::getscopes_die): New cached function that mimics
libdw's dwarf_getscopes_die using cached parent links.
(dwflpp::cache_die_parents): New function to build the parent cache.
(dwflpp::~dwflpp): Clean up the parent caches.
(dwflpp::iterate_over_labels): Use the cached getscopes_die.
(dwflpp::find_variable_and_frame_base): Ditto.
* tapsets.cxx (dwarf_derived_probe::saveargs): Ditto.
(uprobe_derived_probe::saveargs): Ditto.
(dwarf_var_expanding_visitor::visit_target_symbol_context): Ditto.
Fix relay_old implementation of fsize_max and fnum_max.
With old relayfs, out_fd is used only when non-bulk mode. However,
open_oldoutfile and open_relayfs_files open files with fopen and
set only percpu_tmpfile. This will cause a problem with -S option,
that out_fd will be closed when the file size reaches fsize_max
and new fd will be opened only on percpu_tmpfile.
So, out_fd should be synchronized with percpu_tmpfile.
* runtime/staprun/relay_old.c (open_oldoutfile): Set fd of output file
to out_fd[cpu].
(open_relayfs_files): Ditto.