From 9fd6f5f13178feffa945d424c1eefd2f45f244aa Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 29 Oct 2004 23:42:36 +0000 Subject: [PATCH] Much-improved method for configuring test-driver program: copy test_main.h.base to test_main.h, and edit. git-svn-id: svn://svn.valgrind.org/vex/trunk@457 --- VEX/Makefile | 2 +- VEX/test_main.c | 60 +++++++++++++++++++++++--------------------- VEX/test_main.h.base | 35 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 VEX/test_main.h.base diff --git a/VEX/Makefile b/VEX/Makefile index 56333bbbb..d6d866c9e 100644 --- a/VEX/Makefile +++ b/VEX/Makefile @@ -67,7 +67,7 @@ clean: ALL_HEADERS = $(PUB_HEADERS) $(PRIV_HEADERS) ALL_INCLUDES = $(PUB_INCLUDES) $(PRIV_INCLUDES) -test_main.o: $(PUB_HEADERS) test_main.c +test_main.o: $(PUB_HEADERS) test_main.c test_main.h $(CC) $(CCFLAGS) $(PUB_INCLUDES) -o test_main.o \ -c test_main.c diff --git a/VEX/test_main.c b/VEX/test_main.c index 33e2db172..50372ca03 100644 --- a/VEX/test_main.c +++ b/VEX/test_main.c @@ -13,6 +13,9 @@ #include "libvex_basictypes.h" #include "libvex.h" +#include "test_main.h" + + /*---------------------------------------------------------------*/ /*--- Test ---*/ /*---------------------------------------------------------------*/ @@ -49,7 +52,7 @@ int main ( int argc, char** argv ) Int i; UInt u, sum; Addr32 orig_addr; - Int bb_number; + Int bb_number, n_bbs_done = 0; Int orig_nbytes, trans_used, orig_used; TranslateResult tres; VexControl vcon; @@ -73,59 +76,58 @@ int main ( int argc, char** argv ) LibVEX_Init ( &failure_exit, &log_bytes, 1, /* debug_paranoia */ - //False, - True, /* valgrind support */ + TEST_VSUPPORT, /* valgrind support */ &vcon ); -#if 0 - {extern void test_asm86(void); - test_asm86(); - return 0; - } -#endif while (!feof(f)) { + fgets(linebuf, N_LINEBUF,f); - //printf("%s", linebuf); - assert(linebuf[0] != 0); + if (linebuf[0] == 0) continue; if (linebuf[0] != '.') continue; + + if (n_bbs_done == TEST_N_BBS) break; + n_bbs_done++; + /* first line is: . bb-number bb-addr n-bytes */ assert(3 == sscanf(&linebuf[1], " %d %x %d\n", & bb_number, - & orig_addr, & orig_nbytes )); + & orig_addr, & orig_nbytes )); assert(orig_nbytes >= 1); assert(!feof(f)); fgets(linebuf, N_LINEBUF,f); assert(linebuf[0] == '.'); + /* second line is: . byte byte byte etc */ - //printf("%s", linebuf); if (verbose) printf("============ Basic Block %d, " "Start %x, nbytes %2d ============", - bb_number, orig_addr, orig_nbytes); + n_bbs_done-1, orig_addr, orig_nbytes); + assert(orig_nbytes >= 1 && orig_nbytes <= N_ORIGBUF); for (i = 0; i < orig_nbytes; i++) { - assert(1 == sscanf(&linebuf[2 + 3*i], "%x", &u)); - origbuf[i] = (UChar)u; + assert(1 == sscanf(&linebuf[2 + 3*i], "%x", &u)); + origbuf[i] = (UChar)u; } - if (bb_number == 10000) break; - { - for (i = 0; i < 1; i++) - tres = - LibVEX_Translate ( InsnSetX86, InsnSetX86, - origbuf, (Addr64)orig_addr, &orig_used, - transbuf, N_TRANSBUF, &trans_used, - NULL, /* instrument1 */ - NULL, /* instrument2 */ - NULL, /* tool-findhelper */ - NULL, /* access checker */ - (1<<2) ); + for (i = 0; i < TEST_N_ITERS; i++) + tres + = LibVEX_Translate ( + InsnSetX86, InsnSetX86, + origbuf, (Addr64)orig_addr, &orig_used, + transbuf, N_TRANSBUF, &trans_used, + NULL, /* instrument1 */ + NULL, /* instrument2 */ + NULL, /* tool-findhelper */ + NULL, /* access checker */ + TEST_FLAGS + ); + if (tres != TransOK) printf("\ntres = %d\n", (Int)tres); assert(tres == TransOK); assert(orig_used == orig_nbytes); - } + sum = 0; for (i = 0; i < trans_used; i++) sum += (UInt)transbuf[i]; diff --git a/VEX/test_main.h.base b/VEX/test_main.h.base new file mode 100644 index 000000000..908762934 --- /dev/null +++ b/VEX/test_main.h.base @@ -0,0 +1,35 @@ + +/* Copy this file (test_main.h.in) to test_main.h, and edit */ + +/* DEBUG RUN, ON V */ +#if 1 +#define TEST_VSUPPORT True +#define TEST_N_ITERS 1 +#define TEST_N_BBS 1 +#define TEST_FLAGS (1<<7) +#endif + +/* CHECKING RUN, ON V */ +#if 0 +#define TEST_VSUPPORT True +#define TEST_N_ITERS 1 +#define TEST_N_BBS 100000 +#define TEST_FLAGS 0 +#endif + +/* PROFILING RUN, NATIVE */ +#if 0 +#define TEST_VSUPPORT False +#define TEST_N_ITERS 100 +#define TEST_N_BBS 1000 +#define TEST_FLAGS 0 +#endif + +/* PROFILING RUN, REDUCED WORKLOAD */ +#if 0 +#define TEST_VSUPPORT False +#define TEST_N_ITERS 3 +#define TEST_N_BBS 1000 +#define TEST_FLAGS 0 +#endif +