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
[] = {
295 FLAG_GENERIC(AT_EACCESS
),
297 #ifdef AT_SYMLINK_NOFOLLOW
298 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
303 UNUSED
static struct flags unlinkat_flags
[] = {
305 FLAG_GENERIC(AT_REMOVEDIR
),
310 UNUSED
static struct flags mode_flags
[] = {
311 FLAG_GENERIC(S_IFSOCK
),
312 FLAG_GENERIC(S_IFLNK
),
313 FLAG_GENERIC(S_IFREG
),
314 FLAG_GENERIC(S_IFBLK
),
315 FLAG_GENERIC(S_IFDIR
),
316 FLAG_GENERIC(S_IFCHR
),
317 FLAG_GENERIC(S_IFIFO
),
321 UNUSED
static struct flags open_access_flags
[] = {
322 FLAG_TARGET(O_RDONLY
),
323 FLAG_TARGET(O_WRONLY
),
328 UNUSED
static struct flags open_flags
[] = {
329 FLAG_TARGET(O_APPEND
),
330 FLAG_TARGET(O_CREAT
),
331 FLAG_TARGET(O_DIRECTORY
),
333 FLAG_TARGET(O_LARGEFILE
),
334 FLAG_TARGET(O_NOCTTY
),
335 FLAG_TARGET(O_NOFOLLOW
),
336 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
338 FLAG_TARGET(O_TRUNC
),
340 FLAG_TARGET(O_DIRECT
),
345 UNUSED
static struct flags mount_flags
[] = {
347 FLAG_GENERIC(MS_BIND
),
350 FLAG_GENERIC(MS_DIRSYNC
),
352 FLAG_GENERIC(MS_MANDLOCK
),
354 FLAG_GENERIC(MS_MOVE
),
356 FLAG_GENERIC(MS_NOATIME
),
357 FLAG_GENERIC(MS_NODEV
),
358 FLAG_GENERIC(MS_NODIRATIME
),
359 FLAG_GENERIC(MS_NOEXEC
),
360 FLAG_GENERIC(MS_NOSUID
),
361 FLAG_GENERIC(MS_RDONLY
),
363 FLAG_GENERIC(MS_RELATIME
),
365 FLAG_GENERIC(MS_REMOUNT
),
366 FLAG_GENERIC(MS_SYNCHRONOUS
),
370 UNUSED
static struct flags umount2_flags
[] = {
372 FLAG_GENERIC(MNT_FORCE
),
375 FLAG_GENERIC(MNT_DETACH
),
378 FLAG_GENERIC(MNT_EXPIRE
),
383 UNUSED
static struct flags mmap_prot_flags
[] = {
384 FLAG_GENERIC(PROT_NONE
),
385 FLAG_GENERIC(PROT_EXEC
),
386 FLAG_GENERIC(PROT_READ
),
387 FLAG_GENERIC(PROT_WRITE
),
388 FLAG_TARGET(PROT_SEM
),
389 FLAG_GENERIC(PROT_GROWSDOWN
),
390 FLAG_GENERIC(PROT_GROWSUP
),
394 UNUSED
static struct flags mmap_flags
[] = {
395 FLAG_TARGET(MAP_SHARED
),
396 FLAG_TARGET(MAP_PRIVATE
),
397 FLAG_TARGET(MAP_ANONYMOUS
),
398 FLAG_TARGET(MAP_DENYWRITE
),
399 FLAG_TARGET(MAP_FIXED
),
400 FLAG_TARGET(MAP_GROWSDOWN
),
401 FLAG_TARGET(MAP_EXECUTABLE
),
403 FLAG_TARGET(MAP_LOCKED
),
406 FLAG_TARGET(MAP_NONBLOCK
),
408 FLAG_TARGET(MAP_NORESERVE
),
410 FLAG_TARGET(MAP_POPULATE
),
412 #ifdef TARGET_MAP_UNINITIALIZED
413 FLAG_TARGET(MAP_UNINITIALIZED
),
418 UNUSED
static struct flags fcntl_flags
[] = {
419 FLAG_TARGET(F_DUPFD
),
420 FLAG_TARGET(F_GETFD
),
421 FLAG_TARGET(F_SETFD
),
422 FLAG_TARGET(F_GETFL
),
423 FLAG_TARGET(F_SETFL
),
424 FLAG_TARGET(F_GETLK
),
425 FLAG_TARGET(F_SETLK
),
426 FLAG_TARGET(F_SETLKW
),
431 * print_xxx utility functions. These are used to print syscall
432 * parameters in certain format. All of these have parameter
433 * named 'last'. This parameter is used to add comma to output
440 return ((last
) ? "" : ",");
444 print_flags(const struct flags
*f
, abi_long tflags
, int last
)
446 const char *sep
= "";
450 flags
= (int)tswap32(tflags
);
452 if ((flags
== 0) && (f
->f_value
== 0)) {
453 gemu_log("%s%s", f
->f_string
, get_comma(last
));
456 for (n
= 0; f
->f_string
!= NULL
; f
++) {
457 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
458 gemu_log("%s%s", sep
, f
->f_string
);
459 flags
&= ~f
->f_value
;
466 /* print rest of the flags as numeric */
468 gemu_log("%s%#x%s", sep
, flags
, get_comma(last
));
470 gemu_log("%s", get_comma(last
));
473 /* no string version of flags found, print them in hex then */
474 gemu_log("%#x%s", flags
, get_comma(last
));
479 print_at_dirfd(abi_long tdirfd
, int last
)
481 int dirfd
= tswap32(tdirfd
);
484 if (dirfd
== AT_FDCWD
) {
485 gemu_log("AT_FDCWD%s", get_comma(last
));
489 gemu_log("%d%s", dirfd
, get_comma(last
));
493 print_file_mode(abi_long tmode
, int last
)
495 const char *sep
= "";
496 const struct flags
*m
;
497 mode_t mode
= (mode_t
)tswap32(tmode
);
499 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
500 if ((m
->f_value
& mode
) == m
->f_value
) {
501 gemu_log("%s%s", m
->f_string
, sep
);
509 /* print rest of the mode as octal */
511 gemu_log("%s%#o", sep
, mode
);
513 gemu_log("%s", get_comma(last
));
517 print_open_flags(abi_long tflags
, int last
)
519 int flags
= tswap32(tflags
);
521 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
522 flags
&= ~TARGET_O_ACCMODE
;
524 gemu_log("%s", get_comma(last
));
528 print_flags(open_flags
, flags
, last
);
532 print_syscall_prologue(const struct syscallname
*sc
)
534 gemu_log("%s(", sc
->name
);
539 print_syscall_epilogue(const struct syscallname
*sc
)
546 print_string(abi_long addr
, int last
)
550 if ((s
= lock_user_string(addr
)) != NULL
) {
551 gemu_log("\"%s\"%s", s
, get_comma(last
));
552 unlock_user(s
, addr
, 0);
554 /* can't get string out of it, so print it as pointer */
555 print_pointer(addr
, last
);
560 * Prints out raw parameter using given format. Caller needs
561 * to do byte swapping if needed.
564 print_raw_param(const char *fmt
, abi_long param
, int last
)
568 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
569 gemu_log(format
, param
);
573 print_pointer(abi_long p
, int last
)
576 gemu_log("NULL%s", get_comma(last
));
578 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
582 * Reads 32-bit (int) number from guest address space from
583 * address 'addr' and prints it.
586 print_number(abi_long addr
, int last
)
589 gemu_log("NULL%s", get_comma(last
));
593 get_user_s32(num
, addr
);
594 gemu_log("[%d]%s", num
, get_comma(last
));
599 print_timeval(abi_ulong tv_addr
, int last
)
602 struct target_timeval
*tv
;
604 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
607 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
608 tv
->tv_sec
, tv
->tv_usec
, get_comma(last
));
609 unlock_user(tv
, tv_addr
, 0);
611 gemu_log("NULL%s", get_comma(last
));
616 #ifdef TARGET_NR_accept
618 print_accept(const struct syscallname
*name
,
619 abi_long arg0
, abi_long arg1
, abi_long arg2
,
620 abi_long arg3
, abi_long arg4
, abi_long arg5
)
622 print_syscall_prologue(name
);
623 print_raw_param("%d", tswap32(arg0
), 0);
624 print_pointer(arg1
, 0);
625 print_number(arg2
, 1);
626 print_syscall_epilogue(name
);
630 #ifdef TARGET_NR_access
632 print_access(const struct syscallname
*name
,
633 abi_long arg0
, abi_long arg1
, abi_long arg2
,
634 abi_long arg3
, abi_long arg4
, abi_long arg5
)
636 print_syscall_prologue(name
);
637 print_string(arg0
, 0);
638 print_flags(access_flags
, arg1
, 1);
639 print_syscall_epilogue(name
);
645 print_brk(const struct syscallname
*name
,
646 abi_long arg0
, abi_long arg1
, abi_long arg2
,
647 abi_long arg3
, abi_long arg4
, abi_long arg5
)
649 print_syscall_prologue(name
);
650 print_pointer(arg0
, 1);
651 print_syscall_epilogue(name
);
655 #ifdef TARGET_NR_chdir
657 print_chdir(const struct syscallname
*name
,
658 abi_long arg0
, abi_long arg1
, abi_long arg2
,
659 abi_long arg3
, abi_long arg4
, abi_long arg5
)
661 print_syscall_prologue(name
);
662 print_string(arg0
, 1);
663 print_syscall_epilogue(name
);
667 #ifdef TARGET_NR_chmod
669 print_chmod(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_string(arg0
, 0);
675 print_file_mode(arg1
, 1);
676 print_syscall_epilogue(name
);
680 #ifdef TARGET_NR_creat
682 print_creat(const struct syscallname
*name
,
683 abi_long arg0
, abi_long arg1
, abi_long arg2
,
684 abi_long arg3
, abi_long arg4
, abi_long arg5
)
686 print_syscall_prologue(name
);
687 print_string(arg0
, 0);
688 print_file_mode(arg1
, 1);
689 print_syscall_epilogue(name
);
693 #ifdef TARGET_NR_execv
695 print_execv(const struct syscallname
*name
,
696 abi_long arg0
, abi_long arg1
, abi_long arg2
,
697 abi_long arg3
, abi_long arg4
, abi_long arg5
)
699 print_syscall_prologue(name
);
700 print_string(arg0
, 0);
701 print_raw_param("0x" TARGET_ABI_FMT_lx
, tswapl(arg1
), 1);
702 print_syscall_epilogue(name
);
706 #ifdef TARGET_NR_faccessat
708 print_faccessat(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_at_dirfd(arg0
, 0);
714 print_string(arg1
, 0);
715 print_flags(access_flags
, arg2
, 0);
716 print_flags(at_file_flags
, arg3
, 1);
717 print_syscall_epilogue(name
);
721 #ifdef TARGET_NR_fchmodat
723 print_fchmodat(const struct syscallname
*name
,
724 abi_long arg0
, abi_long arg1
, abi_long arg2
,
725 abi_long arg3
, abi_long arg4
, abi_long arg5
)
727 print_syscall_prologue(name
);
728 print_at_dirfd(arg0
, 0);
729 print_string(arg1
, 0);
730 print_file_mode(arg2
, 0);
731 print_flags(at_file_flags
, arg3
, 1);
732 print_syscall_epilogue(name
);
736 #ifdef TARGET_NR_fchownat
738 print_fchownat(const struct syscallname
*name
,
739 abi_long arg0
, abi_long arg1
, abi_long arg2
,
740 abi_long arg3
, abi_long arg4
, abi_long arg5
)
742 print_syscall_prologue(name
);
743 print_at_dirfd(arg0
, 0);
744 print_string(arg1
, 0);
746 print_raw_param("%d", tswap16(arg2
), 0);
747 print_raw_param("%d", tswap16(arg3
), 0);
749 print_raw_param("%d", tswap32(arg2
), 0);
750 print_raw_param("%d", tswap32(arg3
), 0);
752 print_flags(at_file_flags
, arg4
, 1);
753 print_syscall_epilogue(name
);
757 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
759 print_fcntl(const struct syscallname
*name
,
760 abi_long arg0
, abi_long arg1
, abi_long arg2
,
761 abi_long arg3
, abi_long arg4
, abi_long arg5
)
763 print_syscall_prologue(name
);
764 print_raw_param("%d", tswap32(arg0
), 0);
765 print_flags(fcntl_flags
, arg1
, 0);
767 * TODO: check flags and print following argument only
770 print_pointer(arg2
, 1);
771 print_syscall_epilogue(name
);
773 #define print_fcntl64 print_fcntl
777 #ifdef TARGET_NR_futimesat
779 print_futimesat(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_at_dirfd(arg0
, 0);
785 print_string(arg1
, 0);
786 print_timeval(arg2
, 0);
787 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
788 print_syscall_epilogue(name
);
792 #ifdef TARGET_NR_link
794 print_link(const struct syscallname
*name
,
795 abi_long arg0
, abi_long arg1
, abi_long arg2
,
796 abi_long arg3
, abi_long arg4
, abi_long arg5
)
798 print_syscall_prologue(name
);
799 print_string(arg0
, 0);
800 print_string(arg1
, 1);
801 print_syscall_epilogue(name
);
805 #ifdef TARGET_NR_linkat
807 print_linkat(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_at_dirfd(arg2
, 0);
815 print_string(arg3
, 0);
816 print_flags(at_file_flags
, arg4
, 1);
817 print_syscall_epilogue(name
);
821 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
822 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
824 print_stat(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_string(arg0
, 0);
830 print_pointer(arg1
, 1);
831 print_syscall_epilogue(name
);
833 #define print_lstat print_stat
834 #define print_stat64 print_stat
835 #define print_lstat64 print_stat
838 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
840 print_fstat(const struct syscallname
*name
,
841 abi_long arg0
, abi_long arg1
, abi_long arg2
,
842 abi_long arg3
, abi_long arg4
, abi_long arg5
)
844 print_syscall_prologue(name
);
845 print_raw_param("%d", tswap32(arg0
), 0);
846 print_pointer(arg1
, 1);
847 print_syscall_epilogue(name
);
849 #define print_fstat64 print_fstat
852 #ifdef TARGET_NR_mkdir
854 print_mkdir(const struct syscallname
*name
,
855 abi_long arg0
, abi_long arg1
, abi_long arg2
,
856 abi_long arg3
, abi_long arg4
, abi_long arg5
)
858 print_syscall_prologue(name
);
859 print_string(arg0
, 0);
860 print_file_mode(arg1
, 1);
861 print_syscall_epilogue(name
);
865 #ifdef TARGET_NR_mkdirat
867 print_mkdirat(const struct syscallname
*name
,
868 abi_long arg0
, abi_long arg1
, abi_long arg2
,
869 abi_long arg3
, abi_long arg4
, abi_long arg5
)
871 print_syscall_prologue(name
);
872 print_at_dirfd(arg0
, 0);
873 print_string(arg1
, 0);
874 print_file_mode(arg2
, 1);
875 print_syscall_epilogue(name
);
879 #ifdef TARGET_NR_mknod
881 print_mknod(const struct syscallname
*name
,
882 abi_long arg0
, abi_long arg1
, abi_long arg2
,
883 abi_long arg3
, abi_long arg4
, abi_long arg5
)
885 int hasdev
= (tswapl(arg1
) & (S_IFCHR
|S_IFBLK
));
887 print_syscall_prologue(name
);
888 print_string(arg0
, 0);
889 print_file_mode(arg1
, (hasdev
== 0));
891 print_raw_param("makedev(%d", major(tswapl(arg2
)), 0);
892 print_raw_param("%d)", minor(tswapl(arg2
)), 1);
894 print_syscall_epilogue(name
);
898 #ifdef TARGET_NR_mknodat
900 print_mknodat(const struct syscallname
*name
,
901 abi_long arg0
, abi_long arg1
, abi_long arg2
,
902 abi_long arg3
, abi_long arg4
, abi_long arg5
)
904 int hasdev
= (tswapl(arg2
) & (S_IFCHR
|S_IFBLK
));
906 print_syscall_prologue(name
);
907 print_at_dirfd(arg0
, 0);
908 print_string(arg1
, 0);
909 print_file_mode(arg2
, (hasdev
== 0));
911 print_raw_param("makedev(%d", major(tswapl(arg3
)), 0);
912 print_raw_param("%d)", minor(tswapl(arg3
)), 1);
914 print_syscall_epilogue(name
);
918 #ifdef TARGET_NR_mq_open
920 print_mq_open(const struct syscallname
*name
,
921 abi_long arg0
, abi_long arg1
, abi_long arg2
,
922 abi_long arg3
, abi_long arg4
, abi_long arg5
)
924 int is_creat
= (tswapl(arg1
) & TARGET_O_CREAT
);
926 print_syscall_prologue(name
);
927 print_string(arg0
, 0);
928 print_open_flags(arg1
, (is_creat
== 0));
930 print_file_mode(arg2
, 0);
931 print_pointer(arg3
, 1);
933 print_syscall_epilogue(name
);
937 #ifdef TARGET_NR_open
939 print_open(const struct syscallname
*name
,
940 abi_long arg0
, abi_long arg1
, abi_long arg2
,
941 abi_long arg3
, abi_long arg4
, abi_long arg5
)
943 int is_creat
= (tswap32(arg1
) & TARGET_O_CREAT
);
945 print_syscall_prologue(name
);
946 print_string(arg0
, 0);
947 print_open_flags(arg1
, (is_creat
== 0));
949 print_file_mode(arg2
, 1);
950 print_syscall_epilogue(name
);
954 #ifdef TARGET_NR_openat
956 print_openat(const struct syscallname
*name
,
957 abi_long arg0
, abi_long arg1
, abi_long arg2
,
958 abi_long arg3
, abi_long arg4
, abi_long arg5
)
960 int is_creat
= (tswap32(arg2
) & TARGET_O_CREAT
);
962 print_syscall_prologue(name
);
963 print_at_dirfd(arg0
, 0);
964 print_string(arg1
, 0);
965 print_open_flags(arg2
, (is_creat
== 0));
967 print_file_mode(arg3
, 1);
968 print_syscall_epilogue(name
);
972 #ifdef TARGET_NR_mq_unlink
974 print_mq_unlink(const struct syscallname
*name
,
975 abi_long arg0
, abi_long arg1
, abi_long arg2
,
976 abi_long arg3
, abi_long arg4
, abi_long arg5
)
978 print_syscall_prologue(name
);
979 print_string(arg0
, 1);
980 print_syscall_epilogue(name
);
984 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
986 print_fstatat64(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_at_dirfd(arg0
, 0);
992 print_string(arg1
, 0);
993 print_pointer(arg2
, 0);
994 print_flags(at_file_flags
, arg3
, 1);
995 print_syscall_epilogue(name
);
997 #define print_newfstatat print_fstatat64
1000 #ifdef TARGET_NR_readlink
1002 print_readlink(const struct syscallname
*name
,
1003 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1004 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1006 print_syscall_prologue(name
);
1007 print_string(arg0
, 0);
1008 print_pointer(arg1
, 0);
1009 print_raw_param("%u", tswapl(arg2
), 1);
1010 print_syscall_epilogue(name
);
1014 #ifdef TARGET_NR_readlinkat
1016 print_readlinkat(const struct syscallname
*name
,
1017 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1018 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1020 print_syscall_prologue(name
);
1021 print_at_dirfd(arg0
, 0);
1022 print_string(arg1
, 0);
1023 print_pointer(arg2
, 0);
1024 print_raw_param("%u", tswapl(arg3
), 1);
1025 print_syscall_epilogue(name
);
1029 #ifdef TARGET_NR_rename
1031 print_rename(const struct syscallname
*name
,
1032 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1033 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1035 print_syscall_prologue(name
);
1036 print_string(arg0
, 0);
1037 print_string(arg1
, 1);
1038 print_syscall_epilogue(name
);
1042 #ifdef TARGET_NR_renameat
1044 print_renameat(const struct syscallname
*name
,
1045 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1046 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1048 print_syscall_prologue(name
);
1049 print_at_dirfd(arg0
, 0);
1050 print_string(arg1
, 0);
1051 print_at_dirfd(arg2
, 0);
1052 print_string(arg3
, 1);
1053 print_syscall_epilogue(name
);
1057 #ifdef TARGET_NR_statfs
1059 print_statfs(const struct syscallname
*name
,
1060 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1061 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1063 print_syscall_prologue(name
);
1064 print_string(arg0
, 0);
1065 print_pointer(arg1
, 1);
1066 print_syscall_epilogue(name
);
1068 #define print_statfs64 print_statfs
1071 #ifdef TARGET_NR_symlink
1073 print_symlink(const struct syscallname
*name
,
1074 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1075 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1077 print_syscall_prologue(name
);
1078 print_string(arg0
, 0);
1079 print_string(arg1
, 1);
1080 print_syscall_epilogue(name
);
1084 #ifdef TARGET_NR_symlinkat
1086 print_symlinkat(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 print_syscall_prologue(name
);
1091 print_string(arg0
, 0);
1092 print_at_dirfd(arg1
, 0);
1093 print_string(arg2
, 1);
1094 print_syscall_epilogue(name
);
1098 #ifdef TARGET_NR_mount
1100 print_mount(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
, 0);
1106 print_string(arg1
, 0);
1107 print_string(arg2
, 0);
1108 print_flags(mount_flags
, arg3
, 0);
1109 print_pointer(arg4
, 1);
1110 print_syscall_epilogue(name
);
1114 #ifdef TARGET_NR_umount
1116 print_umount(const struct syscallname
*name
,
1117 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1118 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1120 print_syscall_prologue(name
);
1121 print_string(arg0
, 1);
1122 print_syscall_epilogue(name
);
1126 #ifdef TARGET_NR_umount2
1128 print_umount2(const struct syscallname
*name
,
1129 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1130 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1132 print_syscall_prologue(name
);
1133 print_string(arg0
, 0);
1134 print_flags(umount2_flags
, arg1
, 1);
1135 print_syscall_epilogue(name
);
1139 #ifdef TARGET_NR_unlink
1141 print_unlink(const struct syscallname
*name
,
1142 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1143 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1145 print_syscall_prologue(name
);
1146 print_string(arg0
, 1);
1147 print_syscall_epilogue(name
);
1151 #ifdef TARGET_NR_unlinkat
1153 print_unlinkat(const struct syscallname
*name
,
1154 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1155 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1157 print_syscall_prologue(name
);
1158 print_at_dirfd(arg0
, 0);
1159 print_string(arg1
, 0);
1160 print_flags(unlinkat_flags
, arg2
, 1);
1161 print_syscall_epilogue(name
);
1165 #ifdef TARGET_NR_utime
1167 print_utime(const struct syscallname
*name
,
1168 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1169 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1171 print_syscall_prologue(name
);
1172 print_string(arg0
, 0);
1173 print_pointer(arg1
, 1);
1174 print_syscall_epilogue(name
);
1178 #ifdef TARGET_NR_utimes
1180 print_utimes(const struct syscallname
*name
,
1181 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1182 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1184 print_syscall_prologue(name
);
1185 print_string(arg0
, 0);
1186 print_pointer(arg1
, 1);
1187 print_syscall_epilogue(name
);
1191 #ifdef TARGET_NR_utimensat
1193 print_utimensat(const struct syscallname
*name
,
1194 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1195 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1197 print_syscall_prologue(name
);
1198 print_at_dirfd(arg0
, 0);
1199 print_string(arg1
, 0);
1200 print_pointer(arg2
, 0);
1201 print_flags(at_file_flags
, arg3
, 1);
1202 print_syscall_epilogue(name
);
1206 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
1208 print_mmap(const struct syscallname
*name
,
1209 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1210 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1212 print_syscall_prologue(name
);
1213 print_pointer(arg0
, 0);
1214 print_raw_param("%d", tswapl(arg1
), 0);
1215 print_flags(mmap_prot_flags
, arg2
, 0);
1216 print_flags(mmap_flags
, arg3
, 0);
1217 print_raw_param("%d", tswapl(arg4
), 0);
1218 print_raw_param("%#x", tswapl(arg5
), 1);
1219 print_syscall_epilogue(name
);
1221 #define print_mmap2 print_mmap
1224 #ifdef TARGET_NR_mprotect
1226 print_mprotect(const struct syscallname
*name
,
1227 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1228 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1230 print_syscall_prologue(name
);
1231 print_pointer(arg0
, 0);
1232 print_raw_param("%d", tswapl(arg1
), 0);
1233 print_flags(mmap_prot_flags
, arg2
, 1);
1234 print_syscall_epilogue(name
);
1238 #ifdef TARGET_NR_munmap
1240 print_munmap(const struct syscallname
*name
,
1241 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1242 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1244 print_syscall_prologue(name
);
1245 print_pointer(arg0
, 0);
1246 print_raw_param("%d", tswapl(arg1
), 1);
1247 print_syscall_epilogue(name
);
1251 #ifdef TARGET_NR_futex
1252 static void print_futex_op(abi_long tflag
, int last
)
1254 #define print_op(val) \
1255 if( cmd == val ) { \
1260 int cmd
= (int)tswap32(tflag
);
1261 #ifdef FUTEX_PRIVATE_FLAG
1262 if (cmd
& FUTEX_PRIVATE_FLAG
) {
1263 gemu_log("FUTEX_PRIVATE_FLAG|");
1264 cmd
&= ~FUTEX_PRIVATE_FLAG
;
1267 print_op(FUTEX_WAIT
)
1268 print_op(FUTEX_WAKE
)
1270 print_op(FUTEX_REQUEUE
)
1271 print_op(FUTEX_CMP_REQUEUE
)
1272 print_op(FUTEX_WAKE_OP
)
1273 print_op(FUTEX_LOCK_PI
)
1274 print_op(FUTEX_UNLOCK_PI
)
1275 print_op(FUTEX_TRYLOCK_PI
)
1276 #ifdef FUTEX_WAIT_BITSET
1277 print_op(FUTEX_WAIT_BITSET
)
1279 #ifdef FUTEX_WAKE_BITSET
1280 print_op(FUTEX_WAKE_BITSET
)
1282 /* unknown values */
1287 print_futex(const struct syscallname
*name
,
1288 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1289 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1291 print_syscall_prologue(name
);
1292 print_pointer(arg0
, 0);
1293 print_futex_op(arg1
, 0);
1294 print_raw_param(",%d", tswapl(arg2
), 0);
1295 print_pointer(arg3
, 0); /* struct timespec */
1296 print_pointer(arg4
, 0);
1297 print_raw_param("%d", tswapl(arg4
), 1);
1298 print_syscall_epilogue(name
);
1303 * An array of all of the syscalls we know about
1306 static const struct syscallname scnames
[] = {
1307 #include "strace.list"
1310 static int nsyscalls
= ARRAY_SIZE(scnames
);
1313 * The public interface to this module.
1316 print_syscall(int num
,
1317 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1318 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1321 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
")";
1323 gemu_log("%d ", getpid() );
1325 for(i
=0;i
<nsyscalls
;i
++)
1326 if( scnames
[i
].nr
== num
) {
1327 if( scnames
[i
].call
!= NULL
) {
1328 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1330 /* XXX: this format system is broken because it uses
1331 host types and host pointers for strings */
1332 if( scnames
[i
].format
!= NULL
)
1333 format
= scnames
[i
].format
;
1334 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1338 gemu_log("Unknown syscall %d\n", num
);
1343 print_syscall_ret(int num
, abi_long ret
)
1347 for(i
=0;i
<nsyscalls
;i
++)
1348 if( scnames
[i
].nr
== num
) {
1349 if( scnames
[i
].result
!= NULL
) {
1350 scnames
[i
].result(&scnames
[i
],ret
);
1353 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n", -ret
, target_strerror(-ret
));
1355 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);