Abegail Jakop [Mon, 1 Jun 2015 15:46:34 +0000 (11:46 -0400)]
move the bulk of [task_]ns_* tapsets to helper fns
runtime/linux/namespaces.h: define helper fns to get specific pid or user
information based on the target namespaces. rely on the new runtime
variable _stp_namespace_pid rather than the _STP_NAMESPACE_PID macro
runtime/transport/transport.c: define runtime var _stp_namespace_pid
that will contain the target namespaces pid. default to _stp_pid
if there was no target ns pid specified
tapset/linux/*.stp: replace body of [task_]ns_* tapset functions with a
call to the helper functions in namespaces.h
translate.cxx: remove _STP_NAMESPACE_PID macro definition
Abegail Jakop [Fri, 29 May 2015 15:20:17 +0000 (11:20 -0400)]
add /* guru */ pragma to task_ns_* tapsets
the task_ns_* functions aren't protected from read faults when trying to
access the task struct at the provided address, so we'll add the /* guru */
pragma to hint at how unsafe those functions are.
Abegail Jakop [Tue, 26 May 2015 18:40:35 +0000 (14:40 -0400)]
moved repetitive pid-to-ns chunks into a function
runtime/linux/namespaces.h: get_pid_namespace() and get_user_namespace()
that take in a (int) pid returning a pointer to the namespace.
translate.cxx: include the namespaces.h file, if --runtime=kernel
tapset/linux/*.stp: replace repetitive pid-to-namespace code with new
get_*_namespace()
Abegail Jakop [Mon, 25 May 2015 18:45:08 +0000 (14:45 -0400)]
context_ns.exp: test for pid ns-aware tapset functions
new test case to check that the ns-aware tapset functions are returning
values that match what is expected. currently only implemented for pid
ns tapset functions.
Abegail Jakop [Fri, 22 May 2015 18:10:03 +0000 (14:10 -0400)]
remove ns comparison in [task_]ns_* tapsets
turns out that the functions used to get the ns-specific values in the
new tapsets will return a sufficient error value (0 or uid/guid overflow
value) if the target task/current is not in the target pid/user namespace
Abegail Jakop [Fri, 22 May 2015 18:02:17 +0000 (14:02 -0400)]
use find_pid_ns instead of find_get_pid in [task_]ns_*
in the new namespace-aware tapset functions, we cant use find_get_pid() to
get the pid struct from a target ns pid because it looks for that pid in the
current task's pid ns, when we want it to look in the root pidns. switched
to find_pid_ns() which allows us to specify a pid ns to look in.
Abegail Jakop [Tue, 19 May 2015 18:30:50 +0000 (14:30 -0400)]
buildok test cases for ns-aware tapsets
testsuite/buildok/context-embedded-ns.stp: check that the pid and user
related ns_* tapsets can build.
testsuite/buildok/task_ns.stp: check that the pid and user related
task_ns_* tapsets can build.
testsuite/systemtap.pass1-4/buildok-dyninst.exp: add test cases to
dyinst run's KFAIL list
Abegail Jakop [Fri, 15 May 2015 15:18:01 +0000 (11:18 -0400)]
new namespace-aware tapset functions: [task_]ns_*
context.stp: new tapset functions ns_[pid|tid|ppid|pgrp|sid] for pid
namespaces. ns_[e][g|u]id functions for user namespaces. the returned
value with be relative to either the --target-namespaces=PID or the stap
process' pid or user namespace.
task.stp: task_ns_* (and others) functions to be the namespace-aware
counterparts to the original task_* functions. the new functions will
return a value relative to the target-namespaces=PID or stap process'
namespaces.
Abegail Jakop [Tue, 19 May 2015 15:54:31 +0000 (11:54 -0400)]
new option: --target-namespaces=PID
added a new option to specify a set of target namespaces based on a pid.
this will be used with upcoming namespace-aware tapsets, which will
rely on that target namespaces in order to provide relevant information.
David Smith [Wed, 10 Jun 2015 17:38:52 +0000 (12:38 -0500)]
Fixed PR18461 by updating the netfilter code for linux 4.1.
* tapset-netfilter.cxx (emit_module_decls): Add support for new linux 4.1
netfilter changes.
* buildrun.cxx (compile_pass): Add new netfilter autoconf test.
* runtime/linux/autoconf-netfilter-4_1.c: New autoconf test.
Martin Cermak [Tue, 9 Jun 2015 07:47:01 +0000 (09:47 +0200)]
PR18492: Add tapset support and test coverage for sched_{get,set}attr
* tapset/linux/aux_syscalls.stp: New function _struct_sched_attr_u()
* tapset/linux/nd_syscalls2.stp: New probes nd_syscall.sched_{g,s}etattr
* tapset/linux/syscalls2.stp: New probes syscall.sched_{g,s}etattr
* testsuite/buildok/aux_syscalls-embedded.stp: New subtest
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto
* testsuite/buildok/syscalls2-detailed.stp: Ditto
* testsuite/systemtap.syscall/sched_attr.c: New testcase
Martin Cermak [Tue, 9 Jun 2015 06:32:41 +0000 (08:32 +0200)]
PR18501: Add tapset support and test coverage for the kcmp syscall
* tapset/linux/aux_syscalls.stp: New function _kcmp_type_str()
* tapset/linux/nd_syscalls.stp: New probe nd_syscall.kcmp
* tapset/linux/syscalls.stp: New probe syscall.kcmp
* testsuite/buildok/aux_syscalls-embedded.stp: New subtest
* testsuite/buildok/nd_syscalls-detailed.stp: Ditto
* testsuite/buildok/syscalls-detailed.stp: Ditto
* testsuite/systemtap.syscall/kcmp.c: New testcase
William Cohen [Fri, 29 May 2015 19:50:22 +0000 (15:50 -0400)]
Use a value for bad syscall that works better on 32-bit ARM
On 32-bit ARM the use of -1 for the syscall number for the bad syscall
in the utrace_syscall_args test will result in a kernel oops on some
kernels and the use other negative numbers will result in illegal
instruction exceptions. Changing the bad syscall to use a large
positive number for the bad syscall to allow this test to work better
on 32-bit arm.
Frank Ch. Eigler [Tue, 26 May 2015 23:01:33 +0000 (19:01 -0400)]
netfilter/ip tapset: add "kernel<foo.h>" for all @cast()'s
It is preferable to generate typing debuginfo for tapsets from headers
if possible, rather than require kernel-debuginfo. This corrects the
buildok/netfilter-glob.stp test case on f21.
This is because ppc64le is not added to arch list in systemtap.exp .
cmd_parse.exp also fails with similar error for arch. Modifying the
code for ppc64le.
Jonathan Lebon [Thu, 14 May 2015 14:29:50 +0000 (10:29 -0400)]
make from_glob a per-component field rather than per-pp
The original need for from_glob in probe_point was to distinguish
"specified" probe points from those that were still generic/globby. E.g.
so that we know to make function suggestions for
process("/usr/bin/ls").function("bad_func") but not yet for
process("/usr/bin/l*").function("bad_func").
The issue however is that there is no distinction between which
component is from a globby one. E.g. if we have
process("/usr/bin/l*").library("libc").function("bad_func"), which
becomes process("/usr/bin/ls").library("libc").function("bad_func"), we
won't know while resolving the library whether from_glob is true because
the process was globby or because the library was globby.
Thus, the 'from_globbiness' is a property of the component, not the
whole probe point. In this commit, we make from_glob instead a member of
probe_point::component. We then add a from_globby_comp() function which
can be used to determine if a specific component was derived from a
globby one.
Martin Cermak [Wed, 13 May 2015 15:06:34 +0000 (17:06 +0200)]
PR18398: Tapset support for {get,set}_thread_area syscalls
* tapset/linux/i386/aux_syscalls.stp: New function _struct_user_desc_u()
* tapset/linux/i386/nd_syscalls.stp: Decode struct user_desc
* tapset/linux/i386/syscalls.stp: Ditto
* tapset/linux/x86_64/aux_syscalls.stp: New function _struct_user_desc_u()
* tapset/linux/x86_64/nd_syscalls.stp: New probes nd_syscall.{get,set}_thread_area
* tapset/linux/x86_64/syscalls.stp: New probes syscall.{get,set}_thread_area
* testsuite/buildok/nd_syscalls-arch-detailed.stp: New subtests
* testsuite/buildok/syscalls-arch-detailed.stp: New subtests
* testsuite/systemtap.syscall/thread_area.c: New testcase
Martin Cermak [Tue, 28 Apr 2015 16:23:24 +0000 (18:23 +0200)]
PR18343: New tapset handling the clock_adjtime syscall
* tapset/linux/nd_syscalls.stp: New nd_syscall.clock_adjtime
* tapset/linux/syscalls.stp: New syscall.clock_adjtime
* testsuite/buildok/nd_syscalls-detailed.stp: Test script level vars
* testsuite/buildok/syscalls-detailed.stp: Likewise
* testsuite/systemtap.syscall/clock.c: Syscall test coverage
Martin Cermak [Tue, 28 Apr 2015 04:45:02 +0000 (06:45 +0200)]
PR18337: Test coverage improvements, tapset extension.
* tapset/linux/aux_syscalls.stp: New auxiliary function _kexec_flags_str()
* tapset/linux/nd_syscalls.stp: Fix types and nesting for kexec_load
* tapset/linux/syscalls.stp: Likewise
* testsuite/buildok/nd_syscalls-detailed.stp: Test the flags_str variable
* testsuite/buildok/syscalls-detailed.stp: Likewise
* testsuite/systemtap.syscall/kexec_load.c: New testcase
* testsuite/systemtap.syscall/set_tid_address.c: New testcase
David Smith [Mon, 27 Apr 2015 18:21:50 +0000 (13:21 -0500)]
Fix PR17986 by updating the unprivileged_probes.exp test case.
* testsuite/systemtap.unprivileged/unprivileged_probes.exp: Run the loop
executable in the background so that all 'process(number)' probes get a
valid pid.
* testsuite/systemtap.unprivileged/foo.c: Deleted unused file.
* testsuite/systemtap.unprivileged/libfoo.c: Ditto.
Mark Wielaard [Fri, 24 Apr 2015 17:59:32 +0000 (19:59 +0200)]
Filter out descriptor/SHN_UNDEF symbols in symbol_table::lookup_symbol.
With newer elfutils (>= 0.158) function descriptor symbols get resolved
to their actual function entry address. With older elfutils we mark such
symbols as descriptor through reject_section (because their address will
match the .opd). Filter these symbols out in symbol_table::lookup_symbol
and symbol_table::lookup_symbol_address. None of the callers want these
SHN_UNDEF/descriptor symbol (addresses).
This solves another instance of Multiple 'sys_ni_syscall' symbols found
warning on ppc64[be] with older elfutils.
Inspired by wcohen's speculate.stp tapset/testcase and cibegttd@irc's
needs, this script prints a statement-execution trace for a given
function, but only for those runs of the function that ended up with a
(configurable) post-return condition. It turns out to be a neat
multipurpose widget, for random-sampled function tracing as well as
failure analysis.
Previous code had imperfect heuristics about cutting apart parts of
erroneous source lines, with a colorized token in the middle. It
could occur that the token was synthetic, or cmd-line $/@ based,
in which case the srcline-cutting arithmetic could go off-end and
cause a basic_string::substr: exception. New code dabbles less in
heuristics and confirms that the token content actually matches
the srcline content. In case of a mismatch, the original srcline
around the token's location is transcribed verbatim (with ellipses).
Mark Wielaard [Thu, 23 Apr 2015 13:59:49 +0000 (15:59 +0200)]
ppc64le doesn't have function descriptors. Remove __powerpc__ in tapsets.cxx.
Only process the opd section and do function descriptor mangling when
the target is ppc64 ELFv1 ABI. Also filter out any duplicate func_infos.
When seeing a symbol with a name starting with '.' we assume it is a
regular function pointer and not a pointer to a function descriptor and
mangle its name. That might create duplicates if there is also a function
descriptor with that name (the address will already have been resolved to
the same address).
tapsets.cxx: fix symbol/address lookup returned-data to sets passed by value
The symbol_table lookup_symbol[_address] functions are safer if they
return their result-sets by value rather than by pointer. The latter
in specific should be a set rather than a list, to properly eliminate
duplicates.
Martin Cermak [Wed, 22 Apr 2015 17:43:02 +0000 (19:43 +0200)]
PR18293: Test coverage improvements, tapset extension.
* tapset/linux/aux_syscalls.stp: Add auxiliary functions for times and sysinfo.
* tapset/linux/nd_syscalls2.stp: Extend argstr for sysinfo and times.
* tapset/linux/syscalls2.stp: Likewise.
* testsuite/buildok/nd_syscalls2-detailed.stp: New convenience var for times syscall.
* testsuite/buildok/syscalls2-detailed.stp: Likewise for nd_syscall.times.
* testsuite/systemtap.syscall/clock.c: Addo coverage for stime syscall.
* testsuite/systemtap.syscall/syncfs.c: Extend and fix the testcase.
* testsuite/systemtap.syscall/sysctl.c: New testcase.
* testsuite/systemtap.syscall/sysinfo.c: Likewise.
* testsuite/systemtap.syscall/times.c: Likewise.
* testsuite/systemtap.syscall/unshare.c: Likewise.
PPC64 ELF ABI v2 has a Global entry point and a local entry point
for the functions. We need the Local entry point in order to probe
these functions. However, the DIE for these functions in debuginfo
return the function.entrypc which is same as the global entry point.
The local entry point is not encoded in the debuginfo of the ELFs. The
offset to local entry point is however encoded in the st_other field
of these symbols in the symbol table.
We need to use this field to adjust the sym.st_value to actually point
to the local entry point instead of the global entry point.
This patch is in relation to this bug :
https://sourceware.org/bugzilla/show_bug.cgi?id=17638
So, while adding symbols to the sym_table, we add an offset of
PPC64_LOCAL_ENTRY_OFFSET(sym.st_other) to st_value.
And when the function address is queried in query_dwarf_func(), we give
priority to the cached sym_table, where we can retrieve the adjusted
entry address of the function. If we don't get any address from the
symbol table, then we proceed to get from the debuginfo.
Macro definition PPC64_LOCAL_ENTRY_OFFSET has been picked up from glibc.
It won't be defined if we are building systemtap on a machine having
older elf.h and hence, won't recognize PPC64_LOCAL_ENTRY_OFFSET.
Test dwarfless probes on multiple static functions
This patch checks how many symbols were resolved instead of probing on
them which won't require us to go till pass 5. It runs the .stp script
till pass 2. This test can be run with:
make check RUNTESTFLAGS=multisym.exp
systemtap/tapsets.cxx: Fix dwarfless probes on multiple static functions
With multiple static functions with same names in an ELF and in absence
of dwarf, if we probe on one of the functions, then systemtap places
probe only on one static function ignoring the rest. This is because the
mapping between the symbol names and their func_info is a simple map
which doesn't allow insertion of another symbol with the same name.
This patch fixes this issue by changing this map to a multimap which
allows duplicate entries for the same symbol name. lookup_symbol code
will return a set of func_info * instead of a single descriptor for a
function name.
We also need to fix other areas in the code where lookup_symbol() and
lookup_symbol_address() are being called so as to look for a set of
func_info's and a list of Dwarf_Addr's respectively, instead of a single
descriptor.
David Smith [Mon, 20 Apr 2015 21:33:55 +0000 (16:33 -0500)]
Fix PR18264 by adding support for the {name_to,open_by}_handle_at syscalls.
* tapset/linux/syscalls2.stp: Add new 'name_to_handle_at' and
'open_by_handle_at' probes.
* tapset/linux/nd_syscalls2.stp: Ditto.
* testsuite/buildok/syscalls2-detailed.stp: Add new tests.
* testsuite/systemtap.syscall/handle_at.c: New test case.
David Smith [Mon, 20 Apr 2015 21:28:04 +0000 (16:28 -0500)]
Fix PR18284 by improving support/testing for some rt_* syscalls.
* tapset/linux/syscalls2.stp (rt_sigqueueinfo): Import argstr formatting
by decoding siginfo structure.
(rt_sigsuspend): Add argstr formatting of new 'set_uaddr' and
'sigsetsize' convenience variables.
(rt_sigtimedwait): Add s390x fix and decode sigset, siginfo, and
timespec structures in argstr.
(rt_tgsigqueueinfo): New probe.
* tapset/linux/nd_syscalls2.stp: Ditto.
* tapset/linux/aux_syscalls.stp (_stp_siginfo_u): New function.
(_stp_compat_siginfo_u): Ditto.
* runtime/linux/compat_siginfo.h: New file.
* testsuite/buildok/syscalls2-detailed.stp: Test new syscall probe
features.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
* testsuite/buildok/aux-syscalls-embedded.stp: Add tests for new
functions.
* testsuite/systemtap.syscall/coverage.tcl: Add rt_sigreturn as an
untestable syscall.
* testsuite/systemtap.syscall/rt_signal.c: Improve testing and add testing
for rt_sigsuspend() and rt_tgsigqueueinfo().
David Smith [Tue, 14 Apr 2015 15:30:13 +0000 (10:30 -0500)]
Fixed PR18262 by adding support for the sync_file_range/syncfs syscalls.
* tapset/linux/syscalls2.stp: Add support for 'sync_file_range' and
'syncfs'.
* tapset/linux/nd_syscalls2.stp: Ditto.
* tapset/linux/aux_syscalls.stp (_sync_file_range_flags_str): New function.
* tapset/arm/registers.stp (_stp_arg): Allow argument 7 to be fetched.
* testsuite/systemtap.syscall/sync_file_range.c: New test case.
* testsuite/systemtap.syscall/syncfs.c: Ditto.
* testsuite/buildok/syscalls2-detailed.stp: Added build test cases for
'sync_file_range' and 'syncfs'.
* testsuite/buildok/nd_syscalls2-detailed.stp: Ditto.
* testsuite/buildok/aux_syscalls-embedded.stp: Added build test case for
_sync_file_range_flags_str().
RHBZ1121363: make dracut module directory configurable
The place where dracut loads modules for the "service systemtap onboot ..."
facility is fixed, but we want its subdirectory to be configurable,
so that different stap installations can avoid stepping on each other.
So now "configure --with-dracutstap=DRACUT_D/MODULEDIR" is available.
David Smith [Fri, 10 Apr 2015 16:06:09 +0000 (11:06 -0500)]
Fix PR13481 by handling arguments passed on the arm stack.
* tapset/arm/registers.stp (_stp_get_stack_nth): New function to get
arguments from the stack.
(_stp_arg): Add support for getting arguments 5 and 6.
(longlong_arg): Adjust argument numbers when needed.
* tapset/linux/nd_syscalls2.stp (nd_syscall.readahead): Add fix for arm.
Mark Wielaard [Fri, 10 Apr 2015 15:53:08 +0000 (17:53 +0200)]
Add fallback to line table and low_pc for function source file/line.
Some DWARF producers (golang) don't emit any decl_file/line/col information.
For function DIEs we can sometimes still retrieve that information based on
the low_pc address the debug line table. Add a new fallback function
dwflpp::pc_line that returns file/line/col information based on pc address
in the current CU.
Mark Wielaard [Fri, 10 Apr 2015 13:09:31 +0000 (15:09 +0200)]
Improve dwflpp::loc2c_error semantic error.
When the dwflpp::loc2c callback was called from loc2c.c code on failure
to translate a location to a C expression we would loose all context.
Keep track of the pc location and context DIE we are trying to translate
so we can add more details to the error message shown to the user.
Mark Wielaard [Thu, 9 Apr 2015 20:17:21 +0000 (22:17 +0200)]
PR17958 escape DWARF names that aren't C identifier strings.
Some language compilers (golang) might output DWARF names that are not
valid C identifier strings. Provide a escaped_indentifier_string ()
function to turn those into valid C identifier strings so the generated
C code compiles cleanly.
Mark Wielaard [Thu, 9 Apr 2015 14:51:56 +0000 (16:51 +0200)]
PR17959 Allow size-less pointer types.
golang might produce a DW_TAG_pointer_type without any size. Assume
the size of the pointer is equal to the address size of the DWARF CU
in that case. Otherwise we might try to create values of type uint0_t.