David Smith [Fri, 26 Apr 2013 16:25:24 +0000 (11:25 -0500)]
Fixed PR14491 by adding a real transport layer for dyninst.
* runtime/dyninst/transport.c: New file.
* runtime/dyninst/transport.h: New file.
* translate.cxx (c_unparser::emit_module_init): Emit a call to
stp_session_init_finished() before probe registrations.
(c_unparser::emit_module_exit): In dyninst mode, delay
releasing the context.
* tapsets.cxx (common_probe_entryfn_epilogue): In dyninst mode, delay
releasing the context.
* runtime/dyninst/stapdyn.h: Add stp_dyninst_session_init_finished()
prototype.
* runtime/dyninst/shm.c (_stp_shm_destroy): Right before unmapping the
shared memory, tear down the contexts.
* runtime/dyninst/runtime_context.h (__stp_runtime_contexts_free): New
function.
* runtime/dyninst/runtime.h (stp_pthread_rwlock_init_shared): New function.
(stp_dyninst_shm_connect): Initialize the transport by calling
_stp_dyninst_transport_init().
(stp_dyninst_session_init): Ditto.
(stp_dyninst_session_init_finished): New function.
(stp_dyninst_dtor): Shutdown the transport by calling
_stp_dyninst_transport_shutdown().
* runtime/dyninst/print.c (_stp_print_flush): Now just calls
_stp_dyninst_transport_write().
(_stp_reserve_bytes): Now just calls
_stp_dyninst_transport_reserve_bytes().
(_stp_unreserve_bytes): Now just calls
_stp_dyninst_transport_unreserve_bytes().
* runtime/dyninst/common_session_state.h: Add transport data to session
data structure.
* runtime/common_probe_context.h: Add transport data to context structure.
* runtime/dyninst/io.c (_stp_vlog): New function.
(_stp_warn): Now uses _stp_vlog().
(_stp_error): Ditto.
(_stp_softerror): Ditto.
(_stp_dbug): Ditto.
Josh Stone [Tue, 23 Apr 2013 22:10:51 +0000 (15:10 -0700)]
Expand the SDT benchmark locations
- Add the loop index as an argument to stap:benchmark.
- Add stap:benchmark-thread-begin/end around each thread.
- Add stap:benchmark-begin/end around the whole thing.
Josh Stone [Thu, 4 Apr 2013 18:11:36 +0000 (11:11 -0700)]
BZ855981: Further tweak getcpu compatibility
- Keep using sched_getcpu() where possible - it's sometimes faster.
- Pass the correct parameters to syscall(getcpu).
- Direct the tapset cpu() through this compat code too.
BZ855981: stapdyn runtime compatibility with RHEL5
Old kernels & old glibcs require some minor compatibility hacks.
* runtime/dyninst/linux_defs.h: Dummy-define CLOCK_MONOTONIC_RAW
if required.
* runtime/dyninst/runtime.h: Dummy-define BITS_PER_LONG if required.
_stp_runtime_entryfn_get_context: Use syscall(__NR_gettid) as
fallback from __NR_getcpu if required.
Josh Stone [Wed, 27 Mar 2013 23:33:56 +0000 (16:33 -0700)]
PR15315: Filter inode-uprobe processes in the handler
We already had process tracking, mainly for setting semaphores, but this
gives the list needed to check if an incoming uprobe hit is for a
process we care about. So now stapiu_probe_prehandler will consult this
list before proceeding with the rest of the probe handler.
This also updates locking so that readers of this process list have a
more fine-grained lock, rather than the global stapiu_process_lock.
Code that needs to reserve/free a uprobe slot will both the global lock
and the specific target lock.
Josh Stone [Tue, 26 Mar 2013 19:25:17 +0000 (12:25 -0700)]
PR15306: Guard the stapdyn probe prologue for no shm
* runtime/dyninst/common_session_state.h (GET_SESSION_ATOMIC,
_stap_hash_seed, probe_alibi, probe_timing, stp_session_context):
Return NULL if the session (in shm) doesn't exist yet.
* tapsets.cxx (common_probe_entryfn_prologue): Skip the whole probe if
the session_state isn't available at all (i.e. no shm yet).
(common_probe_entryfn_epilogue): Close the session_state block.
linux-headers* already depends on the right linux-kbuild* package and
our heuristic for guessing the package name is lacking. For example
with linux-image-3.2.0-0.bpo.4-amd64 version 3.2.35-2~bpo60+1 from
squeeze-backports it predicts "linux-kbuild-3.2.0" while the package
is actually named "linux-kbuild-3.2".
Serguei Makarov [Fri, 22 Mar 2013 22:11:27 +0000 (18:11 -0400)]
PR15053: stapdyn -G global variable setting support (initial patch)
* buildrun.cxx (make_dyninst_run_command): pass module arguments on to stapdyn.
* runtime/dyninst/runtime.h (set_int64_t): new function.
* runtime/dyninst/stapdyn.h (stp_global_setter): function prototype.
* stapdyn/mutator.cxx (mutator::mutator): add modoptions to mutator.
(mutator::init_modoptions): new function.
(mutator::run_module_init): call init_modoptions to initialize globals.
* stapdyn/mutator.h (class mutator): add modoptions to mutator.
* stapdyn/stapdyn.cxx (main): collect module arguments from command line.
* translate.cxx (struct c_unparser): new emit_global_init_* functions.
(c_unparser::emit_global_param): stapdyn no longer calls this function.
(c_unparser::emit_global_init_setters): new function.
(c_unparser::emit_global_init): emit default initial values in stapdyn mode.
(c_unparser::emit_global_init_type): new function.
(c_unparser::emit_module_init): copy initial values of stapdyn globals
to shared memory as appropriate.
(translate_pass): emit static-initialization struct for stapdyn,
and also emit the setter function to access this struct.
* translate.h (struct c_unparser): document new emit_global_init_* functions.
Josh Stone [Fri, 22 Mar 2013 02:13:25 +0000 (19:13 -0700)]
PR15279: Leave REG_IP alone in 3.9ish uprobes
We had experimental code to use uprobes that passed the IP as an extra
parameter, but that was dropped in favor of modifying pt_regs directly,
before even calling the handlers. So this restores our handler to never
take an IP, and updates REG_IP only for older versions.
* buildrun.cxx: Don't run autoconf-inode-uprobes-noaddr.c.
* runtime/linux/autoconf-inode-uprobes-noaddr.c: Deleted.
* runtime/linux/uprobes-inode.c: Set STAPIU_NEEDS_REG_IP for older
uprobes, and consolidate to a single handler function that uses that
flag to gate IP-setting.
* testsuite/systemtap.context/uprobe_uaddr_mark.*: New test, makes sure
that uaddr() matches the statement(ADDR) in pp().
David Smith [Wed, 20 Mar 2013 20:51:37 +0000 (15:51 -0500)]
Include runtime/dyninst/stapdyn.h properly in stapdyn C++ code.
* stapdyn/dynprobe.cxx: Make sure when we include
runtime/dyninst/stapdyn.h we use 'extern "C"'.
* stapdyn/mutatee.cxx: Ditto.
* stapdyn/mutator.cxx: Ditto.
* stapdyn/mutator.h: Ditto.
David Smith [Tue, 19 Mar 2013 19:27:02 +0000 (14:27 -0500)]
Make sure dyninst stat/map locks are using PTHREAD_PROCESS_SHARED.
* runtime/dyninst/map_runtime.h (_stp_map_initialize_lock): Be sure to set
'PTHREAD_PROCESS_SHARED' on mutexes by calling
stp_pthread_mutex_init_shared().
* runtime/dyninst/stat_runtime.h: Ditto.
* runtime/dyninst/runtime.h: Add forward declaration of
stp_pthread_mutex_init_shared().
Mark Wielaard [Sun, 17 Mar 2013 11:31:27 +0000 (12:31 +0100)]
Make sure macro chain tokens are available for error reporting.
Found by a combination of zzuf and valgrind. When reporting the chain
token we need a real copy, because the existing (junk) token might have
been discarded.
Josh Stone [Tue, 12 Mar 2013 02:08:49 +0000 (19:08 -0700)]
Add options to help benchmark SDT
These are secret, undocumented, for developer use only. Use stap
inception-style as the -c CMD of a stap which probes the SDT mark
process.provider("stap").mark("benchmark").
--benchmark-sdt-loops=N
Loop over the SDT probe point N times.
--benchmark-sdt-threads=N
Run the loop simultaneously in N threads.
Josh Stone [Tue, 12 Mar 2013 02:01:27 +0000 (19:01 -0700)]
stapdyn: fix the context->data_index
This regressed in commit c08bf9de, which lost the initialization of that
field. Thus there was a data race in pmaps, stats, etc. in writing to
data_index 0, rather than the true index of the currently-owned context.
Lukas Berk [Fri, 8 Mar 2013 20:47:27 +0000 (15:47 -0500)]
Allow spin-rawhide to update systemtap.spec with upstream changes
*scripts/spin-rawhide: add diff between spec files and prompt if
there are changes and if the user would like
to patch the sytemtap.spec file. Alter
changelog entry accordingly
systemtap.spec: move some -server install scripting to %post
Specifically, the creation of the ~stap-server/.systemtap/rc file
should be attempted only after the files/directories have been created
and the stap-server account made. Also, rpm-visibly create the
~stap-server/.systemtap subdirectory.
testsuite: impose stap --rlimit-cpu=300 throughout
Use the testsuite/.systemtap-*/rc file to impose cpu limits on stap
processes, considering PR15144 (which results in a spinning/hung
stapdyn child process).
* runtime/linux/autoconf-hlist-4args.c: New test.
* buildrun.cxx (compile_pass): Run it to set STAPCONF_HLIST_4ARGS.
* runtime/linux/runtime.h: Use it to define stap_hlist_* the old way
or the new.
* runtime/*: Adapt by going through new stap_hlist* iterators.
* runtime/uprobes*/*: Don't bother adapting this old-kernel-only code base.
These were found empirically. Some of the functions look innocent but
they are called from functions marked with __kprobes so they still
cause crashes. Further analysis is available at
https://lkml.org/lkml/2013/2/27/82 ("kprobing "hash_64.constprop.26"
crashes the system, recursion through get_kprobe?").
David Smith [Thu, 28 Feb 2013 16:50:18 +0000 (10:50 -0600)]
Fix PR15211 by updating the testsuite for kernel 3.8.
* testsuite/systemtap.syscall/openclose.c: Handle 'creat()' being mapped
to 'creat()' or 'open(FILE, O_CREAT)' in the kernel.
* testsuite/systemtap.syscall/stat.c: Ditto.
* testsuite/systemtap.syscall/test.tcl: Map '!!!!' to '|'.
* testsuite/systemtap.syscall/README: Document the new '!!!!' substitute
for '|'.
David Smith [Tue, 26 Feb 2013 20:21:00 +0000 (14:21 -0600)]
Fix PR15198 by handling new kernel option CONFIG_GENERIC_SIGALTSTACK.
* tapset/linux/syscalls2.stp: Added generic 'sigaltstack' probe alias for
when CONFIG_GENERIC_SIGALTSTACK is set.
* tapset/linux/nd_syscalls2.stp: Ditto.
* tapset/linux/s390/nd_syscalls.stp: Added 'nd_syscall.sigaltstack',
'nd_syscall.sigaltstack.return', 'nd_syscall.sys32_sigaltstack', and
'nd_syscall.sys32_sigaltstack.return' probe aliases.
* tapset/linux/i386/syscalls.stp: Only use arch-specific 'sigaltstack'
probe alias if CONFIG_GENERIC_SIGALTSTACK isn't set. Deprecate 'regs'
variable.
* tapset/linux/ia64/syscalls.stp: Ditto.
* tapset/linux/powerpc/nd_syscalls.stp: Ditto.
* tapset/linux/powerpc/syscalls.stp: Ditto.
* tapset/linux/s390/syscalls.stp: Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.
* tapset/linux/x86_64/syscalls.stp: Ditto.
* tapset/linux/i386/nd_syscalls.stp: Only use arch-specific 'sigaltstack'
probe alias if CONFIG_GENERIC_SIGALTSTACK isn't set.
* tapset/linux/ia64/nd_syscalls.stp: Ditto.
* testsuite/buildok/syscalls-arch-detailed.stp: Only test
the arch-specific 'sigaltstack' probe alias if
CONFIG_GENERIC_SIGALTSTACK is not set. Handle 'regs' deprecation.
* testsuite/buildok/syscalls-arch-detailed.stp: Ditto.
* testsuite/buildok/syscalls2-detailed.stp: Added generic 'sigaltstack'
probe alias test for when CONFIG_GENERIC_SIGALTSTACK is set.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
* NEWS: Mention 'regs' deprecation.
David Smith [Fri, 22 Feb 2013 20:34:48 +0000 (14:34 -0600)]
Actually deprecate items marked as deprecated in vfs.stp.
* tapset/linux/vfs.stp: Several items in vfs.stp had a comment saying they
were deprecated. Acutally make it happen. Deprecate the 'ppos_pos',
'_dev_minor', and '_dev_major' functions. Deprecate the 'page_index'
variable in the 'vfs.block_sync_page' and 'vfs.buffer_migrate_page'
probe aliases. Deprecate the 'write_from' and 'write_upto' variables in
the '_vfs.block_prepare_write' and '_vfs.block_prepare_write.return'
probe aliases.
* testsuite/buildok/vfs-embedded.stp: Handle 'ppos_pos' deprecation.
* testsuite/systemtap.examples/io/iodevstats.stp: Switch from deprecated
'_dev_minor' and '_dev_major' functions to supported 'MINOR' and 'MAJOR'
functions.
* NEWS: Mention deprecations.