From: Pierre Muller <muller@ics.u-strasbg.fr>
To: gdb-patches@sources.redhat.com
Cc: Andrew Cagney <ac131313@cygnus.com>
Subject: [RFA] remove calls to fprintf in language parsers
Date: Thu, 20 Jun 2002 02:44:00 -0000 [thread overview]
Message-ID: <4.2.0.58.20020620114119.01fb8ea8@ics.u-strasbg.fr> (raw)
This is a follow-up of
http://sources.redhat.com/ml/gdb-patches/2002-05/msg00633.html
It follows the first alternative exposed in that
mail.
All parsers get their YYDEBUG set to 1 by default.
The YYFPRINTF macro is set to parse_fprintf function
that is defined in parser-def.h and implemented in
parse.c.
As far as I saw, YYFPRINTF is only used
with stderr as FILE * parameter if we use bison
parser, but I added a check in case some other parser
uses it diferently.
2002-06-19 Pierre Muller <muller@ics.u-strasbg.fr>
* parse.c (parse_fprintf): New function used to avoid calls to
fprintf in bison parser generated debug code.
* parser-defs.h: Declaration of new parse_fprintf function.
* ada-exp.y, c-exp.y, f-exp.y, jv-exp.y, m2-exp.y, p-exp.y:
Set YYDEBUG to 1 by default.
Set YYFPRINTF as parse_fprintf.
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.9
diff -u -p -r1.9 parser-defs.h
--- parser-defs.h 17 May 2002 17:57:48 -0000 1.9
+++ parser-defs.h 19 Jun 2002 10:03:54 -0000
@@ -216,4 +216,9 @@ struct op_print
extern int target_map_name_to_register (char *, int);
+/* Function used to avoid direct calls to fprintf
+ in the code generated by the bison parser. */
+
+extern void parser_fprintf (FILE *, const char *, ...);
+
#endif /* PARSER_DEFS_H */
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.24
diff -u -p -r1.24 parse.c
--- parse.c 17 May 2002 17:57:48 -0000 1.24
+++ parse.c 19 Jun 2002 10:03:54 -0000
@@ -1366,6 +1366,23 @@ build_parse (void)
NULL);
}
+/* This function avoids direct calls to fprintf
+ in the parser generated debug code. */
+void
+parser_fprintf (FILE *x, const char *y, ...)
+{
+ va_list args;
+ va_start (args, y);
+ if (x == stderr)
+ vfprintf_unfiltered (gdb_stderr, y, args);
+ else
+ {
+ fprintf_unfiltered (gdb_stderr, " Unknown FILE used.\n");
+ vfprintf_unfiltered (gdb_stderr, y, args);
+ }
+ va_end (args);
+}
+
void
_initialize_parse (void)
{
Index: ada-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/ada-exp.y,v
retrieving revision 1.1
diff -u -p -r1.1 ada-exp.y
--- ada-exp.y 4 Jun 2002 15:28:47 -0000 1.1
+++ ada-exp.y 19 Jun 2002 10:03:55 -0000
@@ -92,8 +92,10 @@ Foundation, Inc., 675 Mass Ave, Cambridg
#define yytoks ada_toks /* With YYDEBUG defined */
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
struct name_info {
struct symbol* sym;
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.10
diff -u -p -r1.10 c-exp.y
--- c-exp.y 17 May 2002 17:57:48 -0000 1.10
+++ c-exp.y 19 Jun 2002 10:03:55 -0000
@@ -100,8 +100,10 @@ extern int hp_som_som_object_present;
#define yycheck c_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
int yyparse (void);
Index: f-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/f-exp.y,v
retrieving revision 1.6
diff -u -p -r1.6 f-exp.y
--- f-exp.y 3 May 2002 08:22:52 -0000 1.6
+++ f-exp.y 19 Jun 2002 10:03:55 -0000
@@ -102,8 +102,10 @@ Foundation, Inc., 59 Temple Place - Suit
#define yycheck f_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 1 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
int yyparse (void);
Index: jv-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/jv-exp.y,v
retrieving revision 1.6
diff -u -p -r1.6 jv-exp.y
--- jv-exp.y 3 May 2002 08:22:52 -0000 1.6
+++ jv-exp.y 19 Jun 2002 10:03:55 -0000
@@ -96,8 +96,10 @@ Foundation, Inc., 59 Temple Place - Suit
#define yycheck java_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
int yyparse (void);
Index: m2-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/m2-exp.y,v
retrieving revision 1.4
diff -u -p -r1.4 m2-exp.y
--- m2-exp.y 3 May 2002 08:22:52 -0000 1.4
+++ m2-exp.y 19 Jun 2002 10:03:55 -0000
@@ -98,8 +98,10 @@ Foundation, Inc., 59 Temple Place - Suit
#define yycheck m2_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
int yyparse (void);
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.11
diff -u -p -r1.11 p-exp.y
--- p-exp.y 16 May 2002 09:34:54 -0000 1.11
+++ p-exp.y 19 Jun 2002 10:03:55 -0000
@@ -104,8 +104,10 @@ Foundation, Inc., 59 Temple Place - Suit
#define yycheck pascal_yycheck
#ifndef YYDEBUG
-#define YYDEBUG 0 /* Default to no yydebug support */
+#define YYDEBUG 1 /* Default to yydebug support */
#endif
+
+#define YYFPRINTF parser_fprintf
int yyparse (void);
Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07 Fax : (33)-3-88-41-40-99
next reply other threads:[~2002-06-20 9:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-20 2:44 Pierre Muller [this message]
2002-06-20 17:49 ` Andrew Cagney
2002-06-21 0:52 ` Pierre Muller
2002-06-21 7:13 ` Andrew Cagney
2002-06-21 7:40 ` Pierre Muller
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=4.2.0.58.20020620114119.01fb8ea8@ics.u-strasbg.fr \
--to=muller@ics.u-strasbg.fr \
--cc=ac131313@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
/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