Josh Stone [Mon, 11 Feb 2013 22:30:48 +0000 (14:30 -0800)]
stap: Add shorthand option --dyninst for --runtime=dyninst
* cmdline.cxx: Define --dyninst as LONG_OPT_RUNTIME_DYNINST.
* session.cxx (systemtap_session::parse_cmdline_runtime): Pull out the
code to set the runtime option.
(systemtap_session::parse_cmdline): Use parse_cmdline_runtime for both
LONG_OPT_RUNTIME and LONG_OPT_RUNTIME_DYNINST.
(systemtap_session::usage): Document --dyninst.
* man/stap.1: Document --dyninst.
Josh Stone [Fri, 8 Feb 2013 20:58:56 +0000 (12:58 -0800)]
stapdyn: Validate that probe flags are known
If we see unknown flags, we don't want to do the wrong thing with a
probe. So just warn about it and move on without it.
* runtime/dyninst/stapdyn.h: Introduce STAPDYN_PROBE_ALL_FLAGS combining
all the currently-known flags. Also, shift the values of the utracey
flags to leave some room for more uprobey flags.
* stapdyn/dynprobe.cxx (dynprobe_location::validate): New, make sanity
check on the probe. For now, this just means checking that the flags
are within those we know about.
Josh Stone [Fri, 8 Feb 2013 00:43:21 +0000 (16:43 -0800)]
stapdyn: Make sure interprocess maps share hash seeds
We were using a random stap_hash_seed that was initialized separately in
each process. This meant that different processes would compute
different hashes for the same keys. Now the hash seed is stored in the
shared memory, so all participating processes can use maps together.
* runtime/dyninst/common_session_state.h: Add the hash seed to struct
stp_runtime_session, and provide _stap_hash_seed() to read it.
Initialize it one time only in stp_session_init().
* runtime/dyninst/runtime.h: Define the former stap_hash_seed to use
_stap_hash_seed() from shared memory instead.
* testsuite/systemtap.maps/map_hash_interprocess.*: Test the specific
interprocess, manually-keyed conditions that revealed the bug.
Josh Stone [Thu, 7 Feb 2013 23:42:47 +0000 (15:42 -0800)]
stapdyn: Seed _stp_random_u with more "precision"
Use clock_gettime() rather than time(). It's still not necessarily
great to seed from a time-based source, but at least nanosecond
resolution is a little better.
Josh Stone [Thu, 7 Feb 2013 21:02:30 +0000 (13:02 -0800)]
PR14706: Add proto-exec support in stapdyn
This adds preliminary support for stapdyn to follow execs, but the code
it instrument the new process is currently blocked out. I'm seeing
dyninst hang during loadLibrary, waiting for IRPC, but haven't yet
figured out why.
* stapdyn/mutatee.cxx (mutatee_freezer): New helper to automatically
stop a process and then continue it when leaving that scope.
(mutatee::begin_callback): Use a mutatee_freezer.
(mutatee::thread_callback): Use a mutatee_freezer.
(mutatee::copy_forked_instrumentation): Use two mutatee_freezers.
(mutatee::instrument_dynprobes): Support a flag to indicate this is
post-exec, so first run any process.end probes from before exec.
(mutatee::exec_reset_instrumentation): New, clear all members that are
invalidated by the process exec.
* stapdyn/mutator.cxx (g_exec_callback): New global callback for execs.
(mutator::exec_callback): New specific callback for execs. Clear old
instrumentation, then instrument it anew (buggy, #if 0 for now).
David Smith [Thu, 7 Feb 2013 17:52:06 +0000 (11:52 -0600)]
Clean up mutatee::stop_execution() logic.
* stapdyn/mutatee.cxx (mutatee): Removed unneeded 'patch' argument.
(stop_execution): Remove logic that waited on the process to stop, since
process->stopExecution() is synchronous.
* stapdyn/mutatee.h: Update prototypes.
* stapdyn/mutator.cxx: Update mutatee constructor calls.
David Smith [Wed, 6 Feb 2013 22:18:23 +0000 (16:18 -0600)]
Save and restore 'errno' in dyninst probes.
* tapsets.cxx (common_probe_entryfn_prologue): In dyninst mode, save errno
at the start of the probe.
(common_probe_entryfn_epilogue): In dyninst mode, restore errno at the
end of the probe.
Josh Stone [Tue, 5 Feb 2013 21:17:16 +0000 (13:17 -0800)]
Add kprobe.function.call, and squash nd_syscall.exit.return
* tapsets.cxx (register_standard_tapsets): Bind kprobe .call variants.
* man/stapprobes.3stap: Document this new possibility.
* tapset/linux/nd_syscalls.stp: Use .call to make sure that alias
suffixes can't tack a .return on nd_syscall.exit and .exit_group.
Josh Stone [Tue, 5 Feb 2013 19:31:37 +0000 (11:31 -0800)]
Add [nd_]syscall.ustat32.return
This adds the proper .return aliases for the syscall.ustat32 entry
aliases, rather than having them as part of syscall.ustat.return, so
way the entry/return probes are properly balanced. It also makes sure
that wildcards like syscall.ustat** don't end up in an incomplete
ustat.return probe due to implicit alias suffixes.
I considered wrapping this with version-compatibility checks, but IMO
the former behavior was broken enough that it isn't worth it.
* tapset/linux/syscalls2.stp: Split out syscall.ustat32.return.
* tapset/linux/nd_syscalls2.stp: Split out nd_syscall.ustat32.return.
* testsuite/buildok/syscalls2-detailed.stp: Test ustat32.return.
* testsuite/buildok/nd_syscalls2-detailed.stp: Test ustat32.return.
David Smith [Fri, 1 Feb 2013 17:01:40 +0000 (11:01 -0600)]
Fixed PR11955 by updating the signal tapset.
* tapset/linux/signal.stp (signal.send): Now uses the 'signal_generate'
tracepoint where available. Deprecated the 'send2queue' variable.
(signal.send.return): Deprecated.
(signal.handle): Now uses the 'signal_deliver' tracepoint where
available. Deprecated the 'oldset_addr' and 'regs' variables.
(signal.handle.return): Deprecated.
* testsuite/buildok/signal-detailed.stp: Updated with 'signal.send',
'signal.send.return', and 'signal.handle.return' deprecations.
* NEWS: Added deprecation notes.
Josh Stone [Thu, 31 Jan 2013 02:52:09 +0000 (18:52 -0800)]
PR14574 partial: Let stapdyn tests run despite the kernel
Some tests are guarded by [uprobes_p] or [uretprobes_p] before they're
allowed to run, but --runtime=dyninst cares not for such features.
Rework these tests so the kernel features are more tightly considered
only right before running in kernel mode.
Josh Stone [Wed, 30 Jan 2013 20:20:41 +0000 (12:20 -0800)]
PR14705: Modify SDT semaphores in stapdyn
For SDT probes which are guarded by a semaphore, stapdyn needs to update
the value to show when the probes are active.
* stapdyn/mutatee.h (mutatee::semaphores): New vector of variables in
this mutatee which represent active semaphores.
* stapdyn/mutatee.cxx (mutatee::update_semaphores): New, used to
increment or decrement the value of semaphores in this mutatee.
(mutatee::instrument_dynprobe_target): When a probe has a semaphore,
create a variable representation of it.
(mutatee::instrument_object_dynprobes): Increment semaphores in bulk.
(mutatee::copy_forked_instrumentation): Copy semaphore variables too.
(mutatee::remove_instrumentation): Decrement semaphores in bulk.
* tapsets.cxx (sdt_query::handle_query_module): Calculate the difference
in load addresses between .text and .data as semaphore_load_offset.
(sdt_query::record_semaphore): Subtract the semaphore_load_offset for
dyninst to get a file-based offset of the semaphore.
David Smith [Wed, 30 Jan 2013 21:11:48 +0000 (15:11 -0600)]
Add better cleanup to a setjmp.exp and statement.exp.
* testsuite/systemtap.base/setjmp.exp: Cleanup test programs. Allow the
user to override this using the '-v' vebose flag.
* testsuite/systemtap.base/statement.exp: Ditto.
Frank Ch. Eigler [Wed, 30 Jan 2013 14:41:34 +0000 (09:41 -0500)]
testsuite: conditionalize client-server tests on feature: NSS
* testsuite/lib/systemtap.exp (nss_p): New test proc.
(dyninst_p): Switch to globals instead of $env().
(setup_server): Use it.
* testsuite/systemtap.server/*.exp: Do an [nss_p] test early on.
Frank Ch. Eigler [Tue, 29 Jan 2013 21:25:03 +0000 (16:25 -0500)]
testsuite: fix systemtap.examples/check.exp to properly CHDIR back & forth
A failed test_check fragment (such as from virtualization/*.meta)
could result in loss of the original pwd=$builddir/testsuite, because
the loop neglected to restore the old pwd ($curdir) before
"continue"'ing. We now save & restore $pwd outside the loop in
addition to the intra-loop cwd twitchery.
Serguei Makarov [Fri, 25 Jan 2013 19:18:06 +0000 (14:18 -0500)]
PR11334: testsuite tweaks for merge
Keeping the separate re2c-migrate testsuite at the moment.
(I tried putting together a systemtap script with the testsuite,
but it winds up being too unwieldy, and I couldn't figure out
a good way to be able to switch it to 'one Expect test per regex'
mode on demand. Will get rid of separate regcomp testsuite once
I figure it out.)
Serguei Makarov [Thu, 10 Jan 2013 22:55:53 +0000 (17:55 -0500)]
PR11334: declutter re2c -- get rid of stream_lc.h
Note that the deletion of file_info is no big loss -- it was just
used to print a bunch of #line directives which have no relevance
to the output of a SystemTap script (and in fact would make pass-4
errors much more confusing by throwing off the line count!).
in directory re2c-migrate:
* stream_lc.h: delete file.
* token.h: delete stream_lc.h include.
(Token::Token): delete constructors that use file_info as an input.
* globals.cc, globals.h: delete stream_lc.h include and file_info stuff.
* code.cc: add missing includes.
(Rule::emit): do not print file_info stuff.
(basic_null_streambuf, basic_null_stream, null_streambuf, null_stream): moved from stream_lc.h.
(DFA::emit): do not print file_info stuff.
(<<): delete overloading for file_info.
* re.h (RuleLine): delete class.
* scanner.h (Scanner): no longer inherit from line_number.
Serguei Makarov [Wed, 12 Dec 2012 17:27:20 +0000 (12:27 -0500)]
PR11334: improved prepending of .*
Compile .* and store it as a regex, instead of prepending to the regex string.
(The previous commit's method can cause oddball test failures.)
* re2c-migrate/regcomp.h (class stapdfa): declare padRE to hold AST for ".*".
* re2c-migrate/regcomp.cxx (stapdfa::padRE): new static variable.
(stapdfa::stapdfa): prepend padRE (".*") unless the RegExp obviously begins with ^.
* re2c-migrate/re.h (class RegExp): add 'anchored' field.
(class AltOp, CatOp, CloseOp): set 'anchored' field correctly.
* re2c-migrate/actions.cc (RuleOp::RuleOp): set 'anchored' field correctly.
(mkAlt): set 'anchored' field correctly for returned expression.
Serguei Makarov [Tue, 4 Dec 2012 16:55:02 +0000 (11:55 -0500)]
PR11334: fix read-past-the-end error for .* and similar
Solved by the simple expedient of fixing the off-by-one error that caused
YYFILL to abort the match before the terminating '\0' could be returned,
and changing mkDot() (responsible for creating '.' regex) to forbid '\0'.
NOTE: This will have to be revisited due to reliance on explicit '\0'
matching. Namely, a tricky regex *might* try to break things by trying
to match '[s\0]*' or such. This will not read forbidden memory (YYFILL
is too airtight for that), but the match outcome will not be what one
would expect. So we should keep in mind that the regex syntax should
not allow '\0' as a regex match character.
* re2c-migrate/actions.cc (mkDot); detect '\0' instead of '\n' as string end.
* re2c-migrate/regcomp.cxx (emit_declaration): tweak YYFILL to include '\0'.
* re2c-migrate/regcomp.base/regtest.in.0: additional test case.
Serguei Makarov [Tue, 27 Nov 2012 18:59:02 +0000 (13:59 -0500)]
PR11334: custom regex parser & generation wrapper
Further progress -- this one emits code that correctly returns 1 or 0
depending on whether the regex correctly matched or not.
TODO -- re2c seems to anchor the regex on the left of the string, so
to allow a match throughout the string we need to put .* (or similar)
on the front of the regex.
TODO -- .* and similar fail to match due to expecting '\n' to terminate
the string. This is an assumption of re2c which can be fixed.
Serguei Makarov [Thu, 15 Nov 2012 19:24:28 +0000 (14:24 -0500)]
PR 11334: ugly hacky regcomp.cxx progress
Added a RuleOp to trigger { return 1; } on match success.
Added very early outline of regtest.cxx which emits a simple test program.
Next steps:
- polish up regtest.cxx and add a driver.
- trigger { return 0; } on match failure.
- currently, the matching seems to be anchored at the beginning of the string.
re2c can do unanchored matching, however, so I need to enable that.
Serguei Makarov [Wed, 7 Nov 2012 18:47:49 +0000 (13:47 -0500)]
PR11334: partial progress to wrapping re2c in regcomp.cxx.
To test out, cd build/re2c-migrate/, run make, and use ./regtest.
Lots of ommissions currently, and a known bug where re2c eats the first
character of the regexp at some point between the AST and the code output,
so this commit is definitely useful only as a status update...