drd: Add a consistency check
[valgrind.git] / memcheck / tests / recursive-merge.c
blob204f00eba621df17a0d99d8f40862d347752df80
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <valgrind.h>
5 void (*fnptr[256])(char*, char*);
7 #define BODY(f) \
8 { \
9 fprintf(stderr, f); \
10 calls++; \
11 (*fnptr[(int)*calls])(calls,seq); \
14 void stacktrace(char*last, char* callsequence)
16 fprintf(stderr, "\n");
17 VALGRIND_PRINTF_BACKTRACE ("%s", callsequence);
19 __attribute__((noinline)) void f_a(char *calls, char*seq);
20 __attribute__((noinline)) void f_b(char *calls, char*seq);
21 __attribute__((noinline)) void f_c(char *calls, char*seq);
22 __attribute__((noinline)) void f_d(char *calls, char*seq);
24 __attribute__((noinline)) void f_a(char *calls, char*seq)
25 BODY("a")
27 __attribute__((noinline)) void f_b(char *calls, char*seq)
28 BODY("b")
30 __attribute__((noinline)) void f_c(char *calls, char*seq)
31 BODY("c");
33 __attribute__((noinline)) void f_d(char *calls, char*seq)
34 BODY("d");
36 void doit (int argc, char**argv)
38 int i;
39 for (i = 1; i < argc; i++) {
40 char* calls = argv[i];
41 char* seq = argv[i];
42 calls--;
43 BODY("test ")
47 int main(int argc, char**argv)
50 fnptr[0] = stacktrace;
51 fnptr['a'] = f_a;
52 fnptr['b'] = f_b;
53 fnptr['c'] = f_c;
54 fnptr['d'] = f_d;
56 doit(argc, argv); // with default value of our argument.
58 (void) VALGRIND_MONITOR_COMMAND("v.set merge-recursive-frames 3");
59 doit(argc, argv);
61 (void) VALGRIND_MONITOR_COMMAND("v.set merge-recursive-frames 2");
62 doit(argc, argv);
64 (void) VALGRIND_MONITOR_COMMAND("v.set merge-recursive-frames 1");
65 doit(argc, argv);
67 (void) VALGRIND_MONITOR_COMMAND("v.set merge-recursive-frames 0");
68 doit(argc, argv);
70 return 0;