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>
17 #include <linux/openat2.h>
21 #include "user-internals.h"
23 #include "signal-common.h"
24 #include "target_mman.h"
30 void (*call
)(CPUArchState
*, const struct syscallname
*,
31 abi_long
, abi_long
, abi_long
,
32 abi_long
, abi_long
, abi_long
);
33 void (*result
)(CPUArchState
*, const struct syscallname
*, abi_long
,
34 abi_long
, abi_long
, abi_long
,
35 abi_long
, abi_long
, abi_long
);
39 * It is possible that target doesn't have syscall that uses
40 * following flags but we don't want the compiler to warn
41 * us about them being unused. Same applies to utility print
42 * functions. It is ok to keep them while not used.
44 #define UNUSED __attribute__ ((unused))
47 * Structure used to translate flag values into strings. This is
48 * similar that is in the actual strace tool.
51 abi_long f_value
; /* flag */
52 abi_long f_mask
; /* mask */
53 const char *f_string
; /* stringified flag */
56 /* No 'struct flags' element should have a zero mask. */
57 #define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }
59 /* common flags for all architectures */
60 #define FLAG_GENERIC_MASK(V, M) FLAG_BASIC(V, M, #V)
61 #define FLAG_GENERIC(V) FLAG_BASIC(V, V, #V)
62 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
63 #define FLAG_TARGET_MASK(V, M) FLAG_BASIC(TARGET_##V, TARGET_##M, #V)
64 #define FLAG_TARGET(V) FLAG_BASIC(TARGET_##V, TARGET_##V, #V)
65 /* end of flags array */
66 #define FLAG_END { 0, 0, NULL }
68 /* Structure used to translate enumerated values into strings */
70 abi_long e_value
; /* enum value */
71 const char *e_string
; /* stringified enum */
74 /* common enums for all architectures */
75 #define ENUM_GENERIC(name) { name, #name }
76 /* target specific enums */
77 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
78 /* end of enums array */
79 #define ENUM_END { 0, NULL }
81 UNUSED
static const char *get_comma(int);
82 UNUSED
static void print_pointer(abi_long
, int);
83 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
84 UNUSED
static void print_enums(const struct enums
*, abi_long
, int);
85 UNUSED
static void print_at_dirfd(abi_long
, int);
86 UNUSED
static void print_file_mode(abi_long
, int);
87 UNUSED
static void print_open_flags(abi_long
, int);
88 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
89 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
90 UNUSED
static void print_string(abi_long
, int);
91 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
92 UNUSED
static void print_raw_param(const char *, abi_long
, int);
93 UNUSED
static void print_raw_param64(const char *, long long, int last
);
94 UNUSED
static void print_timeval(abi_ulong
, int);
95 UNUSED
static void print_timespec(abi_ulong
, int);
96 UNUSED
static void print_timespec64(abi_ulong
, int);
97 UNUSED
static void print_timezone(abi_ulong
, int);
98 UNUSED
static void print_itimerval(abi_ulong
, int);
99 UNUSED
static void print_number(abi_long
, int);
100 UNUSED
static void print_signal(abi_ulong
, int);
101 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
102 UNUSED
static void print_socket_domain(int domain
);
103 UNUSED
static void print_socket_type(int type
);
104 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
110 print_ipc_cmd(int cmd
)
112 #define output_cmd(val) \
120 /* General IPC commands */
121 output_cmd( IPC_RMID
);
122 output_cmd( IPC_SET
);
123 output_cmd( IPC_STAT
);
124 output_cmd( IPC_INFO
);
125 /* msgctl() commands */
126 output_cmd( MSG_STAT
);
127 output_cmd( MSG_INFO
);
128 /* shmctl() commands */
129 output_cmd( SHM_LOCK
);
130 output_cmd( SHM_UNLOCK
);
131 output_cmd( SHM_STAT
);
132 output_cmd( SHM_INFO
);
133 /* semctl() commands */
134 output_cmd( GETPID
);
135 output_cmd( GETVAL
);
136 output_cmd( GETALL
);
137 output_cmd( GETNCNT
);
138 output_cmd( GETZCNT
);
139 output_cmd( SETVAL
);
140 output_cmd( SETALL
);
141 output_cmd( SEM_STAT
);
142 output_cmd( SEM_INFO
);
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
);
149 output_cmd( IPC_RMID
);
150 output_cmd( IPC_RMID
);
151 output_cmd( IPC_RMID
);
153 /* Some value we don't recognize */
157 static const char * const target_signal_name
[] = {
158 #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig,
160 #undef MAKE_SIG_ENTRY
164 print_signal(abi_ulong arg
, int last
)
166 const char *signal_name
= NULL
;
168 if (arg
< ARRAY_SIZE(target_signal_name
)) {
169 signal_name
= target_signal_name
[arg
];
172 if (signal_name
== NULL
) {
173 print_raw_param("%ld", arg
, last
);
176 qemu_log("%s%s", signal_name
, get_comma(last
));
179 static void print_si_code(int arg
)
181 const char *codename
= NULL
;
185 codename
= "SI_USER";
188 codename
= "SI_KERNEL";
191 codename
= "SI_QUEUE";
194 codename
= "SI_TIMER";
197 codename
= "SI_MESGQ";
200 codename
= "SI_ASYNCIO";
203 codename
= "SI_SIGIO";
206 codename
= "SI_TKILL";
212 qemu_log("%s", codename
);
215 static void get_target_siginfo(target_siginfo_t
*tinfo
,
216 const target_siginfo_t
*info
)
225 __get_user(sig
, &info
->si_signo
);
226 __get_user(si_errno
, &tinfo
->si_errno
);
227 __get_user(si_code
, &info
->si_code
);
229 tinfo
->si_signo
= sig
;
230 tinfo
->si_errno
= si_errno
;
231 tinfo
->si_code
= si_code
;
233 /* Ensure we don't leak random junk to the guest later */
234 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
236 /* This is awkward, because we have to use a combination of
237 * the si_code and si_signo to figure out which of the union's
238 * members are valid. (Within the host kernel it is always possible
239 * to tell, but the kernel carefully avoids giving userspace the
240 * high 16 bits of si_code, so we don't have the information to
241 * do this the easy way...) We therefore make our best guess,
242 * bearing in mind that a guest can spoof most of the si_codes
243 * via rt_sigqueueinfo() if it likes.
245 * Once we have made our guess, we record it in the top 16 bits of
246 * the si_code, so that print_siginfo() later can use it.
247 * print_siginfo() will strip these top bits out before printing
255 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
256 * These are the only unspoofable si_code values.
258 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
259 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
260 si_type
= QEMU_SI_KILL
;
263 /* Everything else is spoofable. Make best guess based on signal */
266 __get_user(tinfo
->_sifields
._sigchld
._pid
,
267 &info
->_sifields
._sigchld
._pid
);
268 __get_user(tinfo
->_sifields
._sigchld
._uid
,
269 &info
->_sifields
._sigchld
._uid
);
270 __get_user(tinfo
->_sifields
._sigchld
._status
,
271 &info
->_sifields
._sigchld
._status
);
272 __get_user(tinfo
->_sifields
._sigchld
._utime
,
273 &info
->_sifields
._sigchld
._utime
);
274 __get_user(tinfo
->_sifields
._sigchld
._stime
,
275 &info
->_sifields
._sigchld
._stime
);
276 si_type
= QEMU_SI_CHLD
;
279 __get_user(tinfo
->_sifields
._sigpoll
._band
,
280 &info
->_sifields
._sigpoll
._band
);
281 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
282 &info
->_sifields
._sigpoll
._fd
);
283 si_type
= QEMU_SI_POLL
;
286 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
287 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
288 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
289 /* XXX: potential problem if 64 bit */
290 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
291 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
293 si_type
= QEMU_SI_RT
;
299 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
302 static void print_siginfo(const target_siginfo_t
*tinfo
)
304 /* Print a target_siginfo_t in the format desired for printing
305 * signals being taken. We assume the target_siginfo_t is in the
306 * internal form where the top 16 bits of si_code indicate which
307 * part of the union is valid, rather than in the guest-visible
308 * form where the bottom 16 bits are sign-extended into the top 16.
310 int si_type
= extract32(tinfo
->si_code
, 16, 16);
311 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
313 qemu_log("{si_signo=");
314 print_signal(tinfo
->si_signo
, 1);
315 qemu_log(", si_code=");
316 print_si_code(si_code
);
320 qemu_log(", si_pid=%u, si_uid=%u",
321 (unsigned int)tinfo
->_sifields
._kill
._pid
,
322 (unsigned int)tinfo
->_sifields
._kill
._uid
);
325 qemu_log(", si_timer1=%u, si_timer2=%u",
326 tinfo
->_sifields
._timer
._timer1
,
327 tinfo
->_sifields
._timer
._timer2
);
330 qemu_log(", si_band=%d, si_fd=%d",
331 tinfo
->_sifields
._sigpoll
._band
,
332 tinfo
->_sifields
._sigpoll
._fd
);
335 qemu_log(", si_addr=");
336 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
339 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
340 ", si_utime=" TARGET_ABI_FMT_ld
341 ", si_stime=" TARGET_ABI_FMT_ld
,
342 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
343 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
344 tinfo
->_sifields
._sigchld
._status
,
345 tinfo
->_sifields
._sigchld
._utime
,
346 tinfo
->_sifields
._sigchld
._stime
);
349 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
350 (unsigned int)tinfo
->_sifields
._rt
._pid
,
351 (unsigned int)tinfo
->_sifields
._rt
._uid
,
352 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
355 g_assert_not_reached();
361 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
363 struct target_sockaddr
*sa
;
367 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
369 sa_family
= tswap16(sa
->sa_family
);
372 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
373 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
374 for (i
= 0; i
< addrlen
-
375 offsetof(struct target_sockaddr_un
, sun_path
) &&
376 un
->sun_path
[i
]; i
++) {
377 qemu_log("%c", un
->sun_path
[i
]);
383 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
384 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
385 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
386 ntohs(in
->sin_port
));
387 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
388 c
[0], c
[1], c
[2], c
[3]);
393 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
394 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
395 qemu_log("{sll_family=AF_PACKET,"
396 "sll_protocol=htons(0x%04x),if%d,pkttype=",
397 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
398 switch (ll
->sll_pkttype
) {
400 qemu_log("PACKET_HOST");
402 case PACKET_BROADCAST
:
403 qemu_log("PACKET_BROADCAST");
405 case PACKET_MULTICAST
:
406 qemu_log("PACKET_MULTICAST");
408 case PACKET_OTHERHOST
:
409 qemu_log("PACKET_OTHERHOST");
411 case PACKET_OUTGOING
:
412 qemu_log("PACKET_OUTGOING");
415 qemu_log("%d", ll
->sll_pkttype
);
418 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
419 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
424 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
425 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u},",
426 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
430 qemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
431 for (i
= 0; i
< 13; i
++) {
432 qemu_log("%02x, ", sa
->sa_data
[i
]);
434 qemu_log("%02x}", sa
->sa_data
[i
]);
438 unlock_user(sa
, addr
, 0);
440 print_pointer(addr
, 0);
442 qemu_log(TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
446 print_socket_domain(int domain
)
456 qemu_log("PF_NETLINK");
459 qemu_log("PF_PACKET");
462 qemu_log("%d", domain
);
468 print_socket_type(int type
)
470 switch (type
& TARGET_SOCK_TYPE_MASK
) {
471 case TARGET_SOCK_DGRAM
:
472 qemu_log("SOCK_DGRAM");
474 case TARGET_SOCK_STREAM
:
475 qemu_log("SOCK_STREAM");
477 case TARGET_SOCK_RAW
:
478 qemu_log("SOCK_RAW");
480 case TARGET_SOCK_RDM
:
481 qemu_log("SOCK_RDM");
483 case TARGET_SOCK_SEQPACKET
:
484 qemu_log("SOCK_SEQPACKET");
486 case TARGET_SOCK_PACKET
:
487 qemu_log("SOCK_PACKET");
490 if (type
& TARGET_SOCK_CLOEXEC
) {
491 qemu_log("|SOCK_CLOEXEC");
493 if (type
& TARGET_SOCK_NONBLOCK
) {
494 qemu_log("|SOCK_NONBLOCK");
499 print_socket_protocol(int domain
, int type
, int protocol
)
501 if (domain
== AF_PACKET
||
502 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
505 qemu_log("ETH_P_ALL");
508 qemu_log("%d", protocol
);
513 if (domain
== PF_NETLINK
) {
516 qemu_log("NETLINK_ROUTE");
519 qemu_log("NETLINK_UNUSED");
521 case NETLINK_USERSOCK
:
522 qemu_log("NETLINK_USERSOCK");
524 case NETLINK_FIREWALL
:
525 qemu_log("NETLINK_FIREWALL");
527 case NETLINK_SOCK_DIAG
:
528 qemu_log("NETLINK_SOCK_DIAG");
531 qemu_log("NETLINK_NFLOG");
534 qemu_log("NETLINK_XFRM");
536 case NETLINK_SELINUX
:
537 qemu_log("NETLINK_SELINUX");
540 qemu_log("NETLINK_ISCSI");
543 qemu_log("NETLINK_AUDIT");
545 case NETLINK_FIB_LOOKUP
:
546 qemu_log("NETLINK_FIB_LOOKUP");
548 case NETLINK_CONNECTOR
:
549 qemu_log("NETLINK_CONNECTOR");
551 case NETLINK_NETFILTER
:
552 qemu_log("NETLINK_NETFILTER");
555 qemu_log("NETLINK_IP6_FW");
557 case NETLINK_DNRTMSG
:
558 qemu_log("NETLINK_DNRTMSG");
560 case NETLINK_KOBJECT_UEVENT
:
561 qemu_log("NETLINK_KOBJECT_UEVENT");
563 case NETLINK_GENERIC
:
564 qemu_log("NETLINK_GENERIC");
566 case NETLINK_SCSITRANSPORT
:
567 qemu_log("NETLINK_SCSITRANSPORT");
569 case NETLINK_ECRYPTFS
:
570 qemu_log("NETLINK_ECRYPTFS");
573 qemu_log("NETLINK_RDMA");
576 qemu_log("NETLINK_CRYPTO");
579 qemu_log("NETLINK_SMC");
582 qemu_log("%d", protocol
);
590 qemu_log("IPPROTO_IP");
593 qemu_log("IPPROTO_TCP");
596 qemu_log("IPPROTO_UDP");
599 qemu_log("IPPROTO_RAW");
602 qemu_log("%d", protocol
);
608 #ifdef TARGET_NR__newselect
610 print_fdset(int n
, abi_ulong target_fds_addr
)
616 if( target_fds_addr
) {
617 abi_long
*target_fds
;
619 target_fds
= lock_user(VERIFY_READ
,
621 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
627 for (i
=n
; i
>=0; i
--) {
628 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >>
629 (i
& (TARGET_ABI_BITS
- 1))) & 1) {
630 qemu_log("%s%d", get_comma(first
), i
);
634 unlock_user(target_fds
, target_fds_addr
, 0);
641 * Sysycall specific output functions
645 #ifdef TARGET_NR__newselect
647 print_newselect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
648 abi_long arg1
, abi_long arg2
, abi_long arg3
,
649 abi_long arg4
, abi_long arg5
, abi_long arg6
)
651 print_syscall_prologue(name
);
652 print_fdset(arg1
, arg2
);
654 print_fdset(arg1
, arg3
);
656 print_fdset(arg1
, arg4
);
658 print_timeval(arg5
, 1);
659 print_syscall_epilogue(name
);
664 print_semctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
665 abi_long arg1
, abi_long arg2
, abi_long arg3
,
666 abi_long arg4
, abi_long arg5
, abi_long arg6
)
668 qemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
669 name
->name
, arg1
, arg2
);
671 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
675 print_shmat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
676 abi_long arg0
, abi_long arg1
, abi_long arg2
,
677 abi_long arg3
, abi_long arg4
, abi_long arg5
)
679 static const struct flags shmat_flags
[] = {
680 FLAG_GENERIC(SHM_RND
),
681 FLAG_GENERIC(SHM_REMAP
),
682 FLAG_GENERIC(SHM_RDONLY
),
683 FLAG_GENERIC(SHM_EXEC
),
687 print_syscall_prologue(name
);
688 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
689 print_pointer(arg1
, 0);
690 print_flags(shmat_flags
, arg2
, 1);
691 print_syscall_epilogue(name
);
696 print_ipc(CPUArchState
*cpu_env
, const struct syscallname
*name
,
697 abi_long arg1
, abi_long arg2
, abi_long arg3
,
698 abi_long arg4
, abi_long arg5
, abi_long arg6
)
702 print_semctl(cpu_env
, &(const struct syscallname
){ .name
= "semctl" },
703 arg2
, arg3
, arg4
, arg5
, 0, 0);
706 print_shmat(cpu_env
, &(const struct syscallname
){ .name
= "shmat" },
707 arg2
, arg5
, arg3
, 0, 0, 0);
711 TARGET_ABI_FMT_ld
","
712 TARGET_ABI_FMT_ld
","
713 TARGET_ABI_FMT_ld
","
716 name
->name
, arg1
, arg2
, arg3
, arg4
);
722 * Variants for the return value output function
726 print_syscall_err(abi_long ret
)
732 errstr
= target_strerror(-ret
);
734 qemu_log("-1 errno=%d (%s)", (int)-ret
, errstr
);
742 print_syscall_ret_addr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
743 abi_long ret
, abi_long arg0
, abi_long arg1
,
744 abi_long arg2
, abi_long arg3
, abi_long arg4
,
747 if (!print_syscall_err(ret
)) {
748 qemu_log("0x" TARGET_ABI_FMT_lx
, ret
);
753 #if 0 /* currently unused */
755 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
757 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
761 #ifdef TARGET_NR__newselect
763 print_syscall_ret_newselect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
764 abi_long ret
, abi_long arg0
, abi_long arg1
,
765 abi_long arg2
, abi_long arg3
, abi_long arg4
,
768 if (!print_syscall_err(ret
)) {
769 qemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
770 print_fdset(arg0
, arg1
);
772 print_fdset(arg0
, arg2
);
774 print_fdset(arg0
, arg3
);
776 print_timeval(arg4
, 1);
784 /* special meanings of adjtimex()' non-negative return values */
785 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
786 #define TARGET_TIME_INS 1 /* insert leap second */
787 #define TARGET_TIME_DEL 2 /* delete leap second */
788 #define TARGET_TIME_OOP 3 /* leap second in progress */
789 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
790 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
791 #ifdef TARGET_NR_adjtimex
793 print_syscall_ret_adjtimex(CPUArchState
*cpu_env
, const struct syscallname
*name
,
794 abi_long ret
, abi_long arg0
, abi_long arg1
,
795 abi_long arg2
, abi_long arg3
, abi_long arg4
,
798 if (!print_syscall_err(ret
)) {
799 qemu_log(TARGET_ABI_FMT_ld
, ret
);
802 qemu_log(" TIME_OK (clock synchronized, no leap second)");
804 case TARGET_TIME_INS
:
805 qemu_log(" TIME_INS (insert leap second)");
807 case TARGET_TIME_DEL
:
808 qemu_log(" TIME_DEL (delete leap second)");
810 case TARGET_TIME_OOP
:
811 qemu_log(" TIME_OOP (leap second in progress)");
813 case TARGET_TIME_WAIT
:
814 qemu_log(" TIME_WAIT (leap second has occurred)");
816 case TARGET_TIME_ERROR
:
817 qemu_log(" TIME_ERROR (clock not synchronized)");
826 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
828 print_syscall_ret_clock_gettime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
829 abi_long ret
, abi_long arg0
, abi_long arg1
,
830 abi_long arg2
, abi_long arg3
, abi_long arg4
,
833 if (!print_syscall_err(ret
)) {
834 qemu_log(TARGET_ABI_FMT_ld
, ret
);
836 print_timespec(arg1
, 1);
842 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
845 #if defined(TARGET_NR_clock_gettime64)
847 print_syscall_ret_clock_gettime64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
848 abi_long ret
, abi_long arg0
, abi_long arg1
,
849 abi_long arg2
, abi_long arg3
, abi_long arg4
,
852 if (!print_syscall_err(ret
)) {
853 qemu_log(TARGET_ABI_FMT_ld
, ret
);
855 print_timespec64(arg1
, 1);
863 #ifdef TARGET_NR_gettimeofday
865 print_syscall_ret_gettimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
866 abi_long ret
, abi_long arg0
, abi_long arg1
,
867 abi_long arg2
, abi_long arg3
, abi_long arg4
,
870 if (!print_syscall_err(ret
)) {
871 qemu_log(TARGET_ABI_FMT_ld
, ret
);
873 print_timeval(arg0
, 0);
874 print_timezone(arg1
, 1);
882 #ifdef TARGET_NR_getitimer
884 print_syscall_ret_getitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
885 abi_long ret
, abi_long arg0
, abi_long arg1
,
886 abi_long arg2
, abi_long arg3
, abi_long arg4
,
889 if (!print_syscall_err(ret
)) {
890 qemu_log(TARGET_ABI_FMT_ld
, ret
);
892 print_itimerval(arg1
, 1);
901 #ifdef TARGET_NR_getitimer
903 print_syscall_ret_setitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
904 abi_long ret
, abi_long arg0
, abi_long arg1
,
905 abi_long arg2
, abi_long arg3
, abi_long arg4
,
908 if (!print_syscall_err(ret
)) {
909 qemu_log(TARGET_ABI_FMT_ld
, ret
);
910 qemu_log(" (old_value = ");
911 print_itimerval(arg2
, 1);
919 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
920 || defined(TARGGET_NR_flistxattr)
922 print_syscall_ret_listxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
923 abi_long ret
, abi_long arg0
, abi_long arg1
,
924 abi_long arg2
, abi_long arg3
, abi_long arg4
,
927 if (!print_syscall_err(ret
)) {
928 qemu_log(TARGET_ABI_FMT_ld
, ret
);
929 qemu_log(" (list = ");
931 abi_long attr
= arg1
;
936 print_string(attr
, 1);
937 ret
-= target_strlen(attr
) + 1;
938 attr
+= target_strlen(attr
) + 1;
948 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
949 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
952 #ifdef TARGET_NR_ioctl
954 print_syscall_ret_ioctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
955 abi_long ret
, abi_long arg0
, abi_long arg1
,
956 abi_long arg2
, abi_long arg3
, abi_long arg4
,
959 if (!print_syscall_err(ret
)) {
960 qemu_log(TARGET_ABI_FMT_ld
, ret
);
962 const IOCTLEntry
*ie
;
963 const argtype
*arg_type
;
967 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
968 if (ie
->target_cmd
== arg1
) {
973 if (ie
->target_cmd
== arg1
&&
974 (ie
->access
== IOC_R
|| ie
->access
== IOC_RW
)) {
975 arg_type
= ie
->arg_type
;
978 target_size
= thunk_type_size(arg_type
, 0);
979 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
981 thunk_print(argptr
, arg_type
);
982 unlock_user(argptr
, arg2
, target_size
);
984 print_pointer(arg2
, 1);
993 UNUSED
static const struct flags access_flags
[] = {
994 FLAG_GENERIC_MASK(F_OK
, R_OK
| W_OK
| X_OK
),
1001 UNUSED
static const struct flags at_file_flags
[] = {
1003 FLAG_GENERIC(AT_EACCESS
),
1005 #ifdef AT_SYMLINK_NOFOLLOW
1006 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1011 UNUSED
static const struct flags unlinkat_flags
[] = {
1013 FLAG_GENERIC(AT_REMOVEDIR
),
1018 UNUSED
static const struct flags mode_flags
[] = {
1019 FLAG_GENERIC(S_IFSOCK
),
1020 FLAG_GENERIC(S_IFLNK
),
1021 FLAG_GENERIC(S_IFREG
),
1022 FLAG_GENERIC(S_IFBLK
),
1023 FLAG_GENERIC(S_IFDIR
),
1024 FLAG_GENERIC(S_IFCHR
),
1025 FLAG_GENERIC(S_IFIFO
),
1029 UNUSED
static const struct flags open_access_flags
[] = {
1030 FLAG_TARGET_MASK(O_RDONLY
, O_ACCMODE
),
1031 FLAG_TARGET_MASK(O_WRONLY
, O_ACCMODE
),
1032 FLAG_TARGET_MASK(O_RDWR
, O_ACCMODE
),
1036 UNUSED
static const struct flags open_flags
[] = {
1037 FLAG_TARGET(O_APPEND
),
1038 FLAG_TARGET(O_CREAT
),
1039 FLAG_TARGET(O_DIRECTORY
),
1040 FLAG_TARGET(O_EXCL
),
1041 #if TARGET_O_LARGEFILE != 0
1042 FLAG_TARGET(O_LARGEFILE
),
1044 FLAG_TARGET(O_NOCTTY
),
1045 FLAG_TARGET(O_NOFOLLOW
),
1046 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
1047 FLAG_TARGET(O_DSYNC
),
1048 FLAG_TARGET(__O_SYNC
),
1049 FLAG_TARGET(O_TRUNC
),
1051 FLAG_TARGET(O_DIRECT
),
1054 FLAG_TARGET(O_NOATIME
),
1057 FLAG_TARGET(O_CLOEXEC
),
1060 FLAG_TARGET(O_PATH
),
1063 FLAG_TARGET(O_TMPFILE
),
1064 FLAG_TARGET(__O_TMPFILE
),
1069 UNUSED
static const struct flags openat2_resolve_flags
[] = {
1070 #ifdef HAVE_OPENAT2_H
1071 FLAG_GENERIC(RESOLVE_NO_XDEV
),
1072 FLAG_GENERIC(RESOLVE_NO_MAGICLINKS
),
1073 FLAG_GENERIC(RESOLVE_NO_SYMLINKS
),
1074 FLAG_GENERIC(RESOLVE_BENEATH
),
1075 FLAG_GENERIC(RESOLVE_IN_ROOT
),
1076 FLAG_GENERIC(RESOLVE_CACHED
),
1081 UNUSED
static const struct flags mount_flags
[] = {
1083 FLAG_GENERIC(MS_BIND
),
1086 FLAG_GENERIC(MS_DIRSYNC
),
1088 FLAG_GENERIC(MS_MANDLOCK
),
1090 FLAG_GENERIC(MS_MOVE
),
1092 FLAG_GENERIC(MS_NOATIME
),
1093 FLAG_GENERIC(MS_NODEV
),
1094 FLAG_GENERIC(MS_NODIRATIME
),
1095 FLAG_GENERIC(MS_NOEXEC
),
1096 FLAG_GENERIC(MS_NOSUID
),
1097 FLAG_GENERIC(MS_RDONLY
),
1099 FLAG_GENERIC(MS_RELATIME
),
1101 FLAG_GENERIC(MS_REMOUNT
),
1102 FLAG_GENERIC(MS_SYNCHRONOUS
),
1106 UNUSED
static const struct flags umount2_flags
[] = {
1108 FLAG_GENERIC(MNT_FORCE
),
1111 FLAG_GENERIC(MNT_DETACH
),
1114 FLAG_GENERIC(MNT_EXPIRE
),
1119 UNUSED
static const struct flags mmap_prot_flags
[] = {
1120 FLAG_GENERIC_MASK(PROT_NONE
, PROT_READ
| PROT_WRITE
| PROT_EXEC
),
1121 FLAG_GENERIC(PROT_EXEC
),
1122 FLAG_GENERIC(PROT_READ
),
1123 FLAG_GENERIC(PROT_WRITE
),
1124 FLAG_TARGET(PROT_SEM
),
1125 FLAG_GENERIC(PROT_GROWSDOWN
),
1126 FLAG_GENERIC(PROT_GROWSUP
),
1130 UNUSED
static const struct flags mmap_flags
[] = {
1131 FLAG_TARGET_MASK(MAP_SHARED
, MAP_TYPE
),
1132 FLAG_TARGET_MASK(MAP_PRIVATE
, MAP_TYPE
),
1133 FLAG_TARGET_MASK(MAP_SHARED_VALIDATE
, MAP_TYPE
),
1134 FLAG_TARGET(MAP_ANONYMOUS
),
1135 FLAG_TARGET(MAP_DENYWRITE
),
1136 FLAG_TARGET(MAP_EXECUTABLE
),
1137 FLAG_TARGET(MAP_FIXED
),
1138 FLAG_TARGET(MAP_FIXED_NOREPLACE
),
1139 FLAG_TARGET(MAP_GROWSDOWN
),
1140 FLAG_TARGET(MAP_HUGETLB
),
1141 FLAG_TARGET(MAP_LOCKED
),
1142 FLAG_TARGET(MAP_NONBLOCK
),
1143 FLAG_TARGET(MAP_NORESERVE
),
1144 FLAG_TARGET(MAP_POPULATE
),
1145 FLAG_TARGET(MAP_STACK
),
1146 FLAG_TARGET(MAP_SYNC
),
1147 #if TARGET_MAP_UNINITIALIZED != 0
1148 FLAG_TARGET(MAP_UNINITIALIZED
),
1154 # define CLONE_PIDFD 0x00001000
1157 UNUSED
static const struct flags clone_flags
[] = {
1158 FLAG_GENERIC(CLONE_VM
),
1159 FLAG_GENERIC(CLONE_FS
),
1160 FLAG_GENERIC(CLONE_FILES
),
1161 FLAG_GENERIC(CLONE_SIGHAND
),
1162 FLAG_GENERIC(CLONE_PIDFD
),
1163 FLAG_GENERIC(CLONE_PTRACE
),
1164 FLAG_GENERIC(CLONE_VFORK
),
1165 FLAG_GENERIC(CLONE_PARENT
),
1166 FLAG_GENERIC(CLONE_THREAD
),
1167 FLAG_GENERIC(CLONE_NEWNS
),
1168 FLAG_GENERIC(CLONE_SYSVSEM
),
1169 FLAG_GENERIC(CLONE_SETTLS
),
1170 FLAG_GENERIC(CLONE_PARENT_SETTID
),
1171 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
1172 FLAG_GENERIC(CLONE_DETACHED
),
1173 FLAG_GENERIC(CLONE_UNTRACED
),
1174 FLAG_GENERIC(CLONE_CHILD_SETTID
),
1175 #if defined(CLONE_NEWUTS)
1176 FLAG_GENERIC(CLONE_NEWUTS
),
1178 #if defined(CLONE_NEWIPC)
1179 FLAG_GENERIC(CLONE_NEWIPC
),
1181 #if defined(CLONE_NEWUSER)
1182 FLAG_GENERIC(CLONE_NEWUSER
),
1184 #if defined(CLONE_NEWPID)
1185 FLAG_GENERIC(CLONE_NEWPID
),
1187 #if defined(CLONE_NEWNET)
1188 FLAG_GENERIC(CLONE_NEWNET
),
1190 #if defined(CLONE_NEWCGROUP)
1191 FLAG_GENERIC(CLONE_NEWCGROUP
),
1193 #if defined(CLONE_NEWTIME)
1194 FLAG_GENERIC(CLONE_NEWTIME
),
1196 #if defined(CLONE_IO)
1197 FLAG_GENERIC(CLONE_IO
),
1202 UNUSED
static const struct flags execveat_flags
[] = {
1203 #ifdef AT_EMPTY_PATH
1204 FLAG_GENERIC(AT_EMPTY_PATH
),
1206 #ifdef AT_SYMLINK_NOFOLLOW
1207 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1212 UNUSED
static const struct flags msg_flags
[] = {
1214 FLAG_GENERIC(MSG_CONFIRM
),
1215 FLAG_GENERIC(MSG_DONTROUTE
),
1216 FLAG_GENERIC(MSG_DONTWAIT
),
1217 FLAG_GENERIC(MSG_EOR
),
1218 FLAG_GENERIC(MSG_MORE
),
1219 FLAG_GENERIC(MSG_NOSIGNAL
),
1220 FLAG_GENERIC(MSG_OOB
),
1222 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1223 FLAG_GENERIC(MSG_ERRQUEUE
),
1224 FLAG_GENERIC(MSG_PEEK
),
1225 FLAG_GENERIC(MSG_TRUNC
),
1226 FLAG_GENERIC(MSG_WAITALL
),
1228 FLAG_GENERIC(MSG_CTRUNC
),
1232 UNUSED
static const struct flags statx_flags
[] = {
1233 #ifdef AT_EMPTY_PATH
1234 FLAG_GENERIC(AT_EMPTY_PATH
),
1236 #ifdef AT_NO_AUTOMOUNT
1237 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1239 #ifdef AT_SYMLINK_NOFOLLOW
1240 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1242 #ifdef AT_STATX_SYNC_AS_STAT
1243 FLAG_GENERIC_MASK(AT_STATX_SYNC_AS_STAT
, AT_STATX_SYNC_TYPE
),
1245 #ifdef AT_STATX_FORCE_SYNC
1246 FLAG_GENERIC_MASK(AT_STATX_FORCE_SYNC
, AT_STATX_SYNC_TYPE
),
1248 #ifdef AT_STATX_DONT_SYNC
1249 FLAG_GENERIC_MASK(AT_STATX_DONT_SYNC
, AT_STATX_SYNC_TYPE
),
1254 UNUSED
static const struct flags statx_mask
[] = {
1255 /* This must come first, because it includes everything. */
1257 FLAG_GENERIC(STATX_ALL
),
1259 /* This must come second; it includes everything except STATX_BTIME. */
1260 #ifdef STATX_BASIC_STATS
1261 FLAG_GENERIC(STATX_BASIC_STATS
),
1264 FLAG_GENERIC(STATX_TYPE
),
1267 FLAG_GENERIC(STATX_MODE
),
1270 FLAG_GENERIC(STATX_NLINK
),
1273 FLAG_GENERIC(STATX_UID
),
1276 FLAG_GENERIC(STATX_GID
),
1279 FLAG_GENERIC(STATX_ATIME
),
1282 FLAG_GENERIC(STATX_MTIME
),
1285 FLAG_GENERIC(STATX_CTIME
),
1288 FLAG_GENERIC(STATX_INO
),
1291 FLAG_GENERIC(STATX_SIZE
),
1294 FLAG_GENERIC(STATX_BLOCKS
),
1297 FLAG_GENERIC(STATX_BTIME
),
1302 UNUSED
static const struct flags falloc_flags
[] = {
1303 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE
),
1304 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE
),
1305 #ifdef FALLOC_FL_NO_HIDE_STALE
1306 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE
),
1308 #ifdef FALLOC_FL_COLLAPSE_RANGE
1309 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE
),
1311 #ifdef FALLOC_FL_ZERO_RANGE
1312 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE
),
1314 #ifdef FALLOC_FL_INSERT_RANGE
1315 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE
),
1317 #ifdef FALLOC_FL_UNSHARE_RANGE
1318 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE
),
1322 UNUSED
static const struct flags termios_iflags
[] = {
1323 FLAG_TARGET(IGNBRK
),
1324 FLAG_TARGET(BRKINT
),
1325 FLAG_TARGET(IGNPAR
),
1326 FLAG_TARGET(PARMRK
),
1328 FLAG_TARGET(ISTRIP
),
1336 FLAG_TARGET(IMAXBEL
),
1341 UNUSED
static const struct flags termios_oflags
[] = {
1347 FLAG_TARGET(ONLRET
),
1353 UNUSED
static struct enums termios_oflags_NLDLY
[] = {
1359 UNUSED
static struct enums termios_oflags_CRDLY
[] = {
1367 UNUSED
static struct enums termios_oflags_TABDLY
[] = {
1375 UNUSED
static struct enums termios_oflags_VTDLY
[] = {
1381 UNUSED
static struct enums termios_oflags_FFDLY
[] = {
1387 UNUSED
static struct enums termios_oflags_BSDLY
[] = {
1393 UNUSED
static struct enums termios_cflags_CBAUD
[] = {
1408 ENUM_TARGET(B19200
),
1409 ENUM_TARGET(B38400
),
1410 ENUM_TARGET(B57600
),
1411 ENUM_TARGET(B115200
),
1412 ENUM_TARGET(B230400
),
1413 ENUM_TARGET(B460800
),
1417 UNUSED
static struct enums termios_cflags_CSIZE
[] = {
1425 UNUSED
static const struct flags termios_cflags
[] = {
1426 FLAG_TARGET(CSTOPB
),
1428 FLAG_TARGET(PARENB
),
1429 FLAG_TARGET(PARODD
),
1431 FLAG_TARGET(CLOCAL
),
1432 FLAG_TARGET(CRTSCTS
),
1436 UNUSED
static const struct flags termios_lflags
[] = {
1438 FLAG_TARGET(ICANON
),
1443 FLAG_TARGET(ECHONL
),
1444 FLAG_TARGET(NOFLSH
),
1445 FLAG_TARGET(TOSTOP
),
1446 FLAG_TARGET(ECHOCTL
),
1447 FLAG_TARGET(ECHOPRT
),
1448 FLAG_TARGET(ECHOKE
),
1449 FLAG_TARGET(FLUSHO
),
1450 FLAG_TARGET(PENDIN
),
1451 FLAG_TARGET(IEXTEN
),
1452 FLAG_TARGET(EXTPROC
),
1456 #ifdef TARGET_NR_mlockall
1457 static const struct flags mlockall_flags
[] = {
1458 FLAG_TARGET(MCL_CURRENT
),
1459 FLAG_TARGET(MCL_FUTURE
),
1461 FLAG_TARGET(MCL_ONFAULT
),
1467 /* IDs of the various system clocks */
1468 #define TARGET_CLOCK_REALTIME 0
1469 #define TARGET_CLOCK_MONOTONIC 1
1470 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1471 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1472 #define TARGET_CLOCK_MONOTONIC_RAW 4
1473 #define TARGET_CLOCK_REALTIME_COARSE 5
1474 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1475 #define TARGET_CLOCK_BOOTTIME 7
1476 #define TARGET_CLOCK_REALTIME_ALARM 8
1477 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1478 #define TARGET_CLOCK_SGI_CYCLE 10
1479 #define TARGET_CLOCK_TAI 11
1481 UNUSED
static struct enums clockids
[] = {
1482 ENUM_TARGET(CLOCK_REALTIME
),
1483 ENUM_TARGET(CLOCK_MONOTONIC
),
1484 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID
),
1485 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID
),
1486 ENUM_TARGET(CLOCK_MONOTONIC_RAW
),
1487 ENUM_TARGET(CLOCK_REALTIME_COARSE
),
1488 ENUM_TARGET(CLOCK_MONOTONIC_COARSE
),
1489 ENUM_TARGET(CLOCK_BOOTTIME
),
1490 ENUM_TARGET(CLOCK_REALTIME_ALARM
),
1491 ENUM_TARGET(CLOCK_BOOTTIME_ALARM
),
1492 ENUM_TARGET(CLOCK_SGI_CYCLE
),
1493 ENUM_TARGET(CLOCK_TAI
),
1497 UNUSED
static struct enums itimer_types
[] = {
1498 ENUM_GENERIC(ITIMER_REAL
),
1499 ENUM_GENERIC(ITIMER_VIRTUAL
),
1500 ENUM_GENERIC(ITIMER_PROF
),
1505 * print_xxx utility functions. These are used to print syscall
1506 * parameters in certain format. All of these have parameter
1507 * named 'last'. This parameter is used to add comma to output
1514 return ((last
) ? "" : ",");
1518 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1520 const char *sep
= "";
1523 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1524 if ((flags
& f
->f_mask
) == f
->f_value
) {
1525 qemu_log("%s%s", sep
, f
->f_string
);
1526 flags
&= ~f
->f_mask
;
1533 /* print rest of the flags as numeric */
1535 qemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1537 qemu_log("%s", get_comma(last
));
1540 /* no string version of flags found, print them in hex then */
1541 qemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1546 print_enums(const struct enums
*e
, abi_long enum_arg
, int last
)
1548 for (; e
->e_string
!= NULL
; e
++) {
1549 if (e
->e_value
== enum_arg
) {
1550 qemu_log("%s", e
->e_string
);
1555 if (e
->e_string
== NULL
) {
1556 qemu_log("%#x", (unsigned int)enum_arg
);
1559 qemu_log("%s", get_comma(last
));
1563 print_at_dirfd(abi_long dirfd
, int last
)
1566 if (dirfd
== AT_FDCWD
) {
1567 qemu_log("AT_FDCWD%s", get_comma(last
));
1571 qemu_log("%d%s", (int)dirfd
, get_comma(last
));
1575 print_file_mode(abi_long mode
, int last
)
1577 const char *sep
= "";
1578 const struct flags
*m
;
1581 qemu_log("000%s", get_comma(last
));
1585 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1586 if ((m
->f_value
& mode
) == m
->f_value
) {
1587 qemu_log("%s%s", m
->f_string
, sep
);
1589 mode
&= ~m
->f_value
;
1595 /* print rest of the mode as octal */
1597 qemu_log("%s%#o", sep
, (unsigned int)mode
);
1599 qemu_log("%s", get_comma(last
));
1603 print_open_flags(abi_long flags
, int last
)
1605 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1606 flags
&= ~TARGET_O_ACCMODE
;
1608 qemu_log("%s", get_comma(last
));
1612 print_flags(open_flags
, flags
, last
);
1616 print_syscall_prologue(const struct syscallname
*sc
)
1618 qemu_log("%s(", sc
->name
);
1623 print_syscall_epilogue(const struct syscallname
*sc
)
1630 print_string(abi_long addr
, int last
)
1634 if ((s
= lock_user_string(addr
)) != NULL
) {
1635 qemu_log("\"%s\"%s", s
, get_comma(last
));
1636 unlock_user(s
, addr
, 0);
1638 /* can't get string out of it, so print it as pointer */
1639 print_pointer(addr
, last
);
1643 #define MAX_PRINT_BUF 40
1645 print_buf(abi_long addr
, abi_long len
, int last
)
1650 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1653 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1654 if (isprint(s
[i
])) {
1655 qemu_log("%c", s
[i
]);
1657 qemu_log("\\%o", s
[i
]);
1667 unlock_user(s
, addr
, 0);
1669 print_pointer(addr
, last
);
1674 print_buf_len(abi_long addr
, abi_long len
, int last
)
1676 print_buf(addr
, len
, 0);
1677 print_raw_param(TARGET_ABI_FMT_ld
, len
, last
);
1681 * Prints out raw parameter using given format. Caller needs
1682 * to do byte swapping if needed.
1685 print_raw_param(const char *fmt
, abi_long param
, int last
)
1689 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1690 qemu_log(format
, param
);
1694 * Same as print_raw_param() but prints out raw 64-bit parameter.
1697 print_raw_param64(const char *fmt
, long long param
, int last
)
1701 (void)snprintf(format
, sizeof(format
), "%s%s", fmt
, get_comma(last
));
1702 qemu_log(format
, param
);
1707 print_pointer(abi_long p
, int last
)
1710 qemu_log("NULL%s", get_comma(last
));
1712 qemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1716 * Reads 32-bit (int) number from guest address space from
1717 * address 'addr' and prints it.
1720 print_number(abi_long addr
, int last
)
1723 qemu_log("NULL%s", get_comma(last
));
1727 get_user_s32(num
, addr
);
1728 qemu_log("[%d]%s", num
, get_comma(last
));
1733 print_timeval(abi_ulong tv_addr
, int last
)
1736 struct target_timeval
*tv
;
1738 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1740 print_pointer(tv_addr
, last
);
1743 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1744 ",tv_usec = " TARGET_ABI_FMT_ld
"}%s",
1745 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1746 unlock_user(tv
, tv_addr
, 0);
1748 qemu_log("NULL%s", get_comma(last
));
1752 print_timespec(abi_ulong ts_addr
, int last
)
1755 struct target_timespec
*ts
;
1757 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1759 print_pointer(ts_addr
, last
);
1762 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1763 ",tv_nsec = " TARGET_ABI_FMT_ld
"}%s",
1764 tswapal(ts
->tv_sec
), tswapal(ts
->tv_nsec
), get_comma(last
));
1765 unlock_user(ts
, ts_addr
, 0);
1767 qemu_log("NULL%s", get_comma(last
));
1772 print_timespec64(abi_ulong ts_addr
, int last
)
1775 struct target__kernel_timespec
*ts
;
1777 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1779 print_pointer(ts_addr
, last
);
1782 print_raw_param64("{tv_sec=%" PRId64
, tswap64(ts
->tv_sec
), 0);
1783 print_raw_param64("tv_nsec=%" PRId64
"}", tswap64(ts
->tv_nsec
), last
);
1784 unlock_user(ts
, ts_addr
, 0);
1786 qemu_log("NULL%s", get_comma(last
));
1791 print_timezone(abi_ulong tz_addr
, int last
)
1794 struct target_timezone
*tz
;
1796 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1798 print_pointer(tz_addr
, last
);
1801 qemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1802 tswap32(tz
->tz_dsttime
), get_comma(last
));
1803 unlock_user(tz
, tz_addr
, 0);
1805 qemu_log("NULL%s", get_comma(last
));
1810 print_itimerval(abi_ulong it_addr
, int last
)
1813 qemu_log("{it_interval=");
1814 print_timeval(it_addr
+
1815 offsetof(struct target_itimerval
, it_interval
), 0);
1816 qemu_log("it_value=");
1817 print_timeval(it_addr
+
1818 offsetof(struct target_itimerval
, it_value
), 0);
1819 qemu_log("}%s", get_comma(last
));
1821 qemu_log("NULL%s", get_comma(last
));
1826 print_termios(void *arg
)
1828 const struct target_termios
*target
= arg
;
1830 target_tcflag_t iflags
= tswap32(target
->c_iflag
);
1831 target_tcflag_t oflags
= tswap32(target
->c_oflag
);
1832 target_tcflag_t cflags
= tswap32(target
->c_cflag
);
1833 target_tcflag_t lflags
= tswap32(target
->c_lflag
);
1837 qemu_log("c_iflag = ");
1838 print_flags(termios_iflags
, iflags
, 0);
1840 qemu_log("c_oflag = ");
1841 target_tcflag_t oflags_clean
= oflags
& ~(TARGET_NLDLY
| TARGET_CRDLY
|
1842 TARGET_TABDLY
| TARGET_BSDLY
|
1843 TARGET_VTDLY
| TARGET_FFDLY
);
1844 print_flags(termios_oflags
, oflags_clean
, 0);
1845 if (oflags
& TARGET_NLDLY
) {
1846 print_enums(termios_oflags_NLDLY
, oflags
& TARGET_NLDLY
, 0);
1848 if (oflags
& TARGET_CRDLY
) {
1849 print_enums(termios_oflags_CRDLY
, oflags
& TARGET_CRDLY
, 0);
1851 if (oflags
& TARGET_TABDLY
) {
1852 print_enums(termios_oflags_TABDLY
, oflags
& TARGET_TABDLY
, 0);
1854 if (oflags
& TARGET_BSDLY
) {
1855 print_enums(termios_oflags_BSDLY
, oflags
& TARGET_BSDLY
, 0);
1857 if (oflags
& TARGET_VTDLY
) {
1858 print_enums(termios_oflags_VTDLY
, oflags
& TARGET_VTDLY
, 0);
1860 if (oflags
& TARGET_FFDLY
) {
1861 print_enums(termios_oflags_FFDLY
, oflags
& TARGET_FFDLY
, 0);
1864 qemu_log("c_cflag = ");
1865 if (cflags
& TARGET_CBAUD
) {
1866 print_enums(termios_cflags_CBAUD
, cflags
& TARGET_CBAUD
, 0);
1868 if (cflags
& TARGET_CSIZE
) {
1869 print_enums(termios_cflags_CSIZE
, cflags
& TARGET_CSIZE
, 0);
1871 target_tcflag_t cflags_clean
= cflags
& ~(TARGET_CBAUD
| TARGET_CSIZE
);
1872 print_flags(termios_cflags
, cflags_clean
, 0);
1874 qemu_log("c_lflag = ");
1875 print_flags(termios_lflags
, lflags
, 0);
1877 qemu_log("c_cc = ");
1878 qemu_log("\"%s\",", target
->c_cc
);
1880 qemu_log("c_line = ");
1881 print_raw_param("\'%c\'", target
->c_line
, 1);
1888 #ifdef TARGET_NR_accept
1890 print_accept(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1891 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1892 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1894 print_syscall_prologue(name
);
1895 print_raw_param("%d", arg0
, 0);
1896 print_pointer(arg1
, 0);
1897 print_number(arg2
, 1);
1898 print_syscall_epilogue(name
);
1902 #ifdef TARGET_NR_access
1904 print_access(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1905 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1906 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1908 print_syscall_prologue(name
);
1909 print_string(arg0
, 0);
1910 print_flags(access_flags
, arg1
, 1);
1911 print_syscall_epilogue(name
);
1915 #ifdef TARGET_NR_acct
1917 print_acct(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1918 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1919 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1921 print_syscall_prologue(name
);
1922 print_string(arg0
, 1);
1923 print_syscall_epilogue(name
);
1927 #ifdef TARGET_NR_brk
1929 print_brk(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1930 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1931 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1933 print_syscall_prologue(name
);
1934 print_pointer(arg0
, 1);
1935 print_syscall_epilogue(name
);
1939 #ifdef TARGET_NR_chdir
1941 print_chdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1942 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1943 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1945 print_syscall_prologue(name
);
1946 print_string(arg0
, 1);
1947 print_syscall_epilogue(name
);
1951 #ifdef TARGET_NR_chroot
1953 print_chroot(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1954 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1955 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1957 print_syscall_prologue(name
);
1958 print_string(arg0
, 1);
1959 print_syscall_epilogue(name
);
1963 #ifdef TARGET_NR_chmod
1965 print_chmod(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1966 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1967 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1969 print_syscall_prologue(name
);
1970 print_string(arg0
, 0);
1971 print_file_mode(arg1
, 1);
1972 print_syscall_epilogue(name
);
1976 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1978 print_chown(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1979 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1980 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1982 print_syscall_prologue(name
);
1983 print_string(arg0
, 0);
1984 print_raw_param("%d", arg1
, 0);
1985 print_raw_param("%d", arg2
, 1);
1986 print_syscall_epilogue(name
);
1988 #define print_lchown print_chown
1991 #ifdef TARGET_NR_clock_adjtime
1993 print_clock_adjtime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
1994 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1995 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1997 print_syscall_prologue(name
);
1998 print_enums(clockids
, arg0
, 0);
1999 print_pointer(arg1
, 1);
2000 print_syscall_epilogue(name
);
2004 #ifdef TARGET_NR_clone
2005 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
2006 abi_ulong parent_tidptr
, target_ulong newtls
,
2007 abi_ulong child_tidptr
)
2009 print_flags(clone_flags
, flags
, 0);
2010 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
2011 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
2012 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
2013 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
2017 print_clone(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2018 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2019 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2021 print_syscall_prologue(name
);
2022 #if defined(TARGET_MICROBLAZE)
2023 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
2024 #elif defined(TARGET_CLONE_BACKWARDS)
2025 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
2026 #elif defined(TARGET_CLONE_BACKWARDS2)
2027 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
2029 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
2031 print_syscall_epilogue(name
);
2035 #ifdef TARGET_NR_creat
2037 print_creat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2038 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2039 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2041 print_syscall_prologue(name
);
2042 print_string(arg0
, 0);
2043 print_file_mode(arg1
, 1);
2044 print_syscall_epilogue(name
);
2048 #ifdef TARGET_NR_execv
2050 print_execv(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2051 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2052 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2054 print_syscall_prologue(name
);
2055 print_string(arg0
, 0);
2056 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
2057 print_syscall_epilogue(name
);
2062 print_execve_argv(abi_long argv
, int last
)
2064 abi_ulong arg_ptr_addr
;
2068 for (arg_ptr_addr
= argv
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
2069 abi_ulong
*arg_ptr
, arg_addr
;
2071 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
2075 arg_addr
= tswapal(*arg_ptr
);
2076 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
2080 s
= lock_user_string(arg_addr
);
2082 qemu_log("\"%s\",", s
);
2083 unlock_user(s
, arg_addr
, 0);
2086 qemu_log("NULL}%s", get_comma(last
));
2090 print_execve(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2091 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2092 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2094 print_syscall_prologue(name
);
2095 print_string(arg1
, 0);
2096 print_execve_argv(arg2
, 1);
2097 print_syscall_epilogue(name
);
2101 print_execveat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2102 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2103 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2105 print_syscall_prologue(name
);
2106 print_at_dirfd(arg1
, 0);
2107 print_string(arg2
, 0);
2108 print_execve_argv(arg3
, 0);
2109 print_flags(execveat_flags
, arg5
, 1);
2110 print_syscall_epilogue(name
);
2113 #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
2115 print_faccessat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2116 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2117 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2119 print_syscall_prologue(name
);
2120 print_at_dirfd(arg0
, 0);
2121 print_string(arg1
, 0);
2122 print_flags(access_flags
, arg2
, 0);
2123 print_flags(at_file_flags
, arg3
, 1);
2124 print_syscall_epilogue(name
);
2128 #ifdef TARGET_NR_fallocate
2130 print_fallocate(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2131 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2132 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2134 print_syscall_prologue(name
);
2135 print_raw_param("%d", arg0
, 0);
2136 print_flags(falloc_flags
, arg1
, 0);
2137 #if TARGET_ABI_BITS == 32
2138 print_raw_param("%" PRIu64
, target_offset64(arg2
, arg3
), 0);
2139 print_raw_param("%" PRIu64
, target_offset64(arg4
, arg5
), 1);
2141 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2142 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 1);
2144 print_syscall_epilogue(name
);
2148 #ifdef TARGET_NR_fchmodat
2150 print_fchmodat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2151 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2152 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2154 print_syscall_prologue(name
);
2155 print_at_dirfd(arg0
, 0);
2156 print_string(arg1
, 0);
2157 print_file_mode(arg2
, 0);
2158 print_flags(at_file_flags
, arg3
, 1);
2159 print_syscall_epilogue(name
);
2163 #ifdef TARGET_NR_fchownat
2165 print_fchownat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2166 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2167 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2169 print_syscall_prologue(name
);
2170 print_at_dirfd(arg0
, 0);
2171 print_string(arg1
, 0);
2172 print_raw_param("%d", arg2
, 0);
2173 print_raw_param("%d", arg3
, 0);
2174 print_flags(at_file_flags
, arg4
, 1);
2175 print_syscall_epilogue(name
);
2179 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
2181 print_fcntl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2182 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2183 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2185 print_syscall_prologue(name
);
2186 print_raw_param("%d", arg0
, 0);
2188 case TARGET_F_DUPFD
:
2189 qemu_log("F_DUPFD,");
2190 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2192 case TARGET_F_GETFD
:
2193 qemu_log("F_GETFD");
2195 case TARGET_F_SETFD
:
2196 qemu_log("F_SETFD,");
2197 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2199 case TARGET_F_GETFL
:
2200 qemu_log("F_GETFL");
2202 case TARGET_F_SETFL
:
2203 qemu_log("F_SETFL,");
2204 print_open_flags(arg2
, 1);
2206 case TARGET_F_GETLK
:
2207 qemu_log("F_GETLK,");
2208 print_pointer(arg2
, 1);
2210 case TARGET_F_SETLK
:
2211 qemu_log("F_SETLK,");
2212 print_pointer(arg2
, 1);
2214 case TARGET_F_SETLKW
:
2215 qemu_log("F_SETLKW,");
2216 print_pointer(arg2
, 1);
2218 case TARGET_F_GETOWN
:
2219 qemu_log("F_GETOWN");
2221 case TARGET_F_SETOWN
:
2222 qemu_log("F_SETOWN,");
2223 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2225 case TARGET_F_GETSIG
:
2226 qemu_log("F_GETSIG");
2228 case TARGET_F_SETSIG
:
2229 qemu_log("F_SETSIG,");
2230 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2232 #if TARGET_ABI_BITS == 32
2233 case TARGET_F_GETLK64
:
2234 qemu_log("F_GETLK64,");
2235 print_pointer(arg2
, 1);
2237 case TARGET_F_SETLK64
:
2238 qemu_log("F_SETLK64,");
2239 print_pointer(arg2
, 1);
2241 case TARGET_F_SETLKW64
:
2242 qemu_log("F_SETLKW64,");
2243 print_pointer(arg2
, 1);
2246 case TARGET_F_OFD_GETLK
:
2247 qemu_log("F_OFD_GETLK,");
2248 print_pointer(arg2
, 1);
2250 case TARGET_F_OFD_SETLK
:
2251 qemu_log("F_OFD_SETLK,");
2252 print_pointer(arg2
, 1);
2254 case TARGET_F_OFD_SETLKW
:
2255 qemu_log("F_OFD_SETLKW,");
2256 print_pointer(arg2
, 1);
2258 case TARGET_F_SETLEASE
:
2259 qemu_log("F_SETLEASE,");
2260 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2262 case TARGET_F_GETLEASE
:
2263 qemu_log("F_GETLEASE");
2265 #ifdef F_DUPFD_CLOEXEC
2266 case TARGET_F_DUPFD_CLOEXEC
:
2267 qemu_log("F_DUPFD_CLOEXEC,");
2268 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2271 case TARGET_F_NOTIFY
:
2272 qemu_log("F_NOTIFY,");
2273 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2276 case TARGET_F_GETOWN_EX
:
2277 qemu_log("F_GETOWN_EX,");
2278 print_pointer(arg2
, 1);
2282 case TARGET_F_SETOWN_EX
:
2283 qemu_log("F_SETOWN_EX,");
2284 print_pointer(arg2
, 1);
2288 case TARGET_F_SETPIPE_SZ
:
2289 qemu_log("F_SETPIPE_SZ,");
2290 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2292 case TARGET_F_GETPIPE_SZ
:
2293 qemu_log("F_GETPIPE_SZ");
2297 case TARGET_F_ADD_SEALS
:
2298 qemu_log("F_ADD_SEALS,");
2299 print_raw_param("0x"TARGET_ABI_FMT_lx
, arg2
, 1);
2301 case TARGET_F_GET_SEALS
:
2302 qemu_log("F_GET_SEALS");
2306 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2307 print_pointer(arg2
, 1);
2310 print_syscall_epilogue(name
);
2312 #define print_fcntl64 print_fcntl
2315 #ifdef TARGET_NR_fgetxattr
2317 print_fgetxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2318 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2319 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2321 print_syscall_prologue(name
);
2322 print_raw_param("%d", arg0
, 0);
2323 print_string(arg1
, 0);
2324 print_pointer(arg2
, 0);
2325 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2326 print_syscall_epilogue(name
);
2330 #ifdef TARGET_NR_flistxattr
2332 print_flistxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2333 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2334 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2336 print_syscall_prologue(name
);
2337 print_raw_param("%d", arg0
, 0);
2338 print_pointer(arg1
, 0);
2339 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2340 print_syscall_epilogue(name
);
2344 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2346 print_getxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2347 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2348 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2350 print_syscall_prologue(name
);
2351 print_string(arg0
, 0);
2352 print_string(arg1
, 0);
2353 print_pointer(arg2
, 0);
2354 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2355 print_syscall_epilogue(name
);
2357 #define print_lgetxattr print_getxattr
2360 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2362 print_listxattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2363 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2364 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2366 print_syscall_prologue(name
);
2367 print_string(arg0
, 0);
2368 print_pointer(arg1
, 0);
2369 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2370 print_syscall_epilogue(name
);
2372 #define print_llistxattr print_listxattr
2375 #if defined(TARGET_NR_fremovexattr)
2377 print_fremovexattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2378 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2379 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2381 print_syscall_prologue(name
);
2382 print_raw_param("%d", arg0
, 0);
2383 print_string(arg1
, 1);
2384 print_syscall_epilogue(name
);
2388 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2390 print_removexattr(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2391 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2392 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2394 print_syscall_prologue(name
);
2395 print_string(arg0
, 0);
2396 print_string(arg1
, 1);
2397 print_syscall_epilogue(name
);
2399 #define print_lremovexattr print_removexattr
2402 #ifdef TARGET_NR_futimesat
2404 print_futimesat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2405 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2406 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2408 print_syscall_prologue(name
);
2409 print_at_dirfd(arg0
, 0);
2410 print_string(arg1
, 0);
2411 print_timeval(arg2
, 0);
2412 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
2413 print_syscall_epilogue(name
);
2417 #ifdef TARGET_NR_gettimeofday
2419 print_gettimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2420 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2421 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2423 print_syscall_prologue(name
);
2424 print_pointer(arg0
, 0);
2425 print_pointer(arg1
, 1);
2426 print_syscall_epilogue(name
);
2430 #ifdef TARGET_NR_settimeofday
2432 print_settimeofday(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2433 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2434 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2436 print_syscall_prologue(name
);
2437 print_timeval(arg0
, 0);
2438 print_timezone(arg1
, 1);
2439 print_syscall_epilogue(name
);
2443 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2445 print_clock_gettime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2446 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2447 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2449 print_syscall_prologue(name
);
2450 print_enums(clockids
, arg0
, 0);
2451 print_pointer(arg1
, 1);
2452 print_syscall_epilogue(name
);
2454 #define print_clock_getres print_clock_gettime
2457 #if defined(TARGET_NR_clock_gettime64)
2459 print_clock_gettime64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2460 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2461 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2463 print_syscall_prologue(name
);
2464 print_enums(clockids
, arg0
, 0);
2465 print_pointer(arg1
, 1);
2466 print_syscall_epilogue(name
);
2470 #ifdef TARGET_NR_clock_settime
2472 print_clock_settime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2473 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2474 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2476 print_syscall_prologue(name
);
2477 print_enums(clockids
, arg0
, 0);
2478 print_timespec(arg1
, 1);
2479 print_syscall_epilogue(name
);
2483 #ifdef TARGET_NR_getitimer
2485 print_getitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2486 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2487 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2489 print_syscall_prologue(name
);
2490 print_enums(itimer_types
, arg0
, 0);
2491 print_pointer(arg1
, 1);
2492 print_syscall_epilogue(name
);
2496 #ifdef TARGET_NR_setitimer
2498 print_setitimer(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2499 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2500 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2502 print_syscall_prologue(name
);
2503 print_enums(itimer_types
, arg0
, 0);
2504 print_itimerval(arg1
, 0);
2505 print_pointer(arg2
, 1);
2506 print_syscall_epilogue(name
);
2510 #ifdef TARGET_NR_link
2512 print_link(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2513 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2514 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2516 print_syscall_prologue(name
);
2517 print_string(arg0
, 0);
2518 print_string(arg1
, 1);
2519 print_syscall_epilogue(name
);
2523 #ifdef TARGET_NR_linkat
2525 print_linkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2526 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2527 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2529 print_syscall_prologue(name
);
2530 print_at_dirfd(arg0
, 0);
2531 print_string(arg1
, 0);
2532 print_at_dirfd(arg2
, 0);
2533 print_string(arg3
, 0);
2534 print_flags(at_file_flags
, arg4
, 1);
2535 print_syscall_epilogue(name
);
2539 #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
2541 print__llseek(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2542 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2543 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2545 const char *whence
= "UNKNOWN";
2546 print_syscall_prologue(name
);
2547 print_raw_param("%d", arg0
, 0);
2548 print_raw_param("%ld", arg1
, 0);
2549 print_raw_param("%ld", arg2
, 0);
2550 print_pointer(arg3
, 0);
2552 case SEEK_SET
: whence
= "SEEK_SET"; break;
2553 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
2554 case SEEK_END
: whence
= "SEEK_END"; break;
2556 qemu_log("%s", whence
);
2557 print_syscall_epilogue(name
);
2559 #define print_llseek print__llseek
2562 #ifdef TARGET_NR_lseek
2564 print_lseek(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2565 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2566 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2568 print_syscall_prologue(name
);
2569 print_raw_param("%d", arg0
, 0);
2570 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2573 qemu_log("SEEK_SET"); break;
2575 qemu_log("SEEK_CUR"); break;
2577 qemu_log("SEEK_END"); break;
2580 qemu_log("SEEK_DATA"); break;
2584 qemu_log("SEEK_HOLE"); break;
2587 print_raw_param("%#x", arg2
, 1);
2589 print_syscall_epilogue(name
);
2593 #ifdef TARGET_NR_truncate
2595 print_truncate(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2596 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2597 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2599 print_syscall_prologue(name
);
2600 print_string(arg0
, 0);
2601 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 1);
2602 print_syscall_epilogue(name
);
2606 #ifdef TARGET_NR_truncate64
2608 print_truncate64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2609 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2610 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2612 print_syscall_prologue(name
);
2613 print_string(arg0
, 0);
2614 if (regpairs_aligned(cpu_env
, TARGET_NR_truncate64
)) {
2618 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2619 print_syscall_epilogue(name
);
2623 #ifdef TARGET_NR_ftruncate64
2625 print_ftruncate64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2626 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2627 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2629 print_syscall_prologue(name
);
2630 print_raw_param("%d", arg0
, 0);
2631 if (regpairs_aligned(cpu_env
, TARGET_NR_ftruncate64
)) {
2635 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2636 print_syscall_epilogue(name
);
2640 #ifdef TARGET_NR_mlockall
2642 print_mlockall(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2643 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2644 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2646 print_syscall_prologue(name
);
2647 print_flags(mlockall_flags
, arg0
, 1);
2648 print_syscall_epilogue(name
);
2652 #if defined(TARGET_NR_socket)
2654 print_socket(CPUArchState
*cpu_env
, const struct syscallname
*name
,
2655 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2656 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2658 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
2660 print_syscall_prologue(name
);
2661 print_socket_domain(domain
);
2663 print_socket_type(type
);
2665 if (domain
== AF_PACKET
||
2666 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2667 protocol
= tswap16(protocol
);
2669 print_socket_protocol(domain
, type
, protocol
);
2670 print_syscall_epilogue(name
);
2675 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2677 static void print_sockfd(abi_long sockfd
, int last
)
2679 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
2684 #if defined(TARGET_NR_socketcall)
2686 #define get_user_ualx(x, gaddr, idx) \
2687 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2689 static void do_print_socket(const char *name
, abi_long arg1
)
2691 abi_ulong domain
, type
, protocol
;
2693 get_user_ualx(domain
, arg1
, 0);
2694 get_user_ualx(type
, arg1
, 1);
2695 get_user_ualx(protocol
, arg1
, 2);
2696 qemu_log("%s(", name
);
2697 print_socket_domain(domain
);
2699 print_socket_type(type
);
2701 if (domain
== AF_PACKET
||
2702 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2703 protocol
= tswap16(protocol
);
2705 print_socket_protocol(domain
, type
, protocol
);
2709 static void do_print_sockaddr(const char *name
, abi_long arg1
)
2711 abi_ulong sockfd
, addr
, addrlen
;
2713 get_user_ualx(sockfd
, arg1
, 0);
2714 get_user_ualx(addr
, arg1
, 1);
2715 get_user_ualx(addrlen
, arg1
, 2);
2717 qemu_log("%s(", name
);
2718 print_sockfd(sockfd
, 0);
2719 print_sockaddr(addr
, addrlen
, 0);
2723 static void do_print_listen(const char *name
, abi_long arg1
)
2725 abi_ulong sockfd
, backlog
;
2727 get_user_ualx(sockfd
, arg1
, 0);
2728 get_user_ualx(backlog
, arg1
, 1);
2730 qemu_log("%s(", name
);
2731 print_sockfd(sockfd
, 0);
2732 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
2736 static void do_print_socketpair(const char *name
, abi_long arg1
)
2738 abi_ulong domain
, type
, protocol
, tab
;
2740 get_user_ualx(domain
, arg1
, 0);
2741 get_user_ualx(type
, arg1
, 1);
2742 get_user_ualx(protocol
, arg1
, 2);
2743 get_user_ualx(tab
, arg1
, 3);
2745 qemu_log("%s(", name
);
2746 print_socket_domain(domain
);
2748 print_socket_type(type
);
2750 print_socket_protocol(domain
, type
, protocol
);
2752 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
2756 static void do_print_sendrecv(const char *name
, abi_long arg1
)
2758 abi_ulong sockfd
, msg
, len
, flags
;
2760 get_user_ualx(sockfd
, arg1
, 0);
2761 get_user_ualx(msg
, arg1
, 1);
2762 get_user_ualx(len
, arg1
, 2);
2763 get_user_ualx(flags
, arg1
, 3);
2765 qemu_log("%s(", name
);
2766 print_sockfd(sockfd
, 0);
2767 print_buf_len(msg
, len
, 0);
2768 print_flags(msg_flags
, flags
, 1);
2772 static void do_print_msgaddr(const char *name
, abi_long arg1
)
2774 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
2776 get_user_ualx(sockfd
, arg1
, 0);
2777 get_user_ualx(msg
, arg1
, 1);
2778 get_user_ualx(len
, arg1
, 2);
2779 get_user_ualx(flags
, arg1
, 3);
2780 get_user_ualx(addr
, arg1
, 4);
2781 get_user_ualx(addrlen
, arg1
, 5);
2783 qemu_log("%s(", name
);
2784 print_sockfd(sockfd
, 0);
2785 print_buf_len(msg
, len
, 0);
2786 print_flags(msg_flags
, flags
, 0);
2787 print_sockaddr(addr
, addrlen
, 0);
2791 static void do_print_shutdown(const char *name
, abi_long arg1
)
2793 abi_ulong sockfd
, how
;
2795 get_user_ualx(sockfd
, arg1
, 0);
2796 get_user_ualx(how
, arg1
, 1);
2798 qemu_log("shutdown(");
2799 print_sockfd(sockfd
, 0);
2802 qemu_log("SHUT_RD");
2805 qemu_log("SHUT_WR");
2808 qemu_log("SHUT_RDWR");
2811 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
2817 static void do_print_msg(const char *name
, abi_long arg1
)
2819 abi_ulong sockfd
, msg
, flags
;
2821 get_user_ualx(sockfd
, arg1
, 0);
2822 get_user_ualx(msg
, arg1
, 1);
2823 get_user_ualx(flags
, arg1
, 2);
2825 qemu_log("%s(", name
);
2826 print_sockfd(sockfd
, 0);
2827 print_pointer(msg
, 0);
2828 print_flags(msg_flags
, flags
, 1);
2832 static void do_print_sockopt(const char *name
, abi_long arg1
)
2834 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
2836 get_user_ualx(sockfd
, arg1
, 0);
2837 get_user_ualx(level
, arg1
, 1);
2838 get_user_ualx(optname
, arg1
, 2);
2839 get_user_ualx(optval
, arg1
, 3);
2840 get_user_ualx(optlen
, arg1
, 4);
2842 qemu_log("%s(", name
);
2843 print_sockfd(sockfd
, 0);
2846 qemu_log("SOL_TCP,");
2847 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2848 print_pointer(optval
, 0);
2851 qemu_log("SOL_UDP,");
2852 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2853 print_pointer(optval
, 0);
2856 qemu_log("SOL_IP,");
2857 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2858 print_pointer(optval
, 0);
2861 qemu_log("SOL_RAW,");
2862 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2863 print_pointer(optval
, 0);
2865 case TARGET_SOL_SOCKET
:
2866 qemu_log("SOL_SOCKET,");
2868 case TARGET_SO_DEBUG
:
2869 qemu_log("SO_DEBUG,");
2871 print_number(optval
, 0);
2873 case TARGET_SO_REUSEADDR
:
2874 qemu_log("SO_REUSEADDR,");
2876 case TARGET_SO_REUSEPORT
:
2877 qemu_log("SO_REUSEPORT,");
2879 case TARGET_SO_TYPE
:
2880 qemu_log("SO_TYPE,");
2882 case TARGET_SO_ERROR
:
2883 qemu_log("SO_ERROR,");
2885 case TARGET_SO_DONTROUTE
:
2886 qemu_log("SO_DONTROUTE,");
2888 case TARGET_SO_BROADCAST
:
2889 qemu_log("SO_BROADCAST,");
2891 case TARGET_SO_SNDBUF
:
2892 qemu_log("SO_SNDBUF,");
2894 case TARGET_SO_RCVBUF
:
2895 qemu_log("SO_RCVBUF,");
2897 case TARGET_SO_KEEPALIVE
:
2898 qemu_log("SO_KEEPALIVE,");
2900 case TARGET_SO_OOBINLINE
:
2901 qemu_log("SO_OOBINLINE,");
2903 case TARGET_SO_NO_CHECK
:
2904 qemu_log("SO_NO_CHECK,");
2906 case TARGET_SO_PRIORITY
:
2907 qemu_log("SO_PRIORITY,");
2909 case TARGET_SO_BSDCOMPAT
:
2910 qemu_log("SO_BSDCOMPAT,");
2912 case TARGET_SO_PASSCRED
:
2913 qemu_log("SO_PASSCRED,");
2915 case TARGET_SO_TIMESTAMP
:
2916 qemu_log("SO_TIMESTAMP,");
2918 case TARGET_SO_RCVLOWAT
:
2919 qemu_log("SO_RCVLOWAT,");
2921 case TARGET_SO_RCVTIMEO
:
2922 qemu_log("SO_RCVTIMEO,");
2923 print_timeval(optval
, 0);
2925 case TARGET_SO_SNDTIMEO
:
2926 qemu_log("SO_SNDTIMEO,");
2927 print_timeval(optval
, 0);
2929 case TARGET_SO_ATTACH_FILTER
: {
2930 struct target_sock_fprog
*fprog
;
2932 qemu_log("SO_ATTACH_FILTER,");
2934 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
2935 struct target_sock_filter
*filter
;
2937 if (lock_user_struct(VERIFY_READ
, filter
,
2938 tswapal(fprog
->filter
), 0)) {
2940 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
2941 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2942 i
, tswap16(filter
[i
].code
),
2943 filter
[i
].jt
, filter
[i
].jf
,
2944 tswap32(filter
[i
].k
));
2946 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2947 i
, tswap16(filter
[i
].code
),
2948 filter
[i
].jt
, filter
[i
].jf
,
2949 tswap32(filter
[i
].k
));
2951 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
2953 qemu_log(",%d},", tswap16(fprog
->len
));
2954 unlock_user(fprog
, optval
, 0);
2956 print_pointer(optval
, 0);
2961 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2962 print_pointer(optval
, 0);
2967 qemu_log("SOL_IPV6,");
2969 case IPV6_MTU_DISCOVER
:
2970 qemu_log("IPV6_MTU_DISCOVER,");
2973 qemu_log("IPV6_MTU,");
2976 qemu_log("IPV6_V6ONLY,");
2978 case IPV6_RECVPKTINFO
:
2979 qemu_log("IPV6_RECVPKTINFO,");
2981 case IPV6_UNICAST_HOPS
:
2982 qemu_log("IPV6_UNICAST_HOPS,");
2984 case IPV6_MULTICAST_HOPS
:
2985 qemu_log("IPV6_MULTICAST_HOPS,");
2987 case IPV6_MULTICAST_LOOP
:
2988 qemu_log("IPV6_MULTICAST_LOOP,");
2991 qemu_log("IPV6_RECVERR,");
2993 case IPV6_RECVHOPLIMIT
:
2994 qemu_log("IPV6_RECVHOPLIMIT,");
2996 case IPV6_2292HOPLIMIT
:
2997 qemu_log("IPV6_2292HOPLIMIT,");
3000 qemu_log("IPV6_CHECKSUM,");
3003 qemu_log("IPV6_ADDRFORM,");
3005 case IPV6_2292PKTINFO
:
3006 qemu_log("IPV6_2292PKTINFO,");
3008 case IPV6_RECVTCLASS
:
3009 qemu_log("IPV6_RECVTCLASS,");
3011 case IPV6_RECVRTHDR
:
3012 qemu_log("IPV6_RECVRTHDR,");
3014 case IPV6_2292RTHDR
:
3015 qemu_log("IPV6_2292RTHDR,");
3017 case IPV6_RECVHOPOPTS
:
3018 qemu_log("IPV6_RECVHOPOPTS,");
3020 case IPV6_2292HOPOPTS
:
3021 qemu_log("IPV6_2292HOPOPTS,");
3023 case IPV6_RECVDSTOPTS
:
3024 qemu_log("IPV6_RECVDSTOPTS,");
3026 case IPV6_2292DSTOPTS
:
3027 qemu_log("IPV6_2292DSTOPTS,");
3030 qemu_log("IPV6_TCLASS,");
3032 case IPV6_ADDR_PREFERENCES
:
3033 qemu_log("IPV6_ADDR_PREFERENCES,");
3035 #ifdef IPV6_RECVPATHMTU
3036 case IPV6_RECVPATHMTU
:
3037 qemu_log("IPV6_RECVPATHMTU,");
3040 #ifdef IPV6_TRANSPARENT
3041 case IPV6_TRANSPARENT
:
3042 qemu_log("IPV6_TRANSPARENT,");
3045 #ifdef IPV6_FREEBIND
3047 qemu_log("IPV6_FREEBIND,");
3050 #ifdef IPV6_RECVORIGDSTADDR
3051 case IPV6_RECVORIGDSTADDR
:
3052 qemu_log("IPV6_RECVORIGDSTADDR,");
3056 qemu_log("IPV6_PKTINFO,");
3057 print_pointer(optval
, 0);
3059 case IPV6_ADD_MEMBERSHIP
:
3060 qemu_log("IPV6_ADD_MEMBERSHIP,");
3061 print_pointer(optval
, 0);
3063 case IPV6_DROP_MEMBERSHIP
:
3064 qemu_log("IPV6_DROP_MEMBERSHIP,");
3065 print_pointer(optval
, 0);
3068 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
3069 print_pointer(optval
, 0);
3074 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
3075 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
3076 print_pointer(optval
, 0);
3079 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
3083 #define PRINT_SOCKOP(name, func) \
3084 [TARGET_SYS_##name] = { #name, func }
3088 void (*print
)(const char *, abi_long
);
3090 PRINT_SOCKOP(SOCKET
, do_print_socket
),
3091 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
3092 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
3093 PRINT_SOCKOP(LISTEN
, do_print_listen
),
3094 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
3095 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
3096 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
3097 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
3098 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
3099 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
3100 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
3101 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
3102 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
3103 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
3104 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
3105 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
3106 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
3107 PRINT_SOCKOP(ACCEPT4
, NULL
),
3108 PRINT_SOCKOP(RECVMMSG
, NULL
),
3109 PRINT_SOCKOP(SENDMMSG
, NULL
),
3113 print_socketcall(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3114 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3115 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3117 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
3118 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
3121 print_syscall_prologue(name
);
3122 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
3123 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
3124 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
3125 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
3126 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
3127 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
3128 print_syscall_epilogue(name
);
3132 #if defined(TARGET_NR_bind)
3134 print_bind(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3135 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3136 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3138 print_syscall_prologue(name
);
3139 print_sockfd(arg0
, 0);
3140 print_sockaddr(arg1
, arg2
, 1);
3141 print_syscall_epilogue(name
);
3145 #ifdef TARGET_NR_recvfrom
3147 print_recvfrom(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3148 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3149 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3151 print_syscall_prologue(name
);
3152 print_sockfd(arg0
, 0);
3153 print_pointer(arg1
, 0); /* output */
3154 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
3155 print_flags(msg_flags
, arg3
, 0);
3156 print_pointer(arg4
, 0); /* output */
3157 print_pointer(arg5
, 1); /* in/out */
3158 print_syscall_epilogue(name
);
3162 #ifdef TARGET_NR_sendto
3164 print_sendto(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3165 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3166 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3168 print_syscall_prologue(name
);
3169 print_sockfd(arg0
, 0);
3170 print_buf_len(arg1
, arg2
, 0);
3171 print_flags(msg_flags
, arg3
, 0);
3172 print_sockaddr(arg4
, arg5
, 1);
3173 print_syscall_epilogue(name
);
3177 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
3178 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
3180 print_stat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3181 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3182 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3184 print_syscall_prologue(name
);
3185 print_string(arg0
, 0);
3186 print_pointer(arg1
, 1);
3187 print_syscall_epilogue(name
);
3189 #define print_lstat print_stat
3190 #define print_stat64 print_stat
3191 #define print_lstat64 print_stat
3194 #if defined(TARGET_NR_madvise)
3195 static struct enums madvise_advice
[] = {
3196 ENUM_TARGET(MADV_NORMAL
),
3197 ENUM_TARGET(MADV_RANDOM
),
3198 ENUM_TARGET(MADV_SEQUENTIAL
),
3199 ENUM_TARGET(MADV_WILLNEED
),
3200 ENUM_TARGET(MADV_DONTNEED
),
3201 ENUM_TARGET(MADV_FREE
),
3202 ENUM_TARGET(MADV_REMOVE
),
3203 ENUM_TARGET(MADV_DONTFORK
),
3204 ENUM_TARGET(MADV_DOFORK
),
3205 ENUM_TARGET(MADV_MERGEABLE
),
3206 ENUM_TARGET(MADV_UNMERGEABLE
),
3207 ENUM_TARGET(MADV_HUGEPAGE
),
3208 ENUM_TARGET(MADV_NOHUGEPAGE
),
3209 ENUM_TARGET(MADV_DONTDUMP
),
3210 ENUM_TARGET(MADV_DODUMP
),
3211 ENUM_TARGET(MADV_WIPEONFORK
),
3212 ENUM_TARGET(MADV_KEEPONFORK
),
3213 ENUM_TARGET(MADV_COLD
),
3214 ENUM_TARGET(MADV_PAGEOUT
),
3215 ENUM_TARGET(MADV_POPULATE_READ
),
3216 ENUM_TARGET(MADV_POPULATE_WRITE
),
3217 ENUM_TARGET(MADV_DONTNEED_LOCKED
),
3222 print_madvise(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3223 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3224 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3226 print_syscall_prologue(name
);
3227 print_pointer(arg0
, 0);
3228 print_raw_param("%d", arg1
, 0);
3229 print_enums(madvise_advice
, arg2
, 1);
3230 print_syscall_epilogue(name
);
3234 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
3236 print_fstat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3237 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3238 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3240 print_syscall_prologue(name
);
3241 print_raw_param("%d", arg0
, 0);
3242 print_pointer(arg1
, 1);
3243 print_syscall_epilogue(name
);
3245 #define print_fstat64 print_fstat
3248 #ifdef TARGET_NR_mkdir
3250 print_mkdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3251 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3252 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3254 print_syscall_prologue(name
);
3255 print_string(arg0
, 0);
3256 print_file_mode(arg1
, 1);
3257 print_syscall_epilogue(name
);
3261 #ifdef TARGET_NR_mkdirat
3263 print_mkdirat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3264 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3265 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3267 print_syscall_prologue(name
);
3268 print_at_dirfd(arg0
, 0);
3269 print_string(arg1
, 0);
3270 print_file_mode(arg2
, 1);
3271 print_syscall_epilogue(name
);
3275 #ifdef TARGET_NR_rmdir
3277 print_rmdir(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3278 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3279 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3281 print_syscall_prologue(name
);
3282 print_string(arg0
, 0);
3283 print_syscall_epilogue(name
);
3287 #ifdef TARGET_NR_rt_sigaction
3289 print_rt_sigaction(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3290 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3291 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3293 print_syscall_prologue(name
);
3294 print_signal(arg0
, 0);
3295 print_pointer(arg1
, 0);
3296 print_pointer(arg2
, 1);
3297 print_syscall_epilogue(name
);
3301 #ifdef TARGET_NR_rt_sigprocmask
3303 print_rt_sigprocmask(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3304 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3305 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3307 const char *how
= "UNKNOWN";
3308 print_syscall_prologue(name
);
3310 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
3311 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
3312 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
3314 qemu_log("%s,", how
);
3315 print_pointer(arg1
, 0);
3316 print_pointer(arg2
, 0);
3317 print_raw_param("%u", arg3
, 1);
3318 print_syscall_epilogue(name
);
3322 #ifdef TARGET_NR_rt_sigqueueinfo
3324 print_rt_sigqueueinfo(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3325 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3326 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3329 target_siginfo_t uinfo
;
3331 print_syscall_prologue(name
);
3332 print_raw_param("%d", arg0
, 0);
3333 print_signal(arg1
, 0);
3334 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
3336 get_target_siginfo(&uinfo
, p
);
3337 print_siginfo(&uinfo
);
3339 unlock_user(p
, arg2
, 0);
3341 print_pointer(arg2
, 1);
3343 print_syscall_epilogue(name
);
3347 #ifdef TARGET_NR_rt_tgsigqueueinfo
3349 print_rt_tgsigqueueinfo(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3350 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3351 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3354 target_siginfo_t uinfo
;
3356 print_syscall_prologue(name
);
3357 print_raw_param("%d", arg0
, 0);
3358 print_raw_param("%d", arg1
, 0);
3359 print_signal(arg2
, 0);
3360 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
3362 get_target_siginfo(&uinfo
, p
);
3363 print_siginfo(&uinfo
);
3365 unlock_user(p
, arg3
, 0);
3367 print_pointer(arg3
, 1);
3369 print_syscall_epilogue(name
);
3373 #ifdef TARGET_NR_syslog
3375 print_syslog_action(abi_ulong arg
, int last
)
3380 case TARGET_SYSLOG_ACTION_CLOSE
: {
3381 type
= "SYSLOG_ACTION_CLOSE";
3384 case TARGET_SYSLOG_ACTION_OPEN
: {
3385 type
= "SYSLOG_ACTION_OPEN";
3388 case TARGET_SYSLOG_ACTION_READ
: {
3389 type
= "SYSLOG_ACTION_READ";
3392 case TARGET_SYSLOG_ACTION_READ_ALL
: {
3393 type
= "SYSLOG_ACTION_READ_ALL";
3396 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
3397 type
= "SYSLOG_ACTION_READ_CLEAR";
3400 case TARGET_SYSLOG_ACTION_CLEAR
: {
3401 type
= "SYSLOG_ACTION_CLEAR";
3404 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
3405 type
= "SYSLOG_ACTION_CONSOLE_OFF";
3408 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
3409 type
= "SYSLOG_ACTION_CONSOLE_ON";
3412 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
3413 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
3416 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
3417 type
= "SYSLOG_ACTION_SIZE_UNREAD";
3420 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
3421 type
= "SYSLOG_ACTION_SIZE_BUFFER";
3425 print_raw_param("%ld", arg
, last
);
3429 qemu_log("%s%s", type
, get_comma(last
));
3433 print_syslog(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3434 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3435 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3437 print_syscall_prologue(name
);
3438 print_syslog_action(arg0
, 0);
3439 print_pointer(arg1
, 0);
3440 print_raw_param("%d", arg2
, 1);
3441 print_syscall_epilogue(name
);
3445 #ifdef TARGET_NR_mknod
3447 print_mknod(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3448 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3449 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3451 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
3453 print_syscall_prologue(name
);
3454 print_string(arg0
, 0);
3455 print_file_mode(arg1
, (hasdev
== 0));
3457 print_raw_param("makedev(%d", major(arg2
), 0);
3458 print_raw_param("%d)", minor(arg2
), 1);
3460 print_syscall_epilogue(name
);
3464 #ifdef TARGET_NR_mknodat
3466 print_mknodat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3467 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3468 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3470 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
3472 print_syscall_prologue(name
);
3473 print_at_dirfd(arg0
, 0);
3474 print_string(arg1
, 0);
3475 print_file_mode(arg2
, (hasdev
== 0));
3477 print_raw_param("makedev(%d", major(arg3
), 0);
3478 print_raw_param("%d)", minor(arg3
), 1);
3480 print_syscall_epilogue(name
);
3484 #ifdef TARGET_NR_mq_open
3486 print_mq_open(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3487 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3488 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3490 int is_creat
= (arg1
& TARGET_O_CREAT
);
3492 print_syscall_prologue(name
);
3493 print_string(arg0
, 0);
3494 print_open_flags(arg1
, (is_creat
== 0));
3496 print_file_mode(arg2
, 0);
3497 print_pointer(arg3
, 1);
3499 print_syscall_epilogue(name
);
3503 #ifdef TARGET_NR_open
3505 print_open(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3506 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3507 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3509 int is_creat
= (arg1
& TARGET_O_CREAT
);
3511 print_syscall_prologue(name
);
3512 print_string(arg0
, 0);
3513 print_open_flags(arg1
, (is_creat
== 0));
3515 print_file_mode(arg2
, 1);
3516 print_syscall_epilogue(name
);
3520 #ifdef TARGET_NR_openat
3522 print_openat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3523 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3524 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3526 int is_creat
= (arg2
& TARGET_O_CREAT
);
3528 print_syscall_prologue(name
);
3529 print_at_dirfd(arg0
, 0);
3530 print_string(arg1
, 0);
3531 print_open_flags(arg2
, (is_creat
== 0));
3533 print_file_mode(arg3
, 1);
3534 print_syscall_epilogue(name
);
3538 #ifdef TARGET_NR_openat2
3540 print_openat2(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3541 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3542 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3544 struct open_how_ver0 how
;
3546 print_syscall_prologue(name
);
3547 print_at_dirfd(arg0
, 0);
3548 print_string(arg1
, 0);
3550 if ((abi_ulong
)arg3
>= sizeof(struct target_open_how_ver0
) &&
3551 copy_struct_from_user(&how
, sizeof(how
), arg2
, arg3
) == 0) {
3552 how
.flags
= tswap64(how
.flags
);
3553 how
.mode
= tswap64(how
.mode
);
3554 how
.resolve
= tswap64(how
.resolve
);
3556 print_open_flags(how
.flags
, 0);
3557 if (how
.flags
& TARGET_O_CREAT
) {
3558 print_file_mode(how
.mode
, 0);
3560 print_flags(openat2_resolve_flags
, how
.resolve
, 1);
3563 print_pointer(arg2
, 0);
3565 print_raw_param(TARGET_ABI_FMT_lu
, arg3
, 1);
3566 print_syscall_epilogue(name
);
3570 #ifdef TARGET_NR_pidfd_send_signal
3572 print_pidfd_send_signal(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3573 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3574 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3577 target_siginfo_t uinfo
;
3579 print_syscall_prologue(name
);
3580 print_raw_param("%d", arg0
, 0);
3581 print_signal(arg1
, 0);
3583 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
3585 get_target_siginfo(&uinfo
, p
);
3586 print_siginfo(&uinfo
);
3588 unlock_user(p
, arg2
, 0);
3590 print_pointer(arg2
, 0);
3593 print_raw_param("%u", arg3
, 1);
3594 print_syscall_epilogue(name
);
3598 #ifdef TARGET_NR_mq_unlink
3600 print_mq_unlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3601 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3602 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3604 print_syscall_prologue(name
);
3605 print_string(arg0
, 1);
3606 print_syscall_epilogue(name
);
3610 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3612 print_fstatat64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3613 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3614 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3616 print_syscall_prologue(name
);
3617 print_at_dirfd(arg0
, 0);
3618 print_string(arg1
, 0);
3619 print_pointer(arg2
, 0);
3620 print_flags(at_file_flags
, arg3
, 1);
3621 print_syscall_epilogue(name
);
3623 #define print_newfstatat print_fstatat64
3626 #ifdef TARGET_NR_readlink
3628 print_readlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3629 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3630 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3632 print_syscall_prologue(name
);
3633 print_string(arg0
, 0);
3634 print_pointer(arg1
, 0);
3635 print_raw_param("%u", arg2
, 1);
3636 print_syscall_epilogue(name
);
3640 #ifdef TARGET_NR_readlinkat
3642 print_readlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3643 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3644 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3646 print_syscall_prologue(name
);
3647 print_at_dirfd(arg0
, 0);
3648 print_string(arg1
, 0);
3649 print_pointer(arg2
, 0);
3650 print_raw_param("%u", arg3
, 1);
3651 print_syscall_epilogue(name
);
3655 #ifdef TARGET_NR_rename
3657 print_rename(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3658 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3659 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3661 print_syscall_prologue(name
);
3662 print_string(arg0
, 0);
3663 print_string(arg1
, 1);
3664 print_syscall_epilogue(name
);
3668 #ifdef TARGET_NR_renameat
3670 print_renameat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3671 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3672 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3674 print_syscall_prologue(name
);
3675 print_at_dirfd(arg0
, 0);
3676 print_string(arg1
, 0);
3677 print_at_dirfd(arg2
, 0);
3678 print_string(arg3
, 1);
3679 print_syscall_epilogue(name
);
3683 #ifdef TARGET_NR_statfs
3685 print_statfs(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3686 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3687 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3689 print_syscall_prologue(name
);
3690 print_string(arg0
, 0);
3691 print_pointer(arg1
, 1);
3692 print_syscall_epilogue(name
);
3696 #ifdef TARGET_NR_statfs64
3698 print_statfs64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3699 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3700 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3702 print_syscall_prologue(name
);
3703 print_string(arg0
, 0);
3704 print_pointer(arg1
, 1);
3705 print_syscall_epilogue(name
);
3709 #ifdef TARGET_NR_symlink
3711 print_symlink(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_string(arg0
, 0);
3717 print_string(arg1
, 1);
3718 print_syscall_epilogue(name
);
3722 #ifdef TARGET_NR_symlinkat
3724 print_symlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3725 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3726 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3728 print_syscall_prologue(name
);
3729 print_string(arg0
, 0);
3730 print_at_dirfd(arg1
, 0);
3731 print_string(arg2
, 1);
3732 print_syscall_epilogue(name
);
3736 #ifdef TARGET_NR_mount
3738 print_mount(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3739 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3740 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3742 print_syscall_prologue(name
);
3743 print_string(arg0
, 0);
3744 print_string(arg1
, 0);
3745 print_string(arg2
, 0);
3746 print_flags(mount_flags
, arg3
, 0);
3747 print_pointer(arg4
, 1);
3748 print_syscall_epilogue(name
);
3752 #ifdef TARGET_NR_umount
3754 print_umount(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3755 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3756 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3758 print_syscall_prologue(name
);
3759 print_string(arg0
, 1);
3760 print_syscall_epilogue(name
);
3764 #ifdef TARGET_NR_umount2
3766 print_umount2(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3767 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3768 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3770 print_syscall_prologue(name
);
3771 print_string(arg0
, 0);
3772 print_flags(umount2_flags
, arg1
, 1);
3773 print_syscall_epilogue(name
);
3777 #ifdef TARGET_NR_unlink
3779 print_unlink(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3780 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3781 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3783 print_syscall_prologue(name
);
3784 print_string(arg0
, 1);
3785 print_syscall_epilogue(name
);
3789 #ifdef TARGET_NR_unlinkat
3791 print_unlinkat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3792 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3793 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3795 print_syscall_prologue(name
);
3796 print_at_dirfd(arg0
, 0);
3797 print_string(arg1
, 0);
3798 print_flags(unlinkat_flags
, arg2
, 1);
3799 print_syscall_epilogue(name
);
3803 #ifdef TARGET_NR_unshare
3805 print_unshare(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3806 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3807 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3809 print_syscall_prologue(name
);
3810 print_flags(clone_flags
, arg0
, 1);
3811 print_syscall_epilogue(name
);
3815 #ifdef TARGET_NR_clock_nanosleep
3817 print_clock_nanosleep(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3818 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3819 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3821 print_syscall_prologue(name
);
3822 print_enums(clockids
, arg0
, 0);
3823 print_raw_param("%d", arg1
, 0);
3824 print_timespec(arg2
, 0);
3825 print_timespec(arg3
, 1);
3826 print_syscall_epilogue(name
);
3830 #ifdef TARGET_NR_utime
3832 print_utime(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3833 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3834 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3836 print_syscall_prologue(name
);
3837 print_string(arg0
, 0);
3838 print_pointer(arg1
, 1);
3839 print_syscall_epilogue(name
);
3843 #ifdef TARGET_NR_utimes
3845 print_utimes(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3846 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3847 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3849 print_syscall_prologue(name
);
3850 print_string(arg0
, 0);
3851 print_pointer(arg1
, 1);
3852 print_syscall_epilogue(name
);
3856 #ifdef TARGET_NR_utimensat
3858 print_utimensat(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3859 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3860 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3862 print_syscall_prologue(name
);
3863 print_at_dirfd(arg0
, 0);
3864 print_string(arg1
, 0);
3865 print_pointer(arg2
, 0);
3866 print_flags(at_file_flags
, arg3
, 1);
3867 print_syscall_epilogue(name
);
3871 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3873 print_mmap_both(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3874 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3875 abi_long arg3
, abi_long arg4
, abi_long arg5
,
3880 abi_ulong argp
= arg0
;
3881 if (!(v
= lock_user(VERIFY_READ
, argp
, 6 * sizeof(abi_ulong
), 1)))
3883 arg0
= tswapal(v
[0]);
3884 arg1
= tswapal(v
[1]);
3885 arg2
= tswapal(v
[2]);
3886 arg3
= tswapal(v
[3]);
3887 arg4
= tswapal(v
[4]);
3888 arg5
= tswapal(v
[5]);
3889 unlock_user(v
, argp
, 0);
3891 print_syscall_prologue(name
);
3892 print_pointer(arg0
, 0);
3893 print_raw_param("%d", arg1
, 0);
3894 print_flags(mmap_prot_flags
, arg2
, 0);
3895 print_flags(mmap_flags
, arg3
, 0);
3896 print_raw_param("%d", arg4
, 0);
3897 print_raw_param("%#x", arg5
, 1);
3898 print_syscall_epilogue(name
);
3902 #if defined(TARGET_NR_mmap)
3904 print_mmap(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3905 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3906 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3908 return print_mmap_both(cpu_env
, name
, arg0
, arg1
, arg2
, arg3
,
3910 #if defined(TARGET_NR_mmap2)
3919 #if defined(TARGET_NR_mmap2)
3921 print_mmap2(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3922 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3923 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3925 return print_mmap_both(cpu_env
, name
, arg0
, arg1
, arg2
, arg3
,
3930 #ifdef TARGET_NR_mprotect
3932 print_mprotect(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3933 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3934 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3936 print_syscall_prologue(name
);
3937 print_pointer(arg0
, 0);
3938 print_raw_param("%d", arg1
, 0);
3939 print_flags(mmap_prot_flags
, arg2
, 1);
3940 print_syscall_epilogue(name
);
3944 #ifdef TARGET_NR_munmap
3946 print_munmap(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3947 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3948 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3950 print_syscall_prologue(name
);
3951 print_pointer(arg0
, 0);
3952 print_raw_param("%d", arg1
, 1);
3953 print_syscall_epilogue(name
);
3957 #ifdef TARGET_NR_futex
3958 static void print_futex_op(int cmd
, int last
)
3960 static const char * const futex_names
[] = {
3961 #define NAME(X) [X] = #X
3965 NAME(FUTEX_REQUEUE
),
3966 NAME(FUTEX_CMP_REQUEUE
),
3967 NAME(FUTEX_WAKE_OP
),
3968 NAME(FUTEX_LOCK_PI
),
3969 NAME(FUTEX_UNLOCK_PI
),
3970 NAME(FUTEX_TRYLOCK_PI
),
3971 NAME(FUTEX_WAIT_BITSET
),
3972 NAME(FUTEX_WAKE_BITSET
),
3973 NAME(FUTEX_WAIT_REQUEUE_PI
),
3974 NAME(FUTEX_CMP_REQUEUE_PI
),
3975 NAME(FUTEX_LOCK_PI2
),
3979 unsigned base_cmd
= cmd
& FUTEX_CMD_MASK
;
3981 if (base_cmd
< ARRAY_SIZE(futex_names
)) {
3983 (cmd
& FUTEX_PRIVATE_FLAG
? "FUTEX_PRIVATE_FLAG|" : ""),
3984 (cmd
& FUTEX_CLOCK_REALTIME
? "FUTEX_CLOCK_REALTIME|" : ""),
3985 futex_names
[base_cmd
]);
3987 qemu_log("0x%x", cmd
);
3992 print_futex(CPUArchState
*cpu_env
, const struct syscallname
*name
,
3993 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3994 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3996 abi_long op
= arg1
& FUTEX_CMD_MASK
;
3997 print_syscall_prologue(name
);
3998 print_pointer(arg0
, 0);
3999 print_futex_op(arg1
, 0);
4000 print_raw_param(",%d", arg2
, 0);
4003 case FUTEX_WAIT_BITSET
:
4005 case FUTEX_LOCK_PI2
:
4006 case FUTEX_WAIT_REQUEUE_PI
:
4007 print_timespec(arg3
, 0);
4010 print_pointer(arg3
, 0);
4013 print_pointer(arg4
, 0);
4014 print_raw_param("%d", arg4
, 1);
4015 print_syscall_epilogue(name
);
4019 #ifdef TARGET_NR_prlimit64
4020 static const char *target_ressource_string(abi_ulong r
)
4022 #define RET_RES_ENTRY(res) case TARGET_##res: return #res;
4024 RET_RES_ENTRY(RLIMIT_AS
);
4025 RET_RES_ENTRY(RLIMIT_CORE
);
4026 RET_RES_ENTRY(RLIMIT_CPU
);
4027 RET_RES_ENTRY(RLIMIT_DATA
);
4028 RET_RES_ENTRY(RLIMIT_FSIZE
);
4029 RET_RES_ENTRY(RLIMIT_LOCKS
);
4030 RET_RES_ENTRY(RLIMIT_MEMLOCK
);
4031 RET_RES_ENTRY(RLIMIT_MSGQUEUE
);
4032 RET_RES_ENTRY(RLIMIT_NICE
);
4033 RET_RES_ENTRY(RLIMIT_NOFILE
);
4034 RET_RES_ENTRY(RLIMIT_NPROC
);
4035 RET_RES_ENTRY(RLIMIT_RSS
);
4036 RET_RES_ENTRY(RLIMIT_RTPRIO
);
4037 #ifdef RLIMIT_RTTIME
4038 RET_RES_ENTRY(RLIMIT_RTTIME
);
4040 RET_RES_ENTRY(RLIMIT_SIGPENDING
);
4041 RET_RES_ENTRY(RLIMIT_STACK
);
4045 #undef RET_RES_ENTRY
4049 print_rlimit64(abi_ulong rlim_addr
, int last
)
4052 struct target_rlimit64
*rl
;
4054 rl
= lock_user(VERIFY_READ
, rlim_addr
, sizeof(*rl
), 1);
4056 print_pointer(rlim_addr
, last
);
4059 print_raw_param64("{rlim_cur=%" PRId64
, tswap64(rl
->rlim_cur
), 0);
4060 print_raw_param64("rlim_max=%" PRId64
"}", tswap64(rl
->rlim_max
),
4062 unlock_user(rl
, rlim_addr
, 0);
4064 qemu_log("NULL%s", get_comma(last
));
4069 print_prlimit64(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 const char *rlim_name
;
4075 print_syscall_prologue(name
);
4076 print_raw_param("%d", arg0
, 0);
4077 rlim_name
= target_ressource_string(arg1
);
4079 qemu_log("%s,", rlim_name
);
4081 print_raw_param("%d", arg1
, 0);
4083 print_rlimit64(arg2
, 0);
4084 print_pointer(arg3
, 1);
4085 print_syscall_epilogue(name
);
4089 print_syscall_ret_prlimit64(CPUArchState
*cpu_env
,
4090 const struct syscallname
*name
,
4091 abi_long ret
, abi_long arg0
, abi_long arg1
,
4092 abi_long arg2
, abi_long arg3
, abi_long arg4
,
4095 if (!print_syscall_err(ret
)) {
4096 qemu_log(TARGET_ABI_FMT_ld
, ret
);
4099 print_rlimit64(arg3
, 1);
4107 #ifdef TARGET_NR_kill
4109 print_kill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4110 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4111 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4113 print_syscall_prologue(name
);
4114 print_raw_param("%d", arg0
, 0);
4115 print_signal(arg1
, 1);
4116 print_syscall_epilogue(name
);
4120 #ifdef TARGET_NR_tkill
4122 print_tkill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4123 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4124 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4126 print_syscall_prologue(name
);
4127 print_raw_param("%d", arg0
, 0);
4128 print_signal(arg1
, 1);
4129 print_syscall_epilogue(name
);
4133 #ifdef TARGET_NR_tgkill
4135 print_tgkill(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4136 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4137 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4139 print_syscall_prologue(name
);
4140 print_raw_param("%d", arg0
, 0);
4141 print_raw_param("%d", arg1
, 0);
4142 print_signal(arg2
, 1);
4143 print_syscall_epilogue(name
);
4147 #if defined(TARGET_NR_pread64) || defined(TARGET_NR_pwrite64)
4149 print_pread64(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4150 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4151 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4153 if (regpairs_aligned(cpu_env
, TARGET_NR_pread64
)) {
4157 print_syscall_prologue(name
);
4158 print_raw_param("%d", arg0
, 0);
4159 print_pointer(arg1
, 0);
4160 print_raw_param("%d", arg2
, 0);
4161 print_raw_param("%" PRIu64
, target_offset64(arg3
, arg4
), 1);
4162 print_syscall_epilogue(name
);
4166 #ifdef TARGET_NR_statx
4168 print_statx(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4169 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4170 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4172 print_syscall_prologue(name
);
4173 print_at_dirfd(arg0
, 0);
4174 print_string(arg1
, 0);
4175 print_flags(statx_flags
, arg2
, 0);
4176 print_flags(statx_mask
, arg3
, 0);
4177 print_pointer(arg4
, 1);
4178 print_syscall_epilogue(name
);
4182 #ifdef TARGET_NR_ioctl
4184 print_ioctl(CPUArchState
*cpu_env
, const struct syscallname
*name
,
4185 abi_long arg0
, abi_long arg1
, abi_long arg2
,
4186 abi_long arg3
, abi_long arg4
, abi_long arg5
)
4188 print_syscall_prologue(name
);
4189 print_raw_param("%d", arg0
, 0);
4191 const IOCTLEntry
*ie
;
4192 const argtype
*arg_type
;
4196 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
4197 if (ie
->target_cmd
== arg1
) {
4202 if (ie
->target_cmd
== 0) {
4203 print_raw_param("%#x", arg1
, 0);
4204 print_raw_param("%#x", arg2
, 1);
4206 qemu_log("%s", ie
->name
);
4207 arg_type
= ie
->arg_type
;
4209 if (arg_type
[0] != TYPE_NULL
) {
4212 switch (arg_type
[0]) {
4214 print_pointer(arg2
, 1);
4219 print_raw_param("%d", arg2
, 1);
4222 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
4225 print_raw_param(TARGET_ABI_FMT_lu
, arg2
, 1);
4228 switch (ie
->access
) {
4230 print_pointer(arg2
, 1);
4235 target_size
= thunk_type_size(arg_type
, 0);
4236 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
4238 thunk_print(argptr
, arg_type
);
4239 unlock_user(argptr
, arg2
, target_size
);
4241 print_pointer(arg2
, 1);
4247 g_assert_not_reached();
4251 print_syscall_epilogue(name
);
4255 #if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
4256 static void print_wstatus(int wstatus
)
4258 if (WIFSIGNALED(wstatus
)) {
4259 qemu_log("{WIFSIGNALED(s) && WTERMSIG(s) == ");
4260 print_signal(WTERMSIG(wstatus
), 1);
4261 if (WCOREDUMP(wstatus
)) {
4262 qemu_log(" && WCOREDUMP(s)");
4265 } else if (WIFEXITED(wstatus
)) {
4266 qemu_log("{WIFEXITED(s) && WEXITSTATUS(s) == %d}",
4267 WEXITSTATUS(wstatus
));
4269 print_number(wstatus
, 1);
4273 static void print_ret_wstatus(abi_long ret
, abi_long wstatus_addr
)
4277 if (!print_syscall_err(ret
)
4279 && get_user_s32(wstatus
, wstatus_addr
)) {
4280 qemu_log(TARGET_ABI_FMT_ld
" (wstatus=", ret
);
4281 print_wstatus(wstatus
);
4288 #ifdef TARGET_NR_wait4
4290 print_syscall_ret_wait4(CPUArchState
*cpu_env
,
4291 const struct syscallname
*name
,
4292 abi_long ret
, abi_long arg0
, abi_long arg1
,
4293 abi_long arg2
, abi_long arg3
, abi_long arg4
,
4296 print_ret_wstatus(ret
, arg1
);
4300 #ifdef TARGET_NR_waitpid
4302 print_syscall_ret_waitpid(CPUArchState
*cpu_env
,
4303 const struct syscallname
*name
,
4304 abi_long ret
, abi_long arg0
, abi_long arg1
,
4305 abi_long arg2
, abi_long arg3
, abi_long arg4
,
4308 print_ret_wstatus(ret
, arg1
);
4313 * An array of all of the syscalls we know about
4316 static const struct syscallname scnames
[] = {
4317 #include "strace.list"
4320 static int nsyscalls
= ARRAY_SIZE(scnames
);
4323 * The public interface to this module.
4326 print_syscall(CPUArchState
*cpu_env
, int num
,
4327 abi_long arg1
, abi_long arg2
, abi_long arg3
,
4328 abi_long arg4
, abi_long arg5
, abi_long arg6
)
4332 const char *format
= "%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
4333 TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
","
4334 TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")";
4336 f
= qemu_log_trylock();
4340 fprintf(f
, "%d ", getpid());
4342 for (i
= 0; i
< nsyscalls
; i
++) {
4343 if (scnames
[i
].nr
== num
) {
4344 if (scnames
[i
].call
!= NULL
) {
4345 scnames
[i
].call(cpu_env
, &scnames
[i
], arg1
, arg2
, arg3
,
4348 /* XXX: this format system is broken because it uses
4349 host types and host pointers for strings */
4350 if (scnames
[i
].format
!= NULL
) {
4351 format
= scnames
[i
].format
;
4353 fprintf(f
, format
, scnames
[i
].name
, arg1
, arg2
,
4354 arg3
, arg4
, arg5
, arg6
);
4360 fprintf(f
, "Unknown syscall %d\n", num
);
4366 print_syscall_ret(CPUArchState
*cpu_env
, int num
, abi_long ret
,
4367 abi_long arg1
, abi_long arg2
, abi_long arg3
,
4368 abi_long arg4
, abi_long arg5
, abi_long arg6
)
4373 f
= qemu_log_trylock();
4378 for (i
= 0; i
< nsyscalls
; i
++) {
4379 if (scnames
[i
].nr
== num
) {
4380 if (scnames
[i
].result
!= NULL
) {
4381 scnames
[i
].result(cpu_env
, &scnames
[i
], ret
,
4385 if (!print_syscall_err(ret
)) {
4386 fprintf(f
, TARGET_ABI_FMT_ld
, ret
);
4396 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
4398 /* Print the strace output for a signal being taken:
4399 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
4403 f
= qemu_log_trylock();
4409 print_signal(target_signum
, 1);
4411 print_siginfo(tinfo
);
4412 fprintf(f
, " ---\n");