]> sourceware.org Git - systemtap.git/log
systemtap.git
5 years agostapbpf/stapbpf.cxx :: placate the gods of Coverity
Serhei Makarov [Thu, 9 May 2019 20:45:11 +0000 (16:45 -0400)]
stapbpf/stapbpf.cxx :: placate the gods of Coverity

* stapbpf/stapbpf.cxx (instantiate_maps): UNUSED_VALUE #if0 out unused code;
NEGATIVE_RETURNS handle error return from sysconf(_SC_NPROCESSORS_CONF),
previous sysconf fix was valid but it might make sense to print a warning.
(register_tracepoints): RESOURCE_LEAK close fd on read failure.

5 years agostapbpf/bpfinterp.cxx :: placate the gods of Coverity
Serhei Makarov [Thu, 9 May 2019 20:43:36 +0000 (16:43 -0400)]
stapbpf/bpfinterp.cxx :: placate the gods of Coverity

* bpf-internal.h (BPF_MAXSTRINGLEN_PLUS): new define, BPF_MAXSTRINGLEN+1.
* stapbpf/bpfinterp.cxx (map_get_next_key): BUFFER_SIZE_WARNING use bigger buffer.
(bpf_interpret): UNUSED_VALUE memset regs to 0x0,
OVERFLOW_BEFORE_WIDEN indicate in 32-bit LSH operation that widening is inappropriate.

5 years agoPR23074: fix guru mode issue with generated calls to register get/set
Jafeer Uddin [Thu, 9 May 2019 20:18:46 +0000 (16:18 -0400)]
PR23074: fix guru mode issue with generated calls to register get/set

5 years agostapbpf.cxx sysconf() coverity nit
Frank Ch. Eigler [Thu, 9 May 2019 13:22:08 +0000 (09:22 -0400)]
stapbpf.cxx sysconf() coverity nit

5 years agoupdate-docs pass
Frank Ch. Eigler [Tue, 7 May 2019 22:35:02 +0000 (18:35 -0400)]
update-docs pass

5 years agobegin next release work: bump version to Ultimate Answer
Serhei Makarov [Tue, 7 May 2019 21:21:39 +0000 (17:21 -0400)]
begin next release work: bump version to Ultimate Answer

5 years agosystemtap.spec: inconsequential(?) typo
Serhei Makarov [Tue, 7 May 2019 18:59:39 +0000 (14:59 -0400)]
systemtap.spec: inconsequential(?) typo

5 years agoNEWS, systemtap.spec :: bump release by 1d release-4.1
Serhei Makarov [Tue, 7 May 2019 14:36:41 +0000 (10:36 -0400)]
NEWS, systemtap.spec :: bump release by 1d

5 years agoNEWS :: 4.1 release is go
Serhei Makarov [Mon, 6 May 2019 18:21:12 +0000 (14:21 -0400)]
NEWS :: 4.1 release is go

5 years agoruntime: on kernels >= 4.0, multiple concurrent systemtap scripts
Frank Ch. Eigler [Mon, 6 May 2019 22:27:09 +0000 (22:27 +0000)]
runtime: on kernels >= 4.0, multiple concurrent systemtap scripts

This old kernel commit:

commit 190afd81e4a5f24d1db6c774ca7f18acde2fca30
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Sun Jan 25 13:55:55 2015 -0500

    debugfs: split the beginning and the end of __create_file() off

appears to have encoded duplicate $debugfs/systemtap directory
existence into an -EEXIST error code, which we didn't handle.
We now treat it as though it were NULL.  Tested on 5.1-rc7.

5 years agoexamples index regen
Frank Ch. Eigler [Mon, 6 May 2019 16:38:40 +0000 (12:38 -0400)]
examples index regen

5 years agoprerelease docs regen
Frank Ch. Eigler [Mon, 6 May 2019 16:35:58 +0000 (12:35 -0400)]
prerelease docs regen

5 years agoPRERELEASE content bump
Frank Ch. Eigler [Mon, 6 May 2019 16:25:09 +0000 (12:25 -0400)]
PRERELEASE content bump

5 years agocopyright year updates
Frank Ch. Eigler [Mon, 6 May 2019 16:18:06 +0000 (12:18 -0400)]
copyright year updates

5 years agoNEWS :: mention ktime_get_real_fast_ns() from commit e2e13220fb
Serhei Makarov [Mon, 6 May 2019 15:48:54 +0000 (11:48 -0400)]
NEWS :: mention ktime_get_real_fast_ns() from commit e2e13220fb

5 years agoNEWS :: mention BPF tapset functions
Serhei Makarov [Sat, 4 May 2019 20:41:07 +0000 (16:41 -0400)]
NEWS :: mention BPF tapset functions

5 years agoadd recent AUTHORS
Serhei Makarov [Sat, 4 May 2019 17:14:00 +0000 (13:14 -0400)]
add recent AUTHORS

5 years agoNEWS: document added support for unhandled DW_OP_GNU_parameter_ref
Jafeer Uddin [Fri, 3 May 2019 19:35:36 +0000 (15:35 -0400)]
NEWS: document added support for unhandled DW_OP_GNU_parameter_ref

5 years agostapbpf/stapbpf.8 :: update based on recent stapbpf work
Serhei Makarov [Fri, 3 May 2019 19:00:44 +0000 (15:00 -0400)]
stapbpf/stapbpf.8 :: update based on recent stapbpf work

5 years agoNEWS :: document recent stapbpf additions
Serhei Makarov [Fri, 3 May 2019 18:52:56 +0000 (14:52 -0400)]
NEWS :: document recent stapbpf additions

5 years agoNEWS :: fxi tyops
Serhei Makarov [Fri, 3 May 2019 18:46:03 +0000 (14:46 -0400)]
NEWS :: fxi tyops

5 years agoAllow preprocessor.exp test to work with 5.x kernels
William Cohen [Fri, 3 May 2019 18:44:31 +0000 (14:44 -0400)]
Allow preprocessor.exp test to work with 5.x kernels

5 years agostapbpf fixup for 4.1 :: typo in error message
Serhei Makarov [Fri, 3 May 2019 15:54:35 +0000 (11:54 -0400)]
stapbpf fixup for 4.1 :: typo in error message

5 years agostapbpf PR23476 fixup :: typo in stat2.stp testcase
Serhei Makarov [Fri, 3 May 2019 15:42:19 +0000 (11:42 -0400)]
stapbpf PR23476 fixup :: typo in stat2.stp testcase

5 years agostapbpf PR23476 :: add tests for stat array and foreach
Serhei Makarov [Fri, 3 May 2019 15:33:03 +0000 (11:33 -0400)]
stapbpf PR23476 :: add tests for stat array and foreach

5 years agostapbpf PR23476 :: enable foreach iteration for stat arrays
Serhei Makarov [Fri, 3 May 2019 15:32:20 +0000 (11:32 -0400)]
stapbpf PR23476 :: enable foreach iteration for stat arrays

5 years agopr23476 fixup for 4.1 :: fix interned_aggregates layout
Serhei Makarov [Fri, 3 May 2019 15:29:56 +0000 (11:29 -0400)]
pr23476 fixup for 4.1 :: fix interned_aggregates layout

5 years agopr23476 fixup for 4.1 :: remove not-yet-supported tests
Serhei Makarov [Thu, 2 May 2019 21:37:51 +0000 (17:37 -0400)]
pr23476 fixup for 4.1 :: remove not-yet-supported tests

5 years agopr23476 fixup for 4.1 :: typo fix in array stat map auto-naming
Serhei Makarov [Thu, 2 May 2019 21:36:51 +0000 (17:36 -0400)]
pr23476 fixup for 4.1 :: typo fix in array stat map auto-naming

5 years agopr23476 fixup for 4.1 :: catch map_id < 0 in unexpected places
Serhei Makarov [Thu, 2 May 2019 21:20:06 +0000 (17:20 -0400)]
pr23476 fixup for 4.1 :: catch map_id < 0 in unexpected places

5 years agopr23476 fixup for 4.1 :: include bpf-shared-globals outside namespace
Serhei Makarov [Thu, 2 May 2019 21:19:27 +0000 (17:19 -0400)]
pr23476 fixup for 4.1 :: include bpf-shared-globals outside namespace

5 years agostapbpf PR23476 WIP (4/6) :: proof-of-concept statistic aggregates
Serhei Makarov [Fri, 12 Apr 2019 19:41:12 +0000 (15:41 -0400)]
stapbpf PR23476 WIP (4/6) :: proof-of-concept statistic aggregates

This is a preview version of the statistics aggregate feature
for inclusion in the stap 4.1 release. Only @sum, @count, @avg
operations are supported for the time being.

5 years agostapbpf PR23476 (3/6) :: add testcases
Serhei Makarov [Wed, 10 Apr 2019 17:16:50 +0000 (13:16 -0400)]
stapbpf PR23476 (3/6) :: add testcases

* testsuite/systemtap.bpf/bpf_tests/stat1.stp: Basic test (<<<, @count, @sum, @avg).
* testsuite/systemtap.bpf/bpf_tests/stat2.stp: Test stat arrays and foreach.
* testsuite/systemtap.bpf/bpf_tests/stat3.stp: Test delete and array-in.

5 years agostapbpf PR23476 (2/7) :: generate scalar+array stat aggregate declarations
Serhei Makarov [Tue, 9 Apr 2019 16:38:54 +0000 (12:38 -0400)]
stapbpf PR23476 (2/7) :: generate scalar+array stat aggregate declarations

* bpf-translate.cxx (translate_globals): Add a case for scalar pe_stats (init scalar stat maps),
add a case for array pe_stats (init a set of array stat maps),
pull out some duplicate code between stat and non-stat cases.
(output_maps): Add a separate case to give snazzy names to stat maps.

5 years agostapbpf PR23476 (1/7) :: redesign struct globals for stat aggregates
Serhei Makarov [Mon, 8 Apr 2019 16:46:04 +0000 (12:46 -0400)]
stapbpf PR23476 (1/7) :: redesign struct globals for stat aggregates

Modify struct globals to allow stats map slots (map_id = -1) and track a
set of percpu maps for each stat aggregate -- one map per field from struct stat_data.

* bpf-internal.h (struct globals): General redesign.
(globals::map_idx): New typedef to identify index of a map.
(globals::map_slot): New type (replacing pair<short,short>) with support for
marking a value's 'slot' as non-scalar (no index) and/or stats (no single map).
(globals::globals_map): Use map_slot type.
(globals::stat_field): New typedef to identify a stats field name.
(globals::stat_fields): The set of supported stats fields.
(globals::stat_iter_field): Stat field to use to obtain keys for foreach, in, &c.
(globals::stats_map): New typedef to identify one map per stats field.
(globals::scalar_stats): One map per stats field to represent scalar stats.
(globals::array_stats): One map per stats field per array to represent stats arrays.
(globals::internal_map_idx): Change type to globals::map_idx.
(globals::perf_event_map_idx): Change type to globals::map_idx.

Also take the first step to supporting stats map slots in bpf-translate.cxx:

* bpf-base.cxx (program::load_map): Guard against unimplemented uses of stats map slots.
* bpf-translate.cxx (bpf_unparser::emit_store): Use new map_slot type from globals_map.
(bpf_unparser::visit_foreach_loop): Ditto.
(bpf_unparser::visit_delete_statement): Ditto.
(bpf_unparser::visit_assignment): For now, explicitly mark <<< as unimplemented.
(bpf_unparser::visit_symbol): Use new map_slot type from globals_map.
(bpf_unparser::visit_arrayindex): Ditto.
(bpf_unparser::visit_array_in): Ditto.
(globals::stat_fields): Initialize globals::stat_fields with count, sum for now.
(globals::stat_iter_field): Initialize globals::stat_iter_field.
(output_maps): Use new map_slot type from globals_map, note requirement to support stats map slots.

NOTE: All of the above bpf-translate.cxx uses of map_slot will change
to also handle stats arrays in the next patches.

