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.
Josh Stone [Wed, 2 Sep 2009 23:14:08 +0000 (16:14 -0700)]
Unify lex_cast* and avoid string copies
We always use lex_cast either to string or from string, so I made that
explicit, and got rid of some string copies in the process. There was
also stringify(), which was redundant to lex_cast<string>.
We also always used lex_cast_hex to string, so that's now hard-coded and
again eliminated a string copy.
For lex_cast_qstring<string>, there's no need to write the streamify the
input, so a specialization now operates directly on the input.
Hopefully this is a bit cleaner, and I do measure it to be a little
faster on scripts with many probes.
Josh Stone [Tue, 1 Sep 2009 16:38:12 +0000 (09:38 -0700)]
PR10581: Use ARCH for tracepoints and kernel typequeries
These are kernel modules that we generate for querying debuginfo, so
they need to use the same ARCH settings that we put in the main script
module.
* buildrun.cxx (make_tracequery, make_typequery_kmod): Add the arch and
kbuild flags to make_cmd.
* hash.cxx (find_stapconf_hash, find_tracequery_hash,
find_typequery_hash): The arch is in the base hash already, but add
the kbuild flags too.
Josh Stone [Mon, 31 Aug 2009 22:22:33 +0000 (15:22 -0700)]
Use a header-cast in nd_syscall.sigaltstack
The nd_syscalls tapset is meant to run with no debuginfo, so using a
@cast into a module type defeats the purpose. We should use a @cast
with a header name instead, so debuginfo is generated.
* tapset/i386/nd_syscalls.stp (nd_syscall.sigaltstack): Get the pt_regs
type definition from "kernel<asm/ptrace.h>".
Mark Wielaard [Sat, 29 Aug 2009 14:49:44 +0000 (16:49 +0200)]
Fix overlapping statement probe error in warnings.stp.
Instead of generating a warning the current kernel.statement probe
produced a warning on some 386 kernels that had optimized that
particular line:
semantic error: multiple addresses for fs/bio.c:282
(try fs/bio.c:278 or fs/bio.c:284)
semantic error: no match while resolving probe point
kernel.statement("bio_init@fs/bio.c+3")
So do as told to just get the expected warnings for this probe.