1 /* Ltrace Test : parameters.c.
2 Objectives : Verify that Ltrace can handle all the different
5 This file was written by Steve Fink <sphink@gmail.com>. */
9 #include <sys/syscall.h>
15 void func_intptr(int *i);
16 void func_intptr_ret(int *i);
17 int func_strlen(char*);
18 void func_strfixed(char*);
19 void func_ppp(int***);
20 void func_stringp(char**);
21 void func_short(short, short);
22 void func_ushort(unsigned short, unsigned short);
23 float func_float(float, float);
24 double func_double(double, double);
25 void func_arrayi(int*, int);
26 void func_arrayf(float*, int);
27 void func_struct(void*);
36 void func_enum(color_t);
37 void func_typedef(color_t);
39 void func_work(char *x);
40 void func_call(char *x, char *y, void (*cb)(char *));
43 call_func_work (char *x)
62 func_string("zero\0xxxxxxxxxxxxxx");
65 extern int func_arg0(char *);
78 s = (char*) malloc(100);
86 float f = func_float(3.4, -3.4);
87 double d = func_double(3.4, -3.4);
91 ai = (int*) calloc(sizeof(int), 8);
92 for (x = 0; x < 8; x++)
97 af = (float*) calloc(sizeof(float), 8);
98 for (x = 0; x < 8; x++)
108 struct { int a; int b; }* array;
109 struct { int a; int b; } seq[3];
116 x.array = malloc(800);
138 func_call(x, y, call_func_work);
150 struct S2 func_struct_2(int, struct S3 s3, double d);
151 func_struct_2(17, (struct S3){ "ABCDE", 0.25 }, 0.5);
159 struct S4 func_struct_large(struct S4 a, struct S4 b);
160 func_struct_large((struct S4){ 1, 2, 3, 4 }, (struct S4){ 5, 6, 7, 8 });
168 struct S5 func_struct_large2(struct S5 a, struct S5 b);
169 func_struct_large2((struct S5){ '0', '1', 3, 4 }, (struct S5){ '2', '3', 7, 8 });
177 struct S6 func_struct_large3(struct S6 a, struct S6 b);
178 func_struct_large3((struct S6){ 3, 4, '0', '1' }, (struct S6){ 7, 8 ,'2', '3' });
180 void func_many_args(int a, int b, long c, double d, char e, int f, float g,
181 char h, int i, double j, int k, double l, char m, int n,
182 short o, int p, char q, float r, float s, double t,
183 long u, float v, float w, float x, float y);
184 func_many_args(1, 2, 3, 4.0, '5', 6, 7.0,
185 '8', 9, 10.0, 11, 12.0, 'A', 14,
186 15, 16, 'B', 18.0, 19.0, 20.0,
187 21, 22.0, 23.0, 24.0, 25.0);
189 void func_printf(char *format, ...);
190 func_printf("sotnuh %d %ld %g %c\n", 5, 6L, 1.5, 'X');
191 func_printf("sotnuh1 %d %ld %hd\n", 5, 6L, (short)7);
192 func_printf("sotnuh2 %s %10s %10s\n", "a string", "a trimmed string", "short");
193 func_printf("many_args"
194 "%d %d %ld %g %c %d %g "
195 "%c %d %g %d %g %c %d "
196 "%hd %d %c %g %g %g "
198 1, 2, 3L, 4.0, '5', 6, 7.0,
199 '8', 9, 10.0, 11, 12.0, 'A', 14,
200 (short)15, 16, 'B', 18.0, 19.0, 20.0,
201 21L, 22.0, 23.0, 24.0, 25.0);
203 func_printf("sotnuh3 %*s\n", 4, "a trimmed string");
205 void func_sprintf(char *str, char *format, ...);
206 func_sprintf(NULL, "test %d %d %d %d\n", 1, 2, 3, 4);
208 void func_lens(int, long, short, long);
209 func_lens(22, 23, 24, 25);
211 int func_bool(int a, int b);
215 void func_hide(int a, int b, int c, int d, int e, int f, int g, int h);
216 func_hide(1, 2, 3, 4, 5, 6, 7, 8);
218 struct func_hide_struct {
219 int a; int b; int c; int d; int e; int f; int g; int h;
221 void func_hide_struct(struct func_hide_struct hs);
222 func_hide_struct((struct func_hide_struct){1, 2, 3, 4, 5, 6, 7, 8});
225 long *func_short_enums(short abs[]);
226 func_short_enums((short[]){ A, B, A, A });
228 long func_negative_enum(short a, unsigned short b, int c, unsigned d,
229 long e, unsigned long f);
230 func_negative_enum(-1, -1, -1, -1, -1, -1);
232 void func_charp_string(char *p);
233 func_charp_string("null-terminated string");
235 struct struct_empty {};
236 struct struct_empty func_struct_empty(struct struct_empty e);
237 func_struct_empty((struct struct_empty) {});
239 struct struct_size1 { char a; };
240 struct struct_size1 func_struct_size1(struct struct_size1 e);
241 func_struct_size1((struct struct_size1){ '5' });
243 struct struct_size2 { short a; };
244 struct struct_size2 func_struct_size2(struct struct_size2 e);
245 func_struct_size2((struct struct_size2){ 5 });
247 struct struct_size4 { int a; };
248 struct struct_size4 func_struct_size4(struct struct_size4 e);
249 func_struct_size4((struct struct_size4){ 5 });
251 struct struct_size8 { int a; int b; };
252 struct struct_size8 func_struct_size8(struct struct_size8 e);
253 func_struct_size8((struct struct_size8){ 5, 6 });