Jonathan Lebon [Mon, 11 Nov 2013 17:19:35 +0000 (12:19 -0500)]
add mismatch_complexity
The mismatch_complexity variable allows us to only print out the most
complex kind of mismatch, and skip over simpler mismatches, in order to
keep the mismatch reporting as simple to understand as possible.
When assert_resolvability is false, mismatch_complexity simply remembers
the most complex mismatch we've met so far during each pass (e.g.
unresolved() is 0, mismatch(e) is 1, mismatch(tok, t1, t2) is 2, and
mismatch(tok, t, decl, index) is 3).
Once we turn on assert_resolvability, we check mismatch_complexity in
mismatch() and unresolved() to determine whether to print out an error
or not. If mismatch_complexity is higher than our own complexity, then
we don't print anything since we know that there is a better-suited
mismatch coming up.
Jonathan Lebon [Mon, 11 Nov 2013 17:05:42 +0000 (12:05 -0500)]
implement resolved() and mismatch() and use them
We finally complete the new function bodies. In resolved(), we add items
to the resolved_types vector, while in mismatch(), we retrieve from the
vector to print out exactly where the decl type was initially resolved.
Jonathan Lebon [Mon, 11 Nov 2013 16:34:39 +0000 (11:34 -0500)]
new resolved_type struct and mismatch/resolved functions
The resolved_type struct holds all the information about a newly
resolved decl. The token 'tok' holds where the resolution occurred, and
'index' is the position of the function-argument/array-index of the
decl.
The vector resolved_types will hold all the decls we resolve. A new
resolved() function is introduced which will add elements to the vector,
while an analogous mismatch() function will be used to report mismatches
between type and resolved decl.
* runtime/linux/uprobes-common.c (stap_uprobe_change_plus): The outer if
statement use curly braces to create a block, however the ending
curly brace ended up outside macro conditional.
David Smith [Fri, 8 Nov 2013 17:01:20 +0000 (11:01 -0600)]
Revert commit 65ddca0 since s390x can get get syscall arguments 7+.
* tapset/linux/nd_syscalls2.stp (nd_syscall.pselect7): Since the fix for
PR15913, s390x systems can get arguments 7 (and following) off the
stack. Revert commit 65ddca0 which hardcoded argument 7 to -1.
(nd_syscall.compat_pselect7): Ditto.
Josh Stone [Thu, 7 Nov 2013 23:30:42 +0000 (15:30 -0800)]
stapdyn: Tighten BPatch insertion sets
We were doing insertion sets in instrument_object_dynprobes(),
regardless of whether there was even a target match. This sometimes
triggers bad corner cases in Dyninst when the finalize tries to go do
things in a nascent process, with no action actually needed. While this
gets investigated in Dyninst, we can narrow down our insertion sets to
instrument_dynprobe_target(), where at least we know it's a match.
PR16132: staprun: fix fallback for openat/open modes for debugfs trace%d
Previous code got confused as to how many trace%d files to open and
where. Now we openat() only from the incoming staprun/stapio -F fd
directory, or open() right from /sys/kernel/debug/systemtap/..., with
no hanky panky between them.
stap-server ssl: enable all cipher suites manually
On some versions of NSS, NSS_SetDomesticPolicy doesn't work right,
so let's use lower-level functions with the appropriate (zero)
level of return-code checking.
The stap runtime doesn't play that well with k[gu]id_t and namespaces.
$SUBJECT kconfig option highlights the extent to which we use [ug]id_t.
An earlier commit 857163157b8 papered over the problem to some extent;
the present commit adds anothet coat of slop to cover the cracks.
Jonathan Lebon [Tue, 5 Nov 2013 16:16:16 +0000 (11:16 -0500)]
don't test uprobes_filtering.exp on RHEL5/6
We don't want to run this test on RHEL5/6, where we compile our own
uprobes module (there's no filtering possible anyway, since these
kernels don't support UPROBE_HANDLER_REMOVE).
Jonathan Lebon [Tue, 5 Nov 2013 15:17:12 +0000 (10:17 -0500)]
update user_string_n_quoted.exp test case
With commit 7bec2c2, the default behaviour of user_string_n_quoted() has
changed. The test case is now updated to test that
user_string_n_quoted() trims strings according to input length and that
user_string_n2_quoted() trims strings according to output length given
the inverse parameters.
David Smith [Mon, 4 Nov 2013 17:18:39 +0000 (11:18 -0600)]
Fix BZ1020853 by fixing procfs probe compile problems on newer kernels.
* runtime/procfs.c (_stp_mkdir_proc_module): Support kern_path(), along
with vfs_path_lookup().
* buildrun.cxx (compile_pass): Added 'exportconf' for kern_path().
Jonathan Lebon [Fri, 1 Nov 2013 18:57:40 +0000 (14:57 -0400)]
improve levenshtein performance
Doing this simple bypass has drastic performance consequences. E.g. when
matching against small-ish strings, we see ~10 time speed improvements,
while with larger strings we see slightly more than twice the speed.
Jonathan Lebon [Fri, 1 Nov 2013 15:19:55 +0000 (11:19 -0400)]
improve function arity mismatch error msg
The symbolic semantic_pass now prints a clearer error when a function
matches by name, but not by arity. Previously, there was no distinction
between referencing a non-existent function and one that exists but does
not match arity.
Upon arity mismatch, we print both where the function call occurred, and
where the function was defined.
Jonathan Lebon [Fri, 1 Nov 2013 13:21:49 +0000 (09:21 -0400)]
move visited_modules from dwarf_query to base_query
The visited_modules set is now part of base_query. This helps us
centralize the place where modules are added to the set (in
query_module) and will be needed for implementing suggestions for
non-dwarf-related probes.
Jonathan Lebon [Thu, 31 Oct 2013 19:38:29 +0000 (15:38 -0400)]
levensh suggest unresolved probe points
This patch adds Levenshtein suggestion to match_node::find_and_build().
Suggestions are made in three cases:
- Unresolved double-glob (e.g. syscall.poen**)
- Unresolved glob (e.g. syscall.poen*)
- Unresolved no-glob (e.g. kernel.functoin("bla"))
Note that suggestions for globby functors are based on the prefix part
only (part of functor prior to the **) to increase meaningfulness.
Jonathan Lebon [Thu, 31 Oct 2013 17:45:58 +0000 (13:45 -0400)]
refactor levenshtein suggesting
In anticipation for a wider use of levenshtein(), we factor out the
common part into a new function levenshtein_suggest(). We then change
suggest_functions() to use levenshtein_suggest().
Josh Stone [Thu, 31 Oct 2013 22:03:34 +0000 (15:03 -0700)]
Flip user_string_n_quoted to limit the input count
The documentation of that function implies that it's counting n from the
input string, but in fact that limit was being applied to the output,
including quotes and escaping.
Now _stp_text_str takes two length parameters to limit the input count
and output size separately. A new user_string_n2_quoted() lets you
specify both of these lengths, and user_string_n_quoted now uses that to
limit input length, or output still in compatibility mode.
Several syscall tapsets which read user buffers of known length will now
use user_string_n2_quoted to fit that. This was seen in syscall.write
which may not necessarily have any '\0' at the end of its buffer.
Jonathan Lebon [Wed, 30 Oct 2013 15:12:45 +0000 (11:12 -0400)]
PR16019: treat errors from tapsets/functions as non-critical
Since we now include parsing errors in seen_errors, we get an increase
in num_errors() which we didn't have before. This would cause the
function passes_0_4() to stop at pass 1 even when parsing errors only
occurred in tapset/macro files (previously, we simply issued a warning
and kept going).
We now pass a new flag, errs_as_warnings, to the parsing methods so that
whenever any parsing errors occur while parsing tapset or macro files,
systemtap_session::print_error() will not count the error towards the
num_errors() value.
The net effect is that prior to pass 1b (user script parsing), any error
is printed (along with a warning) but not counted. Warnings are still
emitted, so that -W will still stop everything.
Thus, from the user's standpoint, there is no change in behaviour prior
to these series of patches.
Jonathan Lebon [Mon, 21 Oct 2013 13:35:48 +0000 (09:35 -0400)]
PR16019: improve duplicate error elimination
Previously, we relied on exact string matching when considering whether
to print an error or not. This had the disadvantage of not filtering out
whenever the same error occurred on many different lines. Also, error
chains, which often provided context, were cut off, causing errors to be
more cryptic.
With this series of patches, this is how behaviour is modified:
1. Errors are filtered out based on their source, i.e. the function
and line at which the error was thrown. This means that slightly
different error messages are still considered equivalent and
eligible for duplicate elimination.
2. Errors that get passed the filter are always printed with thei
full chain to provide maximum context.
3. When in verbose mode (just one -v), filtering is completely turned
off and all errors are printed out.
This patch simply installs the mechanisms through which these
modifications will take place in the next patches.
- main.cxx: print out number of suppressed errors on cleanup
- session.cxx: rework the print_error() functions to account for
chaining
- session.h: new function and variable declarations and modify
parse_error object to hold errsrc
- staptree.h: modify semantic_error object to hold errsrc
- util.h: add helper macros for throwing errors which include source
You can use the SEMANTIC_ERROR and PARSE_ERROR macros to ease error
throwing. These macros automatically pass the the function and line
number to the error constructor.
William Cohen [Tue, 29 Oct 2013 19:00:58 +0000 (15:00 -0400)]
Make the ARM _stp_store_deref and _stp_deref more like kernel ARM uaccess.h macros
The ARM uaccess.h macros for put_user and get_user do an explicit
typecast of the address into an unsigned long. This typecast is
important for the __stp_get_user_asm_half and __stp_put_user_asm_half
macros. Without it these macros attempt to do pointer and get an
incorrect address for the second byte of a 16-bit value.
William Cohen [Tue, 29 Oct 2013 16:44:49 +0000 (12:44 -0400)]
Make the 32-bit ARM get_user() and put_user() work for 16-bit quantities
The 32-bit ARM does not have instructions to perform 16-bit loads or
stores. The __get_user_asm_half and __put_user_asm_half macros
sythesize those operations. However, in most cases the pointers
passed into these macros are pointers to 16-bit types and the pointer
arithmetic will end up pointing at the next 16-bit quantity rather
than the second half (byte) of the 16-bit quantity. The macros need
to explicitly typecast the pointers as pointers to 8-bit quantities to
make the pointer arithmetic work out properly.
Josh Stone [Mon, 28 Oct 2013 22:42:46 +0000 (15:42 -0700)]
Add an example for tracking shared futexes
The existing futexes.stp does show shared futexes, but only by the
$uaddr which is specific to any given process. This futexes2.stp tries
to show shared futexes by the inode path+offset of the mapping. I found
this useful in examining stapdyn's pthread_mutexes in shm.
This also adds an inode_path() tapset function which tries to locate the
vfsmount containing an inode in the current namespace, and if found uses
task_dentry_path() to get a full path.
David Smith [Mon, 28 Oct 2013 21:35:43 +0000 (16:35 -0500)]
Fix 'syscall.accept' probe alias.
* tapset/linux/syscalls.stp (syscall.accept): Make sure optional probe
points are marked as optional at the top, since optionalness passes down
along alias definitions, not up.
David Smith [Mon, 28 Oct 2013 21:33:05 +0000 (16:33 -0500)]
Refix PR16058 by updating the old syscall.mmap2/nd_syscall.mmap2 probes.
* tapset/linux/i386/syscalls.stp: Make sure optional probe points are
marked as optional at the top, since optionalness passes down along
alias definitions, not up.
* tapset/linux/i386/nd_syscalls.stp: Ditto.
* tapset/linux/s390/nd_syscalls.stp:
* tapset/linux/s390/syscalls.stp: Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.
* tapset/linux/x86_64/syscalls.stp: Ditto.
Josh Stone [Fri, 25 Oct 2013 00:02:53 +0000 (17:02 -0700)]
Allow "read-mostly" stats to elide locks
In c_unparser::emit_lock_decls, we invert read/write locks for stats
types, since they only need a shared lock for writing updates but an
exclusive lock for aggregation to read. However, we didn't invert our
view of vcv_needs_global_locks across all probes, so it was impossible
for stats to ever get counted as "read-mostly" and elide locks.
Now the sense of vcv_needs_global_locks.read/written is swapped for
stats too, so those that are only aggregated in lock-free probes
(begin/end) can be completely lock-free.
Josh Stone [Thu, 24 Oct 2013 23:47:17 +0000 (16:47 -0700)]
stapdyn: Print dbug/warn/error messages with libc vsnprintf
The kernel runtime uses vscnprintf for these, which roughly follows
C99 rules, but the dyninst runtime was using _stp_vsnprintf, which is
not quite the same. Since some runtime code is shared, we need
compatible format strings, so just use libc's vsnprintf here.
Also, one shm_dbug was using %zi for off_t, which isn't always correct
since we #define _FILE_OFFSET_BITS 64, so use PRIi64 instead.
Josh Stone [Thu, 24 Oct 2013 23:00:38 +0000 (16:00 -0700)]
stapdyn: send context-free DBUG messages to stderr
Some debug messages occur outside of probe context, like shm_dbug,
so they would get an error trying to allocate the print buffer. In
the particular case of shm initialization, the transport memory
doesn't even exist yet!
Now if there's not an active context, DBUG just goes to stderr.
Josh Stone [Thu, 24 Oct 2013 22:44:19 +0000 (15:44 -0700)]
Filter duplicates out of globbed process names
For example, process("/lib64/libpthread*") matches libpthread-2.17.so
and libpthread.so.0, but the latter is just a symlink to the former. We
already canonicalized those names, but still had double the probes.
* tapsets.cxx (dwarf_builder::build): Track canonicalized name in a set
so we can skip globbed names that resolve to the same thing.
Josh Stone [Thu, 24 Oct 2013 21:56:06 +0000 (14:56 -0700)]
Fix canonicalize_file_name() leaks
This function allocates memory, but in a few places we weren't freeing
it. We have a resolve_path() to do this correctly for std::string-happy
code, and this patch adds free() for the rest.
Jonathan Lebon [Thu, 24 Oct 2013 14:02:25 +0000 (10:02 -0400)]
man: use SAMPLE macro in remaining docs
To be more consistent with the other man pages, all the remaining pages
had their SAMPLE macro modified in the same way (see commit 895c959).
- dtrace.1: add SAMPLE macro and replace manual RS/RE with it
- error::pass1.7stap: fix description on same line as .SH
- error::process-tracking.7stap: use new macro
- stapex.3stap: ditto
- stapprobes.3stap: ditto
Josh Stone [Wed, 23 Oct 2013 17:01:33 +0000 (10:01 -0700)]
Rename the 'examples' symlink to 'EXAMPLES'
This avoids a conflict with the way systemtap.spec is munging the
examples for %doc (rhbz 1022483), and in caps it will also be closer to
the top of the naive sorting in gitweb.
David Smith [Fri, 18 Oct 2013 18:49:45 +0000 (13:49 -0500)]
Fix PR16058 by updating the old syscall.mmap2/nd_syscall.mmap2 probe aliases.
* tapset/linux/i386/syscalls.stp: Break the 'mmap2' probe alias down into
subprobes, so that 'pgoff' can be converted to a number of bytes when
necessary.
* tapset/linux/i386/nd_syscalls.stp: Ditto.
* tapset/linux/x86_64/syscalls.stp: Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.