The kmodule.stp test case could evoke a double-free of module-info
structs, since these were shared pointers, and not managed by GC.
Oh yeah, what GC, in the year 2010.
* dwflpp.cxx (dwflpp dtor): Don't delete shared mod_info ptr.
(module_cache dtor): New function.
* dwflpp.h: Declare.
* tapsets.cxx (delete_session_module_cache): New function.
(several::build_no_more): Call it.
(dwarf_build_no_more): Use delete_map<> template.
David Smith [Mon, 1 Nov 2010 20:37:23 +0000 (15:37 -0500)]
Improved fork/vfork tests for RHEL5.
* testsuite/systemtap.clone/dtrace_fork_exec.exp: Improve output string to
handle parent/child execution order differences.
* testsuite/systemtap.clone/dtrace_vfork_parent.c: Added include files to
avoid compile error on RHEL5.
* testsuite/systemtap.clone/dtrace_vfork_parent.c: Ditto.
David Smith [Mon, 1 Nov 2010 20:32:57 +0000 (15:32 -0500)]
Improve handling of vfork'ed processes for uprobes version 1.
* runtime/uprobes/uprobes.c (insert_bkpt): Don't log EEXIST errors (since
systemtap inserts duplicate probes).
(uprobe_report_exec): Only cleanup if this is the last thread. Without
this change, vfork'ed processes doing an exec weren't handled correctly.
Frank Ch. Eigler [Thu, 28 Oct 2010 22:42:35 +0000 (18:42 -0400)]
PR12169: fix tokenize()
* tapset/tokenize.stp: New file for tokenize(). Use per-context statics.
* doc/SystemTap_Tapset_Reference/tapsets.tmpl: Pull it into new docs.
* tapset/string.stp: Remove old tokenize() code.
* translate.cxx (emit_common_header): Add STAP_NEED_CONTEXT_TOKENIZE bits.
(translate_pass): Emit global %{ %} embeds before context definition.
Frank Ch. Eigler [Thu, 28 Oct 2010 17:31:26 +0000 (13:31 -0400)]
tracepoints: restore access to include/trace/event/* points w/o debuginfo
An earlier commit impeded access to kernel tracepoints that are
defined in the proper header files, but lacking the debuginfo
for the backup searching widget to work.
* tapsets.cxx (tracepoint_derived_probe_group::emit_module_decls):
Remove "include/" substring from header files.
David Smith [Thu, 28 Oct 2010 15:36:39 +0000 (10:36 -0500)]
Improve handling of vfork'ed processes.
* runtime/uprobes2/uprobes.c (insert_bkpt): Don't log EEXIST errors (since
systemtap inserts duplicate probes).
(uprobe_report_exec): Only cleanup if this is the last thread. Without
this change, vfork'ed processes doing an exec weren't handled correctly.
Josh Stone [Wed, 27 Oct 2010 20:12:08 +0000 (13:12 -0700)]
Don't treat hashed numbers like strings
Valgrind noted that we were reading uninitialized memory in __GI_strlen,
and I tracked this down to our treating a number value as a char buffer,
leading to "parm_stream << [&number]". Since it isn't a NULL-terminated
buffer, this runs away on the stack.
* hash.cxx (hash::add): Change all the numeric variants to a template,
which lets operator<< figure the right thing for parm_stream, and then
pass the raw value to mdfour.
PR6456: support wildcards in process("/bin/*") probes
* tapsets.cxx (dwarf_builder::build): For process probes, detect
and expand glob patterns via synthetic aliases.
* util.* (contains_glob_chars): New function.
* tapsets.cxx (tracepoint_builder::init_dw): Throw error if glob(3) failed.
Josh Stone [Thu, 21 Oct 2010 02:37:30 +0000 (19:37 -0700)]
A few further pfiles tweaks
- Handle device numbers that are (0,0).
- Add kreads on a few __retvalue assignments.
- Add kreads for getting sock->ops.
- Remove kreads from socket functions that are using the stack.
Josh Stone [Wed, 20 Oct 2010 23:47:55 +0000 (16:47 -0700)]
Build SDT's derived_loc more precisely
This refactors how the derived_loc is created, in a way that I think
will get better results. For example, the kprobe variant doesn't have
to try and delete components that don't apply. Also, the provider
component is now wildcard-expanded for probe listing.
* tapsets.cxx (sdt_query::convert_location): Build up components for
derived_loc from scratch, rather than trying to rewrite a copy.
Josh Stone [Wed, 20 Oct 2010 22:03:49 +0000 (15:03 -0700)]
PR12137: Separate the .stapsdt.base logic from probe asm
This splits the SDT probes into two __asm__ statements, one for the
probe itself, and the other for logic to prepare the .stapsdt.base
section. This avoids having a string literal that is too long for
-pedantic compilation (max length 509).
* includes/sys/sdt.h: Define _SDT_ASM_BASE for .stapsdt.base logic,
separate from _SDT_ASM_BODY, and add to _SDT_PROBE and STAP_PROBE_ASM.
Frank Ch. Eigler [Wed, 20 Oct 2010 15:27:59 +0000 (11:27 -0400)]
PR10745: access hidden kernel tracepoints
A bunch of kernel tracepoints have been declared outside the conventional
include/linux/trace/* hierarchy, and left in the source tree only. By
searching the source tree with some additional glob patterns, we can find
them and generate debuginfo the usual way. On Fedora/RHEL, this means
looking through debuginfo to find the DW_AT_comp_dir (compilation source
directory), which is something like /usr/src/debug/kernels/FOO/BAR/.
Nearly all tracepoints appear now accessible under RHEL6/F13 era kernels:
% ls -1 /sys/kernel/debug/tracing/events/*/*/id |
cut -f8 -d/ | egrep -v 'sys_(enter|exit)' |
while read tp
do
stap -L 'kernel.trace("'$tp'")' || echo no $tp
done
reports no "no"s. Note that syscall tracepoints are treated specially
in the kernel; stap sees only a single sys_enter / sys_exit pair, thus
the egrep -v above.
* session.h (kernel_source_tree): New field.
* buildrun.cxx (compile_pass, make_tracequery): Add EXTRA_CFLAGS += -I....
(make_tracequery): Squish repeated TRACE_INCLUDE_PATH defines.
* tapsets.cxx (tracepoint_derived_probe ctor): Relax conventions
on tracepoint header file name.
(tracepoint_extra_headers): Renamed to ...
(tracepoint_extra_decls): New function. Include struct/type forward
decls as needed.
(emit_module_decls): Use new decl list style.
(tracepoint_builder::init_dw): Search kernel source tree also for
tracepoint headers.
Josh Stone [Tue, 19 Oct 2010 19:20:24 +0000 (12:20 -0700)]
PR12121: distinguish struct/typedef homonyms
For example:
typedef struct foo foo;
foo x;
This kind of "repeated" typedef used to cause bad things for us if the
struct definition is not in the current CU. When resolving $x->bar, we
start at the typedef-foo and dereference to the struct-foo. That's just
a declaration, so we use declaration_resolve to look for the struct
definition. But since we were looking by the name "foo" only, we would
find the typedef again, getting us nowhere.
The fixed code does declaration_resolve on "struct foo" in the global cache,
so in this case we won't find anything locally, and thus we continue looking
in other CUs. If the definition isn't found elsewhere, we're stuck anyway.
* dwflpp.cxx (dwflpp::global_alias_caching_callback): Cache type names
with a relevant prefix: struct, union, etc. Classes are normalized to
be "struct" too, as that's a very blurry line.
(dwflpp::declaration_resolve(die)): New variant to resolve a specific
die -- used so we know what exact prefix we should look for.
* parse.cxx (parser::parse_target_symbol): Don't strip the prefix from
@cast types anymore, so the user can be precise about what they want.
* tapsets.cxx (dwarf_cast_query::handle_query_module): Normalize "class"
to "struct". If the user provides a bare name that fails to resolve,
then try it again with the various prefixes.
* testsuite/systemtap.base/unresolved-struct-typedef.*: New test.
Dave Brolley [Mon, 18 Oct 2010 16:17:55 +0000 (12:17 -0400)]
PR 11442: Tests for adding/revoking trust as a module signer.
These tests alter the state of the trusted signer database which is
in the install tree, and thus should not be run when the test suite
is invoked as root. The related tests which depend on these tests
are still run, but are marked as XFAIL in this situation.
Lukas Berk [Thu, 14 Oct 2010 21:07:28 +0000 (17:07 -0400)]
pr 11554 further documentation to the SYSTEMTAP_DEBUGINFO_PATH; where it looks for vmlinux, how to set it, and more information about debuginfo for user-space applications.
Dave Brolley [Wed, 13 Oct 2010 20:17:00 +0000 (16:17 -0400)]
PR 11922: Still need to resolve host names discovered using avahi.
SSL requires that the client's connection be set up with an expected DNS name
which must match one of the names on the server's certificate. This is
the only protection from 'man in the middle' attacks. The server generates
it certificate to contain its own host name. <name>.local as returned by
avahi must be resolved in attaempt to match what's on the certificate.
Dave Brolley [Tue, 5 Oct 2010 18:25:20 +0000 (14:25 -0400)]
Miscellaneous improvements.
- break out starting of a server into start_server to be used by
setup_server and elsewhere.
- call cleanup before exiting if smoke tests fail.
- cleanup *.sgn files.
Dave Brolley [Mon, 27 Sep 2010 16:03:39 +0000 (12:03 -0400)]
PR 11922: Restrict compile-server client attempts to resolve server hosts.
Most times we can get the proper host name/ip address from avahi or from
certificates in our databases. Only attempt to resolve hosts for servers
specified directly using --use-server.
David Smith [Tue, 5 Oct 2010 21:52:30 +0000 (16:52 -0500)]
Run clone/fork/vfork tests with and without semaphores.
* testsuite/systemtap.clone/dtrace_clone.exp: Run the test twice - once
without semaphores, once with semaphores.
* testsuite/systemtap.clone/dtrace_fork_exec.exp: Ditto.
* testsuite/systemtap.clone/dtrace_vfork_exec.exp: Ditto.
* testsuite/systemtap.clone/test_progs.tcl: Automatically run "make clean"
when needed. Allow callers to specify extra CFLAGS values.
* testsuite/systemtap.clone/dtrace_child.c: Allow semaphores to be
ifdef'ed out.
* testsuite/systemtap.clone/dtrace_clone.c: Ditto.
* testsuite/systemtap.clone/dtrace_fork_parent.c: Ditto.
* testsuite/systemtap.clone/dtrace_vfork_parent.c: Ditto.
* testsuite/systemtap.clone/Makefile.fork_exec: Removed unused define.
* testsuite/systemtap.clone/Makefile.vfork_exec: Ditto.
David Smith [Tue, 5 Oct 2010 21:07:31 +0000 (16:07 -0500)]
In the syscall.*utime probes, get values directly.
* tapset/syscalls2.stp (syscall.utime): Instead of calling a function to
get actime/modtime, use user_long() to get the value.
(syscall.compat_utime): Ditto.
Josh Stone [Tue, 5 Oct 2010 00:56:26 +0000 (17:56 -0700)]
PR11739: Add an STP_ALIBI flag
Primarily just for testing purposes, define STP_ALIBI to shortcut all
probe handlers, so they're nothing but an atomic_inc. It prints a hit
report similar to STP_TIMING at the end.
Note that any logic that would have called exit() will also be blocked,
so you need other ways to end the script: SIGINT, finished -c, etc.
* tapsets.cxx (common_probe_entryfn_prologue): #ifdef STP_ALIBI, reduce
the probe handler to just an atomic_inc().
(common_probe_entryfn_epilogue): Close the #ifdef from above.
* translate.cxx (translate_pass): Add an atomic_t to stap_probe for
STP_ALIBI to track probe hits.
(c_unparser::emit_module_exit): Print alibi hit-report.
David Smith [Mon, 4 Oct 2010 20:46:38 +0000 (15:46 -0500)]
Fixed BZ634242 for older kernels.
* runtime/uprobes/uprobes.c (uprobe_report_clone): If two processes are
are sharing the same memory space (CLONE_VM) don't remove probes, since
that will remove the probes from both processes.
Josh Stone [Mon, 4 Oct 2010 19:26:30 +0000 (12:26 -0700)]
PR12081: Name procfs buffers based on a local index
We shouldn't use probe->name for the buffers, as that name is not
necessarily unique after our probe de-duplication efforts. Instead, we
can use a simple index variable to get a unique name for each procfs probe.
* tapset-procfs.cxx (procfs_derived_probe_group::emit_module_decls):
Declare and use the buffers with a name based on a simple index.
David Smith [Mon, 4 Oct 2010 15:45:36 +0000 (10:45 -0500)]
Small kprobes_test updates.
* scripts/kprobes_test/run_module.py: Improved waiting on spawned load
commands. Makes 30 attempts to find output (instead of trying
forever).
* scripts/kprobes_test/.gitignore: Ignore 'Module.markers' file and config
files.
* scripts/kprobes_test/kprobes_test.py: Minor update.
Josh Stone [Fri, 1 Oct 2010 23:41:19 +0000 (16:41 -0700)]
Replace kretprobe->entry_ph with a full stap_probe
This ensures that pp, pn, and STP_TIMING can be kept distinct for entry
handlers vs. their normal kretprobe handlers.
* tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Replace
entry_ph with entry_probe, pointing to the global stap_probes[], and
update all references.
Josh Stone [Fri, 1 Oct 2010 22:47:45 +0000 (15:47 -0700)]
Centralize stap_probe, and make STP_TIMING data-driven
With the move to per-probe_point STP_TIMING statistics, the design which
wrote a separate code block for every Stat suddenly ran into scalability
issues. We should instead be using a data-driven loop for this.
So, the scattered stap_probe structs are now pulled together in one
global, stap_probes[]. This contains the usual suspects: ph, pp, and pn;
it also keeps the extras that STP_TIMING needs: a Stat, the script
location, and the derivation record.
* translate.cxx (translate_pass): Add the STP_TIMING data to stap_probe,
and output the global stap_probes[] with everything.
(c_unparser::emit_module_init): Iterate the timing init at runtime.
(c_unparser::emit_module_exit): Iterate the timing output at runtime.
* tapsets.cxx (common_probe_init): Just return the right global stap_probe*
* tapset*.cxx, runtime/*: Make pointers of all stap_probe's, and make
the s/\./->/ change where needed too.
* elaborate.cxx (derived_probe::derived_locations): New, gives a string
reporting the derivation steps which reached this probe point.
David Smith [Fri, 1 Oct 2010 17:56:54 +0000 (12:56 -0500)]
Fixed BZ634242 by always looking up pids in the global namespace.
* runtime/uprobes2/uprobes.c (uprobe_get_tg_leader): Always look up the
pid in the global pid namespace. From Roland McGrath
<roland@redhat.com>
(uprobe_fork_uproc): Ditto. From Roland McGrath <roland@redhat.com>
(uprobe_report_clone): If two processes are are sharing the same memory
space (CLONE_VM) don't remove probes, since that will remove the probes
from both processes.
* tapsets.cxx (emit_module_exit): Make sure we always look up pids
in the global pid namespace, not in any private pid namespace.
* runtime/uprobes-common.c (stap_uprobe_change_plus): Ignore EEXIST
errors.
Josh Stone [Wed, 29 Sep 2010 20:51:30 +0000 (13:51 -0700)]
Improve the derivation output of STP_TIMING
We can't assume location[0] from the probes in the derivation chain, as
it may include e.g. an alias with multiple expansions. Instead, a new
"base_pp" member tracks which probe_point actually led to each step of
the derivation.
* elaborate.cxx (derived_probe::derived_probe): Remember the unmodified
probe_point as base_pp, esp. before any components are rewritten.
(derived_probe::collect_derivation_pp_chain): New, collect base_pp.
* translate.cxx (c_unparser::emit_module_exit): Use the pp chain in
STP_TIMING output.
Josh Stone [Wed, 29 Sep 2010 20:36:51 +0000 (13:36 -0700)]
Standardize how derived_probes dupe their location
A few of the derived_probe subclasses make duplicates of their
probe_point so they can rewrite it to something more specific. This
patch standardizes that behavior.
It also fixes kprobe_derived_probe and hwbkpt_derived_probe, which were
rewriting components without making a copy first.
Tony Jones [Wed, 29 Sep 2010 16:47:52 +0000 (12:47 -0400)]
PR10812: relocate module build-id
Relocate the build_id_vaddr obtained from dwfl_module_build_id. Failure to
do this was causing ppc64 systems to fail the build-id check for cases such as:
Josh Stone [Tue, 28 Sep 2010 21:41:37 +0000 (14:41 -0700)]
Allow de-duping in spite of STP_TIMING
To enable this, we can use a Stat pointer in the same place we keep the
individual pp data, so now even when the probe body is shared, separate
timing data is kept.
* elaborate.h (derived_probe): Add a "real" name which is unchanging,
unlike the regular name that may face de-duping.
* tapsets.cxx (common_probe_init): Use the "real" name for timing data.
(common_probe_entryfn_prologue): Use a local stat instead of
CONTEXT->statp, and initialize it from the probe data.
(common_probe_entryfn_epilogue): Also use the local stat.
* translate.cxx (c_unparser::emit_common_header): Remove statp, and
don't use any timing anti-dupe.
(c_unparser::emit_module_init): Timing globals are now based on the
"real" probe names.
(c_unparser::emit_module_exit): Ditto.
(c_unparser::emit_probe): No more timing anti-dupe.
(translate_pass): Declare the new global timing struct, and point to
it accordingly in STAP_PROBE_INIT.
Josh Stone [Fri, 24 Sep 2010 22:16:36 +0000 (15:16 -0700)]
Simplify the '?' removal for STP_TIMING
Add a new flag to probe_point::print() so the extra details can be
avoided. This skips '?', '!', and any conditionals as well.
* staptree.cxx (probe_point::print): Make the extras optional.
(probe_point::str): Pass along the choice of extras.
* translate.cxx (c_unparser::emit_module_exit): Let the print routine
skip the extra flags, rather than trying to strip them out manually.
Josh Stone [Tue, 28 Sep 2010 22:41:52 +0000 (15:41 -0700)]
Fix SDTv2 with separate debuginfo
We had a case where the ".probes" section was found in the main binary,
but then sdt_query::init_probe_scn got its Elf* by looking first via the
debuginfo and then falling back to the executable. So when we got the
raw data pointer, it was using the wrong Elf* for that section.
This fix is to let dwflpp::get_section return the Elf* in which it found
the appropriate section, so init_probe_scn doesn't have to guess.
* dwflpp.cxx (dwflpp::get_section): Add an optional Elf** return
pointer, and fill it in if needed.
* tapsets.cxx (sdt_query::init_probe_scn): Use that Elf* for the section.
Stan Cox [Mon, 27 Sep 2010 19:26:53 +0000 (15:26 -0400)]
Add v3 sdt.h awareness to scripts/probe_perf.
* scripts/probe_perf/bench.sh (stap_test): Use testsuite/sdt.h so we
can build for any of v1, v2, v3.
(main): Add -testsrcdir for pointing to testsuite/sdt.h.