parser: fix parser debugging yet again
PATCH 1/4 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.
--- libdtrace/dt_impl.h | 2 ++ libdtrace/dt_lex.l | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-)
libdtrace/dt_impl.h +2 -0
@@ -808,7 +808,9 @@ extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */extern int yyintdecimal;/* int token is decimal (1) or octal/hex (0) */ extern char *yytext;/* lex input buffer */ extern int yylineno;/* lex line number */ +#if defined(YYDEBUG ) &&YYDEBUG ==1 extern int yydebug;/* lex debugging */ +#endif extern dt_node_t *yypragma;/* lex token list for control lines */ extern const dtrace_attribute_t _dtrace_maxattr;/* maximum attributes */
libdtrace/dt_lex.l +1 -3
@@ -21,8 +21,6 @@ static int id_or_type(const char *); static size_t dt_input(char *buf, size_t max_size); -int yydebug; - #define YY_INPUT(buf,result,max_size) \ result = dt_input(buf,max_size);
@@ -663,7 +661,7 @@ if (yypcb->pcb_token != 0) { void yybegin(yystate_t state) { -#ifdef YYDEBUG +#if defined(YYDEBUG) && YYDEBUG == 1 yydebug = _dtrace_debug; #endif if (yypcb->pcb_yystate == state)
Signature · 1 line
2.48.1.283.g18c60a128c
PATCH 2/4 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
--- libdtrace/dt_lex.l | 17 +++++++++++++++-- libdtrace/dt_pcb.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-)
libdtrace/dt_lex.l +15 -2
@@ -88,7 +88,7 @@ if (yypcb->pcb_token != 0) { <S0>do return DT_KEY_DO; <S0>double return DT_KEY_DOUBLE; <S0>else return DT_KEY_ELSE; -<S0>enum { yypcb->pcb_sou_type = 1; return DT_KEY_ENUM; } +<S0>enum { yypcb->pcb_sou_type = 1; yypcb->pcb_enum_decl = 1; return DT_KEY_ENUM; } <S0>extern return DT_KEY_EXTERN; <S0>float return DT_KEY_FLOAT; <S0>for return DT_KEY_FOR;
@@ -128,6 +128,7 @@ if (yypcb->pcb_token != 0) { <S2>counter { yybegin(YYS_DEFINE); return DT_KEY_COUNTER; } <S2>double { yybegin(YYS_EXPR); return DT_KEY_DOUBLE; } <S2>enum { yybegin(YYS_EXPR); yypcb->pcb_sou_type = 1; + yypcb->pcb_enum_decl = 1; return DT_KEY_ENUM; } <S2>extern { yybegin(YYS_EXPR); return DT_KEY_EXTERN; } <S2>float { yybegin(YYS_EXPR); return DT_KEY_FLOAT; }
@@ -463,6 +464,7 @@ if (yypcb->pcb_token != 0) { <S0>"(" { yypcb->pcb_parens++; yypcb->pcb_sou_type = 0; + yypcb->pcb_enum_decl = 0; return DT_TOK_LPAR; }
@@ -488,10 +490,13 @@ if (yypcb->pcb_token != 0) { <S2>"{" { yypcb->pcb_braces++; yypcb->pcb_sou_type = 0; + if (yypcb->pcb_enum_decl) + yypcb->pcb_enum_decl++; return '{'; } <S0>"}" { + yypcb->pcb_enum_decl = 0; if (--yypcb->pcb_braces < 0) yyerror("extra } in input stream\n"); return '}';
@@ -536,7 +541,7 @@ if (yypcb->pcb_token != 0) { <S0>"--" return DT_TOK_SUBSUB; <S0>"..." return DT_TOK_ELLIPSIS; <S0>"," return DT_TOK_COMMA; -<S0>";" return ';'; +<S0>";" yypcb->pcb_enum_decl = 0; return ';'; <S0>{RGX_WS} ; /* discard */ <S0>"\\"\n ; /* discard */ <S0>. {
@@ -769,6 +774,14 @@ id_or_type(const char *s) return DT_TOK_IDENT; } + /* + * Inside an enumeration declaration's { }'s region: must be an ident. + * Checking for conflicts is handled by dt_decl_enumerator(). No + * need to look anything up here. + */ + if (yypcb->pcb_enum_decl == 2) + return DT_TOK_IDENT; + /* * If the lexeme is a global variable or likely identifier, then it is * an identifier token.
libdtrace/dt_pcb.h +1 -0
@@ -71,6 +71,7 @@ typedef struct dt_pcb {int pcb_parens;/* number of open parentheses in lexer */ int pcb_sou_type;/* lexer in struct/union type name */ int pcb_sou_deref;/* lexer in struct/union dereference */ +int pcb_enum_decl;/* lexer in enum declaration: 2 for inside { }. */ int pcb_xlator_input;/* in translator input type */ int pcb_array_dimens;/* in array dimensions */ int pcb_alloca_taints;/* number of alloca taint changes */
Signature · 1 line
2.48.1.283.g18c60a128c
Re: [DTrace-devel] [PATCH 2/4] lexer: the things inside an enum { ... } declaration are identifiers
Quoted 16 lines · Nick Alcock via DTrace-devel
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.cchecks for duplicate identifiers, and carefully avoids considering code outside the C and D dicts to be duplicates: but ifid_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.cwill correctly reject it no matter what the lexer says).
Quoted 8 lines
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 <[email protected]>
Quoted 92 lines
--- libdtrace/dt_lex.l | 17 +++++++++++++++-- libdtrace/dt_pcb.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-)libdtrace/dt_lex.l +15
-2@@ -88,7 +88,7 @@ if (yypcb->pcb_token != 0) { <S0>do return DT_KEY_DO; <S0>double return DT_KEY_DOUBLE; <S0>else return DT_KEY_ELSE; -<S0>enum { yypcb->pcb_sou_type = 1; return DT_KEY_ENUM; } +<S0>enum { yypcb->pcb_sou_type = 1; yypcb->pcb_enum_decl = 1; return DT_KEY_ENUM; } <S0>extern return DT_KEY_EXTERN; <S0>float return DT_KEY_FLOAT; <S0>for return DT_KEY_FOR;@@ -128,6 +128,7 @@ if (yypcb->pcb_token != 0) { <S2>counter { yybegin(YYS_DEFINE); return DT_KEY_COUNTER; } <S2>double { yybegin(YYS_EXPR); return DT_KEY_DOUBLE; } <S2>enum { yybegin(YYS_EXPR); yypcb->pcb_sou_type = 1; + yypcb->pcb_enum_decl = 1; return DT_KEY_ENUM; } <S2>extern { yybegin(YYS_EXPR); return DT_KEY_EXTERN; } <S2>float { yybegin(YYS_EXPR); return DT_KEY_FLOAT; }@@ -463,6 +464,7 @@ if (yypcb->pcb_token != 0) { <S0>"(" { yypcb->pcb_parens++; yypcb->pcb_sou_type = 0; + yypcb->pcb_enum_decl = 0; return DT_TOK_LPAR; }@@ -488,10 +490,13 @@ if (yypcb->pcb_token != 0) { <S2>"{" { yypcb->pcb_braces++; yypcb->pcb_sou_type = 0; + if (yypcb->pcb_enum_decl) + yypcb->pcb_enum_decl++; return '{'; } <S0>"}" { + yypcb->pcb_enum_decl = 0; if (--yypcb->pcb_braces < 0) yyerror("extra } in input stream\n"); return '}';@@ -536,7 +541,7 @@ if (yypcb->pcb_token != 0) { <S0>"--" return DT_TOK_SUBSUB; <S0>"..." return DT_TOK_ELLIPSIS; <S0>"," return DT_TOK_COMMA; -<S0>";" return ';'; +<S0>";" yypcb->pcb_enum_decl = 0; return ';'; <S0>{RGX_WS} ; /* discard */ <S0>"\\"\n ; /* discard */ <S0>. {@@ -769,6 +774,14 @@ id_or_type(const char *s) return DT_TOK_IDENT; } + /* + * Inside an enumeration declaration's { }'s region: must be an ident. + * Checking for conflicts is handled by dt_decl_enumerator(). No + * need to look anything up here. + */ + if (yypcb->pcb_enum_decl == 2) + return DT_TOK_IDENT; + /* * If the lexeme is a global variable or likely identifier, then it is * an identifier token.libdtrace/dt_pcb.h +1
-0@@ -71,6 +71,7 @@ typedef struct dt_pcb {int pcb_parens;/* number of open parentheses in lexer */ int pcb_sou_type;/* lexer in struct/union type name */ int pcb_sou_deref;/* lexer in struct/union dereference */ +int pcb_enum_decl;/* lexer in enum declaration: 2 for inside { }. */ int pcb_xlator_input;/* in translator input type */ int pcb_array_dimens;/* in array dimensions */ int pcb_alloca_taints;/* number of alloca taint changes */ Signature · 7 lines
2.48.1.283.g18c60a128c _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel
PATCH 3/4 test: enum tests
In reply to Nick AlcockA 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.)
---
...iers.d => err.D_DECL_IDRED.RepeatIdentifiers.d} | 0
.../enum/err.D_DECL_IDRED.RepeatIdentifiers.r | 2 ++
....r.p => err.D_DECL_IDRED.RepeatIdentifiers.r.p} | 0
...dentifiers.d => err.D_SYNTAX.RepeatTypeNames.d} | 12 +++---------
.../enum/err.D_UNKNOWN.RepeatIdentifiers.r | 2 --
...OWN.RepeatIdentifiers.d => tst.EnumKernelDup.d} | 14 ++++++--------
test/unittest/enum/tst.EnumKernelDup.r | 1 +
...NKNOWN.dupenum.d => err.D_DECL_IDRED.dupenum.d} | 0
test/unittest/types/err.D_DECL_IDRED.dupenum.r | 2 ++
...WN.dupenum.r.p => err.D_DECL_IDRED.dupenum.r.p} | 0
test/unittest/types/err.D_UNKNOWN.dupenum.r | 2 --
11 files changed, 14 insertions(+), 21 deletions(-)
copy test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => err.D_DECL_IDRED.RepeatIdentifiers.d} (100%)
create mode 100644 test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r
rename test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.r.p => err.D_DECL_IDRED.RepeatIdentifiers.r.p} (100%)
copy test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => err.D_SYNTAX.RepeatTypeNames.d} (72%)
delete mode 100644 test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r
rename test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => tst.EnumKernelDup.d} (57%)
create mode 100644 test/unittest/enum/tst.EnumKernelDup.r
rename test/unittest/types/{err.D_UNKNOWN.dupenum.d => err.D_DECL_IDRED.dupenum.d} (100%)
create mode 100644 test/unittest/types/err.D_DECL_IDRED.dupenum.r
rename test/unittest/types/{err.D_UNKNOWN.dupenum.r.p => err.D_DECL_IDRED.dupenum.r.p} (100%)
delete mode 100644 test/unittest/types/err.D_UNKNOWN.dupenum.rtest/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +0 -0
test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r new file +2 -0
@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.d: [D_DECL_IDRED] line 24: identifier redeclared: GREEN
test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r.p renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r.p +0 -0
test/unittest/enum/err.D_SYNTAX.RepeatTypeNames.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +3 -9
@@ -7,22 +7,16 @@ /* * ASSERTION: - * Repeating the same identifier in the same enumeration will throw a compiler - * error. + * Enumerations cannot have the same names as already-existing types. * * SECTION: Type and Constant Definitions/Enumerations - * - * NOTES: - * */ #pragma D option quiet enum colors { - RED, - GREEN, - GREEN = 2, - BLUE + int, + not_int }; BEGIN
test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r deleted +0 -2
@@ -1,2 +0,0 @@ --- @@stderr -- -dtrace: failed to compile script test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d: [D_UNKNOWN] line 24: failed to define enumerator 'GREEN': Duplicate member or variable name
test/unittest/enum/tst.EnumKernelDup.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +6 -8
@@ -1,14 +1,14 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ /* * ASSERTION: - * Repeating the same identifier in the same enumeration will throw a compiler - * error. + * Enumerations using names also used for enumerators in the kernel should not + * raise errors. * * SECTION: Type and Constant Definitions/Enumerations *
@@ -18,11 +18,9 @@ #pragma D option quiet -enum colors { - RED, - GREEN, - GREEN = 2, - BLUE +enum dirs { + UP, + DOWN }; BEGIN
test/unittest/enum/tst.EnumKernelDup.r new file +1 -0
@@ -0,0 +1 @@ +
test/unittest/types/err.D_DECL_IDRED.dupenum.d renamed from test/unittest/types/err.D_UNKNOWN.dupenum.d +0 -0
test/unittest/types/err.D_DECL_IDRED.dupenum.r new file +2 -0
@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/types/err.D_DECL_IDRED.dupenum.d: [D_DECL_IDRED] line 18: identifier redeclared: x
test/unittest/types/err.D_DECL_IDRED.dupenum.r.p renamed from test/unittest/types/err.D_UNKNOWN.dupenum.r.p +0 -0
test/unittest/types/err.D_UNKNOWN.dupenum.r deleted +0 -2
@@ -1,2 +0,0 @@ --- @@stderr -- -dtrace: failed to compile script test/unittest/types/err.D_UNKNOWN.dupenum.d: [D_UNKNOWN] line 18: failed to define enumerator 'x': Duplicate member or variable name
Signature · 1 line
2.48.1.283.g18c60a128c
Re: [PATCH 3/4] test: enum tests
Quoted 10 lines · Nick Alcock
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_UNKNOWNtests 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 <[email protected]>
Quoted 156 lines
--- ...iers.d => err.D_DECL_IDRED.RepeatIdentifiers.d} | 0 .../enum/err.D_DECL_IDRED.RepeatIdentifiers.r | 2 ++ ....r.p => err.D_DECL_IDRED.RepeatIdentifiers.r.p} | 0 ...dentifiers.d => err.D_SYNTAX.RepeatTypeNames.d} | 12 +++--------- .../enum/err.D_UNKNOWN.RepeatIdentifiers.r | 2 -- ...OWN.RepeatIdentifiers.d => tst.EnumKernelDup.d} | 14 ++++++-------- test/unittest/enum/tst.EnumKernelDup.r | 1 + ...NKNOWN.dupenum.d => err.D_DECL_IDRED.dupenum.d} | 0 test/unittest/types/err.D_DECL_IDRED.dupenum.r | 2 ++ ...WN.dupenum.r.p => err.D_DECL_IDRED.dupenum.r.p} | 0 test/unittest/types/err.D_UNKNOWN.dupenum.r | 2 -- 11 files changed, 14 insertions(+), 21 deletions(-) copy test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => err.D_DECL_IDRED.RepeatIdentifiers.d} (100%) create mode 100644 test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r rename test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.r.p => err.D_DECL_IDRED.RepeatIdentifiers.r.p} (100%) copy test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => err.D_SYNTAX.RepeatTypeNames.d} (72%) delete mode 100644 test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r rename test/unittest/enum/{err.D_UNKNOWN.RepeatIdentifiers.d => tst.EnumKernelDup.d} (57%) create mode 100644 test/unittest/enum/tst.EnumKernelDup.r rename test/unittest/types/{err.D_UNKNOWN.dupenum.d => err.D_DECL_IDRED.dupenum.d} (100%) create mode 100644 test/unittest/types/err.D_DECL_IDRED.dupenum.r rename test/unittest/types/{err.D_UNKNOWN.dupenum.r.p => err.D_DECL_IDRED.dupenum.r.p} (100%) delete mode 100644 test/unittest/types/err.D_UNKNOWN.dupenum.rtest/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +0
-0test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r new file +2
-0@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.d: [D_DECL_IDRED] line 24: identifier redeclared: GREENtest/unittest/enum/err.D_DECL_IDRED.RepeatIdentifiers.r.p renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r.p +0
-0test/unittest/enum/err.D_SYNTAX.RepeatTypeNames.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +3
-9@@ -7,22 +7,16 @@ /* * ASSERTION: - * Repeating the same identifier in the same enumeration will throw a compiler - * error. + * Enumerations cannot have the same names as already-existing types. * * SECTION: Type and Constant Definitions/Enumerations - * - * NOTES: - * */ #pragma D option quiet enum colors { - RED, - GREEN, - GREEN = 2, - BLUE + int, + not_int }; BEGINtest/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.r deleted +0
-2@@ -1,2 +0,0 @@ --- @@stderr -- -dtrace: failed to compile script test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d: [D_UNKNOWN] line 24: failed to define enumerator 'GREEN': Duplicate member or variable nametest/unittest/enum/tst.EnumKernelDup.d renamed from test/unittest/enum/err.D_UNKNOWN.RepeatIdentifiers.d +6
-8@@ -1,14 +1,14 @@ /* * Oracle Linux DTrace. - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ /* * ASSERTION: - * Repeating the same identifier in the same enumeration will throw a compiler - * error. + * Enumerations using names also used for enumerators in the kernel should not + * raise errors. * * SECTION: Type and Constant Definitions/Enumerations *@@ -18,11 +18,9 @@ #pragma D option quiet -enum colors { - RED, - GREEN, - GREEN = 2, - BLUE +enum dirs { + UP, + DOWN }; BEGINtest/unittest/enum/tst.EnumKernelDup.r new file +1
-0@@ -0,0 +1 @@ +test/unittest/types/err.D_DECL_IDRED.dupenum.d renamed from test/unittest/types/err.D_UNKNOWN.dupenum.d +0
-0test/unittest/types/err.D_DECL_IDRED.dupenum.r new file +2
-0@@ -0,0 +1,2 @@ +-- @@stderr -- +dtrace: failed to compile script test/unittest/types/err.D_DECL_IDRED.dupenum.d: [D_DECL_IDRED] line 18: identifier redeclared: xtest/unittest/types/err.D_DECL_IDRED.dupenum.r.p renamed from test/unittest/types/err.D_UNKNOWN.dupenum.r.p +0
-0test/unittest/types/err.D_UNKNOWN.dupenum.r deleted +0
-2@@ -1,2 +0,0 @@ --- @@stderr -- -dtrace: failed to compile script test/unittest/types/err.D_UNKNOWN.dupenum.d: [D_UNKNOWN] line 18: failed to define enumerator 'x': Duplicate member or variable nameSignature · 1 line
2.48.1.283.g18c60a128c
PATCH 4/4 test: fix test failure when no /usr/sbin/dtrace exists
In reply to Nick AlcockA missing $ led to this test spuriously failing in this case.
--- test/unittest/usdt/tst.exec-dof-replacement.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/usdt/tst.exec-dof-replacement.sh +1 -1
@@ -33,7 +33,7 @@ provider test_prov { }; EOF -if ! { $dtrace $dt_flags -h -s prov1.d && dtrace -h -s prov2.d; } then +if ! { $dtrace $dt_flags -h -s prov1.d && $dtrace -h -s prov2.d; } then echo "failed to generate header files" >&2 exit 1 fi
Signature · 1 line
2.48.1.283.g18c60a128c
Re: [PATCH 4/4] test: fix test failure when no /usr/sbin/dtrace exists
Okay, but should it even be $dtrace $dt_flags? If for no other reason than symmetry with prov1.d?
Quoted 20 lines · Nick Alcock
A missing $ led to this test spuriously failing in this case.
Signed-off-by Nick Alcock <[email protected]>--- test/unittest/usdt/tst.exec-dof-replacement.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/usdt/tst.exec-dof-replacement.sh +1
-1@@ -33,7 +33,7 @@ provider test_prov { }; EOF -if ! { $dtrace $dt_flags -h -s prov1.d && dtrace -h -s prov2.d; } then +if ! { $dtrace $dt_flags -h -s prov1.d && $dtrace -h -s prov2.d; } then echo "failed to generate header files" >&2 exit 1 fi
Re: [PATCH 4/4] test: fix test failure when no /usr/sbin/dtrace exists
On 18 Sep 2025, Eugene Loh uttered the following:
Quoted 1 line
Okay, but should it even be $dtrace $dt_flags? If for no other reason than symmetry with prov1.d?
... I guess so. Missed that. Can fix if you like.
Signature · 1 line
NULL && (void)
PATCH v2 4/4 test: fix test failure when no /usr/sbin/dtrace exists
In reply to Eugene LohA missing $ led to this test spuriously failing in this case.
--- test/unittest/usdt/tst.exec-dof-replacement.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/usdt/tst.exec-dof-replacement.sh +1 -1
@@ -33,7 +33,7 @@ provider test_prov { }; EOF -if ! { $dtrace $dt_flags -h -s prov1.d && dtrace -h -s prov2.d; } then +if ! { $dtrace $dt_flags -h -s prov1.d && $dtrace $dt_flags -h -s prov2.d; } then echo "failed to generate header files" >&2 exit 1 fi
Signature · 1 line
2.51.0.284.g117bcb8de7
Re: [DTrace-devel] [PATCH 4/4] test: fix test failure when no /usr/sbin/dtrace exists
In reply to Nick AlcockQuoted 3 lines · Nick Alcock via DTrace-devel
A missing $ led to this test spuriously failing in this case.
Signed-off-by Nick Alcock <[email protected]>
Quoted 25 lines
--- test/unittest/usdt/tst.exec-dof-replacement.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)test/unittest/usdt/tst.exec-dof-replacement.sh +1
-1@@ -33,7 +33,7 @@ provider test_prov { }; EOF -if ! { $dtrace $dt_flags -h -s prov1.d && dtrace -h -s prov2.d; } then +if ! { $dtrace $dt_flags -h -s prov1.d && $dtrace -h -s prov2.d; } then echo "failed to generate header files" >&2 exit 1 fiSignature · 7 lines
2.48.1.283.g18c60a128c _______________________________________________ DTrace-devel mailing list [email protected] https://oss.oracle.com/mailman/listinfo/dtrace-devel
Quoted 9 lines · Nick Alcock
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.hshould only be declaring it extern if YYDEBUG is 1.
Quoted 5 lines
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 <[email protected]>
Quoted 44 lines
--- libdtrace/dt_impl.h | 2 ++ libdtrace/dt_lex.l | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-)libdtrace/dt_impl.h +2
-0@@ -808,7 +808,9 @@ extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */extern int yyintdecimal;/* int token is decimal (1) or octal/hex (0) */ extern char *yytext;/* lex input buffer */ extern int yylineno;/* lex line number */ +#if defined(YYDEBUG ) &&YYDEBUG ==1 extern int yydebug;/* lex debugging */ +#endif extern dt_node_t *yypragma;/* lex token list for control lines */ extern const dtrace_attribute_t _dtrace_maxattr;/* maximum attributes */ libdtrace/dt_lex.l +1
-3@@ -21,8 +21,6 @@ static int id_or_type(const char *); static size_t dt_input(char *buf, size_t max_size); -int yydebug; - #define YY_INPUT(buf,result,max_size) \ result = dt_input(buf,max_size);@@ -663,7 +661,7 @@ if (yypcb->pcb_token != 0) { void yybegin(yystate_t state) { -#ifdef YYDEBUG +#if defined(YYDEBUG) && YYDEBUG == 1 yydebug = _dtrace_debug; #endif if (yypcb->pcb_yystate == state)Signature · 1 line
2.48.1.283.g18c60a128c