7 #include <sys/select.h>
20 void (*call)(const struct syscallname *,
21 abi_long, abi_long, abi_long,
22 abi_long, abi_long, abi_long);
23 void (*result)(const struct syscallname *, abi_long);
28 * It is possible that target doesn't have syscall that uses
29 * following flags but we don't want the compiler to warn
30 * us about them being unused. Same applies to utility print
31 * functions. It is ok to keep them while not used.
33 #define UNUSED __attribute__ ((unused))
39 * Structure used to translate flag values into strings. This is
40 * similar that is in the actual strace tool.
43 abi_long f_value; /* flag */
44 const char *f_string; /* stringified flag */
47 /* common flags for all architectures */
48 #define FLAG_GENERIC(name) { name, #name }
49 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
50 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
51 /* end of flags array */
52 #define FLAG_END { 0, NULL }
54 UNUSED static const char *get_comma(int);
55 UNUSED static void print_pointer(abi_long, int);
56 UNUSED static void print_flags(const struct flags *, abi_long, int);
57 UNUSED static void print_at_dirfd(abi_long, int);
58 UNUSED static void print_file_mode(abi_long, int);
59 UNUSED static void print_open_flags(abi_long, int);
60 UNUSED static void print_syscall_prologue(const struct syscallname *);
61 UNUSED static void print_syscall_epilogue(const struct syscallname *);
62 UNUSED static void print_string(abi_long, int);
63 UNUSED static void print_raw_param(const char *, abi_long, int);
64 UNUSED static void print_timeval(abi_ulong, int);
65 UNUSED static void print_number(abi_long, int);
71 print_ipc_cmd(int cmd)
73 #define output_cmd(val) \
81 /* General IPC commands */
82 output_cmd( IPC_RMID );
83 output_cmd( IPC_SET );
84 output_cmd( IPC_STAT );
85 output_cmd( IPC_INFO );
86 /* msgctl() commands */
88 output_cmd( MSG_STAT );
89 output_cmd( MSG_INFO );
91 /* shmctl() commands */
92 output_cmd( SHM_LOCK );
93 output_cmd( SHM_UNLOCK );
94 output_cmd( SHM_STAT );
95 output_cmd( SHM_INFO );
96 /* semctl() commands */
100 output_cmd( GETNCNT );
101 output_cmd( GETZCNT );
102 output_cmd( SETVAL );
103 output_cmd( SETALL );
104 output_cmd( SEM_STAT );
105 output_cmd( SEM_INFO );
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 output_cmd( IPC_RMID );
114 output_cmd( IPC_RMID );
116 /* Some value we don't recognize */
120 #ifdef TARGET_NR__newselect
122 print_fdset(int n, abi_ulong target_fds_addr)
127 if( target_fds_addr ) {
128 abi_long *target_fds;
130 target_fds = lock_user(VERIFY_READ,
132 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
138 for (i=n; i>=0; i--) {
139 if ((tswapl(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1)
142 unlock_user(target_fds, target_fds_addr, 0);
149 * Sysycall specific output functions
153 #ifdef TARGET_NR__newselect
154 static long newselect_arg1 = 0;
155 static long newselect_arg2 = 0;
156 static long newselect_arg3 = 0;
157 static long newselect_arg4 = 0;
158 static long newselect_arg5 = 0;
161 print_newselect(const struct syscallname *name,
162 abi_long arg1, abi_long arg2, abi_long arg3,
163 abi_long arg4, abi_long arg5, abi_long arg6)
165 gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1);
166 print_fdset(arg1, arg2);
168 print_fdset(arg1, arg3);
170 print_fdset(arg1, arg4);
172 print_timeval(arg5, 1);
175 /* save for use in the return output function below */
184 #ifdef TARGET_NR_semctl
186 print_semctl(const struct syscallname *name,
187 abi_long arg1, abi_long arg2, abi_long arg3,
188 abi_long arg4, abi_long arg5, abi_long arg6)
190 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2);
192 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
197 print_execve(const struct syscallname *name,
198 abi_long arg1, abi_long arg2, abi_long arg3,
199 abi_long arg4, abi_long arg5, abi_long arg6)
201 abi_ulong arg_ptr_addr;
204 if (!(s = lock_user_string(arg1)))
206 gemu_log("%s(\"%s\",{", name->name, s);
207 unlock_user(s, arg1, 0);
209 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
210 abi_ulong *arg_ptr, arg_addr;
212 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
215 arg_addr = tswapl(*arg_ptr);
216 unlock_user(arg_ptr, arg_ptr_addr, 0);
219 if ((s = lock_user_string(arg_addr))) {
220 gemu_log("\"%s\",", s);
221 unlock_user(s, arg_addr, 0);
230 print_ipc(const struct syscallname *name,
231 abi_long arg1, abi_long arg2, abi_long arg3,
232 abi_long arg4, abi_long arg5, abi_long arg6)
236 gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2);
238 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
241 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")",
242 name->name, arg1, arg2, arg3, arg4);
248 * Variants for the return value output function
252 print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
255 gemu_log(" = -1 errno=%d (%s)\n", errno, target_strerror(errno));
257 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
261 #if 0 /* currently unused */
263 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
265 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
269 #ifdef TARGET_NR__newselect
271 print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)
273 gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
274 print_fdset(newselect_arg1,newselect_arg2);
276 print_fdset(newselect_arg1,newselect_arg3);
278 print_fdset(newselect_arg1,newselect_arg4);
280 print_timeval(newselect_arg5, 1);
285 UNUSED static struct flags access_flags[] = {
293 UNUSED static struct flags at_file_flags[] = {
294 FLAG_GENERIC(AT_EACCESS),
295 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
299 UNUSED static struct flags unlinkat_flags[] = {
300 FLAG_GENERIC(AT_REMOVEDIR),
304 UNUSED static struct flags mode_flags[] = {
305 FLAG_GENERIC(S_IFSOCK),
306 FLAG_GENERIC(S_IFLNK),
307 FLAG_GENERIC(S_IFREG),
308 FLAG_GENERIC(S_IFBLK),
309 FLAG_GENERIC(S_IFDIR),
310 FLAG_GENERIC(S_IFCHR),
311 FLAG_GENERIC(S_IFIFO),
315 UNUSED static struct flags open_access_flags[] = {
316 FLAG_TARGET(O_RDONLY),
317 FLAG_TARGET(O_WRONLY),
322 UNUSED static struct flags open_flags[] = {
323 FLAG_TARGET(O_APPEND),
324 FLAG_TARGET(O_CREAT),
325 FLAG_TARGET(O_DIRECTORY),
327 FLAG_TARGET(O_LARGEFILE),
328 FLAG_TARGET(O_NOCTTY),
329 FLAG_TARGET(O_NOFOLLOW),
330 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
332 FLAG_TARGET(O_TRUNC),
334 FLAG_TARGET(O_DIRECT),
339 UNUSED static struct flags mount_flags[] = {
341 FLAG_GENERIC(MS_BIND),
344 FLAG_GENERIC(MS_DIRSYNC),
346 FLAG_GENERIC(MS_MANDLOCK),
348 FLAG_GENERIC(MS_MOVE),
350 FLAG_GENERIC(MS_NOATIME),
351 FLAG_GENERIC(MS_NODEV),
352 FLAG_GENERIC(MS_NODIRATIME),
353 FLAG_GENERIC(MS_NOEXEC),
354 FLAG_GENERIC(MS_NOSUID),
355 FLAG_GENERIC(MS_RDONLY),
357 FLAG_GENERIC(MS_RELATIME),
359 FLAG_GENERIC(MS_REMOUNT),
360 FLAG_GENERIC(MS_SYNCHRONOUS),
364 UNUSED static struct flags umount2_flags[] = {
366 FLAG_GENERIC(MNT_FORCE),
369 FLAG_GENERIC(MNT_DETACH),
372 FLAG_GENERIC(MNT_EXPIRE),
377 UNUSED static struct flags mmap_prot_flags[] = {
378 FLAG_GENERIC(PROT_NONE),
379 FLAG_GENERIC(PROT_EXEC),
380 FLAG_GENERIC(PROT_READ),
381 FLAG_GENERIC(PROT_WRITE),
385 UNUSED static struct flags mmap_flags[] = {
386 FLAG_TARGET(MAP_SHARED),
387 FLAG_TARGET(MAP_PRIVATE),
388 FLAG_TARGET(MAP_ANONYMOUS),
389 FLAG_TARGET(MAP_DENYWRITE),
390 FLAG_TARGET(MAP_FIXED),
391 FLAG_TARGET(MAP_GROWSDOWN),
393 FLAG_TARGET(MAP_LOCKED),
396 FLAG_TARGET(MAP_NONBLOCK),
398 FLAG_TARGET(MAP_NORESERVE),
400 FLAG_TARGET(MAP_POPULATE),
405 UNUSED static struct flags fcntl_flags[] = {
406 FLAG_TARGET(F_DUPFD),
407 FLAG_TARGET(F_GETFD),
408 FLAG_TARGET(F_SETFD),
409 FLAG_TARGET(F_GETFL),
410 FLAG_TARGET(F_SETFL),
411 FLAG_TARGET(F_GETLK),
412 FLAG_TARGET(F_SETLK),
413 FLAG_TARGET(F_SETLKW),
418 * print_xxx utility functions. These are used to print syscall
419 * parameters in certain format. All of these have parameter
420 * named 'last'. This parameter is used to add comma to output
427 return ((last) ? "" : ",");
431 print_flags(const struct flags *f, abi_long tflags, int last)
433 const char *sep = "";
437 flags = (int)tswap32(tflags);
439 if ((flags == 0) && (f->f_value == 0)) {
440 gemu_log("%s%s", f->f_string, get_comma(last));
443 for (n = 0; f->f_string != NULL; f++) {
444 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
445 gemu_log("%s%s", sep, f->f_string);
446 flags &= ~f->f_value;
453 /* print rest of the flags as numeric */
455 gemu_log("%s%#x%s", sep, flags, get_comma(last));
457 gemu_log("%s", get_comma(last));
460 /* no string version of flags found, print them in hex then */
461 gemu_log("%#x%s", flags, get_comma(last));
466 print_at_dirfd(abi_long tdirfd, int last)
468 int dirfd = tswap32(tdirfd);
470 if (dirfd == AT_FDCWD)
471 gemu_log("AT_FDCWD%s", get_comma(last));
473 gemu_log("%d%s", dirfd, get_comma(last));
477 print_file_mode(abi_long tmode, int last)
479 const char *sep = "";
480 const struct flags *m;
481 mode_t mode = (mode_t)tswap32(tmode);
483 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
484 if ((m->f_value & mode) == m->f_value) {
485 gemu_log("%s%s", m->f_string, sep);
493 /* print rest of the mode as octal */
495 gemu_log("%s%#o", sep, mode);
497 gemu_log("%s", get_comma(last));
501 print_open_flags(abi_long tflags, int last)
503 int flags = tswap32(tflags);
505 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
506 flags &= ~TARGET_O_ACCMODE;
508 gemu_log("%s", get_comma(last));
512 print_flags(open_flags, flags, last);
516 print_syscall_prologue(const struct syscallname *sc)
518 gemu_log("%s(", sc->name);
523 print_syscall_epilogue(const struct syscallname *sc)
530 print_string(abi_long addr, int last)
534 if ((s = lock_user_string(addr)) != NULL) {
535 gemu_log("\"%s\"%s", s, get_comma(last));
536 unlock_user(s, addr, 0);
538 /* can't get string out of it, so print it as pointer */
539 print_pointer(addr, last);
544 * Prints out raw parameter using given format. Caller needs
545 * to do byte swapping if needed.
548 print_raw_param(const char *fmt, abi_long param, int last)
552 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
553 gemu_log(format, param);
557 print_pointer(abi_long p, int last)
560 gemu_log("NULL%s", get_comma(last));
562 gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
566 * Reads 32-bit (int) number from guest address space from
567 * address 'addr' and prints it.
570 print_number(abi_long addr, int last)
573 gemu_log("NULL%s", get_comma(last));
577 get_user_s32(num, addr);
578 gemu_log("[%d]%s", num, get_comma(last));
583 print_timeval(abi_ulong tv_addr, int last)
586 struct target_timeval *tv;
588 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
591 gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s",
592 tv->tv_sec, tv->tv_usec, get_comma(last));
593 unlock_user(tv, tv_addr, 0);
595 gemu_log("NULL%s", get_comma(last));
600 #ifdef TARGET_NR_accept
602 print_accept(const struct syscallname *name,
603 abi_long arg0, abi_long arg1, abi_long arg2,
604 abi_long arg3, abi_long arg4, abi_long arg5)
606 print_syscall_prologue(name);
607 print_raw_param("%d", tswap32(arg0), 0);
608 print_pointer(arg1, 0);
609 print_number(arg2, 1);
610 print_syscall_epilogue(name);
614 #ifdef TARGET_NR_access
616 print_access(const struct syscallname *name,
617 abi_long arg0, abi_long arg1, abi_long arg2,
618 abi_long arg3, abi_long arg4, abi_long arg5)
620 print_syscall_prologue(name);
621 print_string(arg0, 0);
622 print_flags(access_flags, arg1, 1);
623 print_syscall_epilogue(name);
629 print_brk(const struct syscallname *name,
630 abi_long arg0, abi_long arg1, abi_long arg2,
631 abi_long arg3, abi_long arg4, abi_long arg5)
633 print_syscall_prologue(name);
634 print_pointer(arg0, 1);
635 print_syscall_epilogue(name);
639 #ifdef TARGET_NR_chdir
641 print_chdir(const struct syscallname *name,
642 abi_long arg0, abi_long arg1, abi_long arg2,
643 abi_long arg3, abi_long arg4, abi_long arg5)
645 print_syscall_prologue(name);
646 print_string(arg0, 1);
647 print_syscall_epilogue(name);
651 #ifdef TARGET_NR_chmod
653 print_chmod(const struct syscallname *name,
654 abi_long arg0, abi_long arg1, abi_long arg2,
655 abi_long arg3, abi_long arg4, abi_long arg5)
657 print_syscall_prologue(name);
658 print_string(arg0, 0);
659 print_file_mode(arg1, 1);
660 print_syscall_epilogue(name);
664 #ifdef TARGET_NR_creat
666 print_creat(const struct syscallname *name,
667 abi_long arg0, abi_long arg1, abi_long arg2,
668 abi_long arg3, abi_long arg4, abi_long arg5)
670 print_syscall_prologue(name);
671 print_string(arg0, 0);
672 print_file_mode(arg1, 1);
673 print_syscall_epilogue(name);
677 #ifdef TARGET_NR_execv
679 print_execv(const struct syscallname *name,
680 abi_long arg0, abi_long arg1, abi_long arg2,
681 abi_long arg3, abi_long arg4, abi_long arg5)
683 print_syscall_prologue(name);
684 print_string(arg0, 0);
685 print_raw_param("0x" TARGET_ABI_FMT_lx, tswapl(arg1), 1);
686 print_syscall_epilogue(name);
690 #ifdef TARGET_NR_faccessat
692 print_faccessat(const struct syscallname *name,
693 abi_long arg0, abi_long arg1, abi_long arg2,
694 abi_long arg3, abi_long arg4, abi_long arg5)
696 print_syscall_prologue(name);
697 print_at_dirfd(arg0, 0);
698 print_string(arg1, 0);
699 print_flags(access_flags, arg2, 0);
700 print_flags(at_file_flags, arg3, 1);
701 print_syscall_epilogue(name);
705 #ifdef TARGET_NR_fchmodat
707 print_fchmodat(const struct syscallname *name,
708 abi_long arg0, abi_long arg1, abi_long arg2,
709 abi_long arg3, abi_long arg4, abi_long arg5)
711 print_syscall_prologue(name);
712 print_at_dirfd(arg0, 0);
713 print_string(arg1, 0);
714 print_file_mode(arg2, 0);
715 print_flags(at_file_flags, arg3, 1);
716 print_syscall_epilogue(name);
720 #ifdef TARGET_NR_fchownat
722 print_fchownat(const struct syscallname *name,
723 abi_long arg0, abi_long arg1, abi_long arg2,
724 abi_long arg3, abi_long arg4, abi_long arg5)
726 print_syscall_prologue(name);
727 print_at_dirfd(arg0, 0);
728 print_string(arg1, 0);
730 print_raw_param("%d", tswap16(arg2), 0);
731 print_raw_param("%d", tswap16(arg3), 0);
733 print_raw_param("%d", tswap32(arg2), 0);
734 print_raw_param("%d", tswap32(arg3), 0);
736 print_flags(at_file_flags, arg4, 1);
737 print_syscall_epilogue(name);
741 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
743 print_fcntl(const struct syscallname *name,
744 abi_long arg0, abi_long arg1, abi_long arg2,
745 abi_long arg3, abi_long arg4, abi_long arg5)
747 print_syscall_prologue(name);
748 print_raw_param("%d", tswap32(arg0), 0);
749 print_flags(fcntl_flags, arg1, 0);
751 * TODO: check flags and print following argument only
754 print_pointer(arg2, 1);
755 print_syscall_epilogue(name);
757 #define print_fcntl64 print_fcntl
761 #ifdef TARGET_NR_futimesat
763 print_futimesat(const struct syscallname *name,
764 abi_long arg0, abi_long arg1, abi_long arg2,
765 abi_long arg3, abi_long arg4, abi_long arg5)
767 print_syscall_prologue(name);
768 print_at_dirfd(arg0, 0);
769 print_string(arg1, 0);
770 print_timeval(arg2, 0);
771 print_timeval(arg2 + sizeof (struct target_timeval), 1);
772 print_syscall_epilogue(name);
776 #ifdef TARGET_NR_link
778 print_link(const struct syscallname *name,
779 abi_long arg0, abi_long arg1, abi_long arg2,
780 abi_long arg3, abi_long arg4, abi_long arg5)
782 print_syscall_prologue(name);
783 print_string(arg0, 0);
784 print_string(arg1, 1);
785 print_syscall_epilogue(name);
789 #ifdef TARGET_NR_linkat
791 print_linkat(const struct syscallname *name,
792 abi_long arg0, abi_long arg1, abi_long arg2,
793 abi_long arg3, abi_long arg4, abi_long arg5)
795 print_syscall_prologue(name);
796 print_at_dirfd(arg0, 0);
797 print_string(arg1, 0);
798 print_at_dirfd(arg2, 0);
799 print_string(arg3, 0);
800 print_flags(at_file_flags, arg4, 1);
801 print_syscall_epilogue(name);
805 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
806 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
808 print_stat(const struct syscallname *name,
809 abi_long arg0, abi_long arg1, abi_long arg2,
810 abi_long arg3, abi_long arg4, abi_long arg5)
812 print_syscall_prologue(name);
813 print_string(arg0, 0);
814 print_pointer(arg1, 1);
815 print_syscall_epilogue(name);
817 #define print_lstat print_stat
818 #define print_stat64 print_stat
819 #define print_lstat64 print_stat
822 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
824 print_fstat(const struct syscallname *name,
825 abi_long arg0, abi_long arg1, abi_long arg2,
826 abi_long arg3, abi_long arg4, abi_long arg5)
828 print_syscall_prologue(name);
829 print_raw_param("%d", tswap32(arg0), 0);
830 print_pointer(arg1, 1);
831 print_syscall_epilogue(name);
833 #define print_fstat64 print_fstat
836 #ifdef TARGET_NR_mkdir
838 print_mkdir(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_string(arg0, 0);
844 print_file_mode(arg1, 1);
845 print_syscall_epilogue(name);
849 #ifdef TARGET_NR_mkdirat
851 print_mkdirat(const struct syscallname *name,
852 abi_long arg0, abi_long arg1, abi_long arg2,
853 abi_long arg3, abi_long arg4, abi_long arg5)
855 print_syscall_prologue(name);
856 print_at_dirfd(arg0, 0);
857 print_string(arg1, 0);
858 print_file_mode(arg2, 1);
859 print_syscall_epilogue(name);
863 #ifdef TARGET_NR_mknod
865 print_mknod(const struct syscallname *name,
866 abi_long arg0, abi_long arg1, abi_long arg2,
867 abi_long arg3, abi_long arg4, abi_long arg5)
869 int hasdev = (tswapl(arg1) & (S_IFCHR|S_IFBLK));
871 print_syscall_prologue(name);
872 print_string(arg0, 0);
873 print_file_mode(arg1, (hasdev == 0));
875 print_raw_param("makedev(%d", major(tswapl(arg2)), 0);
876 print_raw_param("%d)", minor(tswapl(arg2)), 1);
878 print_syscall_epilogue(name);
882 #ifdef TARGET_NR_mknodat
884 print_mknodat(const struct syscallname *name,
885 abi_long arg0, abi_long arg1, abi_long arg2,
886 abi_long arg3, abi_long arg4, abi_long arg5)
888 int hasdev = (tswapl(arg2) & (S_IFCHR|S_IFBLK));
890 print_syscall_prologue(name);
891 print_at_dirfd(arg0, 0);
892 print_string(arg1, 0);
893 print_file_mode(arg2, (hasdev == 0));
895 print_raw_param("makedev(%d", major(tswapl(arg3)), 0);
896 print_raw_param("%d)", minor(tswapl(arg3)), 1);
898 print_syscall_epilogue(name);
902 #ifdef TARGET_NR_mq_open
904 print_mq_open(const struct syscallname *name,
905 abi_long arg0, abi_long arg1, abi_long arg2,
906 abi_long arg3, abi_long arg4, abi_long arg5)
908 int is_creat = (tswapl(arg1) & TARGET_O_CREAT);
910 print_syscall_prologue(name);
911 print_string(arg0, 0);
912 print_open_flags(arg1, (is_creat == 0));
914 print_file_mode(arg2, 0);
915 print_pointer(arg3, 1);
917 print_syscall_epilogue(name);
921 #ifdef TARGET_NR_open
923 print_open(const struct syscallname *name,
924 abi_long arg0, abi_long arg1, abi_long arg2,
925 abi_long arg3, abi_long arg4, abi_long arg5)
927 int is_creat = (tswap32(arg1) & TARGET_O_CREAT);
929 print_syscall_prologue(name);
930 print_string(arg0, 0);
931 print_open_flags(arg1, (is_creat == 0));
933 print_file_mode(arg2, 1);
934 print_syscall_epilogue(name);
938 #ifdef TARGET_NR_openat
940 print_openat(const struct syscallname *name,
941 abi_long arg0, abi_long arg1, abi_long arg2,
942 abi_long arg3, abi_long arg4, abi_long arg5)
944 int is_creat = (tswap32(arg2) & TARGET_O_CREAT);
946 print_syscall_prologue(name);
947 print_at_dirfd(arg0, 0);
948 print_string(arg1, 0);
949 print_open_flags(arg2, (is_creat == 0));
951 print_file_mode(arg3, 1);
952 print_syscall_epilogue(name);
956 #ifdef TARGET_NR_mq_unlink
958 print_mq_unlink(const struct syscallname *name,
959 abi_long arg0, abi_long arg1, abi_long arg2,
960 abi_long arg3, abi_long arg4, abi_long arg5)
962 print_syscall_prologue(name);
963 print_string(arg0, 1);
964 print_syscall_epilogue(name);
968 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
970 print_fstatat64(const struct syscallname *name,
971 abi_long arg0, abi_long arg1, abi_long arg2,
972 abi_long arg3, abi_long arg4, abi_long arg5)
974 print_syscall_prologue(name);
975 print_at_dirfd(arg0, 0);
976 print_string(arg1, 0);
977 print_pointer(arg2, 0);
978 print_flags(at_file_flags, arg3, 1);
979 print_syscall_epilogue(name);
981 #define print_newfstatat print_fstatat64
984 #ifdef TARGET_NR_readlink
986 print_readlink(const struct syscallname *name,
987 abi_long arg0, abi_long arg1, abi_long arg2,
988 abi_long arg3, abi_long arg4, abi_long arg5)
990 print_syscall_prologue(name);
991 print_string(arg0, 0);
992 print_pointer(arg1, 0);
993 print_raw_param("%u", tswapl(arg2), 1);
994 print_syscall_epilogue(name);
998 #ifdef TARGET_NR_readlinkat
1000 print_readlinkat(const struct syscallname *name,
1001 abi_long arg0, abi_long arg1, abi_long arg2,
1002 abi_long arg3, abi_long arg4, abi_long arg5)
1004 print_syscall_prologue(name);
1005 print_at_dirfd(arg0, 0);
1006 print_string(arg1, 0);
1007 print_pointer(arg2, 0);
1008 print_raw_param("%u", tswapl(arg3), 1);
1009 print_syscall_epilogue(name);
1013 #ifdef TARGET_NR_rename
1015 print_rename(const struct syscallname *name,
1016 abi_long arg0, abi_long arg1, abi_long arg2,
1017 abi_long arg3, abi_long arg4, abi_long arg5)
1019 print_syscall_prologue(name);
1020 print_string(arg0, 0);
1021 print_string(arg1, 1);
1022 print_syscall_epilogue(name);
1026 #ifdef TARGET_NR_renameat
1028 print_renameat(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 print_syscall_prologue(name);
1033 print_at_dirfd(arg0, 0);
1034 print_string(arg1, 0);
1035 print_at_dirfd(arg2, 0);
1036 print_string(arg3, 1);
1037 print_syscall_epilogue(name);
1041 #ifdef TARGET_NR_statfs
1043 print_statfs(const struct syscallname *name,
1044 abi_long arg0, abi_long arg1, abi_long arg2,
1045 abi_long arg3, abi_long arg4, abi_long arg5)
1047 print_syscall_prologue(name);
1048 print_string(arg0, 0);
1049 print_pointer(arg1, 1);
1050 print_syscall_epilogue(name);
1052 #define print_statfs64 print_statfs
1055 #ifdef TARGET_NR_symlink
1057 print_symlink(const struct syscallname *name,
1058 abi_long arg0, abi_long arg1, abi_long arg2,
1059 abi_long arg3, abi_long arg4, abi_long arg5)
1061 print_syscall_prologue(name);
1062 print_string(arg0, 0);
1063 print_string(arg1, 1);
1064 print_syscall_epilogue(name);
1068 #ifdef TARGET_NR_symlinkat
1070 print_symlinkat(const struct syscallname *name,
1071 abi_long arg0, abi_long arg1, abi_long arg2,
1072 abi_long arg3, abi_long arg4, abi_long arg5)
1074 print_syscall_prologue(name);
1075 print_string(arg0, 0);
1076 print_at_dirfd(arg1, 0);
1077 print_string(arg2, 1);
1078 print_syscall_epilogue(name);
1082 #ifdef TARGET_NR_mount
1084 print_mount(const struct syscallname *name,
1085 abi_long arg0, abi_long arg1, abi_long arg2,
1086 abi_long arg3, abi_long arg4, abi_long arg5)
1088 print_syscall_prologue(name);
1089 print_string(arg0, 0);
1090 print_string(arg1, 0);
1091 print_string(arg2, 0);
1092 print_flags(mount_flags, arg3, 0);
1093 print_pointer(arg4, 1);
1094 print_syscall_epilogue(name);
1098 #ifdef TARGET_NR_umount
1100 print_umount(const struct syscallname *name,
1101 abi_long arg0, abi_long arg1, abi_long arg2,
1102 abi_long arg3, abi_long arg4, abi_long arg5)
1104 print_syscall_prologue(name);
1105 print_string(arg0, 1);
1106 print_syscall_epilogue(name);
1110 #ifdef TARGET_NR_umount2
1112 print_umount2(const struct syscallname *name,
1113 abi_long arg0, abi_long arg1, abi_long arg2,
1114 abi_long arg3, abi_long arg4, abi_long arg5)
1116 print_syscall_prologue(name);
1117 print_string(arg0, 0);
1118 print_flags(umount2_flags, arg1, 1);
1119 print_syscall_epilogue(name);
1123 #ifdef TARGET_NR_unlink
1125 print_unlink(const struct syscallname *name,
1126 abi_long arg0, abi_long arg1, abi_long arg2,
1127 abi_long arg3, abi_long arg4, abi_long arg5)
1129 print_syscall_prologue(name);
1130 print_string(arg0, 1);
1131 print_syscall_epilogue(name);
1135 #ifdef TARGET_NR_unlinkat
1137 print_unlinkat(const struct syscallname *name,
1138 abi_long arg0, abi_long arg1, abi_long arg2,
1139 abi_long arg3, abi_long arg4, abi_long arg5)
1141 print_syscall_prologue(name);
1142 print_at_dirfd(arg0, 0);
1143 print_string(arg1, 0);
1144 print_flags(unlinkat_flags, arg2, 1);
1145 print_syscall_epilogue(name);
1149 #ifdef TARGET_NR_utime
1151 print_utime(const struct syscallname *name,
1152 abi_long arg0, abi_long arg1, abi_long arg2,
1153 abi_long arg3, abi_long arg4, abi_long arg5)
1155 print_syscall_prologue(name);
1156 print_string(arg0, 0);
1157 print_pointer(arg1, 1);
1158 print_syscall_epilogue(name);
1162 #ifdef TARGET_NR_utimes
1164 print_utimes(const struct syscallname *name,
1165 abi_long arg0, abi_long arg1, abi_long arg2,
1166 abi_long arg3, abi_long arg4, abi_long arg5)
1168 print_syscall_prologue(name);
1169 print_string(arg0, 0);
1170 print_pointer(arg1, 1);
1171 print_syscall_epilogue(name);
1175 #ifdef TARGET_NR_utimensat
1177 print_utimensat(const struct syscallname *name,
1178 abi_long arg0, abi_long arg1, abi_long arg2,
1179 abi_long arg3, abi_long arg4, abi_long arg5)
1181 print_syscall_prologue(name);
1182 print_at_dirfd(arg0, 0);
1183 print_string(arg1, 0);
1184 print_pointer(arg2, 0);
1185 print_flags(at_file_flags, arg3, 1);
1186 print_syscall_epilogue(name);
1190 #ifdef TARGET_NR_mmap
1192 print_mmap(const struct syscallname *name,
1193 abi_long arg0, abi_long arg1, abi_long arg2,
1194 abi_long arg3, abi_long arg4, abi_long arg5)
1196 print_syscall_prologue(name);
1197 print_pointer(arg0, 0);
1198 print_raw_param("%d", tswapl(arg1), 0);
1199 print_flags(mmap_prot_flags, arg2, 0);
1200 print_flags(mmap_flags, arg3, 0);
1201 print_raw_param("%d", tswapl(arg4), 0);
1202 print_raw_param("%#x", tswapl(arg5), 1);
1203 print_syscall_epilogue(name);
1205 #define print_mmap2 print_mmap
1208 #ifdef TARGET_NR_mprotect
1210 print_mprotect(const struct syscallname *name,
1211 abi_long arg0, abi_long arg1, abi_long arg2,
1212 abi_long arg3, abi_long arg4, abi_long arg5)
1214 print_syscall_prologue(name);
1215 print_pointer(arg0, 0);
1216 print_raw_param("%d", tswapl(arg1), 0);
1217 print_flags(mmap_prot_flags, arg2, 1);
1218 print_syscall_epilogue(name);
1222 #ifdef TARGET_NR_munmap
1224 print_munmap(const struct syscallname *name,
1225 abi_long arg0, abi_long arg1, abi_long arg2,
1226 abi_long arg3, abi_long arg4, abi_long arg5)
1228 print_syscall_prologue(name);
1229 print_pointer(arg0, 0);
1230 print_raw_param("%d", tswapl(arg1), 1);
1231 print_syscall_epilogue(name);
1236 * An array of all of the syscalls we know about
1239 static const struct syscallname scnames[] = {
1240 #include "strace.list"
1243 static int nsyscalls = ARRAY_SIZE(scnames);
1246 * The public interface to this module.
1249 print_syscall(int num,
1250 abi_long arg1, abi_long arg2, abi_long arg3,
1251 abi_long arg4, abi_long arg5, abi_long arg6)
1254 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 ")";
1256 gemu_log("%d ", getpid() );
1258 for(i=0;i<nsyscalls;i++)
1259 if( scnames[i].nr == num ) {
1260 if( scnames[i].call != NULL ) {
1261 scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6);
1263 /* XXX: this format system is broken because it uses
1264 host types and host pointers for strings */
1265 if( scnames[i].format != NULL )
1266 format = scnames[i].format;
1267 gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6);
1271 gemu_log("Unknown syscall %d\n", num);
1276 print_syscall_ret(int num, abi_long ret)
1280 for(i=0;i<nsyscalls;i++)
1281 if( scnames[i].nr == num ) {
1282 if( scnames[i].result != NULL ) {
1283 scnames[i].result(&scnames[i],ret);
1286 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", -ret, target_strerror(-ret));
1288 gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);