Am 20.02.19 um 21:36 schrieb Steve Kargl:
On Wed, Feb 20, 2019 at 09:10:51PM +0100, Thomas König wrote:
Hello world,
the attached patch implements a few versions of debug for Fortran data
structures. It lets you type, for example
(gdb) call debug (expr)
and get some output which is readable, instead of having to look at
the structures yourself.
This has no user impact, because thsese functions are never called
from the compiler itself.
Comments, suggestions etc welcome. I will commit in a couple of days
unless there are objections. Once that is done, I will also adjust
the quickstart guide on the wiki.
Oh yes, the code compiles :-)
Did you mean to attach a patch?
Well, yes :-)
Index: dump-parse-tree.c
===================================================================
--- dump-parse-tree.c (Revision 268968)
+++ dump-parse-tree.c (Arbeitskopie)
@@ -48,11 +48,37 @@ static void show_expr (gfc_expr *p);
static void show_code_node (int, gfc_code *);
static void show_namespace (gfc_namespace *ns);
static void show_code (int, gfc_code *);
+static void show_symbol (gfc_symbol *);
+static void show_typespec (gfc_typespec *);
-
/* Allow dumping of an expression in the debugger. */
void gfc_debug_expr (gfc_expr *);
+void debug (gfc_expr *e)
+{
+ FILE *tmp = dumpfile;
+ dumpfile = stderr;
+ show_expr (e);
+ fputc (' ', dumpfile);
+ show_typespec (&e->ts);
+ fputc ('\n', dumpfile);
+ dumpfile = tmp;
+}
+
+void debug (gfc_typespec *ts)
+{
+ FILE *tmp = dumpfile;
+ dumpfile = stderr;
+ show_typespec (ts);
+ fputc ('\n', dumpfile);
+ dumpfile = tmp;
+}
+
+void debug (gfc_typespec ts)
+{
+ debug (&ts);
+}
+
void
gfc_debug_expr (gfc_expr *e)
{
@@ -76,6 +102,15 @@ gfc_debug_code (gfc_code *c)
dumpfile = tmp;
}
+void debug (gfc_symbol *sym)
+{
+ FILE *tmp = dumpfile;
+ dumpfile = stderr;
+ show_symbol (sym);
+ fputc ('\n', dumpfile);
+ dumpfile = tmp;
+}
+
/* Do indentation for a specific level. */
static inline void