[DTrace-devel] [oracle/dtrace-utils] 4c388b: Add support for the print() action

Kris Van Hees noreply at github.com
Wed Jan 3 16:20:12 UTC 2024


  Branch: refs/heads/devel
  Home:   https://github.com/oracle/dtrace-utils
  Commit: 4c388bfd7430fc4a3e2558410b550b219dd0ba77
      https://github.com/oracle/dtrace-utils/commit/4c388bfd7430fc4a3e2558410b550b219dd0ba77
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M include/dtrace/actions_defines.h
    M include/dtrace/options_defines.h
    M libdtrace/dt_cg.c
    M libdtrace/dt_consume.c
    M libdtrace/dt_errtags.h
    M libdtrace/dt_impl.h
    M libdtrace/dt_open.c
    M libdtrace/dt_options.c
    M libdtrace/dt_printf.c
    M libdtrace/dt_printf.h

  Log Message:
  -----------
  Add support for the print() action

print() [1] prints the address, type and associated values of the data pointed
to by the pointer passed in.  For example:

$ /sbin/dtrace -n 'fbt::ip_rcv_core:entry { print((struct sk_buff *)arg0); }'
dtrace: description 'fbt::ip_rcv_core:entry ' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0  75596                  ip_output:entry 0xffff89ab58f88200 = *
                                            (struct sk_buff) {
                                             (struct) {
                                              .sk = (struct sock *)0xffff9b7ad5df2f80,
                                              .ip_defrag_offset = (int)-706793600,
                                             },
                                             (struct) {
                                              .tstamp = (ktime_t)504907694897760,
                                              .skb_mstamp_ns = (u64)504907694897760,
                                             },
                                             .cb = (char [48]) [
                                             ],
                                             (struct) {
                                              (struct) {
                                               ._skb_refdst = (long unsigned int)18446633550675199489,
                                               .destructor = (void (*)(*) ())0xffffffffb66c0b80,
                                              },
                                              .tcp_tsorted_anchor = (struct list_head) {
                                               .next = (struct list_head *)0xffff9b7ad9cc4601,
                                               .prev = (struct list_head *)0xffffffffb66c0b80,
                                              },
                                              ._sk_redir = (long unsigned int)18446633550675199489,
                                             },
                                             ._nfct = (long unsigned int)18446633547046898499,
                                             .len = (unsigned int)8788,
                                             .data_len = (unsigned int)8736,
                                             .hdr_len = (__u16)320,
                                             .cloned = (__u8)1,
                                             .ip_summed = (__u8)2,

...etc.

Zero-valued fields are skipped to improve compactness of the representation.
Since some data structures are large, the dynamic "printsize" option can be
used to restrict the amount of data displayed; in such cases a "..." connotes
the fact that additional data was present but not shown.

User-defined structures can also be printed:

CPU     ID                    FUNCTION:NAME
  0  75596                  ip_output:entry 0xffff89ab58f88200 = *
                                            (struct foo) {
                                             .a = (int)2,
                                            }

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

[1] https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/dtrace-guide/print-action.html#GUID-533E6BD9-8DE8-474E-9770-96F84244911C


  Commit: 98618feb820dce1b263ab6154ab14edc4357247a
      https://github.com/oracle/dtrace-utils/commit/98618feb820dce1b263ab6154ab14edc4357247a
  Author: Alan Maguire <alan.maguire at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    A test/unittest/print/err.D_PRINT_SIZE.zero.d
    A test/unittest/print/err.D_PRINT_SIZE.zero.r
    A test/unittest/print/err.D_PROTO_ARG.arg.d
    A test/unittest/print/err.D_PROTO_ARG.arg.r
    A test/unittest/print/err.D_PROTO_LEN.toofew.d
    A test/unittest/print/err.D_PROTO_LEN.toofew.r
    A test/unittest/print/err.D_PROTO_LEN.toomany.d
    A test/unittest/print/err.D_PROTO_LEN.toomany.r
    A test/unittest/print/tst.print.local.d
    A test/unittest/print/tst.print.local.r
    A test/unittest/print/tst.print.local.trunc.d
    A test/unittest/print/tst.print.local.trunc.r
    A test/unittest/print/tst.print.local.zeroed.d
    A test/unittest/print/tst.print.local.zeroed.r
    A test/unittest/print/tst.print.regleak.d
    A test/unittest/print/tst.print.regleak.r
    A test/unittest/print/tst.print.skb.d
    A test/unittest/print/tst.print.skb.r

  Log Message:
  -----------
  test: Add print() tests

use local type declaration + alloca() to create custom types for
testing, or use kernel types + alloca().  Verify

- various user-defined types are printed correctly
- zeroed values are skipped
- we truncate display at offset <value> with -x printsize=<value>,
  and can dynamically alter printsize via setopt()
- we can print kernel-defined types
- multiple print()s do not exhaust register needs

For error testing we verify errors are seen

- with a zero-sized type (need to use a kernel type as D compiler
  rejects attempts to create a zero-sized struct)
- with an invalid argument (1)
- with too few arguments (0)
- with too many arguments (2)

Thanks to Eugene for reworking the tests to use the much
cleaner .d/.r format, and providing err.* tests.

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


  Commit: e24fe204078d8406d299115c0eba7739e9255eeb
      https://github.com/oracle/dtrace-utils/commit/e24fe204078d8406d299115c0eba7739e9255eeb
  Author: eugene.loh at oracle.com <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M libdtrace/dt_cg.c

  Log Message:
  -----------
  Allow dt_cg_subr_arg_to_tstring() to take any subroutine arg index

The function dt_cg_subr_arg_to_tstring() is used to generate BPF
code for a variety of subroutines that output temporary strings.
It sets up a BPF function call where one arg is a key arg from
the subroutine being implemented.  Typically the first subroutine
arg is used.

Allow any subroutine arg to be used, both for calculating the
arg value and checking pointers.

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


  Commit: 371ecc1491396337e8f5ddf4b974f7e25726aa09
      https://github.com/oracle/dtrace-utils/commit/371ecc1491396337e8f5ddf4b974f7e25726aa09
  Author: eugene.loh at oracle.com <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M bpf/Build
    A bpf/link_ntop.S
    M libdtrace/dt_cg.c
    A test/unittest/funcs/err.link_ntopbadaddr.r
    A test/unittest/funcs/err.link_ntopbadarg.r
    M test/unittest/funcs/tst.link_ntop.d
    A test/unittest/funcs/tst.link_ntop_runtime_type.d
    A test/unittest/funcs/tst.link_ntop_runtime_type.r

  Log Message:
  -----------
  Add support for the link_ntop() subroutine

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


  Commit: f9f33caaec325e346a1d470adf442b813b3d41b3
      https://github.com/oracle/dtrace-utils/commit/f9f33caaec325e346a1d470adf442b813b3d41b3
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M test/unittest/aggs/tst.quantmany.d

  Log Message:
  -----------
  test: Convert tick-* probes to ioctl:entry for tst.quantmany.d

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


  Commit: 6029a38d266acab431382790d0248b453937e7a1
      https://github.com/oracle/dtrace-utils/commit/6029a38d266acab431382790d0248b453937e7a1
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M test/unittest/aggs/tst.negtrunc.d

  Log Message:
  -----------
  test: Convert tick-* probes to ioctl:entry for tst.negquant.d

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


  Commit: dc2ffd08b4b72a6aba905e92035f670c6cf64bea
      https://github.com/oracle/dtrace-utils/commit/dc2ffd08b4b72a6aba905e92035f670c6cf64bea
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M test/unittest/aggs/tst.trunc0.d

  Log Message:
  -----------
  test: Convert tick-* probes to write:entry probes for trunc() test

In commit 07a56e29b6c1
"test: Convert tick-* probes to write:entry probes for clear() tests",
clear() tests were cleaned up because they rely on tricky interactions
between the producer and consumer.  Make the same change here for a
trunc() test that has been seen to be similarly vulnerable.

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


  Commit: 4632cbdccc40c56043377320cbe2bac064de34a1
      https://github.com/oracle/dtrace-utils/commit/4632cbdccc40c56043377320cbe2bac064de34a1
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M test/unittest/cpc/tst.allcpus.sh

  Log Message:
  -----------
  test: Increase period in cpc allcpus test

Some kernels have problems with clock firings due to throttling.
The CPC allcpus test uses a similar software event because that
event is so ubiquitous.  But, while we have migrated many tests
away from clock ticks due to their fickleness, this test inherently
depends on this unfortunately unstable event.

Nevertheless, it seems that the problems with this event are
mitigated when events fire less often, and we only need one
firing per CPU for this test.

Therefore, increase the period.

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


  Commit: 80ea527cd65acb14033b2b5eeb20498b9856aed0
      https://github.com/oracle/dtrace-utils/commit/80ea527cd65acb14033b2b5eeb20498b9856aed0
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    M bpf/inet_ntoa6.S

  Log Message:
  -----------
  Fix typo

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


  Commit: a7765d6c2a231f64c54e57d8f12d1f2fd55f1907
      https://github.com/oracle/dtrace-utils/commit/a7765d6c2a231f64c54e57d8f12d1f2fd55f1907
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2023-12-21 (Thu, 21 Dec 2023)

  Changed paths:
    M bpf/get_bvar.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_cc.c
    M libdtrace/dt_dctx.h
    M libdtrace/dt_dlibs.c
    A test/unittest/codegen/tst.tstring_overlap_bug.d
    A test/unittest/codegen/tst.tstring_overlap_bug.r

  Log Message:
  -----------
  Dedicate space for call stacks

In the dctx->mem memory block, storage for a call stack and storage
for tstrings overlapped.  The rationale was that a stack() action and
temporary strings would never co-exist.

However, the call stack storage wasn't being used for stack() (or ustack
or jstack) actions at all.  It was being used for stackdepth (and
ustackdepth and jstackdepth) built-in variables.  And they could
co-exist with temporary strings.

So make the call stack storage its own area within dctx->mem.

Add a test to check for the overlap bug.

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


  Commit: 29702ce76f59b8397311eb2ff3d834e83362b880
      https://github.com/oracle/dtrace-utils/commit/29702ce76f59b8397311eb2ff3d834e83362b880
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M libdtrace/dt_conf.c

  Log Message:
  -----------
  Fix uninitialized variable warning on older compilers

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


  Commit: f86b1e276e85c15a1494d59daec8e86e82b08776
      https://github.com/oracle/dtrace-utils/commit/f86b1e276e85c15a1494d59daec8e86e82b08776
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    A include/linux/btf.h
    M libdtrace/Build
    M libdtrace/dt_btf.c
    M libdtrace/dt_btf.h
    M libdtrace/dt_module.c

  Log Message:
  -----------
  btf: support compilation in older environments

Include a btf.h from a recent enough kernel to support all the type
kinds that the BTF-to-CTF convertor provides code for.

Note that the BTF-to-CTF convertor requires libctf.  This patch also
ensures that the BTF-to-CTF convertor is not used when CTF is provided
by libdtrace-ctf (which is deprecated).

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>


  Commit: 9232efc8988a3a6857f33ca33ff4442b5b4c03dd
      https://github.com/oracle/dtrace-utils/commit/9232efc8988a3a6857f33ca33ff4442b5b4c03dd
  Author: Eugene Loh <eugene.loh at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

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

  Log Message:
  -----------
  cg: make dt_cg_ctf_offsetof() non-static and search all modules

The function dt_cg_ctf_offsetof() was searching just in the shared dict.
Have it look for types across all modules.

It is now also available outside of dt_cg.c.

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


  Commit: 7da9e5bb91ac7926625c644545a84623587eeb44
      https://github.com/oracle/dtrace-utils/commit/7da9e5bb91ac7926625c644545a84623587eeb44
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_peb.c
    M libdtrace/dt_prov_cpc.c
    M libdtrace/dt_prov_profile.c
    M libdtrace/dt_prov_rawtp.c
    M libdtrace/dt_provider_tp.c

  Log Message:
  -----------
  bpf, perf: helper functions should return -errno on failure

The bpf() and perf_event_open() helper functions were returning -1 on
failure and callers were supposed to check errno.  Since the only valid
values are >= 0, it would be convenient to avoid the burden on callers
to check for a -1 return value and to then check errno (which can also be
dangerous if there are intermediary functions that could possibly cause
the errno value to change)..

The functions are now renamed dt_bpf() and dt_perf_event_open() to avoid
confusion with possible C library system call wrappers and they now
return -errno on failure so callers can just check the return value
rather than errno.

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


  Commit: 8d9ae281cb49032e5da6094f013e893a7d479bd1
      https://github.com/oracle/dtrace-utils/commit/8d9ae281cb49032e5da6094f013e893a7d479bd1
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M cmd/dtrace.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_probe.c

  Log Message:
  -----------
  probe: propagate dt_probe_args_info() failures to dt_probe_info()

Failures in dt_probe_args_info() were ignored by dt_probe_info() and
that could lead to strange behaviour.  E.g. if lockmem issues cause
the logic in the raw tracepoint argument count determination to fail,
the probe was reported as not having any arguments.  This patch will
make it possible to add code to accurately report such failures
rather than silently ignoring them.

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


  Commit: f59258bb42068917025a81b026560b6131a14d6b
      https://github.com/oracle/dtrace-utils/commit/f59258bb42068917025a81b026560b6131a14d6b
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

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

  Log Message:
  -----------
  options: ensure lockmem is set before retrieving probe info

The rawtp provider uses trial-and-error BPF program loading to determine
the number of arguments for a raw tracepoint.  That requires the lockmem
option value to be applied before probe info is retrieved.

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


  Commit: 27960efda80b14a51d51b4b9257cb992fe114bf2
      https://github.com/oracle/dtrace-utils/commit/27960efda80b14a51d51b4b9257cb992fe114bf2
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M runtest.sh

  Log Message:
  -----------
  test: fix err.* tests forcing XFAIL

Tests cam force an XFAIL condition by returning 67, but when that is
used in err.* tests, it gets reported as XPASS.  It should report
XFAIL no matter what.

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


  Commit: 6a3903c634b12fa0ad61758c404283ce5c11fe32
      https://github.com/oracle/dtrace-utils/commit/6a3903c634b12fa0ad61758c404283ce5c11fe32
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M libdtrace/dt_bpf.c
    M libdtrace/dt_bpf.h
    M libdtrace/dt_cc.c
    M libdtrace/dt_prov_rawtp.c
    A test/unittest/providers/rawtp/err.lockmem-too-low.sh

  Log Message:
  -----------
  rawtp: report lockmem issues when determining rawtp argument count

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


  Commit: d6308814e3467dcfe6599add2cf9743f75baaf8c
      https://github.com/oracle/dtrace-utils/commit/d6308814e3467dcfe6599add2cf9743f75baaf8c
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M libdtrace/dt_prov_rawtp.c
    A test/unittest/providers/rawtp/tst.lv-sched_process_fork.r
    A test/unittest/providers/rawtp/tst.lv-sched_process_fork.r.p
    A test/unittest/providers/rawtp/tst.lv-sched_process_fork.sh

  Log Message:
  -----------
  rawtp: retrieve probe arguments from CTF data

We were determining the number of arguments using a trial-and-error
approach with minimal BPF programs.  If there is CTF type data for
the raw tracepoints (in the form of a function prototype), we use
that because it also gives us the types of the arguments.

If no such CTF data is available, we fall back to the trial-and-error
approach.

The included test will fail if the fallback is used.  There is no way
to force the fallback to get triggered explicitly.

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


  Commit: 46b9a637f79b65b4a74c41a32b5baa18b3918fb1
      https://github.com/oracle/dtrace-utils/commit/46b9a637f79b65b4a74c41a32b5baa18b3918fb1
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

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

  Log Message:
  -----------
  cg: allow non-fatal dt_cg_ctf_offsetof() failures

Lookup failures for a struct member should not always be fatal.  There
is a need to be able to try again (e.g. to support the case where a
struct member was renamed between two kernel versions).

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


  Commit: c30641e10740bb70738d3f5c0e02da4d313b8d57
      https://github.com/oracle/dtrace-utils/commit/c30641e10740bb70738d3f5c0e02da4d313b8d57
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

  Changed paths:
    M libdtrace/dt_cg.c
    A test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d

  Log Message:
  -----------
  cg: do not perform runtime bounds checking on arrays of size 0 or 1

Commit c7d73146 "parser: do not bounds-check arrays of size 0 or 1"
already disabled compile time bounds checking but there are cases
where the bounds checking was done at runtime instead.  Those also
need to ignore arrays of size 0 or 1, for the same reason.

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


  Commit: c99bce85efbaeba72175e0f9f8aa1a2e080d931b
      https://github.com/oracle/dtrace-utils/commit/c99bce85efbaeba72175e0f9f8aa1a2e080d931b
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2024-01-03 (Wed, 03 Jan 2024)

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

  Log Message:
  -----------
  sdt: support min and max kernel versions for probe dependencies

The underlying probes that are used to trigger SDT probes may be kernel
version dependent.  Adding optional minimum and maximum specifications
(using DT_VERSION_NUMBER(x, y, z)) allows us to specify what kernels a
certain dependency can be expected to work on.

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/1dc6bb9b1e50...c99bce85efba



More information about the DTrace-devel mailing list