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().
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'.
William Cohen [Thu, 22 Jun 2017 03:26:33 +0000 (23:26 -0400)]
Adapt huge page systemtap scripts from blog article into examples
People may be concerned about issues due to huge page operation overhead. The
blog article at https://developers.redhat.com/blog/2014/03/10/examining-huge-pages-or-transparent-huge-pages-performance/
describes a number of the possible problems. The example scripts in the article have been tweaked and added to the systemtap memory examples.
Aaron Merey [Wed, 21 Jun 2017 16:13:21 +0000 (12:13 -0400)]
Add new probe alias input.char
input.char enables scripts to receive input from stdin during
module runtime. It is an alias for the probe procfs.write("__stdin").
The presence of this procfs probe puts the terminal in non-canonical mode
and causes a thread to spawn in staprun. This thread will read characters
from stdin one at a time and write them to /proc/systemtap/MODNAME/__stdin,
triggering the probe once per character.
An example of this functionality can be seen in EXAMPLES/general/eventcount_interactive.stp.
This script is a modified eventcount.stp where two of the display parameters can
be modified during runtime.
David Smith [Tue, 20 Jun 2017 15:44:44 +0000 (10:44 -0500)]
Update several server tests.
* testsuite/systemtap.server/server.exp: Handle the change in
setup_server() that no longer produces a "server.log" file.
* testsuite/systemtap.server/server_concurrency.exp: Ditto.
* testsuite/systemtap.server/server_req_size.exp: Ditto.
David Smith [Wed, 14 Jun 2017 20:34:20 +0000 (15:34 -0500)]
The httpd server now captures stdout/stderr from systemtap.
* httpd/api.cxx (result_info::generate_response): Add the return code,
stdout and stderr files. Change the way we output the module file
name. Add the module mode.
(build_info::module_build): Capture stdout and stderr from the module
build.
* httpd/client.py: Download stdout/stderr files. Add a "stap -L" test.
* httpd/hello_world.stp: Test file.
David Smith [Tue, 13 Jun 2017 15:51:45 +0000 (10:51 -0500)]
Add file upload to the httpd server.
* httpd/client.py: Move common code into a function. Add a second test
case that uploads a script file.
* httpd/server.cxx (connection_info::post_files_cleanup): New function.
(connection_info::postdataiterator): Handle files included with the POST
request.
(server::access_handler): Copy all the POST file info into the request.
* httpd/server.h (struct request): Add 'base_dir' and 'files' member
variables.
* httpd/api.cxx (build_info::module_build): Do an unshare()/chdir() before
the spatp_spawn if needed.
David Smith [Wed, 7 Jun 2017 17:28:51 +0000 (12:28 -0500)]
The httpd server now builds a kernel module and returns its information.
* httpd/main.cxx: Add code to actually build a kernel module. Add code to
return information about the kernel module.
* httpd/client.py: Add code to expect the redirect from the build info to
the build results.
David Smith [Tue, 30 May 2017 21:56:58 +0000 (16:56 -0500)]
The httpd server now expects the command line to be sent tokenized.
* httpd/server.cxx (get_key_values): Expect each request parameter to
possibly have multiple values.
* httpd/server.h (struct request): Ditto
* httpd/main.cxx (string build_info::content): Output the command line
arguments as an JSON array instead of as a single value.
(build_info::start_module_build): New function.
(response build_collection::POST): Expect each request parameter to
possibly have multiple values.
* httpd/client.py: Pass the command line arguments as an array of strings
instead of as one string.
David Smith [Tue, 23 May 2017 21:33:23 +0000 (16:33 -0500)]
Add httpd signal handling.
* httpd/server.cxx (server::stop): New function.
(server::wait): Ditto.
* httpd/server.h: Add condition variable to wait on.
* httpd/main.cxx (build_info::content): Put the json object when we're
done with it.
(cleanup): New function.
(signal_thread): Ditto.
(setup_main_signals): Ditto.
(main): Call signal handling functions.
David Smith [Fri, 12 May 2017 16:36:24 +0000 (11:36 -0500)]
Add httpd server updates.
* httpd/server.cxx (server::access_handler): Save regexp matches.
(server::queue_response): Add response headers.
* httpd/main.cxx: Add initial support for build info.
* httpd/Makefile.am: Link with the json-c library.
* httpd/server.h (struct request): Add 'matches' variable.
* configure.ac: Add the json-c library as a requirement of the httpd
server.
* config.in: Regenerated.
* configure: Ditto.
* httpd/Makefile.in: Ditto.
David Smith [Wed, 10 May 2017 16:36:47 +0000 (11:36 -0500)]
Mark several tests as needing uprobes.
* testsuite/systemtap.base/at_var_void_stmt.exp: Don't run the test if we
don't have uprobes.
* testsuite/systemtap.base/auto_path.exp: Ditto.
* testsuite/systemtap.base/pr18649.exp: Ditto.
* testsuite/systemtap.base/set_user.exp: Ditto.
* testsuite/systemtap.context/usymfileline.exp: Ditto.
* testsuite/systemtap.exelib/pthreadprobes.exp: Ditto.
David Smith [Tue, 9 May 2017 21:39:11 +0000 (16:39 -0500)]
Add small testsuite fixes for 4.11 kernels.
* testsuite/buildok/twentyseven.stp: Avoid missing inlined function
arguments by probing 'kernel.function("do_execve").call'.
* testsuite/buildok/thirtyone.stp: On 4.11 kernels, handle the vfs_stat()
function being renamed to vfs_statx().
* testsuite/systemtap.pass1-4/buildok.exp: Add kfails for
buildok/fortyfour.stp and buildok/map_probe_cond.stp if we don't have
uprobes.
* testsuite/systemtap.pass1-4/buildok-interactive.exp: Ditto.
David Smith [Tue, 9 May 2017 21:32:25 +0000 (16:32 -0500)]
Add missing @cast() calls for 4.11 kernels.
* tapset/linux/task.stp: Add a "signal_struct" cast to
_task_rlimit_cur().
* tapset/linux/task.stpm: Fix @mm() macro for kernels >= 2.6.34, where the
mm_struct definition has moved to <linux/mm_types.h>
* tapset/linux/proc_mem.stp (proc_mem_size): Use the @mm() macro to cast
values to a mm_struct.
(proc_mem_txt): Ditto.
(proc_mem_data): Ditto.
* tapset/linux/context.stp (cmdline_args): Ditto.
* tapset/linux/context-envvar.stp (env_var): Ditto.
David Smith [Tue, 9 May 2017 21:20:41 +0000 (16:20 -0500)]
Avoid missing "task_stack()" definition on 4.11 kernels.
* runtime/compatdefs.h: If <linux/sched/task_stack.h> exists, include
it. This avoids a missing task_stack() definition.
* buildrun.cxx (compile_pass): Add autoconf test for
<linux/sched/task_stack.h>.
* runtime/linux/autoconf-sched-task_stack.c: New file.
We used to emit these during dwflpp::express_as_string, after we'd
generated the rest of the body of the embeddedcode node. Emitting
these unconditionally is, for now at least, easier than walking the
tree to figure out if they're needed.
The __attribute__ syntax for labels dates from gcc 4.2.
Cody Santing [Wed, 3 May 2017 16:31:39 +0000 (12:31 -0400)]
Remove duplication in deprecated tapset functions
* Removed systemtap version compile conditions on
deprecated functions. Deprecated functions now refer to their
replacements rather than being a direct copy.
David Smith [Tue, 2 May 2017 17:11:29 +0000 (12:11 -0500)]
Make changes for RHEL6 in the http web service server code.
* configure.ac: Accept version 2.17.0 of the uuid library (for RHEL6).
* httpd/Makefile.am: Add ../util.cxx for regexp support that works on
RHEL6.
* httpd/main.cxx: Ditto.
* httpd/server.cxx: Ditto.
* httpd/server.h: Ditto.
* configure: Regenerated.
* httpd/Makefile.in: Ditto.
David Smith [Mon, 1 May 2017 20:55:51 +0000 (15:55 -0500)]
Added initial http web service server code.
* httpd/Makefile.am
* httpd/Makefile.in: Generated.
* httpd/main.cxx: httpd main program source.
* httpd/server.cxx: httpd server framework
* httpd/server.h: httpd server include file
* configure.ac: Make sure we have the microhttpd and uuid libraries before
trying to build the httpd code.
* Makefile.am: Added 'httpd' subdirectory.
* Makefile.in: Regenerated.
* config.in: Ditto.
* configure: Ditto.
David Smith [Tue, 25 Apr 2017 19:48:13 +0000 (14:48 -0500)]
Avoid server test failures by fixing test server startup/shutdown.
* testsuite/lib/systemtap.exp: Avoid 'output: can't read "logfile": no
such variable' tcl errors when starting systemtap server by properly
handling server logfile.
William Cohen [Mon, 17 Apr 2017 02:57:34 +0000 (22:57 -0400)]
Add aarch64 DWARF register names
To allow systemtap to compile on aarch64 machines with kernels that
supports BPF bpf-translate.cxx needs to have mappings for the DWARF
register names for aarch64.
William Cohen [Sun, 16 Apr 2017 19:44:27 +0000 (15:44 -0400)]
Add ARM DWARF register names
To allow systemtap to compile on 32-bit ARM machines with kernels that
supports BPF bpf-translate.cxx needs to have mappings for the DWARF
register names for ARM.
Mark Wielaard [Fri, 14 Apr 2017 10:44:36 +0000 (12:44 +0200)]
stapbpf/libbpf.c: Define __NR_bpf and initialize anonymous bpf_attr union.
__NR_bpf might not be defined in older headers, if so define it ourselves.
Older GCC have trouble initializing anonymous struct fields in a union
directly. Initialize them more explicitly.
David Smith [Fri, 7 Apr 2017 15:13:41 +0000 (10:13 -0500)]
Fix PR21363 by getting _struct_sched_attr_u() working on rawhide.
* buildrun.cxx (compile_pass): Add autoconf test to check for the
existence of <uapi/linux/sched/types.h>
* tapset/linux/aux_syscalls.stp: Include <uapi/linux/sched/types.h> if
STAPCONF_UAPI_LINUX_SCHED_TYPES is defined.
* runtime/linux/autoconf-uapi-linux-sched-types.c: New autoconf test.
David Smith [Wed, 5 Apr 2017 16:05:04 +0000 (11:05 -0500)]
Add a new tracepoint test to check compile requirements for each group.
* testsuite/systemtap.base/tracepoints_list.exp: Add a new test where we
make sure that each tracepoint group's compile tweaks are sufficient in
itself.
David Smith [Wed, 5 Apr 2017 15:28:39 +0000 (10:28 -0500)]
Fix several small items found by a coverty code scan.
* tapsets.cxx (uprobe_derived_probe_group): Add constructor to initialize
'max_perf_counters'.
* session.cxx (parse_cmdline): Be sure check 'optarg' is NULL before
trying to use it.
* elaborate.cxx (stat_decl_collector::visit_stat_op): Make sure that if
iterator is at the end, we don't try to access it anyway.
Martin Cermak [Tue, 4 Apr 2017 08:25:22 +0000 (10:25 +0200)]
PR21297 Add support for new statx syscall
tapset/linux/aux_syscalls.stp: Add _statx_mask_str()
tapset/linux/i386/syscall_num.stp: Add statx syscall info
tapset/linux/x86_64/syscall_num.stp: Ditto
tapset/linux/sysc_statx.stp: New syscall tapset
testsuite/buildok/nd_syscalls2-detailed.stp: New buildok test
testsuite/buildok/syscalls2-detailed.stp: Ditto
testsuite/systemtap.syscall/stat.c: New statx syscall subtest
David Smith [Fri, 31 Mar 2017 19:36:40 +0000 (14:36 -0500)]
Tweak elfutils version discovery in the testsuite.
* testsuite/lib/systemtap.exp (get_system_info): If we're running a
version of systemtap compiled with version X of elfutils, but running
with version Y of elfutils (where Y > X), the elfutils version gets
reported as 'Y/X'. Make sure to parse this correctly.