Josh Stone [Wed, 14 May 2014 01:21:57 +0000 (18:21 -0700)]
Unify checks for target_symbol::comp_pretty_print
The slightly-complicated check for comp_pretty_print was repeated in a few
places. These are now done via target_symbol::pretty_print_depth() and
::check_pretty_print(), and the latter handles common lvalue asserts too.
Josh Stone [Tue, 13 May 2014 23:55:55 +0000 (16:55 -0700)]
Hide the details of target_symbol_setter_functioncalls
This is a somewhat ugly detail of var_expanding_visitor for turning
lvalue assignments into functioncalls, and the manipulation of
target_symbol_setter_functioncalls was duplicated in several places.
Make that manipulation a new method, provide_lvalue_call, and hide that
field as private.
Josh Stone [Tue, 13 May 2014 23:28:25 +0000 (16:28 -0700)]
Resolve function refs added by autocast expansion
* elaborate.cxx(autocast_expanding_visitor::resolve_functioncall): New,
run symresolution and functioncall_traversing to make sure functions
added by autocasting are resolved.
(autocast_expanding_visitor::visit_autocast_op): Use it.
Josh Stone [Fri, 9 May 2014 23:46:21 +0000 (16:46 -0700)]
elaborate: Propagate type_details in limited cases
First there's a new exp_type_null which acts as an explicit marker,
"there be no detailed types here!" Apply this to globals, and it may
also be used combining disparate type details to degrade to pe_long.
Then there are three expression cases that copy type details around:
* Ternary (?:) - if the true/false branches agree on type details, then
the expression as a whole carries that type too.
* Plain assignment (=) - the right side propagates to the left, but not
vice versa. The assignment itself gets the type details too.
* Symbol to its declaration, and vice versa. If the details of either
disagree, then both are demoted to exp_type_null, so that can trickle
back to all uses of that symbol.
Josh Stone [Fri, 9 May 2014 23:45:24 +0000 (16:45 -0700)]
elaborate: turn referent asserts into exceptions
It's a bit nicer to throw an "internal error" semantic error message,
rather than assert and leave dirty tmp et al, especially while I'm working
on (and breaking) type resolution. :)
So that captures the task_current() address *with* the type, and then
the "->pid" is working as a separate expression to dereference it.
* elaborate.cxx (semantic_pass_symbols): Move build_no_more from here...
(semantic_pass): ... to here, well after all types are resolved.
(autocast_expanding_visitor): New, call on the type_details to expand
autocast_op into a functioncall, like any $var/@cast would.
(semantic_pass_types): Use autocast_expanding_visitor whenever the
normal type resolution indicated there might be something to do.
(typeresolution_info::visit_autocast_op): Don't fail immediately;
just visit the operand, and note when type_details show up.
* tapsets.cxx (exp_type_dwarf::expand): Expand that autocast_op!
(dwarf_autocast_expanding_visitor): Removed in favor of just having
autocast_expanding_visitor call exp_type_ptr->expand().
Josh Stone [Tue, 6 May 2014 22:28:21 +0000 (15:28 -0700)]
Save type details in expressions
* dwflpp.cxx (dwflpp::translate_final_fetch_or_store): Return the final
typedie in memory provided by the caller.
(dwflpp::literal_stmt_for_local): Pass through the final typedie.
(dwflpp::literal_stmt_for_return): Ditto.
(dwflpp::literal_stmt_for_pointer): Ditto.
* staptree.h (exp_type_details): New, generic type extras.
(expression): Store optional exp_type_details.
(expression_visitor): New, simple visitor to ease operating on all
expressions equally.
* staptree.cxx (expression_visitor): Implement.
* tapsets.cxx (exp_type_dwarf): New DWARF type details.
(synthetic_embedded_deref_call): Set the DWARF type on the resulting
functioncall expression.
* elaborate.cxx (expression_build_no_more_visitor): New, clear extra
type details from all expressions.
(build_no_more): Clear expression types before calling build_no_more
in the builders, so dwflpp lives long enough.
Jonathan Lebon [Fri, 2 May 2014 14:19:06 +0000 (10:19 -0400)]
PR16894: new wordexp.exp to check -c COMMAND handling
This simple testcase checks that invalid -c COMMANDs for unspecified
process probes are properly handled (e.g. prior to commit eb94071, we
segfaulted).
Jonathan Lebon [Fri, 2 May 2014 13:43:07 +0000 (09:43 -0400)]
PR16894: give better errors re. -c commands
This patch allows SystemTap to make the distinction when reporting an
error between no -c command given, and a given but invalid -c command.
- man/stapprobes.3stap: introduce 'unspecified' verbiage and clear up
restrictions on unspecified process probes
- session.cxx: cmd_file() now throws errors upon wordexp() failures
- tapsets.cxx: (1) handle possibility of error from cmd_file() and chain
with own error if it occurs
(2) separately handle no -c command / empty file
(3) introduce 'unspecified' verbiage in error messages
and point to [man stapprobes]
- tapset-perfmon.cxx: ditto
Jonathan Lebon [Tue, 29 Apr 2014 18:32:48 +0000 (14:32 -0400)]
pyexample.stp: split into py2example.stp and py3example.stp
In order to be compatible on systems with only python2 installed (or
only python3 installed), we split the pyexample.stp script into two
versions.
We also add a test_support line in the meta files so that check.exp
marks them as untested if either/both python versions are not present.
In the tapsets, we make py2/3 aliases that the scripts then use, but
also create general ones that refer to both the 2 and 3 variants.
The python3 version requires -g --suppress-time-limits, otherwise it's
very likely that a 'overhead exceeded' ERROR.
- py2example.stp: python 2 version of the script
- py2example.meta: meta file for python 2 version, with test_support
check for python 2 specific SDT markers
- py3example.stp: python 3 version of the script
- py3example.meta: meta file for python 3 version, with test_support
check for python 3 specific SDT markers
- tapset/python2.stp: make python2 specific aliases and alias the
general ones to that
- tapset/python3.stp: make python3 specific aliases and alias the
general ones to that
Lukas Berk [Tue, 29 Apr 2014 20:17:36 +0000 (16:17 -0400)]
Fix typo for suppress-time-limits in runtime headers
*man/stap.1 - update man page to properly list macro's
and polarity of statement
*runtime/common_probe_context.h - fix STAP_SUPPRESS_TIME_LIMITS_ENABLE typo
*runtime/runtime_defines.h - ditto
David Smith [Tue, 29 Apr 2014 15:54:27 +0000 (10:54 -0500)]
PR16716 partial fix: Fix types in syscall.{dup,dup2,dup3}.
* tapset/linux/syscalls.stp: Fixed types in syscall.{dup,dup2,dup3}.
* tapset/linux/aux_syscalls.stp (_dup3_flag_str): Just use the open mode
flags list.
* testsuite/systemtap.syscall/dup.c: Add more tests.
Jonathan Lebon [Thu, 24 Apr 2014 16:53:06 +0000 (12:53 -0400)]
new helper script scripts/update-copyrights
This script looks at all the tracked files in the tree that are
copyrighted by <company> and updates the copyright year if they've been
modified this year by a user at <domain>.
PR16406: fix build-id false mismatch for userspace-program vs. kernel-module
The translate.cxx-emitted _stp_module array has two name fields, .name
and .path, which were ambiguous as to whether each was a kernel module
or a userspace executable. The .name string was just the basename,
and it was used in the near-startup-time _stp_module_check(). If the
userspace program matched a kernel module, bangorama (a false build-id
mismatch error at startup) .. unless --all-modules was given, in
which case the kernel modules won the duplication race.
The correction has a couple of parts. First, the _stp_module .name is
made the same as the fully-/-qualified .path for userspace programs.
Second, _stp_module_check checks all kernel+module bits it knows
about, not just the first one. Hand-tested with a variety of runs,
and with the *myproc.exp test, which is now forced to try to conflict.
* translate.cxx (dump_unwindsym_ctx): Make userspace _stp_module->name's
fully-/-qualified.
* runtime/sym.c (_stp_module_check): Check all and only kernel-space
build-ids. Filter by _stp_module->name.
(stp_kmodule_check, stp_usermodule_check): WARN_ON wrong-polarity
incoming module/path name.
* testsuite/.../unprivileged_myproc.exp: Run 'modprobe loop'
Jonathan Lebon [Mon, 28 Apr 2014 21:00:39 +0000 (17:00 -0400)]
unprivileged_myproc.exp: only KFAIL .callee(string)
This is a followup to the followup commit 9d4241d. The .callees and
.callees(number) probes will always work because they will match ibar().
Only the .callee(string), which is turned to .callee("tbar"), should be
KFAILed, since it will definitely fail for GCC < 4.7.
Jonathan Lebon [Mon, 28 Apr 2014 20:24:32 +0000 (16:24 -0400)]
unprivileged_myproc.exp: adjust loop.c
The process("./loop").function("ibar").inline probe was failing in this
test because of a bug in GCC (RHBZ1092144). In a nutshell, GCC unrolls
the loop once, resulting in ibar() being called twice: once outside the
loop and once inside. However, only the former gets a corresponding
inlined_subroutine DIE. As a result, the SystemTap probe only fires once
at startup rather than at every iteration.
This patch takes out the if-expression in the loop so that GCC doesn't
need to do any unrolling and we end up with two inlined_subroutine DIEs.
syscall testsuite test.tcl: use staprun -R for reused module
It's been occasionally observed that a single syscall test case can
leave the [nd_]syscall.ko module loaded, which blocks further testing.
staprun -R can rename the .ko, to avoid the chain failure.
runtime rhel6: avoid kernel crash with buildid checks for process(PID#) probes
Crash observed on rhel6 (utrace -> process(NUM).statement(ADDR).absolute probes)
in unprivileged_myproc.exp test case.
* runtime/linux/uprobes-common.c (stap_uprobe_change_plus): Don't try to check
process against _stp_module entry, if we don't even have a process pathname.
* runtime/sym.c (_stp_usermodule_check): WARN_ON incoming null pathname.
Josh Stone [Sat, 26 Apr 2014 00:17:03 +0000 (17:17 -0700)]
tapset: Deal with missing fs in i386/register.stp
Older kernels didn't have fs in pt_regs, so the following _reg_offsets
were incorrect. Make fs conditional on stapconf, and use a counter to
more easily keep track of the differences.
Josh Stone [Sat, 26 Apr 2014 00:12:18 +0000 (17:12 -0700)]
runtime: Fix synthesized regs on ix86
The ix86 register names and offsets in the inline asm of
arch_unw_init_frame_info are now fixed, including stapconf to deal with
fs/xfs/gs changes over time.
x86_64 is updated to match the same style of access.
Josh Stone [Fri, 25 Apr 2014 22:25:10 +0000 (15:25 -0700)]
runtime: Initialize _stp_module_self from THIS_MODULE
By iterating the sections of THIS_MODULE directly, rather than from
STP_RELOCATION messages, we can more safely contain the eh_frame length
determination. As an upper bound, the length can be no more than the
distance to the next section in memory. Then when we walk fde records,
we can sanity check that the offsets make sense.
syscalls tapset: adapt to absence of uselib(2) syscall
LKML commit 69369a70 made it possible to configure a kernel without
uselib(2) support. Mark these tapset aliases optional so syscall.*
type probing works on !CONFIG_USELIB kernels.
PR6961 cont'd: add a terminating 0x00000000 word to module .ko .eh_frame
This is necessary because now we parse our own module's .eh_frame
lightly at startup time, and must reliably find the end of the
entries. (We don't get the crtend.o goodies from userspace.)
We also reject 8-byte extended-length cases, should they ever come up.
* session.* (op_create_auxiliary): Make possible to designate aux files
as trailers (coming in after the main generated .o file) instead of before.
* buildrun.cxx (compile_pass): Add s.auxiliary_output trailers.
* translate.cxx (emit_symbol_data_done): T-800 returns from the future.
* runtime/sym.c (_stp_kmodule_update_address): Reject 8-byte extended-length
fields in .eh_frame.
Jonathan Lebon [Fri, 25 Apr 2014 19:00:07 +0000 (15:00 -0400)]
statement.exp: adapt for RHEL5
In GCC < 4.4, the decl_line is the line holding the opening brace, not the
line with the identifier. Since the decl_line is the basis for relative
line number statement probes, this discrepancy was causing statement.exp
to have some RELATIVE subtest failures.
Add another empty line so that main@statement.c+4 always falls on an
empty line, regardless of which is the decl_line.
Jonathan Lebon [Fri, 25 Apr 2014 16:01:52 +0000 (12:01 -0400)]
testsuite: adapt to RHEL5
- callee.exp: set as untested if GCC or elfutils too old
- dump_functions.exp: RHEL5 exec doesn't support -ignorestderr
- dump_probe_aliases.exp: ditto
Jonathan Lebon [Fri, 25 Apr 2014 15:53:12 +0000 (11:53 -0400)]
lib/systemtap.exp: get better GCC and elfutils version info
Rather than having the global GCC_Version hold the whole
"gcc --version | head -n 1" string, create a new GCC_FullVersion for
that and make GCC_Version only hold the raw version (e.g. "4.1.2").
This will be useful later on for version comparison.
Create new ELF_Version which holds the elfutils library version against
which SystemTap was compiled.
Jonathan Lebon [Wed, 23 Apr 2014 19:48:37 +0000 (15:48 -0400)]
pr16806.exp: new testcase
- pr16806.exp: new testcase to verify proper tracepoint unregistration
and utrace shutdown.
- loop.c: don't call usleep() if NOSLEEP is defined. This is used by
pr16806.exp, which requires it to make conditions more racy.
- unprivileged_myproc.exp: simplify path to C file.
- unprivileged_probes.exp: ditto.
Josh Stone [Tue, 22 Apr 2014 16:07:42 +0000 (09:07 -0700)]
PR16844: Initial adaptation for kernel 3.15 tracepoints
This hides the tracepoint version adaptations in stp_tracepoint.h. For
older kernel versions, that header is sufficient. With 3.15 we have to
do extra bookkeeping ourselves, so it pulls in stp_tracepoints.c, which
is borrowed almost verbatim from lttng. It seems to work well, but we
can still decide if we want to take a different approach.
David Smith [Tue, 22 Apr 2014 15:32:05 +0000 (10:32 -0500)]
PR16716 partial fix: Better types in 'syscall.{access,faccessat}'.
* tapset/linux/syscalls.stp: Fix 'mode' variable type in
'syscall.{access,faccessat}'.
* tapset/linux/aux_syscall.stp: Convert to use _stp_lookup_or_str().
* testsuite/systemtap.syscall/access.c (main): Add tests.
David Smith [Tue, 22 Apr 2014 13:42:59 +0000 (08:42 -0500)]
PR16716 partial fix: Better types in 'syscall.{swapon,syslog}'.
* tapset/linux/syscalls2.stp: Fix types in 'syscall.syslog' and
'syscall.swapon'. In 'syscall.swapon', decode the flags in the new
'swapflags' variable.
* tapset/linux/nd_syscalls2.stp: In 'nd_syscall.swapon', decode the flags
in the new 'swapflags' variable.
* tapset/linux/aux_syscalls.stp (_swapon_flags_str): New function.
* tapset/uconversions.stp (user_string_n2_quoted): If we're in a compat
task, when printing the pointer value as a number, don't expand it to
64-bits.
* testsuite/systemtap.syscall/swap.c: Added more tests.
* testsuite/systemtap.syscall/syslog.c: New test case.
* testsuite/buildok/syscalls2-detailed.stp: Added new 'swapflags' variable.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
Stan Cox [Tue, 22 Apr 2014 13:37:16 +0000 (09:37 -0400)]
Add python support tapset example.
* systemtap.examples/general/tapset/(python2.stp,python3.stp,python.stpm): Python support tapset
* systemtap.examples/general/(pyexample.meta,pyexample.stp,pyexample.py): Use it.
David Smith [Mon, 21 Apr 2014 18:43:33 +0000 (13:43 -0500)]
PR16716 partial fix: Better types in 'syscall.{getpriority,setpriority}'.
* tapset/linux/syscalls.stp: Fix types in 'syscall.getpriority'.
* tapset/linux/syscalls2.stp: Fix types in 'syscall.setpriority'.
* tapset/linux/aux_syscalls.stp (_priority_which_str): Convert to use
_stp_lookup_str().
* testsuite/systemtap.syscall/getpriority.c: New test case.
* testsuite/systemtap.syscall/setpriority.c: Ditto.
Josh Stone [Fri, 18 Apr 2014 01:14:06 +0000 (18:14 -0700)]
tapset: mark _sched_policy_str() as pure and :string
This was causing issues in any script that pulled in aux_syscalls, but
didn't use _sched_policy_str(). Since it wasn't pure, it couldn't be
elided, and since it wasn't explicitly declared :string, there was no
type deduction to define its STAP_RETVALUE.
Josh Stone [Fri, 18 Apr 2014 00:54:01 +0000 (17:54 -0700)]
testsuite: don't mix -p2 and -l in labels.exp
Since commit bba368c5c5fea, -p2 and -l are exclusive options, even
though internally they are similar.
Furthermore, "labels exe .statement" and "labels so .statement" had this
failure masked, because they were looking for the absence of the error
"semantic error: no match" rather than the presence of actual matches.
Thus the option-validating error didn't trigger failure before.
Josh Stone [Thu, 17 Apr 2014 21:32:40 +0000 (14:32 -0700)]
Prevent lock-recursion in _stp_ctl_send
In rare cases, we may hit a probe while the transport layer is holding a
spinlock, and that probe may call _stp_ctl_send which tries to grab the
same and deadlocks. This is a bit easier to trigger on lockdep-enabled
kernels with the lock_acquired tracepoint.
This patch refactors the context->busy state management into get/put
context, and those areas which grab probe-sensitive locks now wrap
themselves with a context to stay comfortably free of probes.
Tangentially, the dyninst side abandons the busy flag, as it already had
a tls_context pointer to prevent direct recursion and a mutex for
exclusive access across all processes.
DEBUG_REENTRANCY is an unfortunate casualty, because we can't safely
call _stp_warn when the busy context may be from those held locks.
Jonathan Lebon [Thu, 17 Apr 2014 21:34:24 +0000 (17:34 -0400)]
stmt_rel.exp: improve coverage
The testcase previously only tested that specific relative linenos in
bio_init() were valid and that there were at least 3 linenos available
for probing.
We now improve this test by checking that probes listed by the wildcard
lineno are all accessible by relative numbering as well. As a sanity
check, we check that bio_init() has at least 3 linenos available, as
before.
Jonathan Lebon [Thu, 17 Apr 2014 16:21:25 +0000 (12:21 -0400)]
add DWARF_LINE* macros to help diagnosis
Similarly to the previous commit, we modify the new safe_dwarf_line*()
functions so that they carry __FILE__ and __LINE__ information into the
error. This new information is filled in when using the new DWARF_LINE*
macros.
Before:
semantic error: libdw failure (dwarf_lineaddr): no error
After:
semantic error: libdw failure (dwarf_lineaddr): no error
thrown from: ../systemtap/dwflpp.cxx:2242
Jonathan Lebon [Thu, 17 Apr 2014 16:08:00 +0000 (12:08 -0400)]
add DWFL_ASSERT and DWARF_ASSERT to help diagnosis
Semantic errors thrown from dwfl_assert() and dwarf_assert() lacked any
positional information to help track down where the assertion failed. We
create two new macros, DWFL_ASSERT and DWARF_ASSERT, which carry down
the __FILE__ and __LINE__ information so that the semantic_error created
contains that information, which can be printed out using -vv.
Before:
semantic error: libdwfl failure (asserting!): no error
After:
semantic error: libdwfl failure (asserting!): no error
thrown from: ../systemtap/tapsets.cxx:7183
Jonathan Lebon [Wed, 16 Apr 2014 18:02:21 +0000 (14:02 -0400)]
statement.exp: rework and expand
The statement.exp test case previously only tested a few specific cases.
We now introduce a new test program, 'statement.c', on which we can test
for all the things we previously tested, allowing us to remove the other
test programs. Furthermore, we extend coverage to test many other
possible combinations.