7 #include <sys/select.h>
11 #include <linux/futex.h>
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
);
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))
40 * Structure used to translate flag values into strings. This is
41 * similar that is in the actual strace tool.
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);
72 print_ipc_cmd(int cmd
)
74 #define output_cmd(val) \
82 /* General IPC commands */
83 output_cmd( IPC_RMID
);
84 output_cmd( IPC_SET
);
85 output_cmd( IPC_STAT
);
86 output_cmd( IPC_INFO
);
87 /* msgctl() commands */
89 output_cmd( MSG_STAT
);
90 output_cmd( MSG_INFO
);
92 /* shmctl() commands */
93 output_cmd( SHM_LOCK
);
94 output_cmd( SHM_UNLOCK
);
95 output_cmd( SHM_STAT
);
96 output_cmd( SHM_INFO
);
97 /* semctl() commands */
100 output_cmd( GETALL
);
101 output_cmd( GETNCNT
);
102 output_cmd( GETZCNT
);
103 output_cmd( SETVAL
);
104 output_cmd( SETALL
);
105 output_cmd( SEM_STAT
);
106 output_cmd( SEM_INFO
);
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
);
115 output_cmd( IPC_RMID
);
117 /* Some value we don't recognize */
121 #ifdef TARGET_NR__newselect
123 print_fdset(int n
, abi_ulong target_fds_addr
)
128 if( target_fds_addr
) {
129 abi_long
*target_fds
;
131 target_fds
= lock_user(VERIFY_READ
,
133 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
139 for (i
=n
; i
>=0; i
--) {
140 if ((tswapl(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
143 unlock_user(target_fds
, target_fds_addr
, 0);
150 * Sysycall specific output functions
154 #ifdef TARGET_NR__newselect
155 static long newselect_arg1
= 0;
156 static long newselect_arg2
= 0;
157 static long newselect_arg3
= 0;
158 static long newselect_arg4
= 0;
159 static long newselect_arg5
= 0;
162 print_newselect(const struct syscallname
*name
,
163 abi_long arg1
, abi_long arg2
, abi_long arg3
,
164 abi_long arg4
, abi_long arg5
, abi_long arg6
)
166 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
167 print_fdset(arg1
, arg2
);
169 print_fdset(arg1
, arg3
);
171 print_fdset(arg1
, arg4
);
173 print_timeval(arg5
, 1);
176 /* save for use in the return output function below */
185 #ifdef TARGET_NR_semctl
187 print_semctl(const struct syscallname
*name
,
188 abi_long arg1
, abi_long arg2
, abi_long arg3
,
189 abi_long arg4
, abi_long arg5
, abi_long arg6
)
191 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
193 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
198 print_execve(const struct syscallname
*name
,
199 abi_long arg1
, abi_long arg2
, abi_long arg3
,
200 abi_long arg4
, abi_long arg5
, abi_long arg6
)
202 abi_ulong arg_ptr_addr
;
205 if (!(s
= lock_user_string(arg1
)))
207 gemu_log("%s(\"%s\",{", name
->name
, s
);
208 unlock_user(s
, arg1
, 0);
210 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
211 abi_ulong
*arg_ptr
, arg_addr
;
213 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
216 arg_addr
= tswapl(*arg_ptr
);
217 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
220 if ((s
= lock_user_string(arg_addr
))) {
221 gemu_log("\"%s\",", s
);
222 unlock_user(s
, arg_addr
, 0);
231 print_ipc(const struct syscallname
*name
,
232 abi_long arg1
, abi_long arg2
, abi_long arg3
,
233 abi_long arg4
, abi_long arg5
, abi_long arg6
)
237 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
239 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
242 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
243 name
->name
, arg1
, arg2
, arg3
, arg4
);
249 * Variants for the return value output function
253 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
256 gemu_log(" = -1 errno=%d (%s)\n", errno
, target_strerror(errno
));
258 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
262 #if 0 /* currently unused */
264 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
266 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
270 #ifdef TARGET_NR__newselect
272 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
274 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
275 print_fdset(newselect_arg1
,newselect_arg2
);
277 print_fdset(newselect_arg1
,newselect_arg3
);
279 print_fdset(newselect_arg1
,newselect_arg4
);
281 print_timeval(newselect_arg5
, 1);
286 UNUSED
static struct flags access_flags
[] = {
294 UNUSED
static struct flags at_file_flags
[] = {
296 FLAG_GENERIC(AT_EACCESS
),
298 #ifdef AT_SYMLINK_NOFOLLOW
299 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
304 UNUSED
static struct flags unlinkat_flags
[] = {
306 FLAG_GENERIC(AT_REMOVEDIR
),
311 UNUSED
static struct flags mode_flags
[] = {
312 FLAG_GENERIC(S_IFSOCK
),
313 FLAG_GENERIC(S_IFLNK
),
314 FLAG_GENERIC(S_IFREG
),
315 FLAG_GENERIC(S_IFBLK
),
316 FLAG_GENERIC(S_IFDIR
),
317 FLAG_GENERIC(S_IFCHR
),
318 FLAG_GENERIC(S_IFIFO
),
322 UNUSED
static struct flags open_access_flags
[] = {
323 FLAG_TARGET(O_RDONLY
),
324 FLAG_TARGET(O_WRONLY
),
329 UNUSED
static struct flags open_flags
[] = {
330 FLAG_TARGET(O_APPEND
),
331 FLAG_TARGET(O_CREAT
),
332 FLAG_TARGET(O_DIRECTORY
),
334 FLAG_TARGET(O_LARGEFILE
),
335 FLAG_TARGET(O_NOCTTY
),
336 FLAG_TARGET(O_NOFOLLOW
),
337 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
339 FLAG_TARGET(O_TRUNC
),
341 FLAG_TARGET(O_DIRECT
),
346 UNUSED
static struct flags mount_flags
[] = {
348 FLAG_GENERIC(MS_BIND
),
351 FLAG_GENERIC(MS_DIRSYNC
),
353 FLAG_GENERIC(MS_MANDLOCK
),
355 FLAG_GENERIC(MS_MOVE
),
357 FLAG_GENERIC(MS_NOATIME
),
358 FLAG_GENERIC(MS_NODEV
),
359 FLAG_GENERIC(MS_NODIRATIME
),
360 FLAG_GENERIC(MS_NOEXEC
),
361 FLAG_GENERIC(MS_NOSUID
),
362 FLAG_GENERIC(MS_RDONLY
),
364 FLAG_GENERIC(MS_RELATIME
),
366 FLAG_GENERIC(MS_REMOUNT
),
367 FLAG_GENERIC(MS_SYNCHRONOUS
),
371 UNUSED
static struct flags umount2_flags
[] = {
373 FLAG_GENERIC(MNT_FORCE
),
376 FLAG_GENERIC(MNT_DETACH
),
379 FLAG_GENERIC(MNT_EXPIRE
),
384 UNUSED
static struct flags mmap_prot_flags
[] = {
385 FLAG_GENERIC(PROT_NONE
),
386 FLAG_GENERIC(PROT_EXEC
),
387 FLAG_GENERIC(PROT_READ
),
388 FLAG_GENERIC(PROT_WRITE
),
392 UNUSED
static struct flags mmap_flags
[] = {
393 FLAG_TARGET(MAP_SHARED
),
394 FLAG_TARGET(MAP_PRIVATE
),
395 FLAG_TARGET(MAP_ANONYMOUS
),
396 FLAG_TARGET(MAP_DENYWRITE
),
397 FLAG_TARGET(MAP_FIXED
),
398 FLAG_TARGET(MAP_GROWSDOWN
),
400 FLAG_TARGET(MAP_LOCKED
),
403 FLAG_TARGET(MAP_NONBLOCK
),
405 FLAG_TARGET(MAP_NORESERVE
),
407 FLAG_TARGET(MAP_POPULATE
),
412 UNUSED
static struct flags fcntl_flags
[] = {
413 FLAG_TARGET(F_DUPFD
),
414 FLAG_TARGET(F_GETFD
),
415 FLAG_TARGET(F_SETFD
),
416 FLAG_TARGET(F_GETFL
),
417 FLAG_TARGET(F_SETFL
),
418 FLAG_TARGET(F_GETLK
),
419 FLAG_TARGET(F_SETLK
),
420 FLAG_TARGET(F_SETLKW
),
425 * print_xxx utility functions. These are used to print syscall
426 * parameters in certain format. All of these have parameter
427 * named 'last'. This parameter is used to add comma to output
434 return ((last
) ? "" : ",");
438 print_flags(const struct flags
*f
, abi_long tflags
, int last
)
440 const char *sep
= "";
444 flags
= (int)tswap32(tflags
);
446 if ((flags
== 0) && (f
->f_value
== 0)) {
447 gemu_log("%s%s", f
->f_string
, get_comma(last
));
450 for (n
= 0; f
->f_string
!= NULL
; f
++) {
451 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
452 gemu_log("%s%s", sep
, f
->f_string
);
453 flags
&= ~f
->f_value
;
460 /* print rest of the flags as numeric */
462 gemu_log("%s%#x%s", sep
, flags
, get_comma(last
));
464 gemu_log("%s", get_comma(last
));
467 /* no string version of flags found, print them in hex then */
468 gemu_log("%#x%s", flags
, get_comma(last
));
473 print_at_dirfd(abi_long tdirfd
, int last
)
475 int dirfd
= tswap32(tdirfd
);
478 if (dirfd
== AT_FDCWD
) {
479 gemu_log("AT_FDCWD%s", get_comma(last
));
483 gemu_log("%d%s", dirfd
, get_comma(last
));
487 print_file_mode(abi_long tmode
, int last
)
489 const char *sep
= "";
490 const struct flags
*m
;
491 mode_t mode
= (mode_t
)tswap32(tmode
);
493 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
494 if ((m
->f_value
& mode
) == m
->f_value
) {
495 gemu_log("%s%s", m
->f_string
, sep
);
503 /* print rest of the mode as octal */
505 gemu_log("%s%#o", sep
, mode
);
507 gemu_log("%s", get_comma(last
));
511 print_open_flags(abi_long tflags
, int last
)
513 int flags
= tswap32(tflags
);
515 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
516 flags
&= ~TARGET_O_ACCMODE
;
518 gemu_log("%s", get_comma(last
));
522 print_flags(open_flags
, flags
, last
);
526 print_syscall_prologue(const struct syscallname
*sc
)
528 gemu_log("%s(", sc
->name
);
533 print_syscall_epilogue(const struct syscallname
*sc
)
540 print_string(abi_long addr
, int last
)
544 if ((s
= lock_user_string(addr
)) != NULL
) {
545 gemu_log("\"%s\"%s", s
, get_comma(last
));
546 unlock_user(s
, addr
, 0);
548 /* can't get string out of it, so print it as pointer */
549 print_pointer(addr
, last
);
554 * Prints out raw parameter using given format. Caller needs
555 * to do byte swapping if needed.
558 print_raw_param(const char *fmt
, abi_long param
, int last
)
562 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
563 gemu_log(format
, param
);
567 print_pointer(abi_long p
, int last
)
570 gemu_log("NULL%s", get_comma(last
));
572 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
576 * Reads 32-bit (int) number from guest address space from
577 * address 'addr' and prints it.
580 print_number(abi_long addr
, int last
)
583 gemu_log("NULL%s", get_comma(last
));
587 get_user_s32(num
, addr
);
588 gemu_log("[%d]%s", num
, get_comma(last
));
593 print_timeval(abi_ulong tv_addr
, int last
)
596 struct target_timeval
*tv
;
598 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
601 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
602 tv
->tv_sec
, tv
->tv_usec
, get_comma(last
));
603 unlock_user(tv
, tv_addr
, 0);
605 gemu_log("NULL%s", get_comma(last
));
610 #ifdef TARGET_NR_accept
612 print_accept(const struct syscallname
*name
,
613 abi_long arg0
, abi_long arg1
, abi_long arg2
,
614 abi_long arg3
, abi_long arg4
, abi_long arg5
)
616 print_syscall_prologue(name
);
617 print_raw_param("%d", tswap32(arg0
), 0);
618 print_pointer(arg1
, 0);
619 print_number(arg2
, 1);
620 print_syscall_epilogue(name
);
624 #ifdef TARGET_NR_access
626 print_access(const struct syscallname
*name
,
627 abi_long arg0
, abi_long arg1
, abi_long arg2
,
628 abi_long arg3
, abi_long arg4
, abi_long arg5
)
630 print_syscall_prologue(name
);
631 print_string(arg0
, 0);
632 print_flags(access_flags
, arg1
, 1);
633 print_syscall_epilogue(name
);
639 print_brk(const struct syscallname
*name
,
640 abi_long arg0
, abi_long arg1
, abi_long arg2
,
641 abi_long arg3
, abi_long arg4
, abi_long arg5
)
643 print_syscall_prologue(name
);
644 print_pointer(arg0
, 1);
645 print_syscall_epilogue(name
);
649 #ifdef TARGET_NR_chdir
651 print_chdir(const struct syscallname
*name
,
652 abi_long arg0
, abi_long arg1
, abi_long arg2
,
653 abi_long arg3
, abi_long arg4
, abi_long arg5
)
655 print_syscall_prologue(name
);
656 print_string(arg0
, 1);
657 print_syscall_epilogue(name
);
661 #ifdef TARGET_NR_chmod
663 print_chmod(const struct syscallname
*name
,
664 abi_long arg0
, abi_long arg1
, abi_long arg2
,
665 abi_long arg3
, abi_long arg4
, abi_long arg5
)
667 print_syscall_prologue(name
);
668 print_string(arg0
, 0);
669 print_file_mode(arg1
, 1);
670 print_syscall_epilogue(name
);
674 #ifdef TARGET_NR_creat
676 print_creat(const struct syscallname
*name
,
677 abi_long arg0
, abi_long arg1
, abi_long arg2
,
678 abi_long arg3
, abi_long arg4
, abi_long arg5
)
680 print_syscall_prologue(name
);
681 print_string(arg0
, 0);
682 print_file_mode(arg1
, 1);
683 print_syscall_epilogue(name
);
687 #ifdef TARGET_NR_execv
689 print_execv(const struct syscallname
*name
,
690 abi_long arg0
, abi_long arg1
, abi_long arg2
,
691 abi_long arg3
, abi_long arg4
, abi_long arg5
)
693 print_syscall_prologue(name
);
694 print_string(arg0
, 0);
695 print_raw_param("0x" TARGET_ABI_FMT_lx
, tswapl(arg1
), 1);
696 print_syscall_epilogue(name
);
700 #ifdef TARGET_NR_faccessat
702 print_faccessat(const struct syscallname
*name
,
703 abi_long arg0
, abi_long arg1
, abi_long arg2
,
704 abi_long arg3
, abi_long arg4
, abi_long arg5
)
706 print_syscall_prologue(name
);
707 print_at_dirfd(arg0
, 0);
708 print_string(arg1
, 0);
709 print_flags(access_flags
, arg2
, 0);
710 print_flags(at_file_flags
, arg3
, 1);
711 print_syscall_epilogue(name
);
715 #ifdef TARGET_NR_fchmodat
717 print_fchmodat(const struct syscallname
*name
,
718 abi_long arg0
, abi_long arg1
, abi_long arg2
,
719 abi_long arg3
, abi_long arg4
, abi_long arg5
)
721 print_syscall_prologue(name
);
722 print_at_dirfd(arg0
, 0);
723 print_string(arg1
, 0);
724 print_file_mode(arg2
, 0);
725 print_flags(at_file_flags
, arg3
, 1);
726 print_syscall_epilogue(name
);
730 #ifdef TARGET_NR_fchownat
732 print_fchownat(const struct syscallname
*name
,
733 abi_long arg0
, abi_long arg1
, abi_long arg2
,
734 abi_long arg3
, abi_long arg4
, abi_long arg5
)
736 print_syscall_prologue(name
);
737 print_at_dirfd(arg0
, 0);
738 print_string(arg1
, 0);
740 print_raw_param("%d", tswap16(arg2
), 0);
741 print_raw_param("%d", tswap16(arg3
), 0);
743 print_raw_param("%d", tswap32(arg2
), 0);
744 print_raw_param("%d", tswap32(arg3
), 0);
746 print_flags(at_file_flags
, arg4
, 1);
747 print_syscall_epilogue(name
);
751 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
753 print_fcntl(const struct syscallname
*name
,
754 abi_long arg0
, abi_long arg1
, abi_long arg2
,
755 abi_long arg3
, abi_long arg4
, abi_long arg5
)
757 print_syscall_prologue(name
);
758 print_raw_param("%d", tswap32(arg0
), 0);
759 print_flags(fcntl_flags
, arg1
, 0);
761 * TODO: check flags and print following argument only
764 print_pointer(arg2
, 1);
765 print_syscall_epilogue(name
);
767 #define print_fcntl64 print_fcntl
771 #ifdef TARGET_NR_futimesat
773 print_futimesat(const struct syscallname
*name
,
774 abi_long arg0
, abi_long arg1
, abi_long arg2
,
775 abi_long arg3
, abi_long arg4
, abi_long arg5
)
777 print_syscall_prologue(name
);
778 print_at_dirfd(arg0
, 0);
779 print_string(arg1
, 0);
780 print_timeval(arg2
, 0);
781 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
782 print_syscall_epilogue(name
);
786 #ifdef TARGET_NR_link
788 print_link(const struct syscallname
*name
,
789 abi_long arg0
, abi_long arg1
, abi_long arg2
,
790 abi_long arg3
, abi_long arg4
, abi_long arg5
)
792 print_syscall_prologue(name
);
793 print_string(arg0
, 0);
794 print_string(arg1
, 1);
795 print_syscall_epilogue(name
);
799 #ifdef TARGET_NR_linkat
801 print_linkat(const struct syscallname
*name
,
802 abi_long arg0
, abi_long arg1
, abi_long arg2
,
803 abi_long arg3
, abi_long arg4
, abi_long arg5
)
805 print_syscall_prologue(name
);
806 print_at_dirfd(arg0
, 0);
807 print_string(arg1
, 0);
808 print_at_dirfd(arg2
, 0);
809 print_string(arg3
, 0);
810 print_flags(at_file_flags
, arg4
, 1);
811 print_syscall_epilogue(name
);
815 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
816 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
818 print_stat(const struct syscallname
*name
,
819 abi_long arg0
, abi_long arg1
, abi_long arg2
,
820 abi_long arg3
, abi_long arg4
, abi_long arg5
)
822 print_syscall_prologue(name
);
823 print_string(arg0
, 0);
824 print_pointer(arg1
, 1);
825 print_syscall_epilogue(name
);
827 #define print_lstat print_stat
828 #define print_stat64 print_stat
829 #define print_lstat64 print_stat
832 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
834 print_fstat(const struct syscallname
*name
,
835 abi_long arg0
, abi_long arg1
, abi_long arg2
,
836 abi_long arg3
, abi_long arg4
, abi_long arg5
)
838 print_syscall_prologue(name
);
839 print_raw_param("%d", tswap32(arg0
), 0);
840 print_pointer(arg1
, 1);
841 print_syscall_epilogue(name
);
843 #define print_fstat64 print_fstat
846 #ifdef TARGET_NR_mkdir
848 print_mkdir(const struct syscallname
*name
,
849 abi_long arg0
, abi_long arg1
, abi_long arg2
,
850 abi_long arg3
, abi_long arg4
, abi_long arg5
)
852 print_syscall_prologue(name
);
853 print_string(arg0
, 0);
854 print_file_mode(arg1
, 1);
855 print_syscall_epilogue(name
);
859 #ifdef TARGET_NR_mkdirat
861 print_mkdirat(const struct syscallname
*name
,
862 abi_long arg0
, abi_long arg1
, abi_long arg2
,
863 abi_long arg3
, abi_long arg4
, abi_long arg5
)
865 print_syscall_prologue(name
);
866 print_at_dirfd(arg0
, 0);
867 print_string(arg1
, 0);
868 print_file_mode(arg2
, 1);
869 print_syscall_epilogue(name
);
873 #ifdef TARGET_NR_mknod
875 print_mknod(const struct syscallname
*name
,
876 abi_long arg0
, abi_long arg1
, abi_long arg2
,
877 abi_long arg3
, abi_long arg4
, abi_long arg5
)
879 int hasdev
= (tswapl(arg1
) & (S_IFCHR
|S_IFBLK
));
881 print_syscall_prologue(name
);
882 print_string(arg0
, 0);
883 print_file_mode(arg1
, (hasdev
== 0));
885 print_raw_param("makedev(%d", major(tswapl(arg2
)), 0);
886 print_raw_param("%d)", minor(tswapl(arg2
)), 1);
888 print_syscall_epilogue(name
);
892 #ifdef TARGET_NR_mknodat
894 print_mknodat(const struct syscallname
*name
,
895 abi_long arg0
, abi_long arg1
, abi_long arg2
,
896 abi_long arg3
, abi_long arg4
, abi_long arg5
)
898 int hasdev
= (tswapl(arg2
) & (S_IFCHR
|S_IFBLK
));
900 print_syscall_prologue(name
);
901 print_at_dirfd(arg0
, 0);
902 print_string(arg1
, 0);
903 print_file_mode(arg2
, (hasdev
== 0));
905 print_raw_param("makedev(%d", major(tswapl(arg3
)), 0);
906 print_raw_param("%d)", minor(tswapl(arg3
)), 1);
908 print_syscall_epilogue(name
);
912 #ifdef TARGET_NR_mq_open
914 print_mq_open(const struct syscallname
*name
,
915 abi_long arg0
, abi_long arg1
, abi_long arg2
,
916 abi_long arg3
, abi_long arg4
, abi_long arg5
)
918 int is_creat
= (tswapl(arg1
) & TARGET_O_CREAT
);
920 print_syscall_prologue(name
);
921 print_string(arg0
, 0);
922 print_open_flags(arg1
, (is_creat
== 0));
924 print_file_mode(arg2
, 0);
925 print_pointer(arg3
, 1);
927 print_syscall_epilogue(name
);
931 #ifdef TARGET_NR_open
933 print_open(const struct syscallname
*name
,
934 abi_long arg0
, abi_long arg1
, abi_long arg2
,
935 abi_long arg3
, abi_long arg4
, abi_long arg5
)
937 int is_creat
= (tswap32(arg1
) & TARGET_O_CREAT
);
939 print_syscall_prologue(name
);
940 print_string(arg0
, 0);
941 print_open_flags(arg1
, (is_creat
== 0));
943 print_file_mode(arg2
, 1);
944 print_syscall_epilogue(name
);
948 #ifdef TARGET_NR_openat
950 print_openat(const struct syscallname
*name
,
951 abi_long arg0
, abi_long arg1
, abi_long arg2
,
952 abi_long arg3
, abi_long arg4
, abi_long arg5
)
954 int is_creat
= (tswap32(arg2
) & TARGET_O_CREAT
);
956 print_syscall_prologue(name
);
957 print_at_dirfd(arg0
, 0);
958 print_string(arg1
, 0);
959 print_open_flags(arg2
, (is_creat
== 0));
961 print_file_mode(arg3
, 1);
962 print_syscall_epilogue(name
);
966 #ifdef TARGET_NR_mq_unlink
968 print_mq_unlink(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_string(arg0
, 1);
974 print_syscall_epilogue(name
);
978 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
980 print_fstatat64(const struct syscallname
*name
,
981 abi_long arg0
, abi_long arg1
, abi_long arg2
,
982 abi_long arg3
, abi_long arg4
, abi_long arg5
)
984 print_syscall_prologue(name
);
985 print_at_dirfd(arg0
, 0);
986 print_string(arg1
, 0);
987 print_pointer(arg2
, 0);
988 print_flags(at_file_flags
, arg3
, 1);
989 print_syscall_epilogue(name
);
991 #define print_newfstatat print_fstatat64
994 #ifdef TARGET_NR_readlink
996 print_readlink(const struct syscallname
*name
,
997 abi_long arg0
, abi_long arg1
, abi_long arg2
,
998 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1000 print_syscall_prologue(name
);
1001 print_string(arg0
, 0);
1002 print_pointer(arg1
, 0);
1003 print_raw_param("%u", tswapl(arg2
), 1);
1004 print_syscall_epilogue(name
);
1008 #ifdef TARGET_NR_readlinkat
1010 print_readlinkat(const struct syscallname
*name
,
1011 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1012 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1014 print_syscall_prologue(name
);
1015 print_at_dirfd(arg0
, 0);
1016 print_string(arg1
, 0);
1017 print_pointer(arg2
, 0);
1018 print_raw_param("%u", tswapl(arg3
), 1);
1019 print_syscall_epilogue(name
);
1023 #ifdef TARGET_NR_rename
1025 print_rename(const struct syscallname
*name
,
1026 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1027 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1029 print_syscall_prologue(name
);
1030 print_string(arg0
, 0);
1031 print_string(arg1
, 1);
1032 print_syscall_epilogue(name
);
1036 #ifdef TARGET_NR_renameat
1038 print_renameat(const struct syscallname
*name
,
1039 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1040 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1042 print_syscall_prologue(name
);
1043 print_at_dirfd(arg0
, 0);
1044 print_string(arg1
, 0);
1045 print_at_dirfd(arg2
, 0);
1046 print_string(arg3
, 1);
1047 print_syscall_epilogue(name
);
1051 #ifdef TARGET_NR_statfs
1053 print_statfs(const struct syscallname
*name
,
1054 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1055 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1057 print_syscall_prologue(name
);
1058 print_string(arg0
, 0);
1059 print_pointer(arg1
, 1);
1060 print_syscall_epilogue(name
);
1062 #define print_statfs64 print_statfs
1065 #ifdef TARGET_NR_symlink
1067 print_symlink(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 print_syscall_prologue(name
);
1072 print_string(arg0
, 0);
1073 print_string(arg1
, 1);
1074 print_syscall_epilogue(name
);
1078 #ifdef TARGET_NR_symlinkat
1080 print_symlinkat(const struct syscallname
*name
,
1081 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1082 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1084 print_syscall_prologue(name
);
1085 print_string(arg0
, 0);
1086 print_at_dirfd(arg1
, 0);
1087 print_string(arg2
, 1);
1088 print_syscall_epilogue(name
);
1092 #ifdef TARGET_NR_mount
1094 print_mount(const struct syscallname
*name
,
1095 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1096 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1098 print_syscall_prologue(name
);
1099 print_string(arg0
, 0);
1100 print_string(arg1
, 0);
1101 print_string(arg2
, 0);
1102 print_flags(mount_flags
, arg3
, 0);
1103 print_pointer(arg4
, 1);
1104 print_syscall_epilogue(name
);
1108 #ifdef TARGET_NR_umount
1110 print_umount(const struct syscallname
*name
,
1111 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1112 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1114 print_syscall_prologue(name
);
1115 print_string(arg0
, 1);
1116 print_syscall_epilogue(name
);
1120 #ifdef TARGET_NR_umount2
1122 print_umount2(const struct syscallname
*name
,
1123 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1124 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1126 print_syscall_prologue(name
);
1127 print_string(arg0
, 0);
1128 print_flags(umount2_flags
, arg1
, 1);
1129 print_syscall_epilogue(name
);
1133 #ifdef TARGET_NR_unlink
1135 print_unlink(const struct syscallname
*name
,
1136 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1137 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1139 print_syscall_prologue(name
);
1140 print_string(arg0
, 1);
1141 print_syscall_epilogue(name
);
1145 #ifdef TARGET_NR_unlinkat
1147 print_unlinkat(const struct syscallname
*name
,
1148 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1149 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1151 print_syscall_prologue(name
);
1152 print_at_dirfd(arg0
, 0);
1153 print_string(arg1
, 0);
1154 print_flags(unlinkat_flags
, arg2
, 1);
1155 print_syscall_epilogue(name
);
1159 #ifdef TARGET_NR_utime
1161 print_utime(const struct syscallname
*name
,
1162 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1163 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1165 print_syscall_prologue(name
);
1166 print_string(arg0
, 0);
1167 print_pointer(arg1
, 1);
1168 print_syscall_epilogue(name
);
1172 #ifdef TARGET_NR_utimes
1174 print_utimes(const struct syscallname
*name
,
1175 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1176 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1178 print_syscall_prologue(name
);
1179 print_string(arg0
, 0);
1180 print_pointer(arg1
, 1);
1181 print_syscall_epilogue(name
);
1185 #ifdef TARGET_NR_utimensat
1187 print_utimensat(const struct syscallname
*name
,
1188 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1189 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1191 print_syscall_prologue(name
);
1192 print_at_dirfd(arg0
, 0);
1193 print_string(arg1
, 0);
1194 print_pointer(arg2
, 0);
1195 print_flags(at_file_flags
, arg3
, 1);
1196 print_syscall_epilogue(name
);
1200 #ifdef TARGET_NR_mmap
1202 print_mmap(const struct syscallname
*name
,
1203 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1204 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1206 print_syscall_prologue(name
);
1207 print_pointer(arg0
, 0);
1208 print_raw_param("%d", tswapl(arg1
), 0);
1209 print_flags(mmap_prot_flags
, arg2
, 0);
1210 print_flags(mmap_flags
, arg3
, 0);
1211 print_raw_param("%d", tswapl(arg4
), 0);
1212 print_raw_param("%#x", tswapl(arg5
), 1);
1213 print_syscall_epilogue(name
);
1215 #define print_mmap2 print_mmap
1218 #ifdef TARGET_NR_mprotect
1220 print_mprotect(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_pointer(arg0
, 0);
1226 print_raw_param("%d", tswapl(arg1
), 0);
1227 print_flags(mmap_prot_flags
, arg2
, 1);
1228 print_syscall_epilogue(name
);
1232 #ifdef TARGET_NR_munmap
1234 print_munmap(const struct syscallname
*name
,
1235 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1236 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1238 print_syscall_prologue(name
);
1239 print_pointer(arg0
, 0);
1240 print_raw_param("%d", tswapl(arg1
), 1);
1241 print_syscall_epilogue(name
);
1245 #ifdef TARGET_NR_futex
1246 static void print_futex_op(abi_long tflag
, int last
)
1248 #define print_op(val) \
1249 if( cmd == val ) { \
1254 int cmd
= (int)tswap32(tflag
);
1255 #ifdef FUTEX_PRIVATE_FLAG
1256 if (cmd
== FUTEX_PRIVATE_FLAG
)
1257 gemu_log("FUTEX_PRIVATE_FLAG|");
1259 print_op(FUTEX_WAIT
)
1260 print_op(FUTEX_WAKE
)
1262 print_op(FUTEX_REQUEUE
)
1263 print_op(FUTEX_CMP_REQUEUE
)
1264 print_op(FUTEX_WAKE_OP
)
1265 print_op(FUTEX_LOCK_PI
)
1266 print_op(FUTEX_UNLOCK_PI
)
1267 print_op(FUTEX_TRYLOCK_PI
)
1268 #ifdef FUTEX_WAIT_BITSET
1269 print_op(FUTEX_WAIT_BITSET
)
1271 #ifdef FUTEX_WAKE_BITSET
1272 print_op(FUTEX_WAKE_BITSET
)
1274 /* unknown values */
1279 print_futex(const struct syscallname
*name
,
1280 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1281 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1283 print_syscall_prologue(name
);
1284 print_pointer(arg0
, 0);
1285 print_futex_op(arg1
, 0);
1286 print_raw_param(",%d", tswapl(arg2
), 0);
1287 print_pointer(arg3
, 0); /* struct timespec */
1288 print_pointer(arg4
, 0);
1289 print_raw_param("%d", tswapl(arg4
), 1);
1290 print_syscall_epilogue(name
);
1295 * An array of all of the syscalls we know about
1298 static const struct syscallname scnames
[] = {
1299 #include "strace.list"
1302 static int nsyscalls
= ARRAY_SIZE(scnames
);
1305 * The public interface to this module.
1308 print_syscall(int num
,
1309 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1310 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1313 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
")";
1315 gemu_log("%d ", getpid() );
1317 for(i
=0;i
<nsyscalls
;i
++)
1318 if( scnames
[i
].nr
== num
) {
1319 if( scnames
[i
].call
!= NULL
) {
1320 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1322 /* XXX: this format system is broken because it uses
1323 host types and host pointers for strings */
1324 if( scnames
[i
].format
!= NULL
)
1325 format
= scnames
[i
].format
;
1326 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1330 gemu_log("Unknown syscall %d\n", num
);
1335 print_syscall_ret(int num
, abi_long ret
)
1339 for(i
=0;i
<nsyscalls
;i
++)
1340 if( scnames
[i
].nr
== num
) {
1341 if( scnames
[i
].result
!= NULL
) {
1342 scnames
[i
].result(&scnames
[i
],ret
);
1345 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n", -ret
, target_strerror(-ret
));
1347 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);