5 years agoForce correct order of evaluation of macro arguments in check_*register macros
William Cohen [Thu, 2 May 2019 14:41:59 +0000 (10:41 -0400)]
Force correct order of evaluation of macro arguments in check_*register macros

Noted that a number of tests were failing on x86 machines with errors
like the following:

ERROR: register access fault [man error::fault] near identifier 'module_name' at
 /usr/share/systemtap/tapset/linux/context.stp:392:10

The problem was traced to the maxregno argument for the macro having a
?: operator which has lower precedence than || or >.  This caused the
conditional tests in check_fetch_register and check_store_register for
error reporting to incorrectly trigger.  Used ()'s in the conditionals
to force the correct order of evaluation.

5 years agoruntime task_finder2: allocate large enough array for syscall_get_arguments() output
Frank Ch. Eigler [Wed, 1 May 2019 02:00:00 +0000 (02:00 +0000)]
runtime task_finder2: allocate large enough array for syscall_get_arguments() output

args [3] is too small on 5.1.0-5.rc5

5 years agoNEWS: mention pass-2 speedup
Frank Ch. Eigler [Tue, 30 Apr 2019 15:34:21 +0000 (11:34 -0400)]
NEWS: mention pass-2 speedup

5 years agorhbz1703264: use rpm boolean-dependencies for Recommends: kernel-*devel
Frank Ch. Eigler [Mon, 29 Apr 2019 16:08:24 +0000 (12:08 -0400)]
rhbz1703264: use rpm boolean-dependencies for Recommends: kernel-*devel

5 years agostapbpf test failures fix :: handle empty blocks in output_probe()
Serhei Makarov [Fri, 26 Apr 2019 14:12:37 +0000 (10:12 -0400)]
stapbpf test failures fix :: handle empty blocks in output_probe()

* bpf-translate.cxx (output_probe): Follow forwarder blocks to the
  first block that contains an instruction.

5 years agoPR23074: add support for unhandled DW_OP_GNU_parameter_ref in DWARF expression
Jafeer Uddin [Wed, 3 Apr 2019 19:23:36 +0000 (15:23 -0400)]
PR23074: add support for unhandled DW_OP_GNU_parameter_ref in DWARF expression

5 years agoAdjust syscall_get_arguments to match kernel's implementation
William Cohen [Tue, 23 Apr 2019 19:08:08 +0000 (15:08 -0400)]
Adjust syscall_get_arguments to match kernel's implementation

The syscall_get_argument function arguments changed due to
Linux git commit 32d9258662.  Remove the unused arguments
to match the expect arguments for syscall_get_arguments
when needed.

5 years agoDisable kprobe optimization again
William Cohen [Wed, 10 Apr 2019 18:55:05 +0000 (14:55 -0400)]
Disable kprobe optimization again

On x86 processors running linux 5.0 kernel the uprobes_onthefly.exp
test would trigger a RCU hang (PR24416).  Disable the kprobes
optimization until these problems reported in RHBZ1697531 get fixed in
the kernel.

5 years agodoc/Makefile: Fix command list syntax
David Ward [Mon, 11 Feb 2019 17:25:39 +0000 (12:25 -0500)]
doc/Makefile: Fix command list syntax

5 years agooverload.py: Fix python version 2/3 compatibility
David Ward [Mon, 11 Feb 2019 17:25:38 +0000 (12:25 -0500)]
overload.py: Fix python version 2/3 compatibility

The modified XML tree is outputted either as a bytearray with UTF-8
encoding in python version 3, or as a string in python version 2.
Handle this by writing the bytearray directly to sys.stdout.buffer,
or the string directly to sys.stdout, respectively.

Remove what appears to be "troubleshooting code" that was added in
commit 616ec7a0b, which dumps a large amount of unnecessary output
to stderr.

Call this script using the configured program name for python.

5 years agoconfigure: Fix handling of python versions 2 and 3
David Ward [Mon, 11 Feb 2019 17:25:37 +0000 (12:25 -0500)]
configure: Fix handling of python versions 2 and 3

When python version 2 is not found, AM_PROG_PYTHON sets the output
variable PYTHON to ":" (which is intentional; see "man 1P colon").
Fix incorrect tests that compared PYTHON to an empty string.

Use the same behavior for python version 3: when it is not found,
set the output variable PYTHON3 to ":" and test that accordingly.

Pass the variables "python3" and "py3execdir" to the subconfigure
unconditionally, just like the variables "python" and "pyexecdir".

When a program named "python" exists, fix a conditional that tests
if it is python version 3.

Do not guess the name of the python-config script. Simply append
"-config" to the program name for the python interpreter.

5 years agostapbpf.cxx (instantiate_maps) :: temporary fix for PR24324 pending better ideas
Serhei Makarov [Thu, 4 Apr 2019 15:58:33 +0000 (11:58 -0400)]
stapbpf.cxx (instantiate_maps) :: temporary fix for PR24324 pending better ideas

5 years agoregen po/* with update-po
Frank Ch. Eigler [Wed, 3 Apr 2019 23:55:12 +0000 (23:55 +0000)]
regen po/* with update-po

5 years agoPR24408 @{u,k}register(regno) index/context checking
Frank Ch. Eigler [Wed, 3 Apr 2019 23:51:38 +0000 (23:51 +0000)]
PR24408 @{u,k}register(regno) index/context checking

wcohen discovered that the (guru-mode) @*register operator doesn't
sufficiently check the context it is run in, possibly derefencing
null context->*regs pointers, or going out-of-bounds with register
numbering.  This code adds checking via a generic runtime/**/loc2c*
check_register_{fetch,store} macro.  It is used as a wrapper for
all architectures for both kernel and user register
fetch/store ops.

5 years agosession.cxx: bump kernel-tested version to 5.1-rc2
Frank Ch. Eigler [Mon, 1 Apr 2019 22:16:51 +0000 (18:16 -0400)]
session.cxx: bump kernel-tested version to 5.1-rc2

