From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH] gdb: rename YYSTACKDATA in generated parsers
Date: Wed, 7 Oct 2026 09:55:47 -0400 [thread overview]
Message-ID: <20261007140014.2488030-1-simon.marchi@polymtl.ca> (raw)
From: Simon Marchi <simon.marchi@polymtl.ca>
When building with byacc and -flto -Werror=odr, we get:
ada-exp-parser-gen.c.tmp:1552:3: error: type 'struct YYSTACKDATA' violates the C++ One Definition Rule [-Werror=odr]
c-exp-parser-gen.c.tmp:3732:3: note: a different type is defined in another translation unit
ada-exp-parser-gen.c.tmp:1546:30: note: the first difference of corresponding definitions is field 'l_base'
c-exp-parser-gen.c.tmp:3726:28: note: a field of same name but different type is defined in another translation unit
ada-exp-parser-gen.c.tmp:1552:3: note: type name 'ada_exp_parser_YYSTYPE' should match type name 'c_exp_parser_YYSTYPE'
The byacc generated parsers define this type:
typedef struct {
unsigned stacksize;
YYINT *s_base;
YYINT *s_mark;
YYINT *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
...
} YYSTACKDATA;
Since YYSTYPE represents a different type in each parser (it is renamed
to {prefix}_YYSTYPE by post-process-parser-output.sh), then YYSTACKDATA
is also a different type in each parser, which leads to ODR violations.
This is a regression from my patch that removed yy-remap.h (d3d68d798e0c
"gdb: let the parser and lexer generators prefix their symbols").
yy-remap.h remapped YYSTACKDATA, since commit df940f8bb348 ("gdb: Fix an
ODR warning with byacc with GDB_YY_REMAP") which fixed this exact
problem.
Fix it by adding YYSTACKDATA to the renames done in
post-process-parser-output.sh, alongside YYSTYPE and friends.
This is a master-only bug, no need to cherry-pick to gdb-18-branch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34712
Change-Id: I6332bd0edc6619434f67cccef463cd21e96e3251
---
gdb/post-process-parser-output.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/post-process-parser-output.sh b/gdb/post-process-parser-output.sh
index a0cf6b464c4b..ca5f0ba302fb 100755
--- a/gdb/post-process-parser-output.sh
+++ b/gdb/post-process-parser-output.sh
@@ -53,7 +53,8 @@ case "$generator" in
-e '/^#line.*y.tab.c/d' \
-e "s/YYSTYPE/${name}_YYSTYPE/g" \
-e "s/yyalloc/${name}_yyalloc/g" \
- -e "s/yysymbol_kind_t/${name}_yysymbol_kind_t/g"
+ -e "s/yysymbol_kind_t/${name}_yysymbol_kind_t/g" \
+ -e "s/YYSTACKDATA/${name}_YYSTACKDATA/g"
;;
flex)
sed -e "$common" \
base-commit: ca0665335ff67af94f9ded026d7ef2405a68c453
--
2.55.0
next reply other threads:[~2026-10-07 14:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 13:55 simon.marchi [this message]
2026-10-08 14:00 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007140014.2488030-1-simon.marchi@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox