David Smith [Thu, 19 Jun 2014 17:33:52 +0000 (12:33 -0500)]
Minor testsuite updates.
* testsuite/lib/compile_flags.exp: Added a bit more aarch64 support.
* testsuite/systemtap.base/bz1027459.exp: Only run on make
installcheck. Clean up better after a 'spawn'.
* testsuite/systemtap.base/task_dentry_path.exp: Only run on make
installcheck.
* testsuite/systemtap.base/wordexp.exp: Ditto.
* testsuite/systemtap.server/server_locale.exp: Ditto.
Josh Stone [Fri, 13 Jun 2014 23:12:34 +0000 (16:12 -0700)]
runtime: Make sure to free special message buffers too
These special buffers were formerly kept aside, and never released back
to the memory pool, so they weren't freed either. DEBUG_MEM did report
this leak properly. Now these are freed too, and a new debug_mem.exp
test ensures that a simple script doesn't leak any memory.
Josh Stone [Fri, 13 Jun 2014 21:47:54 +0000 (14:47 -0700)]
PR17052: Use RCU-sched for freeing contexts
A context is grabbed from the _stp_ctl_work_callback timer, but it
doesn't actually need it for anything other than preventing a lock
recursion. Since this timer is still running while we are freeing the
contexts, there's a chance to race on the existence of contexts.
Using rcu_assign_pointer, rcu_dereference_sched, and synchronize_sched,
we can make sure that anyone who might have seen the existing contexts
has finished before we free them.
Jonathan Lebon [Fri, 13 Jun 2014 17:24:36 +0000 (13:24 -0400)]
initscript: check script names
Because script names are the basis for some variable names (e.g.
script_name_REQ), they need to adhere to bash variable naming rules.
These are almost the same rules that we enforce for stap -m, so we just
fail 'earlier'. See also RHBZ1109084.
This patch ensures that scripts with invalid names are skipped and
logged.
Jonathan Lebon [Fri, 13 Jun 2014 14:45:03 +0000 (10:45 -0400)]
initscript: use SYSTEMCTL_SKIP_REDIRECT
The SYSTEMCTL_SKIP_REDIRECT variable allows us to avoid being 'handled'
by systemd when users use the legacy 'service' command. This is
necessary in our case because systemctl omits the parameters passed to
the 'service' command for standard service actions such as start/stop.
This commit was initially required because execve would not pass on
RHEL6, which relied on kernel_string() rather than user_string_quoted().
With the new kernel_string_quoted() function, this test should pass on
all platforms.
Jonathan Lebon [Thu, 12 Jun 2014 17:34:06 +0000 (13:34 -0400)]
conversions.stp: new kernel_string_quoted() function
Just like user_string_quoted(), the new kernel_string_quoted() function
returns the resulting string in quotes if it successfully retrieved the
string and the pointer address otherwise.
Abegail Jakop [Thu, 12 Jun 2014 14:13:18 +0000 (10:13 -0400)]
count max statements in probes in translate.cxx
translate.cxx: counts the maximum number of statements expected
to be executed for each probe, in pass 3. results are printed when
verbosity is > 1. probes with for/foreach statements have a
reported statement count of ~0.
Jonathan Lebon [Wed, 11 Jun 2014 18:06:07 +0000 (14:06 -0400)]
listing_mode.exp: use stap itself to get addr of vfs_read
On older platforms, the addresses obtained from /proc/kallsyms show up
as 0 for non-root users. So instead, we use stap itself to retrieve the
address of vfs_read which is later used for testing.
Jonathan Lebon [Wed, 11 Jun 2014 17:34:36 +0000 (13:34 -0400)]
lib/systemtap.exp: add callee_probes_p proc
Rather than checking for the conditions for callee support in various
testcases, add a callee_probes_p proc in lib/systemtap.exp and use that
instead where needed.
Jonathan Lebon [Wed, 11 Jun 2014 17:28:51 +0000 (13:28 -0400)]
lib/systemtap.exp: rename hw_breakpoint_p to hwbkpt_probes_p
To be more consistent with the other procs in lib/systemtap.exp which
check whether certain types of probes are supported, rename
hw_breakpoint_p to hwbkpt_probes_p.
Jonathan Lebon [Wed, 11 Jun 2014 15:15:14 +0000 (11:15 -0400)]
vars.exp: only parse out from first line of grep
There can be multiple _stp_snprintf lines, in which case, the resulting
values for vars and parms can hold the same variables multiple times,
thus throwing off the test (see RHBZ1099757#c4).
Fix this by only using the first line output from grep.
Using a process.function(0xabcd) may still cause prologue searching to
occur on older platforms (for GCC < 4.5) due to possibly bad debuginfo
in the prologue (see e.g. commit 277a2b9 and GDB's PR13777).
Thus, the resulting probe from a process.function(0xabcd) might not
match the exact address given if it has been adjusted by
prologue-searching. So we relax the requirement by simply checking that
the address printed in a proper hex format.
Jonathan Lebon [Tue, 10 Jun 2014 21:38:05 +0000 (17:38 -0400)]
listing_mode.exp: don't test HW bkpt probes if unsupported
We check if HW breakpoint probes are available on the machine during
testsuite setup and use the new hw_breakpoint_p proc in listing_mode.exp
to check if these probes should be tested.
Jonathan Lebon [Wed, 4 Jun 2014 21:46:03 +0000 (17:46 -0400)]
statement.exp: remove mentions of RANGE
Since commit f01d4ff, we now no longer have a RANGE lineno_type. So
let's remove mentions of it to avoid future confusion and replace it by
the new ENUMERATED lineno type. Also clear up subtest names.
Jonathan Lebon [Tue, 10 Jun 2014 21:36:39 +0000 (17:36 -0400)]
stmt_rel.exp: relax requirement for PASS
We previously required that all linenos accessible through wildcards
were the same set as all linenos individually accessible through
relative numbering.
The issue is that two linenos may correspond to the same address (e.g.
due to optimization), in which case a wildcard probe would only pick up
the first lineno (since the second lineno would be eliminated due to
being the same address), which two individual relative probes for these
two linenos would both resolve.
So instead, this test now simply checks that all the linenos which were
found in the wildcard probe were also accessible through relative lineno
(i.e. a subtest test instead of equality test).
David Smith [Tue, 10 Jun 2014 19:58:28 +0000 (14:58 -0500)]
PR16716 partial fix: Fix types in syscall.{fchdir,mkdir,mkdirat}.
* tapset/linux/syscalls.stp (syscall.fchdir): Fixed types.
(syscall.mkdir): Ditto.
(syscall.mkdirat): Fixed types and added 'dirfd_str' convenience
variable, to match syscall.{faccessat,fchmodat,fchownat,etc.}.
* tapset/linux/nd_syscalls.stp: Similar changes.
* testsuite/systemtap.syscall/dir.c: Added more tests.
* testsuite/buildok/syscalls-detailed.stp: Added test for 'dirfd_str'
variable of syscall.mkdirat.
* testsuite/buildok/nd_syscalls-detailed.stp: Ditto.
Jonathan Lebon [Tue, 10 Jun 2014 17:41:28 +0000 (13:41 -0400)]
loc2c: make u_fetch_register() respect CONFIG_COMPAT
If CONFIG_COMPAT is defined, then it is possible to be running 32/31-bit
tasks on a 64-bit kernel. In such cases, we need to ensure that the
values returned from u_fetch_register() are 32-bit friendly.
Thus, we mask whatever pt_regs_fetch_register() returns.
David Smith [Mon, 9 Jun 2014 14:11:13 +0000 (09:11 -0500)]
Fix BZ1099555 by reworking gtod.exp.
* testsuite/systemtap.base/gtod.exp: Rework so that we don't care about
what order the output comes. All we care about now is the variance
between the kernel's time and systemtap's time.
* testsuite/systemtap.base/gtod.c (main): Print the iteration number first.
* testsuite/systemtap.base/gtod.stp: Ditto.
stap -V version string: include build-time elfutils version
We have some translator facilities that are based on _ELFUTILS_PREREQ,
a compile-time elfutils version check. Others might change behavior
based on the run-time elfutils version. These versions may differ,
as the system elfutils libraries are upgraded without stap being
rebuilt. This patch changes stap -V to report both run-time and
build-time elfutils versions (if they are different).
Jonathan Lebon [Thu, 5 Jun 2014 15:09:11 +0000 (11:09 -0400)]
PR17027: adapt pr16806.exp for RHEL6
This test failed on RHEL6 for two reasons:
- The 'timeout' program doesn't support non-integer arguments
- We assumed the uprobes module was already inserted.
Fix the first by changing the timeout to 1s (I verified that this
doesn't change the lethality of the test under the right conditions).
Fix the second by doing a sample run first to allow stap the chance to
self-compile and pass the uprobes module to staprun -u.
Mark Wielaard [Thu, 5 Jun 2014 09:13:31 +0000 (11:13 +0200)]
systemtap_session::modules_must_be_signed might use uninitialized memory.
statm >> status might not actually assign anything to status.
operator >> on ifstream doesn't assign anything the underlying file
doesn't exist. So status will just have random contents that happened
to be on the stack. Make sure to initialize status first.
Mark Wielaard [Thu, 5 Jun 2014 08:12:57 +0000 (10:12 +0200)]
Extra details to explain the error or provide alternatives to the user.
Each one printed after the main error message and tokens aligned on
separate lines. Just push_back anything you want that better explains
the error to the user (not meant for extra verbose developer messages).
Use it for the new explanations of the "not accessible at this address"
errors. Split in die_location_as_string, die_location_as_function_string
and suggested_locations_string.
Mark Wielaard [Wed, 4 Jun 2014 18:48:23 +0000 (20:48 +0200)]
Report address locations where things are accessible in error message.
Instead of just saying "not accessible at this address" tell at which
addresses the location is accessible. Uses dwarf_getlocations which
requires elfutils 0.158+ (if not available, just don't suggest anything).
Mark Wielaard [Wed, 4 Jun 2014 13:24:41 +0000 (15:24 +0200)]
Improve not accessible at this address error message.
Add dwflpp::pc_die_location_as_string and dwflpp::pc_die_location_as_string
to provide more human readable PC and DWARF DIE offset names and source
locations (including which function was inlined where) to help track down
why an argument or variable isn't accessible at a certain address.
David Smith [Tue, 3 Jun 2014 16:05:20 +0000 (11:05 -0500)]
Fixed BZ1099791 by updating the runtime to correctly find the vdso.
* translate.cxx (find_vdso): Add comment mentioning the logic in
_stp_vma_match_vdso needs to match.
* runtime/vma.c (_stp_vma_match_vdso): Add logic from find_vdso() to parse
the path, looking for the vdso.
Jonathan Lebon [Sun, 1 Jun 2014 19:58:48 +0000 (15:58 -0400)]
dwflpp.cxx: check addr returned by lower_bound()
This is a follow-up to commit 71b8e66. The lower_bound() function
returns an iterator to the first addr which does not compare less than
the entrypc. This means that the returned addr is either equal or
greater than the entrypc (depending on whether the latter is in the
vector).
This patch simply checks that the addr returned by lower_bound() is
equal, not just greater or equal.
Jonathan Lebon [Fri, 30 May 2014 19:42:00 +0000 (15:42 -0400)]
dwflpp.cxx: use lower_bound() instead of manual binary search
This is a follow-up to commit 1d50099. We previously implemented our own
binary search to find the line record associated with the function's
entrypc. To be on the safe side, we instead rely on lower_bound() for
binary searching, which will pick the first element in a range of equal
addresses, thus avoiding issues such as BZ1099133.
Jonathan Lebon [Fri, 30 May 2014 15:47:51 +0000 (11:47 -0400)]
BZ1099133: prologue searching: check previous line too
We perform binary search to retrieve the line record matching the
entrypc. However, we may by chance fall on the second of two line
records for the same entrypc. Check for this after binary search is
done.
Jonathan Lebon [Fri, 30 May 2014 14:26:01 +0000 (10:26 -0400)]
BZ1099825: probe_by_pid.exp: small tweak in C program
Since PR6941 (commit 277a2b9), prologue-searching is skipped for
optimized code. However, we do not skip it for GCC < 4.5, which may
provide bad location info (see GDB's PR13777).
On RHEL6, this testcase was failing because prologue-searching was not
skipped, and fell inside the loop in main(). To allow for a safe landing
zone, we slightly tweak the C program so that there is a safe
instruction to land on post-prologue that is not in the loop.
Stan Cox [Thu, 29 May 2014 20:04:13 +0000 (16:04 -0400)]
Relax static-probes.d input file syntax.
* dtrace.in (dtrace_bnf): Allow probe_ident to start with any alphanumeric.
Make trailing probe declaration ';' optional.
(_PypProvider::probe_write): Improve error messages.
Jonathan Lebon [Wed, 28 May 2014 15:12:18 +0000 (11:12 -0400)]
BZ1099757: vars.exp: fix and strengthen
Since PR16615 (merge commit 4636ca3), linenos in statement probes have
become more precise and stringent. As a result, vars.exp was failing
because it was trying to probe a statement at a lineno with no line
records.
We fix this by first retrieving the first valid lineno using stap -l.
The test has also been refactored in general to be more robust. We can
now more easily add more functions to test (e.g. we now test both
bio_copy_user() and vfs_read()).
Jonathan Lebon [Fri, 16 May 2014 14:45:27 +0000 (10:45 -0400)]
list.exp: fix regexes and strengthen
Fix regular expressions so that we expect the full path from stap rather
than just process("stap"). Also strengthen the testcase by making
matches against all output lines, rather than just checking if a single
line matches.
Jonathan Lebon [Tue, 13 May 2014 21:15:01 +0000 (17:15 -0400)]
derive_probes(): properly handle optionality
We previously overrode a location's optionality if it was derived from a
globby process probe. However, this causes further probe points to be
derived to also be optional, even though the 'higher level' probe point
had its optionality restored to what the user really wants. The end
result was that we would list probes as not optional even though the
endpoint probe was optional.
What we really mean when we say process probes born out of a higher
globby process probe should be optional is that only some of the matched
binaries will actually resolve, so it's OK if some don't resolve.
However, those that *do* resolve should respect the user's wish with
regards to optionality.
To do this, we must not override the probe_point's optional flag in
derive_probes.
This is mostly a cosmetic change, although some runtime elements do rely
on optionality to decide whether to emit a warning upon failing to
register a probe.
This patch also makes process.library probes born out of a higher globby
library probe follow the same logic.
The line at which 'mylabel' occurs is not actually associated with any
line records. Thus, when using the new iterate_over_srcfile_lines(),
specifying the lineno of the label results in no records found, whereas
prior to PR16615, the next lineno would be picked up.
Regardless, the previous mechanism of using iterate_over_srcfile_lines()
to then call back to query_srcfile_label() which in turn called
iterate_over_labels() was a roundabout way of making sure that the
specified lineno lies in a filtered function's DIE.
We now rework iterate_over_labels() to directly handle lineno matching
when necessary. Supported cases:
process.function("foo@file.c:N").label("*")
--> matches label in foo at N
process.function("foo@file.c+N").label("*")
--> matches label in foo at N + decl_line of foo
process.function("foo@file.c:N-M").label("*")
--> matches labels in foo between N and M
process.function("foo@file.c:*").label("*")
--> matches all labels in foo
This patch also pushes down the priority of "func@file:N" type probes so
that if a .label or .callee[s] is present, then the relevant
iterate_over_*() is called, rather than iterate_over_srcfile_lines().
Jonathan Lebon [Thu, 15 May 2014 22:06:17 +0000 (18:06 -0400)]
alias probes: mark final aliases as well-formed
When building probes from aliases, we mark them as well-formed if they
reached their final derivation so that in listing mode, we stop at this
final alias form.
Jonathan Lebon [Wed, 7 May 2014 18:16:24 +0000 (14:16 -0400)]
library probes: also try non-NEEDED libraries
This patch adds back support for non-NEEDED libraries even when the user
supplied a non-canonical path. However, a WARNING is emitted to notify
the user. This WARNING can be suppressed by specifying the fully
resolved path to the library.
Jonathan Lebon [Mon, 26 May 2014 16:01:18 +0000 (12:01 -0400)]
process probes: throw error upon unresolved executable
When find_executable() fails to resolve something, it simply returns the
same path it was fed. Depending on the context, the caller may be able
to deal with an unresolved path.
In the case of process probes for dwarf_builder and other base_query
users, dealing with it meant simply that the dwflpp failed to find the
executable which meant iterate_over_modules() never even took off (and
we thus yielded the good ol' "no match" error).
However, in the case of library probes, this may not always work because
if the library path is fully specified, we will switch to it without
resorting to iterate_over_libraries() (see also previous patch) and
without ever actually checking if the process path was fully resolved,
thus allowing a probe such as the following to be created:
So instead, we add explicit checks to verify that process probes were
properly resolved by find_executable(). As an added benefit, users get a
clearer reason of why the probe point failed:
BEFORE:
semantic error: while resolving probe point: identifier 'process' at <input>:1:7
source: probe process("asdf").library("mylib.so").function("foo") {}
^
semantic error: no match
AFTER:
semantic error: while resolving probe point: identifier 'process' at <input>:1:7
source: probe process("asdf").library("mylib.so").function("foo") {}
^
One of two things happens to library probes the first time we enter
dwarf_builder::build():
- If the full path can be resolved using find_executable(), then we
would right away switch focus to the library, rather than the
process.
- Otherwise, we would focus on the process and then use
iterate_over_libraries() to find a library match.
These decisions are made in two spots: in dwarf_builder::build(), prior
to creating the dwflpp object, and in base_query::base_query().
When we resort to iterate_over_libraries(), new probes are created for
each matching library. And since the path inserted in those new probes
is the full path, find_executable() will find it upon recursing into
dwarf_builder::build().
One issue is that if find_executable() succeeds on the first time, we
will focus on the library, regardless of whether the library is NEEDED
or not. Whereas if find_executable() fails, only NEEDED libraries could
ever be picked up by iterate_over_libraries().
This is mostly fine, except that it creates an inconsistency. For
example, let's say executable 'bar' depends on 'libfoo.so' located in
/lib/. Doing a "libfoo.so" library probe would prioritize a libfoo.so
file in the current directory before the one in /lib/, which is the
'real' one. On the other hand, doing "libfoo.*" would match the
libfoo.so file in /lib/ because of the glob char.
It also fixes the potential issue of having a fully specified library
path with a bad process path: we would focus on the library yet in
query_module() try to iterate_over_libraries() on the library, thinking
that the library was not resolved.
In this series of patches, we change the behaviour as follow
- Only switch to the library on the first entry of
dwarf_builder::build() if the path is already fully resolved.
Otherwise, always use iterate_over_libraries().
- If iterate_over_libraries() fails, then try a direct
find_executable() invocation, and warn that the found library is
not a NEEDED one.
This patch does the first part only. The second part is done in the next
patch.
Jonathan Lebon [Tue, 6 May 2014 20:39:04 +0000 (16:39 -0400)]
library probes: don't add libraries to visited_modules
The dwarf_query's visited_modules set is used to keep track of which
modules are visited for suggestions. It works by emptying out the visited
modules into the dwarf_builder's modules_seen after we're done iterating
through the modules. By the end, modules_seen contains the full list of
modules to suggest from.
Since .library(glob) probes resolve to multiple probes for each matching
library, dwarf_builder's modules_seen will already pick each of them up
from the individually created dwarf_query objects.
So in the end, the modules_seen from which we make suggestions will
already contain them.
Almost all of the users of final_function_name() call it with a const
char* for the filename, rather than a string. There may be cases where
the filename is NULL (e.g. if the function was derived using the
symtab), in which case we don't want to cast to a string.
Jonathan Lebon [Wed, 14 May 2014 14:48:39 +0000 (10:48 -0400)]
query_plt_statement(): add well-formed probe point
If the user provides a .plt[(string)] probe, then we'll end up in
query_one_plt during plt iteration, in which we create a specific_loc
where we replace the possibly globby string with the found plt. Mark
this specific loc as well-formed.
If the user provides a .plt[(string)].statement(number) probe, then
we'll end up in query_plt_statement() directly, in which case we need to
create the final well-formed probe point in which we omit the .plt part.