|
From: <sv...@va...> - 2007-01-01 22:17:38
|
Author: sewardj
Date: 2007-01-01 22:17:37 +0000 (Mon, 01 Jan 2007)
New Revision: 6472
Log:
Merge r6471 (Avoid printf in the recursive routines ...)
Modified:
branches/VALGRIND_3_2_BRANCH/memcheck/tests/wrap8.c
Modified: branches/VALGRIND_3_2_BRANCH/memcheck/tests/wrap8.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
--- branches/VALGRIND_3_2_BRANCH/memcheck/tests/wrap8.c 2007-01-01 22:07:=
58 UTC (rev 6471)
+++ branches/VALGRIND_3_2_BRANCH/memcheck/tests/wrap8.c 2007-01-01 22:17:=
37 UTC (rev 6472)
@@ -1,4 +1,4 @@
-
+#include <unistd.h>
#include <stdio.h>
#include <malloc.h>
#include "valgrind.h"
@@ -12,15 +12,15 @@
Hence this test has two expected outcomes:
- on ppc64-linux, a stack overflow is caught, and V aborts.
- on everything else, it runs successfully to completion.
+ Note, pre() and post() used so as to avoid printf, which messes
+ up the call stacks on ppc64-linux due to intercept of mempcpy.
*/
-
typedef=20
struct _Lard {
struct _Lard* next;=20
char stuff[999];=20
}
Lard;
-
Lard* lard =3D NULL;
static int ctr =3D 0;
=20
@@ -34,8 +34,8 @@
lard =3D p;
}
}
-
-
+static void post ( char* s, int n, int r );
+static void pre ( char* s, int n );
static int fact1 ( int n );
static int fact2 ( int n );
=20
@@ -60,11 +60,11 @@
int r;
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
- printf("in wrapper1-pre: fact(%d)\n", n); fflush(stdout);
+ pre("wrapper1", n);
addMoreLard();
CALL_FN_W_W(r, fn, n);
addMoreLard();
- printf("in wrapper1-post: fact(%d) =3D %d\n", n, r); fflush(stdout);
+ post("wrapper1", n, r);
if (n >=3D 3) r +=3D fact2(2);
return r;
}
@@ -74,11 +74,11 @@
int r;
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
- printf("in wrapper2-pre: fact(%d)\n", n); fflush(stdout);
+ pre("wrapper2", n);
addMoreLard();
CALL_FN_W_W(r, fn, n);
addMoreLard();
- printf("in wrapper2-post: fact(%d) =3D %d\n", n, r); fflush(stdout);
+ post("wrapper2", n, r);
return r;
}
=20
@@ -100,3 +100,40 @@
=20
return 0;
}
+
+static void send ( char* s )
+{
+ while (*s) {
+ write(1, s, 1);
+ s++;
+ }
+}
+
+static void pre ( char* s, int n )
+{
+ char buf[50];
+ fflush(stdout);
+ sprintf(buf,"%d", n);
+ send("in ");
+ send(s);
+ send("-pre: fact(");
+ send(buf);
+ send(")\n");
+ fflush(stdout);
+}
+
+static void post ( char* s, int n, int r )
+{
+ char buf[50];
+ fflush(stdout);
+ sprintf(buf,"%d", n);
+ send("in ");
+ send(s);
+ send("-post: fact(");
+ send(buf);
+ send(") =3D ");
+ sprintf(buf,"%d", r);
+ send(buf);
+ send("\n");
+ fflush(stdout);
+}
|