[DTrace-devel] [PATCH 0/7] char signedness, CTF types, and option handling

Nick Alcock nick.alcock at oracle.com
Tue May 2 17:12:15 UTC 2023


This saga of changes emerged from a change in Linux 6.3: the type of char on
all platforms is now unsigned.  This is the first change in the kernel's
type system on major platforms to make it different from the userspace type
system, but the kernel is a freestanding program: it is not required to
abive abide by the ABI which applies to userspace.  The vmlinux.ctfa, of
course, conforms to the kernel ABI, and the D language largely interoperates
with kernel types, which makes the D language's hardwired list of types look
rather more than slightly wrong.

The first two changes in this series arrange to get the core C types used by
the D language from those emitted by the compiler when the kernel was
compiled. (This forces loading of vmlinux.ctfa at all times, but in practice
translators meant that it was always loaded anyway.  So no slowdown is
expected.)

The subsequent ones deal with the fallout from this change on DTrace's
options-handling system.  Loading types so early means that dtrace_open() is
now affected by the value of the ctfpath option -- but it cannot be set,
because options are set on a running dtp handle, and it's dtrace_open that
creates them: and because ctfpath is only consulted once, this makes ctfpath
useless (procfspath was already in this boat). So we arrange to allow
options to be set *before* then (by being set on a NULL handle): they are
treated as defaults and replayed by (every) dtrace_open(). Of course doing
the actual setopts at dtrace_open() time means that they don't get validated
until then, so the dtrace_setopt() calls cmd/dtrace.c does cannot fail any
more. We fix that by introducing a new type of error handler which is called
by dtrace_setopt() to handle option errors. Doing all the error handling
centrally emans we can make it more elaborate and still end up with less
code, so we can now report the value of rejected options (it has long
annoyed me that DTrace complains about the value of options being wrong
without telling you what the wrong value actually was).

Tested with Eugene's euloh/cleartests branch: all tests pass except four,
which fail because DTrace emits better error messages now (a
--capture-expected will fix that).


This fix, or something like it, is needed for Linux 6.3.

(These commits are all atop nix/review/namespaces-multiprobes-etc, but will
probably apply more widely.)

Nick Alcock (7):
  parser: check for all types of char
  types: populate intrinsics from the kernel if possible
  dtrace: add default options and apply path options earlier
  options: reduce redundancy
  options: centralized error handling
  dtrace: clarity: pass NULL to dtrace_setopt() before dtrace is
    initialized
  options: give the value of rejected options

 cmd/dtrace.c                        | 147 +++++++++++++++------
 libdtrace/dt_impl.h                 |   1 +
 libdtrace/dt_open.c                 |  36 ++++-
 libdtrace/dt_options.c              | 197 +++++++++++++++++++++++-----
 libdtrace/dt_parser.h               |   2 +-
 libdtrace/dtrace.h                  |  25 ++++
 libdtrace/libdtrace.ver             |   1 +
 test/unittest/options/err.version.r |   2 +-
 8 files changed, 335 insertions(+), 76 deletions(-)


base-commit: f543fa6706c0b31364356c01bf3de63e3cce8ad1
prerequisite-patch-id: fa667248b7b02e92ee6b3807123ebcf2ac0acc38
prerequisite-patch-id: 0cec5f1a31d528a493d6143644c1e6b78c7f403b
prerequisite-patch-id: 756ad5b8f08d5595c32dd113d742218991107746
prerequisite-patch-id: eb290f098e38981181d85240150e1713979dc505
prerequisite-patch-id: c25b38ab68e815a63f064aff7496408684f94a36
prerequisite-patch-id: b86eb7e00b5883a586bd4dc7143ab25094912288
prerequisite-patch-id: 6afb164d692c7489562e657ef3be3463ab84da2c
prerequisite-patch-id: 85d3c176dc4a7105e4f04dbcdb4ccbdf18741795
prerequisite-patch-id: 304017f7ef8a078214f6444ecbe0710f869bec71
prerequisite-patch-id: 89cf4c6b9242525883ac02bb8ef90856ef908d0f
prerequisite-patch-id: 0992642ac657a1da617588a6d7b28f3669960374
prerequisite-patch-id: 23fdee31382d18dd3d79a269b24579639e8a3ce6
prerequisite-patch-id: 2f7e015fa509baea3b4edd788a77eeb90ad2c6e7
-- 
2.39.1.268.g9de2f9a303




More information about the DTrace-devel mailing list