Frank Ch. Eigler [Thu, 30 Jun 2016 16:08:07 +0000 (12:08 -0400)]
PR20307: fix references to private global in tapset
Previous code could not resolve a reference to a private global
(defined in a tapset) within a probe alias (from that same tapset).
We now try matching up the mangled name in addition to the plain one
in symresolution_info::find_var() when searching the
session.library_files[].globals.
David Smith [Tue, 28 Jun 2016 15:12:25 +0000 (10:12 -0500)]
Partial 20236 fix: Add user_TYPE_error functions that throw errors.
* tapset/uconversions.stp: Add new functions 'user_TYPE_error()' (where
TYPE is 'char', 'short', 'ushort', 'int', 'long', 'ulong', 'int8',
'uint8', 'int16', 'uint16', 'int32', 'uint32', or 'int64'). These
funtions thow an error if the value to be read isn't
accessible. Reimplement 'user_TYPE()' and 'user_TYPE_warn()' functions
in terms of user_TYPE_error() functions.
* tapset/linux/aux_syscalls.stp: Replace '__user_pointer' with
'user_long_error'.
* testsuite/buildok/conversions-embedded.stp: Add tests for new functions.
Martin Cermak [Tue, 28 Jun 2016 14:25:33 +0000 (16:25 +0200)]
Don't error on missing systemtap.sum
Don't report error if systemtap.sum isn't available to tail.
This was producing optically disturbing error message e.g. in case
the testsuite got run without dejagnu installed.
Martin Cermak [Tue, 28 Jun 2016 12:21:04 +0000 (14:21 +0200)]
Implement PR12748 by providing the syscall_table tapset files.
This patch provides architecture specific syscall tables, tapset
script functions syscall_num() and syscall_name() for acessing
them, test coverage, and a script for re-generating the syscall
tables based on strace source code.
* scripts/dump-syscalls.sh: Helper script for re-generating the
syscall tables based on strace source code.
* tapset/linux/syscall_table.stp: Tapset script providing
functions syscall_num() and syscall_name().
* tapset/linux/arm/syscall_num.stp: Syscall table.
* tapset/linux/arm64/syscall_num.stp: Ditto.
* tapset/linux/i386/syscall_num.stp: Ditto.
* tapset/linux/powerpc/syscall_num.stp: Ditto.
* tapset/linux/s390/syscall_num.stp: Ditto.
* tapset/linux/x86_64/syscall_num.stp: Ditto.
* testsuite/systemtap.syscall/sys.stp: A testsuite bit.
* testsuite/systemtap.syscall/syscall.exp: Ditto.
* testsuite/systemtap.syscall/tapset/syscall.stp: Ditto.
David Smith [Mon, 27 Jun 2016 17:57:05 +0000 (12:57 -0500)]
Fix PR20298 by updating the unprivileged_embedded_C.exp test case.
* testsuite/systemtap.unprivileged/unprivileged_embedded_C.exp: Several
changes. Now only tests embedded C functions (since we can't really know
if pure script functions are privileged or not). Look for tapset files
in tapset/linux and in tapset/linux/${ARCH}. Now test all the embedded C
functions intead of a subset. Add a "transitive" test, to make sure
privileged embedded C functions can't be called by script functions.
Nikolay Borisov [Mon, 27 Jun 2016 16:46:35 +0000 (19:46 +0300)]
Add the '-p4' options when exemplifying the module compilation
Currently the example command which supposedly should compile the
instrumentation module is missing the '-p4' option, meaning that
upon running it will compile and run the module. In order to make
the command more in sync with what this particular chapter is about,
add the -p4 options so that after running the command the user gets
to copy the resulting module.
Signed-off-by: Nikolay Borisov <n.borisov.lkml@gmail.com>
Felix Lu [Tue, 21 Jun 2016 20:47:24 +0000 (16:47 -0400)]
Improve error messages
List the probe builders tried during resolution.
* dwflpp.cxx: Display error message when using wildcard for linenumber
mode if no matches.
* elaborate.cxx:
- match_node::find_and_build: Accumulate builders tried
when no probes were resolved.
- derive_probes: Display builders in error chain.
* elaborate.h: New name() for derived_probe_builder.
Martin Cermak [Tue, 21 Jun 2016 14:07:02 +0000 (16:07 +0200)]
Testsuite resume mode only works with its own files.
This update makes the testsuite resume mode only work with its own
files, not touching logs that the user might have set aside for
his/her own reference in the testsuite directory. After this
update, the log names "reserved" for the testsuite resume mode
functionality are systemtap.temp{1,2}.{log,sum}.
David Smith [Fri, 17 Jun 2016 14:16:15 +0000 (09:16 -0500)]
Partial 20236 fix: Cleanup memory accesses and always call lookup_bad_addr().
* runtime/linux/loc2c-runtime.h: Fairly serious rewrite of the
deref/store_deref macros. Instead of custom assembly language macros for
each arch, now we just use the kernel's routines.
(__stp_deref_nocheck): New macro.
(_stp_deref_nofault): New macro.
(__stp_store_deref_nocheck): New macro.
(_stp_store_deref_nofault): New macro.
(kderef_buffer): Rewrote using lookup_bad_addr() and
__stp_deref_nocheck(), allowing us to do 1 address check at the start of
the function instead of checking byte by byte.
(kderef_string): Ditto.
(_stp_store_deref_string): New macro.
(store_kderef_string): Rewrite in terms of _stp_store_deref_string().
(store_uderef_string): Ditto.
* runtime/linux/copy.c (_stp_strncpy_from_user): Always use the kernel's
strncpy_from_user(). Call lookup_bad_addr() on target address.
(_stp_copy_from_user): Call lookup_bad_addr() on target address.
* runtime/stp_string.h (_stp_read_address): Delete
macro. _stp_deref_nofault() can be used instead.
* runtime/stp_string.c (_stp_decode_utf8): Use new macro
_stp_deref_nofault() instead of _stp_read_address().
* runtime/unwind.c: Ditto.
* runtime/unwind/unwind.h (read_ptr_sect): Ditto.
* runtime/addr-map.h: New file.
* runtime/addr-map.c: Include addr-map.h.
* runtime/runtime.h: Include addr-map.h so that early code can use
lookup_bad_addr().
* runtime/linux/addr-map.c (lookup_bad_addr): Updated prototype.
* runtime/dyninst/addr-map.c (lookup_bad_addr): Update function
prototype. Add copyright header.
* runtime/dyninst/loc2c-runtime.h (_stp_deref_nofault): New macro to match
linux runtime changes.
Josh Stone [Thu, 16 Jun 2016 23:32:50 +0000 (16:32 -0700)]
testsuite: refactor pthreadprobes.exp
- move the main script into its own pthreadprobes.stp
- reduce repetition with macros, aliases, and an array of counters
- suppress warnings from stapdyn so individual failures can be checked
David Smith [Thu, 16 Jun 2016 17:26:06 +0000 (12:26 -0500)]
Make some small improvements to [nd_]syscall.fanotify_mark for RHEL7.
* tapset/linux/syscalls.stp (syscall.fanotify_mark): Call
__syscall_gate_compat_simple to avoid compat calls in the real syscall.
* tapset/linux/nd_syscalls.stp (nd_syscall.fanotify_mark): Ditto.
* testsuite/systemtap.syscall/fanotify.c: Make the fanotify file
descriptor non-blocking, to avoid the testcase hanging on read.
Cody Santing [Wed, 15 Jun 2016 13:47:50 +0000 (09:47 -0400)]
PR11637: Completed test cases, updated documentation
/NEWS: Updated NEWS to include information about set_user_*() functions
/doc/SystemTap_Tapset_Referemce/tapsets.tmpl: Include new functions in tapsets documentation
/testsuite/systemtap.base/set_user.c: Generates user space address for use in test case
/testsuite/systemtap.base/set_user.stp: Updated test case to test all functions
/testsuite/systemtap.base/set_user_fail.stp: Removed test case
David Smith [Tue, 14 Jun 2016 13:34:04 +0000 (08:34 -0500)]
Partial 20236 fix: Add access_ok() to lookup_bad_addr().
* runtime/linux/addr-map.c (lookup_bad_addr): Now calls access_ok(), which
required the addition of a 'type' argument. In addition, there are now 2
versions of lookup_bad_addr(), the new one doesn't bother searching the
bad address database, since we don't populate that yet.
* runtime/dyninst/addr-map.c (lookup_bad_addr): Added dummy 'type'
argument.
* runtime/linux/loc2c-runtime.h: Add either VERIFY_READ or VERIFY_WRITE to
every lookup_bad_addr() call.
David Smith [Fri, 10 Jun 2016 19:52:57 +0000 (14:52 -0500)]
Update 4 syscall tests for rawhide.
* testsuite/systemtap.syscall/recvmmsg.c: Skip a test that causes a
SEGFAULT on rawhide's glibc.
* testsuite/systemtap.syscall/recvmsg.c: Ditto.
* testsuite/systemtap.syscall/sendmsg.c: Ditto.
* testsuite/systemtap.syscall/sendmmsg.c: Create our own version of
sendmmsg(), since rawhide's glibc likes to substitute sendmsg() for
sendmmsg().
Martin Cermak [Wed, 8 Jun 2016 10:47:00 +0000 (12:47 +0200)]
Fix PR20211 by aimplementing the "resume mode" of the testsuite.
Once the SYSTEMTAP_TESTSUITE_RESUME environmental variable is set
to some non-zero value, the testsuite can run in "resume mode".
In this mode, tests, that have previously been run, are not being
re-executed, and their existing test results are being reused and
merged instead.
This can be useful e.g. when some of the tests causes kernel panic
or stall. Using the "resume mode", it is possible to reboot the
testing box, and re-run the testsuite skipping already executed
tests (incl. the one that caused the panic or stall - which will
stay "unfinished").
The "make list-unfinished" lists all such unfinished testcases.
Those need additional investigation.
The "resume mode" can be used with "make installcheck", or
"make installcheck-parallel".
Cody Santing [Tue, 7 Jun 2016 15:29:12 +0000 (11:29 -0400)]
11637: Added test cases, added to set_user_* functions
tapset/uconversion-guru.stp : Added deref_fault handlers, /* guru */ tag as well as comments.
testsuite/systemtap.base/set_user.c: Used to generate user space address
testsuite/systemtap.base/set_user.exp: Added to incorporate into testsuite
testsuite/systemtap.base/set_user.stp: Calls set_user_* functions and confirms values written to correct address
testsuite/systemtap.base/set_user_fail.stp: Attempt to write to kernel space address
Martin Cermak [Fri, 27 May 2016 19:41:49 +0000 (21:41 +0200)]
Re-fix PR19926 by simplifying previous implementation.
This reimplementation of the @const() operator (0a7eb12d191)
is based on PR20136, comment 3. It moves all the logic to the
parser. No elaboration involved.
David Smith [Fri, 27 May 2016 16:19:03 +0000 (11:19 -0500)]
Fix PR20158 by updating the runtime for the 4.6 kernel.
* buildrun.cxx (compile_pass): Added autoconf-stacktrace_ops-int-address.c
compile test.
* stack.c: (print_stack_address): If STAPCONF_STACKTRACE_OPS_INT_ADDRESS
is defined, the function returns a int instead of being a void
function.
* runtime/linux/autoconf-stacktrace_ops-int-address.c: New autoconf-style
test.
David Smith [Thu, 26 May 2016 19:17:58 +0000 (14:17 -0500)]
Fix PR20131 by making wildcard library paths work in probe specifications.
* tapsets.cxx (dwarf_builder::build): Fix logic error with commit c30ff77. If the library path isn't fully resolved, then use the path the
user specified.
* testsuite/systemtap.base/listing_mode.exp: Decrease failures by being
more forgiving about getting a full library path in 'stap -l' output.
David Smith [Mon, 23 May 2016 15:26:08 +0000 (10:26 -0500)]
Fix PR17055 by reading perf values in a sleepable context.
* tapsets.cxx (common_probe_entryfn_prologue): Add 'declaration_callback'
and 'pre_context_callback' to allow callers to add to output prologue.
(dwarf_derived_probe::emit_probe_local_init): For perf values, instead
of reading the values here, just copy the values from where we stashed
them when we read them before (when we could sleep).
(uprobe_derived_probe::emit_perf_read_handler): New function.
(uprobe_derived_probe_group::emit_module_perf_read_handlers): Ditto.
(udpg_entryfn_prologue_declaration_callback): Ditto.
(udpg_entryfn_prologue_pre_context_callback): Ditto.
(uprobe_derived_probe_group::emit_module_utrace_decls): Call
new function emit_module_perf_read_handlers().
(uprobe_derived_probe_group::emit_module_decls): Figure out the maximun
number of perf counters used per probe.
* tapsets.h: Add new callbacks to common_probe_entryfn_prologue().
* runtime/linux/uprobes-common.h (stap_uprobe_spec): Add
'perf_read_handler' to actually read perf values.
* runtime/linux/uprobes-inode.c (stapiu_consumer): Ditto.
* runtime/linux/runtime.h: After loading the task_finder code, load the
perf code if needed.
* runtime/common_probe_context.h: Add 'perf_read_values' to the context
structure when we're using perf derived probes.
* testsuite/systemtap.base/perf.sh: Change '/usr/bin/cat' to '/bin/cat' so
that systems (like RHEL6) that don't have 'usrmove' will still work.
Martin Cermak [Thu, 19 May 2016 09:07:19 +0000 (11:07 +0200)]
Fix PR19926 by introducing translator built-in @const() operator.
Tapsets or guru-mode user scripts can access header file constant
tokens, typically macros, using built-in @const() operator. The
respective header file inclusion is possible either via the tapset
library, or using a top-level guru mode embedded-C construct.
This results in appropriate embedded C pragma comments setting.
Felix Lu [Tue, 17 May 2016 18:13:13 +0000 (14:13 -0400)]
new -T timeout option
* cmdline.h: Add -T flag
* elaborate.cxx: New function setup_timeout to create timer probe
* session.cxx: Initialize new timeout variable. Parse -T option
* session.h: New timeout variable
* man/stap.1.in: Documentation
* testsuite/systemtap.base/timeout.exp: Test it
Felix Lu [Wed, 11 May 2016 18:02:27 +0000 (14:02 -0400)]
compile server: use only one server for multiple kernel versions
* stap-serverd.cxx:
- Remove uname_r global
- kernel_build_tree is now a map of kernel version -> build tree
- process_r: Defer adding -r flag
- create_services: Create one service per target kernel version
- handle_request: Pass -r flag to stap based on client's sysinfo field
* stap-server:
- spawn only one server passing -r flags for each kernel version when
using the -i option
Frank Ch. Eigler [Thu, 12 May 2016 15:28:21 +0000 (11:28 -0400)]
elaborate.cxx: add some respect for pending_interrupt
Some wildcardy stap scripts can cause processing for quite awhile
within elaborate.cxx loops, without due respect for ^C. Now respond
quicker, at least in the cases relevant to
Josh Stone [Fri, 6 May 2016 23:43:37 +0000 (16:43 -0700)]
PR20042: support tracepoints with function-pointer args
For example, tracepoint "cpuhp_enter" has "int (*fun)(unsigned int))",
but since dwarf_type_name() didn't handle DW_TAG_subroutine_type, it
would call this "void*", and then the whole tracepoint function
signature would fail -Werror=incompatible-pointer-types.
We can now expand function-pointers in dwarf_type_name(), but we also
need a new dwarf_type_decl() which knows how to insert the name in the
middle of the type string.
Josh Stone [Tue, 3 May 2016 01:43:28 +0000 (18:43 -0700)]
dwflpp: use fixed-size buffers for ldd parsing
The dynamic string allocation causes trouble on RHEL5 -- %as is always
parsed as a float under C++11, but %ms requires glibc >= 2.7. But we
already used a fixed buffer for the line, so additional fixed buffers
are not a big deal for its substrings.
Mateusz Guzik [Mon, 2 May 2016 17:28:55 +0000 (12:28 -0500)]
Plug preempt leak in _stp_runtime_entryfn_put/get_context.
If _stp_runtime_entryfn_get_context returns a context, preemption
counter is always incremented. On the other hand
_stp_runtime_entryfn_put_context only decrements the counter if the
passed context matches the one currently set on the cpu.
The context can be set to NULL by _stp_runtime_contexts_free, making the
comparison false and in effect leading to a leak, e.g.:
timer: _stp_ctl_work_callback+0x0/0x1e0[stap_af8544c7eb51251ef8c
377abff659b05_25070] preempt leak: 00000101 -> 00000102