William Cohen [Tue, 20 Nov 2012 19:26:33 +0000 (14:26 -0500)]
Add a "-O" to the "-D_FORTIFY_SOURCE=2" setjump.exp test
When building code with -D_FORTIFIY_SOURCE=2 need to turn on
optimizations. Without the "-O" the compile of code triggers warning
that will cause the build to fail and some parts of the portion of the
test is untested.
Mark Wielaard [Mon, 19 Nov 2012 20:43:40 +0000 (21:43 +0100)]
Run probefunc inline testcase with --compatible=1.8.
In the new implementation we will observe the name of the function where
this gets inlined, not the inlined function name itself. With the old
implementation of probefunc() it would get the name from the actual
probe string. Test the old behavior explicitly.
Josh Stone [Thu, 8 Nov 2012 01:07:15 +0000 (17:07 -0800)]
stapdyn: loadLibrary now returns BPatch_object
BPatch_addressSpace::loadLibrary changed its return value before Dyninst
8.0 final. We wanted the BPatch_object anyway, so now we don't have to
get it indirectly through BPatch_module::getObject.
Also, bump the rpm spec to require the actual Dyninst 8.0.
David Smith [Mon, 19 Nov 2012 20:08:43 +0000 (14:08 -0600)]
Fix _stp_get_arg32_by_number() for RHEL5.
* runtime/regs.c (_stp_get_arg32_by_number): Handle i386/x86_64
differences better for systems without x86 register unification, like
RHEL5.
Please enter the commit message for your changes. Lines starting
Mark Wielaard [Sat, 17 Nov 2012 21:34:04 +0000 (22:34 +0100)]
PR10272 Warn if we will be unable to generate user backtrace for 32-on-64.
Deduce the kernel ELF class from the kernel normalized machine architecture
and warn if it is different from the module ELF class (except for 32-bit
vdso). Don't generate unwind tables for "wrong class" modules.
Josh Stone [Wed, 7 Nov 2012 19:41:16 +0000 (11:41 -0800)]
stapdyn: Workaround for an i686 Dyninst bug in argument passing
Dyninst appears to be filling only 32-bits for the index to
enter_dyninst_uprobe_regs, which makes the following arguments shift
badly too. This is reported upstream, but we can detect and work around
it ourselves too.
Josh Stone [Tue, 6 Nov 2012 22:07:36 +0000 (14:07 -0800)]
stapdyn: Add tapset function print_regs
The underlying _stp_print_regs is more limited than the kernel version,
as some registers are not available, but this is still useful to see all
the information available to the probe.
Note: this makes it obvious that i686 actually doesn't have register
values right now. Dyninst has documented that only POWER and AMD64
implement getRegisters, unfortunately. This might be expanded by them
in a future release.
* runtime/regs.c: Split into linux/ and dyninst/ versions.
* tapset/context.stp (print_regs): Moved from linux/; now it's generic.
* stapdyn/mutatee.cxx (get_dwarf_registers): Add verbose logging, which
also shows that i686 doesn't have registers. :(
Josh Stone [Tue, 6 Nov 2012 00:21:50 +0000 (16:21 -0800)]
stapdyn: Add support for return probes
Each address is converted to the BPatch_locExit of the function which
contains it. Even $return is working fine from here!
* runtime/dyninst/uprobes.c (stp_dyninst_probe_flags): New, return the
flags describing this probe, notably STAPDYN_PROBE_FLAG_RETURN.
* stapdyn/dynprobe.cxx (find_dynprobes): Read the flags from the module.
(dynprobe_location::dynprobe_location): Parse return_p from the flags.
* stapdyn/mutatee.cxx (mutatee::instrument_dynprobe_target): For probes
with return_p set, transform into BPatch_locExit points.
* tapsets.cxx (dwarf_builder::build): Let stapdyn return probes through.
(uprobe_derived_probe_group::emit_module_dyninst_decls): Emit
.flags=STAPDYN_PROBE_FLAG_RETURN for return probes.
Josh Stone [Mon, 5 Nov 2012 21:58:44 +0000 (13:58 -0800)]
stapdyn: Reduce LDADD to only those directly used
The only part of Dyninst that we actually use and need to link is
libdyninstAPI. The rest of those libraries I had in dyninst_LIBS were
those needed indirectly by that one. But trying to enumerate someone
else's dependencies is a recipe for failure -- e.g. it was already
broken by not including the new libdynElf too.
The reason I had this was to allow successful linking when using
--with-dyninst=/not/a/lib/searched/path without requiring also to set
LD_LIBRARY_PATH. Since the enumeration is prone to break, and you'd
have to set LD_LIBRARY_PATH anyway to be able to run, I've decided it's
not worth trying to be fancy here.
Josh Stone [Mon, 5 Nov 2012 21:50:13 +0000 (13:50 -0800)]
configure: treat any positive --with-dyninst as a hard req
If the user gave --with-dyninst[=yes] or --with-dyninst=/path, treat a
failure in that feature test as a hard error. If the user left dyninst
implicit, then don't make it an error. And of course if the user gave
--without-dyninst, then don't test it at all.
Josh Stone [Mon, 5 Nov 2012 20:20:46 +0000 (12:20 -0800)]
Add System.map kernel functions to systemtap_session
The code to parse System.map was already in place for kprobe.function
validation; now it's generalized and the result made available in
systemtap_session::kernel_functions.
Josh Stone [Fri, 2 Nov 2012 23:23:43 +0000 (16:23 -0700)]
Prototype support for inode-uretprobes
Anton Arapov sent a test kernel build with new support for uretprobes,
and this patch adds stap support. I've confirmed that it works on
x86_64, but i686 is crashing the target processes with SIGSEGV.
We need to find a dynamic (pass-2) way to detect the presence of
uretprobes in the kernel. For now, I've just hacked it enabled, and it
will fail registration at runtime.
* buildrun.cxx (compile_pass): Autoconf uretprobes and its exports.
* runtime/linux/autoconf-inode-uretprobes.c: New, check for uretprobes.
* runtime/linux/runtime.h: Add function pointers for uretprobes.
* runtime/transport/transport.c (_stp_transport_init): Set the uretprobe
function pointers if not exported. (Anton's kernel does have exports,
but we're prepared in case upstream doesn't accept those.)
* runtime/linux/uprobes-inode.c (stapiu_consumer): Let this double as
either a uprobe_consumer or a uretprobe_consumer, chosen by return_p.
(stapiu_probe_handler): Add a new generic function signature.
(stapiu_uprobe_handler, stapiu_uretprobe_handler): New specific
callbacks that mux into stapiu_probe_handler.
(stapiu_register, stapiu_unregister): New functions to perform the
appropriate kind of registration for a probe.
* tapsets.cxx (dwarf_builder::build): Hack the uretprobes check.
(uprobe_derived_probe_group::emit_module_inode_decls): Use the new
signature for the probe handler, and emit .return_p.
New systemtap.examples/stapgames directory added with the supporting
tapsets located in the 'tapset' subdirectory. All tests run with -p4
specified.
* testsuite/systemtap.examples/stapgames/block.meta : block meta data
* testsuite/systemtap.examples/stapgames/block.stp : break a ceiling of
blocks
* testsuite/systemtap.examples/stapgames/eater.meta : eater meta data
* testsuite/systemtap.examples/stapgames/eater.stp : eat the .'s before
being eaten
* testsuite/systemtap.examples/stapgames/lifegame.meta : life meta data
* testsuite/systemtap.examples/stapgames/lifegame.stp : watch a
'lifeform' morph and evolve
* testsuite/systemtap.examples/stapgames/pingpong.meta : ping pong meta
data
* testsuite/systemtap.examples/stapgames/pingpong.stp : cursor bounces
around terminal reflecting off edges
* testsuite/systemtap.examples/stapgames/tapset/audio.stp : audio
functionality
* testsuite/systemtap.examples/stapgames/tapset/cursor.stp : cursor
functionality and tracking
* testsuite/systemtap.examples/stapgames/tapset/game.stp : seed values
* testsuite/systemtap.examples/stapgames/tapset/gmtty.stp : tty functionality
* testsuite/systemtap.examples/stapgames/tapset/input.stp : controlling
game input
Lukas Berk [Wed, 31 Oct 2012 14:41:47 +0000 (10:41 -0400)]
Allow spin-rawhide to be run from any directory
* scripts/spin-rawhide: replace HASH suffix with mktemp function
reposition constant/variable definitions to draw
from newly cloned systemtap.git vs pwd
make STAP_MAJOR_VERSION grep more specific
make Source grep more specific
Josh Stone [Tue, 30 Oct 2012 22:03:38 +0000 (15:03 -0700)]
PR14665: Start handling signals in stapdyn
This works somewhat to receives signals and kill the target process, but
sometimes it hangs. I think it may work better when the notification FD
is resolved.
Josh Stone [Tue, 30 Oct 2012 19:14:53 +0000 (12:14 -0700)]
stapdyn: Sketch out support for polling on Dyninst
By polling instead of waitForStatusChange, we can let signals break us
out of the run loop too. However, the notification FD currently appears
broken in Dyninst, so this is "#if 0" for now.
* util.cxx (ppoll): Move the fallback ppoll() to a general location.
* remote.cxx (ppoll): Moved ppoll() from here.
* stapdyn/mutator.cxx: Add the #if 0 stub of notification FD support.
Josh Stone [Tue, 30 Oct 2012 02:06:30 +0000 (19:06 -0700)]
stapdyn: Add some support for removing instrumentation
We'll need this for signal-handling cleanup, and for detaching from
-x PID target processes.
* stapdyn/mutatee.h (mutatee::snippets): New vector for all the handles
to code that we've added with Dyninst insertSnippet.
* stapdyn/mutatee.cxx (mutatee::instrument_dynprobe_target): Save the
insertSnippet handle in snippets.
(mutatee::remove_instrumentation): New, remove all the snippets.
(mutatee::unload_stap_dso): New placeholder for unloading our module
from the target process. Dyninst can't do this yet...
(mutatee::~mutatee): Call remove_instrumentation and unload_stap_dso.
Josh Stone [Tue, 30 Oct 2012 01:58:58 +0000 (18:58 -0700)]
stapdyn: Manage mutatee lifetimes better
It will be more convenient to manage mutatee resources if there's one
clear owner of the process, so stop allowing implicit copies.
* stapdyn/mutatee.h (mutatee::mutatee): Don't implement copy ctors.
* stapdyn/mutator.h (mutator::mutatees): Use shared_ptr for this list.
* stapdyn/mutator.cxx (mutator::create_process): Save a shared_ptr.
(mutator::run): Use pointer indirection for mutatees.
(mutator::dynamic_library_callback): Ditto.
Josh Stone [Tue, 30 Oct 2012 01:53:59 +0000 (18:53 -0700)]
stapdyn: Manage mutator lifetime better
We need to have a global record of mutators in order for dyninst
callbacks to work, since they have no context attached. But rather than
some singleton factory style, just keep a global list of all mutators
we've seen.
* stapdyn/mutator.cxx (g_mutators): New vector for all mutators.
(g_dynamic_library_callback): Iterate callbacks for all g_mutators.
(mutator::dynamic_library_callback): Do the individual work.
(mutator::mutator): Add this to g_mutators.
(mutator::~mutator): Remove this from g_mutators.
(mutator::create, mutator::g_mutator): Removed.
* stapdyn/stapdyn.cxx (main): Use mutator new and auto_ptr delete.
Frank Ch. Eigler [Mon, 29 Oct 2012 02:39:36 +0000 (22:39 -0400)]
testsuite: make stap_run[23] more verbose when failing
If a stap_run[23] test case fails, in that the actual output varies
from the expected output, all remaining actual output lines were
neither compared nor reported in systemtap.log.
* testsuite/lib/stap_run2.exp (stap_run3): In case of a line mismatch,
report any remaining actual lines.
Frank Ch. Eigler [Mon, 29 Oct 2012 00:53:11 +0000 (20:53 -0400)]
PR14781: use kmem_cache_create with unique name
* runtime/stp_utrace.c (utrace_init): Instead of using the KMEM_CACHE macro,
invoke kmem_cache_create directly, with cache names that are going to be
unique across concurrent systemtap sessions.
Frank Ch. Eigler [Mon, 29 Oct 2012 00:16:55 +0000 (20:16 -0400)]
PR14781 part 1: don't panic
* runtime/stp_utrace.stp (utrace_init): Don't SLAB_PANIC on duplicate
kmem_cache names, as is sadly likely for concurrent inode-uprobes
scripts running on CONFIG_DEBUG_VM kernels.
* runtime/linux/task_finder2.c (stap_start_task_finder): Deign to check
the utrace_init return code, and fail with a touch of grey grace.
David Smith [Tue, 23 Oct 2012 21:21:10 +0000 (16:21 -0500)]
(PR14571 partial fix) Rework dyninst stat/map data storage.
* runtime/map.c: Switched from TLS to just an array of map data for
dyninst mode. Pushed most of the kernel vs. dyninst code down to
runtime/{linux,dyninst}/map_runtime.h.
* runtime/map-stat.c (_stp_map_new_hstat_log): Ditto.
* runtime/map.h: Ditto.
* runtime/pmap-gen.c: Ditto.
* runtime/stat.c (_stp_stat_add): Switched from TLS to just an array of
stat data for dyninst mode. Pushed most of the kernel vs. dyninst code
down to runtime/{linux,dyninst}/stat_runtime.h.
* runtime/stat-common.c: Ditto.
* runtime/stat.h: Ditto.
* runtime/dyninst/map_runtime.h: New file.
* runtime/dyninst/stat_runtime.h: New file.
* runtime/linux/map_runtime.h: New file.
* runtime/linux/stat_runtime.h: New file.
* runtime/dyninst/tls_data.c: Deleted file.
Josh Stone [Mon, 22 Oct 2012 23:35:19 +0000 (16:35 -0700)]
runtime: fix timers for old kernels
This is a regression from commit 2b5ecaf, which split the hrtimer code
into the runtime. The kernel portion needs to vary the return type of
the callback function for old kernels, using int instead of the enum.
This patch defines hrtimer_return_t to abstract the difference.
Josh Stone [Mon, 22 Oct 2012 20:55:49 +0000 (13:55 -0700)]
tapset: Add the macro @choose_defined and use it
This returns the first parameter if it's @defined, otherwise it returns
the second parameter, replacing the common @defined(x)?x:y pattern.
I only updated the tapsets to use this, as I feel that's where we should
show off good code practice. There are opportunities in the testsuite
that could use it too, but it's not necessary, and probably better to
leave existing tests undisturbed when possible.
Mark Wielaard [Sun, 21 Oct 2012 23:00:40 +0000 (01:00 +0200)]
PR14742 - more complete dwz / DW_TAG_partial_unit support
Don't use DW_TAG_partial_units directly in dwflpp::iterate_over_cus
and dwarf_var_expanding_visitor::getcuscope. Descent into imported_units
in has_only_decl_members, dwflpp::iterate_over_globals,
dwflpp::iterate_over_types, dwflpp::iterate_over_labels
dwflpp::inner_die_containing_pc, dwflpp::print_locals,
dwflpp::print_members, dwflpp::find_struct_member and
dwarf_pretty_print::recurse_struct_members.
Josh Stone [Tue, 16 Oct 2012 23:11:07 +0000 (16:11 -0700)]
stapdyn: Big refactoring
The main additions are the "mutator" class working with the overall
session, and the "mutatee" class working with the individual targets.
This is a bit of code churn, with no functional change, but it should
make it easier to keep track of our current state and add new features.
Frank Ch. Eigler [Tue, 16 Oct 2012 18:43:52 +0000 (14:43 -0400)]
PR14731: fix PR12022 regression for synthetic foreach()
* elaborate.cxx (add_global_var_display): For foreach_loop created
for otherwise-unused global, initialize sort_aggr => sc_none, the
same way the parser would.
David Smith [Mon, 15 Oct 2012 21:28:28 +0000 (16:28 -0500)]
Fixed PR14701 by adding dyninst timer probe support.
* tapset-timers.cxx (hrtimer_derived_probe_group::emit_interval): Removed
function.
(hrtimer_derived_probe_group::emit_module_decls): Pushed some code down
to the runtime and added dyninst support.
(hrtimer_derived_probe_group::emit_module_init): Ditto.
(hrtimer_derived_probe_group::emit_module_exit): Ditto.
(timer_builder::build): Throw semantic errors if 'timer.jiffies' or
'timer.profile' probes are used in dyninst mode.
(register_tapset_timers): Add fake privilege for 'timer.profile' probes
when in dyninst mode (so we get a semantic error, not a privilege error).
* buildrun.cxx (compile_dyninst): Added '-lrt' for timer functions.
* testsuite/systemtap.pass1-4/buildok-dyninst.exp: Move some tests to the
kfail list.
* runtime/timer.c: New file.
* runtime/dyninst/timer.c: Ditto.
* runtime/linux/timer.c: Ditto.
Frank Ch. Eigler [Sat, 13 Oct 2012 16:13:35 +0000 (12:13 -0400)]
PR12022: support foreach sorting by user-selected aggregate operator
The syntax goes:
foreach ([x,y] in array @avg -) { }
inserting the desired sorting aggregator between the array name and
the +/- The runtime has been ready for this for a long time (see the
runtime/map.c SORT_* macros), finally time for the translator to let
users enjoy it.
Josh Stone [Fri, 12 Oct 2012 21:45:55 +0000 (14:45 -0700)]
PR14172: Fix for kernels without VM_EXECUTABLE
We were using VM_EXECUTABLE in two ways:
1) In task_finder for locating the process executable among all the
vmas. Since around 2.6.26 there is also mm->exe_file, which will serve
this purpose just fine.
2) In uprobes to avoid relocation offset for semaphores in ET_EXEC
files. This is actually incorrect, but harmless, because the callback
path for ET_EXEC targets already sets relocation=offset=0 anyway. So we
can just remove the special case for VM_EXECUTABLE altogether.
* runtime/task_finder_vma.c (stap_find_exe_file): New, locate the
process executable either by VM_EXECUTABLE or mm->exe_file.
* runtime/linux/task_finder.c (__stp_get_mm_path): Use stap_find_exe_file.
* runtime/linux/task_finder2.c (__stp_get_mm_path): Ditto.
* runtime/linux/uprobes-common.c (stap_uprobe_change_plus): Don't
special case for VM_EXECUTABLE (and add a comment why).
* runtime/linux/uprobes-inode.c (stapiu_change_plus): Ditto.
(stapiu_get_task_inode): Use stap_find_exe_file.
Frank Ch. Eigler [Fri, 12 Oct 2012 16:27:42 +0000 (12:27 -0400)]
testsuite: tweak net-sanity.exp test
It shouldn't use stap -vv, ashat creates too much noise in the .log file.
It shouldn't use 0xd34db33f as a known-bad address, because sometimes it's good.
Really good. Mmmm, tasty, BBQ goodness good. Honey, time to warm up the burners!
Frank Ch. Eigler [Fri, 12 Oct 2012 03:28:30 +0000 (23:28 -0400)]
PR14245 clean up error messages for staprun -d SOMETHING_AWFUL
jistone reported that the previously moved
"ERROR: no access to debugfs; try "chmod 0755 /sys/kernel/debug" as root"
message was appearing for erroneous staprun -d FOOBAR cases.
* ctl.c (init_ctl_channel): Print a more general error for any .ctl-file
opening failure.
Josh Stone [Thu, 11 Oct 2012 17:42:10 +0000 (10:42 -0700)]
Set staprun's verbosity one less than stap
Prior to commit e520ea8, staprun would get one -v for s.verbosity>1 and
a second -v for s.verbosity>2. That commit unbounded the number of -v
for staprun, but changed the off-by-one, and staprun and stapio are too
chatty for that.
This also now sets stapdyn verbosity the same way.
* buildrun.cxx (make_run_command): Give one less -v flag.
(make_dyninst_run_command): Set stapdyn -v flags the same way.
David Smith [Thu, 11 Oct 2012 15:55:58 +0000 (10:55 -0500)]
Fixed PR14659 so that ptrace can be used on tasks probed with systemtap.
* runtime/stp_utrace.c (utrace_set_events): No longer set
TIF_SYSCALL_TRACE on the target task.
(utrace_reset): No longer clear TIF_SYSCALL_TRACE on the target task.
* testsuite/systemtap.base/ptrace.exp: New testcase.
Frank Ch. Eigler [Wed, 10 Oct 2012 22:10:40 +0000 (18:10 -0400)]
PR14245: support /sys/kernel/debug mounted 0700
This is done by staprun passing a file descriptor for the
/sys/kernel/debug/systemtap/stap_MODULE directory from staprun
(running setuid) to stapio (running unprivileged, previously unable to
traverse to that path itself). This FD passing is done with a new
option -F<fd> for stapio (though by accident staprun also accepts (and
rejects) this option).
Since openat(2) is relatively recent, autoconf macros are used to back
down to graceful failure on older kernels, and to hide the new code.
New staprun always uses -F<fd> to stapio, even if permissions on
/sys/kernel/debug do not require it.
* staprun/common.c (relay_basedir_fd): New variable.
(parse_args): Parse new -F: option.
(usage): Document it.
* staprun/staprun.h: Corresponding changes.
* staprun/ctl.c (init_ctl_channel): Reorganize to try an incoming
relay_basedir_fd first (with a faccessat cross-user check) first.
Try to compute a relay_basedir_fd if not already set.
* staprun/mainloop.c (read_buffer_info): Note ignoring of this PR facility on
RHEL4-era old_transport.
* staprun/relayfs.c (init_relayfs): Attempt to open relay_fd[] using
relay_basedir_fd if specified.
* staprun/stapio.c: Top secret.
* staprun/staprun.c (main): Don't allow staprun itself to take -F, for it
could be misused by a very bad person (tm). However, arrange to pass
it to stapio, if we have incidentally discovered a good relay_basedir_fd.
* staprun/staprun_funcs.c (mountfs): Drop access_debugfs() check at this
point, as init_ctl_channel() will do the check later.
PR14555: handle 0 _stext relocs from userspace by kallsyms_lookup_name fallback
* runtime/transport/symbols.c (_stp_do_relocation): For an incoming
_stext=0 relocation (such as for /proc/sys/kernel/kptr_restrict = 2),
fall back to kallsyms_lookup_name.