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.
Frank Ch. Eigler [Wed, 20 Feb 2013 02:00:04 +0000 (21:00 -0500)]
translator: tolerate unavailable System.map
On some linux distros, the System.map file is unreadable to unprivileged
users. systemtap should not overreact to this and assume that the whole
kernel-devel/header world is uninstalled. Just print a warning and move on.
Josh Stone [Tue, 19 Feb 2013 01:55:46 +0000 (17:55 -0800)]
PR15162: Don't output anything at all for skipped unwind tables
* translate.cxx (dump_unwindsym_cxt_table): New common function to
output an unwind table. It checks against MAX_UNWIND_TABLE_SIZE and
nulls out those that are skipped, so they're truly skipped everywhere.
(dump_unwindsym_cxt): Use dump_unwindsym_cxt_table for all four unwind
tables: debug_frame, debug_frame_hdr, eh_frame, and eh_frame_hdr.
Josh Stone [Sat, 16 Feb 2013 20:26:04 +0000 (12:26 -0800)]
PR11341: Fix two improper update_visitor assignments
Both are cases where a too-specific require<target_symbol> was used,
inferred by the parameter type. The result is immediately saved as a
generic expression pointer, so require<expression> is appropriate.
I believe this case is such that there was actually no harm caused here
by the formerly blithe static_cast, but it's still nice to see that such
improprieties are now detected.
Josh Stone [Sat, 16 Feb 2013 03:05:25 +0000 (19:05 -0800)]
PR11341: Add type safety to update_visitor::require()
This uses dynamic_cast<T*> to make a runtime check that the pointer that
was given to update_visitor::provide() is compatible with what the
caller required. Such a cast can't be used on void*, so the ::stack is
now composed of 'visitable' pointers - a new base class for expressions
and statements.
In the process, 'indexable' is now also brought into the expression
hierarchy. This looks a little odd since hist_op isn't really an
expression on its own, but otherwise this change untangles a lot of code
trying to deal with hist_op as an outlier, especially visit and print.
* staptree.h (update_visitor::require): Use dynamic_cast<> instead of a
dangerous static_cast<>, and throw exceptions for bad cases.
(struct visitable): New base class for expression and statement.
(struct indexable): Use expression as a base class, and get rid of the
now-unnecessary visit/print/tok middleman methods.
* staptree.cxx: Use direct indexable->visit/print/tok throughout.
* elaborate.cxx, parse.cxx: Ditto.
Frank Ch. Eigler [Fri, 15 Feb 2013 21:41:19 +0000 (16:41 -0500)]
systemtap.spec: hard-code systemtap instead of most usese of %{name}
... since we'll never change the project name, ever, ever, ever.
(And those special software-collection builds that do change %{name},
we don't want effecting these derived rpm strings, mostly.)
Lukas Berk [Fri, 15 Feb 2013 21:44:23 +0000 (16:44 -0500)]
Still install systemtap rc.d files when systemd is enabled
*systemtap.spec: remove systemtap portions from 'with_systemd'
conditionals so they are still installed even if
stap-server is using systemd. They should not be
combined.
Josh Stone [Thu, 14 Feb 2013 03:54:13 +0000 (19:54 -0800)]
Abstract the synthesizing of deref functions
Frank first noted the duplication in how we synthesize functions for
derefs, and I found there were four sites doing nearly the same thing.
A quick bit of abstraction relieves this.
* tapsets.cxx (synthetic_embedded_deref_call): New common code to create
a functiondecl for a code block and the functioncall to use it.
(dwarf_pretty_print::deref, dwarf_cast_query::handle_query_module,
tracepoint_var_expanding_visitor::visit_target_symbol_arg,
dwarf_var_expanding_visitor::visit_target_symbol): Use it.
Frank Ch. Eigler [Wed, 13 Feb 2013 02:32:30 +0000 (21:32 -0500)]
PR15123: work around broken gcc debuginfo for -mfentry functions
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54793 interferes with the
calm zen-like state of probing function parameters in programs built
with CFLAGS=-mfentry, due to a dwarf location-list problem. This
patch adds a heuristic function dwflpp::pr15123_retry_addr() that
offers callers a post-mfentry-address alternative for locating
variables. Will they use it, or not? Join us next week, as our
heroes encounter ... angry mr. dwarf, five steps away.
* dwflpp.cxx (pr15123_retry_addr): New function.
(translate_location): Call it, in order to enable $var
and $$parms resolution.
* tapsets.cxx (saveargs): Call it, in order to enable
stap -L <probe> listings.