* [RFC, PATCH] YACC parsers
@ 2011-12-17 19:40 Mark Kettenis
2011-12-18 6:21 ` Joel Brobecker
2011-12-19 15:15 ` Tom Tromey
0 siblings, 2 replies; 5+ messages in thread
From: Mark Kettenis @ 2011-12-17 19:40 UTC (permalink / raw)
To: gdb-patches
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 */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC, PATCH] YACC parsers
2011-12-17 19:40 [RFC, PATCH] YACC parsers Mark Kettenis
@ 2011-12-18 6:21 ` Joel Brobecker
2011-12-19 15:15 ` Tom Tromey
1 sibling, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2011-12-18 6:21 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> 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?
FWIW, We are already using those #defines for other symbols, so I don't
think that adding a few is going to make things worse.
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC, PATCH] YACC parsers
2011-12-17 19:40 [RFC, PATCH] YACC parsers Mark Kettenis
2011-12-18 6:21 ` Joel Brobecker
@ 2011-12-19 15:15 ` Tom Tromey
2011-12-19 15:39 ` Mark Kettenis
1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2011-12-19 15:15 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
>>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:
Mark> It may not be impossible to "fix" the OpenBSD yacc(4) here, but given
Mark> the fact that it supports the -p option to add a prefix to all the
Mark> relevant symbols that would be somewhat silly. Unfortunately,
Mark> changing the build infrastructure to use yacc -p isn't exactly
Mark> trivial.
Mark> Opinions?
What is hard about using yacc -p?
I wouldn't mind getting rid of these hacks and requiring a -p-capable
yacc. Or even requiring Bison; I think this would only be needed by gdb
developers anyhow.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC, PATCH] YACC parsers
2011-12-19 15:15 ` Tom Tromey
@ 2011-12-19 15:39 ` Mark Kettenis
2011-12-19 16:13 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2011-12-19 15:39 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
> From: Tom Tromey <tromey@redhat.com>
> Date: Mon, 19 Dec 2011 08:07:49 -0700
>
> >>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:
>
> Mark> It may not be impossible to "fix" the OpenBSD yacc(4) here, but given
> Mark> the fact that it supports the -p option to add a prefix to all the
> Mark> relevant symbols that would be somewhat silly. Unfortunately,
> Mark> changing the build infrastructure to use yacc -p isn't exactly
> Mark> trivial.
>
> Mark> Opinions?
>
> What is hard about using yacc -p?
As far as I can tell, it will require an explicit rule for each
parser, whereas currently an implicit rule is sufficient.
> I wouldn't mind getting rid of these hacks and requiring a -p-capable
> yacc.
POSIX requires the -p option, so I guess that would be fine.
> Or even requiring Bison; I think this would only be needed by gdb
> developers anyhow.
My primary development systems come with a perfectly fine yacc that
isn't bison.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC, PATCH] YACC parsers
2011-12-19 15:39 ` Mark Kettenis
@ 2011-12-19 16:13 ` Tom Tromey
0 siblings, 0 replies; 5+ messages in thread
From: Tom Tromey @ 2011-12-19 16:13 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark> As far as I can tell, it will require an explicit rule for each
Mark> parser, whereas currently an implicit rule is sufficient.
Yeah, I see.
That isn't such a big deal. We can stuff the body of the rule into a
variable and reuse it in each explicit rule.
>> I wouldn't mind getting rid of these hacks and requiring a -p-capable
>> yacc.
Mark> POSIX requires the -p option, so I guess that would be fine.
Fine by me.
>> Or even requiring Bison; I think this would only be needed by gdb
>> developers anyhow.
Mark> My primary development systems come with a perfectly fine yacc that
Mark> isn't bison.
I suspect eventually I will have a reason to require bison, but we can
put that off until and if it ever happens.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-19 15:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17 19:40 [RFC, PATCH] YACC parsers Mark Kettenis
2011-12-18 6:21 ` Joel Brobecker
2011-12-19 15:15 ` Tom Tromey
2011-12-19 15:39 ` Mark Kettenis
2011-12-19 16:13 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox