[DTrace-devel] [oracle/dtrace-utils] 7d659c: parser: fix parser debugging yet again

Kris Van Hees noreply at github.com
Thu Oct 2 22:41:29 UTC 2025


  Branch: refs/heads/dev-queue
  Home:   https://github.com/oracle/dtrace-utils
  Commit: 7d659c9250d5c58c5e3ea0b7c7e0543f859b2ff5
      https://github.com/oracle/dtrace-utils/commit/7d659c9250d5c58c5e3ea0b7c7e0543f859b2ff5
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-10-02 (Thu, 02 Oct 2025)

  Changed paths:
    M libdtrace/dt_impl.h
    M libdtrace/dt_lex.l

  Log Message:
  -----------
  parser: fix parser debugging yet again

The interaction between YYDEBUG and the yydebug extern variable has
changed repeatedly in the various iterations of flex and bison.  The one
thing that is consistent is that yydebug is not used if YYDEBUG is unset
or set to 0; if it's set to 1, the parser skeleton defines it for you.

So (now that -fno-common is on by default) dl_lex.l should not be
defining yydebug itself, and dt_impl.h should only be declaring it
extern if YYDEBUG is 1.

With this in place, we link and run with the parser debugger set to the
expected state when compiling with YYDEBUG 1, YYDEBUG 0, and YYDEBUG
unset.

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


  Commit: c9a90f92419a0da97f996c928882bf2803b0be2b
      https://github.com/oracle/dtrace-utils/commit/c9a90f92419a0da97f996c928882bf2803b0be2b
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-10-02 (Thu, 02 Oct 2025)

  Changed paths:
    M libdtrace/dt_lex.l
    M libdtrace/dt_pcb.h

  Log Message:
  -----------
  lexer: the things inside an enum { ... } declaration are identifiers

The code in dt_lex.c:id_or_type() tries to figure out if something is an
identifier or not: if it cannot prove it is an identifier, it concludes
it must be a type name, which later triggers a search for said type (or
identifier) which eventually reaches (expensively) across the entire
kernel CTF.  Usually this is what we want, since we use type names that
actually reside in the kernel extensively and do not expect to have to
decorate all of them with `. But if this misfires bad things can happen.

In the case of enums, existing code in dt_decl.c checks for duplicate
identifiers, and carefully avoids considering code outside the C and D
dicts to be duplicates: but if id_or_type() concludes this enumerator is
probably a type name, we'll import the thing we find even if it's an
identifier, and then conflict. Enumerators cannot be type names, so this
must always be wrong (if we actually do put a type name in there,
dt_parser.c will correctly reject it no matter what the lexer says).

So add yet another piece of parser context identifying when we are
inside the { } in an enum (we set it to 1 when the enum is seen, then
bump it when the braces are seen, so if it's 2 we are in the relevant
context; it is reset to 0 on every ;), then use that to forcibly declare
everything seen inside enums an identifier without trying to chase it
down

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


  Commit: 967cb6cbcf0dff3e95c63c1e12a9283b25930e32
      https://github.com/oracle/dtrace-utils/commit/967cb6cbcf0dff3e95c63c1e12a9283b25930e32
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-10-02 (Thu, 02 Oct 2025)

  Changed paths:
    A test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.d
    A test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r
    A test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r.p
    A test/unittest/enum/err.D_SYNTAX.RepeatTypeNames.d
    R test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d
    R test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r
    R test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r.p
    A test/unittest/enum/tst.EnumKernelDup.d
    A test/unittest/enum/tst.EnumKernelDup.r
    A test/unittest/types/err.D_DECL_IDRED.dupenum.d
    A test/unittest/types/err.D_DECL_IDRED.dupenum.r
    A test/unittest/types/err.D_DECL_IDRED.dupenum.r.p
    R test/unittest/types/err.D_UNKNOWN.dupenum.d
    R test/unittest/types/err.D_UNKNOWN.dupenum.r
    R test/unittest/types/err.D_UNKNOWN.dupenum.r.p

  Log Message:
  -----------
  test: enum tests

A couple of new tests verifying that type names appearing in enums are
forbidden, as well as that kernel-visible identifiers are permitted;
and a renaming of the D_UNKNOWN tests now that libctf can be assumed
to be everywhere and it's probably more common to have a libctf that
emits a good description of this failure than the converse.

(The previous commit changes the error messages in this case back to
what they used to be in the old days, too.)

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


  Commit: 5390cb838f4334f612160082b38cdb4a52e393d8
      https://github.com/oracle/dtrace-utils/commit/5390cb838f4334f612160082b38cdb4a52e393d8
  Author: Nick Alcock <nick.alcock at oracle.com>
  Date:   2025-10-02 (Thu, 02 Oct 2025)

  Changed paths:
    M test/unittest/usdt/tst.exec-dof-replacement.sh

  Log Message:
  -----------
  test: fix test failure when no /usr/sbin/dtrace exists

A missing $ led to this test spuriously failing in this case.

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


  Commit: 11f0cdcd525a846c35ce421499d19583aeb81461
      https://github.com/oracle/dtrace-utils/commit/11f0cdcd525a846c35ce421499d19583aeb81461
  Author: Kris Van Hees <kris.van.hees at oracle.com>
  Date:   2025-10-02 (Thu, 02 Oct 2025)

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

  Log Message:
  -----------
  cg: fix masking of lower 32 bits

The "and %r0, 0xffffffff' instruction does not actually mask off the
lower 32 bits as one would expect because 0xffffffff is interpreted as
-1 and then sign-extended to a 64-bit value, i.e. keeping all bits.

The "mov32 %r0, %r0" instruction does correctly mask off the lower 32
bits because it forced the value in %r0 to be a 32-bit value.

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/8c61bf213582...11f0cdcd525a

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