[DTrace-devel] [oracle/dtrace-utils] 2479ce: Extirpate longlong_t and u_longlong_t from C

Kris Van Hees noreply at github.com
Tue Sep 13 23:21:28 UTC 2022


  Branch: refs/heads/dev
  Home:   https://github.com/oracle/dtrace-utils
  Commit: 2479ce96993197c22b789dd0b4c348dce2d46bb3
      https://github.com/oracle/dtrace-utils/commit/2479ce96993197c22b789dd0b4c348dce2d46bb3
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M cmd/Build
    M libdtrace/Build
    M libdtrace/dt_consume.c
    M libdtrace/dt_dis.c
    M libdtrace/dt_handle.c
    M libdtrace/dt_ident.c
    M libdtrace/dt_link.c
    M libdtrace/dt_parser.c
    M libdtrace/dt_pid.c
    M libdtrace/dt_printf.c
    M libdtrace/dt_subr.c
    M libproc/Build
    M uts/common/sys/dtrace_types.h

  Log Message:
  -----------
  Extirpate longlong_t and u_longlong_t from C

These constants have to stay in the D layer (like all the other
obsolescent integral *_t constants, people might be relying on them) but
on the C layer DTrace builds with -std=gnu99, so we can absolutely
guarantee that both long long and unsigned long long already exist (and
the codebase already uses them, and GCC has supported them for many
years longer in any case).

So drop them as redundant.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 70c8d23565a68a1265983319ead173adcf6abbc3
      https://github.com/oracle/dtrace-utils/commit/70c8d23565a68a1265983319ead173adcf6abbc3
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libproc/rtld_db.c

  Log Message:
  -----------
  proc: refactor find_link_maps out of find_l_searchlist

I originally thought I'd be using this in the dl_nns search;
after doing it, it was so much clearer than what was there before that I
left it refactored out even though I ended up not using it in the dl_nns
search after all.

A purely mechanical transformation other than varible-name changes
(because 'loadobj' is a terrible name I've long wanted to change).

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 1274bb28da31c4e5073b846f57ae7a35fa8a5ed1
      https://github.com/oracle/dtrace-utils/commit/1274bb28da31c4e5073b846f57ae7a35fa8a5ed1
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libproc/Pcontrol.h
    M libproc/mkoffsets.sh
    M libproc/rtld_db.c

  Log Message:
  -----------
  libproc: dynamically search for elements of the rtld_global structure

On glibc < 2.35 (with r_version 1), there is no rtld support for
multiple lmids, so rtld_db needs to fish the necessary data directly out
of glibc internal data structures.  However, as with link_map (see
commit d1d38404d44ff000) this is not at all ABI-stable. After many
decades of total stability the struct link_namespaces at the head of
this structure changed repeatedly in the 2.31 -- 2.34 timeframe, mostly
to fix race conditions, and it's an array[DL_NNS] so even small changes
have large consequences for offsets of elements beyond this structure:
so we have to hunt for everything we need in this structure dynamically
(because even elements at the start, like _ns_nloaded, are going to
have the offsets of subsequent elements in the array move around when
struct link_namespaces grows, and elements after that array in
rtld_global will move even more).

This is quite hard to scan for because (unlike find_l_searchlist) we can
rely on hardly anything for verification: the first lmid tells us almost
nothing, since most of the elements we need lie above the point of
change, and subsequent lmids are almost (but not entirely) certain to be
uninitialized and thus all-zero.

But we can cheat!  As the code comments note, the field we are
interested in (dl_nns) immediately follows a pointer in all versions of
glibc we care about: and pointers in struct link_namespace are either
value 0 in uninitialized lmids or huge (definitely greater than value of
DL_NNS, which is a fixed 16 in all supported glibc versions): and the
integral fields therein are also nonzero only when the lmid is
initialized.  If the last lmid is initialized we can't really do
anything: there are lots of fields with a pointer followed by a small
integral value.  But this is massively unlikely: glibc < 2.35 cannot
even start that many lmids without having some of them entirely detached
from libc because of in-glibc TLS consumption overflowing the space
allocated for it, and there is no supported way to start an lmid
detached from glibc. So we can rely on looking for a pair of
pointer-aligned fields satisfying (0, 0 < dl_nns < DL_NNS): the second
such field is the dl_nns.  We can then figure out both the offset of all
the other fields after it by offsetting them from the computed dl_nns
offset, and the size of struct link_namespace (which has no padding
following the structure in any supported glibc version, and glibc relies
on this property); and thus determine both the offsets of fields late in
struct link_namespace and the offsets of fields in nonzero lmids.

Unfortunately because most of these fields (other than dl_nns == 1) only
go nonzero when multiple lmids are in use (which is rare) or when
dlopen() is being called in the child (also rare), we can't really
verify our guesses the way we could for l_searchlist.  The existing
verification that when we look up a symbol in a nonzero lmid it actually
comes from a nonzero lmid will have to do.  This will almost certainly
be good enough, particularly given that all this machinery will be
disabled in favour of documented facilities when the victim is a binary
running against glibc 2.35+.

Orabug: 32856318
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: be97c241c3a66bef514f8d0c33cf60a2d78468c3
      https://github.com/oracle/dtrace-utils/commit/be97c241c3a66bef514f8d0c33cf60a2d78468c3
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  memcpy: error-check

This FIXME is pretty easy to implement.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 905a1b699bba0e2be873f7a5cd6b6ccfe2979c7a
      https://github.com/oracle/dtrace-utils/commit/905a1b699bba0e2be873f7a5cd6b6ccfe2979c7a
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  cg: comment typo fix

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 4bfeea99b45b9dc9d2599027c5f5c9437e97d3bb
      https://github.com/oracle/dtrace-utils/commit/4bfeea99b45b9dc9d2599027c5f5c9437e97d3bb
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cc.c

  Log Message:
  -----------
  bpf: don't throw away CTF errors when doing relocations

The first type lookup done after translators are parsed is the set done
to relocate CTF-related offsets.  If something is wrong with the CTF and
the translators are missing, these lookups are likely to fail -- but
since most of these lookups don't set dt_ctferr, the actual error is
discarded and the only thing reported to the user is "unknown CTF
error".  Not even CTF debugging helps.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: fa86bcce583ce0a8efaf49433074005df46bc66b
      https://github.com/oracle/dtrace-utils/commit/fa86bcce583ce0a8efaf49433074005df46bc66b
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  tests: always check expected results as text, not binary

Even if we get \0 in results, we want to see the output, not helpful
"binary files differ" messages.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: d1d4ea8aeb620d344e1d9a61b75c682de938c550
      https://github.com/oracle/dtrace-utils/commit/d1d4ea8aeb620d344e1d9a61b75c682de938c550
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M test/unittest/error/tst.fault-location.sh

  Log Message:
  -----------
  tests: add descriptive comment to fault-location.sh

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: d69076cea83af4c4612e9290ea7eea6e78509c7e
      https://github.com/oracle/dtrace-utils/commit/d69076cea83af4c4612e9290ea7eea6e78509c7e
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_dlibs.c

  Log Message:
  -----------
  dlibs: improve load-time errors

This corrects errors you get at BPF dlib load time from

dtrace: failed to compile script X: Success

to e.g.

dtrace: failed to compile script X: undefined symbol DTRACEFLT_BADADDR in BPF dlib

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: fa9f01031260e2e2c9da1280d4da7e780f7ec880
      https://github.com/oracle/dtrace-utils/commit/fa9f01031260e2e2c9da1280d4da7e780f7ec880
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/procfs.d.in

  Log Message:
  -----------
  translators: procfs.d: rename projid_t

The Linux kernel already has a type named projid_t, with a definition
that conflicts with that in use (for an unused field) by this
translator.  libctf correctly diagnoses this as a conflict (where
libdtrace-ctf didn't): rename the type in the translator.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 3743a5260e3eee8a65054729185d80c61f6d8594
      https://github.com/oracle/dtrace-utils/commit/3743a5260e3eee8a65054729185d80c61f6d8594
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M runtest.sh
    M test/unittest/providers/tst.dtrace_cleanup.sh

  Log Message:
  -----------
  runtest: pass timeouts down to tests: use it in one test

A few tests implement their own timeouts to let them see whether dtrace
has started up properly.  This is less than ideal when valgrind is in
use, since that routinely causes startup to slow down by an order of
magnitude.  The runtest script adapts the script-wide timeout, but
this is not passed down to tests so they cannot do the same even if
they wanted to.

So pass down $timeout, and adjust one test that spuriously fails.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 5f9f704080fdd40c35212e92ddaba61dc7a9cf59
      https://github.com/oracle/dtrace-utils/commit/5f9f704080fdd40c35212e92ddaba61dc7a9cf59
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_module.c

  Log Message:
  -----------
  modules: fix can-never-fail comparison

Spotted by GCC 11.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f861581e658fcfd89585b8e92bc738fdd41b6065
      https://github.com/oracle/dtrace-utils/commit/f861581e658fcfd89585b8e92bc738fdd41b6065
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dtrace.h

  Log Message:
  -----------
  drop obsolete GCC bug workaround

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 3a1181f9ff6c05affb4142682007cc1dd47c0c3c
      https://github.com/oracle/dtrace-utils/commit/3a1181f9ff6c05affb4142682007cc1dd47c0c3c
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M runtest.sh
    A test/unittest/dtrace-util/tst.runopt-e.d
    A test/unittest/dtrace-util/tst.runopt-e.r

  Log Message:
  -----------
  test: allow test options to be set to "-e"

The curse of echo caught us again.  Using printf keeps the -e, but even
then we have to doble-quote the argument because one layer of quotes
will be eaten by the eval, and printf with more args than format string
args reuses the format string over and over again: if it's %s, this
effectively squashes the args together with intervening spaces removed.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 63a1ab5c2dfd18bc85d3bfc745cc840582e76267
      https://github.com/oracle/dtrace-utils/commit/63a1ab5c2dfd18bc85d3bfc745cc840582e76267
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M cmd/dtrace.c
    A test/unittest/dtrace-util/err.MultipleNonOptFlags.d

  Log Message:
  -----------
  cmd: fix multiple args after --

The existing options-parsing machinery in cmd/dtrace.c uses getopt
inside a for loop, with the loop governed by optind.  The purpose of
this is opaque to me: the getopt is *already* in a while loop which
won't terminate until the job is done... but if more than one arg is
found after that (say, if argv contains a -- so getopt terminates
early), the next iteration of the loop will call getopt again, which
will *reset* optind and restart parsing.  Because extra arguments are
pasted into g_argv, which is sized suitably for argc to start with, this
leads to an infloop, a rapid buffer overflow, and a segfault.

(This is probably non-exploitable because a) it's dying in main()
itself, which is rather special and b) it never returns.)

