Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.base / branches.c
blobdf3b7c052beaea6d273e006d278fc95c736d34c5
1 /* Tests for single stepping through various branch conditions */
3 int noscramble(int a)
5 return a ;
8 int echo(int a)
9 { return noscramble(a) ; }
11 int equaltest(int a,int b)
12 { int retval ;
13 if (a == b)
14 retval = noscramble(1) ;
15 else retval = noscramble(0) ;
16 return retval ;
19 int neqtest(int a , int b)
20 { int retval ;
21 if (a != b)
22 retval = echo(1) ;
23 else retval = echo(2) ;
24 return retval ;
26 int zerotest(int a )
27 { int retval ;
28 a = echo(a) ;
29 if (a ==0)
30 retval = echo(1) ;
31 else
32 retval = echo(0) ;
33 retval = echo(retval) ;
34 return retval ;
37 int zerotest2(int a)
39 return (a==0) ;
42 int nonzerotest(int a)
44 int retval ;
45 if (a != 0)
46 retval = echo(0) ;
47 else retval = echo(1) ;
48 return retval ;
51 int whiletest(int a)
53 while (a > 0)
55 a-- ;
57 return 0 ;
59 int whiletest2(int a)
61 while (a > 0)
63 a = noscramble(a) ;
64 a-- ;
66 return a ;
69 int decr(int x) { return x - 1 ; }
71 int while3(int a)
73 int b = a ;
74 while (a == b)
76 a = echo(a) ;
77 b = decr(b) ;
79 return a ;
82 void done (int x) { }
84 int main()
86 int a,b,c,d ;
87 done(1) ;
88 a = echo(123456) ;
89 b = echo(123456) ;
90 c = echo(56789) ;
91 d = echo(0) ;
92 #if 1
93 equaltest(a,b) ;
94 done(7) ;
95 equaltest(a,c) ;
96 done(8) ;
97 whiletest(3) ; /* worked */
98 done(3) ;
99 while3(3) ;
100 done(6) ;
101 #endif
102 neqtest(a,b) ;
103 neqtest(a,b) ;
104 neqtest(a,c) ;
105 zerotest(d) ;
106 zerotest(a) ;
107 done(5) ;
108 nonzerotest(d) ;
109 done(4) ;
110 nonzerotest(a) ;
111 done(111) ;
112 return 1 ;