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.
William Cohen [Thu, 9 Apr 2015 14:20:50 +0000 (10:20 -0400)]
Add a definition of _stp_syscall_get_nr for arm64
Commit 07cecda4dc to fix the syscall_get_nr for 32-bit arm exposed that
there wasn't a definition of _stp_syscall_get_nr for arm64. This adds
the needed definition for arm64.
Mark Wielaard [Thu, 9 Apr 2015 13:44:26 +0000 (15:44 +0200)]
PR17957 Allow "raw" DW_OP_call_frame_cfa in location expressions.
golang will produce DW_OP_call_frame_cfa; DW_OP_consts: 8; DW_OP_plus
location expressions instead of a simple DW_OP_fbreg 8. It will also not
set DW_AT_frame_base, so the frame base/call frame address isn't really
known.
Accept that pattern by signalling we need the frame base in loc2c.c
translate () if we see any DW_OP_call_frame_cfa and just push the
frame_base onto the expression stack. And in location_from_address ()
assume that if no DW_AT_frame_base is given it was implicitly defined
with an DW_OP_call_frame_cfa (so we'll use the CFA as calculated by the
CFI to define the frame base).
David Smith [Wed, 8 Apr 2015 17:01:10 +0000 (12:01 -0500)]
Fixed PR18213 by fixing getting the syscall number on arm kernels.
* runtime/syscall.h: For arm, use our own syscall_get_nr(), since the
kernel supplied one doesn't work well. Rename all uses of
syscall_get_nr() to _stp_syscall_get_nr().
* runtime/linux/task_finder.c: Rename all uses of syscall_get_nr() to
_stp_syscall_get_nr().
* runtime/linux/task_finder2.c: Ditto.
* tapset/linux/aux_syscalls.stp: Ditto.
* tapset/linux/utrace.stp: Ditto.
* stap-serverd.cxx (get_server_mok_fingerprints): Call stat() if readdir()
returns 'DT_UNKNOWN'. Certain filesystems like XFS don't implement
returning the file type.
* stap-serverd.cxx (mok_dir_valid_p): Call stat() if readdir() returns
'DT_UNKNOWN'. Certain filesystems like XFS don't implement returning the
file type.
David Smith [Wed, 1 Apr 2015 15:38:07 +0000 (10:38 -0500)]
Added several small syscall tapset/testsuite fixes.
* tapset/linux/syscalls.stp: Fixed syscall.execveat and added a fix for
arm in syscall.fadvise64.
* tapset/linux/nd_syscalls.stp: Added a fix for arm in
nd_syscall.fadvise64.
* tapset/linux/x86_64/syscalls.stp: Fixed syscall.compat_execve.
* testsuite/systemtap.syscall/getrlimit.c: Updated COVERAGE comment.
* testsuite/systemtap.syscall/syscall.exp: Minor test output
improvement.
* testsuite/systemtap.syscall/nd_syscall.exp: Ditto.
* testsuite/systemtap.syscall/uname.c: New testcase.
Lukas Berk [Mon, 30 Mar 2015 12:20:09 +0000 (08:20 -0400)]
Changed spin-rawhide git-description to match fedora package guidelines
Prerelease snapshots require a YYYYMMDDgit<hash> style release version according
to fedora package guidelines. Changing spin-rawhide to produce the same
As a tool to help diagnose suspected kernel kprobes/uprobes
problems, this script may be helpful to generate "perf probe ..."
command lines from a stap script or probe pattern.
Frank Ch. Eigler [Thu, 26 Mar 2015 20:21:06 +0000 (16:21 -0400)]
numerous small coverity fixes
A mixture of stuff noted for stap 2.7, like missing rc checks, c++ POD
member initialization, @perf() array checks. No actual bugs appear in
this batch, but it should make coverity happier in the future.
Frank Ch. Eigler [Thu, 26 Mar 2015 20:20:09 +0000 (16:20 -0400)]
testsuite: split additional_scripts.exp at installtest_p point
Some of the tests require stap -p5; segregate those at the bottom,
protected by [installtest_p], so the rest of the test still runs &
passes at "make check".
Abegail Jakop [Thu, 19 Mar 2015 15:36:15 +0000 (11:36 -0400)]
remove need for xvfb to generate beginners guide
using xvfb was for a workaround to an issue with publican mentioned
in BZ920216. since the beginners guide docs are generated using xmlto
instead of publican, no longer need the to check for xvfb
Abegail Jakop [Wed, 18 Mar 2015 13:49:00 +0000 (09:49 -0400)]
limit content in beginners guide to generic info
*.xml : remove content where the content is specific to either fedora or
rhel.
*html.xsl: include a title between the nav buttons at the top of the page
Abegail Jakop [Tue, 17 Mar 2015 16:31:02 +0000 (12:31 -0400)]
generate beginners guide with xmlto instead of publican
the beginners guide is generated when --enable-docs is specified and
xmlto is found.
configure.ac: remove publican specific variables and code chunks, since
the beginners guide docs were the last to use publican. create a new
variable to check if xmlto is available.
doc/beginners/Makefile.am: change the requirement from publican to
xmlto. replace the publican commands for generating the html and pdf
docs to xmlto commands.
systemtap.spec: remove publican requirement
Abegail Jakop [Tue, 17 Mar 2015 16:21:22 +0000 (12:21 -0400)]
add images, css and xsl files for beginners guide
*/Common_Content: contains images, css and a few xml files for
generating html and pdf files of the beginners guide using xmlto
*/xsl: contains stylesheets for generating html and pdf files of the
beginners guide using xmlto
David Smith [Fri, 20 Mar 2015 15:45:53 +0000 (10:45 -0500)]
Fix PR18143 by updating tapset/linux/target_set.stp.
* tapset/linux/target_set.stp: Since [nd_]syscall.fork got split into
the [nd_]syscall.{fork,vfork,clone} probes, update the tapset to handle
all 3 probes. Otherwise, we miss clone()/vfork() calls on systems that
don't support process.{begin,end}.
David Smith [Thu, 19 Mar 2015 21:24:33 +0000 (16:24 -0500)]
Adjust fix to PR18122 by displaying the number of environment variables.
* tapset/linux/aux_syscalls.stp (__count_envp): New function.
(__count_compat_envp): Ditto.
* tapset/linux/syscalls.stp: Changed execve, compat_execve, execveat, and
compat_execveat probes to use new __count_envp/__count_compat_envp
functions to display the number of environment variables (instead of
displaying the actual environment variables). Displaying the actual
environment variables can easily overflow MAXSTRINGLEN and doesn't match
what strace does.
* tapset/linux/nd_syscalls.stp: Ditto.
* tapset/linux/i386/nd_syscalls.stp: Ditto.
* tapset/linux/i386/syscalls.stp: Ditto.
* tapset/linux/ia64/nd_syscalls.stp: Ditto.
* tapset/linux/ia64/syscalls.stp: Ditto.
* tapset/linux/powerpc/nd_syscalls.stp: Ditto.
* tapset/linux/powerpc/syscalls.stp: Ditto.
* tapset/linux/s390/nd_syscalls.stp: Ditto.
* tapset/linux/s390/syscalls.stp: Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.
* tapset/linux/x86_64/syscalls.stp: Ditto.
* testsuite/buildok/aux_syscalls-embedded.stp: Added test for new functions.
* testsuite/systemtap.syscall/execve.c: Adjusted regexps for new output.
* testsuite/systemtap.syscall/execveat.c: Ditto.
David Smith [Thu, 19 Mar 2015 17:50:31 +0000 (12:50 -0500)]
Add more syscall testsuite test program fixes.
* testsuite/systemtap.syscall/accept4.c: Test on more systems.
* testsuite/systemtap.syscall/adjtimex.c: Be more forgiving with return
values.
* testsuite/systemtap.syscall/clone.c: Fix gcc 5 problems.
David Smith [Thu, 19 Mar 2015 17:20:20 +0000 (12:20 -0500)]
Fix PR18122 by fixing/updating [nd_]syscall.{execve,execveat}.
* NEWS: Mention deprecation of the 'fd' and 'fd_str' variables in the
[nd_]syscall.execveat probes.
* tapset/linux/syscalls.stp (syscall.execve): Add 'env_str' convenience
variable for the list of environment variables. For kernels < 3.7, move
execve tapset support to arch-specific tapset code so we can catch all
calls.
(syscall.compat_execve): Ditto.
(syscall.execveat): Add 'env_str' convenience variable for the list of
environment variables.
(syscall.compat_execveat): Ditto.
* tapset/linux/nd_syscalls.stp: Ditto.
* tapset/linux/aux_syscalls.stp (__get_argv): Improve formatting and
report the difference between an invalid address and a NULL.
(__get_compat_argv): Ditto.
(_adjtimex_return_str): Minor improvement.
* tapset/linux/i386/syscalls.stp: Added execve support for kernels < 3.7.
* tapset/linux/i386/nd_syscalls.stp: Ditto.
* tapset/linux/ia64/syscalls.stp: Ditto.
* tapset/linux/ia64/nd_syscalls.stp: Ditto.
* tapset/linux/powerpc/syscalls.stp: Ditto.
* tapset/linux/powerpc/nd_syscalls.stp: Ditto.
* tapset/linux/s390/syscalls.stp: Ditto.
* tapset/linux/s390/nd_syscalls.stp: Ditto.
* tapset/linux/x86_64/syscalls.stp: Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.
* testsuite/systemtap.syscall/syscall.exp: No longer use '--skip-badvars'
when compiling module.
* testsuite/systemtap.syscall/nd_syscall.exp: Ditto.
* testsuite/buildok/nd_syscalls-detailed.stp: Updated.
* testsuite/buildok/syscalls-detailed.stp: Ditto.
* testsuite/systemtap.syscall/execveat.c: Improved a bit.
* testsuite/systemtap.syscall/execve.c: New test case.
Jonathan Lebon [Sat, 14 Mar 2015 19:38:51 +0000 (15:38 -0400)]
PR18115: use begin probe to initialize conditions
We previously initialized the cond_enabled field by evaluating the
conditions during systemtap_module_init(). However, these conditions may
create tmpvars during unparsing (e.g. maps), which require a context to
operate. Therefore, we instead create a synthetic begin probe which will
serve to initialize all cond_enabled fields (or more precisely, switch
them to 0 from their default of 1 if the condition is false).
As a bonus, this allows us to re-use emit_probe_condition_update() for
both condition initialization and updating, and thus to get rid of
emit_probe_condition_initialize().
Jonathan Lebon [Mon, 16 Mar 2015 16:05:38 +0000 (12:05 -0400)]
PR18115: make c_tmpcounter visit probe conditions
Probe conditions may require tmpvars when being unparsed (e.g. maps).
These tmpvars need to be accounted by the tmpcounter so that tmpvar
declaration and usage match up.
Josh Stone [Mon, 2 Mar 2015 23:18:37 +0000 (15:18 -0800)]
tapset: tag many inline embedded-C blocks as pure
If embedded-C is not explicitly marked pure, then it is assumed to have
side effects, and can never be optimized away. In many cases, we're
simply referencing a constant value, so this is certainly pure, and
should be tagged so.
This patch doesn't bother updating instances that are in impure contexts
anyway, like the many cases of @__syscall_gate et al. which test the
constant to perhaps issue probe "next".
Josh Stone [Mon, 2 Mar 2015 21:06:06 +0000 (13:06 -0800)]
tapset/linux: Introduce and use @task macro
The @task macro performs the very common @cast to a task_struct.
The embedded-C bodies of task_current() and pid2task() are now wrapped
by @task, which gives them a debuginfo type on the return value. With
autocast type propagation, this removes the need for any explicit @cast
in many places.
Other places which take untyped task pointers as parameters, for
instance, now use @task as well to simplify their code.
Tangentially related, task_start_time() was broken for a while by the
change of real_start_time from timespec to u64, commit 57e0be041d9e2.
This is fixed and added to buildok/task_test.stp.
Abegail Jakop [Mon, 2 Mar 2015 16:13:21 +0000 (11:13 -0500)]
PR10488: add proctop.stp example script
proctop.stp: a top-like script that periodically prints out process
information such as state, mem usage and time, while keeping track of
processes that exited while the script was running.
Jonathan Lebon [Mon, 23 Feb 2015 16:10:03 +0000 (11:10 -0500)]
stmt_rel.exp and vars.exp: adapt to latest kernel
The bio.c file was moved from the fs directory to the block directory.
The two test cases stmt_rel.exp and vars.exp used functions from that
file to make some sanity checks. Update the testcases to be more
flexible.
Jonathan Lebon [Fri, 20 Feb 2015 18:24:18 +0000 (13:24 -0500)]
nearest probes: allow ENUMERATED and WILDCARD linenos
This commit reverses commit 2ff2868 which added the restriction of only
allowing .nearest probes on ABSOLUTE and RELATIVE linenos. We now allow
this for all lineno types.
WILDCARD lineno types do not need any special handling for .nearest
probes since the resulting linenos are already known to be correct. For
ENUMERATED linenos however, we now must add .nearest handling: for each
lineno enumerated, if we fail to find an address, we check if there is a
nearby lineno we can instead probe.
This commit also fixes failures in the unprivileged_myproc.exp testcase.
Related PRs: PR17906, PR17986.
Abegail Jakop [Wed, 25 Feb 2015 21:48:30 +0000 (16:48 -0500)]
PR16974: wrap if, try and for tmpvar decls in unions
translate.cxx: in c_tmpcounter::visit_block, the tmpvar declarations
in the generated c code are wrapped in a union, with each
block->statements[i] wrapped in a struct, to reduce context memory
allocation. following ::visit_block, the tmpvar declarations in
::visit_if_statement, ::visit_try_block and ::visit_for_loop are
wrapped in a union. since this causes quite a lot of nesting, comments
are added to the generated c code to indicate the source file and
line the struct/union tmpvars correspond to.
Abegail Jakop [Wed, 25 Feb 2015 21:32:17 +0000 (16:32 -0500)]
PR16974: move struct+visit outputting to new fn(s)
translate.cxx: from c_tmpcounter::visit_block(), move the portion
to wrap the statement->visit() part in a struct declaration to a
function, ::wrap_visit_in_struct()