[RFC, PATCH] YACC parsers
Mark Kettenis
mark.kettenis@xs4all.nl
Sat Dec 17 19:40:00 GMT 2011
I (finally) figured out why some of the c++ tests were failing for me
on my machines. The problem is that the c-exp.y parser ends up
calling the cp-name-parser.y parser, and the parsers generated by
yacc(4) on OpenBSD (which is essentially Berkely Yacc aka byacc) have
some global variables that conflict. The cp-name-parser.y parser ends
up modifying the state of the c-exp.y parser, which then subsequently
crashes GDB. This diff adds a few more defines to remap symbols to
each parser, which fixes the problem.
However, whoever origionally wrote the parsers clearly didn't think
this was the way to go:
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables
produced by yacc. If other parser generators (bison, byacc, etc) produce
additional global names that conflict at link time, then those parser
generators need to be fixed instead of adding those names to this list. */
It may not be impossible to "fix" the OpenBSD yacc(4) here, but given
the fact that it supports the -p option to add a prefix to all the
relevant symbols that would be somewhat silly. Unfortunately,
changing the build infrastructure to use yacc -p isn't exactly
trivial.
Opinions?
2011-12-17 Mark Kettenis <kettenis@gnu.org>
* ada-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* c-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* cp-name-parser.y (yyss, yysslim, yyssp, yystacksize, yyvs)
(yyvsp): New defines.
* f-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* jv-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* m2-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* objc-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
* p-exp.y (yyss, yysslim, yyssp, yystacksize, yyvs, yyvsp): New
defines.
Index: ada-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/ada-exp.y,v
retrieving revision 1.44
diff -u -p -r1.44 ada-exp.y
--- ada-exp.y 11 Dec 2011 02:27:24 -0000 1.44
+++ ada-exp.y 17 Dec 2011 19:09:53 -0000
@@ -94,6 +94,12 @@
#define yytoks ada_toks /* With YYDEBUG defined */
#define yyname ada_name /* With YYDEBUG defined */
#define yyrule ada_rule /* With YYDEBUG defined */
+#define yyss ada_yyss
+#define yysslim ada_yysslim
+#define yyssp ada_yyssp
+#define yystacksize ada_yystacksize
+#define yyvs ada_yyvs
+#define yyvsp ada_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.84
diff -u -p -r1.84 c-exp.y
--- c-exp.y 11 Oct 2011 15:24:10 -0000 1.84
+++ c-exp.y 17 Dec 2011 19:09:54 -0000
@@ -104,6 +104,12 @@
#define yygindex c_yygindex
#define yytable c_yytable
#define yycheck c_yycheck
+#define yyss c_yyss
+#define yysslim c_yysslim
+#define yyssp c_yyssp
+#define yystacksize c_yystacksize
+#define yyvs c_yyvs
+#define yyvsp c_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
Index: cp-name-parser.y
===================================================================
RCS file: /cvs/src/src/gdb/cp-name-parser.y,v
retrieving revision 1.22
diff -u -p -r1.22 cp-name-parser.y
--- cp-name-parser.y 18 Aug 2011 16:17:37 -0000 1.22
+++ cp-name-parser.y 17 Dec 2011 19:09:55 -0000
@@ -171,6 +171,12 @@ static struct demangle_component *d_bina
#define yygindex cpname_yygindex
#define yytable cpname_yytable
#define yycheck cpname_yycheck
+#define yyss cpname_yyss
+#define yysslim cpname_yysslim
+#define yyssp cpname_yyssp
+#define yystacksize cpname_yystacksize
+#define yyvs cpname_yyvs
+#define yyvsp cpname_yyvsp
int yyparse (void);
static int yylex (void);
Index: f-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/f-exp.y,v
retrieving revision 1.39
diff -u -p -r1.39 f-exp.y
--- f-exp.y 19 Apr 2011 18:04:07 -0000 1.39
+++ f-exp.y 17 Dec 2011 19:09:55 -0000
@@ -106,6 +106,12 @@
#define yygindex f_yygindex
#define yytable f_yytable
#define yycheck f_yycheck
+#define yyss f_yyss
+#define yysslim f_yysslim
+#define yyssp f_yyssp
+#define yystacksize f_yystacksize
+#define yyvs f_yyvs
+#define yyvsp f_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.42
diff -u -p -r1.42 jv-exp.y
--- jv-exp.y 9 Jan 2011 03:08:57 -0000 1.42
+++ jv-exp.y 17 Dec 2011 19:09:55 -0000
@@ -99,6 +99,12 @@
#define yygindex java_yygindex
#define yytable java_yytable
#define yycheck java_yycheck
+#define yyss java_yyss
+#define yysslim java_yysslim
+#define yyssp java_yyssp
+#define yystacksize java_yystacksize
+#define yyvs java_yyvs
+#define yyvsp java_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
Index: m2-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/m2-exp.y,v
retrieving revision 1.35
diff -u -p -r1.35 m2-exp.y
--- m2-exp.y 18 Mar 2011 13:51:41 -0000 1.35
+++ m2-exp.y 17 Dec 2011 19:09:56 -0000
@@ -100,6 +100,12 @@
#define yygindex m2_yygindex
#define yytable m2_yytable
#define yycheck m2_yycheck
+#define yyss m2_yyss
+#define yysslim m2_yysslim
+#define yyssp m2_yyssp
+#define yystacksize m2_yystacksize
+#define yyvs m2_yyvs
+#define yyvsp m2_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
Index: objc-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/objc-exp.y,v
retrieving revision 1.45
diff -u -p -r1.45 objc-exp.y
--- objc-exp.y 17 Jun 2011 20:24:22 -0000 1.45
+++ objc-exp.y 17 Dec 2011 19:09:56 -0000
@@ -102,6 +102,12 @@
#define yygindex objc_yygindex
#define yytable objc_yytable
#define yycheck objc_yycheck
+#define yyss objc_yyss
+#define yysslim objc_yysslim
+#define yyssp objc_yyssp
+#define yystacksize objc_yystacksize
+#define yyvs objc_yyvs
+#define yyvsp objc_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 0 /* Default to no yydebug support. */
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.60
diff -u -p -r1.60 p-exp.y
--- p-exp.y 8 Sep 2011 14:54:19 -0000 1.60
+++ p-exp.y 17 Dec 2011 19:09:57 -0000
@@ -106,6 +106,12 @@
#define yygindex pascal_yygindex
#define yytable pascal_yytable
#define yycheck pascal_yycheck
+#define yyss pascal_yyss
+#define yysslim pascal_yysslim
+#define yyssp pascal_yyssp
+#define yystacksize pascal_yystacksize
+#define yyvs pascal_yyvs
+#define yyvsp pascal_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
More information about the Gdb-patches
mailing list