|
From: <sv...@va...> - 2006-01-19 03:48:50
|
Author: sewardj
Date: 2006-01-19 03:48:47 +0000 (Thu, 19 Jan 2006)
New Revision: 5556
Log:
Make a bit less nonsensical on 64-bit platforms.
Modified:
trunk/memcheck/tests/pointer-trace.c
Modified: trunk/memcheck/tests/pointer-trace.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/memcheck/tests/pointer-trace.c 2006-01-19 03:47:30 UTC (rev 555=
5)
+++ trunk/memcheck/tests/pointer-trace.c 2006-01-19 03:48:47 UTC (rev 555=
6)
@@ -11,19 +11,38 @@
=20
int main()
{
- const int ptrbits =3D sizeof(void *) * 8;
- const int stepbits =3D 14;
- const int stepsize =3D (1 << stepbits);
- const int nptrs =3D 1 << (ptrbits - stepbits);
-
char **volatile ptrs;
int i;
int fd;
char *map;
=20
+ /* I _think_ the point of this is to fill ptrs with a pointer
+ to every 4th page in the entire address space, hence
+ guaranteeing that at least one of them points into one of
+ the below traps, and so checks that the leak checker
+ doesn't bomb when following them. That's fine on 32-bit
+ platforms, but hopeless for a 64-bit system. So the
+ following settings do achieve that on a 32-bit target but
+ merely make a 64-bit target give the same output without
+ properly testing it. */
+ int ptrbits, stepbits, stepsize, nptrs;
+ if (sizeof(void*) =3D=3D 8) {
+ /* 64-bit machine */
+ ptrbits =3D 32; //bogus
+ stepbits =3D 14+1; //bogus
+ stepsize =3D (1 << stepbits);
+ nptrs =3D 1 << (ptrbits - stepbits);
+ } else {
+ /* 32-bit machine */
+ ptrbits =3D 32;
+ stepbits =3D 14;
+ stepsize =3D (1 << stepbits);
+ nptrs =3D 1 << (ptrbits - stepbits);
+ }
+
ptrs =3D malloc(nptrs * sizeof(char *));
for(i =3D 0; i < nptrs; i++)
- ptrs[i] =3D (char *)(i << stepbits);
+ ptrs[i] =3D (char *)((long)i << stepbits);
=20
/* lay some traps */
map =3D mmap(0, stepsize * 2, PROT_NONE, MAP_PRIVATE|MAP_NORESERVE|MAP_=
ANONYMOUS, -1, 0);
|