PR27934: give fuller diagnosis for pass-5 probe-registration errors
While we cannot solve or prevent runtime probe registration errors, we
can help users understand them. Add a new warning::pass5 man page,
and point registration error messages at it.
PR27820 tapset/bpf/logging.stp: implement abort() tapset function
A more obsessively accurate implementation would add a check
equivalent to if (c->aborted) to the start of each probe,
but it would be an imperfect solution in any case.
PR27820 tapset/bpf/logging.stp: move bpf versions of functions
Follows the same scheme as what I instituted earlier for the
uconversions.stp tapsets: toplevel has functions common to
all 3 backends or common to lkm+dyninst (guarded by a
runtime != "bpf" conditional). BPF implementations are
moved to tapset/bpf.
* tapset/bpf/logging.stp: New file.
* logging.stp: Move bpf versions of functions.
Sultan Alsawaf [Mon, 12 Jul 2021 20:31:36 +0000 (15:31 -0500)]
task_finder_vma: add autoconf check for hlist_add_tail_rcu()
The 3.10 version check for hlist_add_tail_rcu() only works for RHEL
kernels. Kernels older than 4.7 that lack the hlist_add_tail_rcu() backport
won't compile (such as Debian kernels). Add an autoconf stub to know for
certain if hlist_add_tail_rcu() is present.
Sultan Alsawaf [Mon, 12 Jul 2021 20:01:57 +0000 (16:01 -0400)]
Don't fail vma tracking mmap callback if module is already known.
An -EEXIST returned by stap_add_vma_map_info() just indicates that the
module is currently in stap's vma cache; it isn't a real issue. Calling
_stp_error() when this occurs causes stap to exit when there isn't a
real bug. Ignore the -EEXIST error to avoid breakage.
William Cohen [Tue, 6 Jul 2021 02:56:09 +0000 (22:56 -0400)]
Update list of reasons for latencytap.stp example
Backtraces change over time. Added additional function names to
monitor in the backtrace and map to reasons. This should reduce the
number of lines with blank reasons when using newer Linux kernels.
rhbz1972805: add basic syscall-in-ptregs support for s390x
Akin to commit 7be7af0fda36 for ARM, add basic syscalls via
tracepoints / CONTEXT->sregs support for s390x. The argno=6 case is
funny because for syscalls they travel in registers, whereas normally
they hop onto the stack.
Frank Ch. Eigler [Thu, 24 Jun 2021 17:30:38 +0000 (13:30 -0400)]
rhbz1972828: tapsets: iommu tracepoints
Disable detection of intel-iommu tracepoint family on non-x86
platforms, because the 5.13ish kernel headers for this tracepoint
include references to functions like clcache_flush_range which don't
exist on all non-x86.
Stan Cox [Thu, 3 Jun 2021 21:19:49 +0000 (17:19 -0400)]
Get the enumerator's enumeration type
Enumeration values are ultimately treated as constants but the path:
literal_stmt_for_local -> find_variable_and_frame_base (-> dwarf_get_enum)
-> translate_final_fetch_or_store often assume there is a
type die. Have dwarf_get_enum also get the type from the enumeration
type and percolate it along.
Sevan Janiyan [Wed, 2 Jun 2021 18:55:53 +0000 (14:55 -0400)]
testsuite/systemtap.base/perf.sh drop bashism
You don't need to use == to check for equality in a test statement, a
single equals sign is sufficient. The use of double equals sign is a
bashism which doesn't always translate as intended on other shells.
[fche checked other scripts in the source tree that used [ == ]; they
are all marked /bin/bash so can stay as is.]
Frank Ch. Eigler [Sun, 23 May 2021 18:12:32 +0000 (14:12 -0400)]
stap-prep: switch to using main vmlinuz file as debuginfod test download
Using the vdso* files only as the debuginfod tests gives us false
positives on platforms where the install vmlinuz files cannot be used
as a basis for debuginfod queries, because they're not elf nor
compressed-elf. This new stap-prep tries to download the vmlinuz
debuginfo itself. It's large, but at least once it's here, it's here!
And if it fails (as it will on those few platforms), the user is
advised to do full platform package-manager debuginfo download.
Timm Bäder [Wed, 19 May 2021 20:38:30 +0000 (16:38 -0400)]
Fix -Woverloaded-virtual warnings when building with clang
Satisfy clang by removing option for non-nested signature printing from
implementations of printsig and declare derived_probe::printsig with 'override'.
Add function derived_probe::printsig_nonest to perform non-nested signature
printing.
Timm Bäder [Wed, 19 May 2021 20:28:29 +0000 (16:28 -0400)]
Add missing copy constructors to set1_ref and set1_const_ref
Clang complains about the missing copy constructors if a user-defined
copy assignment operator exists, e.g.:
./bpf-bitset.h:108:19: error: definition of implicit copy constructor for 'set1_const_ref' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
set1_const_ref& operator= (const set1_const_ref &); // not present
^
./bpf-bitset.h:256:12: note: in implicit copy constructor for 'bpf::bitset::set1_const_ref' first required here
return set1_const_ref(data + w2 * i, w2);
Timm Bäder [Wed, 19 May 2021 20:23:06 +0000 (16:23 -0400)]
util.cxx: Use abs() instead of labs()
Taking the absolute value of unsigned values is pointless, as reported
by clang:
util.cxx:1545:28: error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
unsigned min_score = labs(target.size() - it->size());
^
util.cxx:1545:28: note: remove the call to 'labs' since unsigned values cannot be negative
unsigned min_score = labs(target.size() - it->size());
Frank Ch. Eigler [Wed, 19 May 2021 01:03:17 +0000 (21:03 -0400)]
systemtap.spec: python3 tweaks
Embrace build configurations where python3 is not installed by
default, so needs an explicit BuildRequires; also ones where
python3-probes are not built, ergo stap-exporter isn't packaged.
(The latter is automake-conditionalized on the wrong parameter,
HAVE_PYTHON3_PROBES rather than HAVE_PYTHON3, but this doesn't
matter on normal distro builds.)
use long-lived debuginfod_client handle for buildid based probes
New elfutils is more efficient if reusing debuginfod_client*
handles. Save them in a static unique_ptr<>.
In the corresponding testsuite, stop using -d :memory: for the
temporary debuginfod instance. That's becuase that doesn't work since
elfutils commit 6362941714548d93a3, which uses two concurrent sqlite
database connections. The :memory: syntax causes creation of distinct
databases.
William Cohen [Wed, 5 May 2021 13:49:22 +0000 (09:49 -0400)]
Use the skb_frag_size accessor function rather than directly reading field
There have been changes in the skb_frag_t struct. In newer kernels the
size field no longer exists. Rather than trying to determine the name
of the field the __skb_frag_size tapset function now uses the
skb_frag_size accessor function instead. This function has been in
kernels since 2011 and has been in RHEL kernels since RHEL6.
William Cohen [Tue, 4 May 2021 21:56:27 +0000 (17:56 -0400)]
Further tweak deviceseeks.stp example to work on Fedora 32/33/34
The previous fix for Fedora rawhide Linux kernels (5.12) did not work
on earlier Linux 5.11 kernels in Fedora 32/33/34 because struct bio
has a different field, bd_disk that has a pointer to the queue.
Separated the process for getting the sector size into two steps:
-find the request queue struct
-find the sector size for the device
This script has been tested on RHEL8, Fedora 34, and Fedora Rawhide.
The update_visitor dtor has had an assert() for its value-stack
being empty by the time of its execution. But some combinations
of errors (exceptions being thrown & caught), this assertion could
fire and those diagnostics hidden. So we now ditch the assert()
and leave behind exceptions and other optimistic cleanup.
William Cohen [Fri, 30 Apr 2021 19:17:16 +0000 (15:17 -0400)]
Adjust deviceseeks.stp to work with newer kernels
Newer kernels do not provides the queue parameter ($q) for the
block_bio_queue tracepoint used by ioblock_trace.request. Based on
the suggestion by Jeff Moyer added an alternative way to get queue and
extract the sector size information required for this script.
PR27802: tweak configure.ac for AC_SUBST(pkglibdir)
autoconf is such a hassle for getting expanded path names for the
--FOOdir=BAR names. During execution of the configure script, they
may be defined to be expressions with literal $values in them, which
need to be eval'd with other $values preset. What a mess. Tweak the
sequence used to predict the $pkglibexecdir through heuristics to get
around all this indirection. (e.g. /usr/libexec/systemtap), whether
or not --libexecdir= is given.
William Cohen [Wed, 28 Apr 2021 19:23:01 +0000 (15:23 -0400)]
Correct ucontext.stp umodname function call to _stp_umod_lookup
The runtime _stp_umod_lookup function had an additional offset parameter
added in git commit d1b554876c68f313ec371dbf52c4bddde7bbe10e. That
patch updated the runtime uses of the function, but overlooked the use
of _stp_umod_lookup in the tapsetss. This patch updates the missed
_stp_umod_lookup in the ucontext.stp tapset.
William Cohen [Wed, 28 Apr 2021 13:45:07 +0000 (09:45 -0400)]
Adjust tapset dev.stp to get partition number from newer block_device struct
The kernel git commit 0d02129e76edf91cf04fabf1efbc3a9a1f1d729a removed
the bd_part field from struct block_device. The newer field bd_partno
in the same struct should be used to get the partition number. This
fix allows mbrwatch.stp, ioblktime.stp, and disktop.stp examples
to function on Linux 5.10 and new kernels.
Correct a little brainfart that didn't take into account the
presence of try { ... } catch { ... } blocks, lacking the
optional exception-string catching clause.
Sultan Alsawaf [Tue, 20 Apr 2021 21:13:28 +0000 (14:13 -0700)]
runtime: fix user address calculation for PIE binaries
Commit d1b554876 ("runtime: fix symbol lookups when the first section
isn't executable") resolved an issue caused by not storing VMA info when
it was actually needed, and it did this by unconditionally storing VMA
info. It turns out we don't want to unconditionally store VMA info, as
is the case for PIE binaries. Doing so causes user address calculations
for PIE binaries to erroneously include the offset of the section
containing the target address.
Fix it by restoring the old code and just adding what's needed to fix
the bug described in commit d1b554876 (i.e., always storing VMA info
when `vm_start + offset == addr`).
Bonus for the git sleuths:
2:07 PM <fche> I'm not sure I understand all the offsets and bases and this and that
2:08 PM <fche> but it does bring the code back closer to what it used to be
2:08 PM <kerneltoast> don't worry, i don't understand it either
2:08 PM <fche> ok wait I have to add that into the git commit text ;)
Use modern byteman's ability to load helper .jar on demand, and let
that .jar load the JNI .so on demand, all from full
$pkglibexecdir-based pathnames. That way, the rpm .spec does not need
to worry about symlinking, and stapbm doesn't have to deal with
anything except the convenient bminstall/bmsubmit frontend scripts.
Sultan Alsawaf [Thu, 8 Apr 2021 23:57:41 +0000 (16:57 -0700)]
Always get section info via sysfs using kernel_read()
kernel_read_file_from_path() from before it received the offset argument
is buggy in that it always expects the number of bytes read to be the
size of the inode. Since sysfs inodes are PAGE_SIZE bytes in size on
older kernels, kernel_read_file_from_path() would expect sysfs reads to
produce PAGE_SIZE bytes of output, otherwise it would return an error.
We can avoid kernel_read_file_from_path()'s quirks entirely by simply
using kernel_read() directly, which has the added benefit of existing
since before the first 2.6 kernel. This allows us to ditch the old
module_attribute struct hacks entirely, since the module sections sysfs
has been around since 2.6.8.
PR27658: show stderr of typequery make jobs in pass 2
typequery child-gcc invocations should not cause errors. But if
they do, might as well show them to users, because a typo or some
other momentary/solvable system error might be responsible.
Stan Cox [Mon, 29 Mar 2021 15:36:01 +0000 (11:36 -0400)]
Set trust for new certificates.
Remove the change_cert_trust workaround and replace it with
PK11_InitPin call to initialize the metaData in key4.db. Replace
CERT_DecodeCertFromPackage with PK11_ImportDERCert
Frank Ch. Eigler [Thu, 25 Mar 2021 23:22:31 +0000 (19:22 -0400)]
ioscheduler tapset: adapt for loss of $q, standardize elevator_name
block/scheduler kernel tracepoints have lost the $q parameter, since
it is directly available from $rq. Thus the derived script variable
elevator_name needs to be accessed that other route. Tested on f33
and rhel6.
Frank Ch. Eigler [Wed, 24 Mar 2021 00:36:53 +0000 (20:36 -0400)]
RHBZ1940761: tweak old_timex32 conditional usage
Improve on commit 4ab42baafca69 for pre-5.1 kernels. The subject
compatibility type was introduced not with CONFIG_COMPAT_32BIT_TIME,
but later. Tweak the conditional to also take kernel version >= 5.1
into account.
Serhei Makarov [Fri, 19 Mar 2021 23:11:25 +0000 (19:11 -0400)]
bpf-translate.cxx refactor: move visit{_try,}_block to a more logical place
visit_try_block() was in the middle of the assembler but unrelated to it.
In preparation for improving the register_error assembler directive,
move this code (and visit_block) to a more sensible location.
Then the embeddedcode assembler implementation is grouped at the start of
the visitor functions.
Alice Zhang [Wed, 17 Mar 2021 18:28:39 +0000 (14:28 -0400)]
PR13838: support fp32_to_fp64 conversion automatically at functioncall
synthesize level.
- tapsets.cxx: modified synthetic_embedded_deref_call, so a 4 byte
floating point will be convert to 8 byte double if detected.
- testsuite/buildok/floatingpoint.stp: updated corresponding fp32
examples.
Frank Ch. Eigler [Mon, 15 Feb 2021 17:01:36 +0000 (12:01 -0500)]
PR13838:
- prototype FP support in STAPCONF_REGSET configuration
In REGSET mode (rhel8ish+), fp registers need to be addressed by
ptrace NT_PRFPREG lookup coordinates.
- runtime/linux/loc2c-runtime.h: extend SSE, SSE2 and XMM register
definiton in url_x86_64[]
Alice Zhang [Thu, 7 Jan 2021 21:55:05 +0000 (16:55 -0500)]
PR13838:
- modified dwflpp.cxx so that $fp syntax will be supported
- runtme/loc2c-runtime.h: extended x64_64 register to 24 to allow access of xmm0-xmm7 register.
- testsuite/systemtap.examples/general: update examples, using $fp instead of user_long($fpointer)
Sultan Alsawaf [Tue, 9 Mar 2021 17:14:07 +0000 (12:14 -0500)]
runtime: fix symbol lookups when the first section isn't executable
Some binaries are linked in such a way that there are VMA address
range gaps, indicated by non-zero load offsets. The runtime needs to
not lose those offsets to enable a proper mapping back & forth from
addresses to symbols.
Serhei Makarov [Mon, 8 Mar 2021 20:55:35 +0000 (15:55 -0500)]
PR27030 bpf/uconversions.stp: other sizes user_*_error()
* tapset/bpf/uconversions.stp (__bpf_probe_read_user_error): Don't shift by 8-size.
(__signext): New function.
(__bpf_probe_read_user_error_signed): New function.
(user_*_error): New functions, all from tapset/uconversions.stp.
* tapset/uconversions.stp (user_*_error): Disable these definitions on bpf backend.
* testsuite/systemtap.bpf/bpf-target.c: Extend test to probe different size values.
* testsuite/systemtap.bpf/bpf_target_tests/user_long.stp: Ditto.
Serhei Makarov [Fri, 5 Mar 2021 17:07:38 +0000 (12:07 -0500)]
stapbpf PR27030,PR25177/27032 bpf.exp: use stap -c on bpf_target_tests/
* testsuite/systemtap.bpf/bpf.exp:
compile bpf-target.c, use -x for bpf_tests/, -c for bpf_target_tests/
* testsuite/systemtap.bpf/bpf-target.c:
fix increment, rename from bpf-uconversions.c, XXX more coming soon
* testsuite/systemtap.bpf/bpf_target_tests/user_atvar_entry.stp:
output PASS/FAIL for @var,@entry support
* testsuite/systemtap.bpf/bpf_target_tests/user_long.stp:
output PASS/FAIL for PR27030 user_long(), XXX more coming soon
latex2html has been supplanted by htlatex, a more native latex->html
renderer. Switch the update-htmldocs file etc. to use it to generate
html for the langref and tutorial documents.
1. Merge stapbpf.cxx log_level with verbose.
2. Alias stapbpf.cxx module_name to __name__ (module_name is better).
3. Put back double-space in usage messages.
Serhei Makarov [Thu, 25 Feb 2021 16:54:00 +0000 (11:54 -0500)]
stapbpf PR25177/27032: handle process exit (SIGCHLD)
* stapbpf.cxx (target_pid_failed_p): New variable.
(sigchld): New function, handle child process exit and signal bpf program.
(main): Set up and disable SIGCHLD handler and propagate failure exit.
Serhei Makarov [Wed, 24 Feb 2021 19:48:41 +0000 (14:48 -0500)]
stapbpf PR25177/27032: link start_cmd() into stapbpf, launch the process
This patch takes care of launching the process, next patch must take care
of listening for the process to finish running.
TODO some redundant declarations in stapbpf.cxx should be merged.
TODO in general staprun uses much nicer print functions,
should stapbpf borrow them too?
* buildrun.cxx (make_bpf_run_command): pass s.cmd to the stapbpf command.
* stapbpf/stapbpf.cxx (verbose): TODO redundant decl for start_cmd.c.
(read_stdin): TODO unused decl for start_cmd.c.
(__name__): TODO redundant decl for start_cmd.c.
(target_pid): now shared with C code in start_cmd.c.
(target_cmd): now shared with C code in start_cmd.c.
(eprintf): decl for start_cmd.c.
(start_cmd): decl for start_cmd.c.
(resume_cmd): decl for start_cmd.c.
(load_bpf_file): populate TODO redundant __name__ decl.
(usage): add '-c' option.
(main): add '-c' option, use start_cmd()/resume_cmd() to launch the process.
* stapbpf/bpfinterp.h (target_pid): now shared with C code in start_cmd.c.
* stapbpf/Makefile.{am,in}: add ../staprun/start_cmd.c to sources.
Serhei Makarov [Tue, 23 Feb 2021 21:12:47 +0000 (16:12 -0500)]
PR25177/27032 staprun: factor out start_cmd() for stapbpf usage
Most/all of the start_cmd() code in stap run should apply
to stapbpf '-c' support as well. Factor it out into an object
file that can be linked by both staprun and stapbpf.
* staprun/start_cmd.c: New file to be linked into both staprun and stapbpf.
* staprun/staprun.h: Declare functions in start_cmd.c.
* common.c (closefrom): Moved to start_cmd.c.
(OPEN_MAX): Moved to start_cmd.c.
* mainloop.c (signal_usr1): Moved to start_cmd.c.
(start_cmd): Moved to start_cmd.c.
(stp_main_loop): Move signal code to resume_cmd() in start_cmd.c.