|
From: <sv...@va...> - 2005-06-19 18:49:22
|
Author: njn
Date: 2005-06-19 19:49:19 +0100 (Sun, 19 Jun 2005)
New Revision: 3955
Log:
Move VG_(sanity_check_general) out of m_main.c into scheduler.c.
Removes the dependence of m_scheduler/ on m_main.c; reduces the=20
dependence of m_signals.c on m_main.c.
Modified:
trunk/coregrind/m_main.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/pub_core_aspacemgr.h
trunk/coregrind/pub_core_main.h
trunk/coregrind/pub_core_scheduler.h
Modified: trunk/coregrind/m_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_main.c 2005-06-19 18:38:24 UTC (rev 3954)
+++ trunk/coregrind/m_main.c 2005-06-19 18:49:19 UTC (rev 3955)
@@ -129,22 +129,10 @@
/*=3D=3D=3D Counters, for profiling purposes only =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
-/* Counts pertaining to internal sanity checking. */
-static UInt sanity_fast_count =3D 0;
-static UInt sanity_slow_count =3D 0;
-
static void print_all_stats ( void )
{
- // Translation stats
VG_(print_tt_tc_stats)();
-
- // Scheduler stats
VG_(print_scheduler_stats)();
-
- VG_(message)(Vg_DebugMsg,=20
- " sanity: %d cheap, %d expensive checks.",
- sanity_fast_count, sanity_slow_count );
-
VG_(print_ExeContext_stats)();
=20
// Memory stats
@@ -155,7 +143,6 @@
VG_(sanity_check_malloc_all)();
VG_(print_all_arena_stats)();
VG_(message)(Vg_DebugMsg, "");
- //VG_(print_shadow_stats)();
}
}
=20
@@ -2310,96 +2297,6 @@
=20
=20
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-/*=3D=3D=3D Sanity check machinery (permanently engaged) =
=3D=3D=3D*/
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
-
-/* A fast sanity check -- suitable for calling circa once per
- millisecond. */
-
-void VG_(sanity_check_general) ( Bool force_expensive )
-{
- ThreadId tid;
-
- VGP_PUSHCC(VgpCoreCheapSanity);
-
- if (VG_(clo_sanity_level) < 1) return;
-
- /* --- First do all the tests that we can do quickly. ---*/
-
- sanity_fast_count++;
-
- /* Check stuff pertaining to the memory check system. */
-
- /* Check that nobody has spuriously claimed that the first or
- last 16 pages of memory have become accessible [...] */
- if (VG_(needs).sanity_checks) {
- VGP_PUSHCC(VgpToolCheapSanity);
- vg_assert(VG_TDICT_CALL(tool_cheap_sanity_check));
- VGP_POPCC(VgpToolCheapSanity);
- }
-
- /* --- Now some more expensive checks. ---*/
-
- /* Once every 25 times, check some more expensive stuff. */
- if ( force_expensive
- || VG_(clo_sanity_level) > 1
- || (VG_(clo_sanity_level) =3D=3D 1 && (sanity_fast_count % 25) =3D=3D=
0)) {
-
- VGP_PUSHCC(VgpCoreExpensiveSanity);
- sanity_slow_count++;
-
-# if 0
- { void zzzmemscan(void); zzzmemscan(); }
-# endif
-
- if ((sanity_fast_count % 250) =3D=3D 0)
- VG_(sanity_check_tt_tc)("VG_(sanity_check_general)");
-
- if (VG_(needs).sanity_checks) {
- VGP_PUSHCC(VgpToolExpensiveSanity);
- vg_assert(VG_TDICT_CALL(tool_expensive_sanity_check));
- VGP_POPCC(VgpToolExpensiveSanity);
- }
-
- /* Check that Segments and /proc/self/maps match up */
- //vg_assert(VG_(sanity_check_memory)());
-
- /* Look for stack overruns. Visit all threads. */
- for(tid =3D 1; tid < VG_N_THREADS; tid++) {
- SSizeT remains;
-
- if (VG_(threads)[tid].status =3D=3D VgTs_Empty ||
- VG_(threads)[tid].status =3D=3D VgTs_Zombie)
- continue;
-
- remains =3D VGA_(stack_unused)(tid);
- if (remains < VKI_PAGE_SIZE)
- VG_(message)(Vg_DebugMsg,=20
- "WARNING: Thread %d is within %d bytes "
- "of running out of stack!",
- tid, remains);
- }
-
- /*=20
- if ((sanity_fast_count % 500) =3D=3D 0) VG_(mallocSanityCheckAll)(=
);=20
- */
- VGP_POPCC(VgpCoreExpensiveSanity);
- }
-
- if (VG_(clo_sanity_level) > 1) {
- VGP_PUSHCC(VgpCoreExpensiveSanity);
- /* Check sanity of the low-level memory manager. Note that bugs
- in the client's code can cause this to fail, so we don't do
- this check unless specially asked for. And because it's
- potentially very expensive. */
- VG_(sanity_check_malloc_all)();
- VGP_POPCC(VgpCoreExpensiveSanity);
- }
- VGP_POPCC(VgpCoreCheapSanity);
-}
-
-
-/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
/*=3D=3D=3D main() =
=3D=3D=3D*/
/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/
=20
Modified: trunk/coregrind/m_scheduler/scheduler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_scheduler/scheduler.c 2005-06-19 18:38:24 UTC (rev =
3954)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-19 18:49:19 UTC (rev =
3955)
@@ -71,7 +71,6 @@
#include "pub_core_libcproc.h"
#include "pub_core_libcsignal.h"
#include "pub_core_machine.h"
-#include "pub_core_main.h"
#include "pub_core_mallocfree.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
@@ -116,6 +115,9 @@
static UInt n_scheduling_events_MINOR =3D 0;
static UInt n_scheduling_events_MAJOR =3D 0;
=20
+/* Sanity checking counts. */
+static UInt sanity_fast_count =3D 0;
+static UInt sanity_slow_count =3D 0;
=20
void VG_(print_scheduler_stats)(void)
{
@@ -124,6 +126,9 @@
VG_(message)(Vg_DebugMsg,
"scheduler: %d/%d major/minor sched events.",=20
n_scheduling_events_MAJOR, n_scheduling_events_MINOR);
+ VG_(message)(Vg_DebugMsg,=20
+ " sanity: %d cheap, %d expensive checks.",
+ sanity_fast_count, sanity_slow_count );
}
=20
/* CPU semaphore, so that threads can run exclusively */
@@ -1031,7 +1036,7 @@
=20
=20
/* ---------------------------------------------------------------------
- Sanity checking.
+ Sanity checking (permanently engaged)
------------------------------------------------------------------ */
=20
/* Internal consistency checks on the sched structures. */
@@ -1055,7 +1060,88 @@
}
}
=20
+void VG_(sanity_check_general) ( Bool force_expensive )
+{
+ ThreadId tid;
=20
+ VGP_PUSHCC(VgpCoreCheapSanity);
+
+ if (VG_(clo_sanity_level) < 1) return;
+
+ /* --- First do all the tests that we can do quickly. ---*/
+
+ sanity_fast_count++;
+
+ /* Check stuff pertaining to the memory check system. */
+
+ /* Check that nobody has spuriously claimed that the first or
+ last 16 pages of memory have become accessible [...] */
+ if (VG_(needs).sanity_checks) {
+ VGP_PUSHCC(VgpToolCheapSanity);
+ vg_assert(VG_TDICT_CALL(tool_cheap_sanity_check));
+ VGP_POPCC(VgpToolCheapSanity);
+ }
+
+ /* --- Now some more expensive checks. ---*/
+
+ /* Once every 25 times, check some more expensive stuff. */
+ if ( force_expensive
+ || VG_(clo_sanity_level) > 1
+ || (VG_(clo_sanity_level) =3D=3D 1 && (sanity_fast_count % 25) =3D=3D=
0)) {
+
+ VGP_PUSHCC(VgpCoreExpensiveSanity);
+ sanity_slow_count++;
+
+# if 0
+ { void zzzmemscan(void); zzzmemscan(); }
+# endif
+
+ if ((sanity_fast_count % 250) =3D=3D 0)
+ VG_(sanity_check_tt_tc)("VG_(sanity_check_general)");
+
+ if (VG_(needs).sanity_checks) {
+ VGP_PUSHCC(VgpToolExpensiveSanity);
+ vg_assert(VG_TDICT_CALL(tool_expensive_sanity_check));
+ VGP_POPCC(VgpToolExpensiveSanity);
+ }
+
+ /* Check that Segments and /proc/self/maps match up */
+ //vg_assert(VG_(sanity_check_memory)());
+
+ /* Look for stack overruns. Visit all threads. */
+ for(tid =3D 1; tid < VG_N_THREADS; tid++) {
+ SSizeT remains;
+
+ if (VG_(threads)[tid].status =3D=3D VgTs_Empty ||
+ VG_(threads)[tid].status =3D=3D VgTs_Zombie)
+ continue;
+
+ remains =3D VGA_(stack_unused)(tid);
+ if (remains < VKI_PAGE_SIZE)
+ VG_(message)(Vg_DebugMsg,=20
+ "WARNING: Thread %d is within %d bytes "
+ "of running out of stack!",
+ tid, remains);
+ }
+
+ /*=20
+ if ((sanity_fast_count % 500) =3D=3D 0) VG_(mallocSanityCheckAll)(=
);=20
+ */
+ VGP_POPCC(VgpCoreExpensiveSanity);
+ }
+
+ if (VG_(clo_sanity_level) > 1) {
+ VGP_PUSHCC(VgpCoreExpensiveSanity);
+ /* Check sanity of the low-level memory manager. Note that bugs
+ in the client's code can cause this to fail, so we don't do
+ this check unless specially asked for. And because it's
+ potentially very expensive. */
+ VG_(sanity_check_malloc_all)();
+ VGP_POPCC(VgpCoreExpensiveSanity);
+ }
+ VGP_POPCC(VgpCoreCheapSanity);
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/pub_core_aspacemgr.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_aspacemgr.h 2005-06-19 18:38:24 UTC (rev 395=
4)
+++ trunk/coregrind/pub_core_aspacemgr.h 2005-06-19 18:49:19 UTC (rev 395=
5)
@@ -149,8 +149,6 @@
extern Addr VG_(get_memory_from_mmap_for_client)
(Addr base, SizeT len, UInt prot, UInt flags);
=20
-//extern void VG_(print_shadow_stats)();
-
/* Parses /proc/self/maps, calling `record_mapping' for each entry. */
extern=20
void VG_(parse_procselfmaps) (
Modified: trunk/coregrind/pub_core_main.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_main.h 2005-06-19 18:38:24 UTC (rev 3954)
+++ trunk/coregrind/pub_core_main.h 2005-06-19 18:49:19 UTC (rev 3955)
@@ -38,9 +38,6 @@
// things.
//--------------------------------------------------------------------
=20
-/* Sanity checks which may be done at any time. The scheduler decides w=
hen. */
-extern void VG_(sanity_check_general) ( Bool force_expensive );
-
/* client executable file descriptor */
extern Int VG_(clexecfd);
=20
Modified: trunk/coregrind/pub_core_scheduler.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/pub_core_scheduler.h 2005-06-19 18:38:24 UTC (rev 395=
4)
+++ trunk/coregrind/pub_core_scheduler.h 2005-06-19 18:49:19 UTC (rev 395=
5)
@@ -86,6 +86,9 @@
/* If true, a fault is Valgrind-internal (ie, a bug) */
extern Bool VG_(my_fault);
=20
+/* Sanity checks which may be done at any time. The scheduler decides w=
hen. */
+extern void VG_(sanity_check_general) ( Bool force_expensive );
+
#endif // __PUB_CORE_SCHEDULER_H
=20
/*--------------------------------------------------------------------*/
|