[DTrace-devel] [oracle/dtrace-utils] 936f7e: libproc: make Psystem_daemon() detect modern syste...

euloh noreply at github.com
Wed Aug 6 18:20:43 UTC 2025


  Branch: refs/heads/dev-queue
  Home:   https://github.com/oracle/dtrace-utils
  Commit: 936f7e5a0ba4a742580953c986899a10dde64dd2
      https://github.com/oracle/dtrace-utils/commit/936f7e5a0ba4a742580953c986899a10dde64dd2
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M libproc/Pcontrol.c

  Log Message:
  -----------
  libproc: make Psystem_daemon() detect modern systemd properly

Psystem_daemon() is used when carrying out shortlived grabs to detect
whether a process is too risky to carry out invasive grabs of (you wouldn't
usually want to stop syslogd or, God forbid, try to ptrace PID 1, unless
explicitly requested via -p: the process just coming up in routine probe
firing is not enough).

This has two code paths: a reliable one for systemd systems (which checks to
see if the process is in the system slice, which contains precisely and only
system daemons), and an unreliable one for other systems (which does the old
Unix approach of consdering anything in the user uid range or with a TTY or
with open standard FDs to TTYs to be not system daemons, and everything else
to possibly be one).

We were checking to see if a system was systemd by looking for the systemd
cgroup hierarchy name in any of the victim process's cgroups.  This was
reliable back in the days of cgroups v1, but alas in v2 where systemd runs
all the cgroups if it runs any and there are no longer multiple hierarchies,
systemd no longer names its cgroups this way and the test fails, causing us
to fall back to the unreliable pre-systemd approach.

Use a more reliable approach to detect systemd, the same approach used by
sd_booted() in libsystemd; check for the existence of the
/run/systemd/system directory.  Fix slice detection to work in the absence
of a systemd hierarchy name (but keep it working when a hierarchy name
*is* present, for older systems), and everything else works unchanged.

We also arrange to fall back to the old code for any processes that are
entirely outside of systemd management: this covers kernel threads,
the occasional process that is part of systemd itself, and also processes
running using Delegate= to give over their subtree's cgroup management to
something else.

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


  Commit: 8fee290763aaa12288dc7da762882d8fa7e4a1cc
      https://github.com/oracle/dtrace-utils/commit/8fee290763aaa12288dc7da762882d8fa7e4a1cc
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/tst.onlyenabled.r
    M test/unittest/usdt/tst.onlyenabled.sh

  Log Message:
  -----------
  test: Make the USDT "only enabled" test more stringent

What if a program has an is-enabled probe without the corresponding
parent probe?  It should at least compile, and we test that.

Add more checks to the test:
- the is-enabled branch is not taken when run without dtrace
- the parent USDT probe is listed with "dtrace -l"
- the is-enabled branch is not taken even when run with dtrace
    if the parent probe is not enabled
- the is-enabled branch is taken when run with dtrace
    and the parent probe is enabled;  however, the parent probe
    does not fire since it is not in the test trigger

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


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

  Changed paths:
    M test/unittest/usdt/tst.enable_pid.sh
    A test/unittest/usdt/tst.enable_pid.x

  Log Message:
  -----------
  test: Wait for output to flush out in enable_pid

Our luck with this test has been quite good, but it sometimes fails
to show its last lines of output.  That is, we send a USR1 to the
trigger processes to set off the final output and we immediately
cat the output files.  If there is any delay in handling the signal,
the last output will be missing.

Have the processes terminate themselves when their last output is
flushed; then wait for those processes.  Also, skip testing altogether if
there is only a single processor to run the two, hard-spinning processes.

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


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

  Changed paths:
    M GNUmakefile

  Log Message:
  -----------
  bpf: compile BPF library functions with -ffreestanding

Per Jose, we should be compiling our BPF code with -ffreestanding to
ensure that BPF-specific standard header files are used instead of
host-specific ones.

References:
https://gcc.gnu.org/PR121259
https://bugs.gentoo.org/959876

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Sam James <sam at gentoo.org>
Tested-by: Sam James <sam at gentoo.org>


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

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

  Log Message:
  -----------
  test: Suppress some white space

The test suite turns pointers into "{ptr}" so that results
comparisons will not be sensitive to particular pointer offset
values.

If these offsets change in width -- say, from 0xf0 to 0x100 --
the amount of white space in the postprocessed output can change.

Add additional postprocessing to a test that sometimes fails due
to this problem.

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


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

  Changed paths:
    M test/unittest/pid/tst.manypids.sh

  Log Message:
  -----------
  test: Extend timeout for many-pids test

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


  Commit: 90c51681fd5e347543f02dfc7925f92f133c9080
      https://github.com/oracle/dtrace-utils/commit/90c51681fd5e347543f02dfc7925f92f133c9080
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M INCOMPATIBILITIES
    M cmd/dtrace.c
    A test/unittest/dtrace-util/tst.ListProbes.r
    A test/unittest/dtrace-util/tst.ListProbes.sh

  Log Message:
  -----------
  Make sure all probes are listed in default case

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


  Commit: 633e1c217336bd6d2e18022e8371ac2e047e4b21
      https://github.com/oracle/dtrace-utils/commit/633e1c217336bd6d2e18022e8371ac2e047e4b21
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M libdtrace/dt_prov_uprobe.c

  Log Message:
  -----------
  Optimize USDT discovery a little

We want to reduce the performance cost of USDT discovery if possible.

Specifically, a number of statements -- with probe descriptions such as
"dtrace:::BEGIN" that could never specify USDT probes -- will not get
their clause flags set with DT_CLSFLAG_USDT_EXCLUDE.  So these statements
get considered unnecessarily during periodic probe discovery.

Therefore:

*)  Expand ignore_clause(dtp, n, uprp) to support the case uprp==NULL.
    This case is independent of any knowledge of a specific underlying
    probe.

*)  During probe discovery, check ignore_clause(dtp, i, NULL).  This
    sets the DT_CLSFLAG_USDT_[INCLUDE|EXCLUDE] flag and allows faster
    exclusion of statements that do not need to be reconsidered.

To take advantage of this optimization, users should specify providers.
E.g., instead of "BEGIN" (which could conceivably be a USDT probe),
specify "dtrace:::BEGIN".

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


  Commit: 1cd56071dc6ee552cbd9fdf2465522084d5de557
      https://github.com/oracle/dtrace-utils/commit/1cd56071dc6ee552cbd9fdf2465522084d5de557
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_cg.c
    M libdtrace/dt_impl.h
    A test/unittest/options/err.no-w-or-destructive2.d
    A test/unittest/options/err.no-w-or-destructive2.r
    R test/unittest/usdt/err.Z_no-w.r
    R test/unittest/usdt/err.Z_no-w.sh

  Log Message:
  -----------
  Need -w for destructive actions, even if clause is not used

If a clause includes a destructive action but -w is not used, dtrace
should not start up, even if the clause is ignored (due to -Z).
Solaris treated this as a runtime error.  We should do the same.

The test err.Z_no-w.sh was misguided and is replaced by a more
direct test.

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: 4f58b864a0e61b6ea70465f7e65d3ca64278f533
      https://github.com/oracle/dtrace-utils/commit/4f58b864a0e61b6ea70465f7e65d3ca64278f533
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M include/dtrace/pid.h
    M libdtrace/dt_pid.c
    M libdtrace/dt_prov_uprobe.c

  Log Message:
  -----------
  support stapsdt ELF-note-defined static probes

As well as using dtrace -G to generate USDT probes, programs and
libraries may have added static probes via stapsdt ELF notes.

Read ELF notes from binaries from /proc/ maps associated with processes
and parse them to retrieve uprobe address and argument-related info
to create the associated uprobe.

Probe arguments can be either constants, register values or dereferences
or dereferences from register values (plus offset), identical to the
updated USDT ELF note handling.

A new provider - stapsdt - implements this support, as stapsdt probes do
not dynamically register themselves with DTrace.  This makes them less
powerful than DTrace-based USDT probes, but they do exist in programs and
libraries so should be supported.

As well as supporting ELF-note stapsdt defined probes in programs and
libraries, this patch supports dynamically-created probes that
are created via libstapsdt [1].  libstapsdt allows dynamic languages
like python to declare and fire probes by dynamically creating
a memfd-based shared library containing ELF notes for the probes.
With these changes we can also trace these probes.  This is very
useful since libstapsdt has python, NodeJS, go and luaJIT bindings.

[1] https://github.com/linux-usdt/libstapsdt

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 5d4758679e16b52aea0361c4162cec6b6f714101
      https://github.com/oracle/dtrace-utils/commit/5d4758679e16b52aea0361c4162cec6b6f714101
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/sdt_notes.h
    A test/unittest/usdt/tst.stapsdt-notes.r
    A test/unittest/usdt/tst.stapsdt-notes.sh

  Log Message:
  -----------
  selftests/usdt: add test for stapsdt note-defined probe firing, args

Add test identical to the args tests to verify probe firing and
arg retrieval work for stapsdt notes-defined STAP_PROBEn() probes.
Need a copy of the sdt.h file which is public domain, so add it
in the test directory.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 5771baf4b55eb703e7be05306a6bbd87aa2350f3
      https://github.com/oracle/dtrace-utils/commit/5771baf4b55eb703e7be05306a6bbd87aa2350f3
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/tst.stapsdt-notes-lib.r
    A test/unittest/usdt/tst.stapsdt-notes-lib.sh

  Log Message:
  -----------
  selftests/usdt: add test for stapsdt notes in shared library

To ensure stapsdt notes are found/fire for shared libraries, create
a shared library and trace the stapsdt probes in it.  To ensure the
library is loaded when DTrace has started, call it early in the
program lifetime and sleep until DTrace starts; at that point
trace the probes with the pid and ensure they fire with expected args.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 28d9dae5be730d23fa32690e6e5e665e1422be36
      https://github.com/oracle/dtrace-utils/commit/28d9dae5be730d23fa32690e6e5e665e1422be36
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/tst.stapsdt-notes-args.r
    A test/unittest/usdt/tst.stapsdt-notes-args.sh

  Log Message:
  -----------
  selftests/usdt: add test covering different forms of stapsdt note args

Add a test exercising various arg types supported by stapsdt notes;
register values, register + offset and constants.  The test generates
a binary with probes represented as follows on x86_64:

Displaying notes found in: .note.stapsdt
  Owner                 Data size       Description
  stapsdt              0x00000048       NT_STAPSDT (SystemTap probe descriptors)
    Provider: test_prov
    Name: args
    Location: 0x0000000000400557, Base: 0x00000000004005f8, Semaphore: 0x0000000000000000
    Arguments: -4 at -4(%rbp) 8@%rax 8@%rdx -4@$18

Verify we get expected data for the probe arguments.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: b88e1e4b49c534e32d5ed08739dad90f16a143ca
      https://github.com/oracle/dtrace-utils/commit/b88e1e4b49c534e32d5ed08739dad90f16a143ca
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/tst.stapsdt-notes-pie.sh

  Log Message:
  -----------
  selftests/usdt: add test for stapsdt note-defined probe firing in -fPIE binary

Add test identical to the binary test ensuring that -fPIE is specified
in CFLAGS; this verifies that compilers that use such flags by default
(as is the case for Debian) can instrument stapsdt notes.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


  Commit: 22932a9875ecd01a4d299b869a80ab05ff0f8c7c
      https://github.com/oracle/dtrace-utils/commit/22932a9875ecd01a4d299b869a80ab05ff0f8c7c
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    A test/unittest/usdt/tst.stapsdt-notes-isenabled.r
    A test/unittest/usdt/tst.stapsdt-notes-isenabled.sh

  Log Message:
  -----------
  selftests/usdt: add is-enabled stapsdt tests using semaphores

Is-eanbled probes are implemented using semaphores where the
semaphore address is specified in the ELF notes and passed
in at probe creation time to have the kernel reference-count
probes; this allows us to have argument assembly code that
only gets executed when the stapsdt probe is in use.

Test is-enabled probes and ensure that the kernel-controlled
semaphore is not incremented for disabled probes.  Also test
that provider/probe names with double-underscores are converted
to dashes, i.e. one__probe because :one-probe.

Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>


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

  Changed paths:
    A test/unittest/usdt/tst.stapsdt-notes-l.sh
    A test/unittest/usdt/tst.stapsdt-notes-lv.sh

  Log Message:
  -----------
  test: add -l and -lv tests for stapsdt probes

The stapsdt support in DTrace provides limited support for argument data
for probes.  The number of arguments passed to a probe and their native
type (signed or unsigned int of size 1, 2, 4, or 8 bytes) is discoverable.

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


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

  Changed paths:
    M libdtrace/dt_pid.c
    M libdtrace/dt_prov_uprobe.c

  Log Message:
  -----------
  Fix various memory leaks related to stapsdt and usdt probes

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


  Commit: 907a03a814bf803fb5e1f23469134c007776c04b
      https://github.com/oracle/dtrace-utils/commit/907a03a814bf803fb5e1f23469134c007776c04b
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M test/utils/Build

  Log Message:
  -----------
  test: install get_remote.sh

Otherwise this produces horrible output for every test run in
the entire testsuite when the testsuite is installed from an RPM.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Alan Maguire <alan.maguire at oracle.com>


  Commit: 6cfa1d0143b877527d1b4b72ff39950340123fd7
      https://github.com/oracle/dtrace-utils/commit/6cfa1d0143b877527d1b4b72ff39950340123fd7
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M test/unittest/codegen/tst.tstring_ternary_nested.r

  Log Message:
  -----------
  test: Fix tstring_ternary_nested .r file

In commit 5b20226bc ("cg: optimize ternary expressions for strings"),
new tests were added.  Fix the apparent typo that is in one of them.

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


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

  Changed paths:
    M test/unittest/disasm/tst.vartab-bvar.sh

  Log Message:
  -----------
  test: Remove errant debug statement

In commit e7eaa6216
("test: sdt:task::task_rename takes only 4 args on newer kernels"),
a debug statement was apparently added and left in, causing mismatch
with the .r results file.  Remove the statement.

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


  Commit: 5c639877bfb8da46855f8a23af3d07282424b173
      https://github.com/oracle/dtrace-utils/commit/5c639877bfb8da46855f8a23af3d07282424b173
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2025-08-06 (Wed, 06 Aug 2025)

  Changed paths:
    M test/unittest/actions/return/tst.override-getpid-entry.r.p
    M test/unittest/actions/return/tst.override-getpid-entry.sh
    M test/unittest/actions/return/tst.override-getpid-return.r.p
    M test/unittest/actions/return/tst.override-getpid-return.sh

  Log Message:
  -----------
  test: Fix post processing of return-action override-pid tests

In commit ee8c066e8 ("rawfbt: selectively allow return() in clauses"),
tests were introduced to check that return values are overwritten.  A
pid check value is output and used to facilitate comparisons to a .r
results file.

The post processing logic was flawed in two respects:

1 The check value was being pulled from the "01" entry.  Therefore,
  the "00" entry, typically appearing first, would not be converted.

2 Values were not sorted.  Sometimes this means the disorder just
  described would be avoided and the test would pass.  Mostly,
  it means that behavior can be erratic.

Sort results and use the "00" pid value for converting test results.
Add $dt_flags to the $dtrace line while we're at it.

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


Compare: https://github.com/oracle/dtrace-utils/compare/936f7e5a0ba4%5E...5c639877bfb8

To unsubscribe from these emails, change your notification settings at https://github.com/oracle/dtrace-utils/settings/notifications



More information about the DTrace-devel mailing list