* RFA: interactive command to enable parser debugging
@ 2010-02-09 17:05 Tom Tromey
2010-02-09 18:55 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2010-02-09 17:05 UTC (permalink / raw)
To: gdb-patches
I've been looking at a few possible parser bugs lately, and I wanted to
be able to set "yydebug" interactively.
This patch adds a "set debug parser" command that can be used to do this.
This seems ok to me because we define YYDEBUG in c-exp.y.
I did not modify the other parsers to respect this flag. I leave that
to the relevant language maintainers.
This needs a doc review.
Let me know what you think. Barring objection I will commit it once the
doc patch is satisfactory.
Tom
2010-02-09 Tom Tromey <tromey@redhat.com>
* parser-defs.h (parser_debug): Declare.
* parse.c (_initialize_parse): Install "debug parser" set/show
command.
(parser_debug): New global.
(show_parserdebug): New function.
* c-exp.y (c_parse): Set yydebug.
2010-02-09 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Debugging Output): Document set debug parser and
show debug parser.
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 459177a..095ec40 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2555,6 +2555,9 @@ c_parse (void)
gdb_assert (! macro_original_text);
make_cleanup (scan_macro_cleanup, 0);
+ make_cleanup_restore_integer (&yydebug);
+ yydebug = parser_debug;
+
/* Initialize some state used by the lexer. */
last_was_structop = 0;
saw_name_at_eof = 0;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2145f2b..c645fa2 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18848,6 +18848,11 @@ is off.
@item show debug overload
Displays the current state of displaying @value{GDBN} C@t{++} overload
debugging info.
+@item show debug parser
+Show the current state of expression parser debugging.
+@item set debug parser
+Turns on or off the display of expression parser debugging output.
+The default is off.
@cindex packets, reporting on stdout
@cindex serial connections, debugging
@cindex debug remote protocol
diff --git a/gdb/parse.c b/gdb/parse.c
index 1c73d75..d54053b 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -109,6 +109,18 @@ show_expressiondebug (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("Expression debugging is %s.\n"), value);
}
+
+/* Non-zero if an expression parser should set yydebug. */
+int parser_debug;
+
+static void
+show_parserdebug (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Parser debugging is %s.\n"), value);
+}
+
+
static void free_funcalls (void *ignore);
static int prefixify_expression (struct expression *);
@@ -1388,4 +1400,12 @@ When non-zero, the internal representation of expressions will be printed."),
NULL,
show_expressiondebug,
&setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd ("parser", class_maintenance,
+ &parser_debug, _("\
+Set parser debugging."), _("\
+Show parser debugging."), _("\
+When non-zero, expression parser tracing will be enabled."),
+ NULL,
+ show_parserdebug,
+ &setdebuglist, &showdebuglist);
}
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 6fcf7ae..c4eb1a0 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -29,6 +29,8 @@
struct block;
+extern int parser_debug;
+
extern struct expression *expout;
extern int expout_size;
extern int expout_ptr;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: interactive command to enable parser debugging
2010-02-09 17:05 RFA: interactive command to enable parser debugging Tom Tromey
@ 2010-02-09 18:55 ` Eli Zaretskii
2010-02-10 17:50 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2010-02-09 18:55 UTC (permalink / raw)
To: tromey; +Cc: gdb-patches
> From: Tom Tromey <tromey@redhat.com>
> Date: Tue, 09 Feb 2010 10:04:58 -0700
>
> This needs a doc review.
It's fine with me, but I suggest to add index entries for this
setting. Something like
@cindex expression parser, debugging info
@cindex debug expression parser
I would also consider saying explicitly that this option sets the
value of `yydebug', because whoever wants to debug the parser is
probably familiar with what `yydebug' does.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: interactive command to enable parser debugging
2010-02-09 18:55 ` Eli Zaretskii
@ 2010-02-10 17:50 ` Tom Tromey
2010-02-10 18:39 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2010-02-10 17:50 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
Eli> I would also consider saying explicitly that this option sets the
Eli> value of `yydebug', because whoever wants to debug the parser is
Eli> probably familiar with what `yydebug' does.
How about this? I did that, added the index entries you suggested,
rearranged things so that set comes before show (the other items in the
list all do this, which I didn't notice the first time), and finally
added a link to the bison manual.
Tom
2010-02-10 Tom Tromey <tromey@redhat.com>
* parser-defs.h (parser_debug): Declare.
* parse.c (_initialize_parse): Install "debug parser" set/show
command.
(parser_debug): New global.
(show_parserdebug): New function.
* c-exp.y (c_parse): Set yydebug.
2010-02-10 Tom Tromey <tromey@redhat.com>
* gdb.texinfo (Debugging Output): Document set debug parser and
show debug parser.
Index: c-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/c-exp.y,v
retrieving revision 1.69
diff -u -r1.69 c-exp.y
--- c-exp.y 18 Jan 2010 20:54:33 -0000 1.69
+++ c-exp.y 10 Feb 2010 17:44:21 -0000
@@ -2450,6 +2450,9 @@
gdb_assert (! macro_original_text);
make_cleanup (scan_macro_cleanup, 0);
+ make_cleanup_restore_integer (&yydebug);
+ yydebug = parser_debug;
+
/* Initialize some state used by the lexer. */
last_was_structop = 0;
saw_name_at_eof = 0;
Index: parse.c
===================================================================
RCS file: /cvs/src/src/gdb/parse.c,v
retrieving revision 1.94
diff -u -r1.94 parse.c
--- parse.c 18 Jan 2010 20:54:34 -0000 1.94
+++ parse.c 10 Feb 2010 17:44:22 -0000
@@ -109,6 +109,18 @@
fprintf_filtered (file, _("Expression debugging is %s.\n"), value);
}
+
+/* Non-zero if an expression parser should set yydebug. */
+int parser_debug;
+
+static void
+show_parserdebug (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Parser debugging is %s.\n"), value);
+}
+
+
static void free_funcalls (void *ignore);
static int prefixify_expression (struct expression *);
@@ -1377,4 +1389,12 @@
NULL,
show_expressiondebug,
&setdebuglist, &showdebuglist);
+ add_setshow_boolean_cmd ("parser", class_maintenance,
+ &parser_debug, _("\
+Set parser debugging."), _("\
+Show parser debugging."), _("\
+When non-zero, expression parser tracing will be enabled."),
+ NULL,
+ show_parserdebug,
+ &setdebuglist, &showdebuglist);
}
Index: parser-defs.h
===================================================================
RCS file: /cvs/src/src/gdb/parser-defs.h,v
retrieving revision 1.32
diff -u -r1.32 parser-defs.h
--- parser-defs.h 1 Jan 2010 07:31:38 -0000 1.32
+++ parser-defs.h 10 Feb 2010 17:44:22 -0000
@@ -29,6 +29,8 @@
struct block;
+extern int parser_debug;
+
extern struct expression *expout;
extern int expout_size;
extern int expout_ptr;
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.666
diff -u -r1.666 gdb.texinfo
--- doc/gdb.texinfo 9 Feb 2010 18:58:57 -0000 1.666
+++ doc/gdb.texinfo 10 Feb 2010 17:44:27 -0000
@@ -18848,6 +18848,15 @@
@item show debug overload
Displays the current state of displaying @value{GDBN} C@t{++} overload
debugging info.
+@cindex expression parser, debugging info
+@cindex debug expression parser
+@item set debug parser
+Turns on or off the display of expression parser debugging output.
+Internally, this sets the @code{yydebug} variable in the expression
+parser. @xref{Tracing, , Tracing Your Parser, bison, Bison}, for
+details. The default is off.
+@item show debug parser
+Show the current state of expression parser debugging.
@cindex packets, reporting on stdout
@cindex serial connections, debugging
@cindex debug remote protocol
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA: interactive command to enable parser debugging
2010-02-10 17:50 ` Tom Tromey
@ 2010-02-10 18:39 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2010-02-10 18:39 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches@sourceware.org
> Date: Wed, 10 Feb 2010 10:50:38 -0700
>
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>
> Eli> I would also consider saying explicitly that this option sets the
> Eli> value of `yydebug', because whoever wants to debug the parser is
> Eli> probably familiar with what `yydebug' does.
>
> How about this? I did that, added the index entries you suggested,
> rearranged things so that set comes before show (the other items in the
> list all do this, which I didn't notice the first time), and finally
> added a link to the bison manual.
Terrific! Thank you very much. I'm happy now.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-10 18:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-09 17:05 RFA: interactive command to enable parser debugging Tom Tromey
2010-02-09 18:55 ` Eli Zaretskii
2010-02-10 17:50 ` Tom Tromey
2010-02-10 18:39 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox