Aaron Tomlin [Fri, 22 Nov 2013 15:03:02 +0000 (15:03 +0000)]
Add STAP_ERROR macro
Instead of CONTEXT->last_error = "foo"; goto out; in an embedded-C
function, a newly defined macro STAP_ERROR(str) should be used.
The script can catch the exception with try { } catch { }.
Josh Stone [Wed, 20 Nov 2013 21:01:10 +0000 (13:01 -0800)]
Tighten -Wno-format-nonliteral to just where it's needed
We only have one function, stap_strfloctime(), which actually requires
relaxing this warning; the rest can and should be checked. Split this
function into its own file, and give just that the relaxed option.
Josh Stone [Wed, 20 Nov 2013 19:36:26 +0000 (11:36 -0800)]
parse: Let pp1_activation own the token rather than copying
This works around the RHEL4 compiler, which apparently doesn't see
parser::pp1_activation as a friend of token, even though parser is.
So it was failing to invoke the now-restricted copy-constructor, but
there's not really any reason for it to make a copy anyway.
Josh Stone [Wed, 20 Nov 2013 19:19:19 +0000 (11:19 -0800)]
Don't check kernel "utrace" support for dyninst
This regressed after commit d0923e365964097a2209cfc23568d5770f596bad,
which stopped reading kernel CONFIG variables at all for --dyninst.
We don't need them, but it didn't hurt much to check before.
Josh Stone [Mon, 18 Nov 2013 19:20:02 +0000 (11:20 -0800)]
PR16184: Fix sigmask decoding in the presence of TRACESYSGOOD
Commit f1e0e63bb6992df4127bc7ae7ba89be478b9c250 added SIGTRAP|0x80 to
indicate PTRACE_O_TRACESYSGOOD signals. However, _stp_sigset_str became
unpredictable, because it checks sigismember for all known signals, but
SIGTRAP|0x80 is out of the bitrange possible in a sigmask.
Now _stp_sigset_str only checks sigismember for values <= _NSIG.
Josh Stone [Sat, 16 Nov 2013 01:56:41 +0000 (17:56 -0800)]
PR10574: Fix a few pc=0 that escaped this old bug
We already checked for pc=0 in dwflpp::die_entrypc, but a couple places
didn't check the return value to notice COMDAT rejection. We also need
to check this in the simpler dwflpp::function_entrypc, and both
functions are now marked warn_unused_result.
The new testsuite/semok/nullpc.stp makes sure we don't have any pc=0 in
stap itself, which is a large enough C++ binary to sometimes have these
COMDAT-eliminated null functions.
David Smith [Fri, 15 Nov 2013 19:52:03 +0000 (13:52 -0600)]
PR15219 partial fix. Several syscall.clock_* probes longer nest.
* tapset/linux/syscalls.stp: Add __syscall_get() macro calls to
syscall.clock_nanosleep and syscall.clock_nanosleep.return to reject
nested syscalls. Added compat_sys_clock_settime support to
syscall.clock_settime and syscall.clock_settime.return.
* tapset/linux/nd_syscalls.stp: Similar changes as above.
* tapset/linux/syscalls.stpm: New file.
* tapset/linux/aux_syscalls.stp (_stp_syscall_nr): New function.
Jonathan Lebon [Fri, 15 Nov 2013 19:35:43 +0000 (14:35 -0500)]
also suggest function aliases on unresolved dwarf probes
This patch does two things:
1. It removes sym_seen and replaces it with inlined_funcs, which only
picks up inlined functions.
2. suggest_dwarf_functions() now aggregates functions from both
inlined_funcs and the module_info symtab function cache.
The net result is that (1) we're no longer storing duplicate
information, and (2) we now also suggest function aliases (which are in
the cache).
Jonathan Lebon [Wed, 13 Nov 2013 22:34:56 +0000 (17:34 -0500)]
PR16165: extend print_format::create
In an effort to restrict token creation, we change the
print_format::create() function to accept a string to denote the type of
print statement we want, rather than always deriving it from the token's
content. This allows us to skip the creation of tokens in a few places
that synthesize print statements.
- staptree.h: update print_format::create() declaration to accept new
parameter and add new member print_format_type
- staptree.cxx: update print_format::create() and use print_format_type
in print_format::print()
- elaborate.cxx: don't create token, use new parameter instead
- tapset-mark.cxx: ditto
- tapset-utrace.cxx: ditto
- tapsets.cxx: ditto
Josh Stone [Thu, 14 Nov 2013 01:46:22 +0000 (17:46 -0800)]
testsuite: Support prelink even on NFS paths
We had an issue that prelink would fail trying to restore selinux
context if the file is on NFS, e.g. for someone working in NFS $HOME.
It turns out prelink see nfs_t on the source, but isn't allowed to set
nfs_t on the destination (even though it will already be nfs_t).
Now we have a [prelink] proc for test to run prelink though a mktemp
file. The source is copied to tmp, prelinked, and copied back.
Josh Stone [Thu, 14 Nov 2013 01:04:19 +0000 (17:04 -0800)]
PR16162: Support .plt probes on prelinked libraries
There were a few bias issues in how plt addresses were handled, which
broke in the face of prelink offsets. This patch tries to standardize
how these addresses are handled.
* tapsets.cxx (query_plt_statement): New function to fix plt addresses,
both adding dwfl's elf bias and subtracting the dw bias, so it will
work with dwflpp::relocate_address like everything else.
(base_query::base_query): Leave session::consult_symtab alone!
(dwarf_query::query_module_symtab): PLT doesn't fake a path through
the symbol table anymore.
(dwarf_query::handle_query_module): Direct PLT to query_plt_statement.
(dwarf_query::add_probe_point): Remove the relocate exemption for plt.
* testsuite/systemtap.base/plt.exp: Update with a prelink test, and
refactor a lot of the test on the way.
Josh Stone [Wed, 13 Nov 2013 02:20:44 +0000 (18:20 -0800)]
stapdyn: warn on !isInstrumentable functions
The most common reason I've found that Dyninst won't allow us to
instrument a function is an indirect jump. This prevents them from
creating a control-flow graph, so they conservatively refuse.
Explicit indirect jumps are rare, like in the internals of longjmp, but
they may also occur for switches that are implemented with a jump table,
or tail calls to a vtable function, for instance.
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.