xen: Infratructure for XEN_TMEM_* hypercalls
[valgrind.git] / memcheck / tests / varinfo1.c
blob6a739566fe2bd935c6605f07018827d83a89d3f3
2 /* Basic check of variable location identification, in a zero-biased
3 executable. */
5 /* Relevant compile flags are:
7 -Wall -g -I$prefix/include/valgrind
9 eg -Wall -g -I`pwd`/Inst/include/valgrind
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include "memcheck/memcheck.h"
17 /* Cause memcheck to complain about the address "a" and so to print
18 its best guess as to what "a" actually is. a must be
19 addressible. */
21 void croak ( void* aV )
23 char* a = (char*)aV;
24 char* undefp = malloc(1);
25 char saved = *a;
26 assert(undefp);
27 *a = *undefp;
28 (void) VALGRIND_CHECK_MEM_IS_DEFINED(a, 1);
29 *a = saved;
30 free(undefp);
33 #include <stdio.h>
35 int global_u1;
37 int global_i1 = 17;
39 char global_u2[10];
41 char global_i2[10] = { 1,2,3,4,5,6,7,8,9,10 };
44 int main ( void )
46 int local;
47 char* onheap = malloc(3);
48 assert(onheap);
49 croak(onheap+1);
50 free(onheap);
52 croak( &global_u1 );
53 croak( &global_i1 );
54 croak( &global_u2[3] );
55 croak( &global_i2[7] );
56 croak( &local );
57 return 0;