target-arm: Don't update base register on abort in Thumb T1 LDM
[qemu.git] / linux-user / strace.c
blob5d9bb085c7e1afa08325cc8392e1d0efe6fb716a
1 #include <stdio.h>
2 #include <errno.h>
3 #include <sys/ipc.h>
4 #include <sys/msg.h>
5 #include <sys/sem.h>
6 #include <sys/shm.h>
7 #include <sys/select.h>
8 #include <sys/types.h>
9 #include <sys/mount.h>
10 #include <sys/mman.h>
11 #include <unistd.h>
12 #include <sched.h>
13 #include "qemu.h"
15 int do_strace=0;
17 struct syscallname {
18 int nr;
19 const char *name;
20 const char *format;
21 void (*call)(const struct syscallname *,
22 abi_long, abi_long, abi_long,
23 abi_long, abi_long, abi_long);
24 void (*result)(const struct syscallname *, abi_long);
27 #ifdef __GNUC__
29 * It is possible that target doesn't have syscall that uses
30 * following flags but we don't want the compiler to warn
31 * us about them being unused. Same applies to utility print
32 * functions. It is ok to keep them while not used.
34 #define UNUSED __attribute__ ((unused))
35 #else
36 #define UNUSED
37 #endif
40 * Structure used to translate flag values into strings. This is
41 * similar that is in the actual strace tool.
43 struct flags {
44 abi_long f_value; /* flag */
45 const char *f_string; /* stringified flag */
48 /* common flags for all architectures */
49 #define FLAG_GENERIC(name) { name, #name }
50 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
51 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
52 /* end of flags array */
53 #define FLAG_END { 0, NULL }
55 UNUSED static const char *get_comma(int);
56 UNUSED static void print_pointer(abi_long, int);
57 UNUSED static void print_flags(const struct flags *, abi_long, int);
58 UNUSED static void print_at_dirfd(abi_long, int);
59 UNUSED static void print_file_mode(abi_long, int);
60 UNUSED static void print_open_flags(abi_long, int);
61 UNUSED static void print_syscall_prologue(const struct syscallname *);
62 UNUSED static void print_syscall_epilogue(const struct syscallname *);
63 UNUSED static void print_string(abi_long, int);
64 UNUSED static void print_raw_param(const char *, abi_long, int);
65 UNUSED static void print_timeval(abi_ulong, int);
66 UNUSED static void print_number(abi_long, int);
67 UNUSED static void print_signal(abi_ulong, int);
70 * Utility functions
72 static void
73 print_ipc_cmd(int cmd)
75 #define output_cmd(val) \
76 if( cmd == val ) { \
77 gemu_log(#val); \
78 return; \
81 cmd &= 0xff;
83 /* General IPC commands */
84 output_cmd( IPC_RMID );
85 output_cmd( IPC_SET );
86 output_cmd( IPC_STAT );
87 output_cmd( IPC_INFO );
88 /* msgctl() commands */
89 #ifdef __USER_MISC
90 output_cmd( MSG_STAT );
91 output_cmd( MSG_INFO );
92 #endif
93 /* shmctl() commands */
94 output_cmd( SHM_LOCK );
95 output_cmd( SHM_UNLOCK );
96 output_cmd( SHM_STAT );
97 output_cmd( SHM_INFO );
98 /* semctl() commands */
99 output_cmd( GETPID );
100 output_cmd( GETVAL );
101 output_cmd( GETALL );
102 output_cmd( GETNCNT );
103 output_cmd( GETZCNT );
104 output_cmd( SETVAL );
105 output_cmd( SETALL );
106 output_cmd( SEM_STAT );
107 output_cmd( SEM_INFO );
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 output_cmd( IPC_RMID );
114 output_cmd( IPC_RMID );
115 output_cmd( IPC_RMID );
116 output_cmd( IPC_RMID );
118 /* Some value we don't recognize */
119 gemu_log("%d",cmd);
122 static void
123 print_signal(abi_ulong arg, int last)
125 const char *signal_name = NULL;
126 switch(arg) {
127 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
128 case TARGET_SIGINT: signal_name = "SIGINT"; break;
129 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
130 case TARGET_SIGILL: signal_name = "SIGILL"; break;
131 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
132 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
133 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
134 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
135 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
136 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
137 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
138 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
139 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
140 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
141 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
142 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
143 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
144 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
146 if (signal_name == NULL) {
147 print_raw_param("%ld", arg, 1);
148 return;
150 gemu_log("%s%s", signal_name, get_comma(last));
153 #ifdef TARGET_NR__newselect
154 static void
155 print_fdset(int n, abi_ulong target_fds_addr)
157 int i;
159 gemu_log("[");
160 if( target_fds_addr ) {
161 abi_long *target_fds;
163 target_fds = lock_user(VERIFY_READ,
164 target_fds_addr,
165 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
168 if (!target_fds)
169 return;
171 for (i=n; i>=0; i--) {
172 if ((tswapl(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1)
173 gemu_log("%d,", i );
175 unlock_user(target_fds, target_fds_addr, 0);
177 gemu_log("]");
179 #endif
182 * Sysycall specific output functions
185 /* select */
186 #ifdef TARGET_NR__newselect
187 static long newselect_arg1 = 0;
188 static long newselect_arg2 = 0;
189 static long newselect_arg3 = 0;
190 static long newselect_arg4 = 0;
191 static long newselect_arg5 = 0;
193 static void
194 print_newselect(const struct syscallname *name,
195 abi_long arg1, abi_long arg2, abi_long arg3,
196 abi_long arg4, abi_long arg5, abi_long arg6)
198 gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1);
199 print_fdset(arg1, arg2);
200 gemu_log(",");
201 print_fdset(arg1, arg3);
202 gemu_log(",");
203 print_fdset(arg1, arg4);
204 gemu_log(",");
205 print_timeval(arg5, 1);
206 gemu_log(")");
208 /* save for use in the return output function below */
209 newselect_arg1=arg1;
210 newselect_arg2=arg2;
211 newselect_arg3=arg3;
212 newselect_arg4=arg4;
213 newselect_arg5=arg5;
215 #endif
217 #ifdef TARGET_NR_semctl
218 static void
219 print_semctl(const struct syscallname *name,
220 abi_long arg1, abi_long arg2, abi_long arg3,
221 abi_long arg4, abi_long arg5, abi_long arg6)
223 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2);
224 print_ipc_cmd(arg3);
225 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
227 #endif
229 static void
230 print_execve(const struct syscallname *name,
231 abi_long arg1, abi_long arg2, abi_long arg3,
232 abi_long arg4, abi_long arg5, abi_long arg6)
234 abi_ulong arg_ptr_addr;
235 char *s;
237 if (!(s = lock_user_string(arg1)))
238 return;
239 gemu_log("%s(\"%s\",{", name->name, s);
240 unlock_user(s, arg1, 0);
242 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
243 abi_ulong *arg_ptr, arg_addr;
245 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
246 if (!arg_ptr)
247 return;
248 arg_addr = tswapl(*arg_ptr);
249 unlock_user(arg_ptr, arg_ptr_addr, 0);
250 if (!arg_addr)
251 break;
252 if ((s = lock_user_string(arg_addr))) {
253 gemu_log("\"%s\",", s);
254 unlock_user(s, arg_addr, 0);
258 gemu_log("NULL})");
261 #ifdef TARGET_NR_ipc
262 static void
263 print_ipc(const struct syscallname *name,
264 abi_long arg1, abi_long arg2, abi_long arg3,
265 abi_long arg4, abi_long arg5, abi_long arg6)
267 switch(arg1) {
268 case IPCOP_semctl:
269 gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2);
270 print_ipc_cmd(arg3);
271 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
272 break;
273 default:
274 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")",
275 name->name, arg1, arg2, arg3, arg4);
278 #endif
281 * Variants for the return value output function
284 static void
285 print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
287 if( ret == -1 ) {
288 gemu_log(" = -1 errno=%d (%s)\n", errno, target_strerror(errno));
289 } else {
290 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
294 #if 0 /* currently unused */
295 static void
296 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
298 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
300 #endif
302 #ifdef TARGET_NR__newselect
303 static void
304 print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)
306 gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
307 print_fdset(newselect_arg1,newselect_arg2);
308 gemu_log(",");
309 print_fdset(newselect_arg1,newselect_arg3);
310 gemu_log(",");
311 print_fdset(newselect_arg1,newselect_arg4);
312 gemu_log(",");
313 print_timeval(newselect_arg5, 1);
314 gemu_log(")\n");
316 #endif
318 UNUSED static struct flags access_flags[] = {
319 FLAG_GENERIC(F_OK),
320 FLAG_GENERIC(R_OK),
321 FLAG_GENERIC(W_OK),
322 FLAG_GENERIC(X_OK),
323 FLAG_END,
326 UNUSED static struct flags at_file_flags[] = {
327 #ifdef AT_EACCESS
328 FLAG_GENERIC(AT_EACCESS),
329 #endif
330 #ifdef AT_SYMLINK_NOFOLLOW
331 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
332 #endif
333 FLAG_END,
336 UNUSED static struct flags unlinkat_flags[] = {
337 #ifdef AT_REMOVEDIR
338 FLAG_GENERIC(AT_REMOVEDIR),
339 #endif
340 FLAG_END,
343 UNUSED static struct flags mode_flags[] = {
344 FLAG_GENERIC(S_IFSOCK),
345 FLAG_GENERIC(S_IFLNK),
346 FLAG_GENERIC(S_IFREG),
347 FLAG_GENERIC(S_IFBLK),
348 FLAG_GENERIC(S_IFDIR),
349 FLAG_GENERIC(S_IFCHR),
350 FLAG_GENERIC(S_IFIFO),
351 FLAG_END,
354 UNUSED static struct flags open_access_flags[] = {
355 FLAG_TARGET(O_RDONLY),
356 FLAG_TARGET(O_WRONLY),
357 FLAG_TARGET(O_RDWR),
358 FLAG_END,
361 UNUSED static struct flags open_flags[] = {
362 FLAG_TARGET(O_APPEND),
363 FLAG_TARGET(O_CREAT),
364 FLAG_TARGET(O_DIRECTORY),
365 FLAG_TARGET(O_EXCL),
366 FLAG_TARGET(O_LARGEFILE),
367 FLAG_TARGET(O_NOCTTY),
368 FLAG_TARGET(O_NOFOLLOW),
369 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
370 FLAG_TARGET(O_SYNC),
371 FLAG_TARGET(O_TRUNC),
372 #ifdef O_DIRECT
373 FLAG_TARGET(O_DIRECT),
374 #endif
375 FLAG_END,
378 UNUSED static struct flags mount_flags[] = {
379 #ifdef MS_BIND
380 FLAG_GENERIC(MS_BIND),
381 #endif
382 #ifdef MS_DIRSYNC
383 FLAG_GENERIC(MS_DIRSYNC),
384 #endif
385 FLAG_GENERIC(MS_MANDLOCK),
386 #ifdef MS_MOVE
387 FLAG_GENERIC(MS_MOVE),
388 #endif
389 FLAG_GENERIC(MS_NOATIME),
390 FLAG_GENERIC(MS_NODEV),
391 FLAG_GENERIC(MS_NODIRATIME),
392 FLAG_GENERIC(MS_NOEXEC),
393 FLAG_GENERIC(MS_NOSUID),
394 FLAG_GENERIC(MS_RDONLY),
395 #ifdef MS_RELATIME
396 FLAG_GENERIC(MS_RELATIME),
397 #endif
398 FLAG_GENERIC(MS_REMOUNT),
399 FLAG_GENERIC(MS_SYNCHRONOUS),
400 FLAG_END,
403 UNUSED static struct flags umount2_flags[] = {
404 #ifdef MNT_FORCE
405 FLAG_GENERIC(MNT_FORCE),
406 #endif
407 #ifdef MNT_DETACH
408 FLAG_GENERIC(MNT_DETACH),
409 #endif
410 #ifdef MNT_EXPIRE
411 FLAG_GENERIC(MNT_EXPIRE),
412 #endif
413 FLAG_END,
416 UNUSED static struct flags mmap_prot_flags[] = {
417 FLAG_GENERIC(PROT_NONE),
418 FLAG_GENERIC(PROT_EXEC),
419 FLAG_GENERIC(PROT_READ),
420 FLAG_GENERIC(PROT_WRITE),
421 FLAG_TARGET(PROT_SEM),
422 FLAG_GENERIC(PROT_GROWSDOWN),
423 FLAG_GENERIC(PROT_GROWSUP),
424 FLAG_END,
427 UNUSED static struct flags mmap_flags[] = {
428 FLAG_TARGET(MAP_SHARED),
429 FLAG_TARGET(MAP_PRIVATE),
430 FLAG_TARGET(MAP_ANONYMOUS),
431 FLAG_TARGET(MAP_DENYWRITE),
432 FLAG_TARGET(MAP_FIXED),
433 FLAG_TARGET(MAP_GROWSDOWN),
434 FLAG_TARGET(MAP_EXECUTABLE),
435 #ifdef MAP_LOCKED
436 FLAG_TARGET(MAP_LOCKED),
437 #endif
438 #ifdef MAP_NONBLOCK
439 FLAG_TARGET(MAP_NONBLOCK),
440 #endif
441 FLAG_TARGET(MAP_NORESERVE),
442 #ifdef MAP_POPULATE
443 FLAG_TARGET(MAP_POPULATE),
444 #endif
445 #ifdef TARGET_MAP_UNINITIALIZED
446 FLAG_TARGET(MAP_UNINITIALIZED),
447 #endif
448 FLAG_END,
451 UNUSED static struct flags fcntl_flags[] = {
452 FLAG_TARGET(F_DUPFD),
453 FLAG_TARGET(F_GETFD),
454 FLAG_TARGET(F_SETFD),
455 FLAG_TARGET(F_GETFL),
456 FLAG_TARGET(F_SETFL),
457 FLAG_TARGET(F_GETLK),
458 FLAG_TARGET(F_SETLK),
459 FLAG_TARGET(F_SETLKW),
460 FLAG_END,
463 UNUSED static struct flags clone_flags[] = {
464 FLAG_GENERIC(CLONE_VM),
465 FLAG_GENERIC(CLONE_FS),
466 FLAG_GENERIC(CLONE_FILES),
467 FLAG_GENERIC(CLONE_SIGHAND),
468 FLAG_GENERIC(CLONE_PTRACE),
469 FLAG_GENERIC(CLONE_VFORK),
470 FLAG_GENERIC(CLONE_PARENT),
471 FLAG_GENERIC(CLONE_THREAD),
472 FLAG_GENERIC(CLONE_NEWNS),
473 FLAG_GENERIC(CLONE_SYSVSEM),
474 FLAG_GENERIC(CLONE_SETTLS),
475 FLAG_GENERIC(CLONE_PARENT_SETTID),
476 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
477 FLAG_GENERIC(CLONE_DETACHED),
478 FLAG_GENERIC(CLONE_UNTRACED),
479 FLAG_GENERIC(CLONE_CHILD_SETTID),
480 FLAG_GENERIC(CLONE_NEWUTS),
481 FLAG_GENERIC(CLONE_NEWIPC),
482 FLAG_GENERIC(CLONE_NEWUSER),
483 FLAG_GENERIC(CLONE_NEWPID),
484 FLAG_GENERIC(CLONE_NEWNET),
485 FLAG_GENERIC(CLONE_IO),
486 FLAG_END,
490 * print_xxx utility functions. These are used to print syscall
491 * parameters in certain format. All of these have parameter
492 * named 'last'. This parameter is used to add comma to output
493 * when last == 0.
496 static const char *
497 get_comma(int last)
499 return ((last) ? "" : ",");
502 static void
503 print_flags(const struct flags *f, abi_long flags, int last)
505 const char *sep = "";
506 int n;
508 if ((flags == 0) && (f->f_value == 0)) {
509 gemu_log("%s%s", f->f_string, get_comma(last));
510 return;
512 for (n = 0; f->f_string != NULL; f++) {
513 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
514 gemu_log("%s%s", sep, f->f_string);
515 flags &= ~f->f_value;
516 sep = "|";
517 n++;
521 if (n > 0) {
522 /* print rest of the flags as numeric */
523 if (flags != 0) {
524 gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
525 } else {
526 gemu_log("%s", get_comma(last));
528 } else {
529 /* no string version of flags found, print them in hex then */
530 gemu_log("%#x%s", (unsigned int)flags, get_comma(last));
534 static void
535 print_at_dirfd(abi_long dirfd, int last)
537 #ifdef AT_FDCWD
538 if (dirfd == AT_FDCWD) {
539 gemu_log("AT_FDCWD%s", get_comma(last));
540 return;
542 #endif
543 gemu_log("%d%s", (int)dirfd, get_comma(last));
546 static void
547 print_file_mode(abi_long mode, int last)
549 const char *sep = "";
550 const struct flags *m;
552 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
553 if ((m->f_value & mode) == m->f_value) {
554 gemu_log("%s%s", m->f_string, sep);
555 sep = "|";
556 mode &= ~m->f_value;
557 break;
561 mode &= ~S_IFMT;
562 /* print rest of the mode as octal */
563 if (mode != 0)
564 gemu_log("%s%#o", sep, (unsigned int)mode);
566 gemu_log("%s", get_comma(last));
569 static void
570 print_open_flags(abi_long flags, int last)
572 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
573 flags &= ~TARGET_O_ACCMODE;
574 if (flags == 0) {
575 gemu_log("%s", get_comma(last));
576 return;
578 gemu_log("|");
579 print_flags(open_flags, flags, last);
582 static void
583 print_syscall_prologue(const struct syscallname *sc)
585 gemu_log("%s(", sc->name);
588 /*ARGSUSED*/
589 static void
590 print_syscall_epilogue(const struct syscallname *sc)
592 (void)sc;
593 gemu_log(")");
596 static void
597 print_string(abi_long addr, int last)
599 char *s;
601 if ((s = lock_user_string(addr)) != NULL) {
602 gemu_log("\"%s\"%s", s, get_comma(last));
603 unlock_user(s, addr, 0);
604 } else {
605 /* can't get string out of it, so print it as pointer */
606 print_pointer(addr, last);
611 * Prints out raw parameter using given format. Caller needs
612 * to do byte swapping if needed.
614 static void
615 print_raw_param(const char *fmt, abi_long param, int last)
617 char format[64];
619 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
620 gemu_log(format, param);
623 static void
624 print_pointer(abi_long p, int last)
626 if (p == 0)
627 gemu_log("NULL%s", get_comma(last));
628 else
629 gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
633 * Reads 32-bit (int) number from guest address space from
634 * address 'addr' and prints it.
636 static void
637 print_number(abi_long addr, int last)
639 if (addr == 0) {
640 gemu_log("NULL%s", get_comma(last));
641 } else {
642 int num;
644 get_user_s32(num, addr);
645 gemu_log("[%d]%s", num, get_comma(last));
649 static void
650 print_timeval(abi_ulong tv_addr, int last)
652 if( tv_addr ) {
653 struct target_timeval *tv;
655 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
656 if (!tv)
657 return;
658 gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
659 tv->tv_sec, tv->tv_usec, get_comma(last));
660 unlock_user(tv, tv_addr, 0);
661 } else
662 gemu_log("NULL%s", get_comma(last));
665 #undef UNUSED
667 #ifdef TARGET_NR_accept
668 static void
669 print_accept(const struct syscallname *name,
670 abi_long arg0, abi_long arg1, abi_long arg2,
671 abi_long arg3, abi_long arg4, abi_long arg5)
673 print_syscall_prologue(name);
674 print_raw_param("%d", arg0, 0);
675 print_pointer(arg1, 0);
676 print_number(arg2, 1);
677 print_syscall_epilogue(name);
679 #endif
681 #ifdef TARGET_NR_access
682 static void
683 print_access(const struct syscallname *name,
684 abi_long arg0, abi_long arg1, abi_long arg2,
685 abi_long arg3, abi_long arg4, abi_long arg5)
687 print_syscall_prologue(name);
688 print_string(arg0, 0);
689 print_flags(access_flags, arg1, 1);
690 print_syscall_epilogue(name);
692 #endif
694 #ifdef TARGET_NR_brk
695 static void
696 print_brk(const struct syscallname *name,
697 abi_long arg0, abi_long arg1, abi_long arg2,
698 abi_long arg3, abi_long arg4, abi_long arg5)
700 print_syscall_prologue(name);
701 print_pointer(arg0, 1);
702 print_syscall_epilogue(name);
704 #endif
706 #ifdef TARGET_NR_chdir
707 static void
708 print_chdir(const struct syscallname *name,
709 abi_long arg0, abi_long arg1, abi_long arg2,
710 abi_long arg3, abi_long arg4, abi_long arg5)
712 print_syscall_prologue(name);
713 print_string(arg0, 1);
714 print_syscall_epilogue(name);
716 #endif
718 #ifdef TARGET_NR_chmod
719 static void
720 print_chmod(const struct syscallname *name,
721 abi_long arg0, abi_long arg1, abi_long arg2,
722 abi_long arg3, abi_long arg4, abi_long arg5)
724 print_syscall_prologue(name);
725 print_string(arg0, 0);
726 print_file_mode(arg1, 1);
727 print_syscall_epilogue(name);
729 #endif
731 #ifdef TARGET_NR_clone
732 static void
733 print_clone(const struct syscallname *name,
734 abi_long arg0, abi_long arg1, abi_long arg2,
735 abi_long arg3, abi_long arg4, abi_long arg5)
737 print_syscall_prologue(name);
738 #if defined(TARGET_M68K)
739 print_flags(clone_flags, arg0, 0);
740 print_raw_param("newsp=0x" TARGET_ABI_FMT_lx, arg1, 1);
741 #elif defined(TARGET_SH4) || defined(TARGET_ALPHA)
742 print_flags(clone_flags, arg0, 0);
743 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0);
744 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
745 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 0);
746 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 1);
747 #elif defined(TARGET_CRIS)
748 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg0, 0);
749 print_flags(clone_flags, arg1, 0);
750 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
751 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0);
752 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
753 #else
754 print_flags(clone_flags, arg0, 0);
755 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0);
756 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0);
757 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0);
758 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1);
759 #endif
760 print_syscall_epilogue(name);
762 #endif
764 #ifdef TARGET_NR_creat
765 static void
766 print_creat(const struct syscallname *name,
767 abi_long arg0, abi_long arg1, abi_long arg2,
768 abi_long arg3, abi_long arg4, abi_long arg5)
770 print_syscall_prologue(name);
771 print_string(arg0, 0);
772 print_file_mode(arg1, 1);
773 print_syscall_epilogue(name);
775 #endif
777 #ifdef TARGET_NR_execv
778 static void
779 print_execv(const struct syscallname *name,
780 abi_long arg0, abi_long arg1, abi_long arg2,
781 abi_long arg3, abi_long arg4, abi_long arg5)
783 print_syscall_prologue(name);
784 print_string(arg0, 0);
785 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
786 print_syscall_epilogue(name);
788 #endif
790 #ifdef TARGET_NR_faccessat
791 static void
792 print_faccessat(const struct syscallname *name,
793 abi_long arg0, abi_long arg1, abi_long arg2,
794 abi_long arg3, abi_long arg4, abi_long arg5)
796 print_syscall_prologue(name);
797 print_at_dirfd(arg0, 0);
798 print_string(arg1, 0);
799 print_flags(access_flags, arg2, 0);
800 print_flags(at_file_flags, arg3, 1);
801 print_syscall_epilogue(name);
803 #endif
805 #ifdef TARGET_NR_fchmodat
806 static void
807 print_fchmodat(const struct syscallname *name,
808 abi_long arg0, abi_long arg1, abi_long arg2,
809 abi_long arg3, abi_long arg4, abi_long arg5)
811 print_syscall_prologue(name);
812 print_at_dirfd(arg0, 0);
813 print_string(arg1, 0);
814 print_file_mode(arg2, 0);
815 print_flags(at_file_flags, arg3, 1);
816 print_syscall_epilogue(name);
818 #endif
820 #ifdef TARGET_NR_fchownat
821 static void
822 print_fchownat(const struct syscallname *name,
823 abi_long arg0, abi_long arg1, abi_long arg2,
824 abi_long arg3, abi_long arg4, abi_long arg5)
826 print_syscall_prologue(name);
827 print_at_dirfd(arg0, 0);
828 print_string(arg1, 0);
829 print_raw_param("%d", arg2, 0);
830 print_raw_param("%d", arg3, 0);
831 print_flags(at_file_flags, arg4, 1);
832 print_syscall_epilogue(name);
834 #endif
836 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
837 static void
838 print_fcntl(const struct syscallname *name,
839 abi_long arg0, abi_long arg1, abi_long arg2,
840 abi_long arg3, abi_long arg4, abi_long arg5)
842 print_syscall_prologue(name);
843 print_raw_param("%d", arg0, 0);
844 print_flags(fcntl_flags, arg1, 0);
846 * TODO: check flags and print following argument only
847 * when needed.
849 print_pointer(arg2, 1);
850 print_syscall_epilogue(name);
852 #define print_fcntl64 print_fcntl
853 #endif
856 #ifdef TARGET_NR_futimesat
857 static void
858 print_futimesat(const struct syscallname *name,
859 abi_long arg0, abi_long arg1, abi_long arg2,
860 abi_long arg3, abi_long arg4, abi_long arg5)
862 print_syscall_prologue(name);
863 print_at_dirfd(arg0, 0);
864 print_string(arg1, 0);
865 print_timeval(arg2, 0);
866 print_timeval(arg2 + sizeof (struct target_timeval), 1);
867 print_syscall_epilogue(name);
869 #endif
871 #ifdef TARGET_NR_link
872 static void
873 print_link(const struct syscallname *name,
874 abi_long arg0, abi_long arg1, abi_long arg2,
875 abi_long arg3, abi_long arg4, abi_long arg5)
877 print_syscall_prologue(name);
878 print_string(arg0, 0);
879 print_string(arg1, 1);
880 print_syscall_epilogue(name);
882 #endif
884 #ifdef TARGET_NR_linkat
885 static void
886 print_linkat(const struct syscallname *name,
887 abi_long arg0, abi_long arg1, abi_long arg2,
888 abi_long arg3, abi_long arg4, abi_long arg5)
890 print_syscall_prologue(name);
891 print_at_dirfd(arg0, 0);
892 print_string(arg1, 0);
893 print_at_dirfd(arg2, 0);
894 print_string(arg3, 0);
895 print_flags(at_file_flags, arg4, 1);
896 print_syscall_epilogue(name);
898 #endif
900 #ifdef TARGET_NR__llseek
901 static void
902 print__llseek(const struct syscallname *name,
903 abi_long arg0, abi_long arg1, abi_long arg2,
904 abi_long arg3, abi_long arg4, abi_long arg5)
906 const char *whence = "UNKNOWN";
907 print_syscall_prologue(name);
908 print_raw_param("%d", arg0, 0);
909 print_raw_param("%ld", arg1, 0);
910 print_raw_param("%ld", arg2, 0);
911 print_pointer(arg3, 0);
912 switch(arg4) {
913 case SEEK_SET: whence = "SEEK_SET"; break;
914 case SEEK_CUR: whence = "SEEK_CUR"; break;
915 case SEEK_END: whence = "SEEK_END"; break;
917 gemu_log("%s",whence);
918 print_syscall_epilogue(name);
920 #endif
922 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
923 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
924 static void
925 print_stat(const struct syscallname *name,
926 abi_long arg0, abi_long arg1, abi_long arg2,
927 abi_long arg3, abi_long arg4, abi_long arg5)
929 print_syscall_prologue(name);
930 print_string(arg0, 0);
931 print_pointer(arg1, 1);
932 print_syscall_epilogue(name);
934 #define print_lstat print_stat
935 #define print_stat64 print_stat
936 #define print_lstat64 print_stat
937 #endif
939 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
940 static void
941 print_fstat(const struct syscallname *name,
942 abi_long arg0, abi_long arg1, abi_long arg2,
943 abi_long arg3, abi_long arg4, abi_long arg5)
945 print_syscall_prologue(name);
946 print_raw_param("%d", arg0, 0);
947 print_pointer(arg1, 1);
948 print_syscall_epilogue(name);
950 #define print_fstat64 print_fstat
951 #endif
953 #ifdef TARGET_NR_mkdir
954 static void
955 print_mkdir(const struct syscallname *name,
956 abi_long arg0, abi_long arg1, abi_long arg2,
957 abi_long arg3, abi_long arg4, abi_long arg5)
959 print_syscall_prologue(name);
960 print_string(arg0, 0);
961 print_file_mode(arg1, 1);
962 print_syscall_epilogue(name);
964 #endif
966 #ifdef TARGET_NR_mkdirat
967 static void
968 print_mkdirat(const struct syscallname *name,
969 abi_long arg0, abi_long arg1, abi_long arg2,
970 abi_long arg3, abi_long arg4, abi_long arg5)
972 print_syscall_prologue(name);
973 print_at_dirfd(arg0, 0);
974 print_string(arg1, 0);
975 print_file_mode(arg2, 1);
976 print_syscall_epilogue(name);
978 #endif
980 #ifdef TARGET_NR_rmdir
981 static void
982 print_rmdir(const struct syscallname *name,
983 abi_long arg0, abi_long arg1, abi_long arg2,
984 abi_long arg3, abi_long arg4, abi_long arg5)
986 print_syscall_prologue(name);
987 print_string(arg0, 0);
988 print_syscall_epilogue(name);
990 #endif
992 #ifdef TARGET_NR_rt_sigaction
993 static void
994 print_rt_sigaction(const struct syscallname *name,
995 abi_long arg0, abi_long arg1, abi_long arg2,
996 abi_long arg3, abi_long arg4, abi_long arg5)
998 print_syscall_prologue(name);
999 print_signal(arg0, 0);
1000 print_pointer(arg1, 0);
1001 print_pointer(arg2, 1);
1002 print_syscall_epilogue(name);
1004 #endif
1006 #ifdef TARGET_NR_rt_sigprocmask
1007 static void
1008 print_rt_sigprocmask(const struct syscallname *name,
1009 abi_long arg0, abi_long arg1, abi_long arg2,
1010 abi_long arg3, abi_long arg4, abi_long arg5)
1012 const char *how = "UNKNOWN";
1013 print_syscall_prologue(name);
1014 switch(arg0) {
1015 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
1016 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
1017 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
1019 gemu_log("%s,",how);
1020 print_pointer(arg1, 0);
1021 print_pointer(arg2, 1);
1022 print_syscall_epilogue(name);
1024 #endif
1026 #ifdef TARGET_NR_mknod
1027 static void
1028 print_mknod(const struct syscallname *name,
1029 abi_long arg0, abi_long arg1, abi_long arg2,
1030 abi_long arg3, abi_long arg4, abi_long arg5)
1032 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
1034 print_syscall_prologue(name);
1035 print_string(arg0, 0);
1036 print_file_mode(arg1, (hasdev == 0));
1037 if (hasdev) {
1038 print_raw_param("makedev(%d", major(arg2), 0);
1039 print_raw_param("%d)", minor(arg2), 1);
1041 print_syscall_epilogue(name);
1043 #endif
1045 #ifdef TARGET_NR_mknodat
1046 static void
1047 print_mknodat(const struct syscallname *name,
1048 abi_long arg0, abi_long arg1, abi_long arg2,
1049 abi_long arg3, abi_long arg4, abi_long arg5)
1051 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
1053 print_syscall_prologue(name);
1054 print_at_dirfd(arg0, 0);
1055 print_string(arg1, 0);
1056 print_file_mode(arg2, (hasdev == 0));
1057 if (hasdev) {
1058 print_raw_param("makedev(%d", major(arg3), 0);
1059 print_raw_param("%d)", minor(arg3), 1);
1061 print_syscall_epilogue(name);
1063 #endif
1065 #ifdef TARGET_NR_mq_open
1066 static void
1067 print_mq_open(const struct syscallname *name,
1068 abi_long arg0, abi_long arg1, abi_long arg2,
1069 abi_long arg3, abi_long arg4, abi_long arg5)
1071 int is_creat = (arg1 & TARGET_O_CREAT);
1073 print_syscall_prologue(name);
1074 print_string(arg0, 0);
1075 print_open_flags(arg1, (is_creat == 0));
1076 if (is_creat) {
1077 print_file_mode(arg2, 0);
1078 print_pointer(arg3, 1);
1080 print_syscall_epilogue(name);
1082 #endif
1084 #ifdef TARGET_NR_open
1085 static void
1086 print_open(const struct syscallname *name,
1087 abi_long arg0, abi_long arg1, abi_long arg2,
1088 abi_long arg3, abi_long arg4, abi_long arg5)
1090 int is_creat = (arg1 & TARGET_O_CREAT);
1092 print_syscall_prologue(name);
1093 print_string(arg0, 0);
1094 print_open_flags(arg1, (is_creat == 0));
1095 if (is_creat)
1096 print_file_mode(arg2, 1);
1097 print_syscall_epilogue(name);
1099 #endif
1101 #ifdef TARGET_NR_openat
1102 static void
1103 print_openat(const struct syscallname *name,
1104 abi_long arg0, abi_long arg1, abi_long arg2,
1105 abi_long arg3, abi_long arg4, abi_long arg5)
1107 int is_creat = (arg2 & TARGET_O_CREAT);
1109 print_syscall_prologue(name);
1110 print_at_dirfd(arg0, 0);
1111 print_string(arg1, 0);
1112 print_open_flags(arg2, (is_creat == 0));
1113 if (is_creat)
1114 print_file_mode(arg3, 1);
1115 print_syscall_epilogue(name);
1117 #endif
1119 #ifdef TARGET_NR_mq_unlink
1120 static void
1121 print_mq_unlink(const struct syscallname *name,
1122 abi_long arg0, abi_long arg1, abi_long arg2,
1123 abi_long arg3, abi_long arg4, abi_long arg5)
1125 print_syscall_prologue(name);
1126 print_string(arg0, 1);
1127 print_syscall_epilogue(name);
1129 #endif
1131 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
1132 static void
1133 print_fstatat64(const struct syscallname *name,
1134 abi_long arg0, abi_long arg1, abi_long arg2,
1135 abi_long arg3, abi_long arg4, abi_long arg5)
1137 print_syscall_prologue(name);
1138 print_at_dirfd(arg0, 0);
1139 print_string(arg1, 0);
1140 print_pointer(arg2, 0);
1141 print_flags(at_file_flags, arg3, 1);
1142 print_syscall_epilogue(name);
1144 #define print_newfstatat print_fstatat64
1145 #endif
1147 #ifdef TARGET_NR_readlink
1148 static void
1149 print_readlink(const struct syscallname *name,
1150 abi_long arg0, abi_long arg1, abi_long arg2,
1151 abi_long arg3, abi_long arg4, abi_long arg5)
1153 print_syscall_prologue(name);
1154 print_string(arg0, 0);
1155 print_pointer(arg1, 0);
1156 print_raw_param("%u", arg2, 1);
1157 print_syscall_epilogue(name);
1159 #endif
1161 #ifdef TARGET_NR_readlinkat
1162 static void
1163 print_readlinkat(const struct syscallname *name,
1164 abi_long arg0, abi_long arg1, abi_long arg2,
1165 abi_long arg3, abi_long arg4, abi_long arg5)
1167 print_syscall_prologue(name);
1168 print_at_dirfd(arg0, 0);
1169 print_string(arg1, 0);
1170 print_pointer(arg2, 0);
1171 print_raw_param("%u", arg3, 1);
1172 print_syscall_epilogue(name);
1174 #endif
1176 #ifdef TARGET_NR_rename
1177 static void
1178 print_rename(const struct syscallname *name,
1179 abi_long arg0, abi_long arg1, abi_long arg2,
1180 abi_long arg3, abi_long arg4, abi_long arg5)
1182 print_syscall_prologue(name);
1183 print_string(arg0, 0);
1184 print_string(arg1, 1);
1185 print_syscall_epilogue(name);
1187 #endif
1189 #ifdef TARGET_NR_renameat
1190 static void
1191 print_renameat(const struct syscallname *name,
1192 abi_long arg0, abi_long arg1, abi_long arg2,
1193 abi_long arg3, abi_long arg4, abi_long arg5)
1195 print_syscall_prologue(name);
1196 print_at_dirfd(arg0, 0);
1197 print_string(arg1, 0);
1198 print_at_dirfd(arg2, 0);
1199 print_string(arg3, 1);
1200 print_syscall_epilogue(name);
1202 #endif
1204 #ifdef TARGET_NR_statfs
1205 static void
1206 print_statfs(const struct syscallname *name,
1207 abi_long arg0, abi_long arg1, abi_long arg2,
1208 abi_long arg3, abi_long arg4, abi_long arg5)
1210 print_syscall_prologue(name);
1211 print_string(arg0, 0);
1212 print_pointer(arg1, 1);
1213 print_syscall_epilogue(name);
1215 #define print_statfs64 print_statfs
1216 #endif
1218 #ifdef TARGET_NR_symlink
1219 static void
1220 print_symlink(const struct syscallname *name,
1221 abi_long arg0, abi_long arg1, abi_long arg2,
1222 abi_long arg3, abi_long arg4, abi_long arg5)
1224 print_syscall_prologue(name);
1225 print_string(arg0, 0);
1226 print_string(arg1, 1);
1227 print_syscall_epilogue(name);
1229 #endif
1231 #ifdef TARGET_NR_symlinkat
1232 static void
1233 print_symlinkat(const struct syscallname *name,
1234 abi_long arg0, abi_long arg1, abi_long arg2,
1235 abi_long arg3, abi_long arg4, abi_long arg5)
1237 print_syscall_prologue(name);
1238 print_string(arg0, 0);
1239 print_at_dirfd(arg1, 0);
1240 print_string(arg2, 1);
1241 print_syscall_epilogue(name);
1243 #endif
1245 #ifdef TARGET_NR_mount
1246 static void
1247 print_mount(const struct syscallname *name,
1248 abi_long arg0, abi_long arg1, abi_long arg2,
1249 abi_long arg3, abi_long arg4, abi_long arg5)
1251 print_syscall_prologue(name);
1252 print_string(arg0, 0);
1253 print_string(arg1, 0);
1254 print_string(arg2, 0);
1255 print_flags(mount_flags, arg3, 0);
1256 print_pointer(arg4, 1);
1257 print_syscall_epilogue(name);
1259 #endif
1261 #ifdef TARGET_NR_umount
1262 static void
1263 print_umount(const struct syscallname *name,
1264 abi_long arg0, abi_long arg1, abi_long arg2,
1265 abi_long arg3, abi_long arg4, abi_long arg5)
1267 print_syscall_prologue(name);
1268 print_string(arg0, 1);
1269 print_syscall_epilogue(name);
1271 #endif
1273 #ifdef TARGET_NR_umount2
1274 static void
1275 print_umount2(const struct syscallname *name,
1276 abi_long arg0, abi_long arg1, abi_long arg2,
1277 abi_long arg3, abi_long arg4, abi_long arg5)
1279 print_syscall_prologue(name);
1280 print_string(arg0, 0);
1281 print_flags(umount2_flags, arg1, 1);
1282 print_syscall_epilogue(name);
1284 #endif
1286 #ifdef TARGET_NR_unlink
1287 static void
1288 print_unlink(const struct syscallname *name,
1289 abi_long arg0, abi_long arg1, abi_long arg2,
1290 abi_long arg3, abi_long arg4, abi_long arg5)
1292 print_syscall_prologue(name);
1293 print_string(arg0, 1);
1294 print_syscall_epilogue(name);
1296 #endif
1298 #ifdef TARGET_NR_unlinkat
1299 static void
1300 print_unlinkat(const struct syscallname *name,
1301 abi_long arg0, abi_long arg1, abi_long arg2,
1302 abi_long arg3, abi_long arg4, abi_long arg5)
1304 print_syscall_prologue(name);
1305 print_at_dirfd(arg0, 0);
1306 print_string(arg1, 0);
1307 print_flags(unlinkat_flags, arg2, 1);
1308 print_syscall_epilogue(name);
1310 #endif
1312 #ifdef TARGET_NR_utime
1313 static void
1314 print_utime(const struct syscallname *name,
1315 abi_long arg0, abi_long arg1, abi_long arg2,
1316 abi_long arg3, abi_long arg4, abi_long arg5)
1318 print_syscall_prologue(name);
1319 print_string(arg0, 0);
1320 print_pointer(arg1, 1);
1321 print_syscall_epilogue(name);
1323 #endif
1325 #ifdef TARGET_NR_utimes
1326 static void
1327 print_utimes(const struct syscallname *name,
1328 abi_long arg0, abi_long arg1, abi_long arg2,
1329 abi_long arg3, abi_long arg4, abi_long arg5)
1331 print_syscall_prologue(name);
1332 print_string(arg0, 0);
1333 print_pointer(arg1, 1);
1334 print_syscall_epilogue(name);
1336 #endif
1338 #ifdef TARGET_NR_utimensat
1339 static void
1340 print_utimensat(const struct syscallname *name,
1341 abi_long arg0, abi_long arg1, abi_long arg2,
1342 abi_long arg3, abi_long arg4, abi_long arg5)
1344 print_syscall_prologue(name);
1345 print_at_dirfd(arg0, 0);
1346 print_string(arg1, 0);
1347 print_pointer(arg2, 0);
1348 print_flags(at_file_flags, arg3, 1);
1349 print_syscall_epilogue(name);
1351 #endif
1353 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
1354 static void
1355 print_mmap(const struct syscallname *name,
1356 abi_long arg0, abi_long arg1, abi_long arg2,
1357 abi_long arg3, abi_long arg4, abi_long arg5)
1359 print_syscall_prologue(name);
1360 print_pointer(arg0, 0);
1361 print_raw_param("%d", arg1, 0);
1362 print_flags(mmap_prot_flags, arg2, 0);
1363 print_flags(mmap_flags, arg3, 0);
1364 print_raw_param("%d", arg4, 0);
1365 print_raw_param("%#x", arg5, 1);
1366 print_syscall_epilogue(name);
1368 #define print_mmap2 print_mmap
1369 #endif
1371 #ifdef TARGET_NR_mprotect
1372 static void
1373 print_mprotect(const struct syscallname *name,
1374 abi_long arg0, abi_long arg1, abi_long arg2,
1375 abi_long arg3, abi_long arg4, abi_long arg5)
1377 print_syscall_prologue(name);
1378 print_pointer(arg0, 0);
1379 print_raw_param("%d", arg1, 0);
1380 print_flags(mmap_prot_flags, arg2, 1);
1381 print_syscall_epilogue(name);
1383 #endif
1385 #ifdef TARGET_NR_munmap
1386 static void
1387 print_munmap(const struct syscallname *name,
1388 abi_long arg0, abi_long arg1, abi_long arg2,
1389 abi_long arg3, abi_long arg4, abi_long arg5)
1391 print_syscall_prologue(name);
1392 print_pointer(arg0, 0);
1393 print_raw_param("%d", arg1, 1);
1394 print_syscall_epilogue(name);
1396 #endif
1398 #ifdef TARGET_NR_futex
1399 static void print_futex_op(abi_long tflag, int last)
1401 #define print_op(val) \
1402 if( cmd == val ) { \
1403 gemu_log(#val); \
1404 return; \
1407 int cmd = (int)tflag;
1408 #ifdef FUTEX_PRIVATE_FLAG
1409 if (cmd & FUTEX_PRIVATE_FLAG) {
1410 gemu_log("FUTEX_PRIVATE_FLAG|");
1411 cmd &= ~FUTEX_PRIVATE_FLAG;
1413 #endif
1414 print_op(FUTEX_WAIT)
1415 print_op(FUTEX_WAKE)
1416 print_op(FUTEX_FD)
1417 print_op(FUTEX_REQUEUE)
1418 print_op(FUTEX_CMP_REQUEUE)
1419 print_op(FUTEX_WAKE_OP)
1420 print_op(FUTEX_LOCK_PI)
1421 print_op(FUTEX_UNLOCK_PI)
1422 print_op(FUTEX_TRYLOCK_PI)
1423 #ifdef FUTEX_WAIT_BITSET
1424 print_op(FUTEX_WAIT_BITSET)
1425 #endif
1426 #ifdef FUTEX_WAKE_BITSET
1427 print_op(FUTEX_WAKE_BITSET)
1428 #endif
1429 /* unknown values */
1430 gemu_log("%d",cmd);
1433 static void
1434 print_futex(const struct syscallname *name,
1435 abi_long arg0, abi_long arg1, abi_long arg2,
1436 abi_long arg3, abi_long arg4, abi_long arg5)
1438 print_syscall_prologue(name);
1439 print_pointer(arg0, 0);
1440 print_futex_op(arg1, 0);
1441 print_raw_param(",%d", arg2, 0);
1442 print_pointer(arg3, 0); /* struct timespec */
1443 print_pointer(arg4, 0);
1444 print_raw_param("%d", arg4, 1);
1445 print_syscall_epilogue(name);
1447 #endif
1449 #ifdef TARGET_NR_kill
1450 static void
1451 print_kill(const struct syscallname *name,
1452 abi_long arg0, abi_long arg1, abi_long arg2,
1453 abi_long arg3, abi_long arg4, abi_long arg5)
1455 print_syscall_prologue(name);
1456 print_raw_param("%d", arg0, 0);
1457 print_signal(arg1, 1);
1458 print_syscall_epilogue(name);
1460 #endif
1463 * An array of all of the syscalls we know about
1466 static const struct syscallname scnames[] = {
1467 #include "strace.list"
1470 static int nsyscalls = ARRAY_SIZE(scnames);
1473 * The public interface to this module.
1475 void
1476 print_syscall(int num,
1477 abi_long arg1, abi_long arg2, abi_long arg3,
1478 abi_long arg4, abi_long arg5, abi_long arg6)
1480 int i;
1481 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 ")";
1483 gemu_log("%d ", getpid() );
1485 for(i=0;i<nsyscalls;i++)
1486 if( scnames[i].nr == num ) {
1487 if( scnames[i].call != NULL ) {
1488 scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6);
1489 } else {
1490 /* XXX: this format system is broken because it uses
1491 host types and host pointers for strings */
1492 if( scnames[i].format != NULL )
1493 format = scnames[i].format;
1494 gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6);
1496 return;
1498 gemu_log("Unknown syscall %d\n", num);
1502 void
1503 print_syscall_ret(int num, abi_long ret)
1505 int i;
1507 for(i=0;i<nsyscalls;i++)
1508 if( scnames[i].nr == num ) {
1509 if( scnames[i].result != NULL ) {
1510 scnames[i].result(&scnames[i],ret);
1511 } else {
1512 if( ret < 0 ) {
1513 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret, target_strerror(-ret));
1514 } else {
1515 gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
1518 break;