The handling of getopt has changed repeatedly in the course of
development. In the Solaris days, the getopt string did not start with
+, so the argument string was permuted and when getopt terminated all
remaining entries were non-options -- but the loop still consumes only
one of them before restarting getopt, so the crash is still present.  in
commit e46e2e15d270aba3f78a904be7a76c8e9fc66c17 in 2010, we switched to
POSIXLY_CORRECT for unclear reasons; this had no obviouspositive
effects, but prevented things like -i 10 20 -n ... from working; we then
switched to using + in the optstring instead, which fixed that but left
this bug still present.

DTrace is not sensitive to the relative order of options and non-options
(only to the relative order of non-options with other non-options), so
we don't need + (or -), and indeed this is harmful because if the inner
loop spots a non-option it emits a usage message (so it relies on getopt
doing permutation of non-options to appear after options, which +
prevents).

Fix by doing what almost everything else that uses getopt does, dropping
the overrun-inducing outer for loop, and doing the storage of trailing
non-option arguments in a subsequent loop after the getopt, relying on
getopt's permutation of argc and setting of optind.

(Redo the other two getopt loops similarly, even though they don't
overrun. Nearly all the diff here is indentation changes.  There is no
code change: they both process only options, so the permutation carried
out by the first getopt has no effect on them.)

Add a test for this.  No other tests are affected.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: febf4570839935909c3081884c01e73d7404ef90
      https://github.com/oracle/dtrace-utils/commit/febf4570839935909c3081884c01e73d7404ef90
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    M libdtrace/dt_parser.c
    M libdtrace/dt_parser.h
    M test/unittest/arrays/tst.ctf-bounds.d
    M test/unittest/arrays/tst.ctf-bounds.oob-cast.d
    M test/unittest/arrays/tst.declared-bounds.oob-cast.d
    M test/unittest/builtinvar/tst.hpriority.d
    M test/unittest/builtinvar/tst.lwpsinfo.d
    M test/unittest/builtinvar/tst.lwpsinfo1.d
    A test/unittest/codegen/tst.kernel_read_deref_indirect_scalar.d
    A test/unittest/codegen/tst.kernel_read_deref_indirect_str.d
    A test/unittest/codegen/tst.kernel_read_deref_struct.d
    A test/unittest/codegen/tst.kernel_read_index_indirect_str.d
    A test/unittest/codegen/tst.kernel_read_indirect_scalar.d
    A test/unittest/codegen/tst.kernel_read_mixed.d
    A test/unittest/codegen/tst.kernel_read_neg_small_scalar.aarch64.x
    A test/unittest/codegen/tst.kernel_read_neg_small_scalar.d
    A test/unittest/codegen/tst.kernel_read_neg_small_scalar.r
    A test/unittest/codegen/tst.kernel_read_scalar.d
    A test/unittest/codegen/tst.kernel_read_scalar_regspill.d
    A test/unittest/codegen/tst.kernel_read_scalar_regspill.r
    A test/unittest/codegen/tst.kernel_read_scalar_regspill.r.p
    A test/unittest/codegen/tst.kernel_read_str.d
    A test/unittest/codegen/tst.kernel_read_str.r.p
    A test/unittest/codegen/tst.read_index_indirect_str.d
    M test/unittest/funcs/tst.bcopy.d
    M test/unittest/inline/tst.InlineTypedef.d
    M test/unittest/lexer/tst.keyword-member.d
    M test/unittest/pointers/tst.ArrayPointer2.d
    M test/unittest/pointers/tst.ArrayPointer3.d
    M test/unittest/pointers/tst.GlobalVar.d
    M test/unittest/pointers/tst.IntegerArithmetic1.d
    M test/unittest/pointers/tst.PointerArithmetic2.d
    M test/unittest/pointers/tst.VoidCast.d
    M test/unittest/pointers/tst.basic1.d
    M test/unittest/printf/tst.str.d
    M test/unittest/sched/tst.var-curcpu.d
    M test/unittest/trace/tst.misc.d
    M test/unittest/translators/tst.TestTransStability.d
    M test/unittest/vars/tst.gid.d

  Log Message:
  -----------
  Support loading scalars from kernel addresses

Data access for non-scalar datatypes was implemented using the
probe_read() BPF helper while scalar datatypes were accessed using
load and store instructions.  When loading scalar data from kernel
addresses, a load instruction cannot be used.  This patch ensures
that such accesses use the probe_read() BPF helper.  (Storing to
kernel addresses is not supported by DTrace so that case does not
need special handling.)

The new dt_cg_load_scalar() function implements the scalar kernel
access.

A new node flag is introduced: DT_NF_DPTR.  It is set for any pointer
that is known to be an internal pointer (i.e. address of a location
in a BPF map managed by DTrace).  Such pointers can be dereferenced
with a load instruction.  All other cases use dt_cg_load_scalar().
The DT_NF_DPTR is propagated across =, +, and -.

Comments and code about DT_NF_USERLAND save/restore across dt_cg_ldsize()
have been removed - they are no longer relevant.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: a22be078bc93ec136bf5230b63005c431a91c141
      https://github.com/oracle/dtrace-utils/commit/a22be078bc93ec136bf5230b63005c431a91c141
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Remove obsolete register allocation

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 7fc281025a7a7b1f84c26f01565aca1978f2f0ff
      https://github.com/oracle/dtrace-utils/commit/7fc281025a7a7b1f84c26f01565aca1978f2f0ff
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/funcs/alloca/err.alloca-too-large.d

  Log Message:
  -----------
  Fix alloca() non-constant size check

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 9c76750205d928f5aac85e87aaf20ff91177b878
      https://github.com/oracle/dtrace-utils/commit/9c76750205d928f5aac85e87aaf20ff91177b878
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cc.c
    M libdtrace/dt_dlibs.c
    M libdtrace/dtrace.h
    A test/unittest/options/err.D_PRAGCTL_INVAL.no-cpp.d
    A test/unittest/options/tst.cpp.d

  Log Message:
  -----------
  Fix the -xcpp option

The -xcpp option should be equivalent to the -C option.  The -xcpp
option set DTRACE_C_CPP in the dt_cflags, but the compiler only
ever checked the cflags passed from the command line program for
the DTRACE_C_CPP flag.  As a result, only -C had the intended
behaviour whereas -xcpp was essentially ignored.

When a non-D library script is compiled and the DTRACE_C_CPP flag is
set in dt_cflags, it is also set in the cflags used by the compiler.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: ac2b60601fd05e37ae8ce746d3267dcf3e6c2916
      https://github.com/oracle/dtrace-utils/commit/ac2b60601fd05e37ae8ce746d3267dcf3e6c2916
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M cmd/dtrace.c
    M libdtrace/dt_cc.c
    M libdtrace/dt_open.c
    M libdtrace/dtrace.h
    M libdtrace/libdtrace.ver
    A test/unittest/options/err.ctfpath.d
    A test/unittest/options/err.ctfpath.r
    A test/unittest/options/tst.ctfpath.r
    A test/unittest/options/tst.ctfpath.sh

  Log Message:
  -----------
  Fix the -xctfpath option

The -xctfpath option was (along with all other options) being processed
after dtrace_open().  But the implementation of dtrace_open() included
the instantiation of providers and probes that triggers the loading of
the CTF archive.  As such, this option had no effect.

Instantiation of providers and probes has been moved to a new function:
dtrace_init().  This function is called after all command line options
have been processed, ensuring that -xctfpath sets the pathname to the
CTF archive before it is loaded.

If the CTF rchive specified with -xctfpath (or the default one) is not
valid, a core dump would result.  Nick Alcock submitted a patch that
solved 70% of that problen by properly checking the return value of
ctf_lookup_by_name() during program linking and flagging EDT_NOCTF if
there is an issue.  This has been incorporated into this patch.

In addition, link failure resulted in the constructed DIFO to be free'd
but upon termination, dtrace was walking the identifier hash and freeing
all DIFO and we ended up freeing the same DIFO twice.  This is fixed here
also.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: c8715f7fda79add569660be51958e0542d245f67
      https://github.com/oracle/dtrace-utils/commit/c8715f7fda79add569660be51958e0542d245f67
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M libdtrace/dt_cc.c

  Log Message:
  -----------
  Fix type of variables holding result of ctf_member_info()

The return type of ctf_member_info() is int, but is being assigned to
variables that are declared as ctf_id_t and initialized as CTF_ERR.
The type has been corrected (int), and the initialization is removed
because it is not necessary.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 380e08c3802be177a5be01a4b59ad172eb5bc2b7
      https://github.com/oracle/dtrace-utils/commit/380e08c3802be177a5be01a4b59ad172eb5bc2b7
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cc.c
    A test/unittest/options/tst.S.sh
    A test/unittest/options/tst.verbose.sh

  Log Message:
  -----------
  Fix the -xverbose option

The -xverbose option should be equivalent to the -S option.  The
-xverbose option sets DTRACE_C_DIFV in the dt_cflags, but the compiler
only ever checked the cflags passed from the command line program for
the DTRACE_C_DIFV flag.  As a result, only -S had the intended
behaviour whereas -xverbose was essentially ignored.

Note that -xdisasm=N does not modify the -xverbose behaviour because the
-xverbose option is specifically defined to providw clause disassembly
(equivalent with -S without -xdisasm=N being specified).

When a D script is compiled that is not a library script or the builtin
ERROR probe, and the DTRACE_C_DIFV flag is set in dt_cflags, it is also
set in the cflags used by the compiler.

