diff mbox

[Fortran] PR 45560 - add EXPR pretty printer (gfc_debug_expr)

Message ID 4C852912.3080505@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Sept. 6, 2010, 5:46 p.m. UTC
Richard stated in #gcc that he misses a pretty printer for gfc_expr. 
The attached patch adds one. To be used in the debugger - otherwise, the 
function is not called.

Build on x86-64-linux.
OK for the trunk?

Tobias

Comments

Daniel Kraft Sept. 6, 2010, 6:01 p.m. UTC | #1
Tobias Burnus wrote:
>  Richard stated in #gcc that he misses a pretty printer for gfc_expr. 
> The attached patch adds one. To be used in the debugger - otherwise, the 
> function is not called.

I remember a discussion some time ago about this topic, where the 
argument "against" implementing something like that was that this is 
just what dump-parse-tree can do.  But it seems your patch is just to 
ease this usage.

> Build on x86-64-linux.
> OK for the trunk?

Ok.  Thanks!

Daniel
Andrew Pinski Sept. 6, 2010, 6:22 p.m. UTC | #2
On Mon, Sep 6, 2010 at 10:46 AM, Tobias Burnus <burnus@net-b.de> wrote:
>  Richard stated in #gcc that he misses a pretty printer for gfc_expr. The
> attached patch adds one. To be used in the debugger - otherwise, the
> function is not called.

I would use stderr instead of stdout.  It is also not buffered.
The GCC debug_* functions all use stderr.

Thanks,
Andrew Pinski
Tobias Burnus Sept. 6, 2010, 6:52 p.m. UTC | #3
Andrew Pinski wrote:
> On Mon, Sep 6, 2010 at 10:46 AM, Tobias Burnus<burnus@net-b.de>  wrote:
>>   Richard stated in #gcc that he misses a pretty printer for gfc_expr. The
>> attached patch adds one. To be used in the debugger - otherwise, the
>> function is not called.
> I would use stderr instead of stdout.  It is also not buffered.
> The GCC debug_* functions all use stderr.

I concur - and have commit a fix as Rev. 163931.

Tobias
diff mbox

Patch

2010-09-06  Tobias Burnus  <burnus@net-b.de>

	PR fortran/45560
	* dump-parse-tree.c (gfc_debug_expr): New function.

Index: gcc/fortran/dump-parse-tree.c
===================================================================
--- gcc/fortran/dump-parse-tree.c	(Revision 163924)
+++ gcc/fortran/dump-parse-tree.c	(Arbeitskopie)
@@ -49,6 +49,20 @@ 
 static void show_namespace (gfc_namespace *ns);
 
 
+/* Allow dumping of an expression in the debugger.  */
+void gfc_debug_expr (gfc_expr *);
+
+void
+gfc_debug_expr (gfc_expr *e)
+{
+  FILE *tmp = dumpfile;
+  dumpfile = stdout;
+  show_expr (e);
+  fputc ('\n', dumpfile);
+  dumpfile = tmp;
+}
+
+
 /* Do indentation for a specific level.  */
 
 static inline void