|
From: <sv...@va...> - 2005-04-24 11:23:01
|
Author: sewardj
Date: 2005-04-24 12:22:44 +0100 (Sun, 24 Apr 2005)
New Revision: 3553
Modified:
trunk/coregrind/vg_transtab.c
Log:
Add initialisation-order sanity checks.
Modified: trunk/coregrind/vg_transtab.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/vg_transtab.c 2005-04-24 11:05:55 UTC (rev 3552)
+++ trunk/coregrind/vg_transtab.c 2005-04-24 11:22:44 UTC (rev 3553)
@@ -203,6 +203,10 @@
/*global*/ UInt* VG_(tt_fastN)[VG_TT_FAST_SIZE];
=20
=20
+/* Make sure we're not used before initialisation. */
+static Bool init_done =3D False;
+
+
/*------------------ STATS DECLS ------------------*/
=20
/* Number of fast-cache updates and flushes done. */
@@ -330,6 +334,7 @@
UChar* srcP;
UChar* dstP;
=20
+ vg_assert(init_done);
vg_assert(vge->n_used >=3D 1 && vge->n_used <=3D 3);
vg_assert(code_len > 0 && code_len < 20000);
=20
@@ -429,6 +434,8 @@
Bool upd_cache )
{
Int i, j, k, kstart, sno;
+
+ vg_assert(init_done);
/* Find the initial probe point just once. It will be the same in
all sectors and avoids multiple expensive % operations. */
n_full_lookups++;
@@ -516,6 +523,8 @@
Int sno, i;
Bool anyDeleted =3D False;
=20
+ vg_assert(init_done);
+
for (sno =3D 0; sno < N_SECTORS; sno++) {
if (sectors[sno].tc =3D=3D NULL)
continue;
@@ -553,6 +562,9 @@
{
Int i, avg_codeszQ;
=20
+ vg_assert(!init_done);
+ init_done =3D True;
+
/* Otherwise lots of things go wrong... */
vg_assert(sizeof(ULong) =3D=3D 8);
vg_assert(sizeof(Addr64) =3D=3D 8);
|