1 #include "qemu/osdep.h"
6 #include <sys/select.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.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_buf(abi_long addr
, abi_long len
, int last
);
64 UNUSED
static void print_raw_param(const char *, abi_long
, int);
65 UNUSED
static void print_timeval(abi_ulong
, int);
66 UNUSED
static void print_number(abi_long
, int);
67 UNUSED
static void print_signal(abi_ulong
, int);
68 UNUSED
static void print_sockaddr(abi_ulong addr
, abi_long addrlen
);
69 UNUSED
static void print_socket_domain(int domain
);
70 UNUSED
static void print_socket_type(int type
);
71 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
77 print_ipc_cmd(int cmd
)
79 #define output_cmd(val) \
87 /* General IPC commands */
88 output_cmd( IPC_RMID
);
89 output_cmd( IPC_SET
);
90 output_cmd( IPC_STAT
);
91 output_cmd( IPC_INFO
);
92 /* msgctl() commands */
94 output_cmd( MSG_STAT
);
95 output_cmd( MSG_INFO
);
97 /* shmctl() commands */
98 output_cmd( SHM_LOCK
);
99 output_cmd( SHM_UNLOCK
);
100 output_cmd( SHM_STAT
);
101 output_cmd( SHM_INFO
);
102 /* semctl() commands */
103 output_cmd( GETPID
);
104 output_cmd( GETVAL
);
105 output_cmd( GETALL
);
106 output_cmd( GETNCNT
);
107 output_cmd( GETZCNT
);
108 output_cmd( SETVAL
);
109 output_cmd( SETALL
);
110 output_cmd( SEM_STAT
);
111 output_cmd( SEM_INFO
);
112 output_cmd( IPC_RMID
);
113 output_cmd( IPC_RMID
);
114 output_cmd( IPC_RMID
);
115 output_cmd( IPC_RMID
);
116 output_cmd( IPC_RMID
);
117 output_cmd( IPC_RMID
);
118 output_cmd( IPC_RMID
);
119 output_cmd( IPC_RMID
);
120 output_cmd( IPC_RMID
);
122 /* Some value we don't recognize */
127 print_signal(abi_ulong arg
, int last
)
129 const char *signal_name
= NULL
;
131 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
132 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
133 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
134 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
135 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
136 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
137 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
138 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
139 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
140 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
141 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
142 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
143 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
144 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
145 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
146 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
147 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
148 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
150 if (signal_name
== NULL
) {
151 print_raw_param("%ld", arg
, last
);
154 gemu_log("%s%s", signal_name
, get_comma(last
));
158 print_sockaddr(abi_ulong addr
, abi_long addrlen
)
160 struct target_sockaddr
*sa
;
164 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
166 sa_family
= tswap16(sa
->sa_family
);
169 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
171 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
172 for (i
= 0; i
< addrlen
-
173 offsetof(struct target_sockaddr_un
, sun_path
) &&
174 un
->sun_path
[i
]; i
++) {
175 gemu_log("%c", un
->sun_path
[i
]);
181 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
182 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
183 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
184 ntohs(in
->sin_port
));
185 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
186 c
[0], c
[1], c
[2], c
[3]);
191 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
192 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
193 gemu_log("{sll_family=AF_PACKET,"
194 "sll_protocol=htons(0x%04x),if%d,pkttype=",
195 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
196 switch (ll
->sll_pkttype
) {
198 gemu_log("PACKET_HOST");
200 case PACKET_BROADCAST
:
201 gemu_log("PACKET_BROADCAST");
203 case PACKET_MULTICAST
:
204 gemu_log("PACKET_MULTICAST");
206 case PACKET_OTHERHOST
:
207 gemu_log("PACKET_OTHERHOST");
209 case PACKET_OUTGOING
:
210 gemu_log("PACKET_OUTGOING");
213 gemu_log("%d", ll
->sll_pkttype
);
216 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
217 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
222 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
223 for (i
= 0; i
< 13; i
++) {
224 gemu_log("%02x, ", sa
->sa_data
[i
]);
226 gemu_log("%02x}", sa
->sa_data
[i
]);
230 unlock_user(sa
, addr
, 0);
232 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
234 gemu_log(", "TARGET_ABI_FMT_ld
, addrlen
);
238 print_socket_domain(int domain
)
248 gemu_log("PF_PACKET");
251 gemu_log("%d", domain
);
257 print_socket_type(int type
)
260 case TARGET_SOCK_DGRAM
:
261 gemu_log("SOCK_DGRAM");
263 case TARGET_SOCK_STREAM
:
264 gemu_log("SOCK_STREAM");
266 case TARGET_SOCK_RAW
:
267 gemu_log("SOCK_RAW");
269 case TARGET_SOCK_RDM
:
270 gemu_log("SOCK_RDM");
272 case TARGET_SOCK_SEQPACKET
:
273 gemu_log("SOCK_SEQPACKET");
275 case TARGET_SOCK_PACKET
:
276 gemu_log("SOCK_PACKET");
282 print_socket_protocol(int domain
, int type
, int protocol
)
284 if (domain
== AF_PACKET
||
285 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
288 gemu_log("ETH_P_ALL");
291 gemu_log("%d", protocol
);
298 gemu_log("IPPROTO_IP");
301 gemu_log("IPPROTO_TCP");
304 gemu_log("IPPROTO_UDP");
307 gemu_log("IPPROTO_RAW");
310 gemu_log("%d", protocol
);
316 #ifdef TARGET_NR__newselect
318 print_fdset(int n
, abi_ulong target_fds_addr
)
323 if( target_fds_addr
) {
324 abi_long
*target_fds
;
326 target_fds
= lock_user(VERIFY_READ
,
328 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
334 for (i
=n
; i
>=0; i
--) {
335 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
338 unlock_user(target_fds
, target_fds_addr
, 0);
345 * Sysycall specific output functions
349 #ifdef TARGET_NR__newselect
350 static long newselect_arg1
= 0;
351 static long newselect_arg2
= 0;
352 static long newselect_arg3
= 0;
353 static long newselect_arg4
= 0;
354 static long newselect_arg5
= 0;
357 print_newselect(const struct syscallname
*name
,
358 abi_long arg1
, abi_long arg2
, abi_long arg3
,
359 abi_long arg4
, abi_long arg5
, abi_long arg6
)
361 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
362 print_fdset(arg1
, arg2
);
364 print_fdset(arg1
, arg3
);
366 print_fdset(arg1
, arg4
);
368 print_timeval(arg5
, 1);
371 /* save for use in the return output function below */
380 #ifdef TARGET_NR_semctl
382 print_semctl(const struct syscallname
*name
,
383 abi_long arg1
, abi_long arg2
, abi_long arg3
,
384 abi_long arg4
, abi_long arg5
, abi_long arg6
)
386 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
388 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
393 print_execve(const struct syscallname
*name
,
394 abi_long arg1
, abi_long arg2
, abi_long arg3
,
395 abi_long arg4
, abi_long arg5
, abi_long arg6
)
397 abi_ulong arg_ptr_addr
;
400 if (!(s
= lock_user_string(arg1
)))
402 gemu_log("%s(\"%s\",{", name
->name
, s
);
403 unlock_user(s
, arg1
, 0);
405 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
406 abi_ulong
*arg_ptr
, arg_addr
;
408 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
411 arg_addr
= tswapal(*arg_ptr
);
412 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
415 if ((s
= lock_user_string(arg_addr
))) {
416 gemu_log("\"%s\",", s
);
417 unlock_user(s
, arg_addr
, 0);
426 print_ipc(const struct syscallname
*name
,
427 abi_long arg1
, abi_long arg2
, abi_long arg3
,
428 abi_long arg4
, abi_long arg5
, abi_long arg6
)
432 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
434 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
437 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
438 name
->name
, arg1
, arg2
, arg3
, arg4
);
444 * Variants for the return value output function
448 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
450 const char *errstr
= NULL
;
453 errstr
= target_strerror(-ret
);
456 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
458 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
462 #if 0 /* currently unused */
464 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
466 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
470 #ifdef TARGET_NR__newselect
472 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
474 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
475 print_fdset(newselect_arg1
,newselect_arg2
);
477 print_fdset(newselect_arg1
,newselect_arg3
);
479 print_fdset(newselect_arg1
,newselect_arg4
);
481 print_timeval(newselect_arg5
, 1);
486 UNUSED
static struct flags access_flags
[] = {
494 UNUSED
static struct flags at_file_flags
[] = {
496 FLAG_GENERIC(AT_EACCESS
),
498 #ifdef AT_SYMLINK_NOFOLLOW
499 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
504 UNUSED
static struct flags unlinkat_flags
[] = {
506 FLAG_GENERIC(AT_REMOVEDIR
),
511 UNUSED
static struct flags mode_flags
[] = {
512 FLAG_GENERIC(S_IFSOCK
),
513 FLAG_GENERIC(S_IFLNK
),
514 FLAG_GENERIC(S_IFREG
),
515 FLAG_GENERIC(S_IFBLK
),
516 FLAG_GENERIC(S_IFDIR
),
517 FLAG_GENERIC(S_IFCHR
),
518 FLAG_GENERIC(S_IFIFO
),
522 UNUSED
static struct flags open_access_flags
[] = {
523 FLAG_TARGET(O_RDONLY
),
524 FLAG_TARGET(O_WRONLY
),
529 UNUSED
static struct flags open_flags
[] = {
530 FLAG_TARGET(O_APPEND
),
531 FLAG_TARGET(O_CREAT
),
532 FLAG_TARGET(O_DIRECTORY
),
534 FLAG_TARGET(O_LARGEFILE
),
535 FLAG_TARGET(O_NOCTTY
),
536 FLAG_TARGET(O_NOFOLLOW
),
537 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
538 FLAG_TARGET(O_DSYNC
),
539 FLAG_TARGET(__O_SYNC
),
540 FLAG_TARGET(O_TRUNC
),
542 FLAG_TARGET(O_DIRECT
),
545 FLAG_TARGET(O_NOATIME
),
548 FLAG_TARGET(O_CLOEXEC
),
556 UNUSED
static struct flags mount_flags
[] = {
558 FLAG_GENERIC(MS_BIND
),
561 FLAG_GENERIC(MS_DIRSYNC
),
563 FLAG_GENERIC(MS_MANDLOCK
),
565 FLAG_GENERIC(MS_MOVE
),
567 FLAG_GENERIC(MS_NOATIME
),
568 FLAG_GENERIC(MS_NODEV
),
569 FLAG_GENERIC(MS_NODIRATIME
),
570 FLAG_GENERIC(MS_NOEXEC
),
571 FLAG_GENERIC(MS_NOSUID
),
572 FLAG_GENERIC(MS_RDONLY
),
574 FLAG_GENERIC(MS_RELATIME
),
576 FLAG_GENERIC(MS_REMOUNT
),
577 FLAG_GENERIC(MS_SYNCHRONOUS
),
581 UNUSED
static struct flags umount2_flags
[] = {
583 FLAG_GENERIC(MNT_FORCE
),
586 FLAG_GENERIC(MNT_DETACH
),
589 FLAG_GENERIC(MNT_EXPIRE
),
594 UNUSED
static struct flags mmap_prot_flags
[] = {
595 FLAG_GENERIC(PROT_NONE
),
596 FLAG_GENERIC(PROT_EXEC
),
597 FLAG_GENERIC(PROT_READ
),
598 FLAG_GENERIC(PROT_WRITE
),
599 FLAG_TARGET(PROT_SEM
),
600 FLAG_GENERIC(PROT_GROWSDOWN
),
601 FLAG_GENERIC(PROT_GROWSUP
),
605 UNUSED
static struct flags mmap_flags
[] = {
606 FLAG_TARGET(MAP_SHARED
),
607 FLAG_TARGET(MAP_PRIVATE
),
608 FLAG_TARGET(MAP_ANONYMOUS
),
609 FLAG_TARGET(MAP_DENYWRITE
),
610 FLAG_TARGET(MAP_FIXED
),
611 FLAG_TARGET(MAP_GROWSDOWN
),
612 FLAG_TARGET(MAP_EXECUTABLE
),
614 FLAG_TARGET(MAP_LOCKED
),
617 FLAG_TARGET(MAP_NONBLOCK
),
619 FLAG_TARGET(MAP_NORESERVE
),
621 FLAG_TARGET(MAP_POPULATE
),
623 #ifdef TARGET_MAP_UNINITIALIZED
624 FLAG_TARGET(MAP_UNINITIALIZED
),
629 UNUSED
static struct flags clone_flags
[] = {
630 FLAG_GENERIC(CLONE_VM
),
631 FLAG_GENERIC(CLONE_FS
),
632 FLAG_GENERIC(CLONE_FILES
),
633 FLAG_GENERIC(CLONE_SIGHAND
),
634 FLAG_GENERIC(CLONE_PTRACE
),
635 FLAG_GENERIC(CLONE_VFORK
),
636 FLAG_GENERIC(CLONE_PARENT
),
637 FLAG_GENERIC(CLONE_THREAD
),
638 FLAG_GENERIC(CLONE_NEWNS
),
639 FLAG_GENERIC(CLONE_SYSVSEM
),
640 FLAG_GENERIC(CLONE_SETTLS
),
641 FLAG_GENERIC(CLONE_PARENT_SETTID
),
642 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
643 FLAG_GENERIC(CLONE_DETACHED
),
644 FLAG_GENERIC(CLONE_UNTRACED
),
645 FLAG_GENERIC(CLONE_CHILD_SETTID
),
646 #if defined(CLONE_NEWUTS)
647 FLAG_GENERIC(CLONE_NEWUTS
),
649 #if defined(CLONE_NEWIPC)
650 FLAG_GENERIC(CLONE_NEWIPC
),
652 #if defined(CLONE_NEWUSER)
653 FLAG_GENERIC(CLONE_NEWUSER
),
655 #if defined(CLONE_NEWPID)
656 FLAG_GENERIC(CLONE_NEWPID
),
658 #if defined(CLONE_NEWNET)
659 FLAG_GENERIC(CLONE_NEWNET
),
661 #if defined(CLONE_IO)
662 FLAG_GENERIC(CLONE_IO
),
667 UNUSED
static struct flags msg_flags
[] = {
669 FLAG_GENERIC(MSG_CONFIRM
),
670 FLAG_GENERIC(MSG_DONTROUTE
),
671 FLAG_GENERIC(MSG_DONTWAIT
),
672 FLAG_GENERIC(MSG_EOR
),
673 FLAG_GENERIC(MSG_MORE
),
674 FLAG_GENERIC(MSG_NOSIGNAL
),
675 FLAG_GENERIC(MSG_OOB
),
677 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
678 FLAG_GENERIC(MSG_ERRQUEUE
),
679 FLAG_GENERIC(MSG_PEEK
),
680 FLAG_GENERIC(MSG_TRUNC
),
681 FLAG_GENERIC(MSG_WAITALL
),
683 FLAG_GENERIC(MSG_CTRUNC
),
688 * print_xxx utility functions. These are used to print syscall
689 * parameters in certain format. All of these have parameter
690 * named 'last'. This parameter is used to add comma to output
697 return ((last
) ? "" : ",");
701 print_flags(const struct flags
*f
, abi_long flags
, int last
)
703 const char *sep
= "";
706 if ((flags
== 0) && (f
->f_value
== 0)) {
707 gemu_log("%s%s", f
->f_string
, get_comma(last
));
710 for (n
= 0; f
->f_string
!= NULL
; f
++) {
711 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
712 gemu_log("%s%s", sep
, f
->f_string
);
713 flags
&= ~f
->f_value
;
720 /* print rest of the flags as numeric */
722 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
724 gemu_log("%s", get_comma(last
));
727 /* no string version of flags found, print them in hex then */
728 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
733 print_at_dirfd(abi_long dirfd
, int last
)
736 if (dirfd
== AT_FDCWD
) {
737 gemu_log("AT_FDCWD%s", get_comma(last
));
741 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
745 print_file_mode(abi_long mode
, int last
)
747 const char *sep
= "";
748 const struct flags
*m
;
750 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
751 if ((m
->f_value
& mode
) == m
->f_value
) {
752 gemu_log("%s%s", m
->f_string
, sep
);
760 /* print rest of the mode as octal */
762 gemu_log("%s%#o", sep
, (unsigned int)mode
);
764 gemu_log("%s", get_comma(last
));
768 print_open_flags(abi_long flags
, int last
)
770 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
771 flags
&= ~TARGET_O_ACCMODE
;
773 gemu_log("%s", get_comma(last
));
777 print_flags(open_flags
, flags
, last
);
781 print_syscall_prologue(const struct syscallname
*sc
)
783 gemu_log("%s(", sc
->name
);
788 print_syscall_epilogue(const struct syscallname
*sc
)
795 print_string(abi_long addr
, int last
)
799 if ((s
= lock_user_string(addr
)) != NULL
) {
800 gemu_log("\"%s\"%s", s
, get_comma(last
));
801 unlock_user(s
, addr
, 0);
803 /* can't get string out of it, so print it as pointer */
804 print_pointer(addr
, last
);
808 #define MAX_PRINT_BUF 40
810 print_buf(abi_long addr
, abi_long len
, int last
)
815 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
818 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
820 gemu_log("%c", s
[i
]);
822 gemu_log("\\%o", s
[i
]);
832 unlock_user(s
, addr
, 0);
834 print_pointer(addr
, last
);
839 * Prints out raw parameter using given format. Caller needs
840 * to do byte swapping if needed.
843 print_raw_param(const char *fmt
, abi_long param
, int last
)
847 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
848 gemu_log(format
, param
);
852 print_pointer(abi_long p
, int last
)
855 gemu_log("NULL%s", get_comma(last
));
857 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
861 * Reads 32-bit (int) number from guest address space from
862 * address 'addr' and prints it.
865 print_number(abi_long addr
, int last
)
868 gemu_log("NULL%s", get_comma(last
));
872 get_user_s32(num
, addr
);
873 gemu_log("[%d]%s", num
, get_comma(last
));
878 print_timeval(abi_ulong tv_addr
, int last
)
881 struct target_timeval
*tv
;
883 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
886 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
887 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
888 unlock_user(tv
, tv_addr
, 0);
890 gemu_log("NULL%s", get_comma(last
));
895 #ifdef TARGET_NR_accept
897 print_accept(const struct syscallname
*name
,
898 abi_long arg0
, abi_long arg1
, abi_long arg2
,
899 abi_long arg3
, abi_long arg4
, abi_long arg5
)
901 print_syscall_prologue(name
);
902 print_raw_param("%d", arg0
, 0);
903 print_pointer(arg1
, 0);
904 print_number(arg2
, 1);
905 print_syscall_epilogue(name
);
909 #ifdef TARGET_NR_access
911 print_access(const struct syscallname
*name
,
912 abi_long arg0
, abi_long arg1
, abi_long arg2
,
913 abi_long arg3
, abi_long arg4
, abi_long arg5
)
915 print_syscall_prologue(name
);
916 print_string(arg0
, 0);
917 print_flags(access_flags
, arg1
, 1);
918 print_syscall_epilogue(name
);
924 print_brk(const struct syscallname
*name
,
925 abi_long arg0
, abi_long arg1
, abi_long arg2
,
926 abi_long arg3
, abi_long arg4
, abi_long arg5
)
928 print_syscall_prologue(name
);
929 print_pointer(arg0
, 1);
930 print_syscall_epilogue(name
);
934 #ifdef TARGET_NR_chdir
936 print_chdir(const struct syscallname
*name
,
937 abi_long arg0
, abi_long arg1
, abi_long arg2
,
938 abi_long arg3
, abi_long arg4
, abi_long arg5
)
940 print_syscall_prologue(name
);
941 print_string(arg0
, 1);
942 print_syscall_epilogue(name
);
946 #ifdef TARGET_NR_chmod
948 print_chmod(const struct syscallname
*name
,
949 abi_long arg0
, abi_long arg1
, abi_long arg2
,
950 abi_long arg3
, abi_long arg4
, abi_long arg5
)
952 print_syscall_prologue(name
);
953 print_string(arg0
, 0);
954 print_file_mode(arg1
, 1);
955 print_syscall_epilogue(name
);
959 #ifdef TARGET_NR_clone
960 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
961 abi_ulong parent_tidptr
, target_ulong newtls
,
962 abi_ulong child_tidptr
)
964 print_flags(clone_flags
, flags
, 0);
965 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
966 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
967 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
968 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
972 print_clone(const struct syscallname
*name
,
973 abi_long arg1
, abi_long arg2
, abi_long arg3
,
974 abi_long arg4
, abi_long arg5
, abi_long arg6
)
976 print_syscall_prologue(name
);
977 #if defined(TARGET_MICROBLAZE)
978 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
979 #elif defined(TARGET_CLONE_BACKWARDS)
980 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
981 #elif defined(TARGET_CLONE_BACKWARDS2)
982 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
984 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
986 print_syscall_epilogue(name
);
990 #ifdef TARGET_NR_creat
992 print_creat(const struct syscallname
*name
,
993 abi_long arg0
, abi_long arg1
, abi_long arg2
,
994 abi_long arg3
, abi_long arg4
, abi_long arg5
)
996 print_syscall_prologue(name
);
997 print_string(arg0
, 0);
998 print_file_mode(arg1
, 1);
999 print_syscall_epilogue(name
);
1003 #ifdef TARGET_NR_execv
1005 print_execv(const struct syscallname
*name
,
1006 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1007 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1009 print_syscall_prologue(name
);
1010 print_string(arg0
, 0);
1011 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1012 print_syscall_epilogue(name
);
1016 #ifdef TARGET_NR_faccessat
1018 print_faccessat(const struct syscallname
*name
,
1019 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1020 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1022 print_syscall_prologue(name
);
1023 print_at_dirfd(arg0
, 0);
1024 print_string(arg1
, 0);
1025 print_flags(access_flags
, arg2
, 0);
1026 print_flags(at_file_flags
, arg3
, 1);
1027 print_syscall_epilogue(name
);
1031 #ifdef TARGET_NR_fchmodat
1033 print_fchmodat(const struct syscallname
*name
,
1034 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1035 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1037 print_syscall_prologue(name
);
1038 print_at_dirfd(arg0
, 0);
1039 print_string(arg1
, 0);
1040 print_file_mode(arg2
, 0);
1041 print_flags(at_file_flags
, arg3
, 1);
1042 print_syscall_epilogue(name
);
1046 #ifdef TARGET_NR_fchownat
1048 print_fchownat(const struct syscallname
*name
,
1049 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1050 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1052 print_syscall_prologue(name
);
1053 print_at_dirfd(arg0
, 0);
1054 print_string(arg1
, 0);
1055 print_raw_param("%d", arg2
, 0);
1056 print_raw_param("%d", arg3
, 0);
1057 print_flags(at_file_flags
, arg4
, 1);
1058 print_syscall_epilogue(name
);
1062 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1064 print_fcntl(const struct syscallname
*name
,
1065 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1066 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1068 print_syscall_prologue(name
);
1069 print_raw_param("%d", arg0
, 0);
1071 case TARGET_F_DUPFD
:
1072 gemu_log("F_DUPFD,");
1073 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1075 case TARGET_F_GETFD
:
1076 gemu_log("F_GETFD");
1078 case TARGET_F_SETFD
:
1079 gemu_log("F_SETFD,");
1080 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1082 case TARGET_F_GETFL
:
1083 gemu_log("F_GETFL");
1085 case TARGET_F_SETFL
:
1086 gemu_log("F_SETFL,");
1087 print_open_flags(arg2
, 1);
1089 case TARGET_F_GETLK
:
1090 gemu_log("F_GETLK,");
1091 print_pointer(arg2
, 1);
1093 case TARGET_F_SETLK
:
1094 gemu_log("F_SETLK,");
1095 print_pointer(arg2
, 1);
1097 case TARGET_F_SETLKW
:
1098 gemu_log("F_SETLKW,");
1099 print_pointer(arg2
, 1);
1101 case TARGET_F_GETOWN
:
1102 gemu_log("F_GETOWN");
1104 case TARGET_F_SETOWN
:
1105 gemu_log("F_SETOWN,");
1106 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1108 case TARGET_F_GETSIG
:
1109 gemu_log("F_GETSIG");
1111 case TARGET_F_SETSIG
:
1112 gemu_log("F_SETSIG,");
1113 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1115 #if TARGET_ABI_BITS == 32
1116 case TARGET_F_GETLK64
:
1117 gemu_log("F_GETLK64,");
1118 print_pointer(arg2
, 1);
1120 case TARGET_F_SETLK64
:
1121 gemu_log("F_SETLK64,");
1122 print_pointer(arg2
, 1);
1124 case TARGET_F_SETLKW64
:
1125 gemu_log("F_SETLKW64,");
1126 print_pointer(arg2
, 1);
1129 case TARGET_F_SETLEASE
:
1130 gemu_log("F_SETLEASE,");
1131 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1133 case TARGET_F_GETLEASE
:
1134 gemu_log("F_GETLEASE");
1136 case TARGET_F_SETPIPE_SZ
:
1137 gemu_log("F_SETPIPE_SZ,");
1138 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1140 case TARGET_F_GETPIPE_SZ
:
1141 gemu_log("F_GETPIPE_SZ");
1143 case TARGET_F_DUPFD_CLOEXEC
:
1144 gemu_log("F_DUPFD_CLOEXEC,");
1145 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1147 case TARGET_F_NOTIFY
:
1148 gemu_log("F_NOTIFY,");
1149 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1152 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1153 print_pointer(arg2
, 1);
1156 print_syscall_epilogue(name
);
1158 #define print_fcntl64 print_fcntl
1162 #ifdef TARGET_NR_futimesat
1164 print_futimesat(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_at_dirfd(arg0
, 0);
1170 print_string(arg1
, 0);
1171 print_timeval(arg2
, 0);
1172 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1173 print_syscall_epilogue(name
);
1177 #ifdef TARGET_NR_link
1179 print_link(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_string(arg1
, 1);
1186 print_syscall_epilogue(name
);
1190 #ifdef TARGET_NR_linkat
1192 print_linkat(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_at_dirfd(arg2
, 0);
1200 print_string(arg3
, 0);
1201 print_flags(at_file_flags
, arg4
, 1);
1202 print_syscall_epilogue(name
);
1206 #ifdef TARGET_NR__llseek
1208 print__llseek(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 const char *whence
= "UNKNOWN";
1213 print_syscall_prologue(name
);
1214 print_raw_param("%d", arg0
, 0);
1215 print_raw_param("%ld", arg1
, 0);
1216 print_raw_param("%ld", arg2
, 0);
1217 print_pointer(arg3
, 0);
1219 case SEEK_SET
: whence
= "SEEK_SET"; break;
1220 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1221 case SEEK_END
: whence
= "SEEK_END"; break;
1223 gemu_log("%s",whence
);
1224 print_syscall_epilogue(name
);
1228 #if defined(TARGET_NR_socket)
1230 print_socket(const struct syscallname
*name
,
1231 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1232 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1234 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1236 print_syscall_prologue(name
);
1237 print_socket_domain(domain
);
1239 print_socket_type(type
);
1241 if (domain
== AF_PACKET
||
1242 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1243 protocol
= tswap16(protocol
);
1245 print_socket_protocol(domain
, type
, protocol
);
1246 print_syscall_epilogue(name
);
1251 #if defined(TARGET_NR_socketcall)
1253 #define get_user_ualx(x, gaddr, idx) \
1254 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1256 static void do_print_socket(const char *name
, abi_long arg1
)
1258 abi_ulong domain
, type
, protocol
;
1260 get_user_ualx(domain
, arg1
, 0);
1261 get_user_ualx(type
, arg1
, 1);
1262 get_user_ualx(protocol
, arg1
, 2);
1263 gemu_log("%s(", name
);
1264 print_socket_domain(domain
);
1266 print_socket_type(type
);
1268 if (domain
== AF_PACKET
||
1269 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1270 protocol
= tswap16(protocol
);
1272 print_socket_protocol(domain
, type
, protocol
);
1276 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1278 abi_ulong sockfd
, addr
, addrlen
;
1280 get_user_ualx(sockfd
, arg1
, 0);
1281 get_user_ualx(addr
, arg1
, 1);
1282 get_user_ualx(addrlen
, arg1
, 2);
1284 gemu_log("%s(", name
);
1285 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1286 print_sockaddr(addr
, addrlen
);
1290 static void do_print_listen(const char *name
, abi_long arg1
)
1292 abi_ulong sockfd
, backlog
;
1294 get_user_ualx(sockfd
, arg1
, 0);
1295 get_user_ualx(backlog
, arg1
, 1);
1297 gemu_log("%s(", name
);
1298 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1299 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1303 static void do_print_socketpair(const char *name
, abi_long arg1
)
1305 abi_ulong domain
, type
, protocol
, tab
;
1307 get_user_ualx(domain
, arg1
, 0);
1308 get_user_ualx(type
, arg1
, 1);
1309 get_user_ualx(protocol
, arg1
, 2);
1310 get_user_ualx(tab
, arg1
, 3);
1312 gemu_log("%s(", name
);
1313 print_socket_domain(domain
);
1315 print_socket_type(type
);
1317 print_socket_protocol(domain
, type
, protocol
);
1319 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1323 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1325 abi_ulong sockfd
, msg
, len
, flags
;
1327 get_user_ualx(sockfd
, arg1
, 0);
1328 get_user_ualx(msg
, arg1
, 1);
1329 get_user_ualx(len
, arg1
, 2);
1330 get_user_ualx(flags
, arg1
, 3);
1332 gemu_log("%s(", name
);
1333 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1334 print_buf(msg
, len
, 0);
1335 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1336 print_flags(msg_flags
, flags
, 1);
1340 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1342 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1344 get_user_ualx(sockfd
, arg1
, 0);
1345 get_user_ualx(msg
, arg1
, 1);
1346 get_user_ualx(len
, arg1
, 2);
1347 get_user_ualx(flags
, arg1
, 3);
1348 get_user_ualx(addr
, arg1
, 4);
1349 get_user_ualx(addrlen
, arg1
, 5);
1351 gemu_log("%s(", name
);
1352 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1353 print_buf(msg
, len
, 0);
1354 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1355 print_flags(msg_flags
, flags
, 0);
1356 print_sockaddr(addr
, addrlen
);
1360 static void do_print_shutdown(const char *name
, abi_long arg1
)
1362 abi_ulong sockfd
, how
;
1364 get_user_ualx(sockfd
, arg1
, 0);
1365 get_user_ualx(how
, arg1
, 1);
1367 gemu_log("shutdown(");
1368 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1371 gemu_log("SHUT_RD");
1374 gemu_log("SHUT_WR");
1377 gemu_log("SHUT_RDWR");
1380 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1386 static void do_print_msg(const char *name
, abi_long arg1
)
1388 abi_ulong sockfd
, msg
, flags
;
1390 get_user_ualx(sockfd
, arg1
, 0);
1391 get_user_ualx(msg
, arg1
, 1);
1392 get_user_ualx(flags
, arg1
, 2);
1394 gemu_log("%s(", name
);
1395 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1396 print_pointer(msg
, 0);
1397 print_flags(msg_flags
, flags
, 1);
1401 static void do_print_sockopt(const char *name
, abi_long arg1
)
1403 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1405 get_user_ualx(sockfd
, arg1
, 0);
1406 get_user_ualx(level
, arg1
, 1);
1407 get_user_ualx(optname
, arg1
, 2);
1408 get_user_ualx(optval
, arg1
, 3);
1409 get_user_ualx(optlen
, arg1
, 4);
1411 gemu_log("%s(", name
);
1412 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1415 gemu_log("SOL_TCP,");
1416 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1417 print_pointer(optval
, 0);
1420 gemu_log("SOL_IP,");
1421 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1422 print_pointer(optval
, 0);
1425 gemu_log("SOL_RAW,");
1426 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1427 print_pointer(optval
, 0);
1429 case TARGET_SOL_SOCKET
:
1430 gemu_log("SOL_SOCKET,");
1432 case TARGET_SO_DEBUG
:
1433 gemu_log("SO_DEBUG,");
1435 print_number(optval
, 0);
1437 case TARGET_SO_REUSEADDR
:
1438 gemu_log("SO_REUSEADDR,");
1440 case TARGET_SO_TYPE
:
1441 gemu_log("SO_TYPE,");
1443 case TARGET_SO_ERROR
:
1444 gemu_log("SO_ERROR,");
1446 case TARGET_SO_DONTROUTE
:
1447 gemu_log("SO_DONTROUTE,");
1449 case TARGET_SO_BROADCAST
:
1450 gemu_log("SO_BROADCAST,");
1452 case TARGET_SO_SNDBUF
:
1453 gemu_log("SO_SNDBUF,");
1455 case TARGET_SO_RCVBUF
:
1456 gemu_log("SO_RCVBUF,");
1458 case TARGET_SO_KEEPALIVE
:
1459 gemu_log("SO_KEEPALIVE,");
1461 case TARGET_SO_OOBINLINE
:
1462 gemu_log("SO_OOBINLINE,");
1464 case TARGET_SO_NO_CHECK
:
1465 gemu_log("SO_NO_CHECK,");
1467 case TARGET_SO_PRIORITY
:
1468 gemu_log("SO_PRIORITY,");
1470 case TARGET_SO_BSDCOMPAT
:
1471 gemu_log("SO_BSDCOMPAT,");
1473 case TARGET_SO_PASSCRED
:
1474 gemu_log("SO_PASSCRED,");
1476 case TARGET_SO_TIMESTAMP
:
1477 gemu_log("SO_TIMESTAMP,");
1479 case TARGET_SO_RCVLOWAT
:
1480 gemu_log("SO_RCVLOWAT,");
1482 case TARGET_SO_RCVTIMEO
:
1483 gemu_log("SO_RCVTIMEO,");
1484 print_timeval(optval
, 0);
1486 case TARGET_SO_SNDTIMEO
:
1487 gemu_log("SO_SNDTIMEO,");
1488 print_timeval(optval
, 0);
1490 case TARGET_SO_ATTACH_FILTER
: {
1491 struct target_sock_fprog
*fprog
;
1493 gemu_log("SO_ATTACH_FILTER,");
1495 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1496 struct target_sock_filter
*filter
;
1498 if (lock_user_struct(VERIFY_READ
, filter
,
1499 tswapal(fprog
->filter
), 0)) {
1501 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1502 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1503 i
, tswap16(filter
[i
].code
),
1504 filter
[i
].jt
, filter
[i
].jf
,
1505 tswap32(filter
[i
].k
));
1507 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1508 i
, tswap16(filter
[i
].code
),
1509 filter
[i
].jt
, filter
[i
].jf
,
1510 tswap32(filter
[i
].k
));
1512 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1514 gemu_log(",%d},", tswap16(fprog
->len
));
1515 unlock_user(fprog
, optval
, 0);
1517 print_pointer(optval
, 0);
1522 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1523 print_pointer(optval
, 0);
1528 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
1529 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1530 print_pointer(optval
, 0);
1533 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
1537 #define PRINT_SOCKOP(name, func) \
1538 [SOCKOP_##name] = { #name, func }
1542 void (*print
)(const char *, abi_long
);
1544 PRINT_SOCKOP(socket
, do_print_socket
),
1545 PRINT_SOCKOP(bind
, do_print_sockaddr
),
1546 PRINT_SOCKOP(connect
, do_print_sockaddr
),
1547 PRINT_SOCKOP(listen
, do_print_listen
),
1548 PRINT_SOCKOP(accept
, do_print_sockaddr
),
1549 PRINT_SOCKOP(getsockname
, do_print_sockaddr
),
1550 PRINT_SOCKOP(getpeername
, do_print_sockaddr
),
1551 PRINT_SOCKOP(socketpair
, do_print_socketpair
),
1552 PRINT_SOCKOP(send
, do_print_sendrecv
),
1553 PRINT_SOCKOP(recv
, do_print_sendrecv
),
1554 PRINT_SOCKOP(sendto
, do_print_msgaddr
),
1555 PRINT_SOCKOP(recvfrom
, do_print_msgaddr
),
1556 PRINT_SOCKOP(shutdown
, do_print_shutdown
),
1557 PRINT_SOCKOP(sendmsg
, do_print_msg
),
1558 PRINT_SOCKOP(recvmsg
, do_print_msg
),
1559 PRINT_SOCKOP(setsockopt
, do_print_sockopt
),
1560 PRINT_SOCKOP(getsockopt
, do_print_sockopt
),
1564 print_socketcall(const struct syscallname
*name
,
1565 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1566 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1568 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
1569 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
1572 print_syscall_prologue(name
);
1573 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
1574 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1575 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1576 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
1577 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
1578 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
1579 print_syscall_epilogue(name
);
1583 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1584 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
1586 print_stat(const struct syscallname
*name
,
1587 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1588 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1590 print_syscall_prologue(name
);
1591 print_string(arg0
, 0);
1592 print_pointer(arg1
, 1);
1593 print_syscall_epilogue(name
);
1595 #define print_lstat print_stat
1596 #define print_stat64 print_stat
1597 #define print_lstat64 print_stat
1600 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
1602 print_fstat(const struct syscallname
*name
,
1603 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1604 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1606 print_syscall_prologue(name
);
1607 print_raw_param("%d", arg0
, 0);
1608 print_pointer(arg1
, 1);
1609 print_syscall_epilogue(name
);
1611 #define print_fstat64 print_fstat
1614 #ifdef TARGET_NR_mkdir
1616 print_mkdir(const struct syscallname
*name
,
1617 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1618 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1620 print_syscall_prologue(name
);
1621 print_string(arg0
, 0);
1622 print_file_mode(arg1
, 1);
1623 print_syscall_epilogue(name
);
1627 #ifdef TARGET_NR_mkdirat
1629 print_mkdirat(const struct syscallname
*name
,
1630 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1631 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1633 print_syscall_prologue(name
);
1634 print_at_dirfd(arg0
, 0);
1635 print_string(arg1
, 0);
1636 print_file_mode(arg2
, 1);
1637 print_syscall_epilogue(name
);
1641 #ifdef TARGET_NR_rmdir
1643 print_rmdir(const struct syscallname
*name
,
1644 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1645 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1647 print_syscall_prologue(name
);
1648 print_string(arg0
, 0);
1649 print_syscall_epilogue(name
);
1653 #ifdef TARGET_NR_rt_sigaction
1655 print_rt_sigaction(const struct syscallname
*name
,
1656 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1657 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1659 print_syscall_prologue(name
);
1660 print_signal(arg0
, 0);
1661 print_pointer(arg1
, 0);
1662 print_pointer(arg2
, 1);
1663 print_syscall_epilogue(name
);
1667 #ifdef TARGET_NR_rt_sigprocmask
1669 print_rt_sigprocmask(const struct syscallname
*name
,
1670 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1671 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1673 const char *how
= "UNKNOWN";
1674 print_syscall_prologue(name
);
1676 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
1677 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
1678 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
1680 gemu_log("%s,",how
);
1681 print_pointer(arg1
, 0);
1682 print_pointer(arg2
, 1);
1683 print_syscall_epilogue(name
);
1687 #ifdef TARGET_NR_mknod
1689 print_mknod(const struct syscallname
*name
,
1690 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1691 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1693 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
1695 print_syscall_prologue(name
);
1696 print_string(arg0
, 0);
1697 print_file_mode(arg1
, (hasdev
== 0));
1699 print_raw_param("makedev(%d", major(arg2
), 0);
1700 print_raw_param("%d)", minor(arg2
), 1);
1702 print_syscall_epilogue(name
);
1706 #ifdef TARGET_NR_mknodat
1708 print_mknodat(const struct syscallname
*name
,
1709 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1710 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1712 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
1714 print_syscall_prologue(name
);
1715 print_at_dirfd(arg0
, 0);
1716 print_string(arg1
, 0);
1717 print_file_mode(arg2
, (hasdev
== 0));
1719 print_raw_param("makedev(%d", major(arg3
), 0);
1720 print_raw_param("%d)", minor(arg3
), 1);
1722 print_syscall_epilogue(name
);
1726 #ifdef TARGET_NR_mq_open
1728 print_mq_open(const struct syscallname
*name
,
1729 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1730 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1732 int is_creat
= (arg1
& TARGET_O_CREAT
);
1734 print_syscall_prologue(name
);
1735 print_string(arg0
, 0);
1736 print_open_flags(arg1
, (is_creat
== 0));
1738 print_file_mode(arg2
, 0);
1739 print_pointer(arg3
, 1);
1741 print_syscall_epilogue(name
);
1745 #ifdef TARGET_NR_open
1747 print_open(const struct syscallname
*name
,
1748 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1749 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1751 int is_creat
= (arg1
& TARGET_O_CREAT
);
1753 print_syscall_prologue(name
);
1754 print_string(arg0
, 0);
1755 print_open_flags(arg1
, (is_creat
== 0));
1757 print_file_mode(arg2
, 1);
1758 print_syscall_epilogue(name
);
1762 #ifdef TARGET_NR_openat
1764 print_openat(const struct syscallname
*name
,
1765 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1766 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1768 int is_creat
= (arg2
& TARGET_O_CREAT
);
1770 print_syscall_prologue(name
);
1771 print_at_dirfd(arg0
, 0);
1772 print_string(arg1
, 0);
1773 print_open_flags(arg2
, (is_creat
== 0));
1775 print_file_mode(arg3
, 1);
1776 print_syscall_epilogue(name
);
1780 #ifdef TARGET_NR_mq_unlink
1782 print_mq_unlink(const struct syscallname
*name
,
1783 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1784 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1786 print_syscall_prologue(name
);
1787 print_string(arg0
, 1);
1788 print_syscall_epilogue(name
);
1792 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
1794 print_fstatat64(const struct syscallname
*name
,
1795 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1796 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1798 print_syscall_prologue(name
);
1799 print_at_dirfd(arg0
, 0);
1800 print_string(arg1
, 0);
1801 print_pointer(arg2
, 0);
1802 print_flags(at_file_flags
, arg3
, 1);
1803 print_syscall_epilogue(name
);
1805 #define print_newfstatat print_fstatat64
1808 #ifdef TARGET_NR_readlink
1810 print_readlink(const struct syscallname
*name
,
1811 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1812 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1814 print_syscall_prologue(name
);
1815 print_string(arg0
, 0);
1816 print_pointer(arg1
, 0);
1817 print_raw_param("%u", arg2
, 1);
1818 print_syscall_epilogue(name
);
1822 #ifdef TARGET_NR_readlinkat
1824 print_readlinkat(const struct syscallname
*name
,
1825 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1826 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1828 print_syscall_prologue(name
);
1829 print_at_dirfd(arg0
, 0);
1830 print_string(arg1
, 0);
1831 print_pointer(arg2
, 0);
1832 print_raw_param("%u", arg3
, 1);
1833 print_syscall_epilogue(name
);
1837 #ifdef TARGET_NR_rename
1839 print_rename(const struct syscallname
*name
,
1840 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1841 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1843 print_syscall_prologue(name
);
1844 print_string(arg0
, 0);
1845 print_string(arg1
, 1);
1846 print_syscall_epilogue(name
);
1850 #ifdef TARGET_NR_renameat
1852 print_renameat(const struct syscallname
*name
,
1853 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1854 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1856 print_syscall_prologue(name
);
1857 print_at_dirfd(arg0
, 0);
1858 print_string(arg1
, 0);
1859 print_at_dirfd(arg2
, 0);
1860 print_string(arg3
, 1);
1861 print_syscall_epilogue(name
);
1865 #ifdef TARGET_NR_statfs
1867 print_statfs(const struct syscallname
*name
,
1868 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1869 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1871 print_syscall_prologue(name
);
1872 print_string(arg0
, 0);
1873 print_pointer(arg1
, 1);
1874 print_syscall_epilogue(name
);
1876 #define print_statfs64 print_statfs
1879 #ifdef TARGET_NR_symlink
1881 print_symlink(const struct syscallname
*name
,
1882 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1883 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1885 print_syscall_prologue(name
);
1886 print_string(arg0
, 0);
1887 print_string(arg1
, 1);
1888 print_syscall_epilogue(name
);
1892 #ifdef TARGET_NR_symlinkat
1894 print_symlinkat(const struct syscallname
*name
,
1895 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1896 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1898 print_syscall_prologue(name
);
1899 print_string(arg0
, 0);
1900 print_at_dirfd(arg1
, 0);
1901 print_string(arg2
, 1);
1902 print_syscall_epilogue(name
);
1906 #ifdef TARGET_NR_mount
1908 print_mount(const struct syscallname
*name
,
1909 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1910 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1912 print_syscall_prologue(name
);
1913 print_string(arg0
, 0);
1914 print_string(arg1
, 0);
1915 print_string(arg2
, 0);
1916 print_flags(mount_flags
, arg3
, 0);
1917 print_pointer(arg4
, 1);
1918 print_syscall_epilogue(name
);
1922 #ifdef TARGET_NR_umount
1924 print_umount(const struct syscallname
*name
,
1925 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1926 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1928 print_syscall_prologue(name
);
1929 print_string(arg0
, 1);
1930 print_syscall_epilogue(name
);
1934 #ifdef TARGET_NR_umount2
1936 print_umount2(const struct syscallname
*name
,
1937 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1938 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1940 print_syscall_prologue(name
);
1941 print_string(arg0
, 0);
1942 print_flags(umount2_flags
, arg1
, 1);
1943 print_syscall_epilogue(name
);
1947 #ifdef TARGET_NR_unlink
1949 print_unlink(const struct syscallname
*name
,
1950 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1951 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1953 print_syscall_prologue(name
);
1954 print_string(arg0
, 1);
1955 print_syscall_epilogue(name
);
1959 #ifdef TARGET_NR_unlinkat
1961 print_unlinkat(const struct syscallname
*name
,
1962 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1963 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1965 print_syscall_prologue(name
);
1966 print_at_dirfd(arg0
, 0);
1967 print_string(arg1
, 0);
1968 print_flags(unlinkat_flags
, arg2
, 1);
1969 print_syscall_epilogue(name
);
1973 #ifdef TARGET_NR_utime
1975 print_utime(const struct syscallname
*name
,
1976 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1977 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1979 print_syscall_prologue(name
);
1980 print_string(arg0
, 0);
1981 print_pointer(arg1
, 1);
1982 print_syscall_epilogue(name
);
1986 #ifdef TARGET_NR_utimes
1988 print_utimes(const struct syscallname
*name
,
1989 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1990 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1992 print_syscall_prologue(name
);
1993 print_string(arg0
, 0);
1994 print_pointer(arg1
, 1);
1995 print_syscall_epilogue(name
);
1999 #ifdef TARGET_NR_utimensat
2001 print_utimensat(const struct syscallname
*name
,
2002 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2003 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2005 print_syscall_prologue(name
);
2006 print_at_dirfd(arg0
, 0);
2007 print_string(arg1
, 0);
2008 print_pointer(arg2
, 0);
2009 print_flags(at_file_flags
, arg3
, 1);
2010 print_syscall_epilogue(name
);
2014 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2016 print_mmap(const struct syscallname
*name
,
2017 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2018 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2020 print_syscall_prologue(name
);
2021 print_pointer(arg0
, 0);
2022 print_raw_param("%d", arg1
, 0);
2023 print_flags(mmap_prot_flags
, arg2
, 0);
2024 print_flags(mmap_flags
, arg3
, 0);
2025 print_raw_param("%d", arg4
, 0);
2026 print_raw_param("%#x", arg5
, 1);
2027 print_syscall_epilogue(name
);
2029 #define print_mmap2 print_mmap
2032 #ifdef TARGET_NR_mprotect
2034 print_mprotect(const struct syscallname
*name
,
2035 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2036 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2038 print_syscall_prologue(name
);
2039 print_pointer(arg0
, 0);
2040 print_raw_param("%d", arg1
, 0);
2041 print_flags(mmap_prot_flags
, arg2
, 1);
2042 print_syscall_epilogue(name
);
2046 #ifdef TARGET_NR_munmap
2048 print_munmap(const struct syscallname
*name
,
2049 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2050 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2052 print_syscall_prologue(name
);
2053 print_pointer(arg0
, 0);
2054 print_raw_param("%d", arg1
, 1);
2055 print_syscall_epilogue(name
);
2059 #ifdef TARGET_NR_futex
2060 static void print_futex_op(abi_long tflag
, int last
)
2062 #define print_op(val) \
2063 if( cmd == val ) { \
2068 int cmd
= (int)tflag
;
2069 #ifdef FUTEX_PRIVATE_FLAG
2070 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2071 gemu_log("FUTEX_PRIVATE_FLAG|");
2072 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2075 #ifdef FUTEX_CLOCK_REALTIME
2076 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2077 gemu_log("FUTEX_CLOCK_REALTIME|");
2078 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2081 print_op(FUTEX_WAIT
)
2082 print_op(FUTEX_WAKE
)
2084 print_op(FUTEX_REQUEUE
)
2085 print_op(FUTEX_CMP_REQUEUE
)
2086 print_op(FUTEX_WAKE_OP
)
2087 print_op(FUTEX_LOCK_PI
)
2088 print_op(FUTEX_UNLOCK_PI
)
2089 print_op(FUTEX_TRYLOCK_PI
)
2090 #ifdef FUTEX_WAIT_BITSET
2091 print_op(FUTEX_WAIT_BITSET
)
2093 #ifdef FUTEX_WAKE_BITSET
2094 print_op(FUTEX_WAKE_BITSET
)
2096 /* unknown values */
2101 print_futex(const struct syscallname
*name
,
2102 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2103 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2105 print_syscall_prologue(name
);
2106 print_pointer(arg0
, 0);
2107 print_futex_op(arg1
, 0);
2108 print_raw_param(",%d", arg2
, 0);
2109 print_pointer(arg3
, 0); /* struct timespec */
2110 print_pointer(arg4
, 0);
2111 print_raw_param("%d", arg4
, 1);
2112 print_syscall_epilogue(name
);
2116 #ifdef TARGET_NR_kill
2118 print_kill(const struct syscallname
*name
,
2119 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2120 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2122 print_syscall_prologue(name
);
2123 print_raw_param("%d", arg0
, 0);
2124 print_signal(arg1
, 1);
2125 print_syscall_epilogue(name
);
2130 * An array of all of the syscalls we know about
2133 static const struct syscallname scnames
[] = {
2134 #include "strace.list"
2137 static int nsyscalls
= ARRAY_SIZE(scnames
);
2140 * The public interface to this module.
2143 print_syscall(int num
,
2144 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2145 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2148 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
")";
2150 gemu_log("%d ", getpid() );
2152 for(i
=0;i
<nsyscalls
;i
++)
2153 if( scnames
[i
].nr
== num
) {
2154 if( scnames
[i
].call
!= NULL
) {
2155 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2157 /* XXX: this format system is broken because it uses
2158 host types and host pointers for strings */
2159 if( scnames
[i
].format
!= NULL
)
2160 format
= scnames
[i
].format
;
2161 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2165 gemu_log("Unknown syscall %d\n", num
);
2170 print_syscall_ret(int num
, abi_long ret
)
2173 const char *errstr
= NULL
;
2175 for(i
=0;i
<nsyscalls
;i
++)
2176 if( scnames
[i
].nr
== num
) {
2177 if( scnames
[i
].result
!= NULL
) {
2178 scnames
[i
].result(&scnames
[i
],ret
);
2181 errstr
= target_strerror(-ret
);
2184 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2187 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);