5 years agoAdd needed arch_syscall0_prefix define for arm64
William Cohen [Mon, 1 Apr 2019 15:25:06 +0000 (11:25 -0400)]
Add needed arch_syscall0_prefix define for arm64

On the x86_64 a functions that implement a syscall with no arguments
is used for both the 32-bit and 64-bit versions of the system call and
there are aliases for the same function.  To avoid having handlers run
twice the arch_syscall0_prefix only instruments the 64-bit versions.
However, this prefix was not being set for arm64 and on the arm64 the
syscalls with no arguments would fall back to the tracepoint versions.
Added the arch_syscall0_prefix define to have the syscall tapsets use
the non-dwarf function probes for those syscalls with no arguments on
arm64.

5 years agostapbpf interpreter improvement
Serhei Makarov [Mon, 1 Apr 2019 14:37:52 +0000 (10:37 -0400)]
stapbpf interpreter improvement

In order to ensure a more welcoming environment for vegans and cows,
all instances of 'deadbeef' in the stapbpf interpreter's memory space
have been replaced by an exhortation to 'ea7bee75' ('eat beets').

(Apr1)

5 years agoUpdate _stp_sockopt_optname_list[] to match current current socket.h defines
William Cohen [Sun, 31 Mar 2019 19:47:36 +0000 (15:47 -0400)]
Update _stp_sockopt_optname_list[] to match current current socket.h defines

There have been a number of updates and additions to the Linux
kernel's include/uapi/asm-generic/socket.h defines since the code in
aux_syscalls.stp for _stp_sockopt_optname_list[] was initially
created.  Defines such as SO_RCVTIMEO, SO_SNDTIMEO, and SO_TIMESTAMP
maybe be replaced by SO_RCVTIMEO_NEW, SO_SNDTIMEO_NEW, and
SO_TIMESTAMP_NEW.  Before this patch systemtap scripts would fail to
build with very new 5.1.0-rc kernels due to the missing defines.

5 years agoPR24395: --ldd: add another interpreter path
Frank Ch. Eigler [Thu, 28 Mar 2019 16:29:52 +0000 (12:29 -0400)]
PR24395: --ldd: add another interpreter path

Unspecified distro uses /usr/lib/ld-linux-$ARCH.so.2, so accept that
too.  We'll have to go to glob patterns any time now.

5 years agoPR24239 redux: testsuite / dump fallout on incremental resolution
Frank Ch. Eigler [Tue, 26 Mar 2019 20:31:24 +0000 (16:31 -0400)]
PR24239 redux: testsuite / dump fallout on incremental resolution

Earlier PR24239 work made global / function resolution incremental
(transitive, starting from references in end-user scripts) rather than
tapset-wide (selecting entire tapsets en masse).  This also affected
--dump-functions mode (which should be unselective), and
global-printing mode (the ordering of the output variables changed).

Updated the test suite to tolerate some different orderings, and
updated the translator to fix dumping & pragma/c variable arity.

5 years agoPR23875,PR23816,PR24358 :: tentatively remove testsuite kfails
Serhei Makarov [Tue, 26 Mar 2019 17:11:29 +0000 (13:11 -0400)]
PR23875,PR23816,PR24358 :: tentatively remove testsuite kfails

5 years agoPR23875 :: support string map keys in foreach iteration
Serhei Makarov [Tue, 26 Mar 2019 17:05:26 +0000 (13:05 -0400)]
PR23875 :: support string map keys in foreach iteration

* bpf-translate.cxx (bpf_unparser::visit_foreach_loop): Add code to handle
and correctly allocate space for string map keys.
* bpf-interp.cxx (as_ptr): New overload yielding void * from char *,
to return cached string map keys into bpf registers.
(typedef map_int_keys): Renamed from map_keys, only handles caching integer keys.
(typedef map_str_keys): New typedef, handled caching string keys.
(struct map_keys): New struct (XXX pseudo-union) for either int or str key iteration.
(map_get_next_key): Rewrite to support both int and str key iteration,
take bpf_transport_context.
(bpf_interpret): Pass bpf_transport_context to map_get_next_key.

5 years agoPR23875 test fixup :: should exit()
Serhei Makarov [Tue, 26 Mar 2019 17:00:45 +0000 (13:00 -0400)]
PR23875 test fixup :: should exit()

5 years agosystemtap.examples :: driveby permissions fix
Serhei Makarov [Fri, 22 Mar 2019 19:54:00 +0000 (15:54 -0400)]
systemtap.examples :: driveby permissions fix

5 years agosystemtap.examples :: cachestat.stp can use format specifiers now
Serhei Makarov [Fri, 22 Mar 2019 19:53:10 +0000 (15:53 -0400)]
systemtap.examples :: cachestat.stp can use format specifiers now

5 years agostapbpf PR24358,PR23816 :: enable testcases
Serhei Makarov [Fri, 22 Mar 2019 19:32:35 +0000 (15:32 -0400)]
stapbpf PR24358,PR23816 :: enable testcases

* testsuite/systemtap.bpf/nonbpf.exp: remove string3.stp from KFAILs.
(get_output_str): correct output str for string3,4.
* testsuite/systemtap.bpf/bpf.exp (get_output_str): correct output str for string3,4.

5 years agostapbpf PR24329,PR23816 :: Properly allocate space for map value lookup.
Serhei Makarov [Fri, 22 Mar 2019 19:28:48 +0000 (15:28 -0400)]
stapbpf PR24329,PR23816 :: Properly allocate space for map value lookup.

* stapbpf/bpfinterp.cxx (bpf_interpret): new vector map_values for map value storage,
get rid of lookup_tmp, replace return with branch to cleanup code for map_values,
properly allocate a correctly-sized buffer for each bpf_lookup_elem() operation,
cleanup map_values() on exit.
* stapbpf/bpfinterp.h (bpf_transport_context::map_attrs): new field used to pass
map size information to bpf_interpret.
(bpf_transport_context::bpf_transport_context): take map_attrs argument.
* stapbpf/stapbpf.cxx (init_perf_transport): pass map_attrs to bpf_transport_context.
(main): pass map_attrs to bpf_transport_context.

