[DTrace-devel] [oracle/dtrace-utils] af3b57: Revert "Remove drti.o and related support code."

Kris Van Hees noreply at github.com
Wed Oct 26 21:00:19 UTC 2022


  Branch: refs/heads/dev
  Home:   https://github.com/oracle/dtrace-utils
  Commit: af3b57bb1067180a558edf8f0f8cf13f9a135bef
      https://github.com/oracle/dtrace-utils/commit/af3b57bb1067180a558edf8f0f8cf13f9a135bef
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M Makefunctions
    M libdtrace/Build
    A libdtrace/drti-vers
    A libdtrace/drti.c
    M libdtrace/dt_link.c

  Log Message:
  -----------
  Revert "Remove drti.o and related support code."

We're going to start using drti again, so bring it back.

This reverts commit 1e45252a1e1c9a2ab35e03558dc4e5bbf63ad0d8.

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


  Commit: 95024ee9b015628e6b14672856c96626066cda33
      https://github.com/oracle/dtrace-utils/commit/95024ee9b015628e6b14672856c96626066cda33
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/Build
    M libdtrace/dt_link.c

  Log Message:
  -----------
  drti: emit into a subdirectory

The BPF library loader in dt_dlibs.c assumes that ${libdir}/dtrace/*.o
are all BPF object files.  drti*.o is not, and its presence causes the
initial BPF code load to fail at DTrace startup time.

Move it into a subdirectory to keep it out of trouble.

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: c54acadad06d44f25c57beb3ce7cbab28b418131
      https://github.com/oracle/dtrace-utils/commit/c54acadad06d44f25c57beb3ce7cbab28b418131
  Author: David P. McLean <david.mclean at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/drti.c

  Log Message:
  -----------
  drti: reference first loaded segment of object containing dtrace_dof_init

Any ELF executable or shared library (object) that contains USDT probes
contains a DOF section which describes the probes and also contains a copy
of the dtrace_dof_init() function.  This dtrace_dof_init() function is used
to register the DOF data of the object with the kernel.

The dtrace_dof_init() function needs to identify what type of object it is
being invoked for because the address representation varies (for ELF object
file type ET_DYN the symbol values in the DOF are relative to the load
address of the object rather than absolute values).  The ELF object file
type is obtained from the ELF header and the ELF header is found in the
first mapping (or segment) of the object.

The implementation used previous to this commit was to loop through all
mappings looking for one that contains the address of the dtrace_dof_init()
function.  The assumption was that the executable code mapping with the
dtrace_dof_init() function would always be the first mapping, and since the
ELF header is in the first mapping, the mapping with the dtrace_dof_init()
function would also contain the ELF header.

The assumption was proven wrong where sometimes the dtrace_dof_init()
function is not in the first mapping, and this commit updates the code to:
First loop over the mappings to determine the name of the object containing
the executing dtrace_dof_init() instance and record this object name.
Then a second loop is run over the mappings to determine the mapping with
the lowest start address (which is in fact the first mapping whose name
matches the one recorded from the first loop).

This first mapping of the object contains the ELF header (this ELF header is
used to determine the ELF object file type) and the first mapping start
address is the base address to be passed to the kernel along with the DOF
data.

Signed-off-by: David  Mc Lean <david.mclean at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: d7077ab3168f0101218c819c17ca0037fb2addd1
      https://github.com/oracle/dtrace-utils/commit/d7077ab3168f0101218c819c17ca0037fb2addd1
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_pid.c

  Log Message:
  -----------
  pid: drop dpp_stret

These structure-return thunks in the Solaris libc have never existed on
Linux, nor anything like them, so these calls will always fail.

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: 0811eb4fad43249974d18cc1c8980e268ec43fb9
      https://github.com/oracle/dtrace-utils/commit/0811eb4fad43249974d18cc1c8980e268ec43fb9
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  runtest: make ZAPTHESE an array

This lets us reliably have multiple elements in ZAPTHESE, removing those
that have died naturally without disturbing the others that might still
be running.

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


  Commit: b81f4b1cda4438706e75c84a29325d0f743b2dc1
      https://github.com/oracle/dtrace-utils/commit/b81f4b1cda4438706e75c84a29325d0f743b2dc1
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M include/dtrace/actions_defines.h
    M include/dtrace/dof_defines.h
    M test/Build
    A test/internals/headers/tst.header-endianness.sh

  Log Message:
  -----------
  uapi headers: include <sys/dtrace_types> as needed

This is needed for _LITTLE_ENDIAN and _BIG_ENDIAN.

Add a new internals test to identify this class of failure: add a
tag 'uninstalled' which is disabled in the installed tree to prevent it
from being executed as part of the installed testsuite (since it is not
particularly useful outside the installed set, and making it work in
both places would be complicated and annoying).

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


  Commit: af18c41da929a08dd5c5f7dc904dab3afad80030
      https://github.com/oracle/dtrace-utils/commit/af18c41da929a08dd5c5f7dc904dab3afad80030
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_link.c

  Log Message:
  -----------
  dt_link: finish backing out varint, fixing dt_link-generated object files

For a while now, linking dtrace -G-generated object files has been
saying

/usr/bin/ld: .../build/test-triggers--usdt-tst-special.o: error adding symbols: no error

This is more than slightly confusing.  For starters, collect2 is
corrupting the error message: the actual error is

/usr/bin/ld: .../build/test-triggers--usdt-tst-special.o: error adding symbols: file format not recognized

This is not much more helpful.  The actual cause is in
elf_link_add_object_symbols:

      name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
					      isym->st_name);

where the symbol name comes out as NULL.  This is because we are hitting
a sanity check in bfd_elf_string_from_elf_section:

      /* PR 24273: The string section's contents may have already
	 been loaded elsewhere, eg because a corrupt file has the
	 string section index in the ELF header pointing at a group
	 section.  So be paranoid, and test that the last byte of
	 the section is zero.  */
      if (hdr->sh_size == 0 || hdr->contents[hdr->sh_size - 1] != 0)
	return NULL;

This paranoia has won out! We are generating string tables with
hdr->sh_size one too small, pointing at the last byte of the last
string.

The cause is somewhat gross.  dt_link.c:process_obj computes the length
of the new strtab it's constructing by adding all the symbol names to a
dt_strtab, asking it for its size, subtracting one for the \0 at the
first byte, and then throwing the strtab away and directly editing the
strtab in the object file, using the strtab it generated earlier only
for its size.  Doing things in two stages like this is a bit risky: it's
riskier yet because it's using a dt_strtab, which is not a model of an
ELF strtab at all but rather of a DTrace string table.  No harm, they're
the same: except that when varints landed the format of a string
naturally changed to gain an extra length byte at the start. The size
computation was changed to subtract two bytes rather than one (itself
buggy: *every string in the strtab* had an extra byte on the front of
it, so the wrong number of bytes was being subtracted and the resulting
sh_size was too large).  But when the varint code was backed out (in
29e3f422 "Remove the string length prefix"), this size computation was
not changed back, leading to a sh_size that is one byte too low,
triggering this failure.

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


  Commit: 0ca8be9e8e0a84e8cba4a9043165345672205c38
      https://github.com/oracle/dtrace-utils/commit/0ca8be9e8e0a84e8cba4a9043165345672205c38
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

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

  Log Message:
  -----------
  providers: allow providers with no trampoline

Such providers can be enabled just like any other, but generate no code.

Meant for use by providers like pid which have some probes without
trampolines (but which enable other probes which do contain trampolines
that execute on their behalf).  Both such probes need enabling because
we want to ensure their names are interned, etc: we only want to avoid
trying to execute their trampoline when there is none.

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


  Commit: 4bf7eea1edc7a381c6f180993c87b5bf9ba921d3
      https://github.com/oracle/dtrace-utils/commit/4bf7eea1edc7a381c6f180993c87b5bf9ba921d3
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M Makeconfig

  Log Message:
  -----------
  build: add header+symbol checking