The support for -xcpp is also updated with this patch to set DTRACE_C_CPP
under the same circumstances.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 85be8d813526bff01445ef66fa14a420dbda7d55
      https://github.com/oracle/dtrace-utils/commit/85be8d813526bff01445ef66fa14a420dbda7d55
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    R test/unittest/misc/tst.bpflog-cmdline.sh
    R test/unittest/misc/tst.bpflog-pragma.sh
    R test/unittest/misc/tst.bpflogsize-cmdline.sh
    R test/unittest/misc/tst.bpflogsize-pragma.sh
    A test/unittest/options/err.D_ASRELO.kdefs.d
    A test/unittest/options/err.D_ASRELO.kdefs.r
    A test/unittest/options/err.D_EMPTY.errtags.d
    A test/unittest/options/err.D_EMPTY.errtags.r
    A test/unittest/options/err.D_EMPTY.no-empty.d
    A test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.d
    A test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs.r
    A test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.d
    A test/unittest/options/err.D_MACRO_UNDEF.no-defaultargs2.r
    A test/unittest/options/err.D_MACRO_UNUSED.no-argref.d
    A test/unittest/options/err.D_PDESC_ZERO.no-Z-or-zdefs.d
    A test/unittest/options/err.D_PDESC_ZERO.no-Z-or-zdefs.r
    A test/unittest/options/err.b-too-low.d
    A test/unittest/options/err.b-too-low.r
    A test/unittest/options/err.bufsize-too-low.d
    A test/unittest/options/err.bufsize-too-low.r
    A test/unittest/options/err.empty.d
    A test/unittest/options/err.empty.r
    A test/unittest/options/err.no-errtags.d
    A test/unittest/options/err.no-errtags.r
    A test/unittest/options/err.no-w-or-destructive.d
    A test/unittest/options/err.no-w-or-destructive.r
    A test/unittest/options/tst.D.d
    A test/unittest/options/tst.F.d
    A test/unittest/options/tst.F.r
    A test/unittest/options/tst.U.d
    A test/unittest/options/tst.Z.d
    A test/unittest/options/tst.argref.d
    A test/unittest/options/tst.b.d
    A test/unittest/options/tst.bpflog-cmdline.sh
    A test/unittest/options/tst.bpflog-pragma.sh
    A test/unittest/options/tst.bpflogsize-cmdline.sh
    A test/unittest/options/tst.bpflogsize-pragma.sh
    A test/unittest/options/tst.bufsize.d
    A test/unittest/options/tst.core.sh
    A test/unittest/options/tst.cppargs.sh
    A test/unittest/options/tst.cpphdrs.sh
    A test/unittest/options/tst.cpppath.r
    A test/unittest/options/tst.cpppath.sh
    A test/unittest/options/tst.ctypes.sh
    A test/unittest/options/tst.debug.sh
    A test/unittest/options/tst.defaultargs.d
    A test/unittest/options/tst.defaultargs2.d
    A test/unittest/options/tst.define.d
    A test/unittest/options/tst.destructive.d
    A test/unittest/options/tst.dtypes.sh
    A test/unittest/options/tst.flowindent.d
    A test/unittest/options/tst.flowindent.r
    A test/unittest/options/tst.knodefs.sh
    A test/unittest/options/tst.undef.d
    A test/unittest/options/tst.w.d
    A test/unittest/options/tst.zdefs.d

  Log Message:
  -----------
  Add tests for various options and tunables

Tests added for:
    -xargref
    -xbufsize (and -b)
    -xcore
    -xcppargs
    -xcpphdrs
    -xcpppath
    -xctypes
    -xdebug
    -xdefaultargs
    -xdefine (and -D)
    -xdestructive (and -w)
    -xdtypes
    -xempty
    -xerrtags
    -xflowindent (and -F)
    -xkdefs
    -xknodefs
    -xundef (and -U)
    -xzdefs (and -Z)

Tests moved for:
    -xbpflog
    -xbpflogsize

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: e100caf321485b11a32a8dcb54624da12ac62c5e
      https://github.com/oracle/dtrace-utils/commit/e100caf321485b11a32a8dcb54624da12ac62c5e
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M CODING-STYLE
    R libbpf/Build
    R libbpf/GNUmakefile
    R libbpf/bpf.c
    R libbpf/bpf.h
    R libbpf/bpf_prog_linfo.c
    R libbpf/btf.c
    R libbpf/btf.h
    R libbpf/btf_dump.c
    R libbpf/hashmap.c
    R libbpf/hashmap.h
    R libbpf/include/linux/bpf.h
    R libbpf/include/linux/bpf_common.h
    R libbpf/include/linux/btf.h
    R libbpf/include/linux/compiler-gcc.h
    R libbpf/include/linux/compiler.h
    R libbpf/include/linux/err.h
    R libbpf/include/linux/filter.h
    R libbpf/include/linux/kernel.h
    R libbpf/include/linux/list.h
    R libbpf/include/linux/overflow.h
    R libbpf/include/linux/poison.h
    R libbpf/include/linux/types.h
    R libbpf/include/tools/libc_compat.h
    R libbpf/libbpf.c
    R libbpf/libbpf.h
    R libbpf/libbpf_errno.c
    R libbpf/libbpf_internal.h
    R libbpf/libbpf_probes.c
    R libbpf/netlink.c
    R libbpf/nlattr.c
    R libbpf/nlattr.h
    R libbpf/str_error.c
    R libbpf/str_error.h
    M libdtrace/Build
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h

  Log Message:
  -----------
  Remove libbpf dependency

Use direct bpf() syscalls for map creation and program loading.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: d91f091c4639aeaf7b26ac70e85275a8b45edc09
      https://github.com/oracle/dtrace-utils/commit/d91f091c4639aeaf7b26ac70e85275a8b45edc09
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    A include/linux/bpf.h
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_impl.h
    M libdtrace/dt_open.c

  Log Message:
  -----------
  Add BPF helper mapping

BPF helpers can be very specific to kernel versions, and the set of
available helpers may differ between the system where DTrace was
compiled and the system where it is being used.

We add runtime checking of specific BPF helpers, with support for
possible fallback helpers.  E.g. if probe_read_user() is not found,
we can use probe_read() instead (though that may not guarantee
successful execution).

This can also be used to check whether certain helpers exist.  By
convention, when the BPF helper function id maps to 0 (BPF_FUNC_unspec),
the helper is known not to be supported on the runtime system.

We include bpf.h from a kernel recent enough to support all the BPF
features that DTrace can make use of.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: d97c8fa78cd2f4db8cfca2568cf114bacb41eabb
      https://github.com/oracle/dtrace-utils/commit/d97c8fa78cd2f4db8cfca2568cf114bacb41eabb
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/funcs/copyin/err.D_ALLOCA_SIZE.d
    A test/unittest/funcs/copyin/err.D_PROTO_ARG.non_scalar_arg1.d
    A test/unittest/funcs/copyin/err.D_PROTO_ARG.non_scalar_arg2.d
    A test/unittest/funcs/copyin/err.D_PROTO_LEN.missing_arg.d
    A test/unittest/funcs/copyin/err.D_PROTO_LEN.too_few_args.d
    A test/unittest/funcs/copyin/err.D_PROTO_LEN.too_many_args.d
    A test/unittest/funcs/copyin/err.badaddr.d
    A test/unittest/funcs/copyin/err.badaddr.r
    A test/unittest/funcs/copyin/err.badsize.d
    A test/unittest/funcs/copyin/err.null_arg1.d
    A test/unittest/funcs/copyin/err.null_arg1.r
    A test/unittest/funcs/copyin/tst.copyin.d
    A test/unittest/funcs/copyin/tst.copyin.r
    R test/unittest/funcs/tst.copyin.d

  Log Message:
  -----------
  Add support for copyin() subroutine

The copyin() subroutine makes use of the alloca() subroutine to allocate
the needed scratch space to copy data to.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: c26e2e5f279a0fd22c99437666e0483d29aab766
      https://github.com/oracle/dtrace-utils/commit/c26e2e5f279a0fd22c99437666e0483d29aab766
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/funcs/copyinto/err.D_PROTO_ARG.non_alloca_arg3-2.d
    A test/unittest/funcs/copyinto/err.D_PROTO_ARG.non_alloca_arg3.d
    A test/unittest/funcs/copyinto/err.D_PROTO_ARG.non_ptr_arg3.d
    A test/unittest/funcs/copyinto/err.D_PROTO_ARG.non_scalar_arg1.d
    A test/unittest/funcs/copyinto/err.D_PROTO_ARG.non_scalar_arg2.d
    A test/unittest/funcs/copyinto/err.D_PROTO_LEN.missing_arg.d
    A test/unittest/funcs/copyinto/err.D_PROTO_LEN.too_few_args.d
    A test/unittest/funcs/copyinto/err.D_PROTO_LEN.too_many_args.d
    A test/unittest/funcs/copyinto/err.badaddr.d
    A test/unittest/funcs/copyinto/err.badaddr.r
    A test/unittest/funcs/copyinto/err.badsize.d
    A test/unittest/funcs/copyinto/err.badsize.r
    A test/unittest/funcs/copyinto/err.null_arg1.d
    A test/unittest/funcs/copyinto/err.null_arg1.r
    A test/unittest/funcs/copyinto/tst.copyinto.d
    A test/unittest/funcs/copyinto/tst.copyinto.r
    R test/unittest/funcs/tst.copyinto.d

  Log Message:
  -----------
  Add support for copyinto() subroutine

The copyinto() subroutine is a near-identical copy of bcopy() other
than that the arguments are ordered differently, and it reads from
userspace addresses rather than kernel addresses.  A new function is
added to implement the shared functionality (dt_cg_subr_bcopy_impl).

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: dee44bc6caeeda3f80b6d47eccb6220859452de6
      https://github.com/oracle/dtrace-utils/commit/dee44bc6caeeda3f80b6d47eccb6220859452de6
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/funcs/copyinstr/err.D_ALLOCA_SIZE.d
    A test/unittest/funcs/copyinstr/err.D_PROTO_ARG.non_scalar_arg1.d
    A test/unittest/funcs/copyinstr/err.D_PROTO_ARG.non_scalar_arg2.d
    A test/unittest/funcs/copyinstr/err.D_PROTO_LEN.missing_arg.d
    A test/unittest/funcs/copyinstr/err.D_PROTO_LEN.too_many_args.d
    A test/unittest/funcs/copyinstr/err.badaddr.d
    A test/unittest/funcs/copyinstr/err.badaddr.r
    A test/unittest/funcs/copyinstr/err.badsize.d
    A test/unittest/funcs/copyinstr/err.null_arg1.d
    A test/unittest/funcs/copyinstr/err.null_arg1.r
    A test/unittest/funcs/copyinstr/tst.copyinstr-low-maxsize.d
    A test/unittest/funcs/copyinstr/tst.copyinstr-low-maxsize.r
    A test/unittest/funcs/copyinstr/tst.copyinstr-no-maxsize.d
    A test/unittest/funcs/copyinstr/tst.copyinstr-no-maxsize.r
    A test/unittest/funcs/copyinstr/tst.copyinstr.d
    A test/unittest/funcs/copyinstr/tst.copyinstr.r

  Log Message:
  -----------
  Add support for copyinstr() subroutine

The copyinstr() subroutine is very similar to the copyin() subroutine.
The differences are:
 - the 2nd argument (max size) is optional (default is strsize)
 - if a size is given, it is capped at strsize
 - data is copied using bpf_probe_read_user_str (or bpf_probe_read_str)

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: c89eb968b659d819c83187625f89074844a8dfb7
      https://github.com/oracle/dtrace-utils/commit/c89eb968b659d819c83187625f89074844a8dfb7
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/pid/tst.args1.aarch64.x

  Log Message:
  -----------
  Fix copying of pid entry probe args from stack

