1 #include "qemu/osdep.h"
6 #include <sys/select.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.h>
11 #include <linux/netlink.h>
19 void (*call
)(void *, const struct syscallname
*,
20 abi_long
, abi_long
, abi_long
,
21 abi_long
, abi_long
, abi_long
);
22 void (*result
)(void *, const struct syscallname
*, abi_long
,
23 abi_long
, abi_long
, abi_long
,
24 abi_long
, abi_long
, abi_long
);
29 * It is possible that target doesn't have syscall that uses
30 * following flags but we don't want the compiler to warn
31 * us about them being unused. Same applies to utility print
32 * functions. It is ok to keep them while not used.
34 #define UNUSED __attribute__ ((unused))
40 * Structure used to translate flag values into strings. This is
41 * similar that is in the actual strace tool.
44 abi_long f_value
; /* flag */
45 const char *f_string
; /* stringified flag */
48 /* common flags for all architectures */
49 #define FLAG_GENERIC(name) { name, #name }
50 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
51 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
52 /* end of flags array */
53 #define FLAG_END { 0, NULL }
55 /* Structure used to translate enumerated values into strings */
57 abi_long e_value
; /* enum value */
58 const char *e_string
; /* stringified enum */
61 /* common enums for all architectures */
62 #define ENUM_GENERIC(name) { name, #name }
63 /* target specific enums */
64 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
65 /* end of enums array */
66 #define ENUM_END { 0, NULL }
68 UNUSED
static const char *get_comma(int);
69 UNUSED
static void print_pointer(abi_long
, int);
70 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
71 UNUSED
static void print_enums(const struct enums
*, abi_long
, int);
72 UNUSED
static void print_at_dirfd(abi_long
, int);
73 UNUSED
static void print_file_mode(abi_long
, int);
74 UNUSED
static void print_open_flags(abi_long
, int);
75 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
76 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
77 UNUSED
static void print_string(abi_long
, int);
78 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
79 UNUSED
static void print_raw_param(const char *, abi_long
, int);
80 UNUSED
static void print_timeval(abi_ulong
, int);
81 UNUSED
static void print_timespec(abi_ulong
, int);
82 UNUSED
static void print_timezone(abi_ulong
, int);
83 UNUSED
static void print_itimerval(abi_ulong
, int);
84 UNUSED
static void print_number(abi_long
, int);
85 UNUSED
static void print_signal(abi_ulong
, int);
86 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
87 UNUSED
static void print_socket_domain(int domain
);
88 UNUSED
static void print_socket_type(int type
);
89 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
95 print_ipc_cmd(int cmd
)
97 #define output_cmd(val) \
105 /* General IPC commands */
106 output_cmd( IPC_RMID
);
107 output_cmd( IPC_SET
);
108 output_cmd( IPC_STAT
);
109 output_cmd( IPC_INFO
);
110 /* msgctl() commands */
111 output_cmd( MSG_STAT
);
112 output_cmd( MSG_INFO
);
113 /* shmctl() commands */
114 output_cmd( SHM_LOCK
);
115 output_cmd( SHM_UNLOCK
);
116 output_cmd( SHM_STAT
);
117 output_cmd( SHM_INFO
);
118 /* semctl() commands */
119 output_cmd( GETPID
);
120 output_cmd( GETVAL
);
121 output_cmd( GETALL
);
122 output_cmd( GETNCNT
);
123 output_cmd( GETZCNT
);
124 output_cmd( SETVAL
);
125 output_cmd( SETALL
);
126 output_cmd( SEM_STAT
);
127 output_cmd( SEM_INFO
);
128 output_cmd( IPC_RMID
);
129 output_cmd( IPC_RMID
);
130 output_cmd( IPC_RMID
);
131 output_cmd( IPC_RMID
);
132 output_cmd( IPC_RMID
);
133 output_cmd( IPC_RMID
);
134 output_cmd( IPC_RMID
);
135 output_cmd( IPC_RMID
);
136 output_cmd( IPC_RMID
);
138 /* Some value we don't recognize */
143 print_signal(abi_ulong arg
, int last
)
145 const char *signal_name
= NULL
;
147 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
148 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
149 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
150 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
151 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
152 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
153 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
154 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
155 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
156 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
157 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
158 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
159 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
160 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
161 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
162 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
163 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
164 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
166 if (signal_name
== NULL
) {
167 print_raw_param("%ld", arg
, last
);
170 qemu_log("%s%s", signal_name
, get_comma(last
));
173 static void print_si_code(int arg
)
175 const char *codename
= NULL
;
179 codename
= "SI_USER";
182 codename
= "SI_KERNEL";
185 codename
= "SI_QUEUE";
188 codename
= "SI_TIMER";
191 codename
= "SI_MESGQ";
194 codename
= "SI_ASYNCIO";
197 codename
= "SI_SIGIO";
200 codename
= "SI_TKILL";
206 qemu_log("%s", codename
);
209 static void get_target_siginfo(target_siginfo_t
*tinfo
,
210 const target_siginfo_t
*info
)
219 __get_user(sig
, &info
->si_signo
);
220 __get_user(si_errno
, &tinfo
->si_errno
);
221 __get_user(si_code
, &info
->si_code
);
223 tinfo
->si_signo
= sig
;
224 tinfo
->si_errno
= si_errno
;
225 tinfo
->si_code
= si_code
;
227 /* Ensure we don't leak random junk to the guest later */
228 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
230 /* This is awkward, because we have to use a combination of
231 * the si_code and si_signo to figure out which of the union's
232 * members are valid. (Within the host kernel it is always possible
233 * to tell, but the kernel carefully avoids giving userspace the
234 * high 16 bits of si_code, so we don't have the information to
235 * do this the easy way...) We therefore make our best guess,
236 * bearing in mind that a guest can spoof most of the si_codes
237 * via rt_sigqueueinfo() if it likes.
239 * Once we have made our guess, we record it in the top 16 bits of
240 * the si_code, so that print_siginfo() later can use it.
241 * print_siginfo() will strip these top bits out before printing
249 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
250 * These are the only unspoofable si_code values.
252 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
253 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
254 si_type
= QEMU_SI_KILL
;
257 /* Everything else is spoofable. Make best guess based on signal */
260 __get_user(tinfo
->_sifields
._sigchld
._pid
,
261 &info
->_sifields
._sigchld
._pid
);
262 __get_user(tinfo
->_sifields
._sigchld
._uid
,
263 &info
->_sifields
._sigchld
._uid
);
264 __get_user(tinfo
->_sifields
._sigchld
._status
,
265 &info
->_sifields
._sigchld
._status
);
266 __get_user(tinfo
->_sifields
._sigchld
._utime
,
267 &info
->_sifields
._sigchld
._utime
);
268 __get_user(tinfo
->_sifields
._sigchld
._stime
,
269 &info
->_sifields
._sigchld
._stime
);
270 si_type
= QEMU_SI_CHLD
;
273 __get_user(tinfo
->_sifields
._sigpoll
._band
,
274 &info
->_sifields
._sigpoll
._band
);
275 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
276 &info
->_sifields
._sigpoll
._fd
);
277 si_type
= QEMU_SI_POLL
;
280 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
281 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
282 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
283 /* XXX: potential problem if 64 bit */
284 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
285 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
287 si_type
= QEMU_SI_RT
;
293 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
296 static void print_siginfo(const target_siginfo_t
*tinfo
)
298 /* Print a target_siginfo_t in the format desired for printing
299 * signals being taken. We assume the target_siginfo_t is in the
300 * internal form where the top 16 bits of si_code indicate which
301 * part of the union is valid, rather than in the guest-visible
302 * form where the bottom 16 bits are sign-extended into the top 16.
304 int si_type
= extract32(tinfo
->si_code
, 16, 16);
305 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
307 qemu_log("{si_signo=");
308 print_signal(tinfo
->si_signo
, 1);
309 qemu_log(", si_code=");
310 print_si_code(si_code
);
314 qemu_log(", si_pid=%u, si_uid=%u",
315 (unsigned int)tinfo
->_sifields
._kill
._pid
,
316 (unsigned int)tinfo
->_sifields
._kill
._uid
);
319 qemu_log(", si_timer1=%u, si_timer2=%u",
320 tinfo
->_sifields
._timer
._timer1
,
321 tinfo
->_sifields
._timer
._timer2
);
324 qemu_log(", si_band=%d, si_fd=%d",
325 tinfo
->_sifields
._sigpoll
._band
,
326 tinfo
->_sifields
._sigpoll
._fd
);
329 qemu_log(", si_addr=");
330 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
333 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
334 ", si_utime=" TARGET_ABI_FMT_ld
335 ", si_stime=" TARGET_ABI_FMT_ld
,
336 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
337 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
338 tinfo
->_sifields
._sigchld
._status
,
339 tinfo
->_sifields
._sigchld
._utime
,
340 tinfo
->_sifields
._sigchld
._stime
);
343 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
344 (unsigned int)tinfo
->_sifields
._rt
._pid
,
345 (unsigned int)tinfo
->_sifields
._rt
._uid
,
346 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
349 g_assert_not_reached();
355 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
357 struct target_sockaddr
*sa
;
361 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
363 sa_family
= tswap16(sa
->sa_family
);
366 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
368 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
369 for (i
= 0; i
< addrlen
-
370 offsetof(struct target_sockaddr_un
, sun_path
) &&
371 un
->sun_path
[i
]; i
++) {
372 qemu_log("%c", un
->sun_path
[i
]);
378 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
379 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
380 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
381 ntohs(in
->sin_port
));
382 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
383 c
[0], c
[1], c
[2], c
[3]);
388 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
389 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
390 qemu_log("{sll_family=AF_PACKET,"
391 "sll_protocol=htons(0x%04x),if%d,pkttype=",
392 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
393 switch (ll
->sll_pkttype
) {
395 qemu_log("PACKET_HOST");
397 case PACKET_BROADCAST
:
398 qemu_log("PACKET_BROADCAST");
400 case PACKET_MULTICAST
:
401 qemu_log("PACKET_MULTICAST");
403 case PACKET_OTHERHOST
:
404 qemu_log("PACKET_OTHERHOST");
406 case PACKET_OUTGOING
:
407 qemu_log("PACKET_OUTGOING");
410 qemu_log("%d", ll
->sll_pkttype
);
413 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
414 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
419 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
420 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
421 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
425 qemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
426 for (i
= 0; i
< 13; i
++) {
427 qemu_log("%02x, ", sa
->sa_data
[i
]);
429 qemu_log("%02x}", sa
->sa_data
[i
]);
433 unlock_user(sa
, addr
, 0);
435 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
437 qemu_log(", "TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
441 print_socket_domain(int domain
)
451 qemu_log("PF_NETLINK");
454 qemu_log("PF_PACKET");
457 qemu_log("%d", domain
);
463 print_socket_type(int type
)
465 switch (type
& TARGET_SOCK_TYPE_MASK
) {
466 case TARGET_SOCK_DGRAM
:
467 qemu_log("SOCK_DGRAM");
469 case TARGET_SOCK_STREAM
:
470 qemu_log("SOCK_STREAM");
472 case TARGET_SOCK_RAW
:
473 qemu_log("SOCK_RAW");
475 case TARGET_SOCK_RDM
:
476 qemu_log("SOCK_RDM");
478 case TARGET_SOCK_SEQPACKET
:
479 qemu_log("SOCK_SEQPACKET");
481 case TARGET_SOCK_PACKET
:
482 qemu_log("SOCK_PACKET");
485 if (type
& TARGET_SOCK_CLOEXEC
) {
486 qemu_log("|SOCK_CLOEXEC");
488 if (type
& TARGET_SOCK_NONBLOCK
) {
489 qemu_log("|SOCK_NONBLOCK");
494 print_socket_protocol(int domain
, int type
, int protocol
)
496 if (domain
== AF_PACKET
||
497 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
500 qemu_log("ETH_P_ALL");
503 qemu_log("%d", protocol
);
508 if (domain
== PF_NETLINK
) {
511 qemu_log("NETLINK_ROUTE");
514 qemu_log("NETLINK_AUDIT");
516 case NETLINK_NETFILTER
:
517 qemu_log("NETLINK_NETFILTER");
519 case NETLINK_KOBJECT_UEVENT
:
520 qemu_log("NETLINK_KOBJECT_UEVENT");
523 qemu_log("NETLINK_RDMA");
526 qemu_log("NETLINK_CRYPTO");
529 qemu_log("%d", protocol
);
537 qemu_log("IPPROTO_IP");
540 qemu_log("IPPROTO_TCP");
543 qemu_log("IPPROTO_UDP");
546 qemu_log("IPPROTO_RAW");
549 qemu_log("%d", protocol
);
555 #ifdef TARGET_NR__newselect
557 print_fdset(int n
, abi_ulong target_fds_addr
)
563 if( target_fds_addr
) {
564 abi_long
*target_fds
;
566 target_fds
= lock_user(VERIFY_READ
,
568 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
574 for (i
=n
; i
>=0; i
--) {
575 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >>
576 (i
& (TARGET_ABI_BITS
- 1))) & 1) {
577 qemu_log("%s%d", get_comma(first
), i
);
581 unlock_user(target_fds
, target_fds_addr
, 0);
588 * Sysycall specific output functions
592 #ifdef TARGET_NR__newselect
594 print_newselect(void *cpu_env
, const struct syscallname
*name
,
595 abi_long arg1
, abi_long arg2
, abi_long arg3
,
596 abi_long arg4
, abi_long arg5
, abi_long arg6
)
598 print_syscall_prologue(name
);
599 print_fdset(arg1
, arg2
);
601 print_fdset(arg1
, arg3
);
603 print_fdset(arg1
, arg4
);
605 print_timeval(arg5
, 1);
606 print_syscall_epilogue(name
);
610 #ifdef TARGET_NR_semctl
612 print_semctl(void *cpu_env
, const struct syscallname
*name
,
613 abi_long arg1
, abi_long arg2
, abi_long arg3
,
614 abi_long arg4
, abi_long arg5
, abi_long arg6
)
616 qemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
617 name
->name
, arg1
, arg2
);
619 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
624 print_execve(void *cpu_env
, const struct syscallname
*name
,
625 abi_long arg1
, abi_long arg2
, abi_long arg3
,
626 abi_long arg4
, abi_long arg5
, abi_long arg6
)
628 abi_ulong arg_ptr_addr
;
631 if (!(s
= lock_user_string(arg1
)))
633 qemu_log("%s(\"%s\",{", name
->name
, s
);
634 unlock_user(s
, arg1
, 0);
636 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
637 abi_ulong
*arg_ptr
, arg_addr
;
639 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
642 arg_addr
= tswapal(*arg_ptr
);
643 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
646 if ((s
= lock_user_string(arg_addr
))) {
647 qemu_log("\"%s\",", s
);
648 unlock_user(s
, arg_addr
, 0);
657 print_ipc(void *cpu_env
, const struct syscallname
*name
,
658 abi_long arg1
, abi_long arg2
, abi_long arg3
,
659 abi_long arg4
, abi_long arg5
, abi_long arg6
)
663 qemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
666 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
670 TARGET_ABI_FMT_ld
","
671 TARGET_ABI_FMT_ld
","
672 TARGET_ABI_FMT_ld
","
675 name
->name
, arg1
, arg2
, arg3
, arg4
);
681 * Variants for the return value output function
685 print_syscall_err(abi_long ret
)
691 errstr
= target_strerror(-ret
);
693 qemu_log("-1 errno=%d (%s)", (int)-ret
, errstr
);
701 print_syscall_ret_addr(void *cpu_env
, const struct syscallname
*name
,
702 abi_long ret
, abi_long arg0
, abi_long arg1
,
703 abi_long arg2
, abi_long arg3
, abi_long arg4
,
706 if (!print_syscall_err(ret
)) {
707 qemu_log("0x" TARGET_ABI_FMT_lx
, ret
);
712 #if 0 /* currently unused */
714 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
716 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
720 #ifdef TARGET_NR__newselect
722 print_syscall_ret_newselect(void *cpu_env
, const struct syscallname
*name
,
723 abi_long ret
, abi_long arg0
, abi_long arg1
,
724 abi_long arg2
, abi_long arg3
, abi_long arg4
,
727 if (!print_syscall_err(ret
)) {
728 qemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
729 print_fdset(arg0
, arg1
);
731 print_fdset(arg0
, arg2
);
733 print_fdset(arg0
, arg3
);
735 print_timeval(arg4
, 1);
743 /* special meanings of adjtimex()' non-negative return values */
744 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
745 #define TARGET_TIME_INS 1 /* insert leap second */
746 #define TARGET_TIME_DEL 2 /* delete leap second */
747 #define TARGET_TIME_OOP 3 /* leap second in progress */
748 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
749 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
750 #ifdef TARGET_NR_adjtimex
752 print_syscall_ret_adjtimex(void *cpu_env
, const struct syscallname
*name
,
753 abi_long ret
, abi_long arg0
, abi_long arg1
,
754 abi_long arg2
, abi_long arg3
, abi_long arg4
,
757 if (!print_syscall_err(ret
)) {
758 qemu_log(TARGET_ABI_FMT_ld
, ret
);
761 qemu_log(" TIME_OK (clock synchronized, no leap second)");
763 case TARGET_TIME_INS
:
764 qemu_log(" TIME_INS (insert leap second)");
766 case TARGET_TIME_DEL
:
767 qemu_log(" TIME_DEL (delete leap second)");
769 case TARGET_TIME_OOP
:
770 qemu_log(" TIME_OOP (leap second in progress)");
772 case TARGET_TIME_WAIT
:
773 qemu_log(" TIME_WAIT (leap second has occurred)");
775 case TARGET_TIME_ERROR
:
776 qemu_log(" TIME_ERROR (clock not synchronized)");
785 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
787 print_syscall_ret_clock_gettime(void *cpu_env
, const struct syscallname
*name
,
788 abi_long ret
, abi_long arg0
, abi_long arg1
,
789 abi_long arg2
, abi_long arg3
, abi_long arg4
,
792 if (!print_syscall_err(ret
)) {
793 qemu_log(TARGET_ABI_FMT_ld
, ret
);
795 print_timespec(arg1
, 1);
801 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
804 #ifdef TARGET_NR_gettimeofday
806 print_syscall_ret_gettimeofday(void *cpu_env
, const struct syscallname
*name
,
807 abi_long ret
, abi_long arg0
, abi_long arg1
,
808 abi_long arg2
, abi_long arg3
, abi_long arg4
,
811 if (!print_syscall_err(ret
)) {
812 qemu_log(TARGET_ABI_FMT_ld
, ret
);
814 print_timeval(arg0
, 0);
815 print_timezone(arg1
, 1);
823 #ifdef TARGET_NR_getitimer
825 print_syscall_ret_getitimer(void *cpu_env
, const struct syscallname
*name
,
826 abi_long ret
, abi_long arg0
, abi_long arg1
,
827 abi_long arg2
, abi_long arg3
, abi_long arg4
,
830 if (!print_syscall_err(ret
)) {
831 qemu_log(TARGET_ABI_FMT_ld
, ret
);
833 print_itimerval(arg1
, 1);
842 #ifdef TARGET_NR_getitimer
844 print_syscall_ret_setitimer(void *cpu_env
, const struct syscallname
*name
,
845 abi_long ret
, abi_long arg0
, abi_long arg1
,
846 abi_long arg2
, abi_long arg3
, abi_long arg4
,
849 if (!print_syscall_err(ret
)) {
850 qemu_log(TARGET_ABI_FMT_ld
, ret
);
851 qemu_log(" (old_value = ");
852 print_itimerval(arg2
, 1);
860 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
861 || defined(TARGGET_NR_flistxattr)
863 print_syscall_ret_listxattr(void *cpu_env
, const struct syscallname
*name
,
864 abi_long ret
, abi_long arg0
, abi_long arg1
,
865 abi_long arg2
, abi_long arg3
, abi_long arg4
,
868 if (!print_syscall_err(ret
)) {
869 qemu_log(TARGET_ABI_FMT_ld
, ret
);
870 qemu_log(" (list = ");
872 abi_long attr
= arg1
;
877 print_string(attr
, 1);
878 ret
-= target_strlen(attr
) + 1;
879 attr
+= target_strlen(attr
) + 1;
889 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
890 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
893 #ifdef TARGET_NR_ioctl
895 print_syscall_ret_ioctl(void *cpu_env
, const struct syscallname
*name
,
896 abi_long ret
, abi_long arg0
, abi_long arg1
,
897 abi_long arg2
, abi_long arg3
, abi_long arg4
,
900 if (!print_syscall_err(ret
)) {
901 qemu_log(TARGET_ABI_FMT_ld
, ret
);
903 const IOCTLEntry
*ie
;
904 const argtype
*arg_type
;
908 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
909 if (ie
->target_cmd
== arg1
) {
914 if (ie
->target_cmd
== arg1
&&
915 (ie
->access
== IOC_R
|| ie
->access
== IOC_RW
)) {
916 arg_type
= ie
->arg_type
;
919 target_size
= thunk_type_size(arg_type
, 0);
920 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
922 thunk_print(argptr
, arg_type
);
923 unlock_user(argptr
, arg2
, target_size
);
925 print_pointer(arg2
, 1);
934 UNUSED
static struct flags access_flags
[] = {
942 UNUSED
static struct flags at_file_flags
[] = {
944 FLAG_GENERIC(AT_EACCESS
),
946 #ifdef AT_SYMLINK_NOFOLLOW
947 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
952 UNUSED
static struct flags unlinkat_flags
[] = {
954 FLAG_GENERIC(AT_REMOVEDIR
),
959 UNUSED
static struct flags mode_flags
[] = {
960 FLAG_GENERIC(S_IFSOCK
),
961 FLAG_GENERIC(S_IFLNK
),
962 FLAG_GENERIC(S_IFREG
),
963 FLAG_GENERIC(S_IFBLK
),
964 FLAG_GENERIC(S_IFDIR
),
965 FLAG_GENERIC(S_IFCHR
),
966 FLAG_GENERIC(S_IFIFO
),
970 UNUSED
static struct flags open_access_flags
[] = {
971 FLAG_TARGET(O_RDONLY
),
972 FLAG_TARGET(O_WRONLY
),
977 UNUSED
static struct flags open_flags
[] = {
978 FLAG_TARGET(O_APPEND
),
979 FLAG_TARGET(O_CREAT
),
980 FLAG_TARGET(O_DIRECTORY
),
982 FLAG_TARGET(O_LARGEFILE
),
983 FLAG_TARGET(O_NOCTTY
),
984 FLAG_TARGET(O_NOFOLLOW
),
985 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
986 FLAG_TARGET(O_DSYNC
),
987 FLAG_TARGET(__O_SYNC
),
988 FLAG_TARGET(O_TRUNC
),
990 FLAG_TARGET(O_DIRECT
),
993 FLAG_TARGET(O_NOATIME
),
996 FLAG_TARGET(O_CLOEXEC
),
1002 FLAG_TARGET(O_TMPFILE
),
1003 FLAG_TARGET(__O_TMPFILE
),
1008 UNUSED
static struct flags mount_flags
[] = {
1010 FLAG_GENERIC(MS_BIND
),
1013 FLAG_GENERIC(MS_DIRSYNC
),
1015 FLAG_GENERIC(MS_MANDLOCK
),
1017 FLAG_GENERIC(MS_MOVE
),
1019 FLAG_GENERIC(MS_NOATIME
),
1020 FLAG_GENERIC(MS_NODEV
),
1021 FLAG_GENERIC(MS_NODIRATIME
),
1022 FLAG_GENERIC(MS_NOEXEC
),
1023 FLAG_GENERIC(MS_NOSUID
),
1024 FLAG_GENERIC(MS_RDONLY
),
1026 FLAG_GENERIC(MS_RELATIME
),
1028 FLAG_GENERIC(MS_REMOUNT
),
1029 FLAG_GENERIC(MS_SYNCHRONOUS
),
1033 UNUSED
static struct flags umount2_flags
[] = {
1035 FLAG_GENERIC(MNT_FORCE
),
1038 FLAG_GENERIC(MNT_DETACH
),
1041 FLAG_GENERIC(MNT_EXPIRE
),
1046 UNUSED
static struct flags mmap_prot_flags
[] = {
1047 FLAG_GENERIC(PROT_NONE
),
1048 FLAG_GENERIC(PROT_EXEC
),
1049 FLAG_GENERIC(PROT_READ
),
1050 FLAG_GENERIC(PROT_WRITE
),
1051 FLAG_TARGET(PROT_SEM
),
1052 FLAG_GENERIC(PROT_GROWSDOWN
),
1053 FLAG_GENERIC(PROT_GROWSUP
),
1057 UNUSED
static struct flags mmap_flags
[] = {
1058 FLAG_TARGET(MAP_SHARED
),
1059 FLAG_TARGET(MAP_PRIVATE
),
1060 FLAG_TARGET(MAP_ANONYMOUS
),
1061 FLAG_TARGET(MAP_DENYWRITE
),
1062 FLAG_TARGET(MAP_FIXED
),
1063 FLAG_TARGET(MAP_GROWSDOWN
),
1064 FLAG_TARGET(MAP_EXECUTABLE
),
1066 FLAG_TARGET(MAP_LOCKED
),
1069 FLAG_TARGET(MAP_NONBLOCK
),
1071 FLAG_TARGET(MAP_NORESERVE
),
1073 FLAG_TARGET(MAP_POPULATE
),
1075 #ifdef TARGET_MAP_UNINITIALIZED
1076 FLAG_TARGET(MAP_UNINITIALIZED
),
1081 UNUSED
static struct flags clone_flags
[] = {
1082 FLAG_GENERIC(CLONE_VM
),
1083 FLAG_GENERIC(CLONE_FS
),
1084 FLAG_GENERIC(CLONE_FILES
),
1085 FLAG_GENERIC(CLONE_SIGHAND
),
1086 FLAG_GENERIC(CLONE_PTRACE
),
1087 FLAG_GENERIC(CLONE_VFORK
),
1088 FLAG_GENERIC(CLONE_PARENT
),
1089 FLAG_GENERIC(CLONE_THREAD
),
1090 FLAG_GENERIC(CLONE_NEWNS
),
1091 FLAG_GENERIC(CLONE_SYSVSEM
),
1092 FLAG_GENERIC(CLONE_SETTLS
),
1093 FLAG_GENERIC(CLONE_PARENT_SETTID
),
1094 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
1095 FLAG_GENERIC(CLONE_DETACHED
),
1096 FLAG_GENERIC(CLONE_UNTRACED
),
1097 FLAG_GENERIC(CLONE_CHILD_SETTID
),
1098 #if defined(CLONE_NEWUTS)
1099 FLAG_GENERIC(CLONE_NEWUTS
),
1101 #if defined(CLONE_NEWIPC)
1102 FLAG_GENERIC(CLONE_NEWIPC
),
1104 #if defined(CLONE_NEWUSER)
1105 FLAG_GENERIC(CLONE_NEWUSER
),
1107 #if defined(CLONE_NEWPID)
1108 FLAG_GENERIC(CLONE_NEWPID
),
1110 #if defined(CLONE_NEWNET)
1111 FLAG_GENERIC(CLONE_NEWNET
),
1113 #if defined(CLONE_IO)
1114 FLAG_GENERIC(CLONE_IO
),
1119 UNUSED
static struct flags msg_flags
[] = {
1121 FLAG_GENERIC(MSG_CONFIRM
),
1122 FLAG_GENERIC(MSG_DONTROUTE
),
1123 FLAG_GENERIC(MSG_DONTWAIT
),
1124 FLAG_GENERIC(MSG_EOR
),
1125 FLAG_GENERIC(MSG_MORE
),
1126 FLAG_GENERIC(MSG_NOSIGNAL
),
1127 FLAG_GENERIC(MSG_OOB
),
1129 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1130 FLAG_GENERIC(MSG_ERRQUEUE
),
1131 FLAG_GENERIC(MSG_PEEK
),
1132 FLAG_GENERIC(MSG_TRUNC
),
1133 FLAG_GENERIC(MSG_WAITALL
),
1135 FLAG_GENERIC(MSG_CTRUNC
),
1139 UNUSED
static struct flags statx_flags
[] = {
1140 #ifdef AT_EMPTY_PATH
1141 FLAG_GENERIC(AT_EMPTY_PATH
),
1143 #ifdef AT_NO_AUTOMOUNT
1144 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1146 #ifdef AT_SYMLINK_NOFOLLOW
1147 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1149 #ifdef AT_STATX_SYNC_AS_STAT
1150 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT
),
1152 #ifdef AT_STATX_FORCE_SYNC
1153 FLAG_GENERIC(AT_STATX_FORCE_SYNC
),
1155 #ifdef AT_STATX_DONT_SYNC
1156 FLAG_GENERIC(AT_STATX_DONT_SYNC
),
1161 UNUSED
static struct flags statx_mask
[] = {
1162 /* This must come first, because it includes everything. */
1164 FLAG_GENERIC(STATX_ALL
),
1166 /* This must come second; it includes everything except STATX_BTIME. */
1167 #ifdef STATX_BASIC_STATS
1168 FLAG_GENERIC(STATX_BASIC_STATS
),
1171 FLAG_GENERIC(STATX_TYPE
),
1174 FLAG_GENERIC(STATX_MODE
),
1177 FLAG_GENERIC(STATX_NLINK
),
1180 FLAG_GENERIC(STATX_UID
),
1183 FLAG_GENERIC(STATX_GID
),
1186 FLAG_GENERIC(STATX_ATIME
),
1189 FLAG_GENERIC(STATX_MTIME
),
1192 FLAG_GENERIC(STATX_CTIME
),
1195 FLAG_GENERIC(STATX_INO
),
1198 FLAG_GENERIC(STATX_SIZE
),
1201 FLAG_GENERIC(STATX_BLOCKS
),
1204 FLAG_GENERIC(STATX_BTIME
),
1209 UNUSED
static struct flags falloc_flags
[] = {
1210 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE
),
1211 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE
),
1212 #ifdef FALLOC_FL_NO_HIDE_STALE
1213 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE
),
1215 #ifdef FALLOC_FL_COLLAPSE_RANGE
1216 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE
),
1218 #ifdef FALLOC_FL_ZERO_RANGE
1219 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE
),
1221 #ifdef FALLOC_FL_INSERT_RANGE
1222 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE
),
1224 #ifdef FALLOC_FL_UNSHARE_RANGE
1225 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE
),
1229 UNUSED
static struct flags termios_iflags
[] = {
1230 FLAG_TARGET(IGNBRK
),
1231 FLAG_TARGET(BRKINT
),
1232 FLAG_TARGET(IGNPAR
),
1233 FLAG_TARGET(PARMRK
),
1235 FLAG_TARGET(ISTRIP
),
1243 FLAG_TARGET(IMAXBEL
),
1248 UNUSED
static struct flags termios_oflags
[] = {
1254 FLAG_TARGET(ONLRET
),
1260 UNUSED
static struct enums termios_oflags_NLDLY
[] = {
1266 UNUSED
static struct enums termios_oflags_CRDLY
[] = {
1274 UNUSED
static struct enums termios_oflags_TABDLY
[] = {
1282 UNUSED
static struct enums termios_oflags_VTDLY
[] = {
1288 UNUSED
static struct enums termios_oflags_FFDLY
[] = {
1294 UNUSED
static struct enums termios_oflags_BSDLY
[] = {
1300 UNUSED
static struct enums termios_cflags_CBAUD
[] = {
1315 ENUM_TARGET(B19200
),
1316 ENUM_TARGET(B38400
),
1317 ENUM_TARGET(B57600
),
1318 ENUM_TARGET(B115200
),
1319 ENUM_TARGET(B230400
),
1320 ENUM_TARGET(B460800
),
1324 UNUSED
static struct enums termios_cflags_CSIZE
[] = {
1332 UNUSED
static struct flags termios_cflags
[] = {
1333 FLAG_TARGET(CSTOPB
),
1335 FLAG_TARGET(PARENB
),
1336 FLAG_TARGET(PARODD
),
1338 FLAG_TARGET(CLOCAL
),
1339 FLAG_TARGET(CRTSCTS
),
1343 UNUSED
static struct flags termios_lflags
[] = {
1345 FLAG_TARGET(ICANON
),
1350 FLAG_TARGET(ECHONL
),
1351 FLAG_TARGET(NOFLSH
),
1352 FLAG_TARGET(TOSTOP
),
1353 FLAG_TARGET(ECHOCTL
),
1354 FLAG_TARGET(ECHOPRT
),
1355 FLAG_TARGET(ECHOKE
),
1356 FLAG_TARGET(FLUSHO
),
1357 FLAG_TARGET(PENDIN
),
1358 FLAG_TARGET(IEXTEN
),
1359 FLAG_TARGET(EXTPROC
),
1363 UNUSED
static struct flags mlockall_flags
[] = {
1364 FLAG_TARGET(MCL_CURRENT
),
1365 FLAG_TARGET(MCL_FUTURE
),
1367 FLAG_TARGET(MCL_ONFAULT
),
1372 /* IDs of the various system clocks */
1373 #define TARGET_CLOCK_REALTIME 0
1374 #define TARGET_CLOCK_MONOTONIC 1
1375 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1376 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1377 #define TARGET_CLOCK_MONOTONIC_RAW 4
1378 #define TARGET_CLOCK_REALTIME_COARSE 5
1379 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1380 #define TARGET_CLOCK_BOOTTIME 7
1381 #define TARGET_CLOCK_REALTIME_ALARM 8
1382 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1383 #define TARGET_CLOCK_SGI_CYCLE 10
1384 #define TARGET_CLOCK_TAI 11
1386 UNUSED
static struct enums clockids
[] = {
1387 ENUM_TARGET(CLOCK_REALTIME
),
1388 ENUM_TARGET(CLOCK_MONOTONIC
),
1389 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID
),
1390 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID
),
1391 ENUM_TARGET(CLOCK_MONOTONIC_RAW
),
1392 ENUM_TARGET(CLOCK_REALTIME_COARSE
),
1393 ENUM_TARGET(CLOCK_MONOTONIC_COARSE
),
1394 ENUM_TARGET(CLOCK_BOOTTIME
),
1395 ENUM_TARGET(CLOCK_REALTIME_ALARM
),
1396 ENUM_TARGET(CLOCK_BOOTTIME_ALARM
),
1397 ENUM_TARGET(CLOCK_SGI_CYCLE
),
1398 ENUM_TARGET(CLOCK_TAI
),
1402 UNUSED
static struct enums itimer_types
[] = {
1403 ENUM_GENERIC(ITIMER_REAL
),
1404 ENUM_GENERIC(ITIMER_VIRTUAL
),
1405 ENUM_GENERIC(ITIMER_PROF
),
1410 * print_xxx utility functions. These are used to print syscall
1411 * parameters in certain format. All of these have parameter
1412 * named 'last'. This parameter is used to add comma to output
1419 return ((last
) ? "" : ",");
1423 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1425 const char *sep
= "";
1428 if ((flags
== 0) && (f
->f_value
== 0)) {
1429 qemu_log("%s%s", f
->f_string
, get_comma(last
));
1432 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1433 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1434 qemu_log("%s%s", sep
, f
->f_string
);
1435 flags
&= ~f
->f_value
;
1442 /* print rest of the flags as numeric */
1444 qemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1446 qemu_log("%s", get_comma(last
));
1449 /* no string version of flags found, print them in hex then */
1450 qemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1455 print_enums(const struct enums
*e
, abi_long enum_arg
, int last
)
1457 for (; e
->e_string
!= NULL
; e
++) {
1458 if (e
->e_value
== enum_arg
) {
1459 qemu_log("%s", e
->e_string
);
1464 if (e
->e_string
== NULL
) {
1465 qemu_log("%#x", (unsigned int)enum_arg
);
1468 qemu_log("%s", get_comma(last
));
1472 print_at_dirfd(abi_long dirfd
, int last
)
1475 if (dirfd
== AT_FDCWD
) {
1476 qemu_log("AT_FDCWD%s", get_comma(last
));
1480 qemu_log("%d%s", (int)dirfd
, get_comma(last
));
1484 print_file_mode(abi_long mode
, int last
)
1486 const char *sep
= "";
1487 const struct flags
*m
;
1489 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1490 if ((m
->f_value
& mode
) == m
->f_value
) {
1491 qemu_log("%s%s", m
->f_string
, sep
);
1493 mode
&= ~m
->f_value
;
1499 /* print rest of the mode as octal */
1501 qemu_log("%s%#o", sep
, (unsigned int)mode
);
1503 qemu_log("%s", get_comma(last
));
1507 print_open_flags(abi_long flags
, int last
)
1509 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1510 flags
&= ~TARGET_O_ACCMODE
;
1512 qemu_log("%s", get_comma(last
));
1516 print_flags(open_flags
, flags
, last
);
1520 print_syscall_prologue(const struct syscallname
*sc
)
1522 qemu_log("%s(", sc
->name
);
1527 print_syscall_epilogue(const struct syscallname
*sc
)
1534 print_string(abi_long addr
, int last
)
1538 if ((s
= lock_user_string(addr
)) != NULL
) {
1539 qemu_log("\"%s\"%s", s
, get_comma(last
));
1540 unlock_user(s
, addr
, 0);
1542 /* can't get string out of it, so print it as pointer */
1543 print_pointer(addr
, last
);
1547 #define MAX_PRINT_BUF 40
1549 print_buf(abi_long addr
, abi_long len
, int last
)
1554 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1557 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1558 if (isprint(s
[i
])) {
1559 qemu_log("%c", s
[i
]);
1561 qemu_log("\\%o", s
[i
]);
1571 unlock_user(s
, addr
, 0);
1573 print_pointer(addr
, last
);
1578 * Prints out raw parameter using given format. Caller needs
1579 * to do byte swapping if needed.
1582 print_raw_param(const char *fmt
, abi_long param
, int last
)
1586 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1587 qemu_log(format
, param
);
1591 print_pointer(abi_long p
, int last
)
1594 qemu_log("NULL%s", get_comma(last
));
1596 qemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1600 * Reads 32-bit (int) number from guest address space from
1601 * address 'addr' and prints it.
1604 print_number(abi_long addr
, int last
)
1607 qemu_log("NULL%s", get_comma(last
));
1611 get_user_s32(num
, addr
);
1612 qemu_log("[%d]%s", num
, get_comma(last
));
1617 print_timeval(abi_ulong tv_addr
, int last
)
1620 struct target_timeval
*tv
;
1622 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1624 print_pointer(tv_addr
, last
);
1627 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1628 ",tv_usec = " TARGET_ABI_FMT_ld
"}%s",
1629 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1630 unlock_user(tv
, tv_addr
, 0);
1632 qemu_log("NULL%s", get_comma(last
));
1636 print_timespec(abi_ulong ts_addr
, int last
)
1639 struct target_timespec
*ts
;
1641 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1643 print_pointer(ts_addr
, last
);
1646 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1647 ",tv_nsec = " TARGET_ABI_FMT_ld
"}%s",
1648 tswapal(ts
->tv_sec
), tswapal(ts
->tv_nsec
), get_comma(last
));
1649 unlock_user(ts
, ts_addr
, 0);
1651 qemu_log("NULL%s", get_comma(last
));
1656 print_timezone(abi_ulong tz_addr
, int last
)
1659 struct target_timezone
*tz
;
1661 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1663 print_pointer(tz_addr
, last
);
1666 qemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1667 tswap32(tz
->tz_dsttime
), get_comma(last
));
1668 unlock_user(tz
, tz_addr
, 0);
1670 qemu_log("NULL%s", get_comma(last
));
1675 print_itimerval(abi_ulong it_addr
, int last
)
1678 qemu_log("{it_interval=");
1679 print_timeval(it_addr
+
1680 offsetof(struct target_itimerval
, it_interval
), 0);
1681 qemu_log("it_value=");
1682 print_timeval(it_addr
+
1683 offsetof(struct target_itimerval
, it_value
), 0);
1684 qemu_log("}%s", get_comma(last
));
1686 qemu_log("NULL%s", get_comma(last
));
1691 print_termios(void *arg
)
1693 const struct target_termios
*target
= arg
;
1695 target_tcflag_t iflags
= tswap32(target
->c_iflag
);
1696 target_tcflag_t oflags
= tswap32(target
->c_oflag
);
1697 target_tcflag_t cflags
= tswap32(target
->c_cflag
);
1698 target_tcflag_t lflags
= tswap32(target
->c_lflag
);
1702 qemu_log("c_iflag = ");
1703 print_flags(termios_iflags
, iflags
, 0);
1705 qemu_log("c_oflag = ");
1706 target_tcflag_t oflags_clean
= oflags
& ~(TARGET_NLDLY
| TARGET_CRDLY
|
1707 TARGET_TABDLY
| TARGET_BSDLY
|
1708 TARGET_VTDLY
| TARGET_FFDLY
);
1709 print_flags(termios_oflags
, oflags_clean
, 0);
1710 if (oflags
& TARGET_NLDLY
) {
1711 print_enums(termios_oflags_NLDLY
, oflags
& TARGET_NLDLY
, 0);
1713 if (oflags
& TARGET_CRDLY
) {
1714 print_enums(termios_oflags_CRDLY
, oflags
& TARGET_CRDLY
, 0);
1716 if (oflags
& TARGET_TABDLY
) {
1717 print_enums(termios_oflags_TABDLY
, oflags
& TARGET_TABDLY
, 0);
1719 if (oflags
& TARGET_BSDLY
) {
1720 print_enums(termios_oflags_BSDLY
, oflags
& TARGET_BSDLY
, 0);
1722 if (oflags
& TARGET_VTDLY
) {
1723 print_enums(termios_oflags_VTDLY
, oflags
& TARGET_VTDLY
, 0);
1725 if (oflags
& TARGET_FFDLY
) {
1726 print_enums(termios_oflags_FFDLY
, oflags
& TARGET_FFDLY
, 0);
1729 qemu_log("c_cflag = ");
1730 if (cflags
& TARGET_CBAUD
) {
1731 print_enums(termios_cflags_CBAUD
, cflags
& TARGET_CBAUD
, 0);
1733 if (cflags
& TARGET_CSIZE
) {
1734 print_enums(termios_cflags_CSIZE
, cflags
& TARGET_CSIZE
, 0);
1736 target_tcflag_t cflags_clean
= cflags
& ~(TARGET_CBAUD
| TARGET_CSIZE
);
1737 print_flags(termios_cflags
, cflags_clean
, 0);
1739 qemu_log("c_lflag = ");
1740 print_flags(termios_lflags
, lflags
, 0);
1742 qemu_log("c_cc = ");
1743 qemu_log("\"%s\",", target
->c_cc
);
1745 qemu_log("c_line = ");
1746 print_raw_param("\'%c\'", target
->c_line
, 1);
1753 #ifdef TARGET_NR_accept
1755 print_accept(void *cpu_env
, const struct syscallname
*name
,
1756 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1757 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1759 print_syscall_prologue(name
);
1760 print_raw_param("%d", arg0
, 0);
1761 print_pointer(arg1
, 0);
1762 print_number(arg2
, 1);
1763 print_syscall_epilogue(name
);
1767 #ifdef TARGET_NR_access
1769 print_access(void *cpu_env
, const struct syscallname
*name
,
1770 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1771 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1773 print_syscall_prologue(name
);
1774 print_string(arg0
, 0);
1775 print_flags(access_flags
, arg1
, 1);
1776 print_syscall_epilogue(name
);
1780 #ifdef TARGET_NR_acct
1782 print_acct(void *cpu_env
, const struct syscallname
*name
,
1783 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1784 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1786 print_syscall_prologue(name
);
1787 print_string(arg0
, 1);
1788 print_syscall_epilogue(name
);
1792 #ifdef TARGET_NR_brk
1794 print_brk(void *cpu_env
, const struct syscallname
*name
,
1795 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1796 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1798 print_syscall_prologue(name
);
1799 print_pointer(arg0
, 1);
1800 print_syscall_epilogue(name
);
1804 #ifdef TARGET_NR_chdir
1806 print_chdir(void *cpu_env
, const struct syscallname
*name
,
1807 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1808 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1810 print_syscall_prologue(name
);
1811 print_string(arg0
, 1);
1812 print_syscall_epilogue(name
);
1816 #ifdef TARGET_NR_chroot
1818 print_chroot(void *cpu_env
, const struct syscallname
*name
,
1819 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1820 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1822 print_syscall_prologue(name
);
1823 print_string(arg0
, 1);
1824 print_syscall_epilogue(name
);
1828 #ifdef TARGET_NR_chmod
1830 print_chmod(void *cpu_env
, const struct syscallname
*name
,
1831 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1832 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1834 print_syscall_prologue(name
);
1835 print_string(arg0
, 0);
1836 print_file_mode(arg1
, 1);
1837 print_syscall_epilogue(name
);
1841 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1843 print_chown(void *cpu_env
, const struct syscallname
*name
,
1844 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1845 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1847 print_syscall_prologue(name
);
1848 print_string(arg0
, 0);
1849 print_raw_param("%d", arg1
, 0);
1850 print_raw_param("%d", arg2
, 1);
1851 print_syscall_epilogue(name
);
1853 #define print_lchown print_chown
1856 #ifdef TARGET_NR_clock_adjtime
1858 print_clock_adjtime(void *cpu_env
, const struct syscallname
*name
,
1859 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1860 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1862 print_syscall_prologue(name
);
1863 print_enums(clockids
, arg0
, 0);
1864 print_pointer(arg1
, 1);
1865 print_syscall_epilogue(name
);
1869 #ifdef TARGET_NR_clone
1870 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1871 abi_ulong parent_tidptr
, target_ulong newtls
,
1872 abi_ulong child_tidptr
)
1874 print_flags(clone_flags
, flags
, 0);
1875 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1876 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1877 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1878 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1882 print_clone(void *cpu_env
, const struct syscallname
*name
,
1883 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1884 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1886 print_syscall_prologue(name
);
1887 #if defined(TARGET_MICROBLAZE)
1888 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1889 #elif defined(TARGET_CLONE_BACKWARDS)
1890 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1891 #elif defined(TARGET_CLONE_BACKWARDS2)
1892 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1894 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1896 print_syscall_epilogue(name
);
1900 #ifdef TARGET_NR_creat
1902 print_creat(void *cpu_env
, const struct syscallname
*name
,
1903 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1904 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1906 print_syscall_prologue(name
);
1907 print_string(arg0
, 0);
1908 print_file_mode(arg1
, 1);
1909 print_syscall_epilogue(name
);
1913 #ifdef TARGET_NR_execv
1915 print_execv(void *cpu_env
, const struct syscallname
*name
,
1916 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1917 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1919 print_syscall_prologue(name
);
1920 print_string(arg0
, 0);
1921 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1922 print_syscall_epilogue(name
);
1926 #ifdef TARGET_NR_faccessat
1928 print_faccessat(void *cpu_env
, const struct syscallname
*name
,
1929 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1930 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1932 print_syscall_prologue(name
);
1933 print_at_dirfd(arg0
, 0);
1934 print_string(arg1
, 0);
1935 print_flags(access_flags
, arg2
, 0);
1936 print_flags(at_file_flags
, arg3
, 1);
1937 print_syscall_epilogue(name
);
1941 #ifdef TARGET_NR_fallocate
1943 print_fallocate(void *cpu_env
, const struct syscallname
*name
,
1944 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1945 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1947 print_syscall_prologue(name
);
1948 print_raw_param("%d", arg0
, 0);
1949 print_flags(falloc_flags
, arg1
, 0);
1950 #if TARGET_ABI_BITS == 32
1951 print_raw_param("%" PRIu64
, target_offset64(arg2
, arg3
), 0);
1952 print_raw_param("%" PRIu64
, target_offset64(arg4
, arg5
), 1);
1954 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1955 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 1);
1957 print_syscall_epilogue(name
);
1961 #ifdef TARGET_NR_fchmodat
1963 print_fchmodat(void *cpu_env
, const struct syscallname
*name
,
1964 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1965 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1967 print_syscall_prologue(name
);
1968 print_at_dirfd(arg0
, 0);
1969 print_string(arg1
, 0);
1970 print_file_mode(arg2
, 0);
1971 print_flags(at_file_flags
, arg3
, 1);
1972 print_syscall_epilogue(name
);
1976 #ifdef TARGET_NR_fchownat
1978 print_fchownat(void *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_at_dirfd(arg0
, 0);
1984 print_string(arg1
, 0);
1985 print_raw_param("%d", arg2
, 0);
1986 print_raw_param("%d", arg3
, 0);
1987 print_flags(at_file_flags
, arg4
, 1);
1988 print_syscall_epilogue(name
);
1992 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1994 print_fcntl(void *cpu_env
, const struct syscallname
*name
,
1995 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1996 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1998 print_syscall_prologue(name
);
1999 print_raw_param("%d", arg0
, 0);
2001 case TARGET_F_DUPFD
:
2002 qemu_log("F_DUPFD,");
2003 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2005 case TARGET_F_GETFD
:
2006 qemu_log("F_GETFD");
2008 case TARGET_F_SETFD
:
2009 qemu_log("F_SETFD,");
2010 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2012 case TARGET_F_GETFL
:
2013 qemu_log("F_GETFL");
2015 case TARGET_F_SETFL
:
2016 qemu_log("F_SETFL,");
2017 print_open_flags(arg2
, 1);
2019 case TARGET_F_GETLK
:
2020 qemu_log("F_GETLK,");
2021 print_pointer(arg2
, 1);
2023 case TARGET_F_SETLK
:
2024 qemu_log("F_SETLK,");
2025 print_pointer(arg2
, 1);
2027 case TARGET_F_SETLKW
:
2028 qemu_log("F_SETLKW,");
2029 print_pointer(arg2
, 1);
2031 case TARGET_F_GETOWN
:
2032 qemu_log("F_GETOWN");
2034 case TARGET_F_SETOWN
:
2035 qemu_log("F_SETOWN,");
2036 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2038 case TARGET_F_GETSIG
:
2039 qemu_log("F_GETSIG");
2041 case TARGET_F_SETSIG
:
2042 qemu_log("F_SETSIG,");
2043 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2045 #if TARGET_ABI_BITS == 32
2046 case TARGET_F_GETLK64
:
2047 qemu_log("F_GETLK64,");
2048 print_pointer(arg2
, 1);
2050 case TARGET_F_SETLK64
:
2051 qemu_log("F_SETLK64,");
2052 print_pointer(arg2
, 1);
2054 case TARGET_F_SETLKW64
:
2055 qemu_log("F_SETLKW64,");
2056 print_pointer(arg2
, 1);
2059 case TARGET_F_OFD_GETLK
:
2060 qemu_log("F_OFD_GETLK,");
2061 print_pointer(arg2
, 1);
2063 case TARGET_F_OFD_SETLK
:
2064 qemu_log("F_OFD_SETLK,");
2065 print_pointer(arg2
, 1);
2067 case TARGET_F_OFD_SETLKW
:
2068 qemu_log("F_OFD_SETLKW,");
2069 print_pointer(arg2
, 1);
2071 case TARGET_F_SETLEASE
:
2072 qemu_log("F_SETLEASE,");
2073 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2075 case TARGET_F_GETLEASE
:
2076 qemu_log("F_GETLEASE");
2078 case TARGET_F_SETPIPE_SZ
:
2079 qemu_log("F_SETPIPE_SZ,");
2080 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2082 case TARGET_F_GETPIPE_SZ
:
2083 qemu_log("F_GETPIPE_SZ");
2085 case TARGET_F_DUPFD_CLOEXEC
:
2086 qemu_log("F_DUPFD_CLOEXEC,");
2087 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2089 case TARGET_F_NOTIFY
:
2090 qemu_log("F_NOTIFY,");
2091 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2094 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2095 print_pointer(arg2
, 1);
2098 print_syscall_epilogue(name
);
2100 #define print_fcntl64 print_fcntl
2103 #ifdef TARGET_NR_fgetxattr
2105 print_fgetxattr(void *cpu_env
, const struct syscallname
*name
,
2106 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2107 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2109 print_syscall_prologue(name
);
2110 print_raw_param("%d", arg0
, 0);
2111 print_string(arg1
, 0);
2112 print_pointer(arg2
, 0);
2113 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2114 print_syscall_epilogue(name
);
2118 #ifdef TARGET_NR_flistxattr
2120 print_flistxattr(void *cpu_env
, const struct syscallname
*name
,
2121 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2122 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2124 print_syscall_prologue(name
);
2125 print_raw_param("%d", arg0
, 0);
2126 print_pointer(arg1
, 0);
2127 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2128 print_syscall_epilogue(name
);
2132 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2134 print_getxattr(void *cpu_env
, const struct syscallname
*name
,
2135 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2136 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2138 print_syscall_prologue(name
);
2139 print_string(arg0
, 0);
2140 print_string(arg1
, 0);
2141 print_pointer(arg2
, 0);
2142 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2143 print_syscall_epilogue(name
);
2145 #define print_lgetxattr print_getxattr
2148 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2150 print_listxattr(void *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_string(arg0
, 0);
2156 print_pointer(arg1
, 0);
2157 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2158 print_syscall_epilogue(name
);
2160 #define print_llistxattr print_listxattr
2163 #if defined(TARGET_NR_fremovexattr)
2165 print_fremovexattr(void *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_raw_param("%d", arg0
, 0);
2171 print_string(arg1
, 1);
2172 print_syscall_epilogue(name
);
2176 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2178 print_removexattr(void *cpu_env
, const struct syscallname
*name
,
2179 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2180 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2182 print_syscall_prologue(name
);
2183 print_string(arg0
, 0);
2184 print_string(arg1
, 1);
2185 print_syscall_epilogue(name
);
2187 #define print_lremovexattr print_removexattr
2190 #ifdef TARGET_NR_futimesat
2192 print_futimesat(void *cpu_env
, const struct syscallname
*name
,
2193 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2194 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2196 print_syscall_prologue(name
);
2197 print_at_dirfd(arg0
, 0);
2198 print_string(arg1
, 0);
2199 print_timeval(arg2
, 0);
2200 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
2201 print_syscall_epilogue(name
);
2205 #ifdef TARGET_NR_gettimeofday
2207 print_gettimeofday(void *cpu_env
, const struct syscallname
*name
,
2208 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2209 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2211 print_syscall_prologue(name
);
2212 print_pointer(arg0
, 0);
2213 print_pointer(arg1
, 1);
2214 print_syscall_epilogue(name
);
2218 #ifdef TARGET_NR_settimeofday
2220 print_settimeofday(void *cpu_env
, const struct syscallname
*name
,
2221 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2222 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2224 print_syscall_prologue(name
);
2225 print_timeval(arg0
, 0);
2226 print_timezone(arg1
, 1);
2227 print_syscall_epilogue(name
);
2231 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2233 print_clock_gettime(void *cpu_env
, const struct syscallname
*name
,
2234 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2235 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2237 print_syscall_prologue(name
);
2238 print_enums(clockids
, arg0
, 0);
2239 print_pointer(arg1
, 1);
2240 print_syscall_epilogue(name
);
2242 #define print_clock_getres print_clock_gettime
2245 #ifdef TARGET_NR_clock_settime
2247 print_clock_settime(void *cpu_env
, const struct syscallname
*name
,
2248 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2249 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2251 print_syscall_prologue(name
);
2252 print_enums(clockids
, arg0
, 0);
2253 print_timespec(arg1
, 1);
2254 print_syscall_epilogue(name
);
2258 #ifdef TARGET_NR_getitimer
2260 print_getitimer(void *cpu_env
, const struct syscallname
*name
,
2261 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2262 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2264 print_syscall_prologue(name
);
2265 print_enums(itimer_types
, arg0
, 0);
2266 print_pointer(arg1
, 1);
2267 print_syscall_epilogue(name
);
2271 #ifdef TARGET_NR_setitimer
2273 print_setitimer(void *cpu_env
, const struct syscallname
*name
,
2274 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2275 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2277 print_syscall_prologue(name
);
2278 print_enums(itimer_types
, arg0
, 0);
2279 print_itimerval(arg1
, 0);
2280 print_pointer(arg2
, 1);
2281 print_syscall_epilogue(name
);
2285 #ifdef TARGET_NR_link
2287 print_link(void *cpu_env
, const struct syscallname
*name
,
2288 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2289 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2291 print_syscall_prologue(name
);
2292 print_string(arg0
, 0);
2293 print_string(arg1
, 1);
2294 print_syscall_epilogue(name
);
2298 #ifdef TARGET_NR_linkat
2300 print_linkat(void *cpu_env
, const struct syscallname
*name
,
2301 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2302 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2304 print_syscall_prologue(name
);
2305 print_at_dirfd(arg0
, 0);
2306 print_string(arg1
, 0);
2307 print_at_dirfd(arg2
, 0);
2308 print_string(arg3
, 0);
2309 print_flags(at_file_flags
, arg4
, 1);
2310 print_syscall_epilogue(name
);
2314 #ifdef TARGET_NR__llseek
2316 print__llseek(void *cpu_env
, const struct syscallname
*name
,
2317 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2318 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2320 const char *whence
= "UNKNOWN";
2321 print_syscall_prologue(name
);
2322 print_raw_param("%d", arg0
, 0);
2323 print_raw_param("%ld", arg1
, 0);
2324 print_raw_param("%ld", arg2
, 0);
2325 print_pointer(arg3
, 0);
2327 case SEEK_SET
: whence
= "SEEK_SET"; break;
2328 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
2329 case SEEK_END
: whence
= "SEEK_END"; break;
2331 qemu_log("%s", whence
);
2332 print_syscall_epilogue(name
);
2336 #ifdef TARGET_NR_lseek
2338 print_lseek(void *cpu_env
, const struct syscallname
*name
,
2339 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2340 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2342 print_syscall_prologue(name
);
2343 print_raw_param("%d", arg0
, 0);
2344 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2347 qemu_log("SEEK_SET"); break;
2349 qemu_log("SEEK_CUR"); break;
2351 qemu_log("SEEK_END"); break;
2354 qemu_log("SEEK_DATA"); break;
2358 qemu_log("SEEK_HOLE"); break;
2361 print_raw_param("%#x", arg2
, 1);
2363 print_syscall_epilogue(name
);
2367 #ifdef TARGET_NR_truncate
2369 print_truncate(void *cpu_env
, const struct syscallname
*name
,
2370 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2371 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2373 print_syscall_prologue(name
);
2374 print_string(arg0
, 0);
2375 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 1);
2376 print_syscall_epilogue(name
);
2380 #ifdef TARGET_NR_truncate64
2382 print_truncate64(void *cpu_env
, const struct syscallname
*name
,
2383 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2384 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2386 print_syscall_prologue(name
);
2387 print_string(arg0
, 0);
2388 if (regpairs_aligned(cpu_env
, TARGET_NR_truncate64
)) {
2392 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2393 print_syscall_epilogue(name
);
2397 #ifdef TARGET_NR_ftruncate64
2399 print_ftruncate64(void *cpu_env
, const struct syscallname
*name
,
2400 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2401 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2403 print_syscall_prologue(name
);
2404 print_raw_param("%d", arg0
, 0);
2405 if (regpairs_aligned(cpu_env
, TARGET_NR_ftruncate64
)) {
2409 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2410 print_syscall_epilogue(name
);
2414 #ifdef TARGET_NR_mlockall
2416 print_mlockall(void *cpu_env
, const struct syscallname
*name
,
2417 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2418 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2420 print_syscall_prologue(name
);
2421 print_flags(mlockall_flags
, arg0
, 1);
2422 print_syscall_epilogue(name
);
2426 #if defined(TARGET_NR_socket)
2428 print_socket(void *cpu_env
, const struct syscallname
*name
,
2429 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2430 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2432 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
2434 print_syscall_prologue(name
);
2435 print_socket_domain(domain
);
2437 print_socket_type(type
);
2439 if (domain
== AF_PACKET
||
2440 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2441 protocol
= tswap16(protocol
);
2443 print_socket_protocol(domain
, type
, protocol
);
2444 print_syscall_epilogue(name
);
2449 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2451 static void print_sockfd(abi_long sockfd
, int last
)
2453 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
2458 #if defined(TARGET_NR_socketcall)
2460 #define get_user_ualx(x, gaddr, idx) \
2461 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2463 static void do_print_socket(const char *name
, abi_long arg1
)
2465 abi_ulong domain
, type
, protocol
;
2467 get_user_ualx(domain
, arg1
, 0);
2468 get_user_ualx(type
, arg1
, 1);
2469 get_user_ualx(protocol
, arg1
, 2);
2470 qemu_log("%s(", name
);
2471 print_socket_domain(domain
);
2473 print_socket_type(type
);
2475 if (domain
== AF_PACKET
||
2476 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2477 protocol
= tswap16(protocol
);
2479 print_socket_protocol(domain
, type
, protocol
);
2483 static void do_print_sockaddr(const char *name
, abi_long arg1
)
2485 abi_ulong sockfd
, addr
, addrlen
;
2487 get_user_ualx(sockfd
, arg1
, 0);
2488 get_user_ualx(addr
, arg1
, 1);
2489 get_user_ualx(addrlen
, arg1
, 2);
2491 qemu_log("%s(", name
);
2492 print_sockfd(sockfd
, 0);
2493 print_sockaddr(addr
, addrlen
, 0);
2497 static void do_print_listen(const char *name
, abi_long arg1
)
2499 abi_ulong sockfd
, backlog
;
2501 get_user_ualx(sockfd
, arg1
, 0);
2502 get_user_ualx(backlog
, arg1
, 1);
2504 qemu_log("%s(", name
);
2505 print_sockfd(sockfd
, 0);
2506 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
2510 static void do_print_socketpair(const char *name
, abi_long arg1
)
2512 abi_ulong domain
, type
, protocol
, tab
;
2514 get_user_ualx(domain
, arg1
, 0);
2515 get_user_ualx(type
, arg1
, 1);
2516 get_user_ualx(protocol
, arg1
, 2);
2517 get_user_ualx(tab
, arg1
, 3);
2519 qemu_log("%s(", name
);
2520 print_socket_domain(domain
);
2522 print_socket_type(type
);
2524 print_socket_protocol(domain
, type
, protocol
);
2526 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
2530 static void do_print_sendrecv(const char *name
, abi_long arg1
)
2532 abi_ulong sockfd
, msg
, len
, flags
;
2534 get_user_ualx(sockfd
, arg1
, 0);
2535 get_user_ualx(msg
, arg1
, 1);
2536 get_user_ualx(len
, arg1
, 2);
2537 get_user_ualx(flags
, arg1
, 3);
2539 qemu_log("%s(", name
);
2540 print_sockfd(sockfd
, 0);
2541 print_buf(msg
, len
, 0);
2542 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2543 print_flags(msg_flags
, flags
, 1);
2547 static void do_print_msgaddr(const char *name
, abi_long arg1
)
2549 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
2551 get_user_ualx(sockfd
, arg1
, 0);
2552 get_user_ualx(msg
, arg1
, 1);
2553 get_user_ualx(len
, arg1
, 2);
2554 get_user_ualx(flags
, arg1
, 3);
2555 get_user_ualx(addr
, arg1
, 4);
2556 get_user_ualx(addrlen
, arg1
, 5);
2558 qemu_log("%s(", name
);
2559 print_sockfd(sockfd
, 0);
2560 print_buf(msg
, len
, 0);
2561 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2562 print_flags(msg_flags
, flags
, 0);
2563 print_sockaddr(addr
, addrlen
, 0);
2567 static void do_print_shutdown(const char *name
, abi_long arg1
)
2569 abi_ulong sockfd
, how
;
2571 get_user_ualx(sockfd
, arg1
, 0);
2572 get_user_ualx(how
, arg1
, 1);
2574 qemu_log("shutdown(");
2575 print_sockfd(sockfd
, 0);
2578 qemu_log("SHUT_RD");
2581 qemu_log("SHUT_WR");
2584 qemu_log("SHUT_RDWR");
2587 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
2593 static void do_print_msg(const char *name
, abi_long arg1
)
2595 abi_ulong sockfd
, msg
, flags
;
2597 get_user_ualx(sockfd
, arg1
, 0);
2598 get_user_ualx(msg
, arg1
, 1);
2599 get_user_ualx(flags
, arg1
, 2);
2601 qemu_log("%s(", name
);
2602 print_sockfd(sockfd
, 0);
2603 print_pointer(msg
, 0);
2604 print_flags(msg_flags
, flags
, 1);
2608 static void do_print_sockopt(const char *name
, abi_long arg1
)
2610 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
2612 get_user_ualx(sockfd
, arg1
, 0);
2613 get_user_ualx(level
, arg1
, 1);
2614 get_user_ualx(optname
, arg1
, 2);
2615 get_user_ualx(optval
, arg1
, 3);
2616 get_user_ualx(optlen
, arg1
, 4);
2618 qemu_log("%s(", name
);
2619 print_sockfd(sockfd
, 0);
2622 qemu_log("SOL_TCP,");
2623 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2624 print_pointer(optval
, 0);
2627 qemu_log("SOL_IP,");
2628 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2629 print_pointer(optval
, 0);
2632 qemu_log("SOL_RAW,");
2633 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2634 print_pointer(optval
, 0);
2636 case TARGET_SOL_SOCKET
:
2637 qemu_log("SOL_SOCKET,");
2639 case TARGET_SO_DEBUG
:
2640 qemu_log("SO_DEBUG,");
2642 print_number(optval
, 0);
2644 case TARGET_SO_REUSEADDR
:
2645 qemu_log("SO_REUSEADDR,");
2647 case TARGET_SO_REUSEPORT
:
2648 qemu_log("SO_REUSEPORT,");
2650 case TARGET_SO_TYPE
:
2651 qemu_log("SO_TYPE,");
2653 case TARGET_SO_ERROR
:
2654 qemu_log("SO_ERROR,");
2656 case TARGET_SO_DONTROUTE
:
2657 qemu_log("SO_DONTROUTE,");
2659 case TARGET_SO_BROADCAST
:
2660 qemu_log("SO_BROADCAST,");
2662 case TARGET_SO_SNDBUF
:
2663 qemu_log("SO_SNDBUF,");
2665 case TARGET_SO_RCVBUF
:
2666 qemu_log("SO_RCVBUF,");
2668 case TARGET_SO_KEEPALIVE
:
2669 qemu_log("SO_KEEPALIVE,");
2671 case TARGET_SO_OOBINLINE
:
2672 qemu_log("SO_OOBINLINE,");
2674 case TARGET_SO_NO_CHECK
:
2675 qemu_log("SO_NO_CHECK,");
2677 case TARGET_SO_PRIORITY
:
2678 qemu_log("SO_PRIORITY,");
2680 case TARGET_SO_BSDCOMPAT
:
2681 qemu_log("SO_BSDCOMPAT,");
2683 case TARGET_SO_PASSCRED
:
2684 qemu_log("SO_PASSCRED,");
2686 case TARGET_SO_TIMESTAMP
:
2687 qemu_log("SO_TIMESTAMP,");
2689 case TARGET_SO_RCVLOWAT
:
2690 qemu_log("SO_RCVLOWAT,");
2692 case TARGET_SO_RCVTIMEO
:
2693 qemu_log("SO_RCVTIMEO,");
2694 print_timeval(optval
, 0);
2696 case TARGET_SO_SNDTIMEO
:
2697 qemu_log("SO_SNDTIMEO,");
2698 print_timeval(optval
, 0);
2700 case TARGET_SO_ATTACH_FILTER
: {
2701 struct target_sock_fprog
*fprog
;
2703 qemu_log("SO_ATTACH_FILTER,");
2705 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
2706 struct target_sock_filter
*filter
;
2708 if (lock_user_struct(VERIFY_READ
, filter
,
2709 tswapal(fprog
->filter
), 0)) {
2711 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
2712 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2713 i
, tswap16(filter
[i
].code
),
2714 filter
[i
].jt
, filter
[i
].jf
,
2715 tswap32(filter
[i
].k
));
2717 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2718 i
, tswap16(filter
[i
].code
),
2719 filter
[i
].jt
, filter
[i
].jf
,
2720 tswap32(filter
[i
].k
));
2722 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
2724 qemu_log(",%d},", tswap16(fprog
->len
));
2725 unlock_user(fprog
, optval
, 0);
2727 print_pointer(optval
, 0);
2732 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2733 print_pointer(optval
, 0);
2738 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
2739 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2740 print_pointer(optval
, 0);
2743 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
2747 #define PRINT_SOCKOP(name, func) \
2748 [TARGET_SYS_##name] = { #name, func }
2752 void (*print
)(const char *, abi_long
);
2754 PRINT_SOCKOP(SOCKET
, do_print_socket
),
2755 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
2756 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
2757 PRINT_SOCKOP(LISTEN
, do_print_listen
),
2758 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
2759 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
2760 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
2761 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
2762 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
2763 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
2764 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
2765 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
2766 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
2767 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
2768 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
2769 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
2770 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
2771 PRINT_SOCKOP(ACCEPT4
, NULL
),
2772 PRINT_SOCKOP(RECVMMSG
, NULL
),
2773 PRINT_SOCKOP(SENDMMSG
, NULL
),
2777 print_socketcall(void *cpu_env
, const struct syscallname
*name
,
2778 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2779 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2781 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
2782 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
2785 print_syscall_prologue(name
);
2786 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
2787 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2788 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2789 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
2790 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
2791 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
2792 print_syscall_epilogue(name
);
2796 #if defined(TARGET_NR_bind)
2798 print_bind(void *cpu_env
, const struct syscallname
*name
,
2799 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2800 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2802 print_syscall_prologue(name
);
2803 print_sockfd(arg0
, 0);
2804 print_sockaddr(arg1
, arg2
, 1);
2805 print_syscall_epilogue(name
);
2809 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2810 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2812 print_stat(void *cpu_env
, const struct syscallname
*name
,
2813 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2814 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2816 print_syscall_prologue(name
);
2817 print_string(arg0
, 0);
2818 print_pointer(arg1
, 1);
2819 print_syscall_epilogue(name
);
2821 #define print_lstat print_stat
2822 #define print_stat64 print_stat
2823 #define print_lstat64 print_stat
2826 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2828 print_fstat(void *cpu_env
, const struct syscallname
*name
,
2829 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2830 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2832 print_syscall_prologue(name
);
2833 print_raw_param("%d", arg0
, 0);
2834 print_pointer(arg1
, 1);
2835 print_syscall_epilogue(name
);
2837 #define print_fstat64 print_fstat
2840 #ifdef TARGET_NR_mkdir
2842 print_mkdir(void *cpu_env
, const struct syscallname
*name
,
2843 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2844 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2846 print_syscall_prologue(name
);
2847 print_string(arg0
, 0);
2848 print_file_mode(arg1
, 1);
2849 print_syscall_epilogue(name
);
2853 #ifdef TARGET_NR_mkdirat
2855 print_mkdirat(void *cpu_env
, const struct syscallname
*name
,
2856 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2857 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2859 print_syscall_prologue(name
);
2860 print_at_dirfd(arg0
, 0);
2861 print_string(arg1
, 0);
2862 print_file_mode(arg2
, 1);
2863 print_syscall_epilogue(name
);
2867 #ifdef TARGET_NR_rmdir
2869 print_rmdir(void *cpu_env
, const struct syscallname
*name
,
2870 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2871 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2873 print_syscall_prologue(name
);
2874 print_string(arg0
, 0);
2875 print_syscall_epilogue(name
);
2879 #ifdef TARGET_NR_rt_sigaction
2881 print_rt_sigaction(void *cpu_env
, const struct syscallname
*name
,
2882 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2883 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2885 print_syscall_prologue(name
);
2886 print_signal(arg0
, 0);
2887 print_pointer(arg1
, 0);
2888 print_pointer(arg2
, 1);
2889 print_syscall_epilogue(name
);
2893 #ifdef TARGET_NR_rt_sigprocmask
2895 print_rt_sigprocmask(void *cpu_env
, const struct syscallname
*name
,
2896 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2897 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2899 const char *how
= "UNKNOWN";
2900 print_syscall_prologue(name
);
2902 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2903 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2904 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2906 qemu_log("%s,", how
);
2907 print_pointer(arg1
, 0);
2908 print_pointer(arg2
, 1);
2909 print_syscall_epilogue(name
);
2913 #ifdef TARGET_NR_rt_sigqueueinfo
2915 print_rt_sigqueueinfo(void *cpu_env
, const struct syscallname
*name
,
2916 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2917 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2920 target_siginfo_t uinfo
;
2922 print_syscall_prologue(name
);
2923 print_raw_param("%d", arg0
, 0);
2924 print_signal(arg1
, 0);
2925 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2927 get_target_siginfo(&uinfo
, p
);
2928 print_siginfo(&uinfo
);
2930 unlock_user(p
, arg2
, 0);
2932 print_pointer(arg2
, 1);
2934 print_syscall_epilogue(name
);
2938 #ifdef TARGET_NR_rt_tgsigqueueinfo
2940 print_rt_tgsigqueueinfo(void *cpu_env
, const struct syscallname
*name
,
2941 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2942 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2945 target_siginfo_t uinfo
;
2947 print_syscall_prologue(name
);
2948 print_raw_param("%d", arg0
, 0);
2949 print_raw_param("%d", arg1
, 0);
2950 print_signal(arg2
, 0);
2951 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2953 get_target_siginfo(&uinfo
, p
);
2954 print_siginfo(&uinfo
);
2956 unlock_user(p
, arg3
, 0);
2958 print_pointer(arg3
, 1);
2960 print_syscall_epilogue(name
);
2964 #ifdef TARGET_NR_syslog
2966 print_syslog_action(abi_ulong arg
, int last
)
2971 case TARGET_SYSLOG_ACTION_CLOSE
: {
2972 type
= "SYSLOG_ACTION_CLOSE";
2975 case TARGET_SYSLOG_ACTION_OPEN
: {
2976 type
= "SYSLOG_ACTION_OPEN";
2979 case TARGET_SYSLOG_ACTION_READ
: {
2980 type
= "SYSLOG_ACTION_READ";
2983 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2984 type
= "SYSLOG_ACTION_READ_ALL";
2987 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2988 type
= "SYSLOG_ACTION_READ_CLEAR";
2991 case TARGET_SYSLOG_ACTION_CLEAR
: {
2992 type
= "SYSLOG_ACTION_CLEAR";
2995 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2996 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2999 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
3000 type
= "SYSLOG_ACTION_CONSOLE_ON";
3003 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
3004 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
3007 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
3008 type
= "SYSLOG_ACTION_SIZE_UNREAD";
3011 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
3012 type
= "SYSLOG_ACTION_SIZE_BUFFER";
3016 print_raw_param("%ld", arg
, last
);
3020 qemu_log("%s%s", type
, get_comma(last
));
3024 print_syslog(void *cpu_env
, const struct syscallname
*name
,
3025 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3026 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3028 print_syscall_prologue(name
);
3029 print_syslog_action(arg0
, 0);
3030 print_pointer(arg1
, 0);
3031 print_raw_param("%d", arg2
, 1);
3032 print_syscall_epilogue(name
);
3036 #ifdef TARGET_NR_mknod
3038 print_mknod(void *cpu_env
, const struct syscallname
*name
,
3039 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3040 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3042 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
3044 print_syscall_prologue(name
);
3045 print_string(arg0
, 0);
3046 print_file_mode(arg1
, (hasdev
== 0));
3048 print_raw_param("makedev(%d", major(arg2
), 0);
3049 print_raw_param("%d)", minor(arg2
), 1);
3051 print_syscall_epilogue(name
);
3055 #ifdef TARGET_NR_mknodat
3057 print_mknodat(void *cpu_env
, const struct syscallname
*name
,
3058 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3059 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3061 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
3063 print_syscall_prologue(name
);
3064 print_at_dirfd(arg0
, 0);
3065 print_string(arg1
, 0);
3066 print_file_mode(arg2
, (hasdev
== 0));
3068 print_raw_param("makedev(%d", major(arg3
), 0);
3069 print_raw_param("%d)", minor(arg3
), 1);
3071 print_syscall_epilogue(name
);
3075 #ifdef TARGET_NR_mq_open
3077 print_mq_open(void *cpu_env
, const struct syscallname
*name
,
3078 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3079 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3081 int is_creat
= (arg1
& TARGET_O_CREAT
);
3083 print_syscall_prologue(name
);
3084 print_string(arg0
, 0);
3085 print_open_flags(arg1
, (is_creat
== 0));
3087 print_file_mode(arg2
, 0);
3088 print_pointer(arg3
, 1);
3090 print_syscall_epilogue(name
);
3094 #ifdef TARGET_NR_open
3096 print_open(void *cpu_env
, const struct syscallname
*name
,
3097 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3098 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3100 int is_creat
= (arg1
& TARGET_O_CREAT
);
3102 print_syscall_prologue(name
);
3103 print_string(arg0
, 0);
3104 print_open_flags(arg1
, (is_creat
== 0));
3106 print_file_mode(arg2
, 1);
3107 print_syscall_epilogue(name
);
3111 #ifdef TARGET_NR_openat
3113 print_openat(void *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 int is_creat
= (arg2
& TARGET_O_CREAT
);
3119 print_syscall_prologue(name
);
3120 print_at_dirfd(arg0
, 0);
3121 print_string(arg1
, 0);
3122 print_open_flags(arg2
, (is_creat
== 0));
3124 print_file_mode(arg3
, 1);
3125 print_syscall_epilogue(name
);
3129 #ifdef TARGET_NR_mq_unlink
3131 print_mq_unlink(void *cpu_env
, const struct syscallname
*name
,
3132 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3133 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3135 print_syscall_prologue(name
);
3136 print_string(arg0
, 1);
3137 print_syscall_epilogue(name
);
3141 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3143 print_fstatat64(void *cpu_env
, const struct syscallname
*name
,
3144 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3145 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3147 print_syscall_prologue(name
);
3148 print_at_dirfd(arg0
, 0);
3149 print_string(arg1
, 0);
3150 print_pointer(arg2
, 0);
3151 print_flags(at_file_flags
, arg3
, 1);
3152 print_syscall_epilogue(name
);
3154 #define print_newfstatat print_fstatat64
3157 #ifdef TARGET_NR_readlink
3159 print_readlink(void *cpu_env
, const struct syscallname
*name
,
3160 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3161 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3163 print_syscall_prologue(name
);
3164 print_string(arg0
, 0);
3165 print_pointer(arg1
, 0);
3166 print_raw_param("%u", arg2
, 1);
3167 print_syscall_epilogue(name
);
3171 #ifdef TARGET_NR_readlinkat
3173 print_readlinkat(void *cpu_env
, const struct syscallname
*name
,
3174 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3175 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3177 print_syscall_prologue(name
);
3178 print_at_dirfd(arg0
, 0);
3179 print_string(arg1
, 0);
3180 print_pointer(arg2
, 0);
3181 print_raw_param("%u", arg3
, 1);
3182 print_syscall_epilogue(name
);
3186 #ifdef TARGET_NR_rename
3188 print_rename(void *cpu_env
, const struct syscallname
*name
,
3189 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3190 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3192 print_syscall_prologue(name
);
3193 print_string(arg0
, 0);
3194 print_string(arg1
, 1);
3195 print_syscall_epilogue(name
);
3199 #ifdef TARGET_NR_renameat
3201 print_renameat(void *cpu_env
, const struct syscallname
*name
,
3202 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3203 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3205 print_syscall_prologue(name
);
3206 print_at_dirfd(arg0
, 0);
3207 print_string(arg1
, 0);
3208 print_at_dirfd(arg2
, 0);
3209 print_string(arg3
, 1);
3210 print_syscall_epilogue(name
);
3214 #ifdef TARGET_NR_statfs
3216 print_statfs(void *cpu_env
, const struct syscallname
*name
,
3217 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3218 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3220 print_syscall_prologue(name
);
3221 print_string(arg0
, 0);
3222 print_pointer(arg1
, 1);
3223 print_syscall_epilogue(name
);
3227 #ifdef TARGET_NR_statfs64
3229 print_statfs64(void *cpu_env
, const struct syscallname
*name
,
3230 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3231 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3233 print_syscall_prologue(name
);
3234 print_string(arg0
, 0);
3235 print_pointer(arg1
, 1);
3236 print_syscall_epilogue(name
);
3240 #ifdef TARGET_NR_symlink
3242 print_symlink(void *cpu_env
, const struct syscallname
*name
,
3243 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3244 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3246 print_syscall_prologue(name
);
3247 print_string(arg0
, 0);
3248 print_string(arg1
, 1);
3249 print_syscall_epilogue(name
);
3253 #ifdef TARGET_NR_symlinkat
3255 print_symlinkat(void *cpu_env
, const struct syscallname
*name
,
3256 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3257 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3259 print_syscall_prologue(name
);
3260 print_string(arg0
, 0);
3261 print_at_dirfd(arg1
, 0);
3262 print_string(arg2
, 1);
3263 print_syscall_epilogue(name
);
3267 #ifdef TARGET_NR_mount
3269 print_mount(void *cpu_env
, const struct syscallname
*name
,
3270 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3271 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3273 print_syscall_prologue(name
);
3274 print_string(arg0
, 0);
3275 print_string(arg1
, 0);
3276 print_string(arg2
, 0);
3277 print_flags(mount_flags
, arg3
, 0);
3278 print_pointer(arg4
, 1);
3279 print_syscall_epilogue(name
);
3283 #ifdef TARGET_NR_umount
3285 print_umount(void *cpu_env
, const struct syscallname
*name
,
3286 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3287 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3289 print_syscall_prologue(name
);
3290 print_string(arg0
, 1);
3291 print_syscall_epilogue(name
);
3295 #ifdef TARGET_NR_umount2
3297 print_umount2(void *cpu_env
, const struct syscallname
*name
,
3298 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3299 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3301 print_syscall_prologue(name
);
3302 print_string(arg0
, 0);
3303 print_flags(umount2_flags
, arg1
, 1);
3304 print_syscall_epilogue(name
);
3308 #ifdef TARGET_NR_unlink
3310 print_unlink(void *cpu_env
, const struct syscallname
*name
,
3311 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3312 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3314 print_syscall_prologue(name
);
3315 print_string(arg0
, 1);
3316 print_syscall_epilogue(name
);
3320 #ifdef TARGET_NR_unlinkat
3322 print_unlinkat(void *cpu_env
, const struct syscallname
*name
,
3323 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3324 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3326 print_syscall_prologue(name
);
3327 print_at_dirfd(arg0
, 0);
3328 print_string(arg1
, 0);
3329 print_flags(unlinkat_flags
, arg2
, 1);
3330 print_syscall_epilogue(name
);
3334 #ifdef TARGET_NR_utime
3336 print_utime(void *cpu_env
, const struct syscallname
*name
,
3337 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3338 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3340 print_syscall_prologue(name
);
3341 print_string(arg0
, 0);
3342 print_pointer(arg1
, 1);
3343 print_syscall_epilogue(name
);
3347 #ifdef TARGET_NR_utimes
3349 print_utimes(void *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
)
3353 print_syscall_prologue(name
);
3354 print_string(arg0
, 0);
3355 print_pointer(arg1
, 1);
3356 print_syscall_epilogue(name
);
3360 #ifdef TARGET_NR_utimensat
3362 print_utimensat(void *cpu_env
, const struct syscallname
*name
,
3363 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3364 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3366 print_syscall_prologue(name
);
3367 print_at_dirfd(arg0
, 0);
3368 print_string(arg1
, 0);
3369 print_pointer(arg2
, 0);
3370 print_flags(at_file_flags
, arg3
, 1);
3371 print_syscall_epilogue(name
);
3375 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3377 print_mmap(void *cpu_env
, const struct syscallname
*name
,
3378 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3379 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3381 print_syscall_prologue(name
);
3382 print_pointer(arg0
, 0);
3383 print_raw_param("%d", arg1
, 0);
3384 print_flags(mmap_prot_flags
, arg2
, 0);
3385 print_flags(mmap_flags
, arg3
, 0);
3386 print_raw_param("%d", arg4
, 0);
3387 print_raw_param("%#x", arg5
, 1);
3388 print_syscall_epilogue(name
);
3390 #define print_mmap2 print_mmap
3393 #ifdef TARGET_NR_mprotect
3395 print_mprotect(void *cpu_env
, const struct syscallname
*name
,
3396 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3397 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3399 print_syscall_prologue(name
);
3400 print_pointer(arg0
, 0);
3401 print_raw_param("%d", arg1
, 0);
3402 print_flags(mmap_prot_flags
, arg2
, 1);
3403 print_syscall_epilogue(name
);
3407 #ifdef TARGET_NR_munmap
3409 print_munmap(void *cpu_env
, const struct syscallname
*name
,
3410 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3411 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3413 print_syscall_prologue(name
);
3414 print_pointer(arg0
, 0);
3415 print_raw_param("%d", arg1
, 1);
3416 print_syscall_epilogue(name
);
3420 #ifdef TARGET_NR_futex
3421 static void print_futex_op(abi_long tflag
, int last
)
3423 #define print_op(val) \
3424 if( cmd == val ) { \
3429 int cmd
= (int)tflag
;
3430 #ifdef FUTEX_PRIVATE_FLAG
3431 if (cmd
& FUTEX_PRIVATE_FLAG
) {
3432 qemu_log("FUTEX_PRIVATE_FLAG|");
3433 cmd
&= ~FUTEX_PRIVATE_FLAG
;
3436 #ifdef FUTEX_CLOCK_REALTIME
3437 if (cmd
& FUTEX_CLOCK_REALTIME
) {
3438 qemu_log("FUTEX_CLOCK_REALTIME|");
3439 cmd
&= ~FUTEX_CLOCK_REALTIME
;
3442 print_op(FUTEX_WAIT
)
3443 print_op(FUTEX_WAKE
)
3445 print_op(FUTEX_REQUEUE
)
3446 print_op(FUTEX_CMP_REQUEUE
)
3447 print_op(FUTEX_WAKE_OP
)
3448 print_op(FUTEX_LOCK_PI
)
3449 print_op(FUTEX_UNLOCK_PI
)
3450 print_op(FUTEX_TRYLOCK_PI
)
3451 #ifdef FUTEX_WAIT_BITSET
3452 print_op(FUTEX_WAIT_BITSET
)
3454 #ifdef FUTEX_WAKE_BITSET
3455 print_op(FUTEX_WAKE_BITSET
)
3457 /* unknown values */
3458 qemu_log("%d", cmd
);
3462 print_futex(void *cpu_env
, const struct syscallname
*name
,
3463 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3464 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3466 print_syscall_prologue(name
);
3467 print_pointer(arg0
, 0);
3468 print_futex_op(arg1
, 0);
3469 print_raw_param(",%d", arg2
, 0);
3470 print_pointer(arg3
, 0); /* struct timespec */
3471 print_pointer(arg4
, 0);
3472 print_raw_param("%d", arg4
, 1);
3473 print_syscall_epilogue(name
);
3477 #ifdef TARGET_NR_kill
3479 print_kill(void *cpu_env
, const struct syscallname
*name
,
3480 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3481 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3483 print_syscall_prologue(name
);
3484 print_raw_param("%d", arg0
, 0);
3485 print_signal(arg1
, 1);
3486 print_syscall_epilogue(name
);
3490 #ifdef TARGET_NR_tkill
3492 print_tkill(void *cpu_env
, const struct syscallname
*name
,
3493 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3494 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3496 print_syscall_prologue(name
);
3497 print_raw_param("%d", arg0
, 0);
3498 print_signal(arg1
, 1);
3499 print_syscall_epilogue(name
);
3503 #ifdef TARGET_NR_tgkill
3505 print_tgkill(void *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 print_syscall_prologue(name
);
3510 print_raw_param("%d", arg0
, 0);
3511 print_raw_param("%d", arg1
, 0);
3512 print_signal(arg2
, 1);
3513 print_syscall_epilogue(name
);
3517 #ifdef TARGET_NR_statx
3519 print_statx(void *cpu_env
, const struct syscallname
*name
,
3520 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3521 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3523 print_syscall_prologue(name
);
3524 print_at_dirfd(arg0
, 0);
3525 print_string(arg1
, 0);
3526 print_flags(statx_flags
, arg2
, 0);
3527 print_flags(statx_mask
, arg3
, 0);
3528 print_pointer(arg4
, 1);
3529 print_syscall_epilogue(name
);
3533 #ifdef TARGET_NR_ioctl
3535 print_ioctl(void *cpu_env
, const struct syscallname
*name
,
3536 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3537 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3539 print_syscall_prologue(name
);
3540 print_raw_param("%d", arg0
, 0);
3542 const IOCTLEntry
*ie
;
3543 const argtype
*arg_type
;
3547 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
3548 if (ie
->target_cmd
== arg1
) {
3553 if (ie
->target_cmd
== 0) {
3554 print_raw_param("%#x", arg1
, 0);
3555 print_raw_param("%#x", arg2
, 1);
3557 qemu_log("%s", ie
->name
);
3558 arg_type
= ie
->arg_type
;
3560 if (arg_type
[0] != TYPE_NULL
) {
3563 switch (arg_type
[0]) {
3565 print_pointer(arg2
, 1);
3570 print_raw_param("%d", arg2
, 1);
3573 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
3576 print_raw_param(TARGET_ABI_FMT_lu
, arg2
, 1);
3579 switch (ie
->access
) {
3581 print_pointer(arg2
, 1);
3586 target_size
= thunk_type_size(arg_type
, 0);
3587 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
3589 thunk_print(argptr
, arg_type
);
3590 unlock_user(argptr
, arg2
, target_size
);
3592 print_pointer(arg2
, 1);
3598 g_assert_not_reached();
3602 print_syscall_epilogue(name
);
3607 * An array of all of the syscalls we know about
3610 static const struct syscallname scnames
[] = {
3611 #include "strace.list"
3614 static int nsyscalls
= ARRAY_SIZE(scnames
);
3617 * The public interface to this module.
3620 print_syscall(void *cpu_env
, int num
,
3621 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3622 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3625 const char *format
="%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")";
3627 qemu_log("%d ", getpid());
3629 for(i
=0;i
<nsyscalls
;i
++)
3630 if( scnames
[i
].nr
== num
) {
3631 if( scnames
[i
].call
!= NULL
) {
3633 cpu_env
, &scnames
[i
], arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3635 /* XXX: this format system is broken because it uses
3636 host types and host pointers for strings */
3637 if( scnames
[i
].format
!= NULL
)
3638 format
= scnames
[i
].format
;
3640 scnames
[i
].name
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3644 qemu_log("Unknown syscall %d\n", num
);
3649 print_syscall_ret(void *cpu_env
, int num
, abi_long ret
,
3650 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3651 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3655 for(i
=0;i
<nsyscalls
;i
++)
3656 if( scnames
[i
].nr
== num
) {
3657 if( scnames
[i
].result
!= NULL
) {
3658 scnames
[i
].result(cpu_env
, &scnames
[i
], ret
,
3662 if (!print_syscall_err(ret
)) {
3663 qemu_log(TARGET_ABI_FMT_ld
, ret
);
3671 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
3673 /* Print the strace output for a signal being taken:
3674 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3677 print_signal(target_signum
, 1);
3679 print_siginfo(tinfo
);