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...
Serguei Makarov [Fri, 19 Oct 2012 19:49:43 +0000 (15:49 -0400)]
PR11334: stub out space for implementation of =~ operator.
* staptree.h: define regex_query AST node and visitor behaviour.
* staptree.cxx: ditto.
* parse.cxx: parse nonassociative =~ at same precedence as comparison
-- see parse_comparison_or_regex_query().
* elaborate.cxx: semantic check / tentatively dead code eliminate uses of =~.
* elaborate.h: ditto.
* translate.cxx: generate pointless stub code for =~.
* tapset/string.stp: stubs listing matched() functions et al for subgroup feature.
EMBARRASSINGLY OBVIOUS TODO: parse.cxx allows parsing !~, but doesn't
distinguish it from =~ in any fashion at the moment. Doesn't matter
since neither actually invokes a dfa in this commit!
NEXT STEP: gather the regexes we use in a global regcomp table.
David Smith [Mon, 28 Jan 2013 19:59:07 +0000 (13:59 -0600)]
PR15074 fixed by making pthread_stacks.exp more robust.
* testsuite/systemtap.base/pthread_stacks.exp: Add a test to see if
glibc's debuginfo is installed.
* testsuite/systemtap.base/pthread_stacks.c (main): If pthread_create()
fails (which it can on low-memory systems), don't error if we've already
created at least 100 threads.
David Smith [Fri, 25 Jan 2013 19:26:31 +0000 (13:26 -0600)]
Two testsuite fixes.
* testsuite/lib/stap_run.exp: Append runtime name to the test name (if
present).
* testsuite/systemtap.base/optim_arridx.exp (optim_arridx_run): Instead of
having its own test function, just call stap_run_exact instead.
David Smith [Wed, 23 Jan 2013 22:21:44 +0000 (16:21 -0600)]
Improve library.exp error handling and readability.
* testsuite/systemtap.base/library.exp: Indented for better readability.
When an error occurs, don't cleanup the test executables, since that
causes all the remaining tests to fail. Instead, just cleanup at the
end.
David Smith [Wed, 23 Jan 2013 17:59:07 +0000 (11:59 -0600)]
Fix library.exp so it will pass on systems with uretprobes.
* testsuite/systemtap.base/library.exp: Fix a couple of issues. Fix
a regular expression to match the new warning string for no
debuginfo. Don't depend on glibc debuginfo being installed in the
'.exported' test.
David Smith [Tue, 22 Jan 2013 16:26:18 +0000 (10:26 -0600)]
PR14708 partial fix: Get 'process.end' probes (sort of) working.
* stapdyn/mutator.cxx (mutator::exit_callback): Instead of calling letting
the mutatee handle the exit callback, handle it in the mutator. This
means the probe's context is wrong, but it does get called.
* stapdyn/mutator.h: Add 'utrace_enter_fn' variable.
* stapdyn/mutatee.cxx (mutatee::find_attached_probes): New function.
* stapdyn/mutatee.h: Add mutatee::find_attached_probes() function
declaration.
* testsuite/systemtap.base/utrace_p5.exp: Add more tests.
Josh Stone [Sat, 19 Jan 2013 00:04:10 +0000 (16:04 -0800)]
PR14706: Always register the stapdyn fork callback
We need to watch forks regardless of whether we have process.being
probes, because there may still be other types of probes that should be
triggered in child processes.
Josh Stone [Fri, 18 Jan 2013 23:23:12 +0000 (15:23 -0800)]
PR14706: Follow forks in stapdyn and enable process.begin
* stapdyn/mutatee.cxx (mutatee::call_utrace_dynprobe): Newly abstracted
function to call utrace handlers from various contexts.
(mutatee::begin_callback): New, runs process.begin callbacks.
(mutatee::exit_callback): Use call_utrace_dynprobe.
(mutatee::thread_callback): Use call_utrace_dynprobe.
(mutatee::copy_forked_instrumentation): New, set all the member
variables for a newly-forked process.
* stapdyn/mutator.cxx (mutator::run): Trigger process.begin in target.
(mutator::post_fork_callback): Create an attached mutatee for the
fork, copy the instrumentation status, and trigger process.begin.
David Smith [Fri, 18 Jan 2013 22:12:37 +0000 (16:12 -0600)]
PR14574 partial fix: Add dyninst support to several tests.
* testsuite/lib/stap_run.exp (stap_run): Only append the arguments to the
test name if there are arguments.
* testsuite/systemtap.base/be_order.exp: Add dyninst support.
* testsuite/systemtap.base/const_value.exp: Ditto.
* testsuite/systemtap.base/control_limits.exp: Ditto.
* testsuite/systemtap.base/cu-decl.exp: Ditto.
* testsuite/systemtap.base/cxxclass.exp: Ditto.
* testsuite/systemtap.base/div0.exp: Ditto.
David Smith [Fri, 18 Jan 2013 21:38:16 +0000 (15:38 -0600)]
PR14574 (partial): Improve dyninst ctime.stp tapset and test it.
* testsuite/systemtap.base/ctime.exp: Add dyninst support.
* tapset/dyninst/ctime.stp: When an error occurs, return "<invalid time>"
instead of the empty string.
Josh Stone [Fri, 18 Jan 2013 02:04:59 +0000 (18:04 -0800)]
PR14706: Use shared memory between stapdyn and the target
Probes that are not process-specific (begin/end/timers) are now always
handled within stapdyn itself, while the rest (uprobes/utrace) continue
to run in the target process. The shared memory for globals and such is
allocated and initialized in stapdyn, then just mapped by the target.
This paves the way for allowing multiple target process, especially
following fork/exec, as we're no longer tied to a single address space.
* stapdyn/mutator.cxx (mutator::run_module_init): Manually initialize
shm and save the generated name. Run the session init locally, and
then map the shm in the target process too. For compat modules that
don't have shm functions, keep running session init in the target.
(mutator::run_module_exit): Always run the session exit directly for
shm-enabled modules, but still run it in-target for compat modules.
* stapdyn/mutatee.cxx (mutatee::call_function): Add a variant of this
function that takes an argument list.
* runtime/dyninst/runtime.h (stp_dyninst_ctor): Initialize the runtime
contexts and print system here so it happens for all processes, rather
than only once globally in session init. Also save the rc here to be
reported properly by the init call.
* runtime/dyninst/print.c: Add defensive checks for initialization.
* runtime/dyninst/shm.c (_stp_shm_connect): Fix the debug message.
* runtime/common_probe_context.h: Add a probe_index to the context
structure, because we can't directly access e.g. probe_point pointers
that other processes have set. With an index, we can get the same
info from stap_probes[].
* tapsets.cxx (common_probe_entryfn_prologue): Set probe_index.
* translate.cxx (translate_pass): Provide a simple access function for
the probe_point to ease include order, so places that need it don't
have to come after stap_probe is declared. (Even its type is dynamic.)
* runtime/dyninst/runtime_context.h (_stp_runtime_context_wait): Use the
index to indirectly get the stuck probe point, since c->probe_point is
not necessarily in our address space.
David Smith [Thu, 17 Jan 2013 20:07:45 +0000 (14:07 -0600)]
Add dyninst support to more testcases.
* testsuite/lib/stap_run.exp: Append extra arguments to the test name (so
we can tell the difference between tests with different runtimes.
* testsuite/systemtap.base/add.exp: Add dyninst support.
* testsuite/systemtap.base/alias-condition.exp: Ditto.
* testsuite/systemtap.base/alias_suffixes.exp: Ditto.
* testsuite/systemtap.base/arith.exp: Ditto.
* testsuite/systemtap.base/arith.stp: Ditto.
* testsuite/systemtap.base/arith_limits.exp: Ditto.
* testsuite/systemtap.base/array_size.exp: Ditto.
* testsuite/systemtap.base/array_string.exp: Ditto.
* testsuite/systemtap.base/at_var_mark.exp: Ditto.
* testsuite/systemtap.base/beginenderror.exp: Ditto.
* testsuite/systemtap.base/bench.exp: Ditto.
David Smith [Thu, 17 Jan 2013 17:34:37 +0000 (11:34 -0600)]
Improve testsuite by providing a global 5 second wait function.
* testsuite/systemtap.clone/main_quiesce.exp (wait_5_secs): Move function
to stap_run.exp so other tests can use it.
* testsuite/lib/stap_run.exp: Moved 'wait_5_secs' function here.
* testsuite/systemtap.base/utrace_p5.exp: Remove 'wait_5_sec' function and
use global 'wait_5_secs' instead.
* testsuite/systemtap.base/at_var_mark.exp: Use 'wait_5_secs' function to
give test program a chance to run a bit.
* testsuite/systemtap.clone/probe_by_pid.exp (sleep_5_secs): Removed
unused function.
Frank Ch. Eigler [Thu, 17 Jan 2013 04:10:20 +0000 (23:10 -0500)]
runtime: use stp_module ->path instead of abbreviated ->name in messages
One problem is that ->name is ambiguous, e.g. if probe wildcards
expand to different path files, but with the same basename. That
makes e.g. relocation or unwind dbug/diagnostic messages unclear.
So we switch over to using m->path as much as possible.