The pid-provider "entry" probes must access function arguments -- at
first from registers and, if there are many args, then also from the
stack.  We copied these stack locations using the BPF probe_read()
helper function.  Early versions of this function, however, were only
reliable for copying from kernel space.  Apparently, this issue was
irrelevant on x86_64, but caused probe_read() to return an error
code on aarch64 when copying from user space.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 45da9141da2f59b8b2fbd91cc2e3ee7483b14b28
      https://github.com/oracle/dtrace-utils/commit/45da9141da2f59b8b2fbd91cc2e3ee7483b14b28
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cc.c

  Log Message:
  -----------
  Initialize variable explicitly

Compilation can otherwise complain with
"‘dp’ may be used uninitialized in this function [-Wmaybe-uninitialized]".
It is easy to eliminate such a sensitivity to compiler.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 96d4dfeb5353a51fd24cbd837fcc9447512af011
      https://github.com/oracle/dtrace-utils/commit/96d4dfeb5353a51fd24cbd837fcc9447512af011
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_impl.h

  Log Message:
  -----------
  Eliminate obsolete dt_last*

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 0f0c35cda8c6706ba89d68a2ab8be2d9ef91fb95
      https://github.com/oracle/dtrace-utils/commit/0f0c35cda8c6706ba89d68a2ab8be2d9ef91fb95
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M include/dtrace/metadesc.h

  Log Message:
  -----------
  Get rid of obsolete DTRACE_SIZEOF_* macros

These macros were for when records were at the end of the descriptor.
With commit ecbe2271e2bb ("Implementation of the printa() action"),
the array is replaced with a pointer, and the DTRACE_SIZEOF_* macros
become obsolete.  Actually, dtrace_eprobedesc_t no longer even exists.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 1a9239d0e370797914230f0deb20f762e1253718
      https://github.com/oracle/dtrace-utils/commit/1a9239d0e370797914230f0deb20f762e1253718
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M test/unittest/funcs/tst.rw_.sh

  Log Message:
  -----------
  test: tst.rw_.sh is known to be unstable, tag it so

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: bb699e7ec1aaf17088c1d3cd20ea8dbf9c587324
      https://github.com/oracle/dtrace-utils/commit/bb699e7ec1aaf17088c1d3cd20ea8dbf9c587324
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M test/unittest/aggs/tst.clearlquantize.r
    R test/unittest/aggs/tst.clearlquantize.r.p

  Log Message:
  -----------
  test: Make tst.clearlquantize.d more discriminating

This test exercises both aggregation keys and the clear() action.
It has a .r.p postprocessing script that makes it insensitive to
whether clear() actually works.

Remove the .r.p file to simplify the test and make it more stringent.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 701a02e869ed92a8c8e42c8a9d279b7f7ec1371c
      https://github.com/oracle/dtrace-utils/commit/701a02e869ed92a8c8e42c8a9d279b7f7ec1371c
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M test/unittest/aggs/tst.clear.r.p

  Log Message:
  -----------
  test: Fix search string

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 8b989703b4429f358465132c337de935bfe65b12
      https://github.com/oracle/dtrace-utils/commit/8b989703b4429f358465132c337de935bfe65b12
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M test/unittest/aggs/tst.llquantincr.d
    M test/unittest/aggs/tst.llquantize.d
    M test/unittest/aggs/tst.llquantneg.d
    M test/unittest/aggs/tst.llquantstep.d
    M test/unittest/funcs/tst.rand_inter.sh
    M test/unittest/funcs/tst.rand_intra.sh
    M test/unittest/speculation/tst.SingleCPU.d

  Log Message:
  -----------
  test: Fix race condition in many-fire tests

Some tests that expect probes to fire many times had been using tick-*
for this purpose.  Unfortunately, tick-* quality can be poor, depending
on how the kernel is configured.  Therefore, commit 80a539ae8653
("test: Account for unreliable tick firing") addressed this problem
by replacing tick-* probes with syscall::ioctl:entry probes and with
bogus-ioctl as a trigger.

The problem with this solution is that the actions also involved some
global variables.  The ioctl:entry probes could fire on multiple CPUs
concurrently, overwriting each other.  Test runs were erratic.

Add "pid==$target" to the probe predicates.  This includes both the
the tests in the aforementioned patch but also two rand() tests.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 2474e83e26e4896160fc93ce5fd876be12695e38
      https://github.com/oracle/dtrace-utils/commit/2474e83e26e4896160fc93ce5fd876be12695e38
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M bpf/get_dvar.c

  Log Message:
  -----------
  Remove extraneous tab

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: be2bd546ef321225c9b62e5f3ecf2b91035ccf26
      https://github.com/oracle/dtrace-utils/commit/be2bd546ef321225c9b62e5f3ecf2b91035ccf26
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    M test/unittest/funcs/tst.rand_intra.sh

  Log Message:
  -----------
  Handle high-order bits of rand() properly

The D rand() function is declared to be "int" -- a 4-byte, signed
integer.  Internally, D represents integers as 64-bit quantities.
Therefore, after calling the BPF helper function to get 32 random
bits, we should sign-extend the upper bits.

Meanwhile, the rand_intra test was checking if the uppermost 32 bits
of "x = rand()" were 0.  This makes no sense since x is a signed,
4-byte integer and should be populated with 0xffffffff half of the
time.  The test would fail once x is correctly sign-extended (by a
future patch).  Eliminate the check on the upper bits.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: e437349fc256ad528593b069d3312f26b5d95352
      https://github.com/oracle/dtrace-utils/commit/e437349fc256ad528593b069d3312f26b5d95352
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-07-29 (Fri, 29 Jul 2022)

  Changed paths:
    M libdtrace/dt_parser.c
    A test/unittest/bitfields/tst.bitfield-is-integer.d
    A test/unittest/bitfields/tst.slices.d

  Log Message:
  -----------
  parser: support slices of typedefs, etc

Slices in CTF are almost totally transparent to the user, *except* that
ctf_type_resolve will halt when it encounters a slice and will drill no
further, since going further would lose information about the encoding
of the slice.  Since you can have slices of typedefs, this means you
can't rely on ctf_type_resolve getting rid of all typedefs any more.

This change drills through to base types where necessary.  We have to do
it by hand in every place it's needed, which is fairly unpleasant.  I
think I caught them all (most are covered by the tests added here).  If
we find other places where spurious errors citing bitfields which should
have been treated as integral types appear, we can fix them as they crop
up.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: d5a2077d2124aa716378d94705fb74c7ade6699b
      https://github.com/oracle/dtrace-utils/commit/d5a2077d2124aa716378d94705fb74c7ade6699b
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-29 (Fri, 29 Jul 2022)

  Changed paths:
    M include/dtrace/options_defines.h
    M libdtrace/dt_bpf.c
    M libdtrace/dt_open.c
    M libdtrace/dt_options.c
    M libdtrace/dt_work.c
    M runtest.sh
    A test/unittest/misc/tst.lockmem-cmdline.r
    A test/unittest/misc/tst.lockmem-cmdline.sh
    A test/unittest/misc/tst.lockmem-cmdline.x
    A test/unittest/misc/tst.lockmem-envvar.r
    A test/unittest/misc/tst.lockmem-envvar.sh
    A test/unittest/misc/tst.lockmem-envvar.x
    A test/unittest/misc/tst.lockmem-pragma.r
    A test/unittest/misc/tst.lockmem-pragma.sh
    A test/unittest/misc/tst.lockmem-pragma.x
    A test/unittest/misc/tst.lockmem-x.r
    A test/unittest/misc/tst.lockmem-x.sh
    A test/unittest/misc/tst.lockmem-x.x

  Log Message:
  -----------
  Locked-memory limit

Locked memory is needed for BPF operations such as creating maps and
loading programs.  Therefore, dt_vopen() sets RLIMIT_MEMLOCK to 32 Mbytes,
an amount that seems sufficient for many tests in our suite.  On the other
hand, the value is somewhat arbitrary, excessive for many D scripts yet
insufficient for others, including some of our tests.  Further, it is
silently modifying a resource limit.

Remove dt_vopen()'s silent modification of the locked-memory limit.

Explicitly set "ulimit -l" in runtest.sh to accommodate the tests in our
suite.

While users can similarly set "ulimit -l" explicitly, it would be more
convenient if there were alternative mechanisms, especially when using
"sudo dtrace".  Therefore, add a D option lockmem.  Notice that ulimit
allows the value "unlimited" for users who simply want to ignore any limit.

Add some more verbose error messages that explain that encountering
EPERM during BPF map creation or BPF program load may be solved by
adjusting the locked-memory limit.

With UEKR7, the locked-memory limit seems to be ignored for root.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 173361ff5a3502391bb79dc2099f14c4bc729cba
      https://github.com/oracle/dtrace-utils/commit/173361ff5a3502391bb79dc2099f14c4bc729cba
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-07-29 (Fri, 29 Jul 2022)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  test: Report unexpected results for unstable tests as xfail

Generally, tests are deterministically expected to pass or xfail.

Some tests fail intermittently, however, and are tagged "unstable".
Either pass or fail is acceptable, but one has to check manually
to see if the test is unstable.

If a test xpasses or fails, then if it is unstable, just report it
as xfail and unstable.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 7e9ce1eee47540fb1d22c5cf4603de1301ab880b
      https://github.com/oracle/dtrace-utils/commit/7e9ce1eee47540fb1d22c5cf4603de1301ab880b
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/arithmetic/tst.cast-add.d
    A test/unittest/arithmetic/tst.cast-add.r
    A test/unittest/arithmetic/tst.cast-imp.d
    A test/unittest/arithmetic/tst.cast-imp.r

  Log Message:
  -----------
  Promote integers to 64 bits when loaded

DTrace internally implements integers with 64-bit registers.  This
makes the manipulation of integers of different sizes simpler, by
avoiding a number of typecast operations.  But DTrace has also
loaded integers without promoting them appropriately.  E.g.,
((short)0xffff) has been treated as 0xffff rather than -1.

Promote signed integers to 64 bits when loading (if needed).

Add tests.  Specifically, typecasting should typically not be needed.
Therefore, operations such as x=y and x+y (of different types) should
work properly if integers are correctly represented in 64-bit registers.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 9f9931214aff7f4613017dfa2f5912abfcb9cc59
      https://github.com/oracle/dtrace-utils/commit/9f9931214aff7f4613017dfa2f5912abfcb9cc59
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    M libdtrace/dt_parser.c
    A test/unittest/arithmetic/tst.cast-exp.d
    A test/unittest/arithmetic/tst.cast-exp.r

  Log Message:
  -----------
  Fix typecast

DTrace internally keeps integers basically in a 64-bit format.  Shorter,
signed integers are already sign-extended.

The current logic makes an error when an integer is extended and the
signedness changes.  It truncates the source and then extends.  E.g.,
consider a 1-byte source and 2-byte destination:

    signed?
    src dst  input  expected  currently

     N   Y    0xff   0x00ff       -1
     Y   N    0xff   0xffff      0xff

Note:

*) In the first case, no casting is even necessary.  If the integer
is being extended and it is unsigned, then higher-order bits can simply
be left alone.

*) In the second case, the signed input is supposed to be sign-extended
before truncating to the new size.  We currently truncate first, at the
smaller size.

Fix.  Add tests.

Notice that:

*) Casting constants like "var = (type) constant" is handled
   in the parser.

*) Casting variables like "var1 = (type) var2" is handled
   in the code generator.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 0c5bf3ed23203785966b67222c0190d1a16bc5fe
      https://github.com/oracle/dtrace-utils/commit/0c5bf3ed23203785966b67222c0190d1a16bc5fe
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M test/unittest/aggs/tst.neglquant.d
    M test/unittest/aggs/tst.negquant.d

  Log Message:
  -----------
  test: Need wider variables to hold 1<<63

DTrace has some peculiar -- arguably incorrect -- semantics for
integer types dating back to Solaris.  Consider 1<<63.  Normal C
rules would say this is a 4-byte int whose value is 0.  The DTrace
parser, however, treats it as the 8-byte integer 0x8000000000000000.
Subsequently, D uses the 8-byte value when assigning to an 8-byte
variable.  E.g.,
    long long x;
    x = 1 << 63;
stores 1<<63.  Nevertheless, D treat 1<<63 as a 4-byte expression.
E.g.,
    x = 1 << 63;
    trace(1 << 63);
will use a default 4-byte int for x and trace a 4-byte value of 0.

The tests addressed by this patch expect 8-byte increments but
use default-width int this->val variables.  There is no way a
4-byte int could produce a, say, 9223372036854775801 increment.

Declare this->val to be 8 bytes and properly set it to the intended
values.

The tests will still XFAIL, since support for aggregation keys
is missing.

The D semantics should perhaps be examined further, but this
patch at least fixes these particular tests.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 69a55492a9461f9bf721fb36d6ca37fe8a723fe9
      https://github.com/oracle/dtrace-utils/commit/69a55492a9461f9bf721fb36d6ca37fe8a723fe9
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    A test/unittest/arithmetic/tst.bug-casting.d
    A test/unittest/arithmetic/tst.bug-casting.r

  Log Message:
  -----------
  test: Add XFAIL placeholder: DTrace internal integer representation

When DTrace performs integer operations, it assumes integers (of
all widths and signedness) are internally represented in 64 bits
and do not need frequent typecasting.  This breaks the documented
behavior.  Recent patches have addressed a number of these problems.

A few problems remain.  Notably, arithmetic operations can change
the sign bit of a narrow integer.  This should result in the high
bits of the 64-bit representation changing.  The DTrace code generator
should typecast appropriately.

Add a placeholder test that XFAILs to indicate that work remains.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f92b1ac8457f6e59354befa87217503c13d043d6
      https://github.com/oracle/dtrace-utils/commit/f92b1ac8457f6e59354befa87217503c13d043d6
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    A test/unittest/aggs/tst.goodkey.r
    A test/unittest/aggs/tst.goodkey.r.p

  Log Message:
  -----------
  test: check goodkey results

This test was failing due to lack of support for aggregation keys.
The test was tagged XFAIL.

Support for aggregation keys would cause the test to XPASS.
Unfortunately, the crucial probe action does not even execute since it
depends on vtimestamp, which is not yet implemented.  The XPASS would
be spurious since results were simply not being checked.

Add .r and .r.p files for a sanity check on results.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 44ee4861045cd822ce28c234297539c4956da4b6
      https://github.com/oracle/dtrace-utils/commit/44ee4861045cd822ce28c234297539c4956da4b6
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M test/unittest/rates/tst.aggrate.d

  Log Message:
  -----------
  test: needs aggrate and agg drop support

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 85a9998446dbeaf31848a924b7d30f12603a867d
      https://github.com/oracle/dtrace-utils/commit/85a9998446dbeaf31848a924b7d30f12603a867d
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M test/unittest/actions/printf/err.D_PRINTF_ARG_TYPE.agg.d

  Log Message:
  -----------
  test: Remove XFAIL tag that was messing up a line number

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 7e6f19af53994077a2daa8482515f0231fc6d17a
      https://github.com/oracle/dtrace-utils/commit/7e6f19af53994077a2daa8482515f0231fc6d17a
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M include/dtrace/actions_defines.h
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_cc.c
    M libdtrace/dt_printf.c

  Log Message:
  -----------
  Complete the conversion of DTRACEAGG_* enums to DT_AGG_* enums

In commit 85c8512318e3
("Implement the support code for generating aggregation data"),
the enums DT_AGG_* were introduced.

In commit ecbe2271e2bb
("Implementation of the printa() action"),
the DT_AGG_* were rebased to be offset from DTRACEACT_AGGREGATION.

In commit ecbe2271e2bb
("Implementation of the printa() action"),
the older DTRACEAGG_* enums that remained were said to be replaced
by the newer DT_AGG_*.

In fact, however, instances of DTRACEAGG_* remained.  This was an
issue since the enums were defined in different orders, causing
corresponding values such as DT_AGG_QUANTIZE and DTRACEAGG_QUANTIZE
to disagree.  These problems were in code that was not yet active --
e.g., to print two quantize() results for the same aggregation variable
but with different keys.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 7b443eddcd213e78235fa36d5001ef0e85a569e3
      https://github.com/oracle/dtrace-utils/commit/7b443eddcd213e78235fa36d5001ef0e85a569e3
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c

  Log Message:
  -----------
  Clean up BPF map creation in anticipation of more changes

Adding or removing a BPF map to this function requires changes in
different parts of the function.  Reorganize the function slightly
so that adding or removing a BPF map can be done with simpler, more
localized changes.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 00e2ca4d56f5e4ff35f059329c824385d3c3d310
      https://github.com/oracle/dtrace-utils/commit/00e2ca4d56f5e4ff35f059329c824385d3c3d310
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M bpf/get_bvar.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_ident.h
    M libdtrace/dt_open.c
    M libdtrace/dt_parser.c
    A test/unittest/arithmetic/tst.cast-alloca.d
    A test/unittest/arithmetic/tst.cast-curcpu.d

  Log Message:
  -----------
  Ensure curcpu values are scalarized when typecast

The 'curcpu' built-in variable is special because its value is a
pointer to a map value.  This means that the verifier will impose
strict limitations on what can be done with that pointer value.
By scalarizing it when it is typecast we ensure that the verifier
will treat the value as a regular scalar.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: e79d0e81a5f07cec179211a1796c913f3887e472
      https://github.com/oracle/dtrace-utils/commit/e79d0e81a5f07cec179211a1796c913f3887e472
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Eliminate an unneeded instance of strsize

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 28261a25e77e00a61e7ea7910ea54bab93b675bb
      https://github.com/oracle/dtrace-utils/commit/28261a25e77e00a61e7ea7910ea54bab93b675bb
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M include/dtrace/metadesc.h

  Log Message:
  -----------
  Clean up some comments

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: a36a42c4db2e95b50c61a9eea951bbd666445804
      https://github.com/oracle/dtrace-utils/commit/a36a42c4db2e95b50c61a9eea951bbd666445804
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    R include/arm64/asm/barrier.h
    R include/i386/asm/barrier.h
    R include/linux/compiler-gcc.h
    R include/linux/compiler.h
    R include/linux/ring_buffer.h
    M libdtrace/dt_consume.c

  Log Message:
  -----------
  Simplify the ring buffer consumption loop

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: d9d862b6cf75f1a8482158e40616854615224044
      https://github.com/oracle/dtrace-utils/commit/d9d862b6cf75f1a8482158e40616854615224044
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_cc.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_dlibs.c
    M libdtrace/dt_impl.h

  Log Message:
  -----------
  Add a block of zeroes to use to initialize BPF maps

There are cases in BPF code where we want to read a contiguous block of
zeroes.  Since the block is read-only, it can be shared among all CPUs and
among multiple purposes to save BPF map space (locked memory).  Create such
a block.

The 'strtab' map is a BPF_MAP_TYPE_ARRAY map that already reserves a block
memory at the end of its value to placate the BPF verifier, so we can just
use that (and enlarge it if needed).

For code generation, we need to know the offset of this region in the
strtab.  The offset cannot be known until after compilation, so the
relocation mechanism is used to patch in its value..

The dt_cg_zerosptr() function should be called to obtain the pointer value
to the memory block of zeros.  It will be stored in the given register.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 4f2286e8acf4d2dc936bfb20ef9b3816a568c558
      https://github.com/oracle/dtrace-utils/commit/4f2286e8acf4d2dc936bfb20ef9b3816a568c558
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M bpf/get_dvar.c
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_dis.c
    M test/unittest/disasm/tst.ann-tvar.r
    M test/unittest/disasm/tst.ann-tvar.sh

  Log Message:
  -----------
  Convert dvars to use the default block of zeros

The code sequence for retrieving dynamic variables (TLS variables and
associative arrays) is modified, so the disassembler annotation code is
updated to reflect this.  As a useful side effect, relocation symbols
are now reported for mov and arithmetic intructions as well.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: f72a8b36b5ed976aa12415590870ef89dfa024b5
      https://github.com/oracle/dtrace-utils/commit/f72a8b36b5ed976aa12415590870ef89dfa024b5
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/Build
    R libdtrace/mknames.sh
    R test/unittest/disasm/tst.ann-sub.sh

  Log Message:
  -----------
  Remove obsolete mknames.sh and related test

The id-to-name mapping in dt_names.c (generated by mknames.sh from a
Build rule) is no longer needed.  We therefore no longer need the test
for it either.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: 59d8f9dd149febea0e8f0d44da4e5620bfae9c48
      https://github.com/oracle/dtrace-utils/commit/59d8f9dd149febea0e8f0d44da4e5620bfae9c48
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_dctx.h

  Log Message:
  -----------
  Remove the "default tuple" area

All we need is a bunch of zeroes, which are available from the newly
introduced block of zeroes.  Using that block is better because:

1)  The new block is global, while the older area was per-CPU.
    We only need one copy of this read-only memory.

