From: Matt Birkholz Date: Wed, 20 Jul 2011 17:36:54 +0000 (-0700) Subject: Use trace() for less obtrusive tracing. X-Git-Tag: mit-scheme-pucked-9.2.12~674 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=c216f55f00cddcc77604ad9f07590a5367ed7ae5;p=mit-scheme.git Use trace() for less obtrusive tracing. --- diff --git a/src/gtk/gtkio.c.stay b/src/gtk/gtkio.c.stay index e9bcb78b2..b3d16427e 100644 --- a/src/gtk/gtkio.c.stay +++ b/src/gtk/gtkio.c.stay @@ -63,6 +63,7 @@ static void set_registry (SchemeSource * source, GSList * new, double time); static SchemeSource * scheme_source = NULL; static gboolean tracing_gtk_select = 0; +static void trace (const char *format, ...); static GSList * gtk_registry (select_registry_t registry); static int slice_counter = 0; @@ -73,6 +74,19 @@ static void open_slice_window (void); static void close_slice_window (void); static gchar * gpollfds_string (GSList * gpollfds); +void +trace (const char * format, ...) +{ + va_list args; + va_start (args, format); + if (tracing_gtk_select) + { + voutf_console (format, args); + outf_flush_console (); + } + va_end (args); +} + static gboolean scheme_source_prepare (GSource * source, gint * timeout) { @@ -89,31 +103,15 @@ scheme_source_prepare (GSource * source, gint * timeout) || pending_interrupts_p () || OS_process_any_status_change ()) { - if (tracing_gtk_select) - { - if (timeo > 0) - { - outf_console (";scheme_source_prepare: %s\n", - src->runnable ? "thread" - : pending_interrupts_p () ? "interrupt" - : "subprocess"); - } - else - { - outf_console - (";scheme_source_prepare: timeout at %.1f (in %dmsec)\n", - dtime, timeo); - } - outf_flush_console (); - } + trace (";scheme_source_prepare: ready (%s)\n", + timeo <= 0 ? "timeout" + : src->runnable ? "thread" + : pending_interrupts_p () ? "interrupt" + : "subprocess"); return (TRUE); /* Ready for immediate dispatch. */ } - if (tracing_gtk_select) - { - outf_console (";scheme_source_prepare: polling for %dmsec\n", timeo); - outf_flush_console (); - } + trace (";scheme_source_prepare: polling for %dmsec\n", timeo); *timeout = timeo; return (FALSE); /* Poll/check before dispatching. */ } @@ -129,15 +127,11 @@ scheme_source_check (GSource * source) || OS_process_any_status_change () || pending_io (src)) { - if (tracing_gtk_select) - { - outf_console (";scheme_source_check: %s\n", - src->runnable ? "thread" - : pending_interrupts_p () ? "interrupt" - : OS_process_any_status_change () ? "subprocess" - : "i/o ready"); - outf_flush_console (); - } + trace (";scheme_source_check: %s\n", + src->runnable ? "thread" + : pending_interrupts_p () ? "interrupt" + : OS_process_any_status_change () ? "subprocess" + : "i/o ready"); return (TRUE); /* Ready for immediate dispatch. */ } return (FALSE); /* No I/O ready; no timeout. */ @@ -195,22 +189,12 @@ do_scheme (GSource *source) gtk_label_set_text (GTK_LABEL (status_label), text); g_free (text); } - if (tracing_gtk_select) - { - outf_console (";scheme_source_dispatch: running time slice %d\n", - slice_counter); - outf_flush_console (); - } + trace (";scheme_source_dispatch: running time slice %d\n", slice_counter); Interpret (1); alienate_float_environment (); - if (tracing_gtk_select) - { - outf_console (";scheme_source_dispatch: finished time slice %d\n", - slice_counter); - outf_flush_console (); - } + trace (";scheme_source_dispatch: finished time slice %d\n", slice_counter); return (TRUE); /* Not a once-only. */ } @@ -395,6 +379,7 @@ void yield_gtk (void) { scheme_source->runnable = TRUE; + trace (";yield_gtk: runnable at %.1f\n", OS_real_time_clock ()); }