Final commit for the initial modularisation pass:

- Broke part of m_scheduler off into a new module m_threadstate.  It
  contains ThreadState, VG_(threads)[] and some basic operations on the
  thread table.  All simple stuff, the complex stuff stays in m_scheduler.
  This avoids lots of circular dependencies between m_scheduler and other
  modules.

- Managed to finally remove core.h and tool.h, double hurrah!

- Introduced pub_tool_basics.h and pub_core_basics.h, one of which is
  include by every single C file.

- Lots of little cleanups and changes related to the above.

- I even did a small amount of documentation updating.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3944 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c
index d5825bd..ecaf6b6 100644
--- a/coregrind/m_libcassert.c
+++ b/coregrind/m_libcassert.c
@@ -28,12 +28,14 @@
    The GNU General Public License is contained in the file COPYING.
 */
 
-#include "core.h"
+#include "pub_core_basics.h"
+#include "pub_core_threadstate.h"
 #include "pub_core_libcbase.h"
 #include "pub_core_libcassert.h"
 #include "pub_core_libcprint.h"
 #include "pub_core_libcproc.h"
-#include "pub_core_main.h"
+#include "pub_core_main.h"          // for VG_(bbs_done) -- stupid!
+#include "pub_core_options.h"       // for VG_(bbs_done) -- stupid!
 #include "pub_core_stacktrace.h"
 #include "pub_core_syscall.h"
 #include "pub_core_tooliface.h"
@@ -70,6 +72,21 @@
    vg_assert(2+2 == 5);
 }
 
+// Print the scheduler status.
+static void pp_sched_status ( void )
+{
+   Int i; 
+   VG_(printf)("\nsched status:\n"); 
+   VG_(printf)("  running_tid=%d\n", VG_(get_running_tid)());
+   for (i = 1; i < VG_N_THREADS; i++) {
+      if (VG_(threads)[i].status == VgTs_Empty) continue;
+      VG_(printf)( "\nThread %d: status = %s\n", i, 
+                   VG_(name_of_ThreadStatus)(VG_(threads)[i].status) );
+      VG_(get_and_pp_StackTrace)( i, VG_(clo_backtrace_size) );
+   }
+   VG_(printf)("\n");
+}
+
 __attribute__ ((noreturn))
 static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr fp )
 {
@@ -95,7 +112,7 @@
 
    VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_done) );
 
-   VG_(pp_sched_status)();
+   pp_sched_status();
    VG_(printf)("\n");
    VG_(printf)("Note: see also the FAQ.txt in the source distribution.\n");
    VG_(printf)("It contains workarounds to several common problems.\n");
@@ -196,7 +213,7 @@
       "Valgrind has to exit now.  Sorry.  Bye!");
    VG_(message)(Vg_UserMsg,
       "");
-   VG_(pp_sched_status)();
+   pp_sched_status();
    VG_(exit)(1);
 }