The new check-header-symbol-rule Makeconfig rule allows checking to see
whether a header #inclusion plus a symbol usage plus a given -l library
usage compiles and links successfully.  It's analogous to the Autoconf
AC_TRY_COMPILE macro.

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


  Commit: 89f5863e1a4abf21cfb72b9fb3befa88445aedd2
      https://github.com/oracle/dtrace-utils/commit/89f5863e1a4abf21cfb72b9fb3befa88445aedd2
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M Makeconfig
    M include/port.h
    M libport/Build
    A libport/close_range.c
    A libport/daemonize.c

  Log Message:
  -----------
  port: add daemonization support code

This assists in writing reliable daemons, providing a close_range() that
works on older glibc/kernel combinations, and a daemonize() which
provides a synchronization pipe down which error messages can also be
sent, so that errors occurring after daemonize() is called but before
the daemon is fully working can be reliably reported.

(This uses the check-header-symbol-rule feature just added to let us
verify not only that close_range() is present in libc, but that it's
present in the headers and has the right prototype.  The history of
close_range is a right tangled mess... as usual with glibc features,
linking isn't required to work unless the header is included too, so
we test both at once.)

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


  Commit: 1312744737395c090641bacd4176045aa63971c9
      https://github.com/oracle/dtrace-utils/commit/1312744737395c090641bacd4176045aa63971c9
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M include/sys/sol_procfs.h
    M libproc/Pcontrol.h
    M libproc/Psymtab.c
    M libproc/libproc.h

  Log Message:
  -----------
  libproc: add Pinode_to_file_map()

This lets you rapidly look up the prmap_file_t that corresponds to a
(dev, ino) pair in a given process's mappings.  This is useful when
dealing with uprobes, which work on an *inode* basis, not a process
basis or even a mapping basis: we can use this to see whether a process
we are otherwise interested in has ownership of a given (dev, ino)
mapping rapidly, and what the details of the mapping are.

Do it with a hash table rather than linear iteration because these days
it is getting increasingly common to have processes with a great many
mappings.  Chromium has 1638 mappings on my system, of which 411 are
file-backed, but the real mapping king these days is Emacs with native
compilation, which maps every Lisp file as a separate shared object:
3618 mappings, of which 3135 are file-backed!

While we're at it, rename the (Psymtab.c-private) Pprmap_file_by_name
to Pfilename_to_file_map, so that all prmap_file_t functions have
consistent names (and names less terrible than Pprmap_file_by_name).

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


  Commit: f048fadd3aed9b4e30fcd994accc5c6df4f7591e
      https://github.com/oracle/dtrace-utils/commit/f048fadd3aed9b4e30fcd994accc5c6df4f7591e
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libproc/Psymtab.c

  Log Message:
  -----------
  libproc: fix double-free on error path

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


  Commit: 26dcaab12b07490a4f5f5811e84f1f191d983bfb
      https://github.com/oracle/dtrace-utils/commit/26dcaab12b07490a4f5f5811e84f1f191d983bfb
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    A libcommon/Build
    A libcommon/GNUmakefile
    A libcommon/dt_list.c
    A libcommon/dt_list.h
    M libdtrace/Build
    R libdtrace/dt_list.c
    R libdtrace/dt_list.h
    M libproc/Build
    M libproc/Pcontrol.c
    M test/triggers/Build
    M test/utils/Build

  Log Message:
  -----------
  usdt: common infrastructure

USDT will include a daemon that implements a CUSE device that programs
containing USDT probes issue ioctl()s to.  This daemon needs to create
uprobes, and this needs to use libproc to extract information about the
processes (like mapping addresses, etc).  This is something the rest of
DTrace can already do: so split out infrastructure needed by libproc and
infrastructure needed to create uprobes into a new libcommon (static)
library that the daemon can use.  Make tiny adjustments to libproc and
triggers that use it so that libproc can stand independent of libdtrace
(it was very nearly there already: only one debugging statement change
and a move of dt_list into the common library is needed).

A future commit will adjust DTrace to use this library to create uprobes
too.

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


  Commit: f387a2d3d467bfc60845e5957bc157d5abd366eb
      https://github.com/oracle/dtrace-utils/commit/f387a2d3d467bfc60845e5957bc157d5abd366eb
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    A include/tracefs.h
    M libcommon/Build
    A libcommon/uprobes.c
    A libcommon/uprobes.h
    M libdtrace/dt_prov_dtrace.c
    M libdtrace/dt_provider.h

  Log Message:
  -----------
  libcommon: move uprobes creation into the common library

This commit adds functions in the libcommon library to create uprobes
given a pid and address, create uprobes given more detailed info (a
(dev, ino, addr) triplet, a spec for the uprobe_events file, and a
DTrace probe name), and compute a spec. We also provide
encoding/decoding functions to allow the uprobe to contain the DTrace
probe name as part of its args even though DTrace probes can contain
characters that are not allowed in uprobe names or arg names, and even
though probe arg names must be unique while DTrace probe name components
need not be.

The DTrace provider is rejigged to use this code to generate the
BEGIN/END/ERROR probes, to make sure this code works.

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


  Commit: 3fac45fc129835d68279889444890ea7e241f96e
      https://github.com/oracle/dtrace-utils/commit/3fac45fc129835d68279889444890ea7e241f96e
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M Makeoptions
    M libcommon/Build
    A libcommon/dof_parser.c
    A libcommon/dof_parser.h
    A libcommon/dof_parser_host.c

  Log Message:
  -----------
  libcommon: DOF parsing

This commit adds a DOF parser, derived from DTrace v1 but simplified.
The parser is intended to run in a strict-mode seccomp jail, and does no
I/O except via pre-provided file descriptors.  The host side should do
I/O using the functions in dof_parser_host.h.

The seccomp parser child returns output as a stream of dof_parsed_t
records, which are variable-length records with an early size member
(the reader code in dof_parser_host.c takes care of reading the right
amount of data).  Errors are returned as PIT_ERR records in this stream,
or signified by a simple crash (in which case the invoker can simply
restart it).

The parser has a notably noisy debugging mechanism which can be turned
on via make dof_dbg=yes (it is separate from make debugging=yes because
it makes the daemon emit lots of stuff on stderr, which you're unlikely
to want unless you're actually debugging USDT itself).

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


  Commit: 25cb72704f325aa54a2c7b7753caa404ff279a67
      https://github.com/oracle/dtrace-utils/commit/25cb72704f325aa54a2c7b7753caa404ff279a67
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M GNUmakefile
    M Makeconfig
    A dtprobed/60-dtprobed.rules
    A dtprobed/Build
    A dtprobed/GNUmakefile
    A dtprobed/dtprobed.c
    A dtprobed/dtprobed.service
    A dtprobed/dtrace-usdt.target
    A dtprobed/rpl_fuse_log.c
    A dtprobed/rpl_fuse_log.h
    M dtrace.spec
    M runtest.sh

  Log Message:
  -----------
  usdt: daemon

This commit adds a daemon, "dtprobed", which usually runs at boot
(monitored by systemd, if possible), providing /dev/dtrace/helper using
CUSE, accepting DOF from processes doing the usual DTrace ioctl()s to
that device, and using infrastructure in prior commits in this series to
pass the DOF to a child jailed with seccomp() for parsing, and accepting
structures containing parsed results back, then emitting uprobes from
these results before allowing the ioctl()ing.  The uprobes created have
stereotyped names and argument lists that include an encoded
representation of the name of the corresponding DTrace USDT probe.  (The
name also contains the address and a number of other things, so that
probes that appear in multiple places in a process still work.)

(The CUSE device is an "unrestricted ioctl" device, which restricts
dtprobed to running only as root, because the ioctl has to pull data --
the DOF -- out of arbitrary places in the client memory according to the
passed-in structure. Since you need to be root to create uprobes at all
this is not any kind of restriction.)

Extra complexity is provided by changes to libfuse.  Recent (> 2018)
libfuse has a nice logging interface, which if available means that
libfuse will log FUSE-side problems into syslog or anywhere else of your
choosing: we emit into syslog if -d or -F (debug, foreground) are not
specified and systemd is not in use (if systemd is in use, we never
daemonize at all).  But older libfuse does not provide this, and
unfortunately OL8 (but not OL7!) has such an older libfuse.  So we add a
compatibility wrapper providing a minimal reimplementation of the
logging interface if built against such an old libfuse.  The wrapper is
named like the header and source file implementing the real thing in
FUSE itself, but prepended with rpl_ to avoid the possibility of
dependencies on header file ordering when the new FUSE code is present.

Testing-wise, in installed mode the running dtprobed daemon is used, but
in in-source-tree mode runtest.sh kicks off a new dtprobed emitting to a
local device file named /dev/dtrace/test-$pid, and uses a new
testing-only environment variable to force drti.c to emit its ioctl()s
to that temporary device.  So in-tree testing always tests the actual
dtprobed in the tree (with any bugfixes), not the system copy.

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


  Commit: 5f0780f2019ce6a53efb448bc66ec3bc3183ce6a
      https://github.com/oracle/dtrace-utils/commit/5f0780f2019ce6a53efb448bc66ec3bc3183ce6a
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/drti.c

  Log Message:
  -----------
  drti: use /proc/self/maps

This works in conjunction with PID namespaces where using getpid() does
not.

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: d7fbbd82aa979ad938d741e2a0f903287263126a
      https://github.com/oracle/dtrace-utils/commit/d7fbbd82aa979ad938d741e2a0f903287263126a
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_prov_fbt.c
    M libdtrace/dt_prov_syscall.c
    M libdtrace/dt_provider_tp.c

  Log Message:
  -----------
  fbt, syscall: use getline(), not fgets()

This lets us drop lots of code to handle too-long lines.  (Done for
consistency with the pid provider, which will do the same thing in a
subsequent commit.)

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: 1a21c9ba4ef391ab4063a0713fd7154fd06be94a
      https://github.com/oracle/dtrace-utils/commit/1a21c9ba4ef391ab4063a0713fd7154fd06be94a
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_dof.c

  Log Message:
  -----------
  dof: don't emit providers with no probes

Without this, you end up with DOF with a lot of zero-probe providers
in.  This not only wastes space but causes the DOF to fail validation
(arguably unnecessarily, but why waste the space in the first place?)

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


  Commit: 13152accceb5f0f993c50e7405d324392d8b4b1f
      https://github.com/oracle/dtrace-utils/commit/13152accceb5f0f993c50e7405d324392d8b4b1f
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libcommon/uprobes.c
    M libcommon/uprobes.h

  Log Message:
  -----------
  libcommon: add uprobe_name() and uprobe_delete()

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


  Commit: 876827b0fd6512174e0074675e4ed7b65d594966
      https://github.com/oracle/dtrace-utils/commit/876827b0fd6512174e0074675e4ed7b65d594966
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M include/dtrace/pid.h
    M libdtrace/Build
    M libdtrace/dt_cg.c
    M libdtrace/dt_cg.h
    M libdtrace/dt_impl.h
    M libdtrace/dt_open.c
    M libdtrace/dt_pid.c
    M libdtrace/dt_pid.h
    M libdtrace/dt_prov_fbt.c
    R libdtrace/dt_prov_pid.c
    M libdtrace/dt_prov_sdt.c
    A libdtrace/dt_prov_uprobe.c
    M libdtrace/dt_provider.h

  Log Message:
  -----------
  usdt: DTrace userspace side

This is implemented almost entirely along with the pid provider, which is
reassuringly similar to how it was done in the in-kernel days. They're
really very closely-related beasts, and the same uprobe-based code can
handle both easily enough.  To reflect this, dt_prov_pid.c is renamed to
dt_prov_uprobe.c.

This does several things that are sufficiently intertwined that putting
them in one commit seems most readable:

 - implements USDT probe discovery, ripping out a lot of old ioctl stuff
   and obsolete code handling stuff like structure-copying thunks in the
   Solaris C library and a bunch of obsolete functions around DOF
   acquisition (keeping one which might well be revived in the next
   phase), and adding dt_pid_create_usdt_probes, which scans the
   systemwide uprobe list and creates DTrace-side USDT probes (and their
   associated underlying uprobe-based probes) for any that are relevant
   (see below), using an sscanf-based parser: the uprobe naming scheme
   was designed so that it works with the limitations of such parsers.
   Thanks to the %m conversion specifier there is no risk of buffer
   overrunning if the name components are unexpectedly long.

   Right now this can only create probes for specific processes (those
   named on the command line in probe names, as usual), but in future
   it'll grow the ability to make probes for everything dtprobed has
   spotted probes for.  Because it is driven by the systemwide uprobe
   list, it can create probes for processes that started before DTrace
   did, just like the old in-kernel model.

 - rejigs the pid provider support in dt_prov_uprobe.c (formerly
   dt_prov_pid.c) to use the new uprobe_create mechanism to make pid
   probes, with names consistent with uprobes created by dtprobed for
   USDT probes; the uprobes have names like dt_pid/[pr]_$dev_$ino_$addr.
   USDT probes pass their name components down as encoded uprobe
   arguments, viz:

   p:dt_pid/dt_2d_231d_7fbe933165fd /tmp/runtest.17112/usdt-dlclose1.123064.9010/livelib.so:0x15fd Ptest_prov=\1 Mlivelib__2eso=\2 Fgo=\3 Ngo=\4

   (The [PMFN] prefix is added and stripped off automatically by the
   name en/decoder, and makes sure that no two "args" have the same
   name, even if the probe component is the same, as above.)

 - provides provide_usdt_probe to be called at USDT probe discovery
   time to create USDT probes and their underlying uprobe-based probes.
   The creation of the underlying uprobe-based probes is split off into
   a new funtion create_underlying that is also used for pid probes.
   Probe naming is designed to ensure that USDT probes and pid probes
   that are created at the same offset are associated with the same
   underlying probe.

   The struct dt_uprobe attached to the underlying probe gains a device
   number (which it should always have had) and keeps track of the
   underlying uprobe name from create_uprobe or USDT probe discovery
   and remembers whether or not DTrace created it (if dtprobed created
   it, dtrace must not delete it).

   USDT probes can be associated with more than one underlying probe
   (if the probe appears repeatedly in a program).  Repeated calls to
   provide_usdt_probe for the same probe description but with different
   offsets will cause the USDT probe to be chained into the appropriate
   underlying probes (creating them as needed).

 - enabling gets a little more complex.  We intern both the overlying
   (pid and USDT) probe *and* the associated underlying probe in the
   enablings list (by getting ->enable for the pid/USDT probe to walk
   its list of underlying probes and enable all of them), and to also
   add itself to the enablings list.

 - Trampoline generation has to adapt to this, but also has to use a
   less kludgy way of figuring out the pids the trampoline applies to:
   rather than parsing the name apart on the spot, we ask dt_pid, which
   already has code to *properly* parse apart both pid and usdt names
   and extract the pid from them.

 - stack arg handling needs a bit of a tweak.  USDT probes can take a
   set of arguments that and are implemented as a fake function call.
   The underlying uprobe is placed right after the argument setup and
   therefore should be retrieved without applying PT_REGS_ARGSTKBASE
   for platforms on which PT_REGS_ARGSTKBASE > 0.  The underlying
   probe gets the PP_IS_FUNCALL flag set to indicate this.

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


  Commit: d6af0edaab61259b48a0a9e4f998546cf393cb6f
      https://github.com/oracle/dtrace-utils/commit/d6af0edaab61259b48a0a9e4f998546cf393cb6f
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M test/triggers/Build
    M test/unittest/pid/tst.provregex3.sh
    A test/unittest/usdt/tst.args-alt.aarch64.x
    M test/unittest/usdt/tst.args-alt.d
    M test/unittest/usdt/tst.args.d
    M test/unittest/usdt/tst.dlclose1.sh
    M test/unittest/usdt/tst.dlclose2.sh
    M test/unittest/usdt/tst.dlclose3.sh
    R test/unittest/usdt/tst.dlclose3.x
    M test/unittest/usdt/tst.eliminate.sh
    M test/unittest/usdt/tst.enable.d
    M test/unittest/usdt/tst.enable_and.d
    M test/unittest/usdt/tst.enable_and_2.d
    M test/unittest/usdt/tst.enable_or.d
    M test/unittest/usdt/tst.enable_or_2.d
    M test/unittest/usdt/tst.enable_return.d
    M test/unittest/usdt/tst.enable_stmt.d
    M test/unittest/usdt/tst.enabled.sh
    M test/unittest/usdt/tst.enabled2.sh
    M test/unittest/usdt/tst.entryreturn.sh
    M test/unittest/usdt/tst.fork.sh
    M test/unittest/usdt/tst.guess32.sh
    M test/unittest/usdt/tst.guess64.sh
    A test/unittest/usdt/tst.lingering.r
    A test/unittest/usdt/tst.lingering.sh
    M test/unittest/usdt/tst.multiple.sh
    M test/unittest/usdt/tst.reeval.sh
    M test/unittest/usdt/tst.static.sh
    M test/unittest/usdt/tst.static2.sh
    M test/unittest/usdt/tst.tailcall.d

  Log Message:
  -----------
  usdt: testsuite updates

A lot of tests can be enabled now, but a lot are still XFAIL: anything
that relies on is-enabled probes, systemwide probing, globbing of USDT
probe names, or args which are non-integral are guaranteed broken.

We add one new test to make sure that you can run a probe-containing
program and then repeatedly probe it from multiple dtraces in turn
without them messing up each others' probes in any way: the probes
linger from one dtrace to the next.  (Doing it from multiple dtraces in
*parallel* may well not work yet, as no specific code has been written
to make it work: that's planned for the next phase.)

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


  Commit: 827e4e22c72b52e280e8113fe022bd4eeb0b080d
      https://github.com/oracle/dtrace-utils/commit/827e4e22c72b52e280e8113fe022bd4eeb0b080d
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  test: Signal an error if trigger does not exist

The behavior had been to ignore the trigger silently, leading to
mystifying outcomes.

Clean up a few other minor issues in runtest.sh.

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


  Commit: ef080b483c7225c3e55f65a4045fbda4de1f3041
      https://github.com/oracle/dtrace-utils/commit/ef080b483c7225c3e55f65a4045fbda4de1f3041
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_pid.c

  Log Message:
  -----------
  pid: drop more Solaris-specific bug workarounds

We definitely don't have any old binaries that exhibit a problem only
observed on old versions of Solaris lacking modern ELF constructors.

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


  Commit: 7f01099f039399a6cd03be03bc8b3602989ec62f
      https://github.com/oracle/dtrace-utils/commit/7f01099f039399a6cd03be03bc8b3602989ec62f
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M test/unittest/pid/tst.probefunc.d
    M test/unittest/pid/tst.weak1.d
    M test/unittest/pid/tst.weak2.d

  Log Message:
  -----------
  pid: a few more tests are now passing

These all depended on probefunc etc working.

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


  Commit: 9cd99d9b3e7d68bc1c952ea5cbddd2822c8aa690
      https://github.com/oracle/dtrace-utils/commit/9cd99d9b3e7d68bc1c952ea5cbddd2822c8aa690
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libproc/Psymtab.c

  Log Message:
  -----------
  libproc: add the dev/ino pair to the mapping debug printout

This helps correlation with usdt probes, which are filtered out (really,
filtered in) by the dev/ino.

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


  Commit: cfd19c9213fdd37fd22741ffda1e9711bacb77ef
      https://github.com/oracle/dtrace-utils/commit/cfd19c9213fdd37fd22741ffda1e9711bacb77ef
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_parser.c

  Log Message:
  -----------
  String constants should be marked as DT_NF_DPTR

Although string constants are represented using a scalar offset into the
string constant table, the generated BPF code uses actual pointers into
the string constant table.  They are therefore pointers to DTrace-managed
storage (DT_NF_DPTR).

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


  Commit: ed795c767be4f766be3836f5ba7f34f08d2937a1
      https://github.com/oracle/dtrace-utils/commit/ed795c767be4f766be3836f5ba7f34f08d2937a1
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-10-25 (Tue, 25 Oct 2022)

  Changed paths:
    M libdtrace/dt_parser.c
    A test/unittest/codegen/tst.execname-idx.d

  Log Message:
  -----------
  Ensure that 'execname' is not marked DPTR

The 'execname' builtin variable is a notable exception to REF-type
variables being DTrace-managed pointers.  It is a pointer into the
task_struct and therefore needs to be explicitly excluded from the
DPTR marking of variable nodes.

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


  Commit: 8dca63703aaa9816814bef3f85e888718a2eeef2
      https://github.com/oracle/dtrace-utils/commit/8dca63703aaa9816814bef3f85e888718a2eeef2
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-10-26 (Wed, 26 Oct 2022)

  Changed paths:
    M bpf/strcmp.S
    M libdtrace/dt_cg.c
    M test/unittest/builtinvar/tst.execname.d
    A test/unittest/codegen/tst.execname-cmp-bvar_lhs.d
    A test/unittest/codegen/tst.execname-cmp-bvar_rhs.d
    A test/unittest/codegen/tst.execname-cmp-const_lhs.d
    A test/unittest/codegen/tst.execname-cmp-const_rhs.d
    A test/unittest/codegen/tst.kernel_str-cmp-bvar_lhs.d
    A test/unittest/codegen/tst.kernel_str-cmp-bvar_rhs.d
    A test/unittest/codegen/tst.kernel_str-cmp-const_lhs.d
    A test/unittest/codegen/tst.kernel_str-cmp-const_rhs.d

  Log Message:
  -----------
  String args to dt_strcmp() need to be copied if not DPTR

The dt_strcmp() implementation makes use of indirect load instructions
to retrieve characters from either string argument.  That only works for
DTrace-managed storage pointers.  So, any argument that is not marked
DT_NF_DPTR must be copied into a tstring before the indirect loads are
done.

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


  Commit: b3bed150a838277cc5b06f3d226e5e79dec85f95
      https://github.com/oracle/dtrace-utils/commit/b3bed150a838277cc5b06f3d226e5e79dec85f95
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2022-10-26 (Wed, 26 Oct 2022)

  Changed paths:
    A test/unittest/operators/tst.str_comparison-basic-with-NULL.d
    M test/unittest/operators/tst.str_comparison-basic.d

  Log Message:
  -----------
  test: split tst.str_comparison-basic.d into with and without NULL testing

Since NULL strings are not supported yet, the tst.str_comparison-basic.d
test is failing even though the non-NULL case should PASS without any
problem.  The test is now written as two tests: one that exercises the
case of NULL strings and one that does not.

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/16a526d6d9a8...b3bed150a838



More information about the DTrace-devel mailing list