Josh Stone [Tue, 2 Mar 2010 23:57:58 +0000 (15:57 -0800)]
PR11246 cont'd: Add options for cache control
--disable-cache : turn off all caching
--clean-cache : clean up stale entries and then quit
--poison-cache : force regeneration of items that would have hit the cache
These are undocumented for now, until we decide whether they are
generally useful.
* main.cxx (main): Parse the new options.
* session.h (systemtap_session): Add poison_cache; document the others.
* clean.cxx (clean_cache): No longer static.
(get_stapconf_from_cache, get_script_from_cache): Respect poison.
* tapsets.cxx (tracepoint_builder::get_tracequery_module): Ditto.
(dwarf_cast_expanding_visitor::filter_special_modules): Ditto.
Josh Stone [Tue, 2 Mar 2010 02:42:18 +0000 (18:42 -0800)]
PR11246 cont'd: Separate script/stapconf caching
I'm separating the caching and creation logic for stapconf, so it can be
conditionalized on s.use_cache instead of s.use_script_cache.
* session.h (systemtap_session): Store base_hash for better reuse.
* hash.cxx (get_base_hash): Get the base from the session, or build it.
(find_hash): Split into separate script/stapconf versions.
* cache.cxx (add_to_cache, get_from_cache): Ditto.
* main.cxx (main): Adapt caller, and delay stapconf until pass-4.
Josh Stone [Tue, 2 Mar 2010 01:27:53 +0000 (17:27 -0800)]
PR11246: Add more granular cache control
There are some module options that require us to disable caching for the
script, but before now this had a global effect. There are some cache
objects, like tracepoint and @cast query modules, which we would like to
cache even when the script itself needs to be uncached.
* session.h (systemtap_session): New use_script_cache flag.
* main.cxx (main): -m & -k can just disable the script cache. Failure to
create the cache directories still disables all caching.
* hash.cxx (create_hashdir): Failure disables all caching.
* cache.cxx (add_to_cache): Failure only toggles the script caching. If
the stapconf fails though, we don't need to block the .ko reuse.
David Smith [Mon, 1 Mar 2010 21:17:09 +0000 (15:17 -0600)]
Fixed PR 11336 by using a wait queue to wait on procfs file availability.
* runtime/procfs-probes.c: Removed old kernel 2.6.16 code. Simplified
_spp_lock macros.
(_stp_proc_open_file): If file is busy, use a wait queue to wait on it
being available.
(_stp_proc_release_file): Decrease open count.
* tapset-procfs.cxx (emit_module_init): Updated procfs probe
initialization/shutdown routine names.
(emit_module_exit): Ditto.
Josh Stone [Sat, 27 Feb 2010 00:25:45 +0000 (16:25 -0800)]
Squash elision warnings on synthetic functions
* staptree.h (functiondecl): Add a synthetic flag.
* elaborate.cxx (semantic_pass_opt1): Don't warn about synthetic funcs.
* tapsets.cxx (dwarf_var_expanding_visitor::visit_target_symbol): Mark
the new function as synthetic.
(dwarf_cast_expanding_visitor::visit_cast_op): Ditto.
(tracepoint_var_expanding_visitor::visit_target_symbol_arg): Ditto.
* tapset-perfmon.cxx
(perfmon_var_expanding_visitor::visit_target_symbol): Ditto.
* tapset-procfs.cxx (procfs_var_expanding_visitor::visit_target_symbol):
Ditto.
* testsuite/semok/thirtyeight.stp: New check with -W and @defined.
Josh Stone [Fri, 26 Feb 2010 00:20:50 +0000 (16:20 -0800)]
Expand @defined to support more cases
* tapsets.cxx (var_expanding_visitor::visit_defined_op): If no error was
raised or replacement made on a target_symbol, then its @defined state
is still indeterminate. Some later pass (like @cast) might handle it.
* elaborate.cxx (const_folder::visit_defined_op): Squash any escapees.
* testsuite/semok/thirtysix.stp: Add more variants.
Josh Stone [Thu, 25 Feb 2010 23:15:19 +0000 (15:15 -0800)]
PR11326: Make an early check for saved-return-$var validity
We now check validity *before* the entry-probe is generated, so invalid
$vars have a chance to be properly optimized without error.
* tapsets.cxx
(dwarf_var_expanding_visitor::visit_target_symbol_saved_return):
Attempt variable expansion immediately, and skip out on failure.
* testsuite/semok/thirtysix.stp: unblock the previously broken part.
Josh Stone [Thu, 25 Feb 2010 00:43:06 +0000 (16:43 -0800)]
PR10719 cont'd: const-fold logical ops
We can compute results between two literals, we can short-circuit some
literals on the left ("0&&x", "1||x"), and we can simplify literals on
the right if the left has no side effect ("x&&0", "x||1").
Josh Stone [Sat, 20 Feb 2010 02:32:52 +0000 (18:32 -0800)]
PR10719 part 1: Partial constant folding
This implements constant folding for if/for/foreach, unary expressions,
and ternary expressions. Binary expressions are TODO...
* elaborate.cxx (const_folder): New visitor to collapse constants.
(semantic_pass_const_fold): Drive everything through const_folder.
(semantic_pass_optimize1): Call it.
David Smith [Tue, 23 Feb 2010 21:57:25 +0000 (15:57 -0600)]
Fixed PR 11269 by properly handling mmap syscall 'fd' argument.
* testsuite/systemtap.syscall/mmap.c (main): Added mprotect and mremap
testing (along with testing of anonymous maps).
* tapset/i386/syscalls.stp: In mmap probes, handle the fact that the
kernel gets an unsigned long 'fd', but the user-side passes a signed
int.
* tapset/i386/nd_syscalls.stp: Ditto.
* tapset/ia64/syscalls.stp: Ditto.
* tapset/powerpc/nd_syscalls.stp: Ditto.
* tapset/powerpc/syscalls.stp: Ditto.
* tapset/x86_64/nd_syscalls.stp: Ditto.
* tapset/x86_64/syscalls.stp: Ditto.
David Smith [Tue, 23 Feb 2010 18:48:49 +0000 (12:48 -0600)]
PR 10690 (partial fix). Handle '.=' operator in procfs probes.
* tapsets.h (var_expanding_visitor): Add 'valid_ops' and 'op' member
variables.
* tapsets.cxx (var_expanding_visitor::var_expanding_visitor): Set
'valid_ops' to '='. By default, var_expanding_visitor classes only
handle the '=' operator.
(var_expanding_visitor::visit_assignment): Remember what operator we're
handling. When an operator is found that isn't in the 'valid_ops' set,
error.
* tapset-procfs.cxx
(procfs_var_expanding_visitor::procfs_var_expanding_visitor): Add '.='
to the 'valid_ops' set.
(procfs_var_expanding_visitor::visit_target_symbol): Handle the '.='
operator when the target variable is an lvalue.
Mark Wielaard [Mon, 22 Feb 2010 12:43:41 +0000 (13:43 +0100)]
Prevent accidental global cleanup triggering for syscall test.tcl.
Later tests might trigger a cleanup and might set the global dir variable
leading to the syscall test.tcl trying to do an exec rm -rf on whatever
dir was set. So rename proc cleanup and global dir in syscall test.tcl to
something a bit less likely to clash.
* testsuite/systemtap.syscall/test.tcl: Rename proc cleanup to syscall_cleanup
and global dir to syscall_dir.
* testsuite/systemtap.syscall/test-debug.tcl: Likewise.
Frank Ch. Eigler [Sun, 21 Feb 2010 16:29:04 +0000 (11:29 -0500)]
hwbkpt: simplify diagnostics and code
* tapsets.cxx (hwbkpt_derivedc_probe_group): Lose max_... field.
Rename hwbkpt_probes_vector -> hwbkpt_probes.
(enroll): Instead set it here, emit normal suppressible warning if
exceeded.
(emit_*): Use newline(NN) etc. for proper indentation of generated code.
(emit_module_init): Defer most potential problems to
register_wide_hw_breakpoint() instead of preemptive errors.
* translate.cxx (emit_module_init): Assert 0 indentation more frequently.
Mark Wielaard [Thu, 18 Feb 2010 23:11:18 +0000 (00:11 +0100)]
Allow CONFIG_foo COMPARISON-OP CONFIG_bar in preprocessor conditionals.
* parse.cxx (eval_pp_conditional): If rhs and lhs are both CONFIG_...
identifiers try to convert them both to numbers or otherwise threat
them both as strings for eval_comparison.
* testsuite/semok/config_config.stp: New test.
Dave Brolley [Wed, 17 Feb 2010 21:18:10 +0000 (16:18 -0500)]
Improved server certificate management. ulimit for stap-server only.
- Server now generates a new certificate when old one expires.
- Certificates now valid for 1 year.
- ulimit for stap-server-connect now only set for stap-server
user and only when override variable is not set.
Josh Stone [Tue, 16 Feb 2010 05:27:37 +0000 (21:27 -0800)]
Use clamping to more easily normalize input values
The kernel has min/max/clamp macros to make range comparisons easier.
Clamp is a newer invention, but we can define it for older kernels in
terms of min and max.
Josh Stone [Tue, 16 Feb 2010 05:21:02 +0000 (21:21 -0800)]
PR11282: Keep the md4 state in the hash copy constructor
We were getting new hash collisions, because the new hash copy
constructor was restarting the md4 computation. Everything from
get_base_hash was thus lost.
* hash.h (hash::hash): Keep the md4 state when copying.
Dave Brolley [Mon, 15 Feb 2010 18:56:20 +0000 (13:56 -0500)]
Rework identification of probes allowed for unprivileged users.
- Bind unprivileged permission at probe registration time.
- Remove check_unprivileged filter from derived_probe_builder
and its children.
- Add test suites for unprivilegedok and unprivilegedko.
Add simple test for PR10257 (sprint(@hist_linear)).
Test is simple, because print and sprint uses the same code for handling
@hist_* and it is not intended for playing with MAXSTRINGLEN, which is
required anyway for bigger histograms (the one generated here consists
of only 127 characters).
When PR10690 (need way to produce bigger procfs output) will be fixed,
then we should add another test for both PRs with normal histogram.
David Smith [Wed, 10 Feb 2010 22:35:46 +0000 (16:35 -0600)]
Fixed PR 11270 by adding nd_syscall testcase.
* testsuite/systemtap.syscall/test.tcl: Now uses global variable
'test_script' to find test script to run.
* testsuite/systemtap.syscall/syscall.exp: Sets test_script.
* testsuite/systemtap.syscall/nd_sys.stp: New test script. Copy of
sys.stp, but uses nd_syscall probes.
* testsuite/systemtap.syscall/nd_syscall.exp: New testcase. Copy of
syscall.exp, but uses nd_sys.stp test script.
Mark Wielaard [Tue, 9 Feb 2010 11:22:37 +0000 (12:22 +0100)]
rhbz#563114 Make syscall.pipe sys32_pipe probe alias optional on x86_64.
Some distributions might have backported the pipe fd leak patch and removed
the sys32_pipe kernel function even before 2.6.32. So make the probe alias
optional instead of relying on a version check.
* tapset/x86_64/syscalls.stp (syscall.pipe): Make alias optional.
(syscall.pipe.return): Likewise.
David Smith [Mon, 8 Feb 2010 21:59:29 +0000 (15:59 -0600)]
Fixed BZ559643 by doing 'spawn;expect;wait' instead of 'spawn;wait;expect'.
* testsuite/systemtap.base/labels.exp: Corrected order of
'spawn;expect;wait' calls. Added 'wait' calls when needed. Also,
doesn't run the "labels exe .label" test if uprobes isn't supported.
* tapsets-mark.cxx, tapsets.cxx: Don't even publish probe point families that are
inappropriate for use in --unprivileged mode.
(dwarf_derived_probe_*unprivileged*): Remove, to default to blanket no-permission
rather than emit_process_owner_permission mode.
* testsuite/semko/fortyeight.stp: New test.
Josh Stone [Fri, 5 Feb 2010 01:47:31 +0000 (17:47 -0800)]
PR11234: Rewrite __get_argv without embedded-C
We now implement __get_argv's string building in pure stap script.
Also, every argument is now quoted, which is different than before, but
it's much more robust about handling special characters.
David Smith [Wed, 3 Feb 2010 17:56:58 +0000 (11:56 -0600)]
Fixed PR 11078. Changed code to avoided procfs race condition.
* runtime/procfs.c: Allow STP_MAX_PROCFS_FILES define to be overridden.
(_stp_create_procfs): Calls proc_create() instead of create_proc_entry()
to avoid a race condition.
* runtime/procfs-probes.c: New file containing procfs probe support
routines.
* tapset-procfs.cxx (procfs_derived_probe::join_group): Update struct
_stp_procfs_data definition.
(procfs_derived_probe::emit_module_decls): Include procfs-probes.c,
which is where the definition of struct stap_procfs_probe exists.
Update generated routines to read/write procfs data.
(procfs_derived_probe_group::emit_module_init): Pass file_operations
argument to _stp_create_procfs(). Initialize mutex.
(procfs_var_expanding_visitor::visit_target_symbol): Update generated
code.
Wenji Huang [Wed, 3 Feb 2010 02:21:24 +0000 (10:21 +0800)]
PR9931: generate log to help diagnosing occasional cache hash collisions
Ideas from Frank Ch. Eigler:
- extending the hash.add() function to pass names along with the
hash-mix values, so that class hash can internally track the
hash-report string
- storing the reports themselves in the cache, beside the .ko / .c
files, and changing the cache-size-limit logic to delete
these .txt files upon garbage collection
* hash.h : New member parm_stream.
* hash.cxx (get_parms): New function to convert parms stream to string.
(hash::add): Aggregrate parms stream.
(create_hash_log): New function to log hash operation.
(find_*_hash): Log hash at the end of function.
* cache.cxx (clean_cache): Remove log when cache reaches limitation.
David Smith [Tue, 2 Feb 2010 22:14:39 +0000 (16:14 -0600)]
Fix procfs_write.exp so that it will pass under RHELl5.
* testsuite/systemtap.base/procfs_write.exp: Small changes for RHEL5
support.
* testsuite/lib/stap_run.exp (stap_run): Increase maximum number of
characters to match against.
Dave Brolley [Tue, 2 Feb 2010 19:08:31 +0000 (14:08 -0500)]
Compile server logging and robustness.
Log certificate location and status when starting server.
Additional care in handling arguments in stap-serverd.
New test case discovered by fuzzing added and fixed.