5 years agoPR24239 regression fix: global_access.exp
Frank Ch. Eigler [Fri, 22 Mar 2019 18:35:58 +0000 (14:35 -0400)]
PR24239 regression fix: global_access.exp

Copy over the new varuse parsing from embeddedcode to embedded_expr,
fixing the global_access.exp test case.

5 years agoFix the speculate.stp test
William Cohen [Fri, 22 Mar 2019 17:51:37 +0000 (13:51 -0400)]
Fix the speculate.stp test

The speculate.stp test used target variables for syscall.*.return
probes.  The changes to to the syscall tapsets to use non-dwarf
probes in most cases broke this example.  Added appropriate probes
on syscall syscall entries to record the needed information.

5 years agobrown paper bag fixes from last commit
Frank Ch. Eigler [Thu, 21 Mar 2019 22:11:19 +0000 (18:11 -0400)]
brown paper bag fixes from last commit

note to self - do not commit little diagnostic improvements after the
last build & check

note to self - do not forget above note to self again

note to self - ditto

5 years agoPR24239 PR24363 accelerate & correct embedded-c var-usage elaboration
Frank Ch. Eigler [Thu, 21 Mar 2019 21:53:16 +0000 (17:53 -0400)]
PR24239 PR24363 accelerate & correct embedded-c var-usage elaboration

mcermak noticed that recent PR24239 work broke resolution for script
globals referenced only from embedded-c functions, because at
symresolution-time, we didn't look inside those.  We now do, just
once, and store the resolved vardecl*'s in new embeddedcode fields.

This also means that we never have to search those strings for later
pragma:read:* and pragma:write:* again, just use the vectors produced
earlier.

NB: same transformation is still needed for the embedded_expr case.

5 years agoAdd more __NR_* for missing defines on s390x.
Martin Cermak [Wed, 20 Mar 2019 13:41:02 +0000 (14:41 +0100)]
Add more __NR_* for missing defines on s390x.

On 3.10.0-957.el7.s390x, bz1027459.exp showed missing defines causing
systemtap.base/bz1027459.stp Pass 4: compilation fail.

5 years agoMake testcase bz1027459.exp less sensitive to dwarf quality.
Martin Cermak [Wed, 20 Mar 2019 13:17:48 +0000 (14:17 +0100)]
Make testcase bz1027459.exp less sensitive to dwarf quality.

This update tries to avoid following type of problems:

=======
spawn stap /root/.mcermak/systemtap/testsuite/systemtap.base/bz1027459.stp
semantic error: not accessible at this address (pc: 0xc000000000a14f28) [man error::dwarf]: identifier '$call' at /usr/local/share/systemtap/tapset/linux/sysc_accept.stp:68:14
        dieoffset: 0x57216fd from /usr/lib/debug/lib/modules/4.14.0-115.el7a.ppc64le/vmlinux
        function: SyS_socketcall at net/socket.c:2438
        alternative locations: [0xc000000000a14f30,0xc000000000a14f7c], [0xc000000000a14f7c,0xc000000000a153e8]
        source:         if (__int32($call) != @const("SYS_ACCEPT")) next;
=======

This one was happening e.g. with kernel-4.14.0-115.el7a.ppc64le.

5 years agoAdapt testcase bz1027459.exp to commit 126c384c.
Martin Cermak [Wed, 20 Mar 2019 13:06:58 +0000 (14:06 +0100)]
Adapt testcase bz1027459.exp to commit 126c384c.

Commit 126c384c causes bz1027459.stp to warn about cross-file global variable
reference to identifier 'syscall_string_trunc' at linux/syscalls_cfg_trunc.stp.
After this update, the testcase ignores warnings like this.

5 years agoFix trivial ppc64* compilation issue.
Martin Cermak [Wed, 20 Mar 2019 08:50:47 +0000 (09:50 +0100)]
Fix trivial ppc64* compilation issue.

Before this update, GCC on powerpc complained about stapbpf.cxx:1504:35: error:
format ‘%lld’ expects argument of type ‘long long int’, but argument 3 has type
‘__u64 {aka long unsigned int}’.

5 years agoOptimize nettop.stp example
William Cohen [Tue, 19 Mar 2019 20:04:43 +0000 (16:04 -0400)]
Optimize nettop.stp example

Restructured the script to eliminate two foreach loops in
print_activty() to sum transmit and receive entries.  Instead, just
tallied those directly into global statistical aggregate ifmerge
entries, then just have a single foreach loop print_activity() to
print the entries.  Eliminated the unneeded trinary operators, since
the @sum() of nonexistent entry is 0.

Also adjusted the formatting so long device names do not skew the
columns.

5 years agoOptimize sig_by_pid.stp, sig_by_proc.stp, and syscalls_by_proc.stp
William Cohen [Tue, 19 Mar 2019 18:48:02 +0000 (14:48 -0400)]
Optimize sig_by_pid.stp, sig_by_proc.stp, and syscalls_by_proc.stp

The probe points being used in these examples could be hit quite
frequently.  Using the statistical aggregates can reduce the amount of
locking required in the associated probe handlers and allow the probe
handlers to complete more quickly, reducing the amount of overhead
that the instrumentation introduces.

5 years agoUse statistical aggregates in iodevstats.stp, iostats.stp, and iotop.stp
William Cohen [Tue, 19 Mar 2019 18:18:31 +0000 (14:18 -0400)]
Use statistical aggregates in iodevstats.stp, iostats.stp, and iotop.stp

The vfs.read.return and vfs.write.return probe points being used in
these examples could be hit quite frequently.  Using the statistical
aggregates can reduce the amount of locking required in the associated
probe handlers and allow the probe handlers to complete more quickly,
reducing the amount of overhead that the instrumentation introduces.

5 years agoMerge branch 'stapbpf/pr22330': generate printf via event tuples, userspace formattin...
Serhei Makarov [Tue, 19 Mar 2019 15:29:25 +0000 (11:29 -0400)]
Merge branch 'stapbpf/pr22330': generate printf via event tuples, userspace formatting postprocessing

