]>
Commit | Line | Data |
---|---|---|
d39594e9 | 1 | #include "qemu/osdep.h" |
33189d31 TS |
2 | #include <sys/ipc.h> |
3 | #include <sys/msg.h> | |
4 | #include <sys/sem.h> | |
5 | #include <sys/shm.h> | |
6 | #include <sys/select.h> | |
74d753ac | 7 | #include <sys/mount.h> |
608e5592 | 8 | #include <sched.h> |
33189d31 TS |
9 | #include "qemu.h" |
10 | ||
11 | int do_strace=0; | |
12 | ||
13 | struct syscallname { | |
14 | int nr; | |
7ccfb2eb BS |
15 | const char *name; |
16 | const char *format; | |
17 | void (*call)(const struct syscallname *, | |
c16f9ed3 FB |
18 | abi_long, abi_long, abi_long, |
19 | abi_long, abi_long, abi_long); | |
7ccfb2eb | 20 | void (*result)(const struct syscallname *, abi_long); |
33189d31 TS |
21 | }; |
22 | ||
74d753ac MW |
23 | #ifdef __GNUC__ |
24 | /* | |
25 | * It is possible that target doesn't have syscall that uses | |
26 | * following flags but we don't want the compiler to warn | |
27 | * us about them being unused. Same applies to utility print | |
28 | * functions. It is ok to keep them while not used. | |
29 | */ | |
30 | #define UNUSED __attribute__ ((unused)) | |
31 | #else | |
32 | #define UNUSED | |
33 | #endif | |
34 | ||
35 | /* | |
36 | * Structure used to translate flag values into strings. This is | |
37 | * similar that is in the actual strace tool. | |
38 | */ | |
39 | struct flags { | |
40 | abi_long f_value; /* flag */ | |
41 | const char *f_string; /* stringified flag */ | |
42 | }; | |
43 | ||
44 | /* common flags for all architectures */ | |
45 | #define FLAG_GENERIC(name) { name, #name } | |
46 | /* target specific flags (syscall_defs.h has TARGET_<flag>) */ | |
47 | #define FLAG_TARGET(name) { TARGET_ ## name, #name } | |
48 | /* end of flags array */ | |
49 | #define FLAG_END { 0, NULL } | |
50 | ||
51 | UNUSED static const char *get_comma(int); | |
52 | UNUSED static void print_pointer(abi_long, int); | |
53 | UNUSED static void print_flags(const struct flags *, abi_long, int); | |
54 | UNUSED static void print_at_dirfd(abi_long, int); | |
55 | UNUSED static void print_file_mode(abi_long, int); | |
56 | UNUSED static void print_open_flags(abi_long, int); | |
57 | UNUSED static void print_syscall_prologue(const struct syscallname *); | |
58 | UNUSED static void print_syscall_epilogue(const struct syscallname *); | |
59 | UNUSED static void print_string(abi_long, int); | |
60 | UNUSED static void print_raw_param(const char *, abi_long, int); | |
61 | UNUSED static void print_timeval(abi_ulong, int); | |
62 | UNUSED static void print_number(abi_long, int); | |
608e5592 | 63 | UNUSED static void print_signal(abi_ulong, int); |
74d753ac | 64 | |
33189d31 TS |
65 | /* |
66 | * Utility functions | |
67 | */ | |
68 | static void | |
69 | print_ipc_cmd(int cmd) | |
70 | { | |
71 | #define output_cmd(val) \ | |
72 | if( cmd == val ) { \ | |
73 | gemu_log(#val); \ | |
74 | return; \ | |
75 | } | |
76 | ||
77 | cmd &= 0xff; | |
78 | ||
79 | /* General IPC commands */ | |
80 | output_cmd( IPC_RMID ); | |
81 | output_cmd( IPC_SET ); | |
82 | output_cmd( IPC_STAT ); | |
83 | output_cmd( IPC_INFO ); | |
84 | /* msgctl() commands */ | |
85 | #ifdef __USER_MISC | |
86 | output_cmd( MSG_STAT ); | |
87 | output_cmd( MSG_INFO ); | |
88 | #endif | |
89 | /* shmctl() commands */ | |
90 | output_cmd( SHM_LOCK ); | |
91 | output_cmd( SHM_UNLOCK ); | |
92 | output_cmd( SHM_STAT ); | |
93 | output_cmd( SHM_INFO ); | |
94 | /* semctl() commands */ | |
95 | output_cmd( GETPID ); | |
96 | output_cmd( GETVAL ); | |
97 | output_cmd( GETALL ); | |
98 | output_cmd( GETNCNT ); | |
99 | output_cmd( GETZCNT ); | |
100 | output_cmd( SETVAL ); | |
101 | output_cmd( SETALL ); | |
102 | output_cmd( SEM_STAT ); | |
103 | output_cmd( SEM_INFO ); | |
104 | output_cmd( IPC_RMID ); | |
105 | output_cmd( IPC_RMID ); | |
106 | output_cmd( IPC_RMID ); | |
107 | output_cmd( IPC_RMID ); | |
108 | output_cmd( IPC_RMID ); | |
109 | output_cmd( IPC_RMID ); | |
110 | output_cmd( IPC_RMID ); | |
111 | output_cmd( IPC_RMID ); | |
112 | output_cmd( IPC_RMID ); | |
113 | ||
114 | /* Some value we don't recognize */ | |
115 | gemu_log("%d",cmd); | |
116 | } | |
117 | ||
608e5592 LV |
118 | static void |
119 | print_signal(abi_ulong arg, int last) | |
120 | { | |
121 | const char *signal_name = NULL; | |
122 | switch(arg) { | |
123 | case TARGET_SIGHUP: signal_name = "SIGHUP"; break; | |
124 | case TARGET_SIGINT: signal_name = "SIGINT"; break; | |
125 | case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; | |
126 | case TARGET_SIGILL: signal_name = "SIGILL"; break; | |
127 | case TARGET_SIGABRT: signal_name = "SIGABRT"; break; | |
128 | case TARGET_SIGFPE: signal_name = "SIGFPE"; break; | |
129 | case TARGET_SIGKILL: signal_name = "SIGKILL"; break; | |
130 | case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; | |
131 | case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; | |
132 | case TARGET_SIGALRM: signal_name = "SIGALRM"; break; | |
133 | case TARGET_SIGTERM: signal_name = "SIGTERM"; break; | |
134 | case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; | |
135 | case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; | |
136 | case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; | |
137 | case TARGET_SIGCONT: signal_name = "SIGCONT"; break; | |
138 | case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; | |
139 | case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; | |
140 | case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; | |
141 | } | |
142 | if (signal_name == NULL) { | |
abe20840 | 143 | print_raw_param("%ld", arg, last); |
608e5592 LV |
144 | return; |
145 | } | |
146 | gemu_log("%s%s", signal_name, get_comma(last)); | |
147 | } | |
148 | ||
c16f9ed3 | 149 | #ifdef TARGET_NR__newselect |
33189d31 | 150 | static void |
c16f9ed3 | 151 | print_fdset(int n, abi_ulong target_fds_addr) |
33189d31 TS |
152 | { |
153 | int i; | |
154 | ||
155 | gemu_log("["); | |
156 | if( target_fds_addr ) { | |
579a97f7 | 157 | abi_long *target_fds; |
33189d31 | 158 | |
579a97f7 FB |
159 | target_fds = lock_user(VERIFY_READ, |
160 | target_fds_addr, | |
161 | sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), | |
162 | 1); | |
163 | ||
164 | if (!target_fds) | |
33189d31 TS |
165 | return; |
166 | ||
33189d31 | 167 | for (i=n; i>=0; i--) { |
cbb21eed | 168 | if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) |
33189d31 TS |
169 | gemu_log("%d,", i ); |
170 | } | |
171 | unlock_user(target_fds, target_fds_addr, 0); | |
172 | } | |
173 | gemu_log("]"); | |
174 | } | |
c16f9ed3 | 175 | #endif |
33189d31 TS |
176 | |
177 | /* | |
178 | * Sysycall specific output functions | |
179 | */ | |
180 | ||
181 | /* select */ | |
c16f9ed3 | 182 | #ifdef TARGET_NR__newselect |
33189d31 TS |
183 | static long newselect_arg1 = 0; |
184 | static long newselect_arg2 = 0; | |
185 | static long newselect_arg3 = 0; | |
186 | static long newselect_arg4 = 0; | |
187 | static long newselect_arg5 = 0; | |
188 | ||
189 | static void | |
7ccfb2eb | 190 | print_newselect(const struct syscallname *name, |
c16f9ed3 FB |
191 | abi_long arg1, abi_long arg2, abi_long arg3, |
192 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 193 | { |
c16f9ed3 | 194 | gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); |
33189d31 TS |
195 | print_fdset(arg1, arg2); |
196 | gemu_log(","); | |
197 | print_fdset(arg1, arg3); | |
198 | gemu_log(","); | |
199 | print_fdset(arg1, arg4); | |
200 | gemu_log(","); | |
74d753ac | 201 | print_timeval(arg5, 1); |
33189d31 TS |
202 | gemu_log(")"); |
203 | ||
204 | /* save for use in the return output function below */ | |
205 | newselect_arg1=arg1; | |
206 | newselect_arg2=arg2; | |
207 | newselect_arg3=arg3; | |
208 | newselect_arg4=arg4; | |
209 | newselect_arg5=arg5; | |
210 | } | |
c16f9ed3 | 211 | #endif |
33189d31 | 212 | |
3e46b2ef | 213 | #ifdef TARGET_NR_semctl |
33189d31 | 214 | static void |
7ccfb2eb | 215 | print_semctl(const struct syscallname *name, |
c16f9ed3 FB |
216 | abi_long arg1, abi_long arg2, abi_long arg3, |
217 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 218 | { |
c16f9ed3 | 219 | gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2); |
33189d31 | 220 | print_ipc_cmd(arg3); |
c16f9ed3 | 221 | gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
33189d31 | 222 | } |
3e46b2ef | 223 | #endif |
33189d31 TS |
224 | |
225 | static void | |
7ccfb2eb | 226 | print_execve(const struct syscallname *name, |
c16f9ed3 FB |
227 | abi_long arg1, abi_long arg2, abi_long arg3, |
228 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 | 229 | { |
c16f9ed3 | 230 | abi_ulong arg_ptr_addr; |
33189d31 TS |
231 | char *s; |
232 | ||
579a97f7 | 233 | if (!(s = lock_user_string(arg1))) |
33189d31 | 234 | return; |
33189d31 TS |
235 | gemu_log("%s(\"%s\",{", name->name, s); |
236 | unlock_user(s, arg1, 0); | |
237 | ||
c16f9ed3 | 238 | for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { |
98448f58 | 239 | abi_ulong *arg_ptr, arg_addr; |
33189d31 | 240 | |
c16f9ed3 | 241 | arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); |
579a97f7 | 242 | if (!arg_ptr) |
33189d31 | 243 | return; |
cbb21eed | 244 | arg_addr = tswapal(*arg_ptr); |
33189d31 TS |
245 | unlock_user(arg_ptr, arg_ptr_addr, 0); |
246 | if (!arg_addr) | |
247 | break; | |
579a97f7 FB |
248 | if ((s = lock_user_string(arg_addr))) { |
249 | gemu_log("\"%s\",", s); | |
98448f58 | 250 | unlock_user(s, arg_addr, 0); |
579a97f7 | 251 | } |
33189d31 TS |
252 | } |
253 | ||
254 | gemu_log("NULL})"); | |
255 | } | |
256 | ||
c16f9ed3 | 257 | #ifdef TARGET_NR_ipc |
33189d31 | 258 | static void |
7ccfb2eb | 259 | print_ipc(const struct syscallname *name, |
c16f9ed3 FB |
260 | abi_long arg1, abi_long arg2, abi_long arg3, |
261 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
262 | { |
263 | switch(arg1) { | |
264 | case IPCOP_semctl: | |
7ccfb2eb BS |
265 | gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2); |
266 | print_ipc_cmd(arg3); | |
267 | gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); | |
33189d31 TS |
268 | break; |
269 | default: | |
c16f9ed3 | 270 | gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")", |
33189d31 TS |
271 | name->name, arg1, arg2, arg3, arg4); |
272 | } | |
273 | } | |
c16f9ed3 | 274 | #endif |
33189d31 TS |
275 | |
276 | /* | |
277 | * Variants for the return value output function | |
278 | */ | |
279 | ||
280 | static void | |
7ccfb2eb | 281 | print_syscall_ret_addr(const struct syscallname *name, abi_long ret) |
33189d31 | 282 | { |
7dcdaeaf | 283 | const char *errstr = NULL; |
962b289e | 284 | |
2a7e1245 PM |
285 | if (ret < 0) { |
286 | errstr = target_strerror(-ret); | |
962b289e | 287 | } |
2a7e1245 PM |
288 | if (errstr) { |
289 | gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); | |
33189d31 | 290 | } else { |
29fa23e7 | 291 | gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 TS |
292 | } |
293 | } | |
294 | ||
f3e3285d | 295 | #if 0 /* currently unused */ |
33189d31 | 296 | static void |
c16f9ed3 | 297 | print_syscall_ret_raw(struct syscallname *name, abi_long ret) |
33189d31 | 298 | { |
29fa23e7 | 299 | gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
33189d31 | 300 | } |
f3e3285d | 301 | #endif |
33189d31 | 302 | |
f3e3285d | 303 | #ifdef TARGET_NR__newselect |
33189d31 | 304 | static void |
7ccfb2eb | 305 | print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) |
33189d31 | 306 | { |
29fa23e7 | 307 | gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); |
33189d31 TS |
308 | print_fdset(newselect_arg1,newselect_arg2); |
309 | gemu_log(","); | |
310 | print_fdset(newselect_arg1,newselect_arg3); | |
311 | gemu_log(","); | |
312 | print_fdset(newselect_arg1,newselect_arg4); | |
313 | gemu_log(","); | |
74d753ac | 314 | print_timeval(newselect_arg5, 1); |
33189d31 TS |
315 | gemu_log(")\n"); |
316 | } | |
f3e3285d | 317 | #endif |
33189d31 | 318 | |
74d753ac MW |
319 | UNUSED static struct flags access_flags[] = { |
320 | FLAG_GENERIC(F_OK), | |
321 | FLAG_GENERIC(R_OK), | |
322 | FLAG_GENERIC(W_OK), | |
323 | FLAG_GENERIC(X_OK), | |
324 | FLAG_END, | |
325 | }; | |
326 | ||
327 | UNUSED static struct flags at_file_flags[] = { | |
328 | #ifdef AT_EACCESS | |
329 | FLAG_GENERIC(AT_EACCESS), | |
330 | #endif | |
331 | #ifdef AT_SYMLINK_NOFOLLOW | |
332 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), | |
333 | #endif | |
334 | FLAG_END, | |
335 | }; | |
336 | ||
337 | UNUSED static struct flags unlinkat_flags[] = { | |
338 | #ifdef AT_REMOVEDIR | |
339 | FLAG_GENERIC(AT_REMOVEDIR), | |
340 | #endif | |
341 | FLAG_END, | |
342 | }; | |
343 | ||
344 | UNUSED static struct flags mode_flags[] = { | |
345 | FLAG_GENERIC(S_IFSOCK), | |
346 | FLAG_GENERIC(S_IFLNK), | |
347 | FLAG_GENERIC(S_IFREG), | |
348 | FLAG_GENERIC(S_IFBLK), | |
349 | FLAG_GENERIC(S_IFDIR), | |
350 | FLAG_GENERIC(S_IFCHR), | |
351 | FLAG_GENERIC(S_IFIFO), | |
352 | FLAG_END, | |
353 | }; | |
354 | ||
355 | UNUSED static struct flags open_access_flags[] = { | |
356 | FLAG_TARGET(O_RDONLY), | |
357 | FLAG_TARGET(O_WRONLY), | |
358 | FLAG_TARGET(O_RDWR), | |
359 | FLAG_END, | |
360 | }; | |
361 | ||
362 | UNUSED static struct flags open_flags[] = { | |
363 | FLAG_TARGET(O_APPEND), | |
364 | FLAG_TARGET(O_CREAT), | |
365 | FLAG_TARGET(O_DIRECTORY), | |
366 | FLAG_TARGET(O_EXCL), | |
367 | FLAG_TARGET(O_LARGEFILE), | |
368 | FLAG_TARGET(O_NOCTTY), | |
369 | FLAG_TARGET(O_NOFOLLOW), | |
370 | FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ | |
afc8763f RH |
371 | FLAG_TARGET(O_DSYNC), |
372 | FLAG_TARGET(__O_SYNC), | |
74d753ac MW |
373 | FLAG_TARGET(O_TRUNC), |
374 | #ifdef O_DIRECT | |
375 | FLAG_TARGET(O_DIRECT), | |
afc8763f RH |
376 | #endif |
377 | #ifdef O_NOATIME | |
378 | FLAG_TARGET(O_NOATIME), | |
379 | #endif | |
380 | #ifdef O_CLOEXEC | |
381 | FLAG_TARGET(O_CLOEXEC), | |
382 | #endif | |
383 | #ifdef O_PATH | |
384 | FLAG_TARGET(O_PATH), | |
74d753ac MW |
385 | #endif |
386 | FLAG_END, | |
387 | }; | |
388 | ||
389 | UNUSED static struct flags mount_flags[] = { | |
390 | #ifdef MS_BIND | |
391 | FLAG_GENERIC(MS_BIND), | |
392 | #endif | |
393 | #ifdef MS_DIRSYNC | |
394 | FLAG_GENERIC(MS_DIRSYNC), | |
395 | #endif | |
396 | FLAG_GENERIC(MS_MANDLOCK), | |
397 | #ifdef MS_MOVE | |
398 | FLAG_GENERIC(MS_MOVE), | |
399 | #endif | |
400 | FLAG_GENERIC(MS_NOATIME), | |
401 | FLAG_GENERIC(MS_NODEV), | |
402 | FLAG_GENERIC(MS_NODIRATIME), | |
403 | FLAG_GENERIC(MS_NOEXEC), | |
404 | FLAG_GENERIC(MS_NOSUID), | |
405 | FLAG_GENERIC(MS_RDONLY), | |
406 | #ifdef MS_RELATIME | |
407 | FLAG_GENERIC(MS_RELATIME), | |
408 | #endif | |
409 | FLAG_GENERIC(MS_REMOUNT), | |
410 | FLAG_GENERIC(MS_SYNCHRONOUS), | |
411 | FLAG_END, | |
412 | }; | |
413 | ||
414 | UNUSED static struct flags umount2_flags[] = { | |
415 | #ifdef MNT_FORCE | |
416 | FLAG_GENERIC(MNT_FORCE), | |
417 | #endif | |
418 | #ifdef MNT_DETACH | |
419 | FLAG_GENERIC(MNT_DETACH), | |
420 | #endif | |
421 | #ifdef MNT_EXPIRE | |
422 | FLAG_GENERIC(MNT_EXPIRE), | |
423 | #endif | |
424 | FLAG_END, | |
425 | }; | |
426 | ||
427 | UNUSED static struct flags mmap_prot_flags[] = { | |
428 | FLAG_GENERIC(PROT_NONE), | |
429 | FLAG_GENERIC(PROT_EXEC), | |
430 | FLAG_GENERIC(PROT_READ), | |
431 | FLAG_GENERIC(PROT_WRITE), | |
9e0b74a4 PB |
432 | FLAG_TARGET(PROT_SEM), |
433 | FLAG_GENERIC(PROT_GROWSDOWN), | |
434 | FLAG_GENERIC(PROT_GROWSUP), | |
74d753ac MW |
435 | FLAG_END, |
436 | }; | |
437 | ||
438 | UNUSED static struct flags mmap_flags[] = { | |
439 | FLAG_TARGET(MAP_SHARED), | |
440 | FLAG_TARGET(MAP_PRIVATE), | |
441 | FLAG_TARGET(MAP_ANONYMOUS), | |
442 | FLAG_TARGET(MAP_DENYWRITE), | |
443 | FLAG_TARGET(MAP_FIXED), | |
444 | FLAG_TARGET(MAP_GROWSDOWN), | |
906c1b8e | 445 | FLAG_TARGET(MAP_EXECUTABLE), |
74d753ac MW |
446 | #ifdef MAP_LOCKED |
447 | FLAG_TARGET(MAP_LOCKED), | |
448 | #endif | |
449 | #ifdef MAP_NONBLOCK | |
450 | FLAG_TARGET(MAP_NONBLOCK), | |
451 | #endif | |
452 | FLAG_TARGET(MAP_NORESERVE), | |
453 | #ifdef MAP_POPULATE | |
454 | FLAG_TARGET(MAP_POPULATE), | |
906c1b8e MF |
455 | #endif |
456 | #ifdef TARGET_MAP_UNINITIALIZED | |
457 | FLAG_TARGET(MAP_UNINITIALIZED), | |
74d753ac MW |
458 | #endif |
459 | FLAG_END, | |
460 | }; | |
461 | ||
608e5592 LV |
462 | UNUSED static struct flags clone_flags[] = { |
463 | FLAG_GENERIC(CLONE_VM), | |
464 | FLAG_GENERIC(CLONE_FS), | |
465 | FLAG_GENERIC(CLONE_FILES), | |
466 | FLAG_GENERIC(CLONE_SIGHAND), | |
467 | FLAG_GENERIC(CLONE_PTRACE), | |
468 | FLAG_GENERIC(CLONE_VFORK), | |
469 | FLAG_GENERIC(CLONE_PARENT), | |
470 | FLAG_GENERIC(CLONE_THREAD), | |
471 | FLAG_GENERIC(CLONE_NEWNS), | |
472 | FLAG_GENERIC(CLONE_SYSVSEM), | |
473 | FLAG_GENERIC(CLONE_SETTLS), | |
474 | FLAG_GENERIC(CLONE_PARENT_SETTID), | |
475 | FLAG_GENERIC(CLONE_CHILD_CLEARTID), | |
476 | FLAG_GENERIC(CLONE_DETACHED), | |
477 | FLAG_GENERIC(CLONE_UNTRACED), | |
478 | FLAG_GENERIC(CLONE_CHILD_SETTID), | |
6f11f013 | 479 | #if defined(CLONE_NEWUTS) |
608e5592 | 480 | FLAG_GENERIC(CLONE_NEWUTS), |
6f11f013 SW |
481 | #endif |
482 | #if defined(CLONE_NEWIPC) | |
608e5592 | 483 | FLAG_GENERIC(CLONE_NEWIPC), |
6f11f013 SW |
484 | #endif |
485 | #if defined(CLONE_NEWUSER) | |
608e5592 | 486 | FLAG_GENERIC(CLONE_NEWUSER), |
6f11f013 SW |
487 | #endif |
488 | #if defined(CLONE_NEWPID) | |
608e5592 | 489 | FLAG_GENERIC(CLONE_NEWPID), |
6f11f013 SW |
490 | #endif |
491 | #if defined(CLONE_NEWNET) | |
608e5592 | 492 | FLAG_GENERIC(CLONE_NEWNET), |
6f11f013 SW |
493 | #endif |
494 | #if defined(CLONE_IO) | |
608e5592 | 495 | FLAG_GENERIC(CLONE_IO), |
6f11f013 | 496 | #endif |
608e5592 LV |
497 | FLAG_END, |
498 | }; | |
499 | ||
74d753ac MW |
500 | /* |
501 | * print_xxx utility functions. These are used to print syscall | |
502 | * parameters in certain format. All of these have parameter | |
503 | * named 'last'. This parameter is used to add comma to output | |
504 | * when last == 0. | |
505 | */ | |
506 | ||
507 | static const char * | |
508 | get_comma(int last) | |
509 | { | |
510 | return ((last) ? "" : ","); | |
511 | } | |
512 | ||
513 | static void | |
d2ee72a5 | 514 | print_flags(const struct flags *f, abi_long flags, int last) |
74d753ac MW |
515 | { |
516 | const char *sep = ""; | |
74d753ac MW |
517 | int n; |
518 | ||
74d753ac MW |
519 | if ((flags == 0) && (f->f_value == 0)) { |
520 | gemu_log("%s%s", f->f_string, get_comma(last)); | |
521 | return; | |
522 | } | |
523 | for (n = 0; f->f_string != NULL; f++) { | |
524 | if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { | |
525 | gemu_log("%s%s", sep, f->f_string); | |
526 | flags &= ~f->f_value; | |
527 | sep = "|"; | |
528 | n++; | |
529 | } | |
530 | } | |
531 | ||
532 | if (n > 0) { | |
533 | /* print rest of the flags as numeric */ | |
534 | if (flags != 0) { | |
d2ee72a5 | 535 | gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); |
74d753ac MW |
536 | } else { |
537 | gemu_log("%s", get_comma(last)); | |
538 | } | |
539 | } else { | |
540 | /* no string version of flags found, print them in hex then */ | |
d2ee72a5 | 541 | gemu_log("%#x%s", (unsigned int)flags, get_comma(last)); |
74d753ac MW |
542 | } |
543 | } | |
544 | ||
545 | static void | |
d2ee72a5 | 546 | print_at_dirfd(abi_long dirfd, int last) |
74d753ac | 547 | { |
74d753ac MW |
548 | #ifdef AT_FDCWD |
549 | if (dirfd == AT_FDCWD) { | |
550 | gemu_log("AT_FDCWD%s", get_comma(last)); | |
551 | return; | |
552 | } | |
553 | #endif | |
d2ee72a5 | 554 | gemu_log("%d%s", (int)dirfd, get_comma(last)); |
74d753ac MW |
555 | } |
556 | ||
557 | static void | |
d2ee72a5 | 558 | print_file_mode(abi_long mode, int last) |
74d753ac MW |
559 | { |
560 | const char *sep = ""; | |
561 | const struct flags *m; | |
74d753ac MW |
562 | |
563 | for (m = &mode_flags[0]; m->f_string != NULL; m++) { | |
564 | if ((m->f_value & mode) == m->f_value) { | |
565 | gemu_log("%s%s", m->f_string, sep); | |
566 | sep = "|"; | |
567 | mode &= ~m->f_value; | |
568 | break; | |
569 | } | |
570 | } | |
571 | ||
572 | mode &= ~S_IFMT; | |
573 | /* print rest of the mode as octal */ | |
574 | if (mode != 0) | |
d2ee72a5 | 575 | gemu_log("%s%#o", sep, (unsigned int)mode); |
74d753ac MW |
576 | |
577 | gemu_log("%s", get_comma(last)); | |
578 | } | |
579 | ||
580 | static void | |
d2ee72a5 | 581 | print_open_flags(abi_long flags, int last) |
74d753ac | 582 | { |
74d753ac MW |
583 | print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); |
584 | flags &= ~TARGET_O_ACCMODE; | |
585 | if (flags == 0) { | |
586 | gemu_log("%s", get_comma(last)); | |
587 | return; | |
588 | } | |
589 | gemu_log("|"); | |
590 | print_flags(open_flags, flags, last); | |
591 | } | |
592 | ||
593 | static void | |
594 | print_syscall_prologue(const struct syscallname *sc) | |
595 | { | |
596 | gemu_log("%s(", sc->name); | |
597 | } | |
598 | ||
599 | /*ARGSUSED*/ | |
600 | static void | |
601 | print_syscall_epilogue(const struct syscallname *sc) | |
602 | { | |
603 | (void)sc; | |
604 | gemu_log(")"); | |
605 | } | |
606 | ||
607 | static void | |
608 | print_string(abi_long addr, int last) | |
609 | { | |
610 | char *s; | |
611 | ||
612 | if ((s = lock_user_string(addr)) != NULL) { | |
613 | gemu_log("\"%s\"%s", s, get_comma(last)); | |
614 | unlock_user(s, addr, 0); | |
615 | } else { | |
616 | /* can't get string out of it, so print it as pointer */ | |
617 | print_pointer(addr, last); | |
618 | } | |
619 | } | |
620 | ||
621 | /* | |
622 | * Prints out raw parameter using given format. Caller needs | |
623 | * to do byte swapping if needed. | |
624 | */ | |
625 | static void | |
626 | print_raw_param(const char *fmt, abi_long param, int last) | |
627 | { | |
628 | char format[64]; | |
629 | ||
630 | (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); | |
631 | gemu_log(format, param); | |
632 | } | |
633 | ||
634 | static void | |
635 | print_pointer(abi_long p, int last) | |
636 | { | |
637 | if (p == 0) | |
638 | gemu_log("NULL%s", get_comma(last)); | |
639 | else | |
640 | gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); | |
641 | } | |
642 | ||
643 | /* | |
644 | * Reads 32-bit (int) number from guest address space from | |
645 | * address 'addr' and prints it. | |
646 | */ | |
647 | static void | |
648 | print_number(abi_long addr, int last) | |
649 | { | |
650 | if (addr == 0) { | |
651 | gemu_log("NULL%s", get_comma(last)); | |
652 | } else { | |
653 | int num; | |
654 | ||
655 | get_user_s32(num, addr); | |
656 | gemu_log("[%d]%s", num, get_comma(last)); | |
657 | } | |
658 | } | |
659 | ||
660 | static void | |
661 | print_timeval(abi_ulong tv_addr, int last) | |
662 | { | |
663 | if( tv_addr ) { | |
664 | struct target_timeval *tv; | |
665 | ||
666 | tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); | |
667 | if (!tv) | |
668 | return; | |
669 | gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", | |
910ee4e5 | 670 | tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); |
74d753ac MW |
671 | unlock_user(tv, tv_addr, 0); |
672 | } else | |
673 | gemu_log("NULL%s", get_comma(last)); | |
674 | } | |
675 | ||
676 | #undef UNUSED | |
677 | ||
678 | #ifdef TARGET_NR_accept | |
679 | static void | |
680 | print_accept(const struct syscallname *name, | |
681 | abi_long arg0, abi_long arg1, abi_long arg2, | |
682 | abi_long arg3, abi_long arg4, abi_long arg5) | |
683 | { | |
684 | print_syscall_prologue(name); | |
d2ee72a5 | 685 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
686 | print_pointer(arg1, 0); |
687 | print_number(arg2, 1); | |
688 | print_syscall_epilogue(name); | |
689 | } | |
690 | #endif | |
691 | ||
692 | #ifdef TARGET_NR_access | |
693 | static void | |
694 | print_access(const struct syscallname *name, | |
695 | abi_long arg0, abi_long arg1, abi_long arg2, | |
696 | abi_long arg3, abi_long arg4, abi_long arg5) | |
697 | { | |
698 | print_syscall_prologue(name); | |
699 | print_string(arg0, 0); | |
700 | print_flags(access_flags, arg1, 1); | |
701 | print_syscall_epilogue(name); | |
702 | } | |
703 | #endif | |
704 | ||
705 | #ifdef TARGET_NR_brk | |
706 | static void | |
707 | print_brk(const struct syscallname *name, | |
708 | abi_long arg0, abi_long arg1, abi_long arg2, | |
709 | abi_long arg3, abi_long arg4, abi_long arg5) | |
710 | { | |
711 | print_syscall_prologue(name); | |
712 | print_pointer(arg0, 1); | |
713 | print_syscall_epilogue(name); | |
714 | } | |
715 | #endif | |
716 | ||
717 | #ifdef TARGET_NR_chdir | |
718 | static void | |
719 | print_chdir(const struct syscallname *name, | |
720 | abi_long arg0, abi_long arg1, abi_long arg2, | |
721 | abi_long arg3, abi_long arg4, abi_long arg5) | |
722 | { | |
723 | print_syscall_prologue(name); | |
724 | print_string(arg0, 1); | |
725 | print_syscall_epilogue(name); | |
726 | } | |
727 | #endif | |
728 | ||
729 | #ifdef TARGET_NR_chmod | |
730 | static void | |
731 | print_chmod(const struct syscallname *name, | |
732 | abi_long arg0, abi_long arg1, abi_long arg2, | |
733 | abi_long arg3, abi_long arg4, abi_long arg5) | |
734 | { | |
735 | print_syscall_prologue(name); | |
736 | print_string(arg0, 0); | |
737 | print_file_mode(arg1, 1); | |
738 | print_syscall_epilogue(name); | |
739 | } | |
740 | #endif | |
741 | ||
608e5592 LV |
742 | #ifdef TARGET_NR_clone |
743 | static void | |
744 | print_clone(const struct syscallname *name, | |
745 | abi_long arg0, abi_long arg1, abi_long arg2, | |
746 | abi_long arg3, abi_long arg4, abi_long arg5) | |
747 | { | |
748 | print_syscall_prologue(name); | |
749 | #if defined(TARGET_M68K) | |
750 | print_flags(clone_flags, arg0, 0); | |
751 | print_raw_param("newsp=0x" TARGET_ABI_FMT_lx, arg1, 1); | |
752 | #elif defined(TARGET_SH4) || defined(TARGET_ALPHA) | |
753 | print_flags(clone_flags, arg0, 0); | |
754 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0); | |
755 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); | |
756 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 0); | |
757 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 1); | |
758 | #elif defined(TARGET_CRIS) | |
759 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg0, 0); | |
760 | print_flags(clone_flags, arg1, 0); | |
761 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); | |
762 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0); | |
763 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1); | |
764 | #else | |
765 | print_flags(clone_flags, arg0, 0); | |
766 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0); | |
767 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); | |
768 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0); | |
769 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1); | |
770 | #endif | |
771 | print_syscall_epilogue(name); | |
772 | } | |
773 | #endif | |
774 | ||
74d753ac MW |
775 | #ifdef TARGET_NR_creat |
776 | static void | |
777 | print_creat(const struct syscallname *name, | |
778 | abi_long arg0, abi_long arg1, abi_long arg2, | |
779 | abi_long arg3, abi_long arg4, abi_long arg5) | |
780 | { | |
781 | print_syscall_prologue(name); | |
782 | print_string(arg0, 0); | |
783 | print_file_mode(arg1, 1); | |
784 | print_syscall_epilogue(name); | |
785 | } | |
786 | #endif | |
787 | ||
788 | #ifdef TARGET_NR_execv | |
789 | static void | |
790 | print_execv(const struct syscallname *name, | |
791 | abi_long arg0, abi_long arg1, abi_long arg2, | |
792 | abi_long arg3, abi_long arg4, abi_long arg5) | |
793 | { | |
794 | print_syscall_prologue(name); | |
795 | print_string(arg0, 0); | |
d2ee72a5 | 796 | print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); |
74d753ac MW |
797 | print_syscall_epilogue(name); |
798 | } | |
799 | #endif | |
800 | ||
801 | #ifdef TARGET_NR_faccessat | |
802 | static void | |
803 | print_faccessat(const struct syscallname *name, | |
804 | abi_long arg0, abi_long arg1, abi_long arg2, | |
805 | abi_long arg3, abi_long arg4, abi_long arg5) | |
806 | { | |
807 | print_syscall_prologue(name); | |
808 | print_at_dirfd(arg0, 0); | |
809 | print_string(arg1, 0); | |
810 | print_flags(access_flags, arg2, 0); | |
811 | print_flags(at_file_flags, arg3, 1); | |
812 | print_syscall_epilogue(name); | |
813 | } | |
814 | #endif | |
815 | ||
816 | #ifdef TARGET_NR_fchmodat | |
817 | static void | |
818 | print_fchmodat(const struct syscallname *name, | |
819 | abi_long arg0, abi_long arg1, abi_long arg2, | |
820 | abi_long arg3, abi_long arg4, abi_long arg5) | |
821 | { | |
822 | print_syscall_prologue(name); | |
823 | print_at_dirfd(arg0, 0); | |
824 | print_string(arg1, 0); | |
825 | print_file_mode(arg2, 0); | |
826 | print_flags(at_file_flags, arg3, 1); | |
827 | print_syscall_epilogue(name); | |
828 | } | |
829 | #endif | |
830 | ||
831 | #ifdef TARGET_NR_fchownat | |
832 | static void | |
833 | print_fchownat(const struct syscallname *name, | |
834 | abi_long arg0, abi_long arg1, abi_long arg2, | |
835 | abi_long arg3, abi_long arg4, abi_long arg5) | |
836 | { | |
837 | print_syscall_prologue(name); | |
838 | print_at_dirfd(arg0, 0); | |
839 | print_string(arg1, 0); | |
d2ee72a5 LV |
840 | print_raw_param("%d", arg2, 0); |
841 | print_raw_param("%d", arg3, 0); | |
74d753ac MW |
842 | print_flags(at_file_flags, arg4, 1); |
843 | print_syscall_epilogue(name); | |
844 | } | |
845 | #endif | |
846 | ||
847 | #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) | |
848 | static void | |
849 | print_fcntl(const struct syscallname *name, | |
850 | abi_long arg0, abi_long arg1, abi_long arg2, | |
851 | abi_long arg3, abi_long arg4, abi_long arg5) | |
852 | { | |
853 | print_syscall_prologue(name); | |
d2ee72a5 | 854 | print_raw_param("%d", arg0, 0); |
d95ec14f LV |
855 | switch(arg1) { |
856 | case TARGET_F_DUPFD: | |
857 | gemu_log("F_DUPFD,"); | |
858 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
859 | break; | |
860 | case TARGET_F_GETFD: | |
861 | gemu_log("F_GETFD"); | |
862 | break; | |
863 | case TARGET_F_SETFD: | |
864 | gemu_log("F_SETFD,"); | |
865 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
866 | break; | |
867 | case TARGET_F_GETFL: | |
868 | gemu_log("F_GETFL"); | |
869 | break; | |
870 | case TARGET_F_SETFL: | |
871 | gemu_log("F_SETFL,"); | |
872 | print_open_flags(arg2, 1); | |
873 | break; | |
874 | case TARGET_F_GETLK: | |
875 | gemu_log("F_GETLK,"); | |
876 | print_pointer(arg2, 1); | |
877 | break; | |
878 | case TARGET_F_SETLK: | |
879 | gemu_log("F_SETLK,"); | |
880 | print_pointer(arg2, 1); | |
881 | break; | |
882 | case TARGET_F_SETLKW: | |
883 | gemu_log("F_SETLKW,"); | |
884 | print_pointer(arg2, 1); | |
885 | break; | |
886 | case TARGET_F_GETOWN: | |
887 | gemu_log("F_GETOWN"); | |
888 | break; | |
889 | case TARGET_F_SETOWN: | |
890 | gemu_log("F_SETOWN,"); | |
891 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
892 | break; | |
893 | case TARGET_F_GETSIG: | |
894 | gemu_log("F_GETSIG"); | |
895 | break; | |
896 | case TARGET_F_SETSIG: | |
897 | gemu_log("F_SETSIG,"); | |
898 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
899 | break; | |
900 | #if TARGET_ABI_BITS == 32 | |
901 | case TARGET_F_GETLK64: | |
902 | gemu_log("F_GETLK64,"); | |
903 | print_pointer(arg2, 1); | |
904 | break; | |
905 | case TARGET_F_SETLK64: | |
906 | gemu_log("F_SETLK64,"); | |
907 | print_pointer(arg2, 1); | |
908 | break; | |
909 | case TARGET_F_SETLKW64: | |
910 | gemu_log("F_SETLKW64,"); | |
911 | print_pointer(arg2, 1); | |
912 | break; | |
913 | #endif | |
914 | case TARGET_F_SETLEASE: | |
915 | gemu_log("F_SETLEASE,"); | |
916 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
917 | break; | |
918 | case TARGET_F_GETLEASE: | |
919 | gemu_log("F_GETLEASE"); | |
920 | break; | |
7e3b92ec PM |
921 | case TARGET_F_SETPIPE_SZ: |
922 | gemu_log("F_SETPIPE_SZ,"); | |
923 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
924 | break; | |
925 | case TARGET_F_GETPIPE_SZ: | |
926 | gemu_log("F_GETPIPE_SZ"); | |
927 | break; | |
d95ec14f LV |
928 | case TARGET_F_DUPFD_CLOEXEC: |
929 | gemu_log("F_DUPFD_CLOEXEC,"); | |
930 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); | |
931 | break; | |
932 | case TARGET_F_NOTIFY: | |
933 | gemu_log("F_NOTIFY,"); | |
934 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); | |
935 | break; | |
936 | default: | |
937 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); | |
938 | print_pointer(arg2, 1); | |
939 | break; | |
940 | } | |
74d753ac MW |
941 | print_syscall_epilogue(name); |
942 | } | |
943 | #define print_fcntl64 print_fcntl | |
944 | #endif | |
945 | ||
946 | ||
947 | #ifdef TARGET_NR_futimesat | |
948 | static void | |
949 | print_futimesat(const struct syscallname *name, | |
950 | abi_long arg0, abi_long arg1, abi_long arg2, | |
951 | abi_long arg3, abi_long arg4, abi_long arg5) | |
952 | { | |
953 | print_syscall_prologue(name); | |
954 | print_at_dirfd(arg0, 0); | |
955 | print_string(arg1, 0); | |
956 | print_timeval(arg2, 0); | |
957 | print_timeval(arg2 + sizeof (struct target_timeval), 1); | |
958 | print_syscall_epilogue(name); | |
959 | } | |
960 | #endif | |
961 | ||
962 | #ifdef TARGET_NR_link | |
963 | static void | |
964 | print_link(const struct syscallname *name, | |
965 | abi_long arg0, abi_long arg1, abi_long arg2, | |
966 | abi_long arg3, abi_long arg4, abi_long arg5) | |
967 | { | |
968 | print_syscall_prologue(name); | |
969 | print_string(arg0, 0); | |
970 | print_string(arg1, 1); | |
971 | print_syscall_epilogue(name); | |
972 | } | |
973 | #endif | |
974 | ||
975 | #ifdef TARGET_NR_linkat | |
976 | static void | |
977 | print_linkat(const struct syscallname *name, | |
978 | abi_long arg0, abi_long arg1, abi_long arg2, | |
979 | abi_long arg3, abi_long arg4, abi_long arg5) | |
980 | { | |
981 | print_syscall_prologue(name); | |
982 | print_at_dirfd(arg0, 0); | |
983 | print_string(arg1, 0); | |
984 | print_at_dirfd(arg2, 0); | |
985 | print_string(arg3, 0); | |
986 | print_flags(at_file_flags, arg4, 1); | |
987 | print_syscall_epilogue(name); | |
988 | } | |
989 | #endif | |
990 | ||
608e5592 LV |
991 | #ifdef TARGET_NR__llseek |
992 | static void | |
993 | print__llseek(const struct syscallname *name, | |
994 | abi_long arg0, abi_long arg1, abi_long arg2, | |
995 | abi_long arg3, abi_long arg4, abi_long arg5) | |
996 | { | |
997 | const char *whence = "UNKNOWN"; | |
998 | print_syscall_prologue(name); | |
999 | print_raw_param("%d", arg0, 0); | |
1000 | print_raw_param("%ld", arg1, 0); | |
1001 | print_raw_param("%ld", arg2, 0); | |
1002 | print_pointer(arg3, 0); | |
1003 | switch(arg4) { | |
1004 | case SEEK_SET: whence = "SEEK_SET"; break; | |
1005 | case SEEK_CUR: whence = "SEEK_CUR"; break; | |
1006 | case SEEK_END: whence = "SEEK_END"; break; | |
1007 | } | |
1008 | gemu_log("%s",whence); | |
1009 | print_syscall_epilogue(name); | |
1010 | } | |
1011 | #endif | |
1012 | ||
74d753ac MW |
1013 | #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ |
1014 | defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) | |
1015 | static void | |
1016 | print_stat(const struct syscallname *name, | |
1017 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1018 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1019 | { | |
1020 | print_syscall_prologue(name); | |
1021 | print_string(arg0, 0); | |
1022 | print_pointer(arg1, 1); | |
1023 | print_syscall_epilogue(name); | |
1024 | } | |
1025 | #define print_lstat print_stat | |
1026 | #define print_stat64 print_stat | |
1027 | #define print_lstat64 print_stat | |
1028 | #endif | |
1029 | ||
1030 | #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) | |
1031 | static void | |
1032 | print_fstat(const struct syscallname *name, | |
1033 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1034 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1035 | { | |
1036 | print_syscall_prologue(name); | |
d2ee72a5 | 1037 | print_raw_param("%d", arg0, 0); |
74d753ac MW |
1038 | print_pointer(arg1, 1); |
1039 | print_syscall_epilogue(name); | |
1040 | } | |
1041 | #define print_fstat64 print_fstat | |
1042 | #endif | |
1043 | ||
1044 | #ifdef TARGET_NR_mkdir | |
1045 | static void | |
1046 | print_mkdir(const struct syscallname *name, | |
1047 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1048 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1049 | { | |
1050 | print_syscall_prologue(name); | |
1051 | print_string(arg0, 0); | |
1052 | print_file_mode(arg1, 1); | |
1053 | print_syscall_epilogue(name); | |
1054 | } | |
1055 | #endif | |
1056 | ||
1057 | #ifdef TARGET_NR_mkdirat | |
1058 | static void | |
1059 | print_mkdirat(const struct syscallname *name, | |
1060 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1061 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1062 | { | |
1063 | print_syscall_prologue(name); | |
1064 | print_at_dirfd(arg0, 0); | |
1065 | print_string(arg1, 0); | |
1066 | print_file_mode(arg2, 1); | |
1067 | print_syscall_epilogue(name); | |
1068 | } | |
1069 | #endif | |
1070 | ||
4de596cb LV |
1071 | #ifdef TARGET_NR_rmdir |
1072 | static void | |
1073 | print_rmdir(const struct syscallname *name, | |
1074 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1075 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1076 | { | |
1077 | print_syscall_prologue(name); | |
1078 | print_string(arg0, 0); | |
1079 | print_syscall_epilogue(name); | |
1080 | } | |
1081 | #endif | |
1082 | ||
608e5592 LV |
1083 | #ifdef TARGET_NR_rt_sigaction |
1084 | static void | |
1085 | print_rt_sigaction(const struct syscallname *name, | |
1086 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1087 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1088 | { | |
1089 | print_syscall_prologue(name); | |
1090 | print_signal(arg0, 0); | |
1091 | print_pointer(arg1, 0); | |
1092 | print_pointer(arg2, 1); | |
1093 | print_syscall_epilogue(name); | |
1094 | } | |
1095 | #endif | |
1096 | ||
1097 | #ifdef TARGET_NR_rt_sigprocmask | |
1098 | static void | |
1099 | print_rt_sigprocmask(const struct syscallname *name, | |
1100 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1101 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1102 | { | |
1103 | const char *how = "UNKNOWN"; | |
1104 | print_syscall_prologue(name); | |
1105 | switch(arg0) { | |
1106 | case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; | |
1107 | case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; | |
1108 | case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; | |
1109 | } | |
1110 | gemu_log("%s,",how); | |
1111 | print_pointer(arg1, 0); | |
1112 | print_pointer(arg2, 1); | |
1113 | print_syscall_epilogue(name); | |
1114 | } | |
1115 | #endif | |
1116 | ||
74d753ac MW |
1117 | #ifdef TARGET_NR_mknod |
1118 | static void | |
1119 | print_mknod(const struct syscallname *name, | |
1120 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1121 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1122 | { | |
d2ee72a5 | 1123 | int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
1124 | |
1125 | print_syscall_prologue(name); | |
1126 | print_string(arg0, 0); | |
1127 | print_file_mode(arg1, (hasdev == 0)); | |
1128 | if (hasdev) { | |
d2ee72a5 LV |
1129 | print_raw_param("makedev(%d", major(arg2), 0); |
1130 | print_raw_param("%d)", minor(arg2), 1); | |
74d753ac MW |
1131 | } |
1132 | print_syscall_epilogue(name); | |
1133 | } | |
1134 | #endif | |
1135 | ||
1136 | #ifdef TARGET_NR_mknodat | |
1137 | static void | |
1138 | print_mknodat(const struct syscallname *name, | |
1139 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1140 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1141 | { | |
d2ee72a5 | 1142 | int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); |
74d753ac MW |
1143 | |
1144 | print_syscall_prologue(name); | |
1145 | print_at_dirfd(arg0, 0); | |
1146 | print_string(arg1, 0); | |
1147 | print_file_mode(arg2, (hasdev == 0)); | |
1148 | if (hasdev) { | |
d2ee72a5 LV |
1149 | print_raw_param("makedev(%d", major(arg3), 0); |
1150 | print_raw_param("%d)", minor(arg3), 1); | |
74d753ac MW |
1151 | } |
1152 | print_syscall_epilogue(name); | |
1153 | } | |
1154 | #endif | |
1155 | ||
1156 | #ifdef TARGET_NR_mq_open | |
1157 | static void | |
1158 | print_mq_open(const struct syscallname *name, | |
1159 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1160 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1161 | { | |
d2ee72a5 | 1162 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
1163 | |
1164 | print_syscall_prologue(name); | |
1165 | print_string(arg0, 0); | |
1166 | print_open_flags(arg1, (is_creat == 0)); | |
1167 | if (is_creat) { | |
1168 | print_file_mode(arg2, 0); | |
1169 | print_pointer(arg3, 1); | |
1170 | } | |
1171 | print_syscall_epilogue(name); | |
1172 | } | |
1173 | #endif | |
1174 | ||
1175 | #ifdef TARGET_NR_open | |
1176 | static void | |
1177 | print_open(const struct syscallname *name, | |
1178 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1179 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1180 | { | |
d2ee72a5 | 1181 | int is_creat = (arg1 & TARGET_O_CREAT); |
74d753ac MW |
1182 | |
1183 | print_syscall_prologue(name); | |
1184 | print_string(arg0, 0); | |
1185 | print_open_flags(arg1, (is_creat == 0)); | |
1186 | if (is_creat) | |
1187 | print_file_mode(arg2, 1); | |
1188 | print_syscall_epilogue(name); | |
1189 | } | |
1190 | #endif | |
1191 | ||
1192 | #ifdef TARGET_NR_openat | |
1193 | static void | |
1194 | print_openat(const struct syscallname *name, | |
1195 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1196 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1197 | { | |
d2ee72a5 | 1198 | int is_creat = (arg2 & TARGET_O_CREAT); |
74d753ac MW |
1199 | |
1200 | print_syscall_prologue(name); | |
1201 | print_at_dirfd(arg0, 0); | |
1202 | print_string(arg1, 0); | |
1203 | print_open_flags(arg2, (is_creat == 0)); | |
1204 | if (is_creat) | |
1205 | print_file_mode(arg3, 1); | |
1206 | print_syscall_epilogue(name); | |
1207 | } | |
1208 | #endif | |
1209 | ||
1210 | #ifdef TARGET_NR_mq_unlink | |
1211 | static void | |
1212 | print_mq_unlink(const struct syscallname *name, | |
1213 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1214 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1215 | { | |
1216 | print_syscall_prologue(name); | |
1217 | print_string(arg0, 1); | |
1218 | print_syscall_epilogue(name); | |
1219 | } | |
1220 | #endif | |
1221 | ||
1222 | #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) | |
1223 | static void | |
1224 | print_fstatat64(const struct syscallname *name, | |
1225 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1226 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1227 | { | |
1228 | print_syscall_prologue(name); | |
1229 | print_at_dirfd(arg0, 0); | |
1230 | print_string(arg1, 0); | |
1231 | print_pointer(arg2, 0); | |
1232 | print_flags(at_file_flags, arg3, 1); | |
1233 | print_syscall_epilogue(name); | |
1234 | } | |
1235 | #define print_newfstatat print_fstatat64 | |
1236 | #endif | |
1237 | ||
1238 | #ifdef TARGET_NR_readlink | |
1239 | static void | |
1240 | print_readlink(const struct syscallname *name, | |
1241 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1242 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1243 | { | |
1244 | print_syscall_prologue(name); | |
1245 | print_string(arg0, 0); | |
1246 | print_pointer(arg1, 0); | |
d2ee72a5 | 1247 | print_raw_param("%u", arg2, 1); |
74d753ac MW |
1248 | print_syscall_epilogue(name); |
1249 | } | |
1250 | #endif | |
1251 | ||
1252 | #ifdef TARGET_NR_readlinkat | |
1253 | static void | |
1254 | print_readlinkat(const struct syscallname *name, | |
1255 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1256 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1257 | { | |
1258 | print_syscall_prologue(name); | |
1259 | print_at_dirfd(arg0, 0); | |
1260 | print_string(arg1, 0); | |
1261 | print_pointer(arg2, 0); | |
d2ee72a5 | 1262 | print_raw_param("%u", arg3, 1); |
74d753ac MW |
1263 | print_syscall_epilogue(name); |
1264 | } | |
1265 | #endif | |
1266 | ||
1267 | #ifdef TARGET_NR_rename | |
1268 | static void | |
1269 | print_rename(const struct syscallname *name, | |
1270 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1271 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1272 | { | |
1273 | print_syscall_prologue(name); | |
1274 | print_string(arg0, 0); | |
1275 | print_string(arg1, 1); | |
1276 | print_syscall_epilogue(name); | |
1277 | } | |
1278 | #endif | |
1279 | ||
1280 | #ifdef TARGET_NR_renameat | |
1281 | static void | |
1282 | print_renameat(const struct syscallname *name, | |
1283 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1284 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1285 | { | |
1286 | print_syscall_prologue(name); | |
1287 | print_at_dirfd(arg0, 0); | |
1288 | print_string(arg1, 0); | |
1289 | print_at_dirfd(arg2, 0); | |
1290 | print_string(arg3, 1); | |
1291 | print_syscall_epilogue(name); | |
1292 | } | |
1293 | #endif | |
1294 | ||
1295 | #ifdef TARGET_NR_statfs | |
1296 | static void | |
1297 | print_statfs(const struct syscallname *name, | |
1298 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1299 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1300 | { | |
1301 | print_syscall_prologue(name); | |
1302 | print_string(arg0, 0); | |
1303 | print_pointer(arg1, 1); | |
1304 | print_syscall_epilogue(name); | |
1305 | } | |
1306 | #define print_statfs64 print_statfs | |
1307 | #endif | |
1308 | ||
1309 | #ifdef TARGET_NR_symlink | |
1310 | static void | |
1311 | print_symlink(const struct syscallname *name, | |
1312 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1313 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1314 | { | |
1315 | print_syscall_prologue(name); | |
1316 | print_string(arg0, 0); | |
1317 | print_string(arg1, 1); | |
1318 | print_syscall_epilogue(name); | |
1319 | } | |
1320 | #endif | |
1321 | ||
1322 | #ifdef TARGET_NR_symlinkat | |
1323 | static void | |
1324 | print_symlinkat(const struct syscallname *name, | |
1325 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1326 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1327 | { | |
1328 | print_syscall_prologue(name); | |
1329 | print_string(arg0, 0); | |
1330 | print_at_dirfd(arg1, 0); | |
1331 | print_string(arg2, 1); | |
1332 | print_syscall_epilogue(name); | |
1333 | } | |
1334 | #endif | |
1335 | ||
1336 | #ifdef TARGET_NR_mount | |
1337 | static void | |
1338 | print_mount(const struct syscallname *name, | |
1339 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1340 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1341 | { | |
1342 | print_syscall_prologue(name); | |
1343 | print_string(arg0, 0); | |
1344 | print_string(arg1, 0); | |
1345 | print_string(arg2, 0); | |
1346 | print_flags(mount_flags, arg3, 0); | |
1347 | print_pointer(arg4, 1); | |
1348 | print_syscall_epilogue(name); | |
1349 | } | |
1350 | #endif | |
1351 | ||
1352 | #ifdef TARGET_NR_umount | |
1353 | static void | |
1354 | print_umount(const struct syscallname *name, | |
1355 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1356 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1357 | { | |
1358 | print_syscall_prologue(name); | |
1359 | print_string(arg0, 1); | |
1360 | print_syscall_epilogue(name); | |
1361 | } | |
1362 | #endif | |
1363 | ||
1364 | #ifdef TARGET_NR_umount2 | |
1365 | static void | |
1366 | print_umount2(const struct syscallname *name, | |
1367 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1368 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1369 | { | |
1370 | print_syscall_prologue(name); | |
1371 | print_string(arg0, 0); | |
1372 | print_flags(umount2_flags, arg1, 1); | |
1373 | print_syscall_epilogue(name); | |
1374 | } | |
1375 | #endif | |
1376 | ||
1377 | #ifdef TARGET_NR_unlink | |
1378 | static void | |
1379 | print_unlink(const struct syscallname *name, | |
1380 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1381 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1382 | { | |
1383 | print_syscall_prologue(name); | |
1384 | print_string(arg0, 1); | |
1385 | print_syscall_epilogue(name); | |
1386 | } | |
1387 | #endif | |
1388 | ||
1389 | #ifdef TARGET_NR_unlinkat | |
1390 | static void | |
1391 | print_unlinkat(const struct syscallname *name, | |
1392 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1393 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1394 | { | |
1395 | print_syscall_prologue(name); | |
1396 | print_at_dirfd(arg0, 0); | |
1397 | print_string(arg1, 0); | |
1398 | print_flags(unlinkat_flags, arg2, 1); | |
1399 | print_syscall_epilogue(name); | |
1400 | } | |
1401 | #endif | |
1402 | ||
1403 | #ifdef TARGET_NR_utime | |
1404 | static void | |
1405 | print_utime(const struct syscallname *name, | |
1406 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1407 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1408 | { | |
1409 | print_syscall_prologue(name); | |
1410 | print_string(arg0, 0); | |
1411 | print_pointer(arg1, 1); | |
1412 | print_syscall_epilogue(name); | |
1413 | } | |
1414 | #endif | |
1415 | ||
1416 | #ifdef TARGET_NR_utimes | |
1417 | static void | |
1418 | print_utimes(const struct syscallname *name, | |
1419 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1420 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1421 | { | |
1422 | print_syscall_prologue(name); | |
1423 | print_string(arg0, 0); | |
1424 | print_pointer(arg1, 1); | |
1425 | print_syscall_epilogue(name); | |
1426 | } | |
1427 | #endif | |
1428 | ||
1429 | #ifdef TARGET_NR_utimensat | |
1430 | static void | |
1431 | print_utimensat(const struct syscallname *name, | |
1432 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1433 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1434 | { | |
1435 | print_syscall_prologue(name); | |
1436 | print_at_dirfd(arg0, 0); | |
1437 | print_string(arg1, 0); | |
1438 | print_pointer(arg2, 0); | |
1439 | print_flags(at_file_flags, arg3, 1); | |
1440 | print_syscall_epilogue(name); | |
1441 | } | |
1442 | #endif | |
1443 | ||
8d9016c0 | 1444 | #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) |
74d753ac MW |
1445 | static void |
1446 | print_mmap(const struct syscallname *name, | |
1447 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1448 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1449 | { | |
1450 | print_syscall_prologue(name); | |
1451 | print_pointer(arg0, 0); | |
d2ee72a5 | 1452 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
1453 | print_flags(mmap_prot_flags, arg2, 0); |
1454 | print_flags(mmap_flags, arg3, 0); | |
d2ee72a5 LV |
1455 | print_raw_param("%d", arg4, 0); |
1456 | print_raw_param("%#x", arg5, 1); | |
74d753ac MW |
1457 | print_syscall_epilogue(name); |
1458 | } | |
1459 | #define print_mmap2 print_mmap | |
1460 | #endif | |
1461 | ||
1462 | #ifdef TARGET_NR_mprotect | |
1463 | static void | |
1464 | print_mprotect(const struct syscallname *name, | |
1465 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1466 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1467 | { | |
1468 | print_syscall_prologue(name); | |
1469 | print_pointer(arg0, 0); | |
d2ee72a5 | 1470 | print_raw_param("%d", arg1, 0); |
74d753ac MW |
1471 | print_flags(mmap_prot_flags, arg2, 1); |
1472 | print_syscall_epilogue(name); | |
1473 | } | |
1474 | #endif | |
1475 | ||
1476 | #ifdef TARGET_NR_munmap | |
1477 | static void | |
1478 | print_munmap(const struct syscallname *name, | |
1479 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1480 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1481 | { | |
1482 | print_syscall_prologue(name); | |
1483 | print_pointer(arg0, 0); | |
d2ee72a5 | 1484 | print_raw_param("%d", arg1, 1); |
74d753ac MW |
1485 | print_syscall_epilogue(name); |
1486 | } | |
1487 | #endif | |
1488 | ||
1489 | #ifdef TARGET_NR_futex | |
1490 | static void print_futex_op(abi_long tflag, int last) | |
1491 | { | |
1492 | #define print_op(val) \ | |
1493 | if( cmd == val ) { \ | |
1494 | gemu_log(#val); \ | |
1495 | return; \ | |
1496 | } | |
1497 | ||
d2ee72a5 | 1498 | int cmd = (int)tflag; |
74d753ac | 1499 | #ifdef FUTEX_PRIVATE_FLAG |
5f2243f3 | 1500 | if (cmd & FUTEX_PRIVATE_FLAG) { |
74d753ac | 1501 | gemu_log("FUTEX_PRIVATE_FLAG|"); |
5f2243f3 PB |
1502 | cmd &= ~FUTEX_PRIVATE_FLAG; |
1503 | } | |
bfb669f3 JR |
1504 | #endif |
1505 | #ifdef FUTEX_CLOCK_REALTIME | |
1506 | if (cmd & FUTEX_CLOCK_REALTIME) { | |
1507 | gemu_log("FUTEX_CLOCK_REALTIME|"); | |
1508 | cmd &= ~FUTEX_CLOCK_REALTIME; | |
1509 | } | |
74d753ac MW |
1510 | #endif |
1511 | print_op(FUTEX_WAIT) | |
1512 | print_op(FUTEX_WAKE) | |
1513 | print_op(FUTEX_FD) | |
1514 | print_op(FUTEX_REQUEUE) | |
1515 | print_op(FUTEX_CMP_REQUEUE) | |
1516 | print_op(FUTEX_WAKE_OP) | |
1517 | print_op(FUTEX_LOCK_PI) | |
1518 | print_op(FUTEX_UNLOCK_PI) | |
1519 | print_op(FUTEX_TRYLOCK_PI) | |
1520 | #ifdef FUTEX_WAIT_BITSET | |
1521 | print_op(FUTEX_WAIT_BITSET) | |
1522 | #endif | |
1523 | #ifdef FUTEX_WAKE_BITSET | |
1524 | print_op(FUTEX_WAKE_BITSET) | |
1525 | #endif | |
1526 | /* unknown values */ | |
1527 | gemu_log("%d",cmd); | |
1528 | } | |
1529 | ||
1530 | static void | |
1531 | print_futex(const struct syscallname *name, | |
1532 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1533 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1534 | { | |
1535 | print_syscall_prologue(name); | |
1536 | print_pointer(arg0, 0); | |
1537 | print_futex_op(arg1, 0); | |
d2ee72a5 | 1538 | print_raw_param(",%d", arg2, 0); |
74d753ac MW |
1539 | print_pointer(arg3, 0); /* struct timespec */ |
1540 | print_pointer(arg4, 0); | |
d2ee72a5 | 1541 | print_raw_param("%d", arg4, 1); |
74d753ac MW |
1542 | print_syscall_epilogue(name); |
1543 | } | |
1544 | #endif | |
1545 | ||
608e5592 LV |
1546 | #ifdef TARGET_NR_kill |
1547 | static void | |
1548 | print_kill(const struct syscallname *name, | |
1549 | abi_long arg0, abi_long arg1, abi_long arg2, | |
1550 | abi_long arg3, abi_long arg4, abi_long arg5) | |
1551 | { | |
1552 | print_syscall_prologue(name); | |
1553 | print_raw_param("%d", arg0, 0); | |
1554 | print_signal(arg1, 1); | |
1555 | print_syscall_epilogue(name); | |
1556 | } | |
1557 | #endif | |
1558 | ||
33189d31 TS |
1559 | /* |
1560 | * An array of all of the syscalls we know about | |
1561 | */ | |
1562 | ||
7ccfb2eb | 1563 | static const struct syscallname scnames[] = { |
33189d31 TS |
1564 | #include "strace.list" |
1565 | }; | |
1566 | ||
b1503cda | 1567 | static int nsyscalls = ARRAY_SIZE(scnames); |
33189d31 TS |
1568 | |
1569 | /* | |
1570 | * The public interface to this module. | |
1571 | */ | |
1572 | void | |
1573 | print_syscall(int num, | |
c16f9ed3 FB |
1574 | abi_long arg1, abi_long arg2, abi_long arg3, |
1575 | abi_long arg4, abi_long arg5, abi_long arg6) | |
33189d31 TS |
1576 | { |
1577 | int i; | |
7ccfb2eb | 1578 | const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; |
33189d31 TS |
1579 | |
1580 | gemu_log("%d ", getpid() ); | |
1581 | ||
1582 | for(i=0;i<nsyscalls;i++) | |
1583 | if( scnames[i].nr == num ) { | |
1584 | if( scnames[i].call != NULL ) { | |
1585 | scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6); | |
1586 | } else { | |
6b23f777 FB |
1587 | /* XXX: this format system is broken because it uses |
1588 | host types and host pointers for strings */ | |
33189d31 TS |
1589 | if( scnames[i].format != NULL ) |
1590 | format = scnames[i].format; | |
1591 | gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6); | |
1592 | } | |
74c11e55 | 1593 | return; |
33189d31 | 1594 | } |
74c11e55 | 1595 | gemu_log("Unknown syscall %d\n", num); |
33189d31 TS |
1596 | } |
1597 | ||
1598 | ||
1599 | void | |
c16f9ed3 | 1600 | print_syscall_ret(int num, abi_long ret) |
33189d31 TS |
1601 | { |
1602 | int i; | |
7dcdaeaf | 1603 | const char *errstr = NULL; |
33189d31 TS |
1604 | |
1605 | for(i=0;i<nsyscalls;i++) | |
1606 | if( scnames[i].nr == num ) { | |
1607 | if( scnames[i].result != NULL ) { | |
1608 | scnames[i].result(&scnames[i],ret); | |
1609 | } else { | |
962b289e AG |
1610 | if (ret < 0) { |
1611 | errstr = target_strerror(-ret); | |
1612 | } | |
1613 | if (errstr) { | |
1614 | gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", | |
1615 | -ret, errstr); | |
33189d31 | 1616 | } else { |
c16f9ed3 | 1617 | gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); |
33189d31 TS |
1618 | } |
1619 | } | |
1620 | break; | |
1621 | } | |
1622 | } |