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 flags
, int last
)
446 const char *sep
= "";
449 if ((flags
== 0) && (f
->f_value
== 0)) {
450 gemu_log("%s%s", f
->f_string
, get_comma(last
));
453 for (n
= 0; f
->f_string
!= NULL
; f
++) {
454 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
455 gemu_log("%s%s", sep
, f
->f_string
);
456 flags
&= ~f
->f_value
;
463 /* print rest of the flags as numeric */
465 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
467 gemu_log("%s", get_comma(last
));
470 /* no string version of flags found, print them in hex then */
471 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
476 print_at_dirfd(abi_long dirfd
, int last
)
479 if (dirfd
== AT_FDCWD
) {
480 gemu_log("AT_FDCWD%s", get_comma(last
));
484 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
488 print_file_mode(abi_long mode
, int last
)
490 const char *sep
= "";
491 const struct flags
*m
;
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
, (unsigned int)mode
);
507 gemu_log("%s", get_comma(last
));
511 print_open_flags(abi_long flags
, int last
)
513 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
514 flags
&= ~TARGET_O_ACCMODE
;
516 gemu_log("%s", get_comma(last
));
520 print_flags(open_flags
, flags
, last
);
524 print_syscall_prologue(const struct syscallname
*sc
)
526 gemu_log("%s(", sc
->name
);
531 print_syscall_epilogue(const struct syscallname
*sc
)
538 print_string(abi_long addr
, int last
)
542 if ((s
= lock_user_string(addr
)) != NULL
) {
543 gemu_log("\"%s\"%s", s
, get_comma(last
));
544 unlock_user(s
, addr
, 0);
546 /* can't get string out of it, so print it as pointer */
547 print_pointer(addr
, last
);
552 * Prints out raw parameter using given format. Caller needs
553 * to do byte swapping if needed.
556 print_raw_param(const char *fmt
, abi_long param
, int last
)
560 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
561 gemu_log(format
, param
);
565 print_pointer(abi_long p
, int last
)
568 gemu_log("NULL%s", get_comma(last
));
570 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
574 * Reads 32-bit (int) number from guest address space from
575 * address 'addr' and prints it.
578 print_number(abi_long addr
, int last
)
581 gemu_log("NULL%s", get_comma(last
));
585 get_user_s32(num
, addr
);
586 gemu_log("[%d]%s", num
, get_comma(last
));
591 print_timeval(abi_ulong tv_addr
, int last
)
594 struct target_timeval
*tv
;
596 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
599 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
600 tv
->tv_sec
, tv
->tv_usec
, get_comma(last
));
601 unlock_user(tv
, tv_addr
, 0);
603 gemu_log("NULL%s", get_comma(last
));
608 #ifdef TARGET_NR_accept
610 print_accept(const struct syscallname
*name
,
611 abi_long arg0
, abi_long arg1
, abi_long arg2
,
612 abi_long arg3
, abi_long arg4
, abi_long arg5
)
614 print_syscall_prologue(name
);
615 print_raw_param("%d", arg0
, 0);
616 print_pointer(arg1
, 0);
617 print_number(arg2
, 1);
618 print_syscall_epilogue(name
);
622 #ifdef TARGET_NR_access
624 print_access(const struct syscallname
*name
,
625 abi_long arg0
, abi_long arg1
, abi_long arg2
,
626 abi_long arg3
, abi_long arg4
, abi_long arg5
)
628 print_syscall_prologue(name
);
629 print_string(arg0
, 0);
630 print_flags(access_flags
, arg1
, 1);
631 print_syscall_epilogue(name
);
637 print_brk(const struct syscallname
*name
,
638 abi_long arg0
, abi_long arg1
, abi_long arg2
,
639 abi_long arg3
, abi_long arg4
, abi_long arg5
)
641 print_syscall_prologue(name
);
642 print_pointer(arg0
, 1);
643 print_syscall_epilogue(name
);
647 #ifdef TARGET_NR_chdir
649 print_chdir(const struct syscallname
*name
,
650 abi_long arg0
, abi_long arg1
, abi_long arg2
,
651 abi_long arg3
, abi_long arg4
, abi_long arg5
)
653 print_syscall_prologue(name
);
654 print_string(arg0
, 1);
655 print_syscall_epilogue(name
);
659 #ifdef TARGET_NR_chmod
661 print_chmod(const struct syscallname
*name
,
662 abi_long arg0
, abi_long arg1
, abi_long arg2
,
663 abi_long arg3
, abi_long arg4
, abi_long arg5
)
665 print_syscall_prologue(name
);
666 print_string(arg0
, 0);
667 print_file_mode(arg1
, 1);
668 print_syscall_epilogue(name
);
672 #ifdef TARGET_NR_creat
674 print_creat(const struct syscallname
*name
,
675 abi_long arg0
, abi_long arg1
, abi_long arg2
,
676 abi_long arg3
, abi_long arg4
, abi_long arg5
)
678 print_syscall_prologue(name
);
679 print_string(arg0
, 0);
680 print_file_mode(arg1
, 1);
681 print_syscall_epilogue(name
);
685 #ifdef TARGET_NR_execv
687 print_execv(const struct syscallname
*name
,
688 abi_long arg0
, abi_long arg1
, abi_long arg2
,
689 abi_long arg3
, abi_long arg4
, abi_long arg5
)
691 print_syscall_prologue(name
);
692 print_string(arg0
, 0);
693 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
694 print_syscall_epilogue(name
);
698 #ifdef TARGET_NR_faccessat
700 print_faccessat(const struct syscallname
*name
,
701 abi_long arg0
, abi_long arg1
, abi_long arg2
,
702 abi_long arg3
, abi_long arg4
, abi_long arg5
)
704 print_syscall_prologue(name
);
705 print_at_dirfd(arg0
, 0);
706 print_string(arg1
, 0);
707 print_flags(access_flags
, arg2
, 0);
708 print_flags(at_file_flags
, arg3
, 1);
709 print_syscall_epilogue(name
);
713 #ifdef TARGET_NR_fchmodat
715 print_fchmodat(const struct syscallname
*name
,
716 abi_long arg0
, abi_long arg1
, abi_long arg2
,
717 abi_long arg3
, abi_long arg4
, abi_long arg5
)
719 print_syscall_prologue(name
);
720 print_at_dirfd(arg0
, 0);
721 print_string(arg1
, 0);
722 print_file_mode(arg2
, 0);
723 print_flags(at_file_flags
, arg3
, 1);
724 print_syscall_epilogue(name
);
728 #ifdef TARGET_NR_fchownat
730 print_fchownat(const struct syscallname
*name
,
731 abi_long arg0
, abi_long arg1
, abi_long arg2
,
732 abi_long arg3
, abi_long arg4
, abi_long arg5
)
734 print_syscall_prologue(name
);
735 print_at_dirfd(arg0
, 0);
736 print_string(arg1
, 0);
737 print_raw_param("%d", arg2
, 0);
738 print_raw_param("%d", arg3
, 0);
739 print_flags(at_file_flags
, arg4
, 1);
740 print_syscall_epilogue(name
);
744 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
746 print_fcntl(const struct syscallname
*name
,
747 abi_long arg0
, abi_long arg1
, abi_long arg2
,
748 abi_long arg3
, abi_long arg4
, abi_long arg5
)
750 print_syscall_prologue(name
);
751 print_raw_param("%d", arg0
, 0);
752 print_flags(fcntl_flags
, arg1
, 0);
754 * TODO: check flags and print following argument only
757 print_pointer(arg2
, 1);
758 print_syscall_epilogue(name
);
760 #define print_fcntl64 print_fcntl
764 #ifdef TARGET_NR_futimesat
766 print_futimesat(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_at_dirfd(arg0
, 0);
772 print_string(arg1
, 0);
773 print_timeval(arg2
, 0);
774 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
775 print_syscall_epilogue(name
);
779 #ifdef TARGET_NR_link
781 print_link(const struct syscallname
*name
,
782 abi_long arg0
, abi_long arg1
, abi_long arg2
,
783 abi_long arg3
, abi_long arg4
, abi_long arg5
)
785 print_syscall_prologue(name
);
786 print_string(arg0
, 0);
787 print_string(arg1
, 1);
788 print_syscall_epilogue(name
);
792 #ifdef TARGET_NR_linkat
794 print_linkat(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_at_dirfd(arg0
, 0);
800 print_string(arg1
, 0);
801 print_at_dirfd(arg2
, 0);
802 print_string(arg3
, 0);
803 print_flags(at_file_flags
, arg4
, 1);
804 print_syscall_epilogue(name
);
808 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
809 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
811 print_stat(const struct syscallname
*name
,
812 abi_long arg0
, abi_long arg1
, abi_long arg2
,
813 abi_long arg3
, abi_long arg4
, abi_long arg5
)
815 print_syscall_prologue(name
);
816 print_string(arg0
, 0);
817 print_pointer(arg1
, 1);
818 print_syscall_epilogue(name
);
820 #define print_lstat print_stat
821 #define print_stat64 print_stat
822 #define print_lstat64 print_stat
825 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
827 print_fstat(const struct syscallname
*name
,
828 abi_long arg0
, abi_long arg1
, abi_long arg2
,
829 abi_long arg3
, abi_long arg4
, abi_long arg5
)
831 print_syscall_prologue(name
);
832 print_raw_param("%d", arg0
, 0);
833 print_pointer(arg1
, 1);
834 print_syscall_epilogue(name
);
836 #define print_fstat64 print_fstat
839 #ifdef TARGET_NR_mkdir
841 print_mkdir(const struct syscallname
*name
,
842 abi_long arg0
, abi_long arg1
, abi_long arg2
,
843 abi_long arg3
, abi_long arg4
, abi_long arg5
)
845 print_syscall_prologue(name
);
846 print_string(arg0
, 0);
847 print_file_mode(arg1
, 1);
848 print_syscall_epilogue(name
);
852 #ifdef TARGET_NR_mkdirat
854 print_mkdirat(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_at_dirfd(arg0
, 0);
860 print_string(arg1
, 0);
861 print_file_mode(arg2
, 1);
862 print_syscall_epilogue(name
);
866 #ifdef TARGET_NR_rmdir
868 print_rmdir(const struct syscallname
*name
,
869 abi_long arg0
, abi_long arg1
, abi_long arg2
,
870 abi_long arg3
, abi_long arg4
, abi_long arg5
)
872 print_syscall_prologue(name
);
873 print_string(arg0
, 0);
874 print_syscall_epilogue(name
);
878 #ifdef TARGET_NR_mknod
880 print_mknod(const struct syscallname
*name
,
881 abi_long arg0
, abi_long arg1
, abi_long arg2
,
882 abi_long arg3
, abi_long arg4
, abi_long arg5
)
884 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
886 print_syscall_prologue(name
);
887 print_string(arg0
, 0);
888 print_file_mode(arg1
, (hasdev
== 0));
890 print_raw_param("makedev(%d", major(arg2
), 0);
891 print_raw_param("%d)", minor(arg2
), 1);
893 print_syscall_epilogue(name
);
897 #ifdef TARGET_NR_mknodat
899 print_mknodat(const struct syscallname
*name
,
900 abi_long arg0
, abi_long arg1
, abi_long arg2
,
901 abi_long arg3
, abi_long arg4
, abi_long arg5
)
903 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
905 print_syscall_prologue(name
);
906 print_at_dirfd(arg0
, 0);
907 print_string(arg1
, 0);
908 print_file_mode(arg2
, (hasdev
== 0));
910 print_raw_param("makedev(%d", major(arg3
), 0);
911 print_raw_param("%d)", minor(arg3
), 1);
913 print_syscall_epilogue(name
);
917 #ifdef TARGET_NR_mq_open
919 print_mq_open(const struct syscallname
*name
,
920 abi_long arg0
, abi_long arg1
, abi_long arg2
,
921 abi_long arg3
, abi_long arg4
, abi_long arg5
)
923 int is_creat
= (arg1
& TARGET_O_CREAT
);
925 print_syscall_prologue(name
);
926 print_string(arg0
, 0);
927 print_open_flags(arg1
, (is_creat
== 0));
929 print_file_mode(arg2
, 0);
930 print_pointer(arg3
, 1);
932 print_syscall_epilogue(name
);
936 #ifdef TARGET_NR_open
938 print_open(const struct syscallname
*name
,
939 abi_long arg0
, abi_long arg1
, abi_long arg2
,
940 abi_long arg3
, abi_long arg4
, abi_long arg5
)
942 int is_creat
= (arg1
& TARGET_O_CREAT
);
944 print_syscall_prologue(name
);
945 print_string(arg0
, 0);
946 print_open_flags(arg1
, (is_creat
== 0));
948 print_file_mode(arg2
, 1);
949 print_syscall_epilogue(name
);
953 #ifdef TARGET_NR_openat
955 print_openat(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 int is_creat
= (arg2
& TARGET_O_CREAT
);
961 print_syscall_prologue(name
);
962 print_at_dirfd(arg0
, 0);
963 print_string(arg1
, 0);
964 print_open_flags(arg2
, (is_creat
== 0));
966 print_file_mode(arg3
, 1);
967 print_syscall_epilogue(name
);
971 #ifdef TARGET_NR_mq_unlink
973 print_mq_unlink(const struct syscallname
*name
,
974 abi_long arg0
, abi_long arg1
, abi_long arg2
,
975 abi_long arg3
, abi_long arg4
, abi_long arg5
)
977 print_syscall_prologue(name
);
978 print_string(arg0
, 1);
979 print_syscall_epilogue(name
);
983 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
985 print_fstatat64(const struct syscallname
*name
,
986 abi_long arg0
, abi_long arg1
, abi_long arg2
,
987 abi_long arg3
, abi_long arg4
, abi_long arg5
)
989 print_syscall_prologue(name
);
990 print_at_dirfd(arg0
, 0);
991 print_string(arg1
, 0);
992 print_pointer(arg2
, 0);
993 print_flags(at_file_flags
, arg3
, 1);
994 print_syscall_epilogue(name
);
996 #define print_newfstatat print_fstatat64
999 #ifdef TARGET_NR_readlink
1001 print_readlink(const struct syscallname
*name
,
1002 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1003 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1005 print_syscall_prologue(name
);
1006 print_string(arg0
, 0);
1007 print_pointer(arg1
, 0);
1008 print_raw_param("%u", arg2
, 1);
1009 print_syscall_epilogue(name
);
1013 #ifdef TARGET_NR_readlinkat
1015 print_readlinkat(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_at_dirfd(arg0
, 0);
1021 print_string(arg1
, 0);
1022 print_pointer(arg2
, 0);
1023 print_raw_param("%u", arg3
, 1);
1024 print_syscall_epilogue(name
);
1028 #ifdef TARGET_NR_rename
1030 print_rename(const struct syscallname
*name
,
1031 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1032 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1034 print_syscall_prologue(name
);
1035 print_string(arg0
, 0);
1036 print_string(arg1
, 1);
1037 print_syscall_epilogue(name
);
1041 #ifdef TARGET_NR_renameat
1043 print_renameat(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_at_dirfd(arg0
, 0);
1049 print_string(arg1
, 0);
1050 print_at_dirfd(arg2
, 0);
1051 print_string(arg3
, 1);
1052 print_syscall_epilogue(name
);
1056 #ifdef TARGET_NR_statfs
1058 print_statfs(const struct syscallname
*name
,
1059 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1060 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1062 print_syscall_prologue(name
);
1063 print_string(arg0
, 0);
1064 print_pointer(arg1
, 1);
1065 print_syscall_epilogue(name
);
1067 #define print_statfs64 print_statfs
1070 #ifdef TARGET_NR_symlink
1072 print_symlink(const struct syscallname
*name
,
1073 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1074 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1076 print_syscall_prologue(name
);
1077 print_string(arg0
, 0);
1078 print_string(arg1
, 1);
1079 print_syscall_epilogue(name
);
1083 #ifdef TARGET_NR_symlinkat
1085 print_symlinkat(const struct syscallname
*name
,
1086 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1087 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1089 print_syscall_prologue(name
);
1090 print_string(arg0
, 0);
1091 print_at_dirfd(arg1
, 0);
1092 print_string(arg2
, 1);
1093 print_syscall_epilogue(name
);
1097 #ifdef TARGET_NR_mount
1099 print_mount(const struct syscallname
*name
,
1100 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1101 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1103 print_syscall_prologue(name
);
1104 print_string(arg0
, 0);
1105 print_string(arg1
, 0);
1106 print_string(arg2
, 0);
1107 print_flags(mount_flags
, arg3
, 0);
1108 print_pointer(arg4
, 1);
1109 print_syscall_epilogue(name
);
1113 #ifdef TARGET_NR_umount
1115 print_umount(const struct syscallname
*name
,
1116 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1117 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1119 print_syscall_prologue(name
);
1120 print_string(arg0
, 1);
1121 print_syscall_epilogue(name
);
1125 #ifdef TARGET_NR_umount2
1127 print_umount2(const struct syscallname
*name
,
1128 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1129 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1131 print_syscall_prologue(name
);
1132 print_string(arg0
, 0);
1133 print_flags(umount2_flags
, arg1
, 1);
1134 print_syscall_epilogue(name
);
1138 #ifdef TARGET_NR_unlink
1140 print_unlink(const struct syscallname
*name
,
1141 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1142 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1144 print_syscall_prologue(name
);
1145 print_string(arg0
, 1);
1146 print_syscall_epilogue(name
);
1150 #ifdef TARGET_NR_unlinkat
1152 print_unlinkat(const struct syscallname
*name
,
1153 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1154 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1156 print_syscall_prologue(name
);
1157 print_at_dirfd(arg0
, 0);
1158 print_string(arg1
, 0);
1159 print_flags(unlinkat_flags
, arg2
, 1);
1160 print_syscall_epilogue(name
);
1164 #ifdef TARGET_NR_utime
1166 print_utime(const struct syscallname
*name
,
1167 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1168 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1170 print_syscall_prologue(name
);
1171 print_string(arg0
, 0);
1172 print_pointer(arg1
, 1);
1173 print_syscall_epilogue(name
);
1177 #ifdef TARGET_NR_utimes
1179 print_utimes(const struct syscallname
*name
,
1180 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1181 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1183 print_syscall_prologue(name
);
1184 print_string(arg0
, 0);
1185 print_pointer(arg1
, 1);
1186 print_syscall_epilogue(name
);
1190 #ifdef TARGET_NR_utimensat
1192 print_utimensat(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_at_dirfd(arg0
, 0);
1198 print_string(arg1
, 0);
1199 print_pointer(arg2
, 0);
1200 print_flags(at_file_flags
, arg3
, 1);
1201 print_syscall_epilogue(name
);
1205 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
1207 print_mmap(const struct syscallname
*name
,
1208 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1209 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1211 print_syscall_prologue(name
);
1212 print_pointer(arg0
, 0);
1213 print_raw_param("%d", arg1
, 0);
1214 print_flags(mmap_prot_flags
, arg2
, 0);
1215 print_flags(mmap_flags
, arg3
, 0);
1216 print_raw_param("%d", arg4
, 0);
1217 print_raw_param("%#x", arg5
, 1);
1218 print_syscall_epilogue(name
);
1220 #define print_mmap2 print_mmap
1223 #ifdef TARGET_NR_mprotect
1225 print_mprotect(const struct syscallname
*name
,
1226 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1227 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1229 print_syscall_prologue(name
);
1230 print_pointer(arg0
, 0);
1231 print_raw_param("%d", arg1
, 0);
1232 print_flags(mmap_prot_flags
, arg2
, 1);
1233 print_syscall_epilogue(name
);
1237 #ifdef TARGET_NR_munmap
1239 print_munmap(const struct syscallname
*name
,
1240 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1241 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1243 print_syscall_prologue(name
);
1244 print_pointer(arg0
, 0);
1245 print_raw_param("%d", arg1
, 1);
1246 print_syscall_epilogue(name
);
1250 #ifdef TARGET_NR_futex
1251 static void print_futex_op(abi_long tflag
, int last
)
1253 #define print_op(val) \
1254 if( cmd == val ) { \
1259 int cmd
= (int)tflag
;
1260 #ifdef FUTEX_PRIVATE_FLAG
1261 if (cmd
& FUTEX_PRIVATE_FLAG
) {
1262 gemu_log("FUTEX_PRIVATE_FLAG|");
1263 cmd
&= ~FUTEX_PRIVATE_FLAG
;
1266 print_op(FUTEX_WAIT
)
1267 print_op(FUTEX_WAKE
)
1269 print_op(FUTEX_REQUEUE
)
1270 print_op(FUTEX_CMP_REQUEUE
)
1271 print_op(FUTEX_WAKE_OP
)
1272 print_op(FUTEX_LOCK_PI
)
1273 print_op(FUTEX_UNLOCK_PI
)
1274 print_op(FUTEX_TRYLOCK_PI
)
1275 #ifdef FUTEX_WAIT_BITSET
1276 print_op(FUTEX_WAIT_BITSET
)
1278 #ifdef FUTEX_WAKE_BITSET
1279 print_op(FUTEX_WAKE_BITSET
)
1281 /* unknown values */
1286 print_futex(const struct syscallname
*name
,
1287 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1288 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1290 print_syscall_prologue(name
);
1291 print_pointer(arg0
, 0);
1292 print_futex_op(arg1
, 0);
1293 print_raw_param(",%d", arg2
, 0);
1294 print_pointer(arg3
, 0); /* struct timespec */
1295 print_pointer(arg4
, 0);
1296 print_raw_param("%d", arg4
, 1);
1297 print_syscall_epilogue(name
);
1302 * An array of all of the syscalls we know about
1305 static const struct syscallname scnames
[] = {
1306 #include "strace.list"
1309 static int nsyscalls
= ARRAY_SIZE(scnames
);
1312 * The public interface to this module.
1315 print_syscall(int num
,
1316 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1317 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1320 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
")";
1322 gemu_log("%d ", getpid() );
1324 for(i
=0;i
<nsyscalls
;i
++)
1325 if( scnames
[i
].nr
== num
) {
1326 if( scnames
[i
].call
!= NULL
) {
1327 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1329 /* XXX: this format system is broken because it uses
1330 host types and host pointers for strings */
1331 if( scnames
[i
].format
!= NULL
)
1332 format
= scnames
[i
].format
;
1333 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
1337 gemu_log("Unknown syscall %d\n", num
);
1342 print_syscall_ret(int num
, abi_long ret
)
1346 for(i
=0;i
<nsyscalls
;i
++)
1347 if( scnames
[i
].nr
== num
) {
1348 if( scnames
[i
].result
!= NULL
) {
1349 scnames
[i
].result(&scnames
[i
],ret
);
1352 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n", -ret
, target_strerror(-ret
));
1354 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);