Fix 64-bit uncleanness in VG_(get_bbs_translated)/VG_(get_bbs_discarded_or_dumped) ..
[valgrind.git] / memcheck / tests / varinfo1.c
blob8d885218951e1939abd7d49739f2934a4c067cb1
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 volatile 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((void *)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;