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.
David Smith [Tue, 15 Jan 2013 22:42:20 +0000 (16:42 -0600)]
PR14708 partial fix: Add more testcases and a couple of small fixes.
* tapset-utrace.cxx (utrace_builder::build): Throw an error if the user
tries process.syscall probes with the dyninst runtime.
(utrace_derived_probe_group::emit_module_dyninst_decls): Correct the
probe type.
* testsuite/systemtap.base/utrace_p5.exp: Add dyninst testcases for thread
begin and end.
* testsuite/systemtap.base/utrace_p5_multi.c (main): Remove debug printfs.
Frank Ch. Eigler [Fri, 11 Jan 2013 21:00:24 +0000 (16:00 -0500)]
examples: tweak deviceseeks.stp
Switch to using the ioblock_trace.request probe point (based on a
kernel tracepoint), which is more reliable than the
kprobe-on-inlined-function ioblock.request one, and makes more
information avilable. (Unfortunately, this makes the script
incompatible with non-tracepoint kernels.)
Also, as per Jeff Moyer's correction, seeks are calculated as relative
to the end position of the prior transfer, not its origin.
Frank Ch. Eigler [Fri, 11 Jan 2013 23:04:28 +0000 (18:04 -0500)]
PR14774: tweak test case
Splitting the test case onto separate lines helps ensure separate line
records. Also, use [utrace_p] instead of CONFIG_UTRACE* tests for
applicability.
translate: for stap -t reports, identify probe index
For probe points that expand to multiple separate low-level kprobes,
e.g. for multiply-inlined functions, the stap -t report doesn't give
any hint as to which of those separate kprobes was invoked how many
times. Normally, a user would not care, so that's fine, but sometimes
for debugging it's nice to match up the stap -t output to the stap -p3
stap_probes[] array elements. So let's extend the -t output with an
undocumented index: NNN ditty.
* loc2c.c (STACK): Change macro to assert stack slot number >= 0.
(DW_OP_rot): Implement last assignment against correct stack slot.
* testsuite/buildok/dw_op_rot.stp: New test.
Emit address constants in loc2c for synthetic addresses always as hex
in translate_constant (). ... but then explicitly typecast it to
(uintptr_t), so that a small negative 32-bit value, rendered as a
64-bit positive hex value is acceptably truncated back down.
the omnibus change act of 2013 for copyright and task_finding excellence
* runtime/linux/task_finder*: Add a 'purpose' filed to the
task_finder_tgt, so that callback errors -- now becoming warnings --
can give a little better hint to the user as to what may have gone
wrong. Updated tapsets-*.cxx and runtime/vma.c generators/users to
set a string.
* bump copyright years nearby
* winnow accidentally cargo-culted copyright line (retained in relevant files)
Serguei Makarov [Fri, 21 Dec 2012 19:27:35 +0000 (14:27 -0500)]
PR14883: add combined error message for task_finder_stubs warnings and 'user-space facilities not available' error.
The basic idea behind the renaming is that, if one manpage explains both
errors and warnings, we title it error::FOO, 'error' being the somewhat
more general term.
Serguei Makarov [Thu, 20 Dec 2012 16:17:01 +0000 (11:17 -0500)]
PR14929: revert earlier manpage-reporting mechanism as too clunky.
Instead of having separate semantic_error_manpage() &c classes,
we can just put a compact [man error::...] reference in the error message.
This does not require additional error reporting machinery.
Frank Ch. Eigler [Thu, 20 Dec 2012 15:02:15 +0000 (10:02 -0500)]
PR12443: skip duplicate tapset files between XDG_DATA_DIRS and $prefix
For a self-built systemtap installation, with a $prefix other than
/usr, run on a system with $XDG_DATA_DIRS set, the tapset *.stp /
*.stpm files will collide between those in the freshly-build one and
the system one. This can result in warning messages, duplicate
probes, and cats and dogs living together.
We try to avoid this by duplicate-elimination based upon the tapset
file name.
* session.cxx (systemtap_session ctor): Put compiled-in / -I tapset
path first.
* main.cxx (passes_0_4): While processing *.stpm and *.stp tapset
files, skip subsequent ones that share same sub-path-name (part
after the -I path/ or XDG_DATA_DIRS=path1/:path2/ elements.
With greater pass-1 verbosity, explain.
Serguei Makarov [Wed, 19 Dec 2012 21:18:23 +0000 (16:18 -0500)]
PR14883: let stuff that demands task_finder, incl. probefunc(), fail gracefully when such is not available
Now, instead of failing pass-4, code demanding task_finder process tracking
functionality on systems where the facility is unavailable will run with
a warning, then silently ignore any task_finder callbacks that the script
attempts to register.
* runtime/vma.c (_stp_vma_init()): return silently without doing anything if HAVE_TASK_FINDER is not set.
* runtime/linux/task_finder3.c: new file.
* runtime/linux/runtime.h: include task_finder3.c if actual task_finder not available.
Lukas Berk [Tue, 18 Dec 2012 21:24:09 +0000 (16:24 -0500)]
PR14714: Introduce --suppress-time-limits flag
This flag enables somewhat heavier weight scripts to be run, disabling
-DSTP_NO_OVERLOAD, -DMAXACTION, and -DMAXTRYLOCK mechanisms. The flag
itself also requires guru mode to be specified.
* cmdline.cxx - add the new long option
* cmdline.h - add the corresponding long option to enum
* hash.cxx - add the option to be hashed
* man/stap.1 - updated man page reflecting new option
* runtime/common_probe_context.h - remove actionremaining declaration if
flag is specified and the variable is no longer needed
* runtime/dyninst/probe_lock.h - remove the check against MAXTRYLOCK if
the flag is specified
* runtime/linux/probe_lock.h - remove the check against MAXTRYLOCK if
the flag is specified
* runtime/runtime_defines.h - remove the declarations of MAXTRYLOCK and
MAXACTION if the flag is specified
* session.cxx - add flag bool for stap proper, stap help message, and
command line option check
* session.h - declare the flag boolean
* tapset-timers.cxx - add conditionals for the module 'actionremaning'
variable if the flag is specified
* tapsets.cxx - add conditionals for the module 'actionremaning'
variable if the flag is specified
* testsuite/systemtap.base/suppress-time-limit.exp - new testcase
* testsuite/systemtap.base/suppress-time-limit.stp - testcase script
* translate.cxx - add conditional based on stap proper boolean to
record_actions function
Josh Stone [Mon, 17 Dec 2012 23:44:33 +0000 (15:44 -0800)]
runtime: Updated support for uretprobes test kernels
This updates support for uretprobes kernels from here:
http://repos.fedorapeople.org/repos/aarapov/kernel-uprobes/
... particularly kernel-3.7.0-99.uretprobes.fc18 built 13-Dec-2012.
The struct uretprobe_consumer is gone, and now both uprobes and
uretprobes use the same struct uprobe_consumer. The signature of the
handler function has changed to include a long addr for the uretprobes'
true return address. In the future that parameter will also be set for
plain uprobes to the equivalent of uprobe_get_swbp_addr().
I'm knowingly breaking compatibility with earlier uretprobes test
kernels. As far as I know, those have never been officially shipped
anywhere, so that should be fine. This does maintain compatibility with
the version of plain uprobes before the change in the handler signature.
* runtime/linux/uprobes-inode.c (struct stapiu_consumer): Collapse the
uconsumer and uretconsumer back to a single entry.
(stapiu_probe_prehandler): Fill in the given IP temporarily, then call
the true handler from the translator.
(stapiu_probe_prehandler_noaddr): Compatibility handler to grab the IP
from uprobe_get_swbp_addr().
* runtime/linux/autoconf-inode-uprobes-noaddr.c: New autoconf to detect
the former version of uprobes handler, without the addr parameter.
* buildrun.cxx (compile_pass): Use that autoconf.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_inode_decls):
Yield the IP-munging duties to uprobes-inode.c.
Josh Stone [Sat, 15 Dec 2012 02:00:32 +0000 (18:00 -0800)]
stapdyn: Use shared memory for globals
All globals are now in shared memory, no matter what type.
* runtime/dyninst/common_session_state.h: Add globals to the session
struct, and change the timing stats to offptr_t. Create global()
macros to abstract the access to various globals.
* runtime/linux/common_session_state.h: Create the simpler kernel
equivalents of the global() macros.
* runtime/dyninst/map_runtime.h: Use shm for allocating map and pmap.
* runtime/dyninst/stat_runtime.h: Use shm for allocating stats.
* runtime/dyninst/runtime.h (stp_pthread_rwlock_init_shared): New,
for initializing global locks with PTHREAD_PROCESS_SHARED set.
* translate.cxx: Use global() macros everywhere that did "global.foo".
(c_unparser::emit_global): Emit stapdyn globals with a union foo_typed
so that the global() macros can type-check it a little.
(translate_pass): Globals are only statically-initialized in kernel
mode, where they might be overridden early by module params.
(c_unparser::emit_module_init): For stapdyn mode, initialize global
values during the rest of the module initialization.
* testsuite/buildok/globals.stp: Simple test building all global types.
Josh Stone [Thu, 13 Dec 2012 21:31:53 +0000 (13:31 -0800)]
PR14957: Don't force __GFP_ZERO into kmalloc_node
It turns out that rhel5-era kernels have a BUG check in slab cache_grow
that doesn't permit __GFP_ZERO from this path. Later kernels corrected
this, as the implementation of kzalloc_node is just kmalloc_node with
__GFP_ZERO added, but for compatibility we can't rely on that.
* runtime/linux/alloc.c (_stp_kzalloc_node_gfp): Use a plain
_stp_kmalloc_node_gfp, then memset-0 manually.
Josh Stone [Wed, 12 Dec 2012 23:34:39 +0000 (15:34 -0800)]
stapdyn: Move contexts into shm
David already abstracted different allocation schemes for runtime
contexts, so this time the kernel runtime needs no change. The dyninst
runtime now has the per-cpu contexts included in shared memory.
* translate.cxx (c_unparser::emit_common_header): Move runtime_context.h
and common_session_state.h right after the struct context definition.
* runtime/dyninst/common_session_state.h: Add struct context[] to shm.
(stp_session_context): New function to access a specific context.
* runtime/dyninst/runtime_context.h (_stp_runtime_contexts_alloc/free):
Don't manage memory anymore, just initialize the locks and be done.
Use stp_session_context throughout to retrieve contexts.
* runtime/dyninst/runtime.h (stp_pthread_mutex_init_shared): New, set
the PTHREAD_PROCESS_SHARED attribute while initializing a mutex.
* runtime/dyninst/shm.c (_stp_shm_finalize): dbug the final mmap addr.
Josh Stone [Wed, 12 Dec 2012 22:02:00 +0000 (14:02 -0800)]
stapdyn: Move alibi and timing stats to shm
In dyninst mode, the alibi and timing parts are now part of the main
session struct that lives in shared memory. In kernel mode the same
parts are their own global arrays, but otherwise unchanged.
Also, the global stap_probes[] that used to hold these has no more
mutable members, so it is now const.
* runtime/dyninst/common_session_state.h: Add alibi and timing data to
the session, and define functions to access them.
* runtime/linux/common_session_state.h: Move alibi and timing data to
global arrays, and define the same access functions.
* tapsets.cxx (common_probe_entryfn_prologue): Use probe_alias() and
probe_timing() to get the relevant data in runtime-neutral ways.
* translate.cxx (c_unparser::emit_module_exit): Ditto.
(translate_pass): Define STP_PROBE_COUNT for sizing related arrays.
Update the stap_probes[] initialization with a fixed index to access
the relocated alias/timing data, and make the whole thing const.
* [everything else]: Always use const struct stap_probe pointers.
Josh Stone [Tue, 11 Dec 2012 23:09:54 +0000 (15:09 -0800)]
stapdyn: Move global session counters into shm
In dyninst mode, the atomic_t session_state, error_count, and various
skipped_counts are now lumped into a common structure which is allocated
first thing in shared memory. Kernel mode is effectively unchanged.
* runtime/common_session_state.h: Split into runtime specifics.
* runtime/dyninst/common_session_state.h: Define a session struct,
access functions, and an initialization function using shm.
* runtime/linux/common_session_state.h: Leave the former atomics as
globals, but provide the same function abstractions as in /dyninst/.
* translate.cxx (c_unparser::emit_module_init): Call stp_session_init.
* [everything else]: Update how those global variables are accessed,
essentially just s/&foo/foo()/g.
Josh Stone [Tue, 11 Dec 2012 19:49:58 +0000 (11:49 -0800)]
stapdyn: Guard against unfound return probes
Sometimes dyninst will identify an instrumentation point, but be unable
to find its corresponding return. The reason for this is not yet known,
but we should be defensive against NULL from findPoint(BPatch_locExit).
* stapdyn/mutatee.cxx (mutatee::instrument_dynprobe_target): Check the
return value of findPoint(BPatch_locExit), and warn if not found.
Josh Stone [Tue, 11 Dec 2012 19:48:07 +0000 (11:48 -0800)]
tapset: Add ppfunc() to parse the function name from pp()
This performs similarly to the pre-2.0 probefunc(), but without the
fallback to addr->symbol lookups. That is, if pp() doesn't have a
function name, then an empty string is returned without further ado.
Josh Stone [Tue, 11 Dec 2012 01:11:45 +0000 (17:11 -0800)]
runtime: offptr_t: Fix NULL, and add a global implementation
NULL can't be treated as a relative pointer, because it's always
absolute. Good thing we weren't using offptr_t in relocatable memory
yet. Now this is treated as the special case it must be.
I've also added another offptr_t implementation, based on a fixing
offsets from the global shared-memory base. This means it's only good
for pointers within that memory, but math should be simpler.
Josh Stone [Tue, 11 Dec 2012 00:26:11 +0000 (16:26 -0800)]
stapdyn: Add a shared-memory allocator
* runtime/dyninst/stapdyn.h (stp_dyninst_shm_init): Called to
initialize the shared memory and return its name for mutatees.
(stp_dyninst_shm_connect): Called connect a mutatee to shm.
* runtime/dyninst/runtime.h (stp_dyninst_session_init): Make sure that
stp_dyninst_shm_init is called, in case of old stapdyn.
* runtime/dyninst/shm.c: All new functions to create, map, and allocate
from shared memory. Allocation must only be done from the main
process before anyone else connects, so we don't have to worry about
signalling other processes about the growth.
Josh Stone [Sat, 8 Dec 2012 01:06:40 +0000 (17:06 -0800)]
runtime: Use single allocation for stapdyn maps again
The kernel maps are left as-is, but I remembered a good reason why I
wanted large allocations for stapdyn. As explained in _stp_pmap_new:
The reason for this is that we're allocating in the shared memory
mmap, which may have to move locations in order to grow. If some
smaller unit of the pmap allocation were to cause the whole thing to
move, then we'd lose track of the prior allocations.
Once returned from here, we'll always access the pmap via the global
shared memory base. So if other map/pmap/stat/etc. allocations
cause it to move later, that's ok.
We're not *actually* using a shared memory mmap quite yet, but we're
almost there, I promise...
Serguei Makarov [Fri, 7 Dec 2012 18:00:47 +0000 (13:00 -0500)]
PR14929: groundwork for letting stap refer the user to man staperrors.
To tag an error with a specific manpage, replace
semantic_error (...)
--> semantic_error_manpage ("name_of_manpage", ...)
or
parse_error (...)
--> parse_error_manpage ("name_of_manpage", ...)
Then both errors will output messages instructing the user to refer
to man 3stap error::name_of_manpage.
Josh Stone [Fri, 7 Dec 2012 02:29:32 +0000 (18:29 -0800)]
runtime: remove the map_node data_offset
The value in the map_node is now an honest member of the struct. Here
are your papers, congratulations, now get to work!
* runtime/map-gen.c (KEYSYM(map_node)): Add the value.
(MAP_COPY_VAL): New macro to assist in pmap aggregation.
* runtime/pmap-gen.c (KEYSYM(pmap_update_node)): New callback for
aggregation node updates, copying the keys and values as needed.
* runtime/map-stat.c (_stp_map_new_hstat, _stp_pmap_new_hstat): New
constructors to take responsibility for setting HIST_NONE.
(_stp_[p]map_new_hstat_{log,linear}): Only need to augment the size
with the histogram buckets now; the stat_data is already there.
* runtime/map.c (_stp_map_new, _stp_pmap_new): No longer need the value
type, not the separate key/data sizes; a simple node_size is enough.