This merges a simple transport layer design which uses
perf_events to send each printf as a series of messages,
freeing stapbpf from the deliberately-oppressive constraints
of the trace_printk() mechanism.

e.g. printf("%8d %8d %6s\n", x, y, foo) is sent as

- STP_PRINTF_START(3)
- STP_PRINTF_FORMAT(#1) -> index into a table of format strings
- STP_PRINTF_ARG_LONG(x)
- STP_PRINTF_ARG_LONG(y)
- STP_PRINTF_ARG_STR(foo) -> requires an strcpy() to compose the message
- STP_PRINTF_END()

Which involves six calls to BPF_perf_event_output from
the kernel-side BPF program. Each CPU has its own perf_events
buffer to avoid entangling parallel printfs().

For now, use separate messages to avoid putting pressure on the
very limited stack and avoid complicated packing code. Further
down the line, we could combine small (LONG) arguments into
a several-argument message, or merge STP_PRINTF_START and STP_PRINTF_FORMAT.

5 years agoUse statistical aggregates to reduce overhead and contention for global array
William Cohen [Tue, 19 Mar 2019 00:23:19 +0000 (20:23 -0400)]
Use statistical aggregates to reduce overhead and contention for global array

Statistical aggregates record and update information on a per cpu
basis.  This avoids the lock needed by the ++ operation previously
used.  For monitoring of high frequency events such as system calls
across the entire machine this can improve performance.

5 years agostapbpf PR22330 cleanup and fixes :: note PR24358 may affect code in bpfinterp.cxx
Serhei Makarov [Mon, 18 Mar 2019 15:33:47 +0000 (11:33 -0400)]
stapbpf PR22330 cleanup and fixes :: note PR24358 may affect code in bpfinterp.cxx

5 years agostapbpf PR22330 fix :: support for non-contiguous active cpus
Serhei Makarov [Fri, 15 Mar 2019 20:00:16 +0000 (16:00 -0400)]
stapbpf PR22330 fix :: support for non-contiguous active cpus

This is rather rudimentary (e.g. would be good to listen for cpus
coming online / going offline during the script execution). But
there is a minimum fix needed to ensure stapbpf doesn't break completely
if the CPU arrangement is unusual.

* stapbpf/stapbpf.cxx (cpu_online): new vector tracking active cpus.
(CPUFS, CPUS_ONLINE, CPUS_POSSIBLE): new defines pointing to /sys/devices/system/cpu/.
(mark_active_cpus): new function to parse /sys/devices/system/cpu/online.
Parsing a diagnostic file is not my favourite approach
but I haven't found a better API for this yet.
(count_active_cpus): new function to return number of active (marked) cpus.
(instantiate_maps): invoke mark_active_cpus() when setting up perf_events map.
(init_perf_transport): skip perf transport setup for inactive cpus.
(perf_event_loop): only set up poll_fds for active cpus.

5 years agostapbpf PR22330,PR23816 :: add testcases
Serhei Makarov [Thu, 14 Mar 2019 17:37:50 +0000 (13:37 -0400)]
stapbpf PR22330,PR23816 :: add testcases

5 years agostapbpf PR22330 :: cleanup round 3 of n (sprintf typo fix)
Serhei Makarov [Thu, 14 Mar 2019 17:35:28 +0000 (13:35 -0400)]
stapbpf PR22330 :: cleanup round 3 of n (sprintf typo fix)

5 years agostapbpf PR22330 :: cleanup round 2 of n
Serhei Makarov [Thu, 14 Mar 2019 16:18:39 +0000 (12:18 -0400)]
stapbpf PR22330 :: cleanup round 2 of n

5 years agoPR24327: Remove printing of unused synthetic globals
Jafeer Uddin [Wed, 13 Mar 2019 20:12:45 +0000 (16:12 -0400)]
PR24327: Remove printing of unused synthetic globals

The handling of DW_OP_GNU_entry_value introduces synthetic
global variables that after optimizations may end up not
being used. The default behaviour is to print out the values
of unsued globals in user scripts. This printing is intended
for user defined globals and shouldn't occur with the generated
globals.

5 years agoMake varwatch.stp work regardless of kprocess.release and a bit more flexible
William Cohen [Wed, 13 Mar 2019 19:24:32 +0000 (15:24 -0400)]
Make varwatch.stp work regardless of kprocess.release and a bit more flexible

With newer kernels the kprocess.release is inlined in some places and
the desired argument $p is unavailable.  Make the script just over
writing over older entries in the var associative array.

The script would only work for variables that resulted in strings.
Someone may want to use this script to monitor a single variable that
is an integer.  Having the probe never force the associative array
store strings will cause a problem for monitoring a single integer
variable.  Removed the probe never as the normal use cases of this
script will have something set the type of the associative array.  If
it doesn't, there aren't any value changes to monitor.

5 years agostapbpf PR22330 fixes :: identify format types of pe_unknown arguments
Serhei Makarov [Tue, 12 Mar 2019 17:45:45 +0000 (13:45 -0400)]
stapbpf PR22330 fixes :: identify format types of pe_unknown arguments

* bpf-translate.cxx (bpf_unparser::emit_print_format): take tok for diagnostics,
extract non-literal printf components and pass them to printf_arg_type;
signal an error if the number of printf components doesnt' match the number of args.
(printf_arg_type): take format_component argument and use it to infer the
format type in the case of pe_unknown arguments.
(bpf_unparser::emit_transport_msg): pick format_type based on perf_event_type,
which was inferred from the format string in the case of pe_unknown arguments.
(bpf_unparser::visit_embeddedcode): pass tok to emit_print_format.
(bpf_unparser::visit_print_format): remove some old TODOs, pass tok to emit_print_format.

5 years agostapbpf emit_string_copy() fix :: handle the case of src == NULL
Serhei Makarov [Mon, 11 Mar 2019 19:29:32 +0000 (15:29 -0400)]
stapbpf emit_string_copy() fix :: handle the case of src == NULL

Sometimes a string variable can end up containing NULL (e.g. on map lookup).
This upsets the verifier terribly if the string is passed to emit_string_copy().

NULL case was previously unhandled as trace_printk() did not require a
string copy and did not care about being given a NULL argument
(although it did have an annoying behaviour of silently dropping
the entire printf).

Replace this with a more robust assumption that NULL ~~ "".

* bpf-translate.cxx (emit_simple_literal_str): take const string as input.
(emit_string_copy): rename join_block to return_block,
copy "" string if src == NULL (using zero-pad code if zero_pad is true
and using a call to emit_simple_literal_str otherwise).
* bpf-internal.h (emit_simple_literal_str): take const string as input.

5 years agostapbpf PR22330 WIP :: transport layer bugfixes and cleanup, round 1 of n
Serhei Makarov [Mon, 11 Mar 2019 17:51:33 +0000 (13:51 -0400)]
stapbpf PR22330 WIP :: transport layer bugfixes and cleanup, round 1 of n

There are still testsuite regressions that need to be fixed after this.

* bpf-translate.cxx (bpf_unparser::emit_transport_msg): Fix for non-literal string args,
fix to code for ensuring double-word alignment of transport message.
* stapbpf/bpfinterp.cxx (bpf_sprintf): TODO Need to support more sprintf arguments.
(bpf_handle_transport_msg): remove debug print, make sure to flush after printing.
* stapbpf.cxx (perf_event_loop): handle EINTR as an ordinary occurrence (from ^C),
common code between exit from EINTR and exit from STP_EXIT message.
(main): Reorder ioctl to enable kprobes, now after launching perf_events listener.
* bpfinterp.cxx (bpf_handle_transport_msg): Fix to handle LONG arguments properly!!!

5 years agostapbpf PR22330 WIP :: assembler tweaks to support _send_exit_msg()
Serhei Makarov [Mon, 11 Mar 2019 17:45:26 +0000 (13:45 -0400)]
stapbpf PR22330 WIP :: assembler tweaks to support _send_exit_msg()

Fixed _send_exit_msg() with a couple of assembly aids to make the code less error-prone.

* bpf_translate.cxx (asm_stmt::align_alloc): New field to force alignment.
(bpf_unparser::parse_imm): Support BPF_F_CURRENT_CPU as a constant.
(bpf_unparser::parse_asm_stmt): Optional 3rd (align|noalign) argument for alloc.
(bpf_unparser::emit_asm_arg): Support BPF_F_CURRENT_CPU as a constant.
(bpf_unparser::visit_embeddedcode): Align to double-word if align_alloc == true.

* tapset/bpf/exit.stp (_send_exit_msg): Fix alignment err, use assembly enhancements.
* tapset/logging.stp (abort): Remove redundant _set_exit_status() call.

5 years agostapbpf PR22330 WIP :: change exit.stp to send perf_events message
Serhei Makarov [Fri, 8 Mar 2019 22:53:48 +0000 (17:53 -0500)]
stapbpf PR22330 WIP :: change exit.stp to send perf_events message

* tapset/bpf/exit.stp (_set_exit_status): comment fix.
(_send_exit_msg): new embedded-code function sending STP_EXIT.
* tapset/logging.stp (exit): switch to using _send_exit_msg.

5 years agostapbpf assembly :: add pseudoregister (= this_in_arg0) to emit_asm_arg
Serhei Makarov [Fri, 8 Mar 2019 22:52:26 +0000 (17:52 -0500)]
stapbpf assembly :: add pseudoregister  (= this_in_arg0) to emit_asm_arg

5 years agostapbpf PR22330 WIP :: add interned strings section to the ELF file, invoke fprintf
Serhei Makarov [Fri, 8 Mar 2019 21:48:13 +0000 (16:48 -0500)]
stapbpf PR22330 WIP :: add interned strings section to the ELF file, invoke fprintf

* bpf-internal.h (globals::intern_string): move from standalone intern_str() in bpf-translate.cxx.
(globals::interned_strings): rename from interned_str_map, change to vector.
(globals::interned_str_map): rename from interned_strings.
* bpf-translate.cxx (globals::intern_string): move from standalone intern_str() in bpf-translate.cxx,
adapt to changing fields in globals.
(bpf_unparser::emit_transport_msg): remove USE_INTERNED_STR define (we will always do this),
use BPF_TRANSPORT_ARG instead of magic number,
adapt to moved globals::intern_string.
(output_stapbpf_script_name): populate missing data->d_type.
(output_interned_strings): new function generating pseudo-STRTAB-ish section with format strings.
(bpf_unparser::add_prologue): call output_interned_strings() after codegen.

* stapbpf/stapbpf.cxx (interned_strings): new vector -- global table of interned strings.
(init_perf_transport): pass interned_strings at transport_context creation.
(load_bpf_file): locate and parse stapbpf_interned_strings pseudo-STRTAB-ish section,
populate global interned_strings.
(main): pass interned_strings at transport_context creation.
* stapbpf/bpfinterp.h (bpf_transport_context::interned_strings): new field referencing global strings table.
(bpf_transport_context::printf_format): delete unneeded field.
(bpf_transport_context::bpf_transport_context): adapt to changing fields.
* stapbpf/bpfinterp.cxx (bpf_handle_transport_msg): check for ctx->format_no out of bounds,
retrieve format_str from ctx->interned_strings,
generate an ugly hardcoded call to fprintf with 32 arguments.

5 years agostapbpf PR22330 WIP :: decode perf_events arguments
Serhei Makarov [Fri, 8 Mar 2019 17:59:57 +0000 (12:59 -0500)]
stapbpf PR22330 WIP :: decode perf_events arguments

* stapbpf/bpfinterp.h (bpf_transport_context): new data structure
to hold in-progress transport calls and references to needed global state.
(bpf_handle_transport_msg): new function.
(bpf_interpret): change to take a bpf_transport_context.
* stapbpf/bpfinterp.cxx (bpf_handle_transport_msg): WIP new function;
decodes and handles transport message.
(bpf_interpret): change to take a bpf_transport_context;
add a handler for BPF_FUNC_perf_event_output.

* stapbpf/stapbpf.cxx (transport_contexts): new array;
holds a transport_context for each perf_events fd to disentangle printf() from different threads.
(init_internal_globals): fix errno usage.
(init_perf_transport): new function (separated out from init_internal_globals);
in addition to creating perf_event fds, create a transport_context for each one.
(struct perf_event_sample): new structure; apparently this is the format we get perf_events in.
(perf_event_handle): fill in implementation inspired by kernel tools/testing/selftests/bpf/trace_helpers.c
(perf_event_loop): change error handling,
add STP_EXIT handling,
avoid issuing multiple warnings.
(main): add init_perf_transport() call,
use modified bpf_interpret() interface,
clean up transport_contexts.

* bpf-internal.h (BPF_TRANSPORT_VAL): new define for message format.
(BPF_TRANSPORT_ARG): new define for message format.
(globals::STP_PRINTF_ARG_LONG): specify arg type; replaces STP_PRINTF_ARG.
(globals::STP_PRINTF_ARG_STR): specify arg type; replaces STP_PRINT_ARG.
* bpf-translate.cxx (bpf_unparser::emit_transport_msg): use BPF_TRANSPORT_* defines.
(printf_arg_type): new function; choose correct STP_PRINTF_ARG_*.
(bpf_unparser::emit_print_format): use printf_arg_type.

* stapbpf/libbpf.c (ring_buffer_write_*): comment tweak.

5 years agoPR16596, PR24224: rework handling of DW_OP_GNU_entry_value
Jafeer Uddin [Tue, 5 Mar 2019 14:48:28 +0000 (09:48 -0500)]
PR16596, PR24224: rework handling of DW_OP_GNU_entry_value

The DW_OP_GNU_entry_value handling introduced in commit 68bd23fd0cc
wasn't complete. The value being passed in for addr in dwarf_derived_probe
was not correct for all cases and gave 'inconsistent-relocation-address'
errors. Also the implementation was only able to place entry probes at the
beginning of the function being probed and doesn't handle the case where
you may need to add an entry probe for a different function.

5 years agoDo the search save_stack_trace_regs() in the stap module's initialization wcohen/backtrace
William Cohen [Thu, 7 Mar 2019 14:37:53 +0000 (09:37 -0500)]
Do the search save_stack_trace_regs() in the stap module's initialization

Previously, the search for save_stack_trace_regs() was done the first
time the _stp_stack_print_fallback was called. However, want to avoid
calling kallsyms_lookup_name() in some arbitrary probe handler as it
may take a signficant amount of time to search for
save_stack_trace_regs().  Moving this search to where other
initialization operations are done and there are fewer contraints on
runninging it.

5 years agoUse kallsyms_lookup_name to find save_stack_trace_regs() for fallback unwind
William Cohen [Wed, 6 Mar 2019 21:39:12 +0000 (16:39 -0500)]
Use kallsyms_lookup_name to find save_stack_trace_regs() for fallback unwind

This simplifies the fallback unwinding code to use
save_stack_trace_reg() if it is available.  The save_stack_trace_reg()
is available on more architectures. This eliminates the code using the
x86 specific unwind_start(), unwind_done(), and
unwind_get_return_address() functions.

5 years agostapbpf PR22330 WIP :: deliver perf_events on correct cpu, poll with timeout
Serhei Makarov [Tue, 5 Mar 2019 20:16:41 +0000 (15:16 -0500)]
stapbpf PR22330 WIP :: deliver perf_events on correct cpu, poll with timeout

* stapbpf/stapbpf.cxx (instantiate_maps): TODO issue with CPU numbering.
(init_internal_globals): zero pe_attr every time,
notify on the very first event,
fix typo in bpf_map_update call,
add diagnostic output for log_level>2.
(perf_event_loop): poll at an interval (1000),
add diagnostic output for log_level>2.

5 years agoIf available, use kernel's save_stack_trace_regs() for fallback stack unwind
William Cohen [Mon, 4 Mar 2019 16:14:31 +0000 (11:14 -0500)]
If available, use kernel's save_stack_trace_regs() for fallback stack unwind

When the dwarf information is unavailable SystemTap resorts to
alterntive mechanisms to unwinds the stack. Only the x86 kernels have
unwind_start(), unwind_done(), and unwind_get_return_address().  A
number of architectures including the s390, powerpc, and openrisc
currently export save_stack_trace_reg() and expect that this will be
available on additional architectures such as arm64 in the future.
Adding a test to check for the export of the function and use it where
possible.

5 years agoAlso, /dev/kmsg should probably be opened 'w'
Serhei Makarov [Fri, 1 Mar 2019 16:57:36 +0000 (11:57 -0500)]
Also, /dev/kmsg should probably be opened 'w'

5 years agoDon't print to /dev/kmsg if it's unavailable
Serhei Makarov [Fri, 1 Mar 2019 16:16:32 +0000 (11:16 -0500)]
Don't print to /dev/kmsg if it's unavailable

* stapbpf/stapbpf.cxx (kmsg): initialize to NULL.
(prog_load): only print to kmsg if it's available.
(main): warn if kmsg is unavailable.

5 years agotestsuite/systemtap.bpf :: tests should return, not exit 0
Serhei Makarov [Fri, 1 Mar 2019 15:11:27 +0000 (10:11 -0500)]
testsuite/systemtap.bpf :: tests should return, not exit 0

5 years agocachestat.stp: workaround the current limitations of trace_printk
Serhei Makarov [Thu, 28 Feb 2019 16:57:51 +0000 (11:57 -0500)]
cachestat.stp: workaround the current limitations of trace_printk

5 years agoNewer kernels tapsets may use the kprobe.function("*") adjust alias_tapset.exp.
William Cohen [Wed, 27 Feb 2019 19:14:44 +0000 (14:14 -0500)]
Newer kernels tapsets may use the kprobe.function("*") adjust alias_tapset.exp.

This page took 0.063029 seconds and 5 git commands to generate.