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.
Mark Wielaard [Tue, 2 Feb 2010 12:47:19 +0000 (13:47 +0100)]
Make sure cfa_ops are always retrieved through dwfl global address.
dwflpp::translate_location() works on the dw address space, but
get_cfa_ops() starts out with dwfl calls (only dwarf_cfi_addrframe()
needs to be adjusted for bias).
* dwflpp.cxx (translate_location): Pass pc plus module bias through to
get_cfa_ops.
(get_cfa_ops): Adjust for bias when calling dwarf_cfi_addrframe(),
add frame start/end address when found if verbose logging.
* testsuite/systemtap.exelib/lib.stp: Add $foo and $bar variables to
process.function probes.
* testsuite/systemtap.exelib/libmarkunamestack.stp: Likewise.
* testsuite/systemtap.exelib/lib.tcl: Expect correct values for
process.function probe variables.
* testsuite/systemtap.exelib/libmarkunamestack.tcl: Likewise.
Josh Stone [Fri, 29 Jan 2010 05:00:58 +0000 (21:00 -0800)]
PR11234: Ensure __get_argv doesn't overflow
That function was calling strlcpy as if the return value was the number
of bytes copied, but strlcpy actually returns the length of the input
string. We now use min() to handle the case when it's bigger than the
buffer length, and drop out of the loop when that happens.
David Smith [Mon, 25 Jan 2010 21:04:55 +0000 (15:04 -0600)]
Fixed PR 11220 by setting MAP_STRING_LENGTH to MAXSTRINGLEN.
* runtime/map.h: Set MAP_STRING_LENGTH to MAXSTRINGLEN so that large
strings can be stored in arrays.
* testsuite/systemtap.base/array_string.exp: New testcase.