2)  The new block will be overlapped with other uses of zeroes.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 2240e0c81b31530841a30e4a4530531237878118
      https://github.com/oracle/dtrace-utils/commit/2240e0c81b31530841a30e4a4530531237878118
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Assemble tuple components at predictable offsets

We concatenate tuple components in the tuple assembly area.  When a
component is a string, we place the following component immediately
after the terminating NUL byte.

We will use this same tuple-assembly code to support aggregation keys,
however, and for printing aggregation keys it would be nice for each
key to start at a predictable offset.  Make that change in dt_cg_arglist().

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: fb37ed8359b75ee0b008cd28c00aa2d785afb2c9
      https://github.com/oracle/dtrace-utils/commit/fb37ed8359b75ee0b008cd28c00aa2d785afb2c9
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h

  Log Message:
  -----------
  Implement dt_bpf_map_next_key()

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 1fe17cc22305a2e2c71a07a316c3b70f384572d2
      https://github.com/oracle/dtrace-utils/commit/1fe17cc22305a2e2c71a07a316c3b70f384572d2
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/dt_map.c

  Log Message:
  -----------
  Allow aggid check without having to store agg description

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 397113673a6671ad4ee7571c2826e3fe9426d9e3
      https://github.com/oracle/dtrace-utils/commit/397113673a6671ad4ee7571c2826e3fe9426d9e3
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-05 (Fri, 05 Aug 2022)

  Changed paths:
    M libdtrace/dt_impl.h

  Log Message:
  -----------
  Fix obsolete comment regarding agg latch seq number

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 62417688c502a1018300c15af6600cfa00be0087
      https://github.com/oracle/dtrace-utils/commit/62417688c502a1018300c15af6600cfa00be0087
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M include/dtrace/metadesc.h
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_consume.c
    M libdtrace/dt_map.c
    M libdtrace/dt_printf.c
    M libdtrace/dtrace.h

  Log Message:
  -----------
  Move normalization value to aggregation descriptions

This change is being made in anticipation of adding support for
aggregation keys, which create the possibility of an aggregation
appearing many times (with different keys) in dt_aggregate.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: e3e60505bd1f48453f2f5b62e6e611ed53ed5b0e
      https://github.com/oracle/dtrace-utils/commit/e3e60505bd1f48453f2f5b62e6e611ed53ed5b0e
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-09 (Tue, 09 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c

  Log Message:
  -----------
  Improve error checking and reporting for BPF map creation

Eugene Loh found that when BPF creation fails due to too big a map,
E2BIG is returned.  This got reported as "Argument list too long"
(using strerror()).  That is not very helpful.  It will now report
"Too big".

In addition, the key and value sizes are size_t entities in the main
caller (dt_bpf_gmap_create()), while create_map() accepts ints for
these values.  And the maximum number of map entries is an int in
dt_bpf_gmap_create() but is at times calculated based on size_t values.
And the bpf(BPF_MAP_CREATE) syscall expects uint32_t values for all
three.  That is now cleaned up.

The debug output in create_gmap() also got a small modification to no
longer report sizes in the success report since it is already reported
at the beginning of the function.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 739785f13770b5c1538ea0c53c8a97de4a7a73cc
      https://github.com/oracle/dtrace-utils/commit/739785f13770b5c1538ea0c53c8a97de4a7a73cc
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-25 (Thu, 25 Aug 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_consume.c
    M libdtrace/dt_printf.c

  Log Message:
  -----------
  Fix error reporting for agg walk functions

Callback functions for aggregation walkers were not correctly returning
DTRACE_AGGWALK_* values, causing "invalid return value from callback"
errors to be reported rather than the actual error.  This is only seen
when the consumer code has a bug in it (e.g. record description
mismatches).

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 270cc86d22e85c94ba9531302ef159a6fbefdaa5
      https://github.com/oracle/dtrace-utils/commit/270cc86d22e85c94ba9531302ef159a6fbefdaa5
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M cmd/dtrace.c
    M include/dtrace/metadesc.h
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_consume.c
    M libdtrace/dt_impl.h
    M libdtrace/dt_map.c
    M libdtrace/dt_printf.c

  Log Message:
  -----------
  Fix records for aggregation descriptions

The implementation of aggregations erroneously registered the value of
an aggregation as a series of 64-bit values, each with their own record
description.  However, aggregations in their most generic form should
comprise the following records:

(1) variable ID
(2) keys (values of the index tuple, if any)
(3) latch sequence number
(4) aggregation data

(1) and (2) are records that identify the aggregation, whereas (3) and
(4) are data that is generated by the producer.

Change the aggregation record descriptions to match the layout described
above.

Note that the variable ID is now stored as a 32-bit value whereas DTrace
used to store it as a 64-bit value.  This change is valid because the
variable ID is an identifier ID and therefore cannot exceed the range of
a 32-bit integer,

Support for aggregation keys will be added in later patches.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f83d636010fd729a38d14b2eb90f00ccfee6b40b
      https://github.com/oracle/dtrace-utils/commit/f83d636010fd729a38d14b2eb90f00ccfee6b40b
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c

  Log Message:
  -----------
  Clear dt_aggregate each snapshot

The producer (kernel) gathers aggregation data.  The consumer
(user space) snapshots (reads) the kernel data and maintains
its own copy in dt_aggregate.

In legacy DTrace, the consumer would snapshot incremental kernel
data and either initialize or update an entry in dt_aggregate,
depending on whether the corresponding entry already existed.

In the port to BPF, the kernel data is kept in BPF maps that are
up-to-date, not incremental since the last snapshot.  So a second
mechanism was added to decide whether to initialize or update a
dt_aggregate entry:  for the first CPU, even if an entry has been
found, new data is copied (rather than aggregated) in.

When we support aggregation keys, the new mechanism will not help.
It will be possible for a key to appear on some other CPU than
the first.

Nevertheless, we cannot blindly keep re-aggregating data that
is already in dt_aggregate.

Therefore, clear aggregation data in dt_aggregate's hash entries
at each snapshot.  Use dtrace_aggregate_clear() for this purpose.
Note that this function is apparently unused in both legacy DTrace
as well as the port to BPF.  Note also that the function needs to
be corrected to account for for min() and max()

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: da2b17230a93dc1e76f7e8568ad463b6ea4f5304
      https://github.com/oracle/dtrace-utils/commit/da2b17230a93dc1e76f7e8568ad463b6ea4f5304
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M include/dtrace/metadesc.h
    M libdtrace/dt_cg.c
    M libdtrace/dt_impl.h
    M libdtrace/dt_map.c

  Log Message:
  -----------
  Add aggregation description records for aggregation keys

Introduce and use the new dt_aggid_rec_add() function.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 9fec684c6ef420be1e67e45f4d2a43f3684d3cb8
      https://github.com/oracle/dtrace-utils/commit/9fec684c6ef420be1e67e45f4d2a43f3684d3cb8
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c

  Log Message:
  -----------
  Eliminate fun since it is always dt_agg_one_agg now

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: b2bad3642f22a3414ce75fdbea77d7a3fc01de36
      https://github.com/oracle/dtrace-utils/commit/b2bad3642f22a3414ce75fdbea77d7a3fc01de36
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c

  Log Message:
  -----------
  Clean up latch sequence number checks

We were checking multiple times whether it was 0.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: c9d18cdf7b995886124af53cc1175d4a7aa57c60
      https://github.com/oracle/dtrace-utils/commit/c9d18cdf7b995886124af53cc1175d4a7aa57c60
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_impl.h
    M libdtrace/dt_map.c

  Log Message:
  -----------
  Introduce dt_maxaggdsize

We are moving to an implementation in which dt_aggregate tracks varID,
keys, and aggregation data for each aggregation found by the consumer.
For sizing purposes, dt_maxaggdsize will track the maximum size for
any aggregation.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f7efadce6f6300547e7906209e8c24d91c2bd2bc
      https://github.com/oracle/dtrace-utils/commit/f7efadce6f6300547e7906209e8c24d91c2bd2bc
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M test/stress/buffering/err.resize2.d
    A test/stress/buffering/err.resize2.r

  Log Message:
  -----------
  test: Add results file for err.resize2.d

The err.resize2.d test PASSes.  Since this is an err.* test, that
means that the D script fails.  It fails, however, not because the
aggsize limit was excessive (which is the point of the test) but
simply because there is not yet support for aggregation keys.

Add a .r results file to ensure that if the D script fails,
it fails for the expected reason.

The real point of the test is to check the manual resizing option.
For now, however, we settle for reasonable behavior vis-a-vis
support for aggregation keys.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 2b71d6e334bbcad51a7d215541470ccbe317b0d4
      https://github.com/oracle/dtrace-utils/commit/2b71d6e334bbcad51a7d215541470ccbe317b0d4
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_impl.h
    M libdtrace/dt_map.c

  Log Message:
  -----------
  Remove DT_AGG_NUM_COPIES

Originally, the DTrace port to BPF used two copies of aggregations,
to allow lockless access to aggregation data for producer and consumer.

Then DT_AGG_NUM_COPIES was introduced and set to 1 since the consumer
could not mmap BPF maps;  rather, it read data atomically using bpf()
system calls.  The use of twice as much locked memory for aggregations
was not justified.

Eliminate DT_AGG_NUM_COPIES, committing to the single-copy approach
and simplifying the code.

The dual-copy version used a latch sequence number.  It is now simply
a data counter;  importantly, a nonzero value indicates the presence
of data.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: bb342c3dd762e5377c751ec9de3e3f26f2412d12
      https://github.com/oracle/dtrace-utils/commit/bb342c3dd762e5377c751ec9de3e3f26f2412d12
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_impl.h
    M libdtrace/dt_open.c

  Log Message:
  -----------
  Allow dt_cg_arglist() to handle the NULL case

Even if an argument is empty, we might want to call dt_cg_arglist() to
construct a pointer to a tuple.

Callers can use the following pseudo-code to accomplish this:

	dt_node_t	noargs = {
				dnp->dn_ctfp,
				dtp->dt_type_void,
			};

	...

	if (dnp->dn_aggtup == NULL)
		dnp->dn_aggtup = &noargs;

	dt_cg_arglist(aid, dnp->dn_aggtup, dlp, drp);

	... <use dnp->dn_aggtup->dn_reg> ...

	if (dnp->aggtup == &noargs)
		dnp->aggtup = NULL;

	... <dnp->dn_aggtup->dn_reg is not used anympre> ...

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 4eed25e694c5a69dfb9971fa866bee3174dd6259
      https://github.com/oracle/dtrace-utils/commit/4eed25e694c5a69dfb9971fa866bee3174dd6259
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c

  Log Message:
  -----------
  Split out gmap creation into their own functions

A lot of BPF maps are created for DTrace.  Rather than creating them all
in one big function, implement them as individual functions.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 1c4f17d76dd59a6d9ca6fa3d2df12021b1cba896
      https://github.com/oracle/dtrace-utils/commit/1c4f17d76dd59a6d9ca6fa3d2df12021b1cba896
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c

  Log Message:
  -----------
  Implement dt_bpf_map_create_meta() and create_gmap_of_maps()

The indexed aggregation support will make use of the map-of-maps
structure that BPF supports.  The dt_bpf_map_create_meta() function
provides the low level implementation and create_gmap_of_maps()
provides a function with argument checking and error reporting.

This patch also cleans up some coding style issues with bpf_*()
functions (and it declares local-use-only functions static).

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: aeca7599742c8fc03e8cde48065b489ead2b08e9
      https://github.com/oracle/dtrace-utils/commit/aeca7599742c8fc03e8cde48065b489ead2b08e9
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c

  Log Message:
  -----------
  Allow NULL as map name in dt_bpf_map_create()

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 0595e1d35609f35cc85a5db195d1aee71303b0ce
      https://github.com/oracle/dtrace-utils/commit/0595e1d35609f35cc85a5db195d1aee71303b0ce
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-08-31 (Wed, 31 Aug 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h

  Log Message:
  -----------
  Implement dt_bpf_map_lookup_inner() and dt_bpf_map_update_inner()

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: a04427e6015e8f38c3a6643f55e0a052c1a8cd80
      https://github.com/oracle/dtrace-utils/commit/a04427e6015e8f38c3a6643f55e0a052c1a8cd80
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_impl.h
    M test/stress/buffering/err.resize2.r

  Log Message:
  -----------
  Use array-of-maps as storage for aggregations

In preparation for indexed aggregations and the clear() and trunc()
operations, the storage for aggregations is moving from a per-CPU
array map to an array of maps, indexed by CPU id.

The existing storage solution for aggregations stored all data in a
singleton map value, i.e. all CPUs were writing to their own portion
of a block of memory that the consumer retrieved in its entirety in
a single system call.

The new storage solution allocates a memory block for each CPU so
that data retrieval by the consumer can be done per CPU.  This sets
the stage for future development where the consumer may need to
update the aggregation buffers.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 54773403335fdc39061a97ed7478a2cee8f4adad
      https://github.com/oracle/dtrace-utils/commit/54773403335fdc39061a97ed7478a2cee8f4adad
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Move freeing %r0 to a more consistent place

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 76710ff19c331ab112da379deffa0dea3776c2fa
      https://github.com/oracle/dtrace-utils/commit/76710ff19c331ab112da379deffa0dea3776c2fa
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Implement dt_cg_push_stack() and dt_cg_pop_stack()

Use dt_cg_push_stack() in dt_cg_arglist().  The dt_cg_pop_stack() will
be used in a subsequent patch.

This patch is based on two patches from Eugene Loh.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 2f1b10cee104f3acc4e98a66ec96cddcadb81bb5
      https://github.com/oracle/dtrace-utils/commit/2f1b10cee104f3acc4e98a66ec96cddcadb81bb5
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h

  Log Message:
  -----------
  Implement dt_bpf_map_lookup_fd()

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 2dd92c0202ad8b92104d3a69ab850b47ed876fdd
      https://github.com/oracle/dtrace-utils/commit/2dd92c0202ad8b92104d3a69ab850b47ed876fdd
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M bpf/Build
    A bpf/get_agg.c
    M libdtrace/dt_aggregate.c
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_consume.c
    M libdtrace/dt_ident.c
    M libdtrace/dt_impl.h
    M libdtrace/dt_map.c
    M libdtrace/dt_printf.c
    M libdtrace/dtrace.h
    M test/demo/intro/countdown-multiple.d
    M test/demo/intro/countdown-quant.d
    M test/demo/out/printa.d
    M test/demo/script/syscall.d
    M test/demo/user/libc.d
    M test/stress/buffering/err.resize2.d
    M test/unittest/actions/printa/err.D_PRINTA_AGGKEY.d
    M test/unittest/actions/printa/err.D_PRINTA_AGGPROTO.d
    M test/unittest/aggs/tst.count2.d
    M test/unittest/aggs/tst.count3.d
    M test/unittest/aggs/tst.denormalizeonly.d
    M test/unittest/aggs/tst.fmtnormalize.d
    M test/unittest/aggs/tst.forms.d
    M test/unittest/aggs/tst.keysort.d
    M test/unittest/aggs/tst.lquantize.d
    M test/unittest/aggs/tst.lquantrange.d
    M test/unittest/aggs/tst.lquantzero.d
    M test/unittest/aggs/tst.multiaggs1.d
    M test/unittest/aggs/tst.multinormalize.d
    M test/unittest/aggs/tst.neglquant.d
    M test/unittest/aggs/tst.negorder.d
    M test/unittest/aggs/tst.negquant.d
    M test/unittest/aggs/tst.order.d
    M test/unittest/aggs/tst.quantize.d
    M test/unittest/aggs/tst.quantmany.d
    M test/unittest/aggs/tst.quantzero.d
    M test/unittest/aggs/tst.signedkeyspos.d
    M test/unittest/aggs/tst.valsortkeypos.d
    M test/unittest/funcs/substr/tst.substrminate.d
    M test/unittest/grammar/tst.stmts.d
    M test/unittest/misc/tst.haslam.d
    M test/unittest/multiaggs/err.D_PRINTA_AGGKEY.d
    M test/unittest/multiaggs/err.D_PRINTA_AGGPROTO.d
    M test/unittest/multiaggs/tst.many.d
    M test/unittest/multiaggs/tst.sort.d
    M test/unittest/multiaggs/tst.sortpos.d
    M test/unittest/multiaggs/tst.zero.d
    M test/unittest/multiaggs/tst.zero2.d
    M test/unittest/multiaggs/tst.zero3.d
    M test/unittest/printa/tst.dynwidth.d
    M test/unittest/printa/tst.tuple.d

  Log Message:
  -----------
  Add support for aggregation keys

In the DTrace port to BPF, the initial support for aggregations
had the kernel maintaining aggregations in a per-CPU BPF map that
was statically allocated and managed.  Each aggregation had its
own region of per-CPU memory.  That is, run-time aggregation keys
were not supported.

To support aggregation keys, switch to a per-CPU BPF hash map.
The hash map key comprises:

*)  the aggregation variable ID

*)  the aggregation keys (if any)

*)  a 64-bit zero (to conform to dynamic variable "tuples")

On the producer (dt_cg.c) side:

*)  Use the existing dt_cg_arglist() to process the
    aggregation keys and produce the BPF hash map key.

*)  Call the new dt_get_agg() to get a pointer to the
    aggregation data in the BPF hash map.  The function call
    will create the element if needed, increment the data
    counter, and advance the pointer to the actual data.

*)  Push this pointer to the stack.

*)  Call the aggregation function: compute the value
    to be aggregated and pop the stack for the pointer
    to where the aggregation data is.

*)  Record the aggregation description (e.g., sizes of
    keys and data) if not already done.  This step is
    performed during code generation, though it does not
    generate code per se.

On the consumer (dt_aggregate.c) side, to snapshot aggregation data:

*)  Use dt_bpf_map_next_key() to walk the keys of the
    BPF hash map.

*)  For each hash map key, read the aggregation data on all CPUs.

*)  For each CPU with a nonzero data counter value, check
    dt_aggregate's user-space hash table for this key-specific
    aggregation.  Initialize or aggregate the user-space data
    accordingly.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 268d3e5f8b68bc1e6bd877823461307b3e1d9979
      https://github.com/oracle/dtrace-utils/commit/268d3e5f8b68bc1e6bd877823461307b3e1d9979
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_aggregate.c
    M test/unittest/aggs/tst.llquantize_sort.d
    M test/unittest/aggs/tst.llquantsortkey.d
    M test/unittest/aggs/tst.llquantsortsum.d
    M test/unittest/aggs/tst.llquantsortzero.d

  Log Message:
  -----------
  Pass signatures into dt_aggregate_[l]lquantized[sum|zero]()

In legacy DTrace, aggregation signatures for lquantize() and llquantize()
were prepended to the aggregation data.  In the BPF port, this is no
longer the case.  New mechanisms were put in place.

Nevertheless, functions dt_aggregate_[l]lquantized[sum|zero]() still
expected the legacy behavior.

Have dt_aggregate_valcmp() extract the signatures and pass them to
dt_aggregate_[l]lquantizedcmp(), which then relay the signatures to
dt_aggregate_[l]lquantized[sum|zero](), which now expect the signatures
as explicit arguments.

The associated tests used to XFAIL because aggregations keys were not
supported.  Once support was introduced, the tests would XFAIL due to
core dumps due to extracting aggregation signatures from bogus data.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 1cfcd917398861035bbb9ac2d20178c809fc322a
      https://github.com/oracle/dtrace-utils/commit/1cfcd917398861035bbb9ac2d20178c809fc322a
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M cmd/dtrace.c
    M include/dtrace/metadesc.h
    M libdtrace/dt_map.c
    M libdtrace/dt_printf.c

  Log Message:
  -----------
  Eliminate dtagd_id

In the port to BPF, dtagd_varid and dtagd_id are identical.
The longer name better reflects the current meaning.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 488f582b82330b5056052b657d67e94bc9fe7e6f
      https://github.com/oracle/dtrace-utils/commit/488f582b82330b5056052b657d67e94bc9fe7e6f
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M test/unittest/multiaggs/tst.tuplecompat.d

  Log Message:
  -----------
  test: Relieve some strsize pressure

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 737104bd03b08f04c101e1c2c1867095286c29b2
      https://github.com/oracle/dtrace-utils/commit/737104bd03b08f04c101e1c2c1867095286c29b2
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_impl.h

  Log Message:
  -----------
  Eliminate dtahe_aggregate

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 0f01ddbc2ffc8c044f42d240248f8d04e358c2c5
      https://github.com/oracle/dtrace-utils/commit/0f01ddbc2ffc8c044f42d240248f8d04e358c2c5
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_dis.c
    A test/unittest/disasm/tst.ann-gvar-agg.r
    A test/unittest/disasm/tst.ann-gvar-agg.sh

  Log Message:
  -----------
  Make sure disassembly distinguishes between gvars and agg vars

When the disassembler recognizes access of a variable by value,
it looks up a variable name that matches the offset and scope.
The scope of aggregation variables is also "global", however,
and so the presence of aggregations can lead to incorrect
disassembly of global variables.

Check the variable "kind" when looking up variables accessed
by value.

