[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cex: send traces to stderr, not stdout
From: |
Akim Demaille |
Subject: |
cex: send traces to stderr, not stdout |
Date: |
Wed, 13 Jan 2021 08:03:39 +0100 |
commit 038021446a8f9a736d68ba5787aa042a70dd1bff
Author: Akim Demaille <akim.demaille@gmail.com>
Date: Wed Jan 13 08:01:02 2021 +0100
cex: send traces to stderr, not stdout
When comparing traces from different machines, the mixture of
stdout/stderr in the output are making things uselessly difficult.
* src/lssi.c, src/state-item.c: Output debug traces on stderr.
diff --git a/src/lssi.c b/src/lssi.c
index a5ab8a79..8c26ade0 100644
--- a/src/lssi.c
+++ b/src/lssi.c
@@ -102,15 +102,16 @@ append_lssi (lssi *sn, Hash_table *visited, lssi_list
queue)
static void
lssi_print (lssi *l)
{
- print_state_item (&state_items[l->si], stdout);
+ FILE *out = stderr;
+ print_state_item (&state_items[l->si], out);
if (l->lookahead)
{
- printf ("FOLLOWL = { ");
+ fprintf (out, "FOLLOWL = { ");
bitset_iterator biter;
symbol_number sin;
BITSET_FOR_EACH (biter, l->lookahead, sin, 0)
- printf ("%s, \n", symbols[sin]->tag);
- puts ("}");
+ fprintf (out, "%s, \n", symbols[sin]->tag);
+ fprintf (out, "}");
}
}
#endif
@@ -252,11 +253,11 @@ shortest_path_from_start (state_item_number target,
symbol_number next_sym)
if (trace_flag & trace_cex)
{
- puts ("REDUCE ITEM PATH:");
+ fputs ("REDUCE ITEM PATH:", stderr);
gl_list_iterator_t it = gl_list_iterator (res);
const void *sip;
while (gl_list_iterator_next (&it, &sip, NULL))
- state_item_print ((state_item *) sip, stdout, "");
+ state_item_print ((state_item *) sip, stderr, "");
}
return res;
}
diff --git a/src/state-item.c b/src/state-item.c
index a56be1f2..50a1e1be 100644
--- a/src/state-item.c
+++ b/src/state-item.c
@@ -492,27 +492,26 @@ state_item_rule (const state_item *si)
* Report the state_item graph
*/
static void
-state_items_report (void)
+state_items_report (FILE *out)
{
- printf ("# state items: %zu\n", nstate_items);
+ fprintf (out, "# state items: %zu\n", nstate_items);
for (state_number i = 0; i < nstates; ++i)
{
- printf ("State %d:\n", i);
+ fprintf (out, "State %d:\n", i);
for (state_item_number j = state_item_map[i]; j < state_item_map[i + 1];
++j)
{
state_item *si = &state_items[j];
- item_print (si->item, NULL, stdout);
+ item_print (si->item, NULL, out);
if (SI_DISABLED (j))
{
- item_print (si->item, NULL, stdout);
- puts (" DISABLED");
+ item_print (si->item, NULL, out);
+ fputs (" DISABLED", out);
continue;
}
- puts ("");
if (si->trans >= 0)
{
- fputs (" -> ", stdout);
- state_item_print (&state_items[si->trans], stdout, "");
+ fputs (" -> ", out);
+ state_item_print (&state_items[si->trans], out, "");
}
bitset sets[2] = { si->prods, si->revs };
@@ -526,24 +525,23 @@ state_items_report (void)
state_item_number sin;
BITSET_FOR_EACH (biter, b, sin, 0)
{
- fputs (txt[seti], stdout);
- state_item_print (&state_items[sin], stdout, "");
+ fputs (txt[seti], out);
+ state_item_print (&state_items[sin], out, "");
}
}
}
- puts ("");
}
}
- printf ("FIRSTS\n");
+ fprintf (out, "FIRSTS\n");
for (symbol_number i = ntokens; i < nsyms; ++i)
{
- printf (" %s firsts\n", symbols[i]->tag);
+ fprintf (out, " %s firsts\n", symbols[i]->tag);
bitset_iterator iter;
symbol_number j;
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
- printf (" %s\n", symbols[j]->tag);
+ fprintf (out, " %s\n", symbols[j]->tag);
}
- puts ("\n");
+ fputc ('\n', out);
}
void
@@ -558,8 +556,8 @@ state_items_init (void)
prune_disabled_paths ();
if (trace_flag & trace_cex)
{
- printf ("init: %f\n", difftime (time (NULL), start));
- state_items_report ();
+ fprintf (stderr, "init: %f\n", difftime (time (NULL), start));
+ state_items_report (stderr);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- cex: send traces to stderr, not stdout,
Akim Demaille <=