* dtrace.in: When building packages like libvirt on openSUSE that
link a libvirt_probes.o from dtrace, the build results differed
across builds. This is because the source's temporary filename
was in the .o. Make the temporary filename reproducible.
David Smith [Fri, 11 Aug 2017 14:36:51 +0000 (09:36 -0500)]
Fix PR21802 by improving the syscall test cases.
* testsuite/systemtap.syscall/syscall.exp: Add logic to use the
'CHECK_ONLY' environment variable to limit the syscalls tested.
* testsuite/systemtap.syscall/nd_syscall.exp: Ditto.
David Smith [Thu, 3 Aug 2017 19:23:28 +0000 (14:23 -0500)]
Fix deref handling on 32-bit kernels.
* runtime/linux/loc2c-runtime.h (__stp_deref_nocheck_): Fix i386/arm
systems where handling 8-byte values in one operation isn't possible.
(__stp_store_deref_nocheck_): Ditto.
David Smith [Thu, 3 Aug 2017 18:46:31 +0000 (13:46 -0500)]
Fix PR21901 by releasing locks in the correct order in runtime/stp_utrace.c.
* runtime/stp_utrace.c (utrace_reset): Be sure to release the locks in the
order we take them, otherwise we get an "inconsistent lock state" kernel
warning.
* main.cxx: Don't be sensitive to HAVE_LINUX_BPF_H in redundant
decisions.
* stapbpf: Clear bpf_attr's before passing to kernel, else -EINVAL.
Use log_level for verbosity for bpf syscall and elsewhere. Unshare
random text buffers and bpf's designated bpf_log_buf.
* runtime/linux/netfilter.c: To avoid "sleeping function called from
invalid context" kernel bugs, switch from using 'for_each_net_rcu()' to
using 'for_each_net()'. This avoids putting us into atomic context.
David Smith [Thu, 27 Jul 2017 17:32:54 +0000 (12:32 -0500)]
Fix syscall.{preadv,pwritev} 'offset' variable handling.
* tapset/linux/syscalls.stpm (__pos_from_hilo): New macro.
* tapset/linux/sysc_preadv.stp: Uses @__pos_from_hilo() macro to get the
correct 'offset' value.
* tapset/linux/sysc_preadv2.stp: Ditto.
* tapset/linux/sysc_pwritev.stp: Ditto.
* tapset/linux/sysc_pwritev2.stp: Ditto.
* testsuite/systemtap.syscall/preadv.c (__preadv2): Renamed from
'preadv2', since glibc 2.25 has implemented 'preadv2'.
* testsuite/systemtap.syscall/pwritev.c (__pwritev2): Renamed from
'pwritev2', sine glibc 2.25 has implemented 'pwritev2'.
David Smith [Wed, 26 Jul 2017 21:04:24 +0000 (16:04 -0500)]
syscall.execveat probes: provide decoded env_str
* tapset/linux/sysc_execveat.stp: Commit be0c04a changed syscall.execve to
provide decoded environment variables. Make similar changes for
syscall.execveat.
* testsuite/systemtap.syscall/execve.c: Update for output change.
* testsuite/systemtap.syscall/execveat.c: Ditto.
David Smith [Wed, 26 Jul 2017 15:19:36 +0000 (10:19 -0500)]
Fix PR21834 by updating the netfilter probes for new kernels.
* runtime/linux/netfilter.c: New file containing
nf_register_hook/nf_unregister_hook.
* tapset-netfilter.cxx (netfilter_derived_probe_group::emit_module_decls):
Include "linux/netfilter.c".
* buildrun.cxx (compile_pass): Add exportconf test for "nf_register_hook".
David Smith [Tue, 25 Jul 2017 20:07:46 +0000 (15:07 -0500)]
Updated testsuite/buildok/fortytwo.stp for rawhide.
* testsuite/buildok/fortytwo.stp: Updated for rawhide kernels,
4.13.0-0.rc1.git4.1.fc27.x86_64, where the kernel function
'do_readv_writev' no longer exists. Instead, probe
'do_iter_readv_writev'.
autocast support: bring back early manual functionall->synth-decl referent
When synthesizing dwarf-related functions, we can usually rely on
pass-2 symbol resolution to match up the functioncall*s with the
functiondecl*s. But in the case of autocast handling, synth function
generation is for whatever reason delayed past this point in pass-2,
so we have to manually resolve symbols/referents to some extent.
The bpf branch converts this former macro into an inline function,
so stricter type checking applies. This explicit cast makes several
pass-4 errors go poof!
As commented, we may well require sign-extension of the
rvalue that gets assigned to the lvalue. But the previous
code didn't do that; we certainly get away with it for x86.
Add probe alias input.line, allow multiple procfs.write probes for a single file.
* man/stapprobes.3stap: updated section on input probes.
* runtime/procfs-probes.c (struct stap_procfs_probe): member write_probe renamed to
write_probes. Type of member changed to struct stap_probe**.
(_stp_proc_write_file): now handles multiple write probes.
* runtime/procfs.c (_stp_create_procfs): no longer exits when trying to create
a proc file that already exists.
* tapset-procfs.cxx (struct procfs_probe_set): member write_probe renamed to
write_probes. Type of member changed to vector<procfs_derived_probe*>.
(procfs_derived_probe_group::emit_module_decls): now handles multiple
write_probes.
* tapset/input.stp: added alias input.line.
David Smith [Tue, 18 Jul 2017 21:28:17 +0000 (16:28 -0500)]
Improve the http server "local" backend.
* httpd/backends.cxx (local_backend::local_backend): Look for all the
kernels this system can compile a module for.
(local_backend::can_generate_module): Make sure this system can compile
a module for the target kernel.
(docker_backend): Add class start.
* httpd/api.cxx (result_info::generate_response): Can now return an error
status.
(response build_collection_rh::POST): Fixed typo in error message.
(build_info::set_result): New function.
(build_info::module_build): Always specify the kernel version in the
stap command line. Generate an error result if needed. Return an error
if no suitable backend can be found. Call globfree() when needed.
(get_backends): Add docker backend.
Cody Santing [Tue, 6 Jun 2017 18:20:06 +0000 (14:20 -0400)]
PR21283 initial commit
* remote.cxx: detect dyninst mode then adjust the extension of the
module being sent to .so. Also passes a new '-d' argument to stapsh
signifying dyninst mode.
* staprun/stapsh.c: if in dyninst mode, call stapdyn vs staprun
debuginfo diagnostics: complain about unresolved $vars better
dwarf_var_expanding_visitor::visit_target_symbol used to just quietly
sulk if a $context variable could not be resolved due to a null-die
reference scope. This happens e.g. if no debuginfo was found for a
target binary, but the probe point was resolved perhaps due to symbol
tables. It would result in a mystifying "unresolved target-symbol
expression" error. The new message is thrown in context and treated
like a saved_conversion_error, with an explicit error::dwarf2 hint.
David Smith [Fri, 30 Jun 2017 16:03:52 +0000 (11:03 -0500)]
Disable page faults in _stp_valid_pc_addr().
* runtime/stack.c (_stp_valid_pc_addr): According to the comment for
access_ok(): "User context only. This function may sleep if pagefaults
are enabled." So, disable pagefaults before calling access_ok().
loc2c-runtime: Rely on inline functions more than macros
Since we lack hygienic macros in C, temp variables from one macro/scope
can interfere with same-named variables in another macro/scope. We cannot
remove the use of macros entirely, because DEREF_FAULT includes a goto.
Remove as much code, and as many block-local variables, as possible from
the macros.
Frank Ch. Eigler [Wed, 28 Jun 2017 17:41:40 +0000 (13:41 -0400)]
DEREF_FAULT: print hex better, without #token
With deref() constructs being nested, the expression parameters is now
frequently generated C goo that a stap user cannot be expected to understand.
We no longer print that part in the DEREF_FAULT handler, leaving only the
faulting address.
Richard Fontana [Mon, 26 Jun 2017 21:55:32 +0000 (17:55 -0400)]
Improve public domain dedication language.
A friend contacted me about the legal header in these two files,
arguing that it "makes very little sense", I think because of the
juxtaposition of the copyright notice with the public domain
assertion. Following one of his suggestions I replaced it with a
reference to CC0.
Signed-off-by: Richard Fontana <rfontana@redhat.com>
David Smith [Mon, 26 Jun 2017 21:52:43 +0000 (16:52 -0500)]
Reworked/reorganized the NSS client code to handle the HTTP client code.
* csclient.cxx: Moved lots of code to new file client-nss.cxx. Reorganized
so that both the NSS and HTTP clients use the same framework.
* csclient.h: Added declaration of new 'client_backend' class and updated.
* configure.ac: Define NEED_BASE_CLIENT_CODE if either HAVE_NSS or
HAVE_HTTP_SUPPORT is defined.
* Makefile.am: Compile csclient.css if NEED_BASE_CLIENT_CODE is defined.
* Makefile.in: Regenerated.
* config.in: Ditto.
* configure: Ditto.
* client-http.cxx: Renamed and rewored from http_client.cxx.
* client-http.h: New file.
* client-nss.h: Ditto.
* http_client.cxx: Deleted.
* http_client.h: Deleted.
* main.cxx (interactive_mode): Calls renamed nss_client_* server
functions.
* interactive.cxx: Ditto.
* session.cxx (systemtap_session): Updated.
* session.h: Ditto.
* util.cxx (read_from_file): Moved from csclient.cxx.
(write_to_file): Ditto.
* util.h: Added declarations.
David Smith [Thu, 22 Jun 2017 21:26:43 +0000 (16:26 -0500)]
Fix another compile error in staprun/monitor.c.
* staprun/monitor.c (redirect_stdin): Fix "comparison is always true due
to limited range of data type" compile problem by correctly calling
getchar().
David Smith [Thu, 22 Jun 2017 20:48:39 +0000 (15:48 -0500)]
Update testsuite's kernel debuginfo smoke test.
* testsuite/lib/systemtap.exp (environment_sanity_test): Since we've
merged the syscall and nd_syscall tapsets, we can't probe 'syscall.open'
for a kernel debuginfo smoke test. Instead, we've got to probe
'dw_syscall.open'.
Frank Ch. Eigler [Thu, 22 Jun 2017 19:59:22 +0000 (15:59 -0400)]
loc2c-runtime.h: in deref calls, tolerate nested calling
With the loc2stap code, it is possible to see constructs like
deref(8, deref(8, deref(8, deref(8, fetch_register(4))))
so the addr field is itself a deref. This blows up if the deref
macro copies the addr parameter multiple times, with a glorious
exponential fanout! So now we use a temporary variable within
the macro, to hold the address value, then reuse that.
Frank Ch. Eigler [Thu, 22 Jun 2017 19:49:39 +0000 (15:49 -0400)]
translator for embeddedcode: don't emit deref_fault pseudo-labels
We will aim to rely on the single solitary deref_fault: label
emitted at the tail of functions / probes boilerplate, rather
than labels that may be nested within generated code. This
also needs the old-fashioned CATCH_DEREF_FAULT macro for
embedded-C code to no longer define the label.