When the disassembler recognizes aggregation names, a similar
test for them can be introduced.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 98f14ba4734be0968e3e0c734d0655d5d4a98612
      https://github.com/oracle/dtrace-utils/commit/98f14ba4734be0968e3e0c734d0655d5d4a98612
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M libdtrace/dt_dis.c
    A test/unittest/disasm/tst.ann-agg.r
    A test/unittest/disasm/tst.ann-agg.sh

  Log Message:
  -----------
  Add disassembly for aggregation variables

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: b0644dc4b2321a5512f42b1f6f0a2ceefe5be263
      https://github.com/oracle/dtrace-utils/commit/b0644dc4b2321a5512f42b1f6f0a2ceefe5be263
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-06 (Tue, 06 Sep 2022)

  Changed paths:
    M test/unittest/aggs/tst.signedkeys.d
    M test/unittest/aggs/tst.signedkeys.r

  Log Message:
  -----------
  test: Fix trace((char)-1) in agg test

Legacy DTrace idiosyncratically printed (char)-1 and (short)-1 as
unsigned.  In the BPF port, the old .r file made the test fail.

Fix the .r results file to show negative values.

While it is assumed that char is signed, strictly speaking char's
signedness is platform-dependent.  So make (char) explicitly signed.

Rewrite the comment block.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f256db8fd572999c72e33017f386dfe0d03bfc04
      https://github.com/oracle/dtrace-utils/commit/f256db8fd572999c72e33017f386dfe0d03bfc04
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    M libdtrace/dt_consume.c
    A test/unittest/actions/setopt/err.D_PROTO_ARG.d
    A test/unittest/actions/setopt/err.D_PROTO_ARG.r
    A test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d
    A test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.r
    A test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.d
    A test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.r
    A test/unittest/actions/setopt/tst.badopt.d
    A test/unittest/actions/setopt/tst.badopt.r
    R test/unittest/misc/tst.badopt.d
    R test/unittest/misc/tst.badopt.r
    R test/unittest/setopt/err.D_PROTO_LEN.toomany.d
    R test/unittest/setopt/err.D_PROTO_LEN.toomany.r

  Log Message:
  -----------
  Implement setopt()

The basic mechanics of the setopt() action are implemented in this
patch.  Each dynamic runtime option that can be set using setopt()
must provide support for it.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 79112e2988e80b1a4fcdf991299a18e1fbf69688
      https://github.com/oracle/dtrace-utils/commit/79112e2988e80b1a4fcdf991299a18e1fbf69688
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  test: Add support for a @@nosort tag

By default, we sort test results before comparing with a .r results
file, since test results often do not have a well-defined order.
For example, probes firing on different CPUs emit output in varying
order.

Some tests, however, check for particular ordering.

Add a tag to suppress the default sort behavior.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: f98d9a5476da13b846e239816bc036466512d8bd
      https://github.com/oracle/dtrace-utils/commit/f98d9a5476da13b846e239816bc036466512d8bd
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M test/unittest/aggs/tst.keysort.d
    M test/unittest/aggs/tst.llquantize_sort.d
    M test/unittest/aggs/tst.llquantsortkey.d
    M test/unittest/aggs/tst.llquantsortsum.d
    M test/unittest/aggs/tst.llquantsortzero.d
    M test/unittest/aggs/tst.neglquant.d
    M test/unittest/aggs/tst.signedkeys.d
    M test/unittest/aggs/tst.signedkeyspos.d
    M test/unittest/aggs/tst.valsortkeypos.d

  Log Message:
  -----------
  test: Add @@nosort tag to agg tests that check sort order

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: fb264ec9f1d5bbc97ebfc296473b72a08b062e2f
      https://github.com/oracle/dtrace-utils/commit/fb264ec9f1d5bbc97ebfc296473b72a08b062e2f
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M test/unittest/aggs/tst.clear.d
    M test/unittest/aggs/tst.clearavg.d
    M test/unittest/aggs/tst.clearavg2.d
    M test/unittest/aggs/tst.cleardenormalize.d
    M test/unittest/aggs/tst.clearlquantize.d
    M test/unittest/aggs/tst.clearnormalize.d
    M test/unittest/aggs/tst.negtrunc.d
    M test/unittest/aggs/tst.negtruncquant.d
    M test/unittest/aggs/tst.trunc.d
    M test/unittest/aggs/tst.trunc0.d
    M test/unittest/aggs/tst.truncquant.d

  Log Message:
  -----------
  test: Annotate tests that require missing features

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 8e73aac9ed76dcffdf8a9269dc08643ac9e9f932
      https://github.com/oracle/dtrace-utils/commit/8e73aac9ed76dcffdf8a9269dc08643ac9e9f932
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M test/unittest/aggs/tst.goodkey.d
    M test/unittest/aggs/tst.goodkey.r.p

  Log Message:
  -----------
  test: Fix tst.goodkey.d

The test uses vtimestamp which is not implemented yet.  It is valid to
substitute i instead.

The post-processor also needs tweaking because it was not properly
substituting numbers in the output with only a single space between them.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 8e48e84c7fa227887682bc11d367e5390f5c4842
      https://github.com/oracle/dtrace-utils/commit/8e48e84c7fa227887682bc11d367e5390f5c4842
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/aggs/tst.typecast-key.d
    A test/unittest/aggs/tst.typecast-key.r

  Log Message:
  -----------
  Fix size for typecast tuple (and aggregation key) components

Components of a tuple (or aggregation key) were being typecast where
needed but if narrowing or widening took place, the storage size to store
the value was never updated.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: 0520b27e4765f9c07305ab1f1e08c85e0e124363
      https://github.com/oracle/dtrace-utils/commit/0520b27e4765f9c07305ab1f1e08c85e0e124363
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M test/demo/user/libc.d

  Log Message:
  -----------
  test: fix test/demo/user/libc.d

It seems that /bin/date is more likely to exist than /usr/bin/date.
Also, the test needs a '@@trigger: none' marker to ensure it actually
gets executed.

The probe range is limited to functions that match m* to reduce the
resource needs for this test.  Since this includes functions like
malloc() it does not affect the operation of the test.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 1e3a49d19df3fd98083dadf65bdc1423e750acac
      https://github.com/oracle/dtrace-utils/commit/1e3a49d19df3fd98083dadf65bdc1423e750acac
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    M test/unittest/variables/bvar/tst.probefunc.d
    M test/unittest/variables/bvar/tst.probemod.d
    M test/unittest/variables/bvar/tst.probename.d
    M test/unittest/variables/bvar/tst.probeprov.d

  Log Message:
  -----------
  test: fix probe* builtin variable tests

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>


  Commit: fa470e438d7c6dd170ce6c45bc8a718a4fa35b2a
      https://github.com/oracle/dtrace-utils/commit/fa470e438d7c6dd170ce6c45bc8a718a4fa35b2a
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-08 (Thu, 08 Sep 2022)

  Changed paths:
    A test/unittest/pid/tst.probefunc.d

  Log Message:
  -----------
  test: add test for probe* bvar support for pid probes

This test exercises the correct support for probefunc for pid probes.
The test is marked @@xfail until probefunc works for pid probes.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 672c4532b1581e0802e3776783f5a9921ad4ed6e
      https://github.com/oracle/dtrace-utils/commit/672c4532b1581e0802e3776783f5a9921ad4ed6e
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-09-09 (Fri, 09 Sep 2022)

  Changed paths:
    M test/unittest/misc/tst.lockmem-cmdline.sh
    M test/unittest/misc/tst.lockmem-envvar.sh
    M test/unittest/misc/tst.lockmem-pragma.sh
    M test/unittest/misc/tst.lockmem-x.sh

  Log Message:
  -----------
  test: Bump up locked memory in lockmem tests

The default aggsize is 4M.  This is the dominant drain on locked
memory for a simple script like "BEGIN { @ = avg(1) }".

The lockmem tests check behavior when the lockmem limit is too
small; anything less than 4M is suitable.

They also check when the lockmem limit is large enough.  We were
using a lockmem limit of 16M, which is clearly inadequate even
for only a few CPUs.

Bump the "large enough" sizes up to 256M, which should be sufficient
even for dozens of CPUs.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: d08cc97aecfc9aff9a17171e8f51b951b8739073
      https://github.com/oracle/dtrace-utils/commit/d08cc97aecfc9aff9a17171e8f51b951b8739073
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-13 (Tue, 13 Sep 2022)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_work.c

  Log Message:
  -----------
  Clean up error reporting in the BPF progran load process

The return value for the attach() provider hook was being passed to
the dtrace_go() through dt_bpf_load_progs(), confusing the dtrace
command line utility which was expecting 0 or -1 (with the proper
error code being set).

It turns out return values were misused in a few other places.  The
code will now explicitly check for -1 as failure indication (and return
-1 explicitly where needed) for dt_aggregate_go(), dt_bpf_gmap_create(),
dt_bpf_load_prog(), and dt_bpf_load_progs().

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: ea1a50cf06d977ec7fb48b3ea8097c592caa26cd
      https://github.com/oracle/dtrace-utils/commit/ea1a50cf06d977ec7fb48b3ea8097c592caa26cd
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-13 (Tue, 13 Sep 2022)

  Changed paths:
    M libdtrace/dt_pid.c

  Log Message:
  -----------
  pid: ignore compiler-generated internal function names

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


  Commit: 16a526d6d9a80c1670be058b2c5dacf6eeefce94
      https://github.com/oracle/dtrace-utils/commit/16a526d6d9a80c1670be058b2c5dacf6eeefce94
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-09-13 (Tue, 13 Sep 2022)

  Changed paths:
    M test/unittest/dif/bcopy.d
    M test/unittest/dif/copyin.d
    M test/unittest/dif/loadX.d
    M test/unittest/syscall/tst.openret.sh
    M test/unittest/vars/tst.ppid.d
    M test/unittest/vars/tst.uid.d

  Log Message:
  -----------
  test: remove @@xfail marker from some tests

Commit dee44bc6 "Add support for copyinstr() subroutine"
	Fixed test/unittest/dif/bcopy.d
	Fixed test/unittest/syscall/tst.openret.sh

Commit d97c8fa7 "Add support for copyin() subroutine"
	Fixed test/unittest/dif/copyin.d
	Fixed test/unittest/dif/loadX.d

Commit febf4570 "Support loading scalars from kernel addresses"
	Fixed test/unittest/vars/tst.ppid.d
	Fixed test/unittest/vars/tst.uid.d

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>


Compare: https://github.com/oracle/dtrace-utils/compare/c2be27a79d84...16a526d6d9a8



More information about the DTrace-devel mailing list