Commit d9d8ab15 authored by sof's avatar sof

[project @ 2002-07-25 18:36:59 by sof]

Expose printAllThreads() in non-DEBUG builds;
of some use when debugging ConcHask code and
want a dump of the current state of the system's
threads.

Not provided via a library, so to use, do

 foreign import call unsafe printAllThreads :: IO ()
parent 80a99ae2
/* ---------------------------------------------------------------------------
* $Id: Schedule.c,v 1.150 2002/07/19 18:45:21 sof Exp $
* $Id: Schedule.c,v 1.151 2002/07/25 18:36:59 sof Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -84,6 +84,7 @@
#include "StgRun.h"
#include "StgStartup.h"
#include "Hooks.h"
#define COMPILING_SCHEDULER
#include "Schedule.h"
#include "StgMiscClosures.h"
#include "Storage.h"
......@@ -3549,11 +3550,12 @@ detectBlackHoles( void )
//@subsection Debugging Routines
/* -----------------------------------------------------------------------------
Debugging: why is a thread blocked
* Debugging: why is a thread blocked
* [Also provides useful information when debugging threaded programs
* at the Haskell source code level, so enable outside of DEBUG. --sof 7/02]
-------------------------------------------------------------------------- */
#ifdef DEBUG
static
void
printThreadBlockage(StgTSO *tso)
{
......@@ -3601,6 +3603,7 @@ printThreadBlockage(StgTSO *tso)
}
}
static
void
printThreadStatus(StgTSO *tso)
{
......@@ -3627,15 +3630,15 @@ printAllThreads(void)
ullong_format_string(TIME_ON_PROC(CurrentProc),
time_string, rtsFalse/*no commas!*/);
sched_belch("all threads at [%s]:", time_string);
fprintf(stderr, "all threads at [%s]:\n", time_string);
# elif defined(PAR)
char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN];
ullong_format_string(CURRENT_TIME,
time_string, rtsFalse/*no commas!*/);
sched_belch("all threads at [%s]:", time_string);
fprintf(stderr,"all threads at [%s]:\n", time_string);
# else
sched_belch("all threads:");
fprintf(stderr,"all threads:\n");
# endif
for (t = all_threads; t != END_TSO_QUEUE; t = t->global_link) {
......@@ -3647,6 +3650,8 @@ printAllThreads(void)
}
}
#ifdef DEBUG
/*
Print a whole blocking queue attached to node (debugging only).
*/
......
/* -----------------------------------------------------------------------------
* $Id: Schedule.h,v 1.34 2002/06/19 20:45:15 sof Exp $
* $Id: Schedule.h,v 1.35 2002/07/25 18:37:00 sof Exp $
*
* (c) The GHC Team 1998-1999
*
......@@ -183,14 +183,16 @@ typedef struct StgMainThread_ {
*/
extern StgMainThread *main_threads;
void printAllThreads(void);
#ifdef COMPILING_SCHEDULER
static void printThreadBlockage(StgTSO *tso);
static void printThreadStatus(StgTSO *tso);
#endif
/* debugging only
*/
#ifdef DEBUG
void printThreadBlockage(StgTSO *tso);
void printThreadStatus(StgTSO *tso);
void printAllThreads(void);
#endif
void print_bq (StgClosure *node);
#endif
#if defined(PAR)
void print_bqe (StgBlockingQueueElement *bqe);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment