mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-08 21:09:49 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
35
VEX/test_main.h.base
Normal file
35
VEX/test_main.h.base
Normal file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user