This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] remove calls to fprintf in language parsers


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]