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

login
register
mail settings
Submitter Tobias Burnus
Date Sept. 6, 2010, 5:46 p.m.
Message ID <4C852912.3080505@net-b.de>
Download mbox | patch
Permalink /patch/63949/
State New
Headers show

Comments

Tobias Burnus - Sept. 6, 2010, 5:46 p.m.
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
Daniel Kraft - Sept. 6, 2010, 6:01 p.m.
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.
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.
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

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