OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/tags/gnu-src/gcc-4.5.1/gcc-4.5.1-or32-1.0rc1/libmudflap/testsuite/libmudflap.c
    from Rev 275 to Rev 338
    Reverse comparison

Rev 275 → Rev 338

/pass47-frag.c
0,0 → 1,10
#include <stdlib.h>
#include <ctype.h>
 
int main ()
{
char* buf = "hello";
return ! ((toupper (buf[0]) == 'H' && toupper ('z') == 'Z' &&
tolower (buf[4]) == 'o' && tolower ('X') == 'x' &&
isdigit (buf[3])) == 0 && isalnum ('4'));
}
pass47-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail33-frag.c =================================================================== --- fail33-frag.c (nonexistent) +++ fail33-frag.c (revision 338) @@ -0,0 +1,25 @@ +#include + +#define SIZE 16 + +char b[SIZE]; +char a[SIZE]; + +int main () +{ + int i, j=0, k; + int a_before_b = (& a[0] < & b[0]); + /* Rather than iterating linearly, which would allow loop unrolling + and mapping to pointer manipulation, we traverse the "joined" + arrays in some random order. */ + for (i=0; i
fail33-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass67-frag.c =================================================================== --- pass67-frag.c (nonexistent) +++ pass67-frag.c (revision 338) @@ -0,0 +1,14 @@ +/* PR middle-end/35314 */ +/* { dg-do compile } */ +/* { dg-options "-fmudflap" } */ + +#include + +jmp_buf buf; + +void +foo (volatile char *p) +{ + if (__builtin_setjmp (buf)) + *p; +}
pass67-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail17-frag.c =================================================================== --- fail17-frag.c (nonexistent) +++ fail17-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include +int main () +{ + +char * x; +int foo; +x = (char *) malloc (10); +strcpy (x, "123456789"); +foo = strlen (x+10); +x [foo] = 1; /* we just just use foo to force execution of strlen */ +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail17-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail27-frag.c =================================================================== --- fail27-frag.c (nonexistent) +++ fail27-frag.c (revision 338) @@ -0,0 +1,24 @@ +#include +#include +#include + +char volatile * +__attribute__((noinline)) +foo (unsigned i) +{ + char volatile buffer[10]; + char volatile *k = i ? & buffer[i] : NULL; /* defeat addr-of-local-returned warning */ + return k; +} + +int main () +{ +char volatile *f = foo (5); +f[0] = 'b'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*buffer.*alloc.*dealloc" } */ +/* { dg-do run { xfail *-*-* } } */
fail27-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail37-frag.c =================================================================== --- fail37-frag.c (nonexistent) +++ fail37-frag.c (revision 338) @@ -0,0 +1,22 @@ +typedef struct +{ + short f : 3; +} small; + +struct +{ + int i; + small s[4]; +} x; + +main () +{ + int i; + for (i = 0; i < 5; i++) + x.s[i].f = 0; + exit (0); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.* x.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail37-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass2-frag.c =================================================================== --- pass2-frag.c (nonexistent) +++ pass2-frag.c (revision 338) @@ -0,0 +1,9 @@ +#include +#include +#include +int main () +{ +int foo [10][10]; +foo[9][0] = 0; +return 0; +}
pass2-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass6-frag.c =================================================================== --- pass6-frag.c (nonexistent) +++ pass6-frag.c (revision 338) @@ -0,0 +1,14 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; + +foo = (char *)malloc (10); +bar = (char *)malloc (10); +bar[2] = 'z'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +}
pass6-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail1-frag.c =================================================================== --- fail1-frag.c (nonexistent) +++ fail1-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +volatile int foo [10]; +foo[10] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail1-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail5-frag.c =================================================================== --- fail5-frag.c (nonexistent) +++ fail5-frag.c (revision 338) @@ -0,0 +1,14 @@ +#include +#include +#include +int main () +{ +char foo [15]; +char bar [10]; +memcpy(foo, bar, 11); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. bar.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail5-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail9-frag.c =================================================================== --- fail9-frag.c (nonexistent) +++ fail9-frag.c (revision 338) @@ -0,0 +1,21 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(foo); + +bar[4] = 'a'; /* touch source buffer */ +memcpy(foo, bar, 10); +return 0; +} + +/* { dg-output "mudflap violation 1.*memcpy dest.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*alloc time.*dealloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail9-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass12-frag.c =================================================================== --- pass12-frag.c (nonexistent) +++ pass12-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +int main () +{ +int i = 10; +int *x = (int *) malloc (i * sizeof (int)); + +while (--i) +{ + ++x; + *x = 0; +} +return 0; +}
pass12-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass22-frag.c =================================================================== --- pass22-frag.c (nonexistent) +++ pass22-frag.c (revision 338) @@ -0,0 +1,23 @@ +#include +#include +#include +int main () +{ +struct foo { + unsigned base:8; + unsigned flag1:1; + unsigned flag2:3; + unsigned flag3:4; + char nothing[0]; +}; + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) + +struct foo* f = (struct foo *) malloc (offsetof (struct foo, nothing)); +f->base = 1; +f->flag1 = 1; +free (f); + + +return 0; +}
pass22-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass32-frag.c =================================================================== --- pass32-frag.c (nonexistent) +++ pass32-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include + +struct foo { char z[10]; }; + +char * get_z (struct foo *this) +{ + return & this->z[0] /* the `this' pointer is not dereferenced! */; +} + +int main () +{ +struct foo k; +char *n = get_z (& k); +srand ((int)(__mf_uintptr_t) n); /* use the pointer value */ +return 0; +}
pass32-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass42-frag.c =================================================================== --- pass42-frag.c (nonexistent) +++ pass42-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include + +void +foo () +{ + putc ('h', stdout); + putc ('i', stdout); + putc ('\n', stdout); +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +} +/* { dg-output "hi" } */
pass42-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass16-frag.c =================================================================== --- pass16-frag.c (nonexistent) +++ pass16-frag.c (revision 338) @@ -0,0 +1,22 @@ +#include +#include +#include +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct base *bp; + +bp = (struct base *) malloc (sizeof (struct derived)); + +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +}
pass16-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass52-frag.c =================================================================== --- pass52-frag.c (nonexistent) +++ pass52-frag.c (revision 338) @@ -0,0 +1,36 @@ +#include + + +void writestuff (FILE *f) +{ + fprintf (f, "hello world\n"); + fputc ('y', f); + putc ('e', f); +} + +void readstuff (FILE *f) +{ + int c, d; + char stuff[100], *s; + c = fgetc (f); + ungetc (c, f); + d = fgetc (f); + s = fgets (stuff, sizeof(stuff), f); +} + +int main () +{ + FILE *f; + writestuff (stdout); + writestuff (stderr); + f = fopen ("/dev/null", "w"); + writestuff (f); + fclose (f); + f = fopen ("/dev/zero", "r"); + readstuff (f); + f = freopen ("/dev/null", "w", f); + writestuff (f); + fclose (f); + + return 0; +}
pass52-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail12-frag.c =================================================================== --- fail12-frag.c (nonexistent) +++ fail12-frag.c (revision 338) @@ -0,0 +1,20 @@ +#include +#include +#include +int *y; +int main () +{ +int i = 10; +int *x = (int *) malloc (i * sizeof (int)); +y = x; +while (i--) +{ + ++x; + *x = 0; +} +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail12-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass26-frag.c =================================================================== --- pass26-frag.c (nonexistent) +++ pass26-frag.c (revision 338) @@ -0,0 +1,52 @@ +#include +#include +#include +int main () +{ +volatile int *p; + +__mf_set_options ("-wipe-stack -no-check-initialization"); + +{ + volatile int array [10]; + p = & array[0]; + + array[0] = 2; + array[9] = 5; + + /* Array[] should be wiped clean at this point. */ +} + +__mf_set_options ("-no-wipe-stack"); + +{ + volatile int array2[10]; + + /* hope that this is allocated on top of old array[] */ + if (p != & array2[0]) + exit (0); /* Test is not applicable. */ + + array2[5] = 6; + + /* Old values shouldn't still be around; the new one should. */ + if (p[0] == 2 || p[9] == 5 || p[5] != 6) + abort() ; + + /* array2[] should not be wiped at this point! */ +} + +{ + volatile int array3[10]; + + /* hope that this is allocated on top of old array[] and array2[]*/ + if (p != & array3[0]) + exit (0); /* Test is not applicable. */ + + array3[1] = 2; + + /* Check that old assignment is still around. */ + if (p[5] != 6 || p[1] != 2) + abort() ; +} +return 0; +}
pass26-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass62-frag.c =================================================================== --- pass62-frag.c (nonexistent) +++ pass62-frag.c (revision 338) @@ -0,0 +1,13 @@ +/* PR tree-optimization/34618 */ +/* { dg-do compile } */ +/* { dg-options "-O3 -fmudflap" } */ + +int a[16]; + +void +foo () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i; +}
pass62-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail22-frag.c =================================================================== --- fail22-frag.c (nonexistent) +++ fail22-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include +#include +int main () +{ +struct boo { int a; }; +int c; +struct boo *b = malloc (sizeof (struct boo)); +__mf_set_options ("-check-initialization"); +c = b->a; +(void) malloc (c); /* some dummy use of c */ +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*1r/0w.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail22-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass36-frag.c =================================================================== --- pass36-frag.c (nonexistent) +++ pass36-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +int main () +{ +char *k; +__mf_set_options ("-sigusr1-report -print-leaks"); +k = (char *) malloc (100); +raise (SIGUSR1); +free (k); +return 0; +} +/* { dg-output "Leaked object.*name=.malloc region.*objects: 1" } */
pass36-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail32-frag.c =================================================================== --- fail32-frag.c (nonexistent) +++ fail32-frag.c (revision 338) @@ -0,0 +1,16 @@ +void foo (int k) +{ + volatile int *b = & k; + b++; + *b = 5; +} + +int main () +{ + foo (5); + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*k" } */ +/* { dg-do run { xfail *-*-* } } */
fail32-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass46-frag.c =================================================================== --- pass46-frag.c (nonexistent) +++ pass46-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include + +int foo (int *u, int i) +{ + return u[i]; /* this dereference should not be instrumented */ +} + +int main () +{ + int *k = malloc (6); + int l = foo (k, 8); + int boo [8]; + int m = boo [l % 2 + 12]; /* should not be instrumented */ + return m & strlen (""); /* a fancy way of saying "0" */ +} +/* { dg-options "-fmudflap -fmudflapir -lmudflap -Wall" } */
pass46-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass56-frag.c =================================================================== --- pass56-frag.c (nonexistent) +++ pass56-frag.c (revision 338) @@ -0,0 +1,14 @@ +#include +#include + +int main () +{ + volatile int *k = (int *) malloc (sizeof (int)); + volatile int l; + if (k == NULL) abort (); + *k = 5; + free ((void *) k); + __mf_set_options ("-ignore-reads"); + l = *k; /* Should not trip, even though memory region just freed. */ + return 0; +}
pass56-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail16-frag.c =================================================================== --- fail16-frag.c (nonexistent) +++ fail16-frag.c (revision 338) @@ -0,0 +1,27 @@ +#include +#include +#include +void *p; +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct base *bp; + +bp = (struct base *) malloc (sizeof (struct base));; +p = bp; +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail16-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: hook-allocstuff.c =================================================================== --- hook-allocstuff.c (nonexistent) +++ hook-allocstuff.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include + +int main () +{ + char *foo = (char *) malloc (10); + strcpy (foo, "hello"); + foo = (char *) realloc (foo, 20); + printf ("%s", foo); + if (strcmp (foo, "hello")) + abort (); + free (foo); + printf (" world\n"); + return 0; +} +/* { dg-output "hello world" } */
hook-allocstuff.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail26-frag.c =================================================================== --- fail26-frag.c (nonexistent) +++ fail26-frag.c (revision 338) @@ -0,0 +1,24 @@ +#include +#include +#include +int main () +{ +char *foo; + +__mf_set_options ("-check-initialization"); +foo = (char *)malloc (1); + +/* These two operations each expand to a read-modify-write. + * Even though the end result is that every bit of foo[0] is + * eventually written to deterministically, the first read + * triggers an uninit error. Ideally, it shouldn't, so this + * should be treated more like a regular XFAIL. */ +foo[0] &= 0xfe; +foo[0] |= 0x01; + +return foo[0]; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*1r/0w.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail26-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail36-frag.c =================================================================== --- fail36-frag.c (nonexistent) +++ fail36-frag.c (revision 338) @@ -0,0 +1,23 @@ +#include + +struct k +{ + int p; + struct { + int m : 31; + } q; +}; + +int +main () +{ + volatile struct k *l = malloc (sizeof (int)); /* make it only big enough for k.p */ + /* Confirm that we instrument this nested construct + BIT_FIELD_REF(COMPONENT_REF(INDIRECT_REF)). */ + l->q.m = 5; + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail36-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass1-frag.c =================================================================== --- pass1-frag.c (nonexistent) +++ pass1-frag.c (revision 338) @@ -0,0 +1,9 @@ +#include +#include +#include +int main () +{ +int foo [10]; +foo[9] = 0; +return 0; +}
pass1-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass5-frag.c =================================================================== --- pass5-frag.c (nonexistent) +++ pass5-frag.c (revision 338) @@ -0,0 +1,11 @@ +#include +#include +#include +int main () +{ +char foo [10]; +char bar [10]; +bar[4] = 'k'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +}
pass5-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass9-frag.c =================================================================== --- pass9-frag.c (nonexistent) +++ pass9-frag.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(foo); +foo = (char *)malloc (10); +bar[3] = 'w'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +}
pass9-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail4-frag.c =================================================================== --- fail4-frag.c (nonexistent) +++ fail4-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +char foo [10]; +strcpy(foo, "1234567890"); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail4-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: cfrags.exp =================================================================== --- cfrags.exp (nonexistent) +++ cfrags.exp (revision 338) @@ -0,0 +1,21 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}] + +libmudflap-init c + +dg-init + +global srcdir +foreach flags $MUDFLAP_FLAGS { + foreach srcfile [lsort [glob -nocomplain \ + ${srcdir}/libmudflap.c/*frag.c \ + ${srcdir}/libmudflap.c/heap*.c \ + ${srcdir}/libmudflap.c/hook*.c \ + ${srcdir}/libmudflap.c/pass*.c]] { + set bsrc [file tail $srcfile] + setenv MUDFLAP_OPTIONS "-viol-segv" + dg-runtest $srcfile $flags "-fmudflap -lmudflap" + } +} + +dg-finish Index: fail8-frag.c =================================================================== --- fail8-frag.c (nonexistent) +++ fail8-frag.c (revision 338) @@ -0,0 +1,19 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(bar); + +memcpy(foo, bar, 10); +return 0; +} +/* { dg-output "mudflap violation 1.*memcpy source.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*alloc time.*dealloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail8-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: hook2-allocstuff.c =================================================================== --- hook2-allocstuff.c (nonexistent) +++ hook2-allocstuff.c (revision 338) @@ -0,0 +1,9 @@ +/* Generates recursive malloc call on i386-freebsd4.10 with -fmudflap. */ +#include + +int +main (void) +{ + char *p = malloc (1<<24); + return 0; +}
hook2-allocstuff.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass11-frag.c =================================================================== --- pass11-frag.c (nonexistent) +++ pass11-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +int main () +{ +int i = 10; +char *x = (char *) malloc (i * sizeof (char)); + +while (--i) +{ + ++x; + *x = 0; +} +return 0; +}
pass11-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: externs-1.c =================================================================== --- externs-1.c (nonexistent) +++ externs-1.c (revision 338) @@ -0,0 +1,16 @@ +typedef struct { char *name; } dummy; +extern dummy d[]; + +int +main (void) +{ + dummy *pd = d; + + while (pd->name) + { + printf ("%s\n", pd->name); + pd++; + } + + return 0; +}
externs-1.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass21-frag.c =================================================================== --- pass21-frag.c (nonexistent) +++ pass21-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +#ifndef __FreeBSD__ +#include +#endif +int main () +{ +char *boo, *foo; +boo = (char *) alloca (100); +boo[99] = 'a'; +foo = (char *) __builtin_alloca (200); +foo[44] = 'b'; +return 0; +}
pass21-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass51-frag.c =================================================================== --- pass51-frag.c (nonexistent) +++ pass51-frag.c (revision 338) @@ -0,0 +1,44 @@ +/* Test object-spanning accesses. This is most conveniently done with + mmap, thus the config.h specificity here. */ +#include "../config.h" + +#include +#include +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +int main () +{ +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#ifdef HAVE_MMAP + void *p; + unsigned pg = getpagesize (); + int rc; + + p = mmap (NULL, 4 * pg, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 1; + + memset (p, 0, 4*pg); + rc = munmap (p, pg); + if (rc < 0) return 1; + memset (p+pg, 0, 3*pg); + rc = munmap (p+pg, pg); + if (rc < 0) return 1; + memset (p+2*pg, 0, 2*pg); + rc = munmap (p+2*pg, pg); + if (rc < 0) return 1; + memset (p+3*pg, 0, pg); + rc = munmap (p+3*pg, pg); + if (rc < 0) return 1; +#endif + + return 0; +}
pass51-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass15-frag.c =================================================================== --- pass15-frag.c (nonexistent) +++ pass15-frag.c (revision 338) @@ -0,0 +1,23 @@ +#include +#include +#include +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +struct derived d; +struct base *bp; + +bp = (struct base *)&d; + +bp->basic = 10; +((struct derived *)bp)->extra = 'x'; +return 0; +}
pass15-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass25-frag.c =================================================================== --- pass25-frag.c (nonexistent) +++ pass25-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +int main () +{ +int *foo = malloc (10 * sizeof(int)); +int *bar = & foo[3]; +/* Watching occurs at the object granularity, which is in this case + the entire array. */ +__mf_watch (& foo[1], sizeof(foo[1])); +__mf_unwatch (& foo[6], sizeof(foo[6])); +*bar = 10; +free (foo); +return 0; +}
pass25-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail11-frag.c =================================================================== --- fail11-frag.c (nonexistent) +++ fail11-frag.c (revision 338) @@ -0,0 +1,20 @@ +#include +#include +#include +char *y; +int main () +{ +int i = 10; +char *x = (char *) malloc (i * sizeof (char)); +y = x; +while (i--) +{ + ++x; + *x = 0; +} +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail11-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass35-frag.c =================================================================== --- pass35-frag.c (nonexistent) +++ pass35-frag.c (revision 338) @@ -0,0 +1,14 @@ +#include +#include +#include + +extern char end []; /* Any old symbol we're sure will be defined. */ +/* { dg-warning "cannot track unknown size extern" "cannot track unknown size extern" { target *-*-* } 0 } */ + +int main () +{ +/* dummy register */ +__mf_register ((void *) end, 1, __MF_TYPE_GUESS, "end"); +char z = end[0]; +return z & 0; +}
pass35-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail21-frag.c =================================================================== --- fail21-frag.c (nonexistent) +++ fail21-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include +int main () +{ + int *bar = (int *) malloc (sizeof (int)); +/* Make an access here to get &foo into the lookup cache. */ +*bar = 5; +__mf_watch (bar, sizeof(int)); +/* This access should trigger the watch violation. */ +*bar = 10; +/* NOTREACHED */ +return 0; +} +/* { dg-output "mudflap violation 1.*watch.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail21-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass45-frag.c =================================================================== --- pass45-frag.c (nonexistent) +++ pass45-frag.c (revision 338) @@ -0,0 +1,31 @@ +#include +#include +#include + +extern void h (const char *p, const char *f); +int +main (void) +{ + h (0, "foo"); + return 0; +} + +void +h (const char *p, const char *f) +{ + size_t pl = p == NULL ? 0 : strlen (p); + size_t fl = strlen (f) + 1; + char a[pl + 1 + fl]; + char *cp = a; + char b[pl + 5 + fl * 2]; + char *cccp = b; + if (p != NULL) + { + cp = memcpy (cp, p, pl); + *cp++ = ':'; + } + memcpy (cp, f, fl); + strcpy (b, a); + puts (a); +} +/* { dg-output "foo" } */
pass45-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail31-frag.c =================================================================== --- fail31-frag.c (nonexistent) +++ fail31-frag.c (revision 338) @@ -0,0 +1,23 @@ +#include +#include + +extern int h (int i, int j); + +int main () +{ + int z = h (4, 10); + return 0; +} +int *p; +int h (int i, int j) +{ + int k[i]; + k[j] = i; + p = k; + return j; +} + +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*\(h\).*k" } */ +/* { dg-do run { xfail *-*-* } } */
fail31-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass19-frag.c =================================================================== --- pass19-frag.c (nonexistent) +++ pass19-frag.c (revision 338) @@ -0,0 +1,11 @@ +#include +#include +#include +int main () +{ +struct foo {int base; char variable[1]; }; /* a common idiom for variable-size structs */ + +struct foo * b = (struct foo *) malloc (sizeof (int)); /* enough for base */ +b->base = 4; +return 0; +}
pass19-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass29-frag.c =================================================================== --- pass29-frag.c (nonexistent) +++ pass29-frag.c (revision 338) @@ -0,0 +1,15 @@ +#include +#include +#include +int main () +{ +struct boo { int a; }; +int c; +struct boo *b = malloc (sizeof (struct boo)); +__mf_set_options ("-check-initialization"); +b->a = 0; +/* That __mf_set_options call could be here instead. */ +c = b->a; +(void) malloc (c); /* some dummy use of c */ +return 0; +}
pass29-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail15-frag.c =================================================================== --- fail15-frag.c (nonexistent) +++ fail15-frag.c (revision 338) @@ -0,0 +1,27 @@ +#include +#include +#include +int main () +{ +struct base { + int basic; +}; + +struct derived { + struct base common; + char extra; +}; + +volatile struct base b; +volatile struct base *bp; + +bp = (struct base *)&b; + +bp->basic = 10; +((struct derived volatile *)bp)->extra = 'x'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. b.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail15-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail25-frag.c =================================================================== --- fail25-frag.c (nonexistent) +++ fail25-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +__mf_set_options ("-check-initialization"); +foo = (char *)malloc (10); +bar = (char *)malloc (10); +/* bar[2] = 'z'; */ /* don't touch memcpy source */ +memcpy(foo+1, bar+1, 9); +return 0; +} +/* { dg-output "mudflap violation 1.*check.read.*memcpy source.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc time.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail25-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass49-frag.c =================================================================== --- pass49-frag.c (nonexistent) +++ pass49-frag.c (revision 338) @@ -0,0 +1,35 @@ +#include +#include +#include + +int foo (int a, ...) +{ + va_list args; + char *a1; + int a2; + int k; + + va_start (args, a); + for (k = 0; k < a; k++) + { + if ((k % 2) == 0) + { + char *b = va_arg (args, char *); + printf ("%s", b); + } + else + { + int b = va_arg (args, int); + printf ("%d", b); + } + } + va_end (args); + return a; +} + +int main () +{ + foo (7, "hello ", 5, " ", 3, " world ", 9, "\n"); + return 0; +} +/* { dg-output "hello 5 3 world 9" } */
pass49-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail35-frag.c =================================================================== --- fail35-frag.c (nonexistent) +++ fail35-frag.c (revision 338) @@ -0,0 +1,23 @@ +#include + +struct k +{ + int p; + struct { + int m; + } q; +}; + +int +main () +{ + volatile struct k *l = malloc (sizeof (int)); /* make it only big enough for k.p */ + /* Confirm that we instrument this nested construct + COMPONENT_REF(COMPONENT_REF(INDIRECT_REF)). */ + l->q.m = 5; + return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail35-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail19-frag.c =================================================================== --- fail19-frag.c (nonexistent) +++ fail19-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include +int main () +{ +struct foo { + int bar [10]; +}; + +struct foo *k = (struct foo *) malloc (2 * sizeof(int)); +k->bar[5] = 9; +free (k); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail19-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail29-frag.c =================================================================== --- fail29-frag.c (nonexistent) +++ fail29-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include + +int foo (int u[10]) +{ + return u[8]; /* this dereference should be instrumented */ +} + +int main () +{ +int *k = malloc (6); +return foo (k); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */
fail29-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail39-frag.c =================================================================== --- fail39-frag.c (nonexistent) +++ fail39-frag.c (revision 338) @@ -0,0 +1,20 @@ +#include +#include + +int main () +{ + volatile int *k = (int *) malloc (sizeof (int)); + volatile int l; + if (k == NULL) abort (); + *k = 5; + free ((void *) k); + __mf_set_options ("-ignore-reads"); + l = *k; /* Should not trip, even though memory region just freed. */ + __mf_set_options ("-no-ignore-reads"); + l = *k; /* Should trip now. */ + return 0; +} +/* { dg-output "mudflap violation 1.*check/read.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap dead object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail39-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass-stratcliff.c =================================================================== --- pass-stratcliff.c (nonexistent) +++ pass-stratcliff.c (revision 338) @@ -0,0 +1,319 @@ +/* Test for string function add boundaries of usable memory. + Copyright (C) 1996,1997,1999,2000,2001,2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +#define _GNU_SOURCE 1 +#define __USE_GNU + +/* Make sure we don't test the optimized inline functions if we want to + test the real implementation. */ +#undef __USE_STRING_INLINES + +#include +#include +#include +#include +#include +#include + +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + +int +main (int argc, char *argv[]) +{ + int size = sysconf (_SC_PAGESIZE); + char *adr, *dest; + int result = 0; + + adr = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + dest = (char *) mmap (NULL, 3 * size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); + if (adr == MAP_FAILED || dest == MAP_FAILED) + { + if (errno == ENOSYS) + puts ("No test, mmap not available."); + else + { + printf ("mmap failed: %m"); + result = 1; + } + } + else + { + int inner, middle, outer; + + mprotect(adr, size, PROT_NONE); + mprotect(adr + 2 * size, size, PROT_NONE); + adr += size; + + mprotect(dest, size, PROT_NONE); + mprotect(dest + 2 * size, size, PROT_NONE); + dest += size; + + memset (adr, 'T', size); + + /* strlen test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if (strlen (&adr[outer]) != (size_t) (inner - outer)) + { + printf ("strlen flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* strchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + for (inner = middle; inner < size; ++inner) + { + char *cp; + adr[middle] = 'V'; + adr[inner] = '\0'; + + cp = strchr (&adr[outer], 'V'); + + if ((inner == middle && cp != NULL) + || (inner != middle + && (cp - &adr[outer]) != middle - outer)) + { + printf ("strchr flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + + adr[inner] = 'T'; + adr[middle] = 'T'; + } + } + } + + /* Special test. */ + adr[size - 1] = '\0'; + if (strchr (&adr[size - 1], '\n') != NULL) + { + puts ("strchr flunked for test of empty string at end of page"); + result = 1; + } + + /* strrchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + for (inner = middle; inner < size; ++inner) + { + char *cp; + adr[middle] = 'V'; + adr[inner] = '\0'; + + cp = strrchr (&adr[outer], 'V'); + + if ((inner == middle && cp != NULL) + || (inner != middle + && (cp - &adr[outer]) != middle - outer)) + { + printf ("strrchr flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + + adr[inner] = 'T'; + adr[middle] = 'T'; + } + } + } + +#ifndef __FreeBSD__ + /* rawmemchr test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + char *cp; + adr[middle] = 'V'; + + cp = (char *) rawmemchr (&adr[outer], 'V'); + + if (cp - &adr[outer] != middle - outer) + { + printf ("rawmemchr flunked for outer = %d, middle = %d\n", + outer, middle); + result = 1; + } + + adr[middle] = 'T'; + } + } +#endif + + /* strcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if (strcpy (dest, &adr[outer]) != dest + || strlen (dest) != (size_t) (inner - outer)) + { + printf ("strcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* strncpy tests */ + adr[size-1] = 'T'; + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + size_t len; + + for (len = 0; len < size - outer; ++len) + { + if (strncpy (dest, &adr[outer], len) != dest + || memcmp (dest, &adr[outer], len) != 0) + { + printf ("outer strncpy flunked for outer = %d, len = %Zd\n", + outer, len); + result = 1; + } + } + } + adr[size-1] = '\0'; + + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + size_t len; + + adr[inner] = '\0'; + + for (len = 0; len < size - outer + 64; ++len) + { + if (strncpy (dest, &adr[outer], len) != dest + || memcmp (dest, &adr[outer], + MIN (inner - outer, len)) != 0 + || (inner - outer < len + && strlen (dest) != (inner - outer))) + { + printf ("strncpy flunked for outer = %d, inner = %d, len = %Zd\n", + outer, inner, len); + result = 1; + } + if (strncpy (dest + 1, &adr[outer], len) != dest + 1 + || memcmp (dest + 1, &adr[outer], + MIN (inner - outer, len)) != 0 + || (inner - outer < len + && strlen (dest + 1) != (inner - outer))) + { + printf ("strncpy+1 flunked for outer = %d, inner = %d, len = %Zd\n", + outer, inner, len); + result = 1; + } + } + + adr[inner] = 'T'; + } + } + +#ifndef __FreeBSD__ + /* stpcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (inner = MAX (outer, size - 64); inner < size; ++inner) + { + adr[inner] = '\0'; + + if ((stpcpy (dest, &adr[outer]) - dest) != inner - outer) + { + printf ("stpcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + + adr[inner] = 'T'; + } + } + + /* stpncpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + { + for (middle = MAX (outer, size - 64); middle < size; ++middle) + { + adr[middle] = '\0'; + + for (inner = 0; inner < size - outer; ++ inner) + { + if ((stpncpy (dest, &adr[outer], inner) - dest) + != MIN (inner, middle - outer)) + { + printf ("stpncpy flunked for outer = %d, middle = %d, " + "inner = %d\n", outer, middle, inner); + result = 1; + } + } + + adr[middle] = 'T'; + } + } +#endif + + /* memcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (inner = 0; inner < size - outer; ++inner) + if (memcpy (dest, &adr[outer], inner) != dest) + { + printf ("memcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } + +#ifndef __FreeBSD__ + /* mempcpy test */ + for (outer = size - 1; outer >= MAX (0, size - 128); --outer) + for (inner = 0; inner < size - outer; ++inner) + if (mempcpy (dest, &adr[outer], inner) != dest + inner) + { + printf ("mempcpy flunked for outer = %d, inner = %d\n", + outer, inner); + result = 1; + } +#endif + } + + return result; +}
pass-stratcliff.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass4-frag.c =================================================================== --- pass4-frag.c (nonexistent) +++ pass4-frag.c (revision 338) @@ -0,0 +1,9 @@ +#include +#include +#include +int main () +{ +char foo[10]; +strcpy (foo, "123456789"); +return 0; +}
pass4-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass8-frag.c =================================================================== --- pass8-frag.c (nonexistent) +++ pass8-frag.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); + +free(bar); +bar = (char *)malloc (10); +bar[6] = 'k'; /* touch memcpy source */ +memcpy(foo, bar, 10); +return 0; +}
pass8-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail3-frag.c =================================================================== --- fail3-frag.c (nonexistent) +++ fail3-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +volatile int foo [10][10][10]; +foo[9][10][0] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail3-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail7-frag.c =================================================================== --- fail7-frag.c (nonexistent) +++ fail7-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (12); +bar = (char *)malloc (10); + +memcpy(foo+1, bar+1, 10); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail7-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass10-frag.c =================================================================== --- pass10-frag.c (nonexistent) +++ pass10-frag.c (revision 338) @@ -0,0 +1,12 @@ +#include +#include +#include +int main () +{ +int foo[10]; +int sz = sizeof (int); + +char *bar = (char *)foo; +bar [sz * 9] = 0; +return 0; +}
pass10-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass20-frag.c =================================================================== --- pass20-frag.c (nonexistent) +++ pass20-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +struct bar {int stuff; int array[10]; }; + +struct bar *foo = (struct bar *) malloc (sizeof (struct bar)); +foo->array[5] = 4; +free (foo); + +return 0; +}
pass20-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass30-frag.c =================================================================== --- pass30-frag.c (nonexistent) +++ pass30-frag.c (revision 338) @@ -0,0 +1,12 @@ +#include +#include +#include + +char zoo [10]; + +int main () +{ +int i = strlen ("eight") + strlen ("one"); +zoo[i] = 'a'; +return 0; +}
pass30-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass14-frag.c =================================================================== --- pass14-frag.c (nonexistent) +++ pass14-frag.c (revision 338) @@ -0,0 +1,20 @@ +#include +#include +#include +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct a k; +struct a *p; + +p = &k; + +p->z = 'q'; + +return 0; +}
pass14-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass50-frag.c =================================================================== --- pass50-frag.c (nonexistent) +++ pass50-frag.c (revision 338) @@ -0,0 +1,29 @@ +#include + +struct a +{ + int a1[5]; + union + { + int b1[5]; + struct + { + int c1; + int c2; + } b2[4]; + } a2[8]; +}; + +int i1 = 5; +int i2 = 2; +int i3 = 6; +int i4 = 0; + +int +main () +{ + volatile struct a *k = calloc (1, sizeof (struct a)); + k->a2[i1].b1[i2] = k->a2[i3].b2[i4].c2; + free ((void *) k); + return 0; +}
pass50-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass24-frag.c =================================================================== --- pass24-frag.c (nonexistent) +++ pass24-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include +int main () +{ +struct foo { + int zoo; + int bar [10]; + float baz; +}; + +#define offsetof(S,F) ((size_t) & (((S *) 0)->F)) + +struct foo *k = (struct foo *) malloc (offsetof (struct foo, bar[4])); +k->bar[1] = 9; +free (k); +return 0; +}
pass24-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail10-frag.c =================================================================== --- fail10-frag.c (nonexistent) +++ fail10-frag.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include +#include +int main () +{ +volatile int foo[10]; +int sz = sizeof (int); + +volatile char *bar = (char *)foo; +bar [sz * 10] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail10-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail20-frag.c =================================================================== --- fail20-frag.c (nonexistent) +++ fail20-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +volatile char *p = (char *) 0; +*p = 5; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.NULL.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail20-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass34-frag.c =================================================================== --- pass34-frag.c (nonexistent) +++ pass34-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include + +void test (int *k) +{ + if (*k > 5) { *k --; } +} + +int z; + +int main () +{ +/* z is initialized, but not via a pointer, so not instrumented */ +z = rand (); +test (& z); +return 0; +}
pass34-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail30-frag.c =================================================================== --- fail30-frag.c (nonexistent) +++ fail30-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include + +int foo (int u) +{ + return u*u; +} + +int main () +{ +int *k = malloc(5); +int j = foo (k[8]); /* this call argument should be instrumented */ +return j; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */
fail30-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass44-frag.c =================================================================== --- pass44-frag.c (nonexistent) +++ pass44-frag.c (revision 338) @@ -0,0 +1,14 @@ +#include + +void +foo () +{ + return; /* accept value-less return statement */ +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +}
pass44-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass18-frag.c =================================================================== --- pass18-frag.c (nonexistent) +++ pass18-frag.c (revision 338) @@ -0,0 +1,27 @@ +#include +#include +#include +int main () +{ +int t; +char foo[3] = { 'b', 'c', 'd' }; +int bar[3] = {1, 2, 0}; +t = 1; + +/* These tests check expression evaluation rules, such as + ensuring that side-effect expression (++) get executed the + right number of times; that array lookup checks nest correctly. */ +foo[t++] = 'a'; +if (foo[0] != 'b' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort(); + +foo[bar[t--]] = 'e'; +if (foo[0] != 'e' || foo[1] != 'a' || foo[2] != 'd' || t != 1) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != 0) abort(); + +foo[bar[++t]--] = 'g'; +if (foo[0] != 'g' || foo[1] != 'a' || foo[2] != 'd' || t != 2) abort (); +if (bar[0] != 1 || bar[1] != 2 || bar[2] != -1) abort(); + +return 0; +}
pass18-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail40-frag.c =================================================================== --- fail40-frag.c (nonexistent) +++ fail40-frag.c (revision 338) @@ -0,0 +1,59 @@ +/* Test proper lookup-uncaching of large objects */ +#include "../config.h" + +#include +#include +#include +#include +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +int main () +{ +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif +#ifdef HAVE_MMAP + volatile unsigned char *p; + unsigned num = getpagesize (); + unsigned i; + int rc; + + /* Get a bit of usable address space. We really want an 2**N+1-sized object, + so the low/high addresses wrap when hashed into the lookup cache. So we + will manually unregister the entire mmap, then re-register a slice. */ + p = mmap (NULL, num, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (p == MAP_FAILED) + return 1; + /* Now unregister it, as if munmap was called. But don't actually munmap, so + we can write into the memory. */ + __mf_unregister ((void *) p, num, __MF_TYPE_HEAP_I); + + /* Now register it under a slightly inflated, 2**N+1 size. */ + __mf_register ((void *) p, num+1, __MF_TYPE_HEAP_I, "fake mmap registration"); + + /* Traverse array to ensure that entire lookup cache is made to point at it. */ + for (i=0; i
fail40-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass54-frag.c =================================================================== --- pass54-frag.c (nonexistent) +++ pass54-frag.c (revision 338) @@ -0,0 +1,34 @@ +struct k +{ + struct { + int b; + int c; + } a; +}; + +static struct k l; +static struct k m; + +void foo () +{ + /* This should not be instrumented. */ + l.a.b = 5; +} + +void bar () +{ + /* This should not be instrumented. */ + m.a.b = 5; +} + +int main () +{ + /* Force TREE_ADDRESSABLE on "l" only. */ + volatile int *k = & l.a.c; + *k = 8; + __mf_set_options ("-mode-violate"); + foo (); + bar (); + __mf_set_options ("-mode-check"); + return 0; +}
pass54-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail14-frag.c =================================================================== --- fail14-frag.c (nonexistent) +++ fail14-frag.c (revision 338) @@ -0,0 +1,29 @@ +#include +#include +#include +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct b { + int x; + int y; +}; + +volatile struct b k; +volatile struct a *p; + +p = (struct a*) &k; + +p->z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail14-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass64-frag.c =================================================================== --- pass64-frag.c (nonexistent) +++ pass64-frag.c (revision 338) @@ -0,0 +1,38 @@ +/* PR libmudflap/36397 */ +/* { dg-do run } */ +/* { dg-options "-O -fmudflap -fno-strict-aliasing -lmudflap" } */ + +struct A +{ + int a[2]; +}; + +long long int x; + +int __attribute__ ((noinline)) +baz (long long int *x) +{ + return *x; +} + +int __attribute__ ((noinline)) +foo (int i) +{ + if (i > 10) + return baz (&x); + return ((struct A *) &x)->a[i]; +} + +int +main (void) +{ + if (sizeof (long long) == 2 * sizeof (int) + && sizeof (long long) == sizeof (struct A)) + { + struct A a = { .a[0] = 10, .a[1] = 20 }; + __builtin_memcpy (&x, &a, sizeof (x)); + if (foo (0) != 10 || foo (1) != 20) + __builtin_abort (); + } + return 0; +}
pass64-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass38-frag.c =================================================================== --- pass38-frag.c (nonexistent) +++ pass38-frag.c (revision 338) @@ -0,0 +1,9 @@ +/* Test an odd construct for compilability. */ +static void *fwd; +void *bwd = &fwd; +static void *fwd = &bwd; + +int main () +{ + return 0; +}
pass38-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail34-frag.c =================================================================== --- fail34-frag.c (nonexistent) +++ fail34-frag.c (revision 338) @@ -0,0 +1,22 @@ +#include + +struct s +{ + int a1[4]; +}; + +struct s a, b; +int idx = 7; /* should pass to the next object */ + +int +main () +{ + int i, j=0; + int a_before_b = (& a < & b); + j = (a_before_b ? a.a1[idx] : b.a1[idx]); + return j; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*\[ab\]" } */ +/* { dg-do run { xfail *-*-* } } */
fail34-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass48-frag.c =================================================================== --- pass48-frag.c (nonexistent) +++ pass48-frag.c (revision 338) @@ -0,0 +1,11 @@ +void foo (int k) +{ + volatile int *b = & k; + *b = 5; +} + +int main () +{ + foo (5); + return 0; +}
pass48-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail18-frag.c =================================================================== --- fail18-frag.c (nonexistent) +++ fail18-frag.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include +#include +int main () +{ +/* One cannot redeclare __mf_lc_mask in proper C from instrumented + code, because of the way the instrumentation code emits its decls. */ +extern unsigned foo __asm__ ("__mf_lc_mask"); +unsigned * volatile bar = &foo; +*bar = 4; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.__mf_lc_mask.*no-access.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail18-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: externs.exp =================================================================== --- externs.exp (nonexistent) +++ externs.exp (revision 338) @@ -0,0 +1,43 @@ +global MUDFLAP_FLAGS +set MUDFLAP_FLAGS [list {} {-static} {-O2} {-O3}] + +libmudflap-init c +dg-init + +global srcdir subdir + +foreach flags $MUDFLAP_FLAGS { + set l1 [libmudflap_target_compile "$srcdir/$subdir/externs-1.c" "externs-1.o" object {additional_flags=-fmudflap}] + set test "externs-1 compilation ${flags}" + if [string match "*mudflap cannot track unknown size extern *d*" $l1] { pass $test } { fail $test } + + set l2 [libmudflap_target_compile "$srcdir/$subdir/externs-2.c" "externs-2.o" object {additional_flags=-fmudflap}] + set test "externs-2 compilation ${flags}" + if [string match "" $l2] { pass $test } { fail $test } + + set l3 [libmudflap_target_compile "externs-1.o externs-2.o" "externs-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}] + set test "externs-12 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + set l4 [libmudflap_target_compile "externs-2.o externs-1.o" "externs-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}] + set test "externs-21 linkage ${flags}" + if [string match "" $l3] { pass $test } { fail $test } + + setenv MUDFLAP_OPTIONS "-viol-segv" + + remote_spawn host "./externs-12.exe" + set l5 [remote_wait host 10] + set test "externs-12 execution ${flags}" + if {[lindex $l5 0] == 0} { pass $test } { fail $test } + + remote_spawn host "./externs-21.exe" + set l6 [remote_wait host 10] + set test "externs-21 execution ${flags}" + if {[lindex $l6 0] == 0} { pass $test } { fail $test } + + foreach f [glob -nocomplain "externs-*"] { + remote_file build delete $f + } +} + +dg-finish Index: fail28-frag.c =================================================================== --- fail28-frag.c (nonexistent) +++ fail28-frag.c (revision 338) @@ -0,0 +1,18 @@ +#include +#include +#include + +int foo (int *u, int i) +{ + return u[i]; /* this dereference should be instrumented */ +} + +int main () +{ +int *k = malloc (6); +return foo (k, 8); +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*malloc region.*alloc" } */ +/* { dg-do run { xfail *-*-* } } */
fail28-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail38-frag.c =================================================================== --- fail38-frag.c (nonexistent) +++ fail38-frag.c (revision 338) @@ -0,0 +1,29 @@ +#include +#include +#include +int main () +{ +struct a { + int x; + int y; + int z : 10; +}; + +struct b { + int x; + int y; +}; + +volatile struct b k; +volatile struct a *p; + +p = (struct a*) &k; + +p->z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail38-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: heap-scalestress.c =================================================================== --- heap-scalestress.c (nonexistent) +++ heap-scalestress.c (revision 338) @@ -0,0 +1,79 @@ +/* zz30 + * + * demonstrate a splay-tree depth problem +*/ + +#include +#include +#include + +#ifndef SCALE +#define SCALE 100000 +#endif + + +struct list +{ + struct list *next; +}; + + +int +main () +{ + struct list *head = NULL; + struct list *tail = NULL; + struct list *p; + long n; + int direction; + + for (direction = 0; direction < 2; direction++) + { + fprintf (stdout, "allocating\n"); + fflush (stdout); + + for (n = 0; n < SCALE; ++n) + { + p = malloc (sizeof *p); + if (NULL == p) + { + fprintf (stdout, "malloc failed\n"); + break; + } + if (direction == 0) + { /* add at tail */ + p->next = NULL; + if (NULL != tail) + tail->next = p; + else + head = p; + tail = p; + } + else + { /* add at head */ + p->next = head; + if (NULL == tail) + tail = p; + head = p; + } + } + + fprintf (stdout, "freeing\n"); + fflush (stdout); + + while (NULL != head) + { + p = head; + head = head->next; + free (p); + } + + } + + fprintf (stdout, "done\n"); + fflush (stdout); + + return (0); +} + +/* { dg-output "allocating.*freeing.*allocating.*freeing.*done" } */
heap-scalestress.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass3-frag.c =================================================================== --- pass3-frag.c (nonexistent) +++ pass3-frag.c (revision 338) @@ -0,0 +1,9 @@ +#include +#include +#include +int main () +{ +int foo [10][10][10]; +foo[9][9][0] = 0; +return 0; +}
pass3-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail2-frag.c =================================================================== --- fail2-frag.c (nonexistent) +++ fail2-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +volatile int foo [10][10]; +foo[10][0] = 0; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. foo.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail2-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass7-frag.c =================================================================== --- pass7-frag.c (nonexistent) +++ pass7-frag.c (revision 338) @@ -0,0 +1,13 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (10); +bar[2] = 'z'; /* touch memcpy source */ +memcpy(foo+1, bar+1, 9); +return 0; +}
pass7-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail6-frag.c =================================================================== --- fail6-frag.c (nonexistent) +++ fail6-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include +#include +int main () +{ +char *foo; +char *bar; +foo = (char *)malloc (10); +bar = (char *)malloc (15); + +memcpy(foo, bar, 11); +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*malloc region.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail6-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass13-frag.c =================================================================== --- pass13-frag.c (nonexistent) +++ pass13-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include +#include +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct a k; + +k.z = 'q'; + +return 0; +}
pass13-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: externs-2.c =================================================================== --- externs-2.c (nonexistent) +++ externs-2.c (revision 338) @@ -0,0 +1,2 @@ +typedef struct { char *name; } dummy; +dummy d[] = { {"a"}, {0} };
externs-2.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass23-frag.c =================================================================== --- pass23-frag.c (nonexistent) +++ pass23-frag.c (revision 338) @@ -0,0 +1,29 @@ +#include +#include +#include +int main () +{ +struct foo { + int part1: 8; + int nothing : 1; + int part2 : 5; + int lots_more_nothing : 3; + int some_padding; /* for 64-bit hosts */ + float some_more_nothing; + double yet_more_nothing; +}; + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) + +struct foo* q = (struct foo *) malloc (offsetof (struct foo, some_more_nothing)); +q->nothing = 1; /* touch q */ +/* The RHS of the following expression is meant to trigger a + fold-const.c mapping the expression to a BIT_FIELD_REF. It glues + together the accesses to the two non-neighbouring bitfields into a + single bigger boolean test. */ +q->lots_more_nothing = (q->part1 == 13 && q->part2 == 7); +free (q); + + +return 0; +}
pass23-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass33-frag.c =================================================================== --- pass33-frag.c (nonexistent) +++ pass33-frag.c (revision 338) @@ -0,0 +1,17 @@ +#include +#include +#include + +void test (int *k) +{ + if (*k > 5) { *k --; } +} + +int main () +{ +int z; +/* z is initialized, but not via a pointer, so not instrumented */ +z = rand (); +test (& z); +return 0; +}
pass33-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass43-frag.c =================================================================== --- pass43-frag.c (nonexistent) +++ pass43-frag.c (revision 338) @@ -0,0 +1,11 @@ +void +foo () +{ +} + +int +main (int argc, char *argv[]) +{ + foo (); + return 0; +}
pass43-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass17-frag.c =================================================================== --- pass17-frag.c (nonexistent) +++ pass17-frag.c (revision 338) @@ -0,0 +1,9 @@ +#include +#include +#include +int main () +{ + +strlen("123456789"); +return 0; +}
pass17-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass53-frag.c =================================================================== --- pass53-frag.c (nonexistent) +++ pass53-frag.c (revision 338) @@ -0,0 +1,41 @@ +int foo1 () +{ + union { int l; char c[sizeof (int)]; } k1; + char *m; + k1.l = 0; + /* This test variant triggers ADDR_EXPR of k explicitly in order to + ensure it's registered with the runtime. */ + m = k1.c; + k1.c [sizeof (int)-1] = m[sizeof (int)-2]; +} + +int foo2 () +{ + union { int l; char c[sizeof (int)]; } k2; + k2.l = 0; + /* Since this access is known-in-range, k need not be registered + with the runtime, but then this access better not be instrumented + either. */ + k2.c [sizeof (int)-1] ++; + return k2.l; +} + +int foo3idx = sizeof (int)-1; + +int foo3 () +{ + union { int l; char c[sizeof (int)]; } k3; + k3.l = 0; + /* NB this test uses foo3idx, an extern variable, to defeat mudflap + known-in-range-index optimizations. */ + k3.c [foo3idx] ++; + return k3.l; +} + +int main () +{ + foo1 (); + foo2 (); + foo3 (); + return 0; +}
pass53-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail13-frag.c =================================================================== --- fail13-frag.c (nonexistent) +++ fail13-frag.c (revision 338) @@ -0,0 +1,26 @@ +#include +#include +#include +int main () +{ +struct a { + int x; + int y; + char z; +}; + +struct b { + int x; + int y; +}; + +struct b k; + +(*((volatile struct a *) &k)).z = 'q'; + +return 0; +} +/* { dg-output "mudflap violation 1..check/write.*" } */ +/* { dg-output "Nearby object 1.*" } */ +/* { dg-output "mudflap object.*.main. k.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail13-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: pass63-frag.c =================================================================== --- pass63-frag.c (nonexistent) +++ pass63-frag.c (revision 338) @@ -0,0 +1,6 @@ +/* Check -Wno-mudflap flag */ +/* { dg-do compile } */ +/* { dg-options "-fmudflap -Wno-mudflap" } */ + +extern char x[]; +int main() { return x[3]; } /* { dg-bogus "mudflap cannot track" } */
pass63-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: fail23-frag.c =================================================================== --- fail23-frag.c (nonexistent) +++ fail23-frag.c (revision 338) @@ -0,0 +1,16 @@ +#include +#include +#include + +char zoo [10]; + +int main () +{ +int i = strlen ("012345") + strlen ("6789") + strlen ("01"); /* 11 */ +zoo[i] = 'a'; +return 0; +} +/* { dg-output "mudflap violation 1.*" } */ +/* { dg-output "Nearby object.*" } */ +/* { dg-output "mudflap object.*zoo.*static.*" } */ +/* { dg-do run { xfail *-*-* } } */
fail23-frag.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.