1 #include "qemu/osdep.h"
7 #include <sys/select.h>
10 #include <netinet/in.h>
11 #include <netinet/tcp.h>
12 #include <netinet/udp.h>
13 #include <linux/if_packet.h>
14 #include <linux/in6.h>
15 #include <linux/netlink.h>
18 #include "user-internals.h"
20 #include "signal-common.h"
21 #include "target_mman.h"
27 void (*call
)(CPUArchState
*, const struct syscallname
*,
28 abi_long
, abi_long
, abi_long
,
29 abi_long
, abi_long
, abi_long
);
30 void (*result
)(CPUArchState
*, const struct syscallname
*, abi_long
,
31 abi_long
, abi_long
, abi_long
,
32 abi_long
, abi_long
, abi_long
);
36 * It is possible that target doesn't have syscall that uses
37 * following flags but we don't want the compiler to warn
38 * us about them being unused. Same applies to utility print
39 * functions. It is ok to keep them while not used.
41 #define UNUSED __attribute__ ((unused))
44 * Structure used to translate flag values into strings. This is
45 * similar that is in the actual strace tool.
48 abi_long f_value
; /* flag */
49 abi_long f_mask
; /* mask */
50 const char *f_string
; /* stringified flag */
53 /* No 'struct flags' element should have a zero mask. */
54 #define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }
56 /* common flags for all architectures */
57 #define FLAG_GENERIC_MASK(V, M) FLAG_BASIC(V, M, #V)
58 #define FLAG_GENERIC(V) FLAG_BASIC(V, V, #V)
59 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
60 #define FLAG_TARGET_MASK(V, M) FLAG_BASIC(TARGET_##V, TARGET_##M, #V)
61 #define FLAG_TARGET(V) FLAG_BASIC(TARGET_##V, TARGET_##V, #V)
62 /* end of flags array */
63 #define FLAG_END { 0, 0, NULL }
65 /* Structure used to translate enumerated values into strings */
67 abi_long e_value
; /* enum value */
68 const char *e_string
; /* stringified enum */
71 /* common enums for all architectures */
72 #define ENUM_GENERIC(name) { name, #name }
73 /* target specific enums */
74 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
75 /* end of enums array */
76 #define ENUM_END { 0, NULL }
78 UNUSED
static const char *get_comma(int);
79 UNUSED
static void print_pointer(abi_long
, int);
80 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
81 UNUSED
static void print_enums(const struct enums
*, abi_long
, int);
82 UNUSED
static void print_at_dirfd(abi_long
, int);
83 UNUSED
static void print_file_mode(abi_long
, int);
84 UNUSED
static void print_open_flags(abi_long
, int);
85 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
86 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
87 UNUSED
static void print_string(abi_long
, int);
88 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
89 UNUSED
static void print_raw_param(const char *, abi_long
, int);
90 UNUSED
static void print_raw_param64(const char *, long long, int last
);
91 UNUSED
static void print_timeval(abi_ulong
, int);
92 UNUSED
static void print_timespec(abi_ulong
, int);
93 UNUSED
static void print_timespec64(abi_ulong
, int);
94 UNUSED
static void print_timezone(abi_ulong
, int);
95 UNUSED
static void print_itimerval(abi_ulong
, int);
96 UNUSED
static void print_number(abi_long
, int);
97 UNUSED
static void print_signal(abi_ulong
, int);
98 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
99 UNUSED
static void print_socket_domain(int domain
);
100 UNUSED
static void print_socket_type(int type
);
101 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
107 print_ipc_cmd(int cmd
)
109 #define output_cmd(val) \
117 /* General IPC commands */
118 output_cmd( IPC_RMID
);
119 output_cmd( IPC_SET
);
120 output_cmd( IPC_STAT
);
121 output_cmd( IPC_INFO
);
122 /* msgctl() commands */
123 output_cmd( MSG_STAT
);
124 output_cmd( MSG_INFO
);
125 /* shmctl() commands */
126 output_cmd( SHM_LOCK
);
127 output_cmd( SHM_UNLOCK
);
128 output_cmd( SHM_STAT
);
129 output_cmd( SHM_INFO
);
130 /* semctl() commands */
131 output_cmd( GETPID
);
132 output_cmd( GETVAL
);
133 output_cmd( GETALL
);
134 output_cmd( GETNCNT
);
135 output_cmd( GETZCNT
);
136 output_cmd( SETVAL
);
137 output_cmd( SETALL
);
138 output_cmd( SEM_STAT
);
139 output_cmd( SEM_INFO
);
140 output_cmd( IPC_RMID
);
141 output_cmd( IPC_RMID
);
142 output_cmd( IPC_RMID
);
143 output_cmd( IPC_RMID
);
144 output_cmd( IPC_RMID
);
145 output_cmd( IPC_RMID
);
146 output_cmd( IPC_RMID
);
147 output_cmd( IPC_RMID
);
148 output_cmd( IPC_RMID
);
150 /* Some value we don't recognize */
154 static const char * const target_signal_name
[] = {
155 #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig,
157 #undef MAKE_SIG_ENTRY
161 print_signal(abi_ulong arg
, int last
)
163 const char *signal_name
= NULL
;
165 if (arg
< ARRAY_SIZE(target_signal_name
)) {
166 signal_name
= target_signal_name
[arg
];
169 if (signal_name
== NULL
) {
170 print_raw_param("%ld", arg
, last
);
173 qemu_log("%s%s", signal_name
, get_comma(last
));
176 static void print_si_code(int arg
)
178 const char *codename
= NULL
;
182 codename
= "SI_USER";
185 codename
= "SI_KERNEL";
188 codename
= "SI_QUEUE";
191 codename
= "SI_TIMER";
194 codename
= "SI_MESGQ";
197 codename
= "SI_ASYNCIO";
200 codename
= "SI_SIGIO";
203 codename
= "SI_TKILL";
209 qemu_log("%s", codename
);
212 static void get_target_siginfo(target_siginfo_t
*tinfo
,
213 const target_siginfo_t
*info
)
222 __get_user(sig
, &info
->si_signo
);
223 __get_user(si_errno
, &tinfo
->si_errno
);
224 __get_user(si_code
, &info
->si_code
);
226 tinfo
->si_signo
= sig
;
227 tinfo
->si_errno
= si_errno
;
228 tinfo
->si_code
= si_code
;
230 /* Ensure we don't leak random junk to the guest later */
231 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
233 /* This is awkward, because we have to use a combination of
234 * the si_code and si_signo to figure out which of the union's
235 * members are valid. (Within the host kernel it is always possible
236 * to tell, but the kernel carefully avoids giving userspace the
237 * high 16 bits of si_code, so we don't have the information to
238 * do this the easy way...) We therefore make our best guess,
239 * bearing in mind that a guest can spoof most of the si_codes
240 * via rt_sigqueueinfo() if it likes.
242 * Once we have made our guess, we record it in the top 16 bits of
243 * the si_code, so that print_siginfo() later can use it.
244 * print_siginfo() will strip these top bits out before printing
252 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
253 * These are the only unspoofable si_code values.
255 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
256 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
257 si_type
= QEMU_SI_KILL
;
260 /* Everything else is spoofable. Make best guess based on signal */
263 __get_user(tinfo
->_sifields
._sigchld
._pid
,
264 &info
->_sifields
._sigchld
._pid
);
265 __get_user(tinfo
->_sifields
._sigchld
._uid
,
266 &info
->_sifields
._sigchld
._uid
);
267 __get_user(tinfo
->_sifields
._sigchld
._status
,
268 &info
->_sifields
._sigchld
._status
);
269 __get_user(tinfo
->_sifields
._sigchld
._utime
,
270 &info
->_sifields
._sigchld
._utime
);
271 __get_user(tinfo
->_sifields
._sigchld
._stime
,
272 &info
->_sifields
._sigchld
._stime
);
273 si_type
= QEMU_SI_CHLD
;
276 __get_user(tinfo
->_sifields
._sigpoll
._band
,
277 &info
->_sifields
._sigpoll
._band
);
278 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
279 &info
->_sifields
._sigpoll
._fd
);
280 si_type
= QEMU_SI_POLL
;
283 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
284 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
285 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
286 /* XXX: potential problem if 64 bit */
287 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
288 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
290 si_type
= QEMU_SI_RT
;
296 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
299 static void print_siginfo(const target_siginfo_t
*tinfo
)
301 /* Print a target_siginfo_t in the format desired for printing
302 * signals being taken. We assume the target_siginfo_t is in the
303 * internal form where the top 16 bits of si_code indicate which
304 * part of the union is valid, rather than in the guest-visible
305 * form where the bottom 16 bits are sign-extended into the top 16.
307 int si_type
= extract32(tinfo
->si_code
, 16, 16);
308 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
310 qemu_log("{si_signo=");
311 print_signal(tinfo
->si_signo
, 1);
312 qemu_log(", si_code=");
313 print_si_code(si_code
);
317 qemu_log(", si_pid=%u, si_uid=%u",
318 (unsigned int)tinfo
->_sifields
._kill
._pid
,
319 (unsigned int)tinfo
->_sifields
._kill
._uid
);
322 qemu_log(", si_timer1=%u, si_timer2=%u",
323 tinfo
->_sifields
._timer
._timer1
,
324 tinfo
->_sifields
._timer
._timer2
);
327 qemu_log(", si_band=%d, si_fd=%d",
328 tinfo
->_sifields
._sigpoll
._band
,
329 tinfo
->_sifields
._sigpoll
._fd
);
332 qemu_log(", si_addr=");
333 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
336 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
337 ", si_utime=" TARGET_ABI_FMT_ld
338 ", si_stime=" TARGET_ABI_FMT_ld
,
339 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
340 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
341 tinfo
->_sifields
._sigchld
._status
,
342 tinfo
->_sifields
._sigchld
._utime
,
343 tinfo
->_sifields
._sigchld
._stime
);
346 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
347 (unsigned int)tinfo
->_sifields
._rt
._pid
,
348 (unsigned int)tinfo
->_sifields
._rt
._uid
,
349 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
352 g_assert_not_reached();
358 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
360 struct target_sockaddr
*sa
;
364 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
366 sa_family
= tswap16(sa
->sa_family
);
369 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
370 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
371 for (i
= 0; i
< addrlen
-
372 offsetof(struct target_sockaddr_un
, sun_path
) &&
373 un
->sun_path
[i
]; i
++) {
374 qemu_log("%c", un
->sun_path
[i
]);
380 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
381 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
382 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
383 ntohs(in
->sin_port
));
384 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
385 c
[0], c
[1], c
[2], c
[3]);
390 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
391 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
392 qemu_log("{sll_family=AF_PACKET,"
393 "sll_protocol=htons(0x%04x),if%d,pkttype=",
394 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
395 switch (ll
->sll_pkttype
) {
397 qemu_log("PACKET_HOST");
399 case PACKET_BROADCAST
:
400 qemu_log("PACKET_BROADCAST");
402 case PACKET_MULTICAST
:
403 qemu_log("PACKET_MULTICAST");
405 case PACKET_OTHERHOST
:
406 qemu_log("PACKET_OTHERHOST");
408 case PACKET_OUTGOING
:
409 qemu_log("PACKET_OUTGOING");
412 qemu_log("%d", ll
->sll_pkttype
);
415 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
416 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
421 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
422 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
423 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
427 qemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
428 for (i
= 0; i
< 13; i
++) {
429 qemu_log("%02x, ", sa
->sa_data
[i
]);
431 qemu_log("%02x}", sa
->sa_data
[i
]);
435 unlock_user(sa
, addr
, 0);
437 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
439 qemu_log(", "TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
443 print_socket_domain(int domain
)
453 qemu_log("PF_NETLINK");
456 qemu_log("PF_PACKET");
459 qemu_log("%d", domain
);
465 print_socket_type(int type
)
467 switch (type
& TARGET_SOCK_TYPE_MASK
) {
468 case TARGET_SOCK_DGRAM
:
469 qemu_log("SOCK_DGRAM");
471 case TARGET_SOCK_STREAM
:
472 qemu_log("SOCK_STREAM");
474 case TARGET_SOCK_RAW
:
475 qemu_log("SOCK_RAW");
477 case TARGET_SOCK_RDM
:
478 qemu_log("SOCK_RDM");
480 case TARGET_SOCK_SEQPACKET
:
481 qemu_log("SOCK_SEQPACKET");
483 case TARGET_SOCK_PACKET
:
484 qemu_log("SOCK_PACKET");
487 if (type
& TARGET_SOCK_CLOEXEC
) {
488 qemu_log("|SOCK_CLOEXEC");
490 if (type
& TARGET_SOCK_NONBLOCK
) {
491 qemu_log("|SOCK_NONBLOCK");
496 print_socket_protocol(int domain
, int type
, int protocol
)
498 if (domain
== AF_PACKET
||
499 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
502 qemu_log("ETH_P_ALL");
505 qemu_log("%d", protocol
);
510 if (domain
== PF_NETLINK
) {
513 qemu_log("NETLINK_ROUTE");
516 qemu_log("NETLINK_UNUSED");
518 case NETLINK_USERSOCK
:
519 qemu_log("NETLINK_USERSOCK");
521 case NETLINK_FIREWALL
:
522 qemu_log("NETLINK_FIREWALL");
524 case NETLINK_SOCK_DIAG
:
525 qemu_log("NETLINK_SOCK_DIAG");
528 qemu_log("NETLINK_NFLOG");
531 qemu_log("NETLINK_XFRM");
533 case NETLINK_SELINUX
:
534 qemu_log("NETLINK_SELINUX");
537 qemu_log("NETLINK_ISCSI");
540 qemu_log("NETLINK_AUDIT");
542 case NETLINK_FIB_LOOKUP
:
543 qemu_log("NETLINK_FIB_LOOKUP");
545 case NETLINK_CONNECTOR
:
546 qemu_log("NETLINK_CONNECTOR");
548 case NETLINK_NETFILTER
:
549 qemu_log("NETLINK_NETFILTER");
552 qemu_log("NETLINK_IP6_FW");
554 case NETLINK_DNRTMSG
:
555 qemu_log("NETLINK_DNRTMSG");
557 case NETLINK_KOBJECT_UEVENT
:
558 qemu_log("NETLINK_KOBJECT_UEVENT");
560 case NETLINK_GENERIC
:
561 qemu_log("NETLINK_GENERIC");
563 case NETLINK_SCSITRANSPORT
:
564 qemu_log("NETLINK_SCSITRANSPORT");
566 case NETLINK_ECRYPTFS
:
567 qemu_log("NETLINK_ECRYPTFS");
570 qemu_log("NETLINK_RDMA");
573 qemu_log("NETLINK_CRYPTO");
576 qemu_log("NETLINK_SMC");
579 qemu_log("%d", protocol
);
587 qemu_log("IPPROTO_IP");
590 qemu_log("IPPROTO_TCP");
593 qemu_log("IPPROTO_UDP");
596 qemu_log("IPPROTO_RAW");
599 qemu_log("%d", protocol
);
605 #ifdef TARGET_NR__newselect
607 print_fdset(int n
, abi_ulong target_fds_addr
)
613 if( target_fds_addr
) {
614 abi_long
*target_fds
;
616 target_fds
= lock_user(VERIFY_READ
,
618 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
624 for (i
=n
; i
>=0; i
--) {
625 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >>
626 (i
& (TARGET_ABI_BITS
- 1))) & 1) {
627 qemu_log("%s%d", get_comma(first
), i
);
631 unlock_user(target_fds
, target_fds_addr
, 0);
638 * Sysycall specific output functions
642 #ifdef TARGET_NR__newselect
644 print_newselect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
645 abi_long arg1
, abi_long arg2
, abi_long arg3
,
646 abi_long arg4
, abi_long arg5
, abi_long arg6
)
648 print_syscall_prologue(name
);
649 print_fdset(arg1
, arg2
);
651 print_fdset(arg1
, arg3
);
653 print_fdset(arg1
, arg4
);
655 print_timeval(arg5
, 1);
656 print_syscall_epilogue(name
);
660 #ifdef TARGET_NR_semctl
662 print_semctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
663 abi_long arg1
, abi_long arg2
, abi_long arg3
,
664 abi_long arg4
, abi_long arg5
, abi_long arg6
)
666 qemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
667 name
->name
, arg1
, arg2
);
669 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
674 print_shmat(CPUArchState
*cpu_env
, 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 static const struct flags shmat_flags
[] = {
679 FLAG_GENERIC(SHM_RND
),
680 FLAG_GENERIC(SHM_REMAP
),
681 FLAG_GENERIC(SHM_RDONLY
),
682 FLAG_GENERIC(SHM_EXEC
),
686 print_syscall_prologue(name
);
687 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
688 print_pointer(arg1
, 0);
689 print_flags(shmat_flags
, arg2
, 1);
690 print_syscall_epilogue(name
);
695 print_ipc(CPUArchState
*cpu_env
, const struct syscallname
*name
,
696 abi_long arg1
, abi_long arg2
, abi_long arg3
,
697 abi_long arg4
, abi_long arg5
, abi_long arg6
)
701 qemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
704 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
707 print_shmat(cpu_env
, &(const struct syscallname
){ .name
= "shmat" },
708 arg1
, arg4
, arg2
, 0, 0, 0);
712 TARGET_ABI_FMT_ld
","
713 TARGET_ABI_FMT_ld
","
714 TARGET_ABI_FMT_ld
","
717 name
->name
, arg1
, arg2
, arg3
, arg4
);
723 * Variants for the return value output function
727 print_syscall_err(abi_long ret
)
733 errstr
= target_strerror(-ret
);
735 qemu_log("-1 errno=%d (%s)", (int)-ret
, errstr
);
743 print_syscall_ret_addr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
744 abi_long ret
, abi_long arg0
, abi_long arg1
,
745 abi_long arg2
, abi_long arg3
, abi_long arg4
,
748 if (!print_syscall_err(ret
)) {
749 qemu_log("0x" TARGET_ABI_FMT_lx
, ret
);
754 #if 0 /* currently unused */
756 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
758 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
762 #ifdef TARGET_NR__newselect
764 print_syscall_ret_newselect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
765 abi_long ret
, abi_long arg0
, abi_long arg1
,
766 abi_long arg2
, abi_long arg3
, abi_long arg4
,
769 if (!print_syscall_err(ret
)) {
770 qemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
771 print_fdset(arg0
, arg1
);
773 print_fdset(arg0
, arg2
);
775 print_fdset(arg0
, arg3
);
777 print_timeval(arg4
, 1);
785 /* special meanings of adjtimex()' non-negative return values */
786 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
787 #define TARGET_TIME_INS 1 /* insert leap second */
788 #define TARGET_TIME_DEL 2 /* delete leap second */
789 #define TARGET_TIME_OOP 3 /* leap second in progress */
790 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
791 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
792 #ifdef TARGET_NR_adjtimex
794 print_syscall_ret_adjtimex(CPUArchState
*cpu_env
, const struct syscallname
*name
,
795 abi_long ret
, abi_long arg0
, abi_long arg1
,
796 abi_long arg2
, abi_long arg3
, abi_long arg4
,
799 if (!print_syscall_err(ret
)) {
800 qemu_log(TARGET_ABI_FMT_ld
, ret
);
803 qemu_log(" TIME_OK (clock synchronized, no leap second)");
805 case TARGET_TIME_INS
:
806 qemu_log(" TIME_INS (insert leap second)");
808 case TARGET_TIME_DEL
:
809 qemu_log(" TIME_DEL (delete leap second)");
811 case TARGET_TIME_OOP
:
812 qemu_log(" TIME_OOP (leap second in progress)");
814 case TARGET_TIME_WAIT
:
815 qemu_log(" TIME_WAIT (leap second has occurred)");
817 case TARGET_TIME_ERROR
:
818 qemu_log(" TIME_ERROR (clock not synchronized)");
827 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
829 print_syscall_ret_clock_gettime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
830 abi_long ret
, abi_long arg0
, abi_long arg1
,
831 abi_long arg2
, abi_long arg3
, abi_long arg4
,
834 if (!print_syscall_err(ret
)) {
835 qemu_log(TARGET_ABI_FMT_ld
, ret
);
837 print_timespec(arg1
, 1);
843 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
846 #if defined(TARGET_NR_clock_gettime64)
848 print_syscall_ret_clock_gettime64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
849 abi_long ret
, abi_long arg0
, abi_long arg1
,
850 abi_long arg2
, abi_long arg3
, abi_long arg4
,
853 if (!print_syscall_err(ret
)) {
854 qemu_log(TARGET_ABI_FMT_ld
, ret
);
856 print_timespec64(arg1
, 1);
864 #ifdef TARGET_NR_gettimeofday
866 print_syscall_ret_gettimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
867 abi_long ret
, abi_long arg0
, abi_long arg1
,
868 abi_long arg2
, abi_long arg3
, abi_long arg4
,
871 if (!print_syscall_err(ret
)) {
872 qemu_log(TARGET_ABI_FMT_ld
, ret
);
874 print_timeval(arg0
, 0);
875 print_timezone(arg1
, 1);
883 #ifdef TARGET_NR_getitimer
885 print_syscall_ret_getitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
886 abi_long ret
, abi_long arg0
, abi_long arg1
,
887 abi_long arg2
, abi_long arg3
, abi_long arg4
,
890 if (!print_syscall_err(ret
)) {
891 qemu_log(TARGET_ABI_FMT_ld
, ret
);
893 print_itimerval(arg1
, 1);
902 #ifdef TARGET_NR_getitimer
904 print_syscall_ret_setitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
905 abi_long ret
, abi_long arg0
, abi_long arg1
,
906 abi_long arg2
, abi_long arg3
, abi_long arg4
,
909 if (!print_syscall_err(ret
)) {
910 qemu_log(TARGET_ABI_FMT_ld
, ret
);
911 qemu_log(" (old_value = ");
912 print_itimerval(arg2
, 1);
920 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
921 || defined(TARGGET_NR_flistxattr)
923 print_syscall_ret_listxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
924 abi_long ret
, abi_long arg0
, abi_long arg1
,
925 abi_long arg2
, abi_long arg3
, abi_long arg4
,
928 if (!print_syscall_err(ret
)) {
929 qemu_log(TARGET_ABI_FMT_ld
, ret
);
930 qemu_log(" (list = ");
932 abi_long attr
= arg1
;
937 print_string(attr
, 1);
938 ret
-= target_strlen(attr
) + 1;
939 attr
+= target_strlen(attr
) + 1;
949 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
950 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
953 #ifdef TARGET_NR_ioctl
955 print_syscall_ret_ioctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
956 abi_long ret
, abi_long arg0
, abi_long arg1
,
957 abi_long arg2
, abi_long arg3
, abi_long arg4
,
960 if (!print_syscall_err(ret
)) {
961 qemu_log(TARGET_ABI_FMT_ld
, ret
);
963 const IOCTLEntry
*ie
;
964 const argtype
*arg_type
;
968 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
969 if (ie
->target_cmd
== arg1
) {
974 if (ie
->target_cmd
== arg1
&&
975 (ie
->access
== IOC_R
|| ie
->access
== IOC_RW
)) {
976 arg_type
= ie
->arg_type
;
979 target_size
= thunk_type_size(arg_type
, 0);
980 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
982 thunk_print(argptr
, arg_type
);
983 unlock_user(argptr
, arg2
, target_size
);
985 print_pointer(arg2
, 1);
994 UNUSED
static const struct flags access_flags
[] = {
995 FLAG_GENERIC_MASK(F_OK
, R_OK
| W_OK
| X_OK
),
1002 UNUSED
static const struct flags at_file_flags
[] = {
1004 FLAG_GENERIC(AT_EACCESS
),
1006 #ifdef AT_SYMLINK_NOFOLLOW
1007 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1012 UNUSED
static const struct flags unlinkat_flags
[] = {
1014 FLAG_GENERIC(AT_REMOVEDIR
),
1019 UNUSED
static const struct flags mode_flags
[] = {
1020 FLAG_GENERIC(S_IFSOCK
),
1021 FLAG_GENERIC(S_IFLNK
),
1022 FLAG_GENERIC(S_IFREG
),
1023 FLAG_GENERIC(S_IFBLK
),
1024 FLAG_GENERIC(S_IFDIR
),
1025 FLAG_GENERIC(S_IFCHR
),
1026 FLAG_GENERIC(S_IFIFO
),
1030 UNUSED
static const struct flags open_access_flags
[] = {
1031 FLAG_TARGET_MASK(O_RDONLY
, O_ACCMODE
),
1032 FLAG_TARGET_MASK(O_WRONLY
, O_ACCMODE
),
1033 FLAG_TARGET_MASK(O_RDWR
, O_ACCMODE
),
1037 UNUSED
static const struct flags open_flags
[] = {
1038 FLAG_TARGET(O_APPEND
),
1039 FLAG_TARGET(O_CREAT
),
1040 FLAG_TARGET(O_DIRECTORY
),
1041 FLAG_TARGET(O_EXCL
),
1042 #if TARGET_O_LARGEFILE != 0
1043 FLAG_TARGET(O_LARGEFILE
),
1045 FLAG_TARGET(O_NOCTTY
),
1046 FLAG_TARGET(O_NOFOLLOW
),
1047 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
1048 FLAG_TARGET(O_DSYNC
),
1049 FLAG_TARGET(__O_SYNC
),
1050 FLAG_TARGET(O_TRUNC
),
1052 FLAG_TARGET(O_DIRECT
),
1055 FLAG_TARGET(O_NOATIME
),
1058 FLAG_TARGET(O_CLOEXEC
),
1061 FLAG_TARGET(O_PATH
),
1064 FLAG_TARGET(O_TMPFILE
),
1065 FLAG_TARGET(__O_TMPFILE
),
1070 UNUSED
static const struct flags mount_flags
[] = {
1072 FLAG_GENERIC(MS_BIND
),
1075 FLAG_GENERIC(MS_DIRSYNC
),
1077 FLAG_GENERIC(MS_MANDLOCK
),
1079 FLAG_GENERIC(MS_MOVE
),
1081 FLAG_GENERIC(MS_NOATIME
),
1082 FLAG_GENERIC(MS_NODEV
),
1083 FLAG_GENERIC(MS_NODIRATIME
),
1084 FLAG_GENERIC(MS_NOEXEC
),
1085 FLAG_GENERIC(MS_NOSUID
),
1086 FLAG_GENERIC(MS_RDONLY
),
1088 FLAG_GENERIC(MS_RELATIME
),
1090 FLAG_GENERIC(MS_REMOUNT
),
1091 FLAG_GENERIC(MS_SYNCHRONOUS
),
1095 UNUSED
static const struct flags umount2_flags
[] = {
1097 FLAG_GENERIC(MNT_FORCE
),
1100 FLAG_GENERIC(MNT_DETACH
),
1103 FLAG_GENERIC(MNT_EXPIRE
),
1108 UNUSED
static const struct flags mmap_prot_flags
[] = {
1109 FLAG_GENERIC_MASK(PROT_NONE
, PROT_READ
| PROT_WRITE
| PROT_EXEC
),
1110 FLAG_GENERIC(PROT_EXEC
),
1111 FLAG_GENERIC(PROT_READ
),
1112 FLAG_GENERIC(PROT_WRITE
),
1113 FLAG_TARGET(PROT_SEM
),
1114 FLAG_GENERIC(PROT_GROWSDOWN
),
1115 FLAG_GENERIC(PROT_GROWSUP
),
1119 UNUSED
static const struct flags mmap_flags
[] = {
1120 FLAG_TARGET_MASK(MAP_SHARED
, MAP_TYPE
),
1121 FLAG_TARGET_MASK(MAP_PRIVATE
, MAP_TYPE
),
1122 FLAG_TARGET_MASK(MAP_SHARED_VALIDATE
, MAP_TYPE
),
1123 FLAG_TARGET(MAP_ANONYMOUS
),
1124 FLAG_TARGET(MAP_DENYWRITE
),
1125 FLAG_TARGET(MAP_EXECUTABLE
),
1126 FLAG_TARGET(MAP_FIXED
),
1127 FLAG_TARGET(MAP_FIXED_NOREPLACE
),
1128 FLAG_TARGET(MAP_GROWSDOWN
),
1129 FLAG_TARGET(MAP_HUGETLB
),
1130 FLAG_TARGET(MAP_LOCKED
),
1131 FLAG_TARGET(MAP_NONBLOCK
),
1132 FLAG_TARGET(MAP_NORESERVE
),
1133 FLAG_TARGET(MAP_POPULATE
),
1134 FLAG_TARGET(MAP_STACK
),
1135 FLAG_TARGET(MAP_SYNC
),
1136 #if TARGET_MAP_UNINITIALIZED != 0
1137 FLAG_TARGET(MAP_UNINITIALIZED
),
1143 # define CLONE_PIDFD 0x00001000
1146 UNUSED
static const struct flags clone_flags
[] = {
1147 FLAG_GENERIC(CLONE_VM
),
1148 FLAG_GENERIC(CLONE_FS
),
1149 FLAG_GENERIC(CLONE_FILES
),
1150 FLAG_GENERIC(CLONE_SIGHAND
),
1151 FLAG_GENERIC(CLONE_PIDFD
),
1152 FLAG_GENERIC(CLONE_PTRACE
),
1153 FLAG_GENERIC(CLONE_VFORK
),
1154 FLAG_GENERIC(CLONE_PARENT
),
1155 FLAG_GENERIC(CLONE_THREAD
),
1156 FLAG_GENERIC(CLONE_NEWNS
),
1157 FLAG_GENERIC(CLONE_SYSVSEM
),
1158 FLAG_GENERIC(CLONE_SETTLS
),
1159 FLAG_GENERIC(CLONE_PARENT_SETTID
),
1160 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
1161 FLAG_GENERIC(CLONE_DETACHED
),
1162 FLAG_GENERIC(CLONE_UNTRACED
),
1163 FLAG_GENERIC(CLONE_CHILD_SETTID
),
1164 #if defined(CLONE_NEWUTS)
1165 FLAG_GENERIC(CLONE_NEWUTS
),
1167 #if defined(CLONE_NEWIPC)
1168 FLAG_GENERIC(CLONE_NEWIPC
),
1170 #if defined(CLONE_NEWUSER)
1171 FLAG_GENERIC(CLONE_NEWUSER
),
1173 #if defined(CLONE_NEWPID)
1174 FLAG_GENERIC(CLONE_NEWPID
),
1176 #if defined(CLONE_NEWNET)
1177 FLAG_GENERIC(CLONE_NEWNET
),
1179 #if defined(CLONE_NEWCGROUP)
1180 FLAG_GENERIC(CLONE_NEWCGROUP
),
1182 #if defined(CLONE_NEWTIME)
1183 FLAG_GENERIC(CLONE_NEWTIME
),
1185 #if defined(CLONE_IO)
1186 FLAG_GENERIC(CLONE_IO
),
1191 UNUSED
static const struct flags execveat_flags
[] = {
1192 #ifdef AT_EMPTY_PATH
1193 FLAG_GENERIC(AT_EMPTY_PATH
),
1195 #ifdef AT_SYMLINK_NOFOLLOW
1196 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1201 UNUSED
static const struct flags msg_flags
[] = {
1203 FLAG_GENERIC(MSG_CONFIRM
),
1204 FLAG_GENERIC(MSG_DONTROUTE
),
1205 FLAG_GENERIC(MSG_DONTWAIT
),
1206 FLAG_GENERIC(MSG_EOR
),
1207 FLAG_GENERIC(MSG_MORE
),
1208 FLAG_GENERIC(MSG_NOSIGNAL
),
1209 FLAG_GENERIC(MSG_OOB
),
1211 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1212 FLAG_GENERIC(MSG_ERRQUEUE
),
1213 FLAG_GENERIC(MSG_PEEK
),
1214 FLAG_GENERIC(MSG_TRUNC
),
1215 FLAG_GENERIC(MSG_WAITALL
),
1217 FLAG_GENERIC(MSG_CTRUNC
),
1221 UNUSED
static const struct flags statx_flags
[] = {
1222 #ifdef AT_EMPTY_PATH
1223 FLAG_GENERIC(AT_EMPTY_PATH
),
1225 #ifdef AT_NO_AUTOMOUNT
1226 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1228 #ifdef AT_SYMLINK_NOFOLLOW
1229 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1231 #ifdef AT_STATX_SYNC_AS_STAT
1232 FLAG_GENERIC_MASK(AT_STATX_SYNC_AS_STAT
, AT_STATX_SYNC_TYPE
),
1234 #ifdef AT_STATX_FORCE_SYNC
1235 FLAG_GENERIC_MASK(AT_STATX_FORCE_SYNC
, AT_STATX_SYNC_TYPE
),
1237 #ifdef AT_STATX_DONT_SYNC
1238 FLAG_GENERIC_MASK(AT_STATX_DONT_SYNC
, AT_STATX_SYNC_TYPE
),
1243 UNUSED
static const struct flags statx_mask
[] = {
1244 /* This must come first, because it includes everything. */
1246 FLAG_GENERIC(STATX_ALL
),
1248 /* This must come second; it includes everything except STATX_BTIME. */
1249 #ifdef STATX_BASIC_STATS
1250 FLAG_GENERIC(STATX_BASIC_STATS
),
1253 FLAG_GENERIC(STATX_TYPE
),
1256 FLAG_GENERIC(STATX_MODE
),
1259 FLAG_GENERIC(STATX_NLINK
),
1262 FLAG_GENERIC(STATX_UID
),
1265 FLAG_GENERIC(STATX_GID
),
1268 FLAG_GENERIC(STATX_ATIME
),
1271 FLAG_GENERIC(STATX_MTIME
),
1274 FLAG_GENERIC(STATX_CTIME
),
1277 FLAG_GENERIC(STATX_INO
),
1280 FLAG_GENERIC(STATX_SIZE
),
1283 FLAG_GENERIC(STATX_BLOCKS
),
1286 FLAG_GENERIC(STATX_BTIME
),
1291 UNUSED
static const struct flags falloc_flags
[] = {
1292 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE
),
1293 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE
),
1294 #ifdef FALLOC_FL_NO_HIDE_STALE
1295 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE
),
1297 #ifdef FALLOC_FL_COLLAPSE_RANGE
1298 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE
),
1300 #ifdef FALLOC_FL_ZERO_RANGE
1301 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE
),
1303 #ifdef FALLOC_FL_INSERT_RANGE
1304 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE
),
1306 #ifdef FALLOC_FL_UNSHARE_RANGE
1307 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE
),
1311 UNUSED
static const struct flags termios_iflags
[] = {
1312 FLAG_TARGET(IGNBRK
),
1313 FLAG_TARGET(BRKINT
),
1314 FLAG_TARGET(IGNPAR
),
1315 FLAG_TARGET(PARMRK
),
1317 FLAG_TARGET(ISTRIP
),
1325 FLAG_TARGET(IMAXBEL
),
1330 UNUSED
static const struct flags termios_oflags
[] = {
1336 FLAG_TARGET(ONLRET
),
1342 UNUSED
static struct enums termios_oflags_NLDLY
[] = {
1348 UNUSED
static struct enums termios_oflags_CRDLY
[] = {
1356 UNUSED
static struct enums termios_oflags_TABDLY
[] = {
1364 UNUSED
static struct enums termios_oflags_VTDLY
[] = {
1370 UNUSED
static struct enums termios_oflags_FFDLY
[] = {
1376 UNUSED
static struct enums termios_oflags_BSDLY
[] = {
1382 UNUSED
static struct enums termios_cflags_CBAUD
[] = {
1397 ENUM_TARGET(B19200
),
1398 ENUM_TARGET(B38400
),
1399 ENUM_TARGET(B57600
),
1400 ENUM_TARGET(B115200
),
1401 ENUM_TARGET(B230400
),
1402 ENUM_TARGET(B460800
),
1406 UNUSED
static struct enums termios_cflags_CSIZE
[] = {
1414 UNUSED
static const struct flags termios_cflags
[] = {
1415 FLAG_TARGET(CSTOPB
),
1417 FLAG_TARGET(PARENB
),
1418 FLAG_TARGET(PARODD
),
1420 FLAG_TARGET(CLOCAL
),
1421 FLAG_TARGET(CRTSCTS
),
1425 UNUSED
static const struct flags termios_lflags
[] = {
1427 FLAG_TARGET(ICANON
),
1432 FLAG_TARGET(ECHONL
),
1433 FLAG_TARGET(NOFLSH
),
1434 FLAG_TARGET(TOSTOP
),
1435 FLAG_TARGET(ECHOCTL
),
1436 FLAG_TARGET(ECHOPRT
),
1437 FLAG_TARGET(ECHOKE
),
1438 FLAG_TARGET(FLUSHO
),
1439 FLAG_TARGET(PENDIN
),
1440 FLAG_TARGET(IEXTEN
),
1441 FLAG_TARGET(EXTPROC
),
1445 #ifdef TARGET_NR_mlockall
1446 static const struct flags mlockall_flags
[] = {
1447 FLAG_TARGET(MCL_CURRENT
),
1448 FLAG_TARGET(MCL_FUTURE
),
1450 FLAG_TARGET(MCL_ONFAULT
),
1456 /* IDs of the various system clocks */
1457 #define TARGET_CLOCK_REALTIME 0
1458 #define TARGET_CLOCK_MONOTONIC 1
1459 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1460 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1461 #define TARGET_CLOCK_MONOTONIC_RAW 4
1462 #define TARGET_CLOCK_REALTIME_COARSE 5
1463 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1464 #define TARGET_CLOCK_BOOTTIME 7
1465 #define TARGET_CLOCK_REALTIME_ALARM 8
1466 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1467 #define TARGET_CLOCK_SGI_CYCLE 10
1468 #define TARGET_CLOCK_TAI 11
1470 UNUSED
static struct enums clockids
[] = {
1471 ENUM_TARGET(CLOCK_REALTIME
),
1472 ENUM_TARGET(CLOCK_MONOTONIC
),
1473 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID
),
1474 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID
),
1475 ENUM_TARGET(CLOCK_MONOTONIC_RAW
),
1476 ENUM_TARGET(CLOCK_REALTIME_COARSE
),
1477 ENUM_TARGET(CLOCK_MONOTONIC_COARSE
),
1478 ENUM_TARGET(CLOCK_BOOTTIME
),
1479 ENUM_TARGET(CLOCK_REALTIME_ALARM
),
1480 ENUM_TARGET(CLOCK_BOOTTIME_ALARM
),
1481 ENUM_TARGET(CLOCK_SGI_CYCLE
),
1482 ENUM_TARGET(CLOCK_TAI
),
1486 UNUSED
static struct enums itimer_types
[] = {
1487 ENUM_GENERIC(ITIMER_REAL
),
1488 ENUM_GENERIC(ITIMER_VIRTUAL
),
1489 ENUM_GENERIC(ITIMER_PROF
),
1494 * print_xxx utility functions. These are used to print syscall
1495 * parameters in certain format. All of these have parameter
1496 * named 'last'. This parameter is used to add comma to output
1503 return ((last
) ? "" : ",");
1507 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1509 const char *sep
= "";
1512 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1513 if ((flags
& f
->f_mask
) == f
->f_value
) {
1514 qemu_log("%s%s", sep
, f
->f_string
);
1515 flags
&= ~f
->f_mask
;
1522 /* print rest of the flags as numeric */
1524 qemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1526 qemu_log("%s", get_comma(last
));
1529 /* no string version of flags found, print them in hex then */
1530 qemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1535 print_enums(const struct enums
*e
, abi_long enum_arg
, int last
)
1537 for (; e
->e_string
!= NULL
; e
++) {
1538 if (e
->e_value
== enum_arg
) {
1539 qemu_log("%s", e
->e_string
);
1544 if (e
->e_string
== NULL
) {
1545 qemu_log("%#x", (unsigned int)enum_arg
);
1548 qemu_log("%s", get_comma(last
));
1552 print_at_dirfd(abi_long dirfd
, int last
)
1555 if (dirfd
== AT_FDCWD
) {
1556 qemu_log("AT_FDCWD%s", get_comma(last
));
1560 qemu_log("%d%s", (int)dirfd
, get_comma(last
));
1564 print_file_mode(abi_long mode
, int last
)
1566 const char *sep
= "";
1567 const struct flags
*m
;
1570 qemu_log("000%s", get_comma(last
));
1574 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1575 if ((m
->f_value
& mode
) == m
->f_value
) {
1576 qemu_log("%s%s", m
->f_string
, sep
);
1578 mode
&= ~m
->f_value
;
1584 /* print rest of the mode as octal */
1586 qemu_log("%s%#o", sep
, (unsigned int)mode
);
1588 qemu_log("%s", get_comma(last
));
1592 print_open_flags(abi_long flags
, int last
)
1594 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1595 flags
&= ~TARGET_O_ACCMODE
;
1597 qemu_log("%s", get_comma(last
));
1601 print_flags(open_flags
, flags
, last
);
1605 print_syscall_prologue(const struct syscallname
*sc
)
1607 qemu_log("%s(", sc
->name
);
1612 print_syscall_epilogue(const struct syscallname
*sc
)
1619 print_string(abi_long addr
, int last
)
1623 if ((s
= lock_user_string(addr
)) != NULL
) {
1624 qemu_log("\"%s\"%s", s
, get_comma(last
));
1625 unlock_user(s
, addr
, 0);
1627 /* can't get string out of it, so print it as pointer */
1628 print_pointer(addr
, last
);
1632 #define MAX_PRINT_BUF 40
1634 print_buf(abi_long addr
, abi_long len
, int last
)
1639 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1642 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1643 if (isprint(s
[i
])) {
1644 qemu_log("%c", s
[i
]);
1646 qemu_log("\\%o", s
[i
]);
1656 unlock_user(s
, addr
, 0);
1658 print_pointer(addr
, last
);
1663 * Prints out raw parameter using given format. Caller needs
1664 * to do byte swapping if needed.
1667 print_raw_param(const char *fmt
, abi_long param
, int last
)
1671 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1672 qemu_log(format
, param
);
1676 * Same as print_raw_param() but prints out raw 64-bit parameter.
1679 print_raw_param64(const char *fmt
, long long param
, int last
)
1683 (void)snprintf(format
, sizeof(format
), "%s%s", fmt
, get_comma(last
));
1684 qemu_log(format
, param
);
1689 print_pointer(abi_long p
, int last
)
1692 qemu_log("NULL%s", get_comma(last
));
1694 qemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1698 * Reads 32-bit (int) number from guest address space from
1699 * address 'addr' and prints it.
1702 print_number(abi_long addr
, int last
)
1705 qemu_log("NULL%s", get_comma(last
));
1709 get_user_s32(num
, addr
);
1710 qemu_log("[%d]%s", num
, get_comma(last
));
1715 print_timeval(abi_ulong tv_addr
, int last
)
1718 struct target_timeval
*tv
;
1720 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1722 print_pointer(tv_addr
, last
);
1725 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1726 ",tv_usec = " TARGET_ABI_FMT_ld
"}%s",
1727 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1728 unlock_user(tv
, tv_addr
, 0);
1730 qemu_log("NULL%s", get_comma(last
));
1734 print_timespec(abi_ulong ts_addr
, int last
)
1737 struct target_timespec
*ts
;
1739 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1741 print_pointer(ts_addr
, last
);
1744 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1745 ",tv_nsec = " TARGET_ABI_FMT_ld
"}%s",
1746 tswapal(ts
->tv_sec
), tswapal(ts
->tv_nsec
), get_comma(last
));
1747 unlock_user(ts
, ts_addr
, 0);
1749 qemu_log("NULL%s", get_comma(last
));
1754 print_timespec64(abi_ulong ts_addr
, int last
)
1757 struct target__kernel_timespec
*ts
;
1759 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1761 print_pointer(ts_addr
, last
);
1764 print_raw_param64("{tv_sec=%" PRId64
, tswap64(ts
->tv_sec
), 0);
1765 print_raw_param64("tv_nsec=%" PRId64
"}", tswap64(ts
->tv_nsec
), last
);
1766 unlock_user(ts
, ts_addr
, 0);
1768 qemu_log("NULL%s", get_comma(last
));
1773 print_timezone(abi_ulong tz_addr
, int last
)
1776 struct target_timezone
*tz
;
1778 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1780 print_pointer(tz_addr
, last
);
1783 qemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1784 tswap32(tz
->tz_dsttime
), get_comma(last
));
1785 unlock_user(tz
, tz_addr
, 0);
1787 qemu_log("NULL%s", get_comma(last
));
1792 print_itimerval(abi_ulong it_addr
, int last
)
1795 qemu_log("{it_interval=");
1796 print_timeval(it_addr
+
1797 offsetof(struct target_itimerval
, it_interval
), 0);
1798 qemu_log("it_value=");
1799 print_timeval(it_addr
+
1800 offsetof(struct target_itimerval
, it_value
), 0);
1801 qemu_log("}%s", get_comma(last
));
1803 qemu_log("NULL%s", get_comma(last
));
1808 print_termios(void *arg
)
1810 const struct target_termios
*target
= arg
;
1812 target_tcflag_t iflags
= tswap32(target
->c_iflag
);
1813 target_tcflag_t oflags
= tswap32(target
->c_oflag
);
1814 target_tcflag_t cflags
= tswap32(target
->c_cflag
);
1815 target_tcflag_t lflags
= tswap32(target
->c_lflag
);
1819 qemu_log("c_iflag = ");
1820 print_flags(termios_iflags
, iflags
, 0);
1822 qemu_log("c_oflag = ");
1823 target_tcflag_t oflags_clean
= oflags
& ~(TARGET_NLDLY
| TARGET_CRDLY
|
1824 TARGET_TABDLY
| TARGET_BSDLY
|
1825 TARGET_VTDLY
| TARGET_FFDLY
);
1826 print_flags(termios_oflags
, oflags_clean
, 0);
1827 if (oflags
& TARGET_NLDLY
) {
1828 print_enums(termios_oflags_NLDLY
, oflags
& TARGET_NLDLY
, 0);
1830 if (oflags
& TARGET_CRDLY
) {
1831 print_enums(termios_oflags_CRDLY
, oflags
& TARGET_CRDLY
, 0);
1833 if (oflags
& TARGET_TABDLY
) {
1834 print_enums(termios_oflags_TABDLY
, oflags
& TARGET_TABDLY
, 0);
1836 if (oflags
& TARGET_BSDLY
) {
1837 print_enums(termios_oflags_BSDLY
, oflags
& TARGET_BSDLY
, 0);
1839 if (oflags
& TARGET_VTDLY
) {
1840 print_enums(termios_oflags_VTDLY
, oflags
& TARGET_VTDLY
, 0);
1842 if (oflags
& TARGET_FFDLY
) {
1843 print_enums(termios_oflags_FFDLY
, oflags
& TARGET_FFDLY
, 0);
1846 qemu_log("c_cflag = ");
1847 if (cflags
& TARGET_CBAUD
) {
1848 print_enums(termios_cflags_CBAUD
, cflags
& TARGET_CBAUD
, 0);
1850 if (cflags
& TARGET_CSIZE
) {
1851 print_enums(termios_cflags_CSIZE
, cflags
& TARGET_CSIZE
, 0);
1853 target_tcflag_t cflags_clean
= cflags
& ~(TARGET_CBAUD
| TARGET_CSIZE
);
1854 print_flags(termios_cflags
, cflags_clean
, 0);
1856 qemu_log("c_lflag = ");
1857 print_flags(termios_lflags
, lflags
, 0);
1859 qemu_log("c_cc = ");
1860 qemu_log("\"%s\",", target
->c_cc
);
1862 qemu_log("c_line = ");
1863 print_raw_param("\'%c\'", target
->c_line
, 1);
1870 #ifdef TARGET_NR_accept
1872 print_accept(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1873 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1874 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1876 print_syscall_prologue(name
);
1877 print_raw_param("%d", arg0
, 0);
1878 print_pointer(arg1
, 0);
1879 print_number(arg2
, 1);
1880 print_syscall_epilogue(name
);
1884 #ifdef TARGET_NR_access
1886 print_access(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1887 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1888 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1890 print_syscall_prologue(name
);
1891 print_string(arg0
, 0);
1892 print_flags(access_flags
, arg1
, 1);
1893 print_syscall_epilogue(name
);
1897 #ifdef TARGET_NR_acct
1899 print_acct(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1900 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1901 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1903 print_syscall_prologue(name
);
1904 print_string(arg0
, 1);
1905 print_syscall_epilogue(name
);
1909 #ifdef TARGET_NR_brk
1911 print_brk(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1912 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1913 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1915 print_syscall_prologue(name
);
1916 print_pointer(arg0
, 1);
1917 print_syscall_epilogue(name
);
1921 #ifdef TARGET_NR_chdir
1923 print_chdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1924 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1925 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1927 print_syscall_prologue(name
);
1928 print_string(arg0
, 1);
1929 print_syscall_epilogue(name
);
1933 #ifdef TARGET_NR_chroot
1935 print_chroot(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1936 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1937 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1939 print_syscall_prologue(name
);
1940 print_string(arg0
, 1);
1941 print_syscall_epilogue(name
);
1945 #ifdef TARGET_NR_chmod
1947 print_chmod(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1948 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1949 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1951 print_syscall_prologue(name
);
1952 print_string(arg0
, 0);
1953 print_file_mode(arg1
, 1);
1954 print_syscall_epilogue(name
);
1958 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1960 print_chown(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1961 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1962 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1964 print_syscall_prologue(name
);
1965 print_string(arg0
, 0);
1966 print_raw_param("%d", arg1
, 0);
1967 print_raw_param("%d", arg2
, 1);
1968 print_syscall_epilogue(name
);
1970 #define print_lchown print_chown
1973 #ifdef TARGET_NR_clock_adjtime
1975 print_clock_adjtime(CPUArchState
*cpu_env
, 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_enums(clockids
, arg0
, 0);
1981 print_pointer(arg1
, 1);
1982 print_syscall_epilogue(name
);
1986 #ifdef TARGET_NR_clone
1987 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1988 abi_ulong parent_tidptr
, target_ulong newtls
,
1989 abi_ulong child_tidptr
)
1991 print_flags(clone_flags
, flags
, 0);
1992 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1993 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1994 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1995 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1999 print_clone(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2000 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2001 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2003 print_syscall_prologue(name
);
2004 #if defined(TARGET_MICROBLAZE)
2005 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
2006 #elif defined(TARGET_CLONE_BACKWARDS)
2007 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
2008 #elif defined(TARGET_CLONE_BACKWARDS2)
2009 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
2011 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
2013 print_syscall_epilogue(name
);
2017 #ifdef TARGET_NR_creat
2019 print_creat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2020 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2021 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2023 print_syscall_prologue(name
);
2024 print_string(arg0
, 0);
2025 print_file_mode(arg1
, 1);
2026 print_syscall_epilogue(name
);
2030 #ifdef TARGET_NR_execv
2032 print_execv(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2033 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2034 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2036 print_syscall_prologue(name
);
2037 print_string(arg0
, 0);
2038 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
2039 print_syscall_epilogue(name
);
2044 print_execve_argv(abi_long argv
, int last
)
2046 abi_ulong arg_ptr_addr
;
2050 for (arg_ptr_addr
= argv
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
2051 abi_ulong
*arg_ptr
, arg_addr
;
2053 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
2057 arg_addr
= tswapal(*arg_ptr
);
2058 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
2062 s
= lock_user_string(arg_addr
);
2064 qemu_log("\"%s\",", s
);
2065 unlock_user(s
, arg_addr
, 0);
2068 qemu_log("NULL}%s", get_comma(last
));
2072 print_execve(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2073 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2074 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2076 print_syscall_prologue(name
);
2077 print_string(arg1
, 0);
2078 print_execve_argv(arg2
, 1);
2079 print_syscall_epilogue(name
);
2083 print_execveat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2084 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2085 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2087 print_syscall_prologue(name
);
2088 print_at_dirfd(arg1
, 0);
2089 print_string(arg2
, 0);
2090 print_execve_argv(arg3
, 0);
2091 print_flags(execveat_flags
, arg5
, 1);
2092 print_syscall_epilogue(name
);
2095 #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
2097 print_faccessat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2098 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2099 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2101 print_syscall_prologue(name
);
2102 print_at_dirfd(arg0
, 0);
2103 print_string(arg1
, 0);
2104 print_flags(access_flags
, arg2
, 0);
2105 print_flags(at_file_flags
, arg3
, 1);
2106 print_syscall_epilogue(name
);
2110 #ifdef TARGET_NR_fallocate
2112 print_fallocate(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2113 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2114 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2116 print_syscall_prologue(name
);
2117 print_raw_param("%d", arg0
, 0);
2118 print_flags(falloc_flags
, arg1
, 0);
2119 #if TARGET_ABI_BITS == 32
2120 print_raw_param("%" PRIu64
, target_offset64(arg2
, arg3
), 0);
2121 print_raw_param("%" PRIu64
, target_offset64(arg4
, arg5
), 1);
2123 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2124 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 1);
2126 print_syscall_epilogue(name
);
2130 #ifdef TARGET_NR_fchmodat
2132 print_fchmodat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2133 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2134 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2136 print_syscall_prologue(name
);
2137 print_at_dirfd(arg0
, 0);
2138 print_string(arg1
, 0);
2139 print_file_mode(arg2
, 0);
2140 print_flags(at_file_flags
, arg3
, 1);
2141 print_syscall_epilogue(name
);
2145 #ifdef TARGET_NR_fchownat
2147 print_fchownat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2148 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2149 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2151 print_syscall_prologue(name
);
2152 print_at_dirfd(arg0
, 0);
2153 print_string(arg1
, 0);
2154 print_raw_param("%d", arg2
, 0);
2155 print_raw_param("%d", arg3
, 0);
2156 print_flags(at_file_flags
, arg4
, 1);
2157 print_syscall_epilogue(name
);
2161 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
2163 print_fcntl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2164 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2165 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2167 print_syscall_prologue(name
);
2168 print_raw_param("%d", arg0
, 0);
2170 case TARGET_F_DUPFD
:
2171 qemu_log("F_DUPFD,");
2172 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2174 case TARGET_F_GETFD
:
2175 qemu_log("F_GETFD");
2177 case TARGET_F_SETFD
:
2178 qemu_log("F_SETFD,");
2179 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2181 case TARGET_F_GETFL
:
2182 qemu_log("F_GETFL");
2184 case TARGET_F_SETFL
:
2185 qemu_log("F_SETFL,");
2186 print_open_flags(arg2
, 1);
2188 case TARGET_F_GETLK
:
2189 qemu_log("F_GETLK,");
2190 print_pointer(arg2
, 1);
2192 case TARGET_F_SETLK
:
2193 qemu_log("F_SETLK,");
2194 print_pointer(arg2
, 1);
2196 case TARGET_F_SETLKW
:
2197 qemu_log("F_SETLKW,");
2198 print_pointer(arg2
, 1);
2200 case TARGET_F_GETOWN
:
2201 qemu_log("F_GETOWN");
2203 case TARGET_F_SETOWN
:
2204 qemu_log("F_SETOWN,");
2205 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2207 case TARGET_F_GETSIG
:
2208 qemu_log("F_GETSIG");
2210 case TARGET_F_SETSIG
:
2211 qemu_log("F_SETSIG,");
2212 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2214 #if TARGET_ABI_BITS == 32
2215 case TARGET_F_GETLK64
:
2216 qemu_log("F_GETLK64,");
2217 print_pointer(arg2
, 1);
2219 case TARGET_F_SETLK64
:
2220 qemu_log("F_SETLK64,");
2221 print_pointer(arg2
, 1);
2223 case TARGET_F_SETLKW64
:
2224 qemu_log("F_SETLKW64,");
2225 print_pointer(arg2
, 1);
2228 case TARGET_F_OFD_GETLK
:
2229 qemu_log("F_OFD_GETLK,");
2230 print_pointer(arg2
, 1);
2232 case TARGET_F_OFD_SETLK
:
2233 qemu_log("F_OFD_SETLK,");
2234 print_pointer(arg2
, 1);
2236 case TARGET_F_OFD_SETLKW
:
2237 qemu_log("F_OFD_SETLKW,");
2238 print_pointer(arg2
, 1);
2240 case TARGET_F_SETLEASE
:
2241 qemu_log("F_SETLEASE,");
2242 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2244 case TARGET_F_GETLEASE
:
2245 qemu_log("F_GETLEASE");
2247 #ifdef F_DUPFD_CLOEXEC
2248 case TARGET_F_DUPFD_CLOEXEC
:
2249 qemu_log("F_DUPFD_CLOEXEC,");
2250 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2253 case TARGET_F_NOTIFY
:
2254 qemu_log("F_NOTIFY,");
2255 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2258 case TARGET_F_GETOWN_EX
:
2259 qemu_log("F_GETOWN_EX,");
2260 print_pointer(arg2
, 1);
2264 case TARGET_F_SETOWN_EX
:
2265 qemu_log("F_SETOWN_EX,");
2266 print_pointer(arg2
, 1);
2270 case TARGET_F_SETPIPE_SZ
:
2271 qemu_log("F_SETPIPE_SZ,");
2272 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2274 case TARGET_F_GETPIPE_SZ
:
2275 qemu_log("F_GETPIPE_SZ");
2279 case TARGET_F_ADD_SEALS
:
2280 qemu_log("F_ADD_SEALS,");
2281 print_raw_param("0x"TARGET_ABI_FMT_lx
, arg2
, 1);
2283 case TARGET_F_GET_SEALS
:
2284 qemu_log("F_GET_SEALS");
2288 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2289 print_pointer(arg2
, 1);
2292 print_syscall_epilogue(name
);
2294 #define print_fcntl64 print_fcntl
2297 #ifdef TARGET_NR_fgetxattr
2299 print_fgetxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2300 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2301 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2303 print_syscall_prologue(name
);
2304 print_raw_param("%d", arg0
, 0);
2305 print_string(arg1
, 0);
2306 print_pointer(arg2
, 0);
2307 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2308 print_syscall_epilogue(name
);
2312 #ifdef TARGET_NR_flistxattr
2314 print_flistxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2315 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2316 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2318 print_syscall_prologue(name
);
2319 print_raw_param("%d", arg0
, 0);
2320 print_pointer(arg1
, 0);
2321 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2322 print_syscall_epilogue(name
);
2326 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2328 print_getxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2329 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2330 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2332 print_syscall_prologue(name
);
2333 print_string(arg0
, 0);
2334 print_string(arg1
, 0);
2335 print_pointer(arg2
, 0);
2336 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2337 print_syscall_epilogue(name
);
2339 #define print_lgetxattr print_getxattr
2342 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2344 print_listxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2345 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2346 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2348 print_syscall_prologue(name
);
2349 print_string(arg0
, 0);
2350 print_pointer(arg1
, 0);
2351 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2352 print_syscall_epilogue(name
);
2354 #define print_llistxattr print_listxattr
2357 #if defined(TARGET_NR_fremovexattr)
2359 print_fremovexattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2360 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2361 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2363 print_syscall_prologue(name
);
2364 print_raw_param("%d", arg0
, 0);
2365 print_string(arg1
, 1);
2366 print_syscall_epilogue(name
);
2370 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2372 print_removexattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2373 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2374 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2376 print_syscall_prologue(name
);
2377 print_string(arg0
, 0);
2378 print_string(arg1
, 1);
2379 print_syscall_epilogue(name
);
2381 #define print_lremovexattr print_removexattr
2384 #ifdef TARGET_NR_futimesat
2386 print_futimesat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2387 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2388 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2390 print_syscall_prologue(name
);
2391 print_at_dirfd(arg0
, 0);
2392 print_string(arg1
, 0);
2393 print_timeval(arg2
, 0);
2394 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
2395 print_syscall_epilogue(name
);
2399 #ifdef TARGET_NR_gettimeofday
2401 print_gettimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2402 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2403 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2405 print_syscall_prologue(name
);
2406 print_pointer(arg0
, 0);
2407 print_pointer(arg1
, 1);
2408 print_syscall_epilogue(name
);
2412 #ifdef TARGET_NR_settimeofday
2414 print_settimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2415 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2416 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2418 print_syscall_prologue(name
);
2419 print_timeval(arg0
, 0);
2420 print_timezone(arg1
, 1);
2421 print_syscall_epilogue(name
);
2425 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2427 print_clock_gettime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2428 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2429 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2431 print_syscall_prologue(name
);
2432 print_enums(clockids
, arg0
, 0);
2433 print_pointer(arg1
, 1);
2434 print_syscall_epilogue(name
);
2436 #define print_clock_getres print_clock_gettime
2439 #if defined(TARGET_NR_clock_gettime64)
2441 print_clock_gettime64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2442 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2443 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2445 print_syscall_prologue(name
);
2446 print_enums(clockids
, arg0
, 0);
2447 print_pointer(arg1
, 1);
2448 print_syscall_epilogue(name
);
2452 #ifdef TARGET_NR_clock_settime
2454 print_clock_settime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2455 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2456 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2458 print_syscall_prologue(name
);
2459 print_enums(clockids
, arg0
, 0);
2460 print_timespec(arg1
, 1);
2461 print_syscall_epilogue(name
);
2465 #ifdef TARGET_NR_getitimer
2467 print_getitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2468 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2469 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2471 print_syscall_prologue(name
);
2472 print_enums(itimer_types
, arg0
, 0);
2473 print_pointer(arg1
, 1);
2474 print_syscall_epilogue(name
);
2478 #ifdef TARGET_NR_setitimer
2480 print_setitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2481 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2482 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2484 print_syscall_prologue(name
);
2485 print_enums(itimer_types
, arg0
, 0);
2486 print_itimerval(arg1
, 0);
2487 print_pointer(arg2
, 1);
2488 print_syscall_epilogue(name
);
2492 #ifdef TARGET_NR_link
2494 print_link(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2495 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2496 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2498 print_syscall_prologue(name
);
2499 print_string(arg0
, 0);
2500 print_string(arg1
, 1);
2501 print_syscall_epilogue(name
);
2505 #ifdef TARGET_NR_linkat
2507 print_linkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2508 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2509 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2511 print_syscall_prologue(name
);
2512 print_at_dirfd(arg0
, 0);
2513 print_string(arg1
, 0);
2514 print_at_dirfd(arg2
, 0);
2515 print_string(arg3
, 0);
2516 print_flags(at_file_flags
, arg4
, 1);
2517 print_syscall_epilogue(name
);
2521 #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
2523 print__llseek(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2524 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2525 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2527 const char *whence
= "UNKNOWN";
2528 print_syscall_prologue(name
);
2529 print_raw_param("%d", arg0
, 0);
2530 print_raw_param("%ld", arg1
, 0);
2531 print_raw_param("%ld", arg2
, 0);
2532 print_pointer(arg3
, 0);
2534 case SEEK_SET
: whence
= "SEEK_SET"; break;
2535 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
2536 case SEEK_END
: whence
= "SEEK_END"; break;
2538 qemu_log("%s", whence
);
2539 print_syscall_epilogue(name
);
2541 #define print_llseek print__llseek
2544 #ifdef TARGET_NR_lseek
2546 print_lseek(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2547 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2548 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2550 print_syscall_prologue(name
);
2551 print_raw_param("%d", arg0
, 0);
2552 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2555 qemu_log("SEEK_SET"); break;
2557 qemu_log("SEEK_CUR"); break;
2559 qemu_log("SEEK_END"); break;
2562 qemu_log("SEEK_DATA"); break;
2566 qemu_log("SEEK_HOLE"); break;
2569 print_raw_param("%#x", arg2
, 1);
2571 print_syscall_epilogue(name
);
2575 #ifdef TARGET_NR_truncate
2577 print_truncate(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2578 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2579 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2581 print_syscall_prologue(name
);
2582 print_string(arg0
, 0);
2583 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 1);
2584 print_syscall_epilogue(name
);
2588 #ifdef TARGET_NR_truncate64
2590 print_truncate64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2591 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2592 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2594 print_syscall_prologue(name
);
2595 print_string(arg0
, 0);
2596 if (regpairs_aligned(cpu_env
, TARGET_NR_truncate64
)) {
2600 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2601 print_syscall_epilogue(name
);
2605 #ifdef TARGET_NR_ftruncate64
2607 print_ftruncate64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2608 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2609 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2611 print_syscall_prologue(name
);
2612 print_raw_param("%d", arg0
, 0);
2613 if (regpairs_aligned(cpu_env
, TARGET_NR_ftruncate64
)) {
2617 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2618 print_syscall_epilogue(name
);
2622 #ifdef TARGET_NR_mlockall
2624 print_mlockall(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2625 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2626 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2628 print_syscall_prologue(name
);
2629 print_flags(mlockall_flags
, arg0
, 1);
2630 print_syscall_epilogue(name
);
2634 #if defined(TARGET_NR_socket)
2636 print_socket(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2637 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2638 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2640 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
2642 print_syscall_prologue(name
);
2643 print_socket_domain(domain
);
2645 print_socket_type(type
);
2647 if (domain
== AF_PACKET
||
2648 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2649 protocol
= tswap16(protocol
);
2651 print_socket_protocol(domain
, type
, protocol
);
2652 print_syscall_epilogue(name
);
2657 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2659 static void print_sockfd(abi_long sockfd
, int last
)
2661 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
2666 #if defined(TARGET_NR_socketcall)
2668 #define get_user_ualx(x, gaddr, idx) \
2669 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2671 static void do_print_socket(const char *name
, abi_long arg1
)
2673 abi_ulong domain
, type
, protocol
;
2675 get_user_ualx(domain
, arg1
, 0);
2676 get_user_ualx(type
, arg1
, 1);
2677 get_user_ualx(protocol
, arg1
, 2);
2678 qemu_log("%s(", name
);
2679 print_socket_domain(domain
);
2681 print_socket_type(type
);
2683 if (domain
== AF_PACKET
||
2684 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2685 protocol
= tswap16(protocol
);
2687 print_socket_protocol(domain
, type
, protocol
);
2691 static void do_print_sockaddr(const char *name
, abi_long arg1
)
2693 abi_ulong sockfd
, addr
, addrlen
;
2695 get_user_ualx(sockfd
, arg1
, 0);
2696 get_user_ualx(addr
, arg1
, 1);
2697 get_user_ualx(addrlen
, arg1
, 2);
2699 qemu_log("%s(", name
);
2700 print_sockfd(sockfd
, 0);
2701 print_sockaddr(addr
, addrlen
, 0);
2705 static void do_print_listen(const char *name
, abi_long arg1
)
2707 abi_ulong sockfd
, backlog
;
2709 get_user_ualx(sockfd
, arg1
, 0);
2710 get_user_ualx(backlog
, arg1
, 1);
2712 qemu_log("%s(", name
);
2713 print_sockfd(sockfd
, 0);
2714 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
2718 static void do_print_socketpair(const char *name
, abi_long arg1
)
2720 abi_ulong domain
, type
, protocol
, tab
;
2722 get_user_ualx(domain
, arg1
, 0);
2723 get_user_ualx(type
, arg1
, 1);
2724 get_user_ualx(protocol
, arg1
, 2);
2725 get_user_ualx(tab
, arg1
, 3);
2727 qemu_log("%s(", name
);
2728 print_socket_domain(domain
);
2730 print_socket_type(type
);
2732 print_socket_protocol(domain
, type
, protocol
);
2734 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
2738 static void do_print_sendrecv(const char *name
, abi_long arg1
)
2740 abi_ulong sockfd
, msg
, len
, flags
;
2742 get_user_ualx(sockfd
, arg1
, 0);
2743 get_user_ualx(msg
, arg1
, 1);
2744 get_user_ualx(len
, arg1
, 2);
2745 get_user_ualx(flags
, arg1
, 3);
2747 qemu_log("%s(", name
);
2748 print_sockfd(sockfd
, 0);
2749 print_buf(msg
, len
, 0);
2750 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2751 print_flags(msg_flags
, flags
, 1);
2755 static void do_print_msgaddr(const char *name
, abi_long arg1
)
2757 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
2759 get_user_ualx(sockfd
, arg1
, 0);
2760 get_user_ualx(msg
, arg1
, 1);
2761 get_user_ualx(len
, arg1
, 2);
2762 get_user_ualx(flags
, arg1
, 3);
2763 get_user_ualx(addr
, arg1
, 4);
2764 get_user_ualx(addrlen
, arg1
, 5);
2766 qemu_log("%s(", name
);
2767 print_sockfd(sockfd
, 0);
2768 print_buf(msg
, len
, 0);
2769 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2770 print_flags(msg_flags
, flags
, 0);
2771 print_sockaddr(addr
, addrlen
, 0);
2775 static void do_print_shutdown(const char *name
, abi_long arg1
)
2777 abi_ulong sockfd
, how
;
2779 get_user_ualx(sockfd
, arg1
, 0);
2780 get_user_ualx(how
, arg1
, 1);
2782 qemu_log("shutdown(");
2783 print_sockfd(sockfd
, 0);
2786 qemu_log("SHUT_RD");
2789 qemu_log("SHUT_WR");
2792 qemu_log("SHUT_RDWR");
2795 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
2801 static void do_print_msg(const char *name
, abi_long arg1
)
2803 abi_ulong sockfd
, msg
, flags
;
2805 get_user_ualx(sockfd
, arg1
, 0);
2806 get_user_ualx(msg
, arg1
, 1);
2807 get_user_ualx(flags
, arg1
, 2);
2809 qemu_log("%s(", name
);
2810 print_sockfd(sockfd
, 0);
2811 print_pointer(msg
, 0);
2812 print_flags(msg_flags
, flags
, 1);
2816 static void do_print_sockopt(const char *name
, abi_long arg1
)
2818 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
2820 get_user_ualx(sockfd
, arg1
, 0);
2821 get_user_ualx(level
, arg1
, 1);
2822 get_user_ualx(optname
, arg1
, 2);
2823 get_user_ualx(optval
, arg1
, 3);
2824 get_user_ualx(optlen
, arg1
, 4);
2826 qemu_log("%s(", name
);
2827 print_sockfd(sockfd
, 0);
2830 qemu_log("SOL_TCP,");
2831 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2832 print_pointer(optval
, 0);
2835 qemu_log("SOL_UDP,");
2836 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2837 print_pointer(optval
, 0);
2840 qemu_log("SOL_IP,");
2841 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2842 print_pointer(optval
, 0);
2845 qemu_log("SOL_RAW,");
2846 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2847 print_pointer(optval
, 0);
2849 case TARGET_SOL_SOCKET
:
2850 qemu_log("SOL_SOCKET,");
2852 case TARGET_SO_DEBUG
:
2853 qemu_log("SO_DEBUG,");
2855 print_number(optval
, 0);
2857 case TARGET_SO_REUSEADDR
:
2858 qemu_log("SO_REUSEADDR,");
2860 case TARGET_SO_REUSEPORT
:
2861 qemu_log("SO_REUSEPORT,");
2863 case TARGET_SO_TYPE
:
2864 qemu_log("SO_TYPE,");
2866 case TARGET_SO_ERROR
:
2867 qemu_log("SO_ERROR,");
2869 case TARGET_SO_DONTROUTE
:
2870 qemu_log("SO_DONTROUTE,");
2872 case TARGET_SO_BROADCAST
:
2873 qemu_log("SO_BROADCAST,");
2875 case TARGET_SO_SNDBUF
:
2876 qemu_log("SO_SNDBUF,");
2878 case TARGET_SO_RCVBUF
:
2879 qemu_log("SO_RCVBUF,");
2881 case TARGET_SO_KEEPALIVE
:
2882 qemu_log("SO_KEEPALIVE,");
2884 case TARGET_SO_OOBINLINE
:
2885 qemu_log("SO_OOBINLINE,");
2887 case TARGET_SO_NO_CHECK
:
2888 qemu_log("SO_NO_CHECK,");
2890 case TARGET_SO_PRIORITY
:
2891 qemu_log("SO_PRIORITY,");
2893 case TARGET_SO_BSDCOMPAT
:
2894 qemu_log("SO_BSDCOMPAT,");
2896 case TARGET_SO_PASSCRED
:
2897 qemu_log("SO_PASSCRED,");
2899 case TARGET_SO_TIMESTAMP
:
2900 qemu_log("SO_TIMESTAMP,");
2902 case TARGET_SO_RCVLOWAT
:
2903 qemu_log("SO_RCVLOWAT,");
2905 case TARGET_SO_RCVTIMEO
:
2906 qemu_log("SO_RCVTIMEO,");
2907 print_timeval(optval
, 0);
2909 case TARGET_SO_SNDTIMEO
:
2910 qemu_log("SO_SNDTIMEO,");
2911 print_timeval(optval
, 0);
2913 case TARGET_SO_ATTACH_FILTER
: {
2914 struct target_sock_fprog
*fprog
;
2916 qemu_log("SO_ATTACH_FILTER,");
2918 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
2919 struct target_sock_filter
*filter
;
2921 if (lock_user_struct(VERIFY_READ
, filter
,
2922 tswapal(fprog
->filter
), 0)) {
2924 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
2925 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2926 i
, tswap16(filter
[i
].code
),
2927 filter
[i
].jt
, filter
[i
].jf
,
2928 tswap32(filter
[i
].k
));
2930 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2931 i
, tswap16(filter
[i
].code
),
2932 filter
[i
].jt
, filter
[i
].jf
,
2933 tswap32(filter
[i
].k
));
2935 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
2937 qemu_log(",%d},", tswap16(fprog
->len
));
2938 unlock_user(fprog
, optval
, 0);
2940 print_pointer(optval
, 0);
2945 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2946 print_pointer(optval
, 0);
2951 qemu_log("SOL_IPV6,");
2953 case IPV6_MTU_DISCOVER
:
2954 qemu_log("IPV6_MTU_DISCOVER,");
2957 qemu_log("IPV6_MTU,");
2960 qemu_log("IPV6_V6ONLY,");
2962 case IPV6_RECVPKTINFO
:
2963 qemu_log("IPV6_RECVPKTINFO,");
2965 case IPV6_UNICAST_HOPS
:
2966 qemu_log("IPV6_UNICAST_HOPS,");
2968 case IPV6_MULTICAST_HOPS
:
2969 qemu_log("IPV6_MULTICAST_HOPS,");
2971 case IPV6_MULTICAST_LOOP
:
2972 qemu_log("IPV6_MULTICAST_LOOP,");
2975 qemu_log("IPV6_RECVERR,");
2977 case IPV6_RECVHOPLIMIT
:
2978 qemu_log("IPV6_RECVHOPLIMIT,");
2980 case IPV6_2292HOPLIMIT
:
2981 qemu_log("IPV6_2292HOPLIMIT,");
2984 qemu_log("IPV6_CHECKSUM,");
2987 qemu_log("IPV6_ADDRFORM,");
2989 case IPV6_2292PKTINFO
:
2990 qemu_log("IPV6_2292PKTINFO,");
2992 case IPV6_RECVTCLASS
:
2993 qemu_log("IPV6_RECVTCLASS,");
2995 case IPV6_RECVRTHDR
:
2996 qemu_log("IPV6_RECVRTHDR,");
2998 case IPV6_2292RTHDR
:
2999 qemu_log("IPV6_2292RTHDR,");
3001 case IPV6_RECVHOPOPTS
:
3002 qemu_log("IPV6_RECVHOPOPTS,");
3004 case IPV6_2292HOPOPTS
:
3005 qemu_log("IPV6_2292HOPOPTS,");
3007 case IPV6_RECVDSTOPTS
:
3008 qemu_log("IPV6_RECVDSTOPTS,");
3010 case IPV6_2292DSTOPTS
:
3011 qemu_log("IPV6_2292DSTOPTS,");
3014 qemu_log("IPV6_TCLASS,");
3016 case IPV6_ADDR_PREFERENCES
:
3017 qemu_log("IPV6_ADDR_PREFERENCES,");
3019 #ifdef IPV6_RECVPATHMTU
3020 case IPV6_RECVPATHMTU
:
3021 qemu_log("IPV6_RECVPATHMTU,");
3024 #ifdef IPV6_TRANSPARENT
3025 case IPV6_TRANSPARENT
:
3026 qemu_log("IPV6_TRANSPARENT,");
3029 #ifdef IPV6_FREEBIND
3031 qemu_log("IPV6_FREEBIND,");
3034 #ifdef IPV6_RECVORIGDSTADDR
3035 case IPV6_RECVORIGDSTADDR
:
3036 qemu_log("IPV6_RECVORIGDSTADDR,");
3040 qemu_log("IPV6_PKTINFO,");
3041 print_pointer(optval
, 0);
3043 case IPV6_ADD_MEMBERSHIP
:
3044 qemu_log("IPV6_ADD_MEMBERSHIP,");
3045 print_pointer(optval
, 0);
3047 case IPV6_DROP_MEMBERSHIP
:
3048 qemu_log("IPV6_DROP_MEMBERSHIP,");
3049 print_pointer(optval
, 0);
3052 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
3053 print_pointer(optval
, 0);
3058 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
3059 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
3060 print_pointer(optval
, 0);
3063 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
3067 #define PRINT_SOCKOP(name, func) \
3068 [TARGET_SYS_##name] = { #name, func }
3072 void (*print
)(const char *, abi_long
);
3074 PRINT_SOCKOP(SOCKET
, do_print_socket
),
3075 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
3076 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
3077 PRINT_SOCKOP(LISTEN
, do_print_listen
),
3078 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
3079 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
3080 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
3081 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
3082 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
3083 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
3084 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
3085 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
3086 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
3087 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
3088 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
3089 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
3090 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
3091 PRINT_SOCKOP(ACCEPT4
, NULL
),
3092 PRINT_SOCKOP(RECVMMSG
, NULL
),
3093 PRINT_SOCKOP(SENDMMSG
, NULL
),
3097 print_socketcall(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3098 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3099 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3101 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
3102 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
3105 print_syscall_prologue(name
);
3106 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
3107 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
3108 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
3109 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
3110 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
3111 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
3112 print_syscall_epilogue(name
);
3116 #if defined(TARGET_NR_bind)
3118 print_bind(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3119 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3120 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3122 print_syscall_prologue(name
);
3123 print_sockfd(arg0
, 0);
3124 print_sockaddr(arg1
, arg2
, 1);
3125 print_syscall_epilogue(name
);
3129 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
3130 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
3132 print_stat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3133 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3134 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3136 print_syscall_prologue(name
);
3137 print_string(arg0
, 0);
3138 print_pointer(arg1
, 1);
3139 print_syscall_epilogue(name
);
3141 #define print_lstat print_stat
3142 #define print_stat64 print_stat
3143 #define print_lstat64 print_stat
3146 #if defined(TARGET_NR_madvise)
3147 static struct enums madvise_advice
[] = {
3148 ENUM_TARGET(MADV_NORMAL
),
3149 ENUM_TARGET(MADV_RANDOM
),
3150 ENUM_TARGET(MADV_SEQUENTIAL
),
3151 ENUM_TARGET(MADV_WILLNEED
),
3152 ENUM_TARGET(MADV_DONTNEED
),
3153 ENUM_TARGET(MADV_FREE
),
3154 ENUM_TARGET(MADV_REMOVE
),
3155 ENUM_TARGET(MADV_DONTFORK
),
3156 ENUM_TARGET(MADV_DOFORK
),
3157 ENUM_TARGET(MADV_MERGEABLE
),
3158 ENUM_TARGET(MADV_UNMERGEABLE
),
3159 ENUM_TARGET(MADV_HUGEPAGE
),
3160 ENUM_TARGET(MADV_NOHUGEPAGE
),
3161 ENUM_TARGET(MADV_DONTDUMP
),
3162 ENUM_TARGET(MADV_DODUMP
),
3163 ENUM_TARGET(MADV_WIPEONFORK
),
3164 ENUM_TARGET(MADV_KEEPONFORK
),
3165 ENUM_TARGET(MADV_COLD
),
3166 ENUM_TARGET(MADV_PAGEOUT
),
3167 ENUM_TARGET(MADV_POPULATE_READ
),
3168 ENUM_TARGET(MADV_POPULATE_WRITE
),
3169 ENUM_TARGET(MADV_DONTNEED_LOCKED
),
3174 print_madvise(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3175 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3176 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3178 print_syscall_prologue(name
);
3179 print_pointer(arg0
, 0);
3180 print_raw_param("%d", arg1
, 0);
3181 print_enums(madvise_advice
, arg2
, 1);
3182 print_syscall_epilogue(name
);
3186 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
3188 print_fstat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3189 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3190 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3192 print_syscall_prologue(name
);
3193 print_raw_param("%d", arg0
, 0);
3194 print_pointer(arg1
, 1);
3195 print_syscall_epilogue(name
);
3197 #define print_fstat64 print_fstat
3200 #ifdef TARGET_NR_mkdir
3202 print_mkdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3203 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3204 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3206 print_syscall_prologue(name
);
3207 print_string(arg0
, 0);
3208 print_file_mode(arg1
, 1);
3209 print_syscall_epilogue(name
);
3213 #ifdef TARGET_NR_mkdirat
3215 print_mkdirat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3216 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3217 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3219 print_syscall_prologue(name
);
3220 print_at_dirfd(arg0
, 0);
3221 print_string(arg1
, 0);
3222 print_file_mode(arg2
, 1);
3223 print_syscall_epilogue(name
);
3227 #ifdef TARGET_NR_rmdir
3229 print_rmdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3230 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3231 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3233 print_syscall_prologue(name
);
3234 print_string(arg0
, 0);
3235 print_syscall_epilogue(name
);
3239 #ifdef TARGET_NR_rt_sigaction
3241 print_rt_sigaction(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3242 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3243 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3245 print_syscall_prologue(name
);
3246 print_signal(arg0
, 0);
3247 print_pointer(arg1
, 0);
3248 print_pointer(arg2
, 1);
3249 print_syscall_epilogue(name
);
3253 #ifdef TARGET_NR_rt_sigprocmask
3255 print_rt_sigprocmask(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3256 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3257 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3259 const char *how
= "UNKNOWN";
3260 print_syscall_prologue(name
);
3262 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
3263 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
3264 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
3266 qemu_log("%s,", how
);
3267 print_pointer(arg1
, 0);
3268 print_pointer(arg2
, 0);
3269 print_raw_param("%u", arg3
, 1);
3270 print_syscall_epilogue(name
);
3274 #ifdef TARGET_NR_rt_sigqueueinfo
3276 print_rt_sigqueueinfo(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3277 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3278 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3281 target_siginfo_t uinfo
;
3283 print_syscall_prologue(name
);
3284 print_raw_param("%d", arg0
, 0);
3285 print_signal(arg1
, 0);
3286 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
3288 get_target_siginfo(&uinfo
, p
);
3289 print_siginfo(&uinfo
);
3291 unlock_user(p
, arg2
, 0);
3293 print_pointer(arg2
, 1);
3295 print_syscall_epilogue(name
);
3299 #ifdef TARGET_NR_rt_tgsigqueueinfo
3301 print_rt_tgsigqueueinfo(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3302 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3303 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3306 target_siginfo_t uinfo
;
3308 print_syscall_prologue(name
);
3309 print_raw_param("%d", arg0
, 0);
3310 print_raw_param("%d", arg1
, 0);
3311 print_signal(arg2
, 0);
3312 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
3314 get_target_siginfo(&uinfo
, p
);
3315 print_siginfo(&uinfo
);
3317 unlock_user(p
, arg3
, 0);
3319 print_pointer(arg3
, 1);
3321 print_syscall_epilogue(name
);
3325 #ifdef TARGET_NR_syslog
3327 print_syslog_action(abi_ulong arg
, int last
)
3332 case TARGET_SYSLOG_ACTION_CLOSE
: {
3333 type
= "SYSLOG_ACTION_CLOSE";
3336 case TARGET_SYSLOG_ACTION_OPEN
: {
3337 type
= "SYSLOG_ACTION_OPEN";
3340 case TARGET_SYSLOG_ACTION_READ
: {
3341 type
= "SYSLOG_ACTION_READ";
3344 case TARGET_SYSLOG_ACTION_READ_ALL
: {
3345 type
= "SYSLOG_ACTION_READ_ALL";
3348 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
3349 type
= "SYSLOG_ACTION_READ_CLEAR";
3352 case TARGET_SYSLOG_ACTION_CLEAR
: {
3353 type
= "SYSLOG_ACTION_CLEAR";
3356 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
3357 type
= "SYSLOG_ACTION_CONSOLE_OFF";
3360 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
3361 type
= "SYSLOG_ACTION_CONSOLE_ON";
3364 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
3365 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
3368 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
3369 type
= "SYSLOG_ACTION_SIZE_UNREAD";
3372 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
3373 type
= "SYSLOG_ACTION_SIZE_BUFFER";
3377 print_raw_param("%ld", arg
, last
);
3381 qemu_log("%s%s", type
, get_comma(last
));
3385 print_syslog(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3386 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3387 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3389 print_syscall_prologue(name
);
3390 print_syslog_action(arg0
, 0);
3391 print_pointer(arg1
, 0);
3392 print_raw_param("%d", arg2
, 1);
3393 print_syscall_epilogue(name
);
3397 #ifdef TARGET_NR_mknod
3399 print_mknod(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3400 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3401 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3403 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
3405 print_syscall_prologue(name
);
3406 print_string(arg0
, 0);
3407 print_file_mode(arg1
, (hasdev
== 0));
3409 print_raw_param("makedev(%d", major(arg2
), 0);
3410 print_raw_param("%d)", minor(arg2
), 1);
3412 print_syscall_epilogue(name
);
3416 #ifdef TARGET_NR_mknodat
3418 print_mknodat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3419 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3420 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3422 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
3424 print_syscall_prologue(name
);
3425 print_at_dirfd(arg0
, 0);
3426 print_string(arg1
, 0);
3427 print_file_mode(arg2
, (hasdev
== 0));
3429 print_raw_param("makedev(%d", major(arg3
), 0);
3430 print_raw_param("%d)", minor(arg3
), 1);
3432 print_syscall_epilogue(name
);
3436 #ifdef TARGET_NR_mq_open
3438 print_mq_open(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3439 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3440 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3442 int is_creat
= (arg1
& TARGET_O_CREAT
);
3444 print_syscall_prologue(name
);
3445 print_string(arg0
, 0);
3446 print_open_flags(arg1
, (is_creat
== 0));
3448 print_file_mode(arg2
, 0);
3449 print_pointer(arg3
, 1);
3451 print_syscall_epilogue(name
);
3455 #ifdef TARGET_NR_open
3457 print_open(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3458 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3459 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3461 int is_creat
= (arg1
& TARGET_O_CREAT
);
3463 print_syscall_prologue(name
);
3464 print_string(arg0
, 0);
3465 print_open_flags(arg1
, (is_creat
== 0));
3467 print_file_mode(arg2
, 1);
3468 print_syscall_epilogue(name
);
3472 #ifdef TARGET_NR_openat
3474 print_openat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3475 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3476 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3478 int is_creat
= (arg2
& TARGET_O_CREAT
);
3480 print_syscall_prologue(name
);
3481 print_at_dirfd(arg0
, 0);
3482 print_string(arg1
, 0);
3483 print_open_flags(arg2
, (is_creat
== 0));
3485 print_file_mode(arg3
, 1);
3486 print_syscall_epilogue(name
);
3490 #ifdef TARGET_NR_pidfd_send_signal
3492 print_pidfd_send_signal(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3493 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3494 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3497 target_siginfo_t uinfo
;
3499 print_syscall_prologue(name
);
3500 print_raw_param("%d", arg0
, 0);
3501 print_signal(arg1
, 0);
3503 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
3505 get_target_siginfo(&uinfo
, p
);
3506 print_siginfo(&uinfo
);
3508 unlock_user(p
, arg2
, 0);
3510 print_pointer(arg2
, 0);
3513 print_raw_param("%u", arg3
, 1);
3514 print_syscall_epilogue(name
);
3518 #ifdef TARGET_NR_mq_unlink
3520 print_mq_unlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3521 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3522 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3524 print_syscall_prologue(name
);
3525 print_string(arg0
, 1);
3526 print_syscall_epilogue(name
);
3530 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3532 print_fstatat64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3533 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3534 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3536 print_syscall_prologue(name
);
3537 print_at_dirfd(arg0
, 0);
3538 print_string(arg1
, 0);
3539 print_pointer(arg2
, 0);
3540 print_flags(at_file_flags
, arg3
, 1);
3541 print_syscall_epilogue(name
);
3543 #define print_newfstatat print_fstatat64
3546 #ifdef TARGET_NR_readlink
3548 print_readlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3549 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3550 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3552 print_syscall_prologue(name
);
3553 print_string(arg0
, 0);
3554 print_pointer(arg1
, 0);
3555 print_raw_param("%u", arg2
, 1);
3556 print_syscall_epilogue(name
);
3560 #ifdef TARGET_NR_readlinkat
3562 print_readlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3563 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3564 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3566 print_syscall_prologue(name
);
3567 print_at_dirfd(arg0
, 0);
3568 print_string(arg1
, 0);
3569 print_pointer(arg2
, 0);
3570 print_raw_param("%u", arg3
, 1);
3571 print_syscall_epilogue(name
);
3575 #ifdef TARGET_NR_rename
3577 print_rename(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3578 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3579 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3581 print_syscall_prologue(name
);
3582 print_string(arg0
, 0);
3583 print_string(arg1
, 1);
3584 print_syscall_epilogue(name
);
3588 #ifdef TARGET_NR_renameat
3590 print_renameat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3591 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3592 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3594 print_syscall_prologue(name
);
3595 print_at_dirfd(arg0
, 0);
3596 print_string(arg1
, 0);
3597 print_at_dirfd(arg2
, 0);
3598 print_string(arg3
, 1);
3599 print_syscall_epilogue(name
);
3603 #ifdef TARGET_NR_statfs
3605 print_statfs(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3606 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3607 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3609 print_syscall_prologue(name
);
3610 print_string(arg0
, 0);
3611 print_pointer(arg1
, 1);
3612 print_syscall_epilogue(name
);
3616 #ifdef TARGET_NR_statfs64
3618 print_statfs64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3619 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3620 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3622 print_syscall_prologue(name
);
3623 print_string(arg0
, 0);
3624 print_pointer(arg1
, 1);
3625 print_syscall_epilogue(name
);
3629 #ifdef TARGET_NR_symlink
3631 print_symlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3632 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3633 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3635 print_syscall_prologue(name
);
3636 print_string(arg0
, 0);
3637 print_string(arg1
, 1);
3638 print_syscall_epilogue(name
);
3642 #ifdef TARGET_NR_symlinkat
3644 print_symlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3645 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3646 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3648 print_syscall_prologue(name
);
3649 print_string(arg0
, 0);
3650 print_at_dirfd(arg1
, 0);
3651 print_string(arg2
, 1);
3652 print_syscall_epilogue(name
);
3656 #ifdef TARGET_NR_mount
3658 print_mount(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3659 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3660 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3662 print_syscall_prologue(name
);
3663 print_string(arg0
, 0);
3664 print_string(arg1
, 0);
3665 print_string(arg2
, 0);
3666 print_flags(mount_flags
, arg3
, 0);
3667 print_pointer(arg4
, 1);
3668 print_syscall_epilogue(name
);
3672 #ifdef TARGET_NR_umount
3674 print_umount(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3675 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3676 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3678 print_syscall_prologue(name
);
3679 print_string(arg0
, 1);
3680 print_syscall_epilogue(name
);
3684 #ifdef TARGET_NR_umount2
3686 print_umount2(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3687 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3688 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3690 print_syscall_prologue(name
);
3691 print_string(arg0
, 0);
3692 print_flags(umount2_flags
, arg1
, 1);
3693 print_syscall_epilogue(name
);
3697 #ifdef TARGET_NR_unlink
3699 print_unlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3700 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3701 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3703 print_syscall_prologue(name
);
3704 print_string(arg0
, 1);
3705 print_syscall_epilogue(name
);
3709 #ifdef TARGET_NR_unlinkat
3711 print_unlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3712 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3713 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3715 print_syscall_prologue(name
);
3716 print_at_dirfd(arg0
, 0);
3717 print_string(arg1
, 0);
3718 print_flags(unlinkat_flags
, arg2
, 1);
3719 print_syscall_epilogue(name
);
3723 #ifdef TARGET_NR_unshare
3725 print_unshare(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3726 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3727 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3729 print_syscall_prologue(name
);
3730 print_flags(clone_flags
, arg0
, 1);
3731 print_syscall_epilogue(name
);
3735 #ifdef TARGET_NR_clock_nanosleep
3737 print_clock_nanosleep(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3738 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3739 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3741 print_syscall_prologue(name
);
3742 print_enums(clockids
, arg0
, 0);
3743 print_raw_param("%d", arg1
, 0);
3744 print_timespec(arg2
, 0);
3745 print_timespec(arg3
, 1);
3746 print_syscall_epilogue(name
);
3750 #ifdef TARGET_NR_utime
3752 print_utime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3753 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3754 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3756 print_syscall_prologue(name
);
3757 print_string(arg0
, 0);
3758 print_pointer(arg1
, 1);
3759 print_syscall_epilogue(name
);
3763 #ifdef TARGET_NR_utimes
3765 print_utimes(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3766 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3767 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3769 print_syscall_prologue(name
);
3770 print_string(arg0
, 0);
3771 print_pointer(arg1
, 1);
3772 print_syscall_epilogue(name
);
3776 #ifdef TARGET_NR_utimensat
3778 print_utimensat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3779 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3780 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3782 print_syscall_prologue(name
);
3783 print_at_dirfd(arg0
, 0);
3784 print_string(arg1
, 0);
3785 print_pointer(arg2
, 0);
3786 print_flags(at_file_flags
, arg3
, 1);
3787 print_syscall_epilogue(name
);
3791 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3793 print_mmap_both(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3794 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3795 abi_long arg3
, abi_long arg4
, abi_long arg5
,
3800 abi_ulong argp
= arg0
;
3801 if (!(v
= lock_user(VERIFY_READ
, argp
, 6 * sizeof(abi_ulong
), 1)))
3803 arg0
= tswapal(v
[0]);
3804 arg1
= tswapal(v
[1]);
3805 arg2
= tswapal(v
[2]);
3806 arg3
= tswapal(v
[3]);
3807 arg4
= tswapal(v
[4]);
3808 arg5
= tswapal(v
[5]);
3809 unlock_user(v
, argp
, 0);
3811 print_syscall_prologue(name
);
3812 print_pointer(arg0
, 0);
3813 print_raw_param("%d", arg1
, 0);
3814 print_flags(mmap_prot_flags
, arg2
, 0);
3815 print_flags(mmap_flags
, arg3
, 0);
3816 print_raw_param("%d", arg4
, 0);
3817 print_raw_param("%#x", arg5
, 1);
3818 print_syscall_epilogue(name
);
3822 #if defined(TARGET_NR_mmap)
3824 print_mmap(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3825 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3826 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3828 return print_mmap_both(cpu_env
, name
, arg0
, arg1
, arg2
, arg3
,
3830 #if defined(TARGET_NR_mmap2)
3839 #if defined(TARGET_NR_mmap2)
3841 print_mmap2(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3842 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3843 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3845 return print_mmap_both(cpu_env
, name
, arg0
, arg1
, arg2
, arg3
,
3850 #ifdef TARGET_NR_mprotect
3852 print_mprotect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3853 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3854 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3856 print_syscall_prologue(name
);
3857 print_pointer(arg0
, 0);
3858 print_raw_param("%d", arg1
, 0);
3859 print_flags(mmap_prot_flags
, arg2
, 1);
3860 print_syscall_epilogue(name
);
3864 #ifdef TARGET_NR_munmap
3866 print_munmap(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3867 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3868 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3870 print_syscall_prologue(name
);
3871 print_pointer(arg0
, 0);
3872 print_raw_param("%d", arg1
, 1);
3873 print_syscall_epilogue(name
);
3877 #ifdef TARGET_NR_futex
3878 static void print_futex_op(int cmd
, int last
)
3880 static const char * const futex_names
[] = {
3881 #define NAME(X) [X] = #X
3885 NAME(FUTEX_REQUEUE
),
3886 NAME(FUTEX_CMP_REQUEUE
),
3887 NAME(FUTEX_WAKE_OP
),
3888 NAME(FUTEX_LOCK_PI
),
3889 NAME(FUTEX_UNLOCK_PI
),
3890 NAME(FUTEX_TRYLOCK_PI
),
3891 NAME(FUTEX_WAIT_BITSET
),
3892 NAME(FUTEX_WAKE_BITSET
),
3893 NAME(FUTEX_WAIT_REQUEUE_PI
),
3894 NAME(FUTEX_CMP_REQUEUE_PI
),
3895 NAME(FUTEX_LOCK_PI2
),
3899 unsigned base_cmd
= cmd
& FUTEX_CMD_MASK
;
3901 if (base_cmd
< ARRAY_SIZE(futex_names
)) {
3903 (cmd
& FUTEX_PRIVATE_FLAG
? "FUTEX_PRIVATE_FLAG|" : ""),
3904 (cmd
& FUTEX_CLOCK_REALTIME
? "FUTEX_CLOCK_REALTIME|" : ""),
3905 futex_names
[base_cmd
]);
3907 qemu_log("0x%x", cmd
);
3912 print_futex(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3913 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3914 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3916 abi_long op
= arg1
& FUTEX_CMD_MASK
;
3917 print_syscall_prologue(name
);
3918 print_pointer(arg0
, 0);
3919 print_futex_op(arg1
, 0);
3920 print_raw_param(",%d", arg2
, 0);
3923 case FUTEX_WAIT_BITSET
:
3925 case FUTEX_LOCK_PI2
:
3926 case FUTEX_WAIT_REQUEUE_PI
:
3927 print_timespec(arg3
, 0);
3930 print_pointer(arg3
, 0);
3933 print_pointer(arg4
, 0);
3934 print_raw_param("%d", arg4
, 1);
3935 print_syscall_epilogue(name
);
3939 #ifdef TARGET_NR_prlimit64
3940 static const char *target_ressource_string(abi_ulong r
)
3942 #define RET_RES_ENTRY(res) case TARGET_##res: return #res;
3944 RET_RES_ENTRY(RLIMIT_AS
);
3945 RET_RES_ENTRY(RLIMIT_CORE
);
3946 RET_RES_ENTRY(RLIMIT_CPU
);
3947 RET_RES_ENTRY(RLIMIT_DATA
);
3948 RET_RES_ENTRY(RLIMIT_FSIZE
);
3949 RET_RES_ENTRY(RLIMIT_LOCKS
);
3950 RET_RES_ENTRY(RLIMIT_MEMLOCK
);
3951 RET_RES_ENTRY(RLIMIT_MSGQUEUE
);
3952 RET_RES_ENTRY(RLIMIT_NICE
);
3953 RET_RES_ENTRY(RLIMIT_NOFILE
);
3954 RET_RES_ENTRY(RLIMIT_NPROC
);
3955 RET_RES_ENTRY(RLIMIT_RSS
);
3956 RET_RES_ENTRY(RLIMIT_RTPRIO
);
3957 #ifdef RLIMIT_RTTIME
3958 RET_RES_ENTRY(RLIMIT_RTTIME
);
3960 RET_RES_ENTRY(RLIMIT_SIGPENDING
);
3961 RET_RES_ENTRY(RLIMIT_STACK
);
3965 #undef RET_RES_ENTRY
3969 print_rlimit64(abi_ulong rlim_addr
, int last
)
3972 struct target_rlimit64
*rl
;
3974 rl
= lock_user(VERIFY_READ
, rlim_addr
, sizeof(*rl
), 1);
3976 print_pointer(rlim_addr
, last
);
3979 print_raw_param64("{rlim_cur=%" PRId64
, tswap64(rl
->rlim_cur
), 0);
3980 print_raw_param64("rlim_max=%" PRId64
"}", tswap64(rl
->rlim_max
),
3982 unlock_user(rl
, rlim_addr
, 0);
3984 qemu_log("NULL%s", get_comma(last
));
3989 print_prlimit64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3990 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3991 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3993 const char *rlim_name
;
3995 print_syscall_prologue(name
);
3996 print_raw_param("%d", arg0
, 0);
3997 rlim_name
= target_ressource_string(arg1
);
3999 qemu_log("%s,", rlim_name
);
4001 print_raw_param("%d", arg1
, 0);
4003 print_rlimit64(arg2
, 0);
4004 print_pointer(arg3
, 1);
4005 print_syscall_epilogue(name
);
4009 print_syscall_ret_prlimit64(CPUArchState
*cpu_env
,
4010 const struct syscallname
*name
,
4011 abi_long ret
, abi_long arg0
, abi_long arg1
,
4012 abi_long arg2
, abi_long arg3
, abi_long arg4
,
4015 if (!print_syscall_err(ret
)) {
4016 qemu_log(TARGET_ABI_FMT_ld
, ret
);
4019 print_rlimit64(arg3
, 1);
4027 #ifdef TARGET_NR_kill
4029 print_kill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4030 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4031 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4033 print_syscall_prologue(name
);
4034 print_raw_param("%d", arg0
, 0);
4035 print_signal(arg1
, 1);
4036 print_syscall_epilogue(name
);
4040 #ifdef TARGET_NR_tkill
4042 print_tkill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4043 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4044 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4046 print_syscall_prologue(name
);
4047 print_raw_param("%d", arg0
, 0);
4048 print_signal(arg1
, 1);
4049 print_syscall_epilogue(name
);
4053 #ifdef TARGET_NR_tgkill
4055 print_tgkill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4056 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4057 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4059 print_syscall_prologue(name
);
4060 print_raw_param("%d", arg0
, 0);
4061 print_raw_param("%d", arg1
, 0);
4062 print_signal(arg2
, 1);
4063 print_syscall_epilogue(name
);
4067 #if defined(TARGET_NR_pread64) || defined(TARGET_NR_pwrite64)
4069 print_pread64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4070 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4071 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4073 if (regpairs_aligned(cpu_env
, TARGET_NR_pread64
)) {
4077 print_syscall_prologue(name
);
4078 print_raw_param("%d", arg0
, 0);
4079 print_pointer(arg1
, 0);
4080 print_raw_param("%d", arg2
, 0);
4081 print_raw_param("%" PRIu64
, target_offset64(arg3
, arg4
), 1);
4082 print_syscall_epilogue(name
);
4086 #ifdef TARGET_NR_statx
4088 print_statx(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4089 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4090 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4092 print_syscall_prologue(name
);
4093 print_at_dirfd(arg0
, 0);
4094 print_string(arg1
, 0);
4095 print_flags(statx_flags
, arg2
, 0);
4096 print_flags(statx_mask
, arg3
, 0);
4097 print_pointer(arg4
, 1);
4098 print_syscall_epilogue(name
);
4102 #ifdef TARGET_NR_ioctl
4104 print_ioctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4105 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4106 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4108 print_syscall_prologue(name
);
4109 print_raw_param("%d", arg0
, 0);
4111 const IOCTLEntry
*ie
;
4112 const argtype
*arg_type
;
4116 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
4117 if (ie
->target_cmd
== arg1
) {
4122 if (ie
->target_cmd
== 0) {
4123 print_raw_param("%#x", arg1
, 0);
4124 print_raw_param("%#x", arg2
, 1);
4126 qemu_log("%s", ie
->name
);
4127 arg_type
= ie
->arg_type
;
4129 if (arg_type
[0] != TYPE_NULL
) {
4132 switch (arg_type
[0]) {
4134 print_pointer(arg2
, 1);
4139 print_raw_param("%d", arg2
, 1);
4142 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
4145 print_raw_param(TARGET_ABI_FMT_lu
, arg2
, 1);
4148 switch (ie
->access
) {
4150 print_pointer(arg2
, 1);
4155 target_size
= thunk_type_size(arg_type
, 0);
4156 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
4158 thunk_print(argptr
, arg_type
);
4159 unlock_user(argptr
, arg2
, target_size
);
4161 print_pointer(arg2
, 1);
4167 g_assert_not_reached();
4171 print_syscall_epilogue(name
);
4176 * An array of all of the syscalls we know about
4179 static const struct syscallname scnames
[] = {
4180 #include "strace.list"
4183 static int nsyscalls
= ARRAY_SIZE(scnames
);
4186 * The public interface to this module.
4189 print_syscall(CPUArchState
*cpu_env
, int num
,
4190 abi_long arg1
, abi_long arg2
, abi_long arg3
,
4191 abi_long arg4
, abi_long arg5
, abi_long arg6
)
4195 const char *format
= "%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
4196 TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
4197 TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")";
4199 f
= qemu_log_trylock();
4203 fprintf(f
, "%d ", getpid());
4205 for (i
= 0; i
< nsyscalls
; i
++) {
4206 if (scnames
[i
].nr
== num
) {
4207 if (scnames
[i
].call
!= NULL
) {
4208 scnames
[i
].call(cpu_env
, &scnames
[i
], arg1
, arg2
, arg3
,
4211 /* XXX: this format system is broken because it uses
4212 host types and host pointers for strings */
4213 if (scnames
[i
].format
!= NULL
) {
4214 format
= scnames
[i
].format
;
4216 fprintf(f
, format
, scnames
[i
].name
, arg1
, arg2
,
4217 arg3
, arg4
, arg5
, arg6
);
4223 fprintf(f
, "Unknown syscall %d\n", num
);
4229 print_syscall_ret(CPUArchState
*cpu_env
, int num
, abi_long ret
,
4230 abi_long arg1
, abi_long arg2
, abi_long arg3
,
4231 abi_long arg4
, abi_long arg5
, abi_long arg6
)
4236 f
= qemu_log_trylock();
4241 for (i
= 0; i
< nsyscalls
; i
++) {
4242 if (scnames
[i
].nr
== num
) {
4243 if (scnames
[i
].result
!= NULL
) {
4244 scnames
[i
].result(cpu_env
, &scnames
[i
], ret
,
4248 if (!print_syscall_err(ret
)) {
4249 fprintf(f
, TARGET_ABI_FMT_ld
, ret
);
4259 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
4261 /* Print the strace output for a signal being taken:
4262 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
4266 f
= qemu_log_trylock();
4272 print_signal(target_signum
, 1);
4274 print_siginfo(tinfo
);
4275 fprintf(f
, " ---\n");