public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/4] parser: fix parser debugging yet again
@ 2025-09-18 18:03 Nick Alcock
  2025-09-18 18:03 ` [PATCH 2/4] lexer: the things inside an enum { ... } declaration are identifiers Nick Alcock
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Nick Alcock @ 2025-09-18 18:03 UTC (permalink / raw)
  To: dtrace, dtrace-devel

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@oracle.com>
---
 libdtrace/dt_impl.h | 2 ++
 libdtrace/dt_lex.l  | 4 +---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index 7d8e4432a24ad..9c4651a46baa6 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -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 */
diff --git a/libdtrace/dt_lex.l b/libdtrace/dt_lex.l
index e8f3bc8c25bb0..9f12f5c7ca289 100644
--- a/libdtrace/dt_lex.l
+++ b/libdtrace/dt_lex.l
@@ -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)
-- 
2.48.1.283.g18c60a128c


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-10-03  0:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 18:03 [PATCH 1/4] parser: fix parser debugging yet again Nick Alcock
2025-09-18 18:03 ` [PATCH 2/4] lexer: the things inside an enum { ... } declaration are identifiers Nick Alcock
2025-10-03  0:00   ` [DTrace-devel] " Kris Van Hees
2025-09-18 18:03 ` [PATCH 3/4] test: enum tests Nick Alcock
2025-10-03  0:00   ` Kris Van Hees
2025-09-18 18:03 ` [PATCH 4/4] test: fix test failure when no /usr/sbin/dtrace exists Nick Alcock
2025-09-18 19:18   ` Eugene Loh
2025-09-23 15:15     ` Nick Alcock
2025-09-23 15:31     ` [PATCH v2 " Nick Alcock
2025-10-03  0:01   ` [DTrace-devel] [PATCH " Kris Van Hees
2025-10-03  0:00 ` [PATCH 1/4] parser: fix parser debugging yet again Kris Van Hees

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox