David Smith [Wed, 24 Jul 2013 16:13:02 +0000 (11:13 -0500)]
Added "buildok" test improvements.
* testsuite/systemtap.pass1-4/buildok.exp: Kfail twentyeightprime.stp if
we're using inode uprobes, since absolute probes don't work there.
* testsuite/buildok/twenty.stp: Also probe 'iterate_dir', since
'vfs_readdir' has been renamed.
Jonathan Lebon [Wed, 24 Jul 2013 12:59:11 +0000 (08:59 -0400)]
PR15375: implement function suggestions
Added dwarf_builder::suggest_functions(), which builds a list of similar
functions from a given function. This is used in dwarf_builder::build()
to suggest functions to the user when the probe point could not be
derived.
Jonathan Lebon [Wed, 24 Jul 2013 12:48:47 +0000 (08:48 -0400)]
PR15375: add visited_modules to dwarf_query struct
The visited_modules member of dwarf_query is used to keep track of all
the modules which have been visited during the query. This information
will be used in the function suggestion feature to know from which
modules to pull functions.
Jonathan Lebon [Wed, 24 Jul 2013 12:42:11 +0000 (08:42 -0400)]
PR15375: add sym_seen to module_info struct
The sym_tab struct only caches non-inlined functions. The sym_seen set
includes all functions, and is also updated during update_symtab. This
will allow us to give better function suggestions.
David Smith [Tue, 23 Jul 2013 19:49:26 +0000 (14:49 -0500)]
Kfail unsupported inode uprobes tests in unprivileged_probes.exp.
* testsuite/lib/systemtap.exp (inode_uprobes_p): New function.
* testsuite/systemtap.base/uprobes_filtering.exp: Use 'inode_uprobes_p',
instead of private code, to know whether to test.
* testsuite/systemtap.unprivileged/unprivileged_probes.exp
(test_unrestricted_probes): Kfail
'process(number).statement(number).absolute*' tests if we're using inode
uprobes, since absolute probes aren't supported.
David Smith [Tue, 23 Jul 2013 17:27:20 +0000 (12:27 -0500)]
Tweak systemtap.examples/process/psig.stp to compile on RHEL6.
* testsuite/systemtap.examples/process/psig.stp (translate_mask): Tweak
function to lower stack usage. This avoids the dreaded "the frame size
of XXX bytes is larger than 256 bytes" error messages.
David Smith [Mon, 22 Jul 2013 17:55:41 +0000 (12:55 -0500)]
Fix testsuite/semok/thirtysix.stp.
* testsuite/semok/thirtysix.stp: Since not all markers in "stap" have a
'$arg' parameter, this test was failing (correctly). To fix this, only
probe the "pass*__*" markers (which all have a '$arg' parameter).
David Smith [Fri, 19 Jul 2013 17:31:23 +0000 (12:31 -0500)]
The testsuite now looks for systemtap java support before java testing.
* testsuite/lib/systemtap.exp (java_p): New function.
(setup_systemtap_environment): Test for systemtap java functionality.
* testsuite/systemtap.apps/java.exp: Mark as untested if no stap java
support.
* testsuite/systemtap.unprivileged/unprivileged_probes.exp
(test_unrestricted_probes): Mark java probe tests as untested if no stap
java support.
David Smith [Wed, 17 Jul 2013 15:55:56 +0000 (10:55 -0500)]
Fix PR15751 by adding support for new 'compat' sigaction structures.
* buildrun.cxx (compile_pass): Added 'compat_sigaction' autoconf test.
* runtime/linux/autoconf-compat_sigaction.c: New file.
* tapset/linux/aux_syscalls.stp (_struct_sigaction32_u): Prefer 'struct
compat_sigaction' when available (over old 'struct sigaction32').
(_struct_old_sigaction32_u) Prefer 'struct compat_old_sigaction' when
available (over old 'struct old_sigaction32').
* testsuite/systemtap.context/usymbols.exp: Update to use
'compat_sigaction' where available.
David Smith [Tue, 16 Jul 2013 14:57:11 +0000 (09:57 -0500)]
Improve stapdyn uprobe error reporting.
* stapdyn/mutatee.cxx (mutatee::instrument_dynprobe_target): Turn off
dyninst error messages and add our own if we can't find the uprobe entry
functions.
David Smith [Fri, 12 Jul 2013 19:37:17 +0000 (14:37 -0500)]
PR15731: Fix 'syscall.{execve,compat_execve}' on newer kernels.
* tapset/linux/syscalls.stp (syscall.execve): Use 'sys_execve', since
'do_execve' can be inlined.
(syscall.compat_execve): Prefer 'compat_sys_execve', which can't be
inlined.
* tapset/linux/nd_syscalls.stp: Matching changes from syscalls.stp for
'nd_syscall.execve' and 'nd_syscall.compat_execve'.
* testsuite/buildok/twentyseven.stp: Updated for change to
'syscall.execve'.
* testsuite/systemtap.base/pointer_array.stp: Ditto.
* testsuite/systemtap.base/execve.exp: New 'syscall.execve' test.
* testsuite/systemtap.base/execve.stp: Ditto.
David Smith [Thu, 11 Jul 2013 19:17:20 +0000 (14:17 -0500)]
Improve perf probe warnings and testcase.
* runtime/linux/perf.c (_stp_perf_init): Print a better warning for
unsupported perf probe types.
* testsuite/systemtap.base/perf.exp: Change perf hw probes to sw probes,
which are more widely available.
Lukas Berk [Wed, 10 Jul 2013 20:52:57 +0000 (16:52 -0400)]
Enable 32-bit unwinding on 64bit
runtime/unwind.c: Add compat_task flag and enable COMPAT_REG_MAP
when active
runtime/unwind/unwind.h: Add COMPAT_REG_MAP 1 to 1 mapping in case x86_64.h
isn't defined
runtime/unwind/x86_64.h: COMPAT_REG_MAP mapping from 32 DWARF register values
to 64 bit register values
testsuite/systemtap.exelib/exelib.exp: enable -m32 flags on x86_64
translate.cxx: Remove warning and check for 32bit unwinding on 64bit
David Smith [Tue, 9 Jul 2013 21:16:18 +0000 (16:16 -0500)]
Improve buildok-dyninst.exp test results a bit.
* testsuite/systemtap.pass1-4/buildok-dyninst.exp: Add kfail for
buildok/fortyseven.stp.
* testsuite/buildok/gtod_init.stp: Only look for 'STAP_NEED_GETTIMEOFDAY'
when using the kernel runtime.
* testsuite/buildok/gtod_noinit.stp: Ditto.
Jonathan Lebon [Tue, 9 Jul 2013 19:11:23 +0000 (15:11 -0400)]
PR14927: change error messages from using warn/x() to staperror()
There are two main reasons for this:
1. Using staperror() will preface the errors with an "ERROR:" string,
which may be colored, depending on the coloring mode.
2. The use of warn() and family are not recommended as they are provided
only for compatibility with BSD.
When printing source context for an error, we don't really know how
many characters from the source to highlight for any given token, as
that only stores the starting column position.
The tok->content.size() is a guide, but not a perfect one, as for some
(tok_string, tok_embedded, ...), the content is processed from the
source characters (with quotation signs removed, etc.), for others,
the tok->content() can be many lines long. That's a problem because
if we try to source_line.substr(..., long_multiline_token.length()...),
we'll get a SEGV.
So we colorize only those tokens whose type is known to be simple and
literal transcriptions of the source file, starting at
column=tok->column.
Jonathan Lebon [Tue, 9 Jul 2013 13:50:48 +0000 (09:50 -0400)]
PR14927: make more warnings from staprun/stapdyn sensitive to -w
Before, even with the -w option specified for staprun, some warnings
(such as when the child process exits with a nonzero code) were still
output. Now, all warnings are affected by -w.
A similar operation was carried out in stapdyn, where the use of warnx()
was changed to stapwarn() so that -w now silences them. This changes
also gives those warnings the chance to be colored if necessary.
Jonathan Lebon [Tue, 9 Jul 2013 14:05:50 +0000 (10:05 -0400)]
PR14927: fix inheritance of color mode to staprun and stapdyn from stap
Added the -C switch in the building of the cmd for stapdyn. Also, since
the default color mode is now auto, we must check if the currently
active mode is anything other than auto before explicitly passing the -C
switch to staprun or stapdyn.
Jonathan Lebon [Fri, 5 Jul 2013 18:09:00 +0000 (14:09 -0400)]
PR14927: add new testcase color_parsing.exp
To make sure that the parser implemented for PR14927 is correct and
safe, this new testcase sets SYSTEMTAP_COLORS to various erroneous
values and verifies that both stap and staprun react accordingly.
Jonathan Lebon [Mon, 8 Jul 2013 15:34:15 +0000 (11:34 -0400)]
PR14927: make stap use same parser as staprun for consistency
In order to ensure that both stap and staprun react the same way to
various values of SYSTEMTAP_COLORS, the parsing method in staprun was
copied to replace the one in stap (with small C++ adjustments).
This will also allow us to test both stap and staprun using the same
test cases (see the next commit).
Jonathan Lebon [Fri, 5 Jul 2013 17:25:10 +0000 (13:25 -0400)]
PR14927: enable coloring for stap and staprun/io by default
The default coloring mode was changed from 'never' to 'auto'.
Additionally, the terminal is now checked to make sure that it is not
dumb (i.e. it understands ANSI codes). Finally, to make sure that the
color sequences don't affect the testsuite, the latter was changed to
impersonate a dumb terminal.
Jonathan Lebon [Thu, 4 Jul 2013 20:55:28 +0000 (16:55 -0400)]
make STP_OOB_DATA treatment more stringent
Since all STP_OOB_DATA originally comes from _stp_vlog() in
runtime/linux/io.c, we can be sure that all warnings will be prefixed
by "WARNING: " and all errors by "ERROR: ", as defined by WARN_STRING
ERR_STRING in io.c.
Therefore, we can be more stringent in control.c and mainloop.c in the
way we identify warnings and errors. Additionally, warnings can instead
use the warn() macro and errors the err() macro so that they benefit
from coloring.
The main effect of this patch is that all calls to _stp_warn() and
_stp_error() will be colored upon reception by stapio.
Jonathan Lebon [Tue, 2 Jul 2013 20:33:30 +0000 (16:33 -0400)]
PR14927: change wording in some call sites to err() and perr()
Following the changes from the previous commit, all calls to err() and
perr() were checked so that they were consistent with the prefix
"ERROR:" added by those macros.
Where err() was used to report non-critical information, it was
replaced by eprintf(), and where it was used for warnings, it was
replaced by the warn() macro.
Jonathan Lebon [Tue, 2 Jul 2013 15:04:36 +0000 (11:04 -0400)]
PR14927: add -C switch for color in staprun/io
Also make stap send the -C switch if itself it was called with --color.
As opposed to the --color switch of stap, the WHEN argument was made
mandatory here so that it's consistent with the others, and it doesn't
conflict with the MODULE argument (and users don't have to resort to
using e.g. '-Cauto').
A few formatting fixes in the staprun manual page.
Jonathan Lebon [Fri, 28 Jun 2013 15:55:03 +0000 (11:55 -0400)]
PR14927: parse SYSTEMTAP_COLOR on-the-fly
Colors are no longer stored in memory. Instead, upon each request to
colorize(), the SYSTEMTAP_COLOR env var is parsed and queried for the
value of the key of interest.
This allows colorize() and parse_stap_color() to be more self-contained
and easier to eventually port to other parts of SystemTap, such as
staprun/io.
David Smith [Fri, 28 Jun 2013 15:18:14 +0000 (10:18 -0500)]
Fix 'buildok' testsuite failures on ia32.
* testsuite/buildok/nd_syscalls-detailed.stp: Mark 'compat' probe alias
tests as optional, so test will pass on ia32.
* testsuite/buildok/nd_syscalls2-detailed.stp: Dito.
* testsuite/buildok/syscalls-detailed.stp: Ditto.
Jonathan Lebon [Fri, 28 Jun 2013 13:47:55 +0000 (09:47 -0400)]
PR14927: enable support for SYSTEMTAP_COLORS env var
The new SYSTEMTAP_COLORS environment variable allows users to customize
colors. See the updated man page for more info on the syntax and
behaviour of this new env var.
Jonathan Lebon [Tue, 25 Jun 2013 19:06:41 +0000 (15:06 -0400)]
PR14927: elaborate.cxx: change a warning to use print_token()
To be more consistent with other print_warning() calls in the file,
this warning was changed to use its second overloaded form, in which
the token is given as the second argument. This has for effect to allow
proper pretty printing of the token using print_token(), thus making
sure that the path is not repeated and that output is coloured if
necessary.
Jonathan Lebon [Fri, 28 Jun 2013 13:15:08 +0000 (09:15 -0400)]
PR14927: add colorize() functions and colorization mechanism
Added colorization of the following elements:
- Error type (e.g. 'semantic error')
- Source location (e.g. '<input>:1:7')
- Caret ('^')
- Token (the one above the caret)
Jonathan Lebon [Fri, 21 Jun 2013 15:34:47 +0000 (11:34 -0400)]
PR14927: lay groundwork for colors
Created a new command-line option '--color' which is capable of taking
in an argument as well. Added a new member 'color_errors' to the
systemtap_session class which gets set upon treating the new switch's
logic. Also created an entry in the man page.
Jonathan Lebon [Mon, 24 Jun 2013 18:05:42 +0000 (14:05 -0400)]
PR14927: move parser::print_error() to systemtap_session
The parser::print_error() method was moved from the parser class to the
systemtap_session class in anticipation for colorization. The session
class previously already took care of error printing, except for parser
errors. Making all the error-printing methods part of the same class
will simplify the implementation of colorization.
Josh Stone [Fri, 28 Jun 2013 03:01:53 +0000 (20:01 -0700)]
Use explicit sys_utimes functions for at_var.exp
This test wants to access a typed $utimes variable, but on architectures
with HAVE_SYSCALL_WRAPPERS the main sys_utimes has all long arguments.
And starting in 3.10, all archs have syscall wrappers, yay! For this
test's purposes, it's perfectly fine to use the inline SYSC_utimes where
that exists.
Josh Stone [Thu, 27 Jun 2013 22:39:19 +0000 (15:39 -0700)]
PR15688: Set pragma:vma when dwflpp uses _stp_umodule_relocate
* dwflpp.cxx (dwflpp::emit_address): Use pragma:vma when needed, rather
than trying to enable_task_finder. This also leaves the opportunity
for this generated code to be optimized out, such that vma-tracking
may not be needed after all.
* elaborate.cxx (embeddedcode_info::visit_embeddedcode): Before enabling
the vma-tracker, check if runtime=dyninst for PR15052. This turns an
ugly pass-4 failure into a nicer pass-2 message.
* session.cxx (systemtap_session::parse_cmdline): Don't force vma here
for userspace -d modules; dwflpp will add pragma:vma as needed.
* tapsets.cxx (dwarf_atvar_expanding_visitor::visit_atvar_op): Don't
enable_vma_tracker manually; dwflpp will add pragma:vma as needed.
* testsuite/systemtap.base/sdt_global_var.exp: Clear this setup_kfail.
PR11096: Add support for the "module" argument to @var
The notation @var("varname@cuname", "module") is now supported and @var
can thus effectively be used almost everywhere like the context of stap
functions, probe timer.profile, and probe kernel.trace().
Just like @cast, multiple module names can be specified by separating
them with ":", for example, "module1:module2:module3". And they will be
attempted in turn until a match is found.
Refactored the code by introducing atvar_op as suggested by Josh Stone
to make the implementation cleaner. The fields "target_name" and
"cu_name" have been moved from target_symbol to its subclass atvar_op.
@var now searches all the CUs that matches the "cuname" specified for the
variable. And when "cuname" is missing, @var just searches all the CUs.
Accessing global variables in PIE and DSO via @var with either "cuname"
or "module" now mostly works for the default (kernel) runtime (but note
PR15688).
Thanks Josh Stone for reviewing this patch and providing a lot of
invaluable suggestions.
* parse.cxx: Add support for the optional "module" parameter to the
parser.
* staptree.h: Remove the "target_name" field from target_symbol and make
sym_name() virtual. Define atvar_op which inherits target_symbol. Add
method visit_atvar_op to the visitor classes.
* staptree.cxx: Define visit_atvar_op for the visitor classes. Define
methods of atvar_op.
* tapsets.cxx: Define visit_atvar_op for dwarf_var_expanding_visitor,
sdt_uprobe_var_expanding_visitor, and
tracepoint_var_expanding_visitor. Define dwarf_atvar_expanding_visitor
to run in series with dwarf_cast_expanding_visitor in
dwarf_derived_probe. Add dwarf_atvar_query to handle the DWARF queres
of dwarf_atvar_expanding_visitor. Postpone the processing of @var with
either cu name or module name or both to dwarf_atvar_expanding_visitor
in order to eliminate code duplication.
* elaborate.h: Declare visit_atvar_op for typeresolution_info.
void_statement_reducer.
* elaborate.cxx: Define visit_atvar_op for symbol_fetcher,
typeresolution_info, and void_statement_reducer.
* translate.cxx: Define visit_atvar_op for c_unparser.
* testsuite/systemtap.base/: Add many more test cases for @var.
David Smith [Thu, 27 Jun 2013 17:21:39 +0000 (12:21 -0500)]
Fixed PR15690 by fixing 32-bit {nd_}syscall.rt_sigprocmask probe alias.
* tapset/linux/syscalls2.stp: Split 'rt_sigprocmask' alias into
'rt_sigprocmask' and 'compat_rt_sigprocmask'.
* tapset/linux/nd_syscalls2.stp: Ditto.
* tapset/linux/aux_syscalls.stp (sigset_from_compat): New C function for
use when the real function isn't exported.
(_stp_compat_sigset_u): New tapset function.
* buildrun.cxx (compile_pass): Add "sigset_from_compat" export test.
* testsuite/buildok/syscalls2-detailed.stp: Added 'compat_rt_sigprocmask'
test.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
Jonathan Lebon [Thu, 27 Jun 2013 15:35:33 +0000 (11:35 -0400)]
fix umodname()-related issues in testsuite
In vma_vdso.stp, calling umodname() alone was getting elided because of
the /* pure */ marker present. The test was modified so that the value
of umodname() is used (even though the if branch will never be taken).
In usymbols.exp and pf3.stp, wrapped umodname() and modname() calls
between try/catch blocks.