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.
The general approach is to rip out task_finder_tgt's from all over the
place (including the unwindsym vmcbs, and the stap_uprobe_specs), and
instead have a small handful of them: one for all unwindsyms, and one
per abstract probed process (PID or NAME). These are in turn shared
by all new stap_unwind_specs by index.
Before: probe process("./stap").function("*")
-rw-r--r--. 1 fche users 11775283 2009-09-08 20:26 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko
text data bss dec hex filename
445158 8351944430647213103574 c7f1d6 /var/tmp/fche/systemtap/cache/96/stap_96c0479d674db55ec98d8a8750a790e7_7989596.ko
After: (Note how data shrank, though text gained a bit in const-init-data.)
-rw-r--r--. 1 fche users 4021569 2009-09-08 20:27 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko
text data bss dec hex filename 1896511 2192 43248086223511 5ef697 /var/tmp/fche/systemtap/cache/e4/stap_e46e88634efd850b1586e81c231c239a_8058419.ko
task_finder diagnostics: emit start_task_finder dbug message at end of fn.
* task_finder.c (stap_start_task_finder): Emit _stp_dbug message at end
rather at beginning, so printed utrace-engine attach counts reflect
status at end of initialization rather than at beginning.
* runtime/io.c (_stp_vlog): Don't put ansi highlighting into debugging
messages. #if STAP_DEBUG_PRINTK, direct all diagnostics to appropriate
printk channel instead of runtime trace buffer.
Mark Wielaard [Mon, 7 Sep 2009 15:06:27 +0000 (17:06 +0200)]
bz10475.exp: Use filp_open which has a constant const char argument for test.
For some reason the do_filp_open const char *pathname argument has changed
its name between different kernel versions. Luckily filp_open has a cont char
*filename argument that is constant between versions (the test needs a
const char* argument to do an array operation on).
* testsuite/semok/bz10475.stp: Use filp_open instead of do_filp_open.
Save offset of build id relative to _stext instead of absolute
address for kernel and apply relocations at run-time. This fixes
Debian bug #545277 (http://bugs.debian.org/545277).
Dave Brolley [Thu, 3 Sep 2009 21:19:05 +0000 (17:19 -0400)]
Disallow kernel space memory access when unprivileged.
2009-09-03 Dave Brolley <brolley@redhat.com>
* runtime/addr-map.c (lookup_addr_aux): Now takes size argument.
Consider the size when looking for overlapping range with the map
entries.
(lookup_bad_addr): Now takes size argument. Disallow kernel space access
when STP_PRIVILEGED is not defined. Pass size to lookup_addr_aux.
<asm/processor.h>: #include it when STP_PRIVILEGED is not defined.
(add_bad_addr_entry): Supply a size of 1 to calls to lookup_addr_aux.
* runtime/loc2c-runtime.h (kread): Pass sizeof (*(ptr)) to
lookup_bad_addr.
(kwrite): Likewise.
(deref): Pass size to lookup_bad_addr.
(store_deref): Likewise.
Josh Stone [Thu, 3 Sep 2009 18:32:59 +0000 (11:32 -0700)]
PR10573: Squash duplicate inline instances
In C++, identical functions included in multiple CUs will get merged at
link time into a single instance. We need to make sure that inlines
within those merged functions are not probed multiple times.
* tapsets.cxx (inline_instance_info::operator<): Used for set support.
(dwarf_query::handle_query_module): Clear inline_dupes on each module.
(query_dwarf_inline_instance): Squash this inline instance if it's
already in the inline_dupes set.
Josh Stone [Thu, 3 Sep 2009 02:09:50 +0000 (19:09 -0700)]
PR10572: Allow duplicate function names in a CU
We can't assume that a given function name will only appear once in a
CU. In C++, two functions may have the same name in different classes
or namespaces, or even in the same scope with overloaded parameters.
Even in C, the compiler may generate multiple copies of a single
function with different optimizations.
We now use a multimap for function names, so we shouldn't miss any.
* dwflpp.h (cu_type_cache_t, mod_cu_type_cache_t): New typedef to keep a
normal map for the global_alias_cache.
(cu_function_cache_t): Use a multimap for function names.
* dwflpp.cxx (dwflpp::iterate_over_functions): Walk over the range of
exactly-matching functions.
* tapsets.cxx (query_dwarf_func): Don't abort after seeing an exact
match -- there could be more to come.
Josh Stone [Wed, 2 Sep 2009 23:43:58 +0000 (16:43 -0700)]
Provide backward-compatible unordered_map/set
We were defining our own stap_map with a ::type to let us use typedefs
to use the new unordered_map if available, or hash_map otherwise. Since
unordered_map is the future direction, I'm changing our code to use that
directly. The backward-compatible version is a #define to hash_map,
which has a compatible interface.
While I'm at it, let's also define unordered_multimap, unordered_set,
and unordered_multiset.
* unordered.h: New.
* dwflpp.h (stap_map): Removed.
(cache typedefs): Use the unordered name now.