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
);
28 * It is possible that target doesn't have syscall that uses
29 * following flags but we don't want the compiler to warn
30 * us about them being unused. Same applies to utility print
31 * functions. It is ok to keep them while not used.
33 #define UNUSED __attribute__ ((unused))
36 * Structure used to translate flag values into strings. This is
37 * similar that is in the actual strace tool.
40 abi_long f_value
; /* flag */
41 const char *f_string
; /* stringified flag */
44 /* common flags for all architectures */
45 #define FLAG_GENERIC(name) { name, #name }
46 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
47 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
48 /* end of flags array */
49 #define FLAG_END { 0, NULL }
51 /* Structure used to translate enumerated values into strings */
53 abi_long e_value
; /* enum value */
54 const char *e_string
; /* stringified enum */
57 /* common enums for all architectures */
58 #define ENUM_GENERIC(name) { name, #name }
59 /* target specific enums */
60 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
61 /* end of enums array */
62 #define ENUM_END { 0, NULL }
64 UNUSED
static const char *get_comma(int);
65 UNUSED
static void print_pointer(abi_long
, int);
66 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
67 UNUSED
static void print_enums(const struct enums
*, abi_long
, int);
68 UNUSED
static void print_at_dirfd(abi_long
, int);
69 UNUSED
static void print_file_mode(abi_long
, int);
70 UNUSED
static void print_open_flags(abi_long
, int);
71 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
72 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
73 UNUSED
static void print_string(abi_long
, int);
74 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
75 UNUSED
static void print_raw_param(const char *, abi_long
, int);
76 UNUSED
static void print_timeval(abi_ulong
, int);
77 UNUSED
static void print_timespec(abi_ulong
, int);
78 UNUSED
static void print_timezone(abi_ulong
, int);
79 UNUSED
static void print_itimerval(abi_ulong
, int);
80 UNUSED
static void print_number(abi_long
, int);
81 UNUSED
static void print_signal(abi_ulong
, int);
82 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
83 UNUSED
static void print_socket_domain(int domain
);
84 UNUSED
static void print_socket_type(int type
);
85 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
91 print_ipc_cmd(int cmd
)
93 #define output_cmd(val) \
101 /* General IPC commands */
102 output_cmd( IPC_RMID
);
103 output_cmd( IPC_SET
);
104 output_cmd( IPC_STAT
);
105 output_cmd( IPC_INFO
);
106 /* msgctl() commands */
107 output_cmd( MSG_STAT
);
108 output_cmd( MSG_INFO
);
109 /* shmctl() commands */
110 output_cmd( SHM_LOCK
);
111 output_cmd( SHM_UNLOCK
);
112 output_cmd( SHM_STAT
);
113 output_cmd( SHM_INFO
);
114 /* semctl() commands */
115 output_cmd( GETPID
);
116 output_cmd( GETVAL
);
117 output_cmd( GETALL
);
118 output_cmd( GETNCNT
);
119 output_cmd( GETZCNT
);
120 output_cmd( SETVAL
);
121 output_cmd( SETALL
);
122 output_cmd( SEM_STAT
);
123 output_cmd( SEM_INFO
);
124 output_cmd( IPC_RMID
);
125 output_cmd( IPC_RMID
);
126 output_cmd( IPC_RMID
);
127 output_cmd( IPC_RMID
);
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
);
134 /* Some value we don't recognize */
139 print_signal(abi_ulong arg
, int last
)
141 const char *signal_name
= NULL
;
143 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
144 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
145 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
146 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
147 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
148 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
149 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
150 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
151 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
152 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
153 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
154 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
155 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
156 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
157 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
158 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
159 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
160 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
162 if (signal_name
== NULL
) {
163 print_raw_param("%ld", arg
, last
);
166 qemu_log("%s%s", signal_name
, get_comma(last
));
169 static void print_si_code(int arg
)
171 const char *codename
= NULL
;
175 codename
= "SI_USER";
178 codename
= "SI_KERNEL";
181 codename
= "SI_QUEUE";
184 codename
= "SI_TIMER";
187 codename
= "SI_MESGQ";
190 codename
= "SI_ASYNCIO";
193 codename
= "SI_SIGIO";
196 codename
= "SI_TKILL";
202 qemu_log("%s", codename
);
205 static void get_target_siginfo(target_siginfo_t
*tinfo
,
206 const target_siginfo_t
*info
)
215 __get_user(sig
, &info
->si_signo
);
216 __get_user(si_errno
, &tinfo
->si_errno
);
217 __get_user(si_code
, &info
->si_code
);
219 tinfo
->si_signo
= sig
;
220 tinfo
->si_errno
= si_errno
;
221 tinfo
->si_code
= si_code
;
223 /* Ensure we don't leak random junk to the guest later */
224 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
226 /* This is awkward, because we have to use a combination of
227 * the si_code and si_signo to figure out which of the union's
228 * members are valid. (Within the host kernel it is always possible
229 * to tell, but the kernel carefully avoids giving userspace the
230 * high 16 bits of si_code, so we don't have the information to
231 * do this the easy way...) We therefore make our best guess,
232 * bearing in mind that a guest can spoof most of the si_codes
233 * via rt_sigqueueinfo() if it likes.
235 * Once we have made our guess, we record it in the top 16 bits of
236 * the si_code, so that print_siginfo() later can use it.
237 * print_siginfo() will strip these top bits out before printing
245 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
246 * These are the only unspoofable si_code values.
248 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
249 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
250 si_type
= QEMU_SI_KILL
;
253 /* Everything else is spoofable. Make best guess based on signal */
256 __get_user(tinfo
->_sifields
._sigchld
._pid
,
257 &info
->_sifields
._sigchld
._pid
);
258 __get_user(tinfo
->_sifields
._sigchld
._uid
,
259 &info
->_sifields
._sigchld
._uid
);
260 __get_user(tinfo
->_sifields
._sigchld
._status
,
261 &info
->_sifields
._sigchld
._status
);
262 __get_user(tinfo
->_sifields
._sigchld
._utime
,
263 &info
->_sifields
._sigchld
._utime
);
264 __get_user(tinfo
->_sifields
._sigchld
._stime
,
265 &info
->_sifields
._sigchld
._stime
);
266 si_type
= QEMU_SI_CHLD
;
269 __get_user(tinfo
->_sifields
._sigpoll
._band
,
270 &info
->_sifields
._sigpoll
._band
);
271 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
272 &info
->_sifields
._sigpoll
._fd
);
273 si_type
= QEMU_SI_POLL
;
276 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
277 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
278 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
279 /* XXX: potential problem if 64 bit */
280 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
281 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
283 si_type
= QEMU_SI_RT
;
289 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
292 static void print_siginfo(const target_siginfo_t
*tinfo
)
294 /* Print a target_siginfo_t in the format desired for printing
295 * signals being taken. We assume the target_siginfo_t is in the
296 * internal form where the top 16 bits of si_code indicate which
297 * part of the union is valid, rather than in the guest-visible
298 * form where the bottom 16 bits are sign-extended into the top 16.
300 int si_type
= extract32(tinfo
->si_code
, 16, 16);
301 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
303 qemu_log("{si_signo=");
304 print_signal(tinfo
->si_signo
, 1);
305 qemu_log(", si_code=");
306 print_si_code(si_code
);
310 qemu_log(", si_pid=%u, si_uid=%u",
311 (unsigned int)tinfo
->_sifields
._kill
._pid
,
312 (unsigned int)tinfo
->_sifields
._kill
._uid
);
315 qemu_log(", si_timer1=%u, si_timer2=%u",
316 tinfo
->_sifields
._timer
._timer1
,
317 tinfo
->_sifields
._timer
._timer2
);
320 qemu_log(", si_band=%d, si_fd=%d",
321 tinfo
->_sifields
._sigpoll
._band
,
322 tinfo
->_sifields
._sigpoll
._fd
);
325 qemu_log(", si_addr=");
326 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
329 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
330 ", si_utime=" TARGET_ABI_FMT_ld
331 ", si_stime=" TARGET_ABI_FMT_ld
,
332 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
333 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
334 tinfo
->_sifields
._sigchld
._status
,
335 tinfo
->_sifields
._sigchld
._utime
,
336 tinfo
->_sifields
._sigchld
._stime
);
339 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
340 (unsigned int)tinfo
->_sifields
._rt
._pid
,
341 (unsigned int)tinfo
->_sifields
._rt
._uid
,
342 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
345 g_assert_not_reached();
351 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
353 struct target_sockaddr
*sa
;
357 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
359 sa_family
= tswap16(sa
->sa_family
);
362 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
364 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
365 for (i
= 0; i
< addrlen
-
366 offsetof(struct target_sockaddr_un
, sun_path
) &&
367 un
->sun_path
[i
]; i
++) {
368 qemu_log("%c", un
->sun_path
[i
]);
374 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
375 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
376 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
377 ntohs(in
->sin_port
));
378 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
379 c
[0], c
[1], c
[2], c
[3]);
384 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
385 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
386 qemu_log("{sll_family=AF_PACKET,"
387 "sll_protocol=htons(0x%04x),if%d,pkttype=",
388 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
389 switch (ll
->sll_pkttype
) {
391 qemu_log("PACKET_HOST");
393 case PACKET_BROADCAST
:
394 qemu_log("PACKET_BROADCAST");
396 case PACKET_MULTICAST
:
397 qemu_log("PACKET_MULTICAST");
399 case PACKET_OTHERHOST
:
400 qemu_log("PACKET_OTHERHOST");
402 case PACKET_OUTGOING
:
403 qemu_log("PACKET_OUTGOING");
406 qemu_log("%d", ll
->sll_pkttype
);
409 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
410 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
415 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
416 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
417 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
421 qemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
422 for (i
= 0; i
< 13; i
++) {
423 qemu_log("%02x, ", sa
->sa_data
[i
]);
425 qemu_log("%02x}", sa
->sa_data
[i
]);
429 unlock_user(sa
, addr
, 0);
431 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
433 qemu_log(", "TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
437 print_socket_domain(int domain
)
447 qemu_log("PF_NETLINK");
450 qemu_log("PF_PACKET");
453 qemu_log("%d", domain
);
459 print_socket_type(int type
)
461 switch (type
& TARGET_SOCK_TYPE_MASK
) {
462 case TARGET_SOCK_DGRAM
:
463 qemu_log("SOCK_DGRAM");
465 case TARGET_SOCK_STREAM
:
466 qemu_log("SOCK_STREAM");
468 case TARGET_SOCK_RAW
:
469 qemu_log("SOCK_RAW");
471 case TARGET_SOCK_RDM
:
472 qemu_log("SOCK_RDM");
474 case TARGET_SOCK_SEQPACKET
:
475 qemu_log("SOCK_SEQPACKET");
477 case TARGET_SOCK_PACKET
:
478 qemu_log("SOCK_PACKET");
481 if (type
& TARGET_SOCK_CLOEXEC
) {
482 qemu_log("|SOCK_CLOEXEC");
484 if (type
& TARGET_SOCK_NONBLOCK
) {
485 qemu_log("|SOCK_NONBLOCK");
490 print_socket_protocol(int domain
, int type
, int protocol
)
492 if (domain
== AF_PACKET
||
493 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
496 qemu_log("ETH_P_ALL");
499 qemu_log("%d", protocol
);
504 if (domain
== PF_NETLINK
) {
507 qemu_log("NETLINK_ROUTE");
510 qemu_log("NETLINK_AUDIT");
512 case NETLINK_NETFILTER
:
513 qemu_log("NETLINK_NETFILTER");
515 case NETLINK_KOBJECT_UEVENT
:
516 qemu_log("NETLINK_KOBJECT_UEVENT");
519 qemu_log("NETLINK_RDMA");
522 qemu_log("NETLINK_CRYPTO");
525 qemu_log("%d", protocol
);
533 qemu_log("IPPROTO_IP");
536 qemu_log("IPPROTO_TCP");
539 qemu_log("IPPROTO_UDP");
542 qemu_log("IPPROTO_RAW");
545 qemu_log("%d", protocol
);
551 #ifdef TARGET_NR__newselect
553 print_fdset(int n
, abi_ulong target_fds_addr
)
559 if( target_fds_addr
) {
560 abi_long
*target_fds
;
562 target_fds
= lock_user(VERIFY_READ
,
564 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
570 for (i
=n
; i
>=0; i
--) {
571 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >>
572 (i
& (TARGET_ABI_BITS
- 1))) & 1) {
573 qemu_log("%s%d", get_comma(first
), i
);
577 unlock_user(target_fds
, target_fds_addr
, 0);
584 * Sysycall specific output functions
588 #ifdef TARGET_NR__newselect
590 print_newselect(void *cpu_env
, const struct syscallname
*name
,
591 abi_long arg1
, abi_long arg2
, abi_long arg3
,
592 abi_long arg4
, abi_long arg5
, abi_long arg6
)
594 print_syscall_prologue(name
);
595 print_fdset(arg1
, arg2
);
597 print_fdset(arg1
, arg3
);
599 print_fdset(arg1
, arg4
);
601 print_timeval(arg5
, 1);
602 print_syscall_epilogue(name
);
606 #ifdef TARGET_NR_semctl
608 print_semctl(void *cpu_env
, const struct syscallname
*name
,
609 abi_long arg1
, abi_long arg2
, abi_long arg3
,
610 abi_long arg4
, abi_long arg5
, abi_long arg6
)
612 qemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
613 name
->name
, arg1
, arg2
);
615 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
620 print_execve(void *cpu_env
, const struct syscallname
*name
,
621 abi_long arg1
, abi_long arg2
, abi_long arg3
,
622 abi_long arg4
, abi_long arg5
, abi_long arg6
)
624 abi_ulong arg_ptr_addr
;
627 if (!(s
= lock_user_string(arg1
)))
629 qemu_log("%s(\"%s\",{", name
->name
, s
);
630 unlock_user(s
, arg1
, 0);
632 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
633 abi_ulong
*arg_ptr
, arg_addr
;
635 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
638 arg_addr
= tswapal(*arg_ptr
);
639 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
642 if ((s
= lock_user_string(arg_addr
))) {
643 qemu_log("\"%s\",", s
);
644 unlock_user(s
, arg_addr
, 0);
653 print_ipc(void *cpu_env
, const struct syscallname
*name
,
654 abi_long arg1
, abi_long arg2
, abi_long arg3
,
655 abi_long arg4
, abi_long arg5
, abi_long arg6
)
659 qemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
662 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
666 TARGET_ABI_FMT_ld
","
667 TARGET_ABI_FMT_ld
","
668 TARGET_ABI_FMT_ld
","
671 name
->name
, arg1
, arg2
, arg3
, arg4
);
677 * Variants for the return value output function
681 print_syscall_err(abi_long ret
)
687 errstr
= target_strerror(-ret
);
689 qemu_log("-1 errno=%d (%s)", (int)-ret
, errstr
);
697 print_syscall_ret_addr(void *cpu_env
, const struct syscallname
*name
,
698 abi_long ret
, abi_long arg0
, abi_long arg1
,
699 abi_long arg2
, abi_long arg3
, abi_long arg4
,
702 if (!print_syscall_err(ret
)) {
703 qemu_log("0x" TARGET_ABI_FMT_lx
, ret
);
708 #if 0 /* currently unused */
710 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
712 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
716 #ifdef TARGET_NR__newselect
718 print_syscall_ret_newselect(void *cpu_env
, const struct syscallname
*name
,
719 abi_long ret
, abi_long arg0
, abi_long arg1
,
720 abi_long arg2
, abi_long arg3
, abi_long arg4
,
723 if (!print_syscall_err(ret
)) {
724 qemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
725 print_fdset(arg0
, arg1
);
727 print_fdset(arg0
, arg2
);
729 print_fdset(arg0
, arg3
);
731 print_timeval(arg4
, 1);
739 /* special meanings of adjtimex()' non-negative return values */
740 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
741 #define TARGET_TIME_INS 1 /* insert leap second */
742 #define TARGET_TIME_DEL 2 /* delete leap second */
743 #define TARGET_TIME_OOP 3 /* leap second in progress */
744 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
745 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
746 #ifdef TARGET_NR_adjtimex
748 print_syscall_ret_adjtimex(void *cpu_env
, const struct syscallname
*name
,
749 abi_long ret
, abi_long arg0
, abi_long arg1
,
750 abi_long arg2
, abi_long arg3
, abi_long arg4
,
753 if (!print_syscall_err(ret
)) {
754 qemu_log(TARGET_ABI_FMT_ld
, ret
);
757 qemu_log(" TIME_OK (clock synchronized, no leap second)");
759 case TARGET_TIME_INS
:
760 qemu_log(" TIME_INS (insert leap second)");
762 case TARGET_TIME_DEL
:
763 qemu_log(" TIME_DEL (delete leap second)");
765 case TARGET_TIME_OOP
:
766 qemu_log(" TIME_OOP (leap second in progress)");
768 case TARGET_TIME_WAIT
:
769 qemu_log(" TIME_WAIT (leap second has occurred)");
771 case TARGET_TIME_ERROR
:
772 qemu_log(" TIME_ERROR (clock not synchronized)");
781 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
783 print_syscall_ret_clock_gettime(void *cpu_env
, const struct syscallname
*name
,
784 abi_long ret
, abi_long arg0
, abi_long arg1
,
785 abi_long arg2
, abi_long arg3
, abi_long arg4
,
788 if (!print_syscall_err(ret
)) {
789 qemu_log(TARGET_ABI_FMT_ld
, ret
);
791 print_timespec(arg1
, 1);
797 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
800 #ifdef TARGET_NR_gettimeofday
802 print_syscall_ret_gettimeofday(void *cpu_env
, const struct syscallname
*name
,
803 abi_long ret
, abi_long arg0
, abi_long arg1
,
804 abi_long arg2
, abi_long arg3
, abi_long arg4
,
807 if (!print_syscall_err(ret
)) {
808 qemu_log(TARGET_ABI_FMT_ld
, ret
);
810 print_timeval(arg0
, 0);
811 print_timezone(arg1
, 1);
819 #ifdef TARGET_NR_getitimer
821 print_syscall_ret_getitimer(void *cpu_env
, const struct syscallname
*name
,
822 abi_long ret
, abi_long arg0
, abi_long arg1
,
823 abi_long arg2
, abi_long arg3
, abi_long arg4
,
826 if (!print_syscall_err(ret
)) {
827 qemu_log(TARGET_ABI_FMT_ld
, ret
);
829 print_itimerval(arg1
, 1);
838 #ifdef TARGET_NR_getitimer
840 print_syscall_ret_setitimer(void *cpu_env
, const struct syscallname
*name
,
841 abi_long ret
, abi_long arg0
, abi_long arg1
,
842 abi_long arg2
, abi_long arg3
, abi_long arg4
,
845 if (!print_syscall_err(ret
)) {
846 qemu_log(TARGET_ABI_FMT_ld
, ret
);
847 qemu_log(" (old_value = ");
848 print_itimerval(arg2
, 1);
856 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
857 || defined(TARGGET_NR_flistxattr)
859 print_syscall_ret_listxattr(void *cpu_env
, const struct syscallname
*name
,
860 abi_long ret
, abi_long arg0
, abi_long arg1
,
861 abi_long arg2
, abi_long arg3
, abi_long arg4
,
864 if (!print_syscall_err(ret
)) {
865 qemu_log(TARGET_ABI_FMT_ld
, ret
);
866 qemu_log(" (list = ");
868 abi_long attr
= arg1
;
873 print_string(attr
, 1);
874 ret
-= target_strlen(attr
) + 1;
875 attr
+= target_strlen(attr
) + 1;
885 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
886 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
889 #ifdef TARGET_NR_ioctl
891 print_syscall_ret_ioctl(void *cpu_env
, const struct syscallname
*name
,
892 abi_long ret
, abi_long arg0
, abi_long arg1
,
893 abi_long arg2
, abi_long arg3
, abi_long arg4
,
896 if (!print_syscall_err(ret
)) {
897 qemu_log(TARGET_ABI_FMT_ld
, ret
);
899 const IOCTLEntry
*ie
;
900 const argtype
*arg_type
;
904 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
905 if (ie
->target_cmd
== arg1
) {
910 if (ie
->target_cmd
== arg1
&&
911 (ie
->access
== IOC_R
|| ie
->access
== IOC_RW
)) {
912 arg_type
= ie
->arg_type
;
915 target_size
= thunk_type_size(arg_type
, 0);
916 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
918 thunk_print(argptr
, arg_type
);
919 unlock_user(argptr
, arg2
, target_size
);
921 print_pointer(arg2
, 1);
930 UNUSED
static struct flags access_flags
[] = {
938 UNUSED
static struct flags at_file_flags
[] = {
940 FLAG_GENERIC(AT_EACCESS
),
942 #ifdef AT_SYMLINK_NOFOLLOW
943 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
948 UNUSED
static struct flags unlinkat_flags
[] = {
950 FLAG_GENERIC(AT_REMOVEDIR
),
955 UNUSED
static struct flags mode_flags
[] = {
956 FLAG_GENERIC(S_IFSOCK
),
957 FLAG_GENERIC(S_IFLNK
),
958 FLAG_GENERIC(S_IFREG
),
959 FLAG_GENERIC(S_IFBLK
),
960 FLAG_GENERIC(S_IFDIR
),
961 FLAG_GENERIC(S_IFCHR
),
962 FLAG_GENERIC(S_IFIFO
),
966 UNUSED
static struct flags open_access_flags
[] = {
967 FLAG_TARGET(O_RDONLY
),
968 FLAG_TARGET(O_WRONLY
),
973 UNUSED
static struct flags open_flags
[] = {
974 FLAG_TARGET(O_APPEND
),
975 FLAG_TARGET(O_CREAT
),
976 FLAG_TARGET(O_DIRECTORY
),
978 FLAG_TARGET(O_LARGEFILE
),
979 FLAG_TARGET(O_NOCTTY
),
980 FLAG_TARGET(O_NOFOLLOW
),
981 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
982 FLAG_TARGET(O_DSYNC
),
983 FLAG_TARGET(__O_SYNC
),
984 FLAG_TARGET(O_TRUNC
),
986 FLAG_TARGET(O_DIRECT
),
989 FLAG_TARGET(O_NOATIME
),
992 FLAG_TARGET(O_CLOEXEC
),
998 FLAG_TARGET(O_TMPFILE
),
999 FLAG_TARGET(__O_TMPFILE
),
1004 UNUSED
static struct flags mount_flags
[] = {
1006 FLAG_GENERIC(MS_BIND
),
1009 FLAG_GENERIC(MS_DIRSYNC
),
1011 FLAG_GENERIC(MS_MANDLOCK
),
1013 FLAG_GENERIC(MS_MOVE
),
1015 FLAG_GENERIC(MS_NOATIME
),
1016 FLAG_GENERIC(MS_NODEV
),
1017 FLAG_GENERIC(MS_NODIRATIME
),
1018 FLAG_GENERIC(MS_NOEXEC
),
1019 FLAG_GENERIC(MS_NOSUID
),
1020 FLAG_GENERIC(MS_RDONLY
),
1022 FLAG_GENERIC(MS_RELATIME
),
1024 FLAG_GENERIC(MS_REMOUNT
),
1025 FLAG_GENERIC(MS_SYNCHRONOUS
),
1029 UNUSED
static struct flags umount2_flags
[] = {
1031 FLAG_GENERIC(MNT_FORCE
),
1034 FLAG_GENERIC(MNT_DETACH
),
1037 FLAG_GENERIC(MNT_EXPIRE
),
1042 UNUSED
static struct flags mmap_prot_flags
[] = {
1043 FLAG_GENERIC(PROT_NONE
),
1044 FLAG_GENERIC(PROT_EXEC
),
1045 FLAG_GENERIC(PROT_READ
),
1046 FLAG_GENERIC(PROT_WRITE
),
1047 FLAG_TARGET(PROT_SEM
),
1048 FLAG_GENERIC(PROT_GROWSDOWN
),
1049 FLAG_GENERIC(PROT_GROWSUP
),
1053 UNUSED
static struct flags mmap_flags
[] = {
1054 FLAG_TARGET(MAP_SHARED
),
1055 FLAG_TARGET(MAP_PRIVATE
),
1056 FLAG_TARGET(MAP_ANONYMOUS
),
1057 FLAG_TARGET(MAP_DENYWRITE
),
1058 FLAG_TARGET(MAP_FIXED
),
1059 FLAG_TARGET(MAP_GROWSDOWN
),
1060 FLAG_TARGET(MAP_EXECUTABLE
),
1062 FLAG_TARGET(MAP_LOCKED
),
1065 FLAG_TARGET(MAP_NONBLOCK
),
1067 FLAG_TARGET(MAP_NORESERVE
),
1069 FLAG_TARGET(MAP_POPULATE
),
1071 #ifdef TARGET_MAP_UNINITIALIZED
1072 FLAG_TARGET(MAP_UNINITIALIZED
),
1077 UNUSED
static struct flags clone_flags
[] = {
1078 FLAG_GENERIC(CLONE_VM
),
1079 FLAG_GENERIC(CLONE_FS
),
1080 FLAG_GENERIC(CLONE_FILES
),
1081 FLAG_GENERIC(CLONE_SIGHAND
),
1082 FLAG_GENERIC(CLONE_PTRACE
),
1083 FLAG_GENERIC(CLONE_VFORK
),
1084 FLAG_GENERIC(CLONE_PARENT
),
1085 FLAG_GENERIC(CLONE_THREAD
),
1086 FLAG_GENERIC(CLONE_NEWNS
),
1087 FLAG_GENERIC(CLONE_SYSVSEM
),
1088 FLAG_GENERIC(CLONE_SETTLS
),
1089 FLAG_GENERIC(CLONE_PARENT_SETTID
),
1090 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
1091 FLAG_GENERIC(CLONE_DETACHED
),
1092 FLAG_GENERIC(CLONE_UNTRACED
),
1093 FLAG_GENERIC(CLONE_CHILD_SETTID
),
1094 #if defined(CLONE_NEWUTS)
1095 FLAG_GENERIC(CLONE_NEWUTS
),
1097 #if defined(CLONE_NEWIPC)
1098 FLAG_GENERIC(CLONE_NEWIPC
),
1100 #if defined(CLONE_NEWUSER)
1101 FLAG_GENERIC(CLONE_NEWUSER
),
1103 #if defined(CLONE_NEWPID)
1104 FLAG_GENERIC(CLONE_NEWPID
),
1106 #if defined(CLONE_NEWNET)
1107 FLAG_GENERIC(CLONE_NEWNET
),
1109 #if defined(CLONE_IO)
1110 FLAG_GENERIC(CLONE_IO
),
1115 UNUSED
static struct flags msg_flags
[] = {
1117 FLAG_GENERIC(MSG_CONFIRM
),
1118 FLAG_GENERIC(MSG_DONTROUTE
),
1119 FLAG_GENERIC(MSG_DONTWAIT
),
1120 FLAG_GENERIC(MSG_EOR
),
1121 FLAG_GENERIC(MSG_MORE
),
1122 FLAG_GENERIC(MSG_NOSIGNAL
),
1123 FLAG_GENERIC(MSG_OOB
),
1125 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1126 FLAG_GENERIC(MSG_ERRQUEUE
),
1127 FLAG_GENERIC(MSG_PEEK
),
1128 FLAG_GENERIC(MSG_TRUNC
),
1129 FLAG_GENERIC(MSG_WAITALL
),
1131 FLAG_GENERIC(MSG_CTRUNC
),
1135 UNUSED
static struct flags statx_flags
[] = {
1136 #ifdef AT_EMPTY_PATH
1137 FLAG_GENERIC(AT_EMPTY_PATH
),
1139 #ifdef AT_NO_AUTOMOUNT
1140 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1142 #ifdef AT_SYMLINK_NOFOLLOW
1143 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1145 #ifdef AT_STATX_SYNC_AS_STAT
1146 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT
),
1148 #ifdef AT_STATX_FORCE_SYNC
1149 FLAG_GENERIC(AT_STATX_FORCE_SYNC
),
1151 #ifdef AT_STATX_DONT_SYNC
1152 FLAG_GENERIC(AT_STATX_DONT_SYNC
),
1157 UNUSED
static struct flags statx_mask
[] = {
1158 /* This must come first, because it includes everything. */
1160 FLAG_GENERIC(STATX_ALL
),
1162 /* This must come second; it includes everything except STATX_BTIME. */
1163 #ifdef STATX_BASIC_STATS
1164 FLAG_GENERIC(STATX_BASIC_STATS
),
1167 FLAG_GENERIC(STATX_TYPE
),
1170 FLAG_GENERIC(STATX_MODE
),
1173 FLAG_GENERIC(STATX_NLINK
),
1176 FLAG_GENERIC(STATX_UID
),
1179 FLAG_GENERIC(STATX_GID
),
1182 FLAG_GENERIC(STATX_ATIME
),
1185 FLAG_GENERIC(STATX_MTIME
),
1188 FLAG_GENERIC(STATX_CTIME
),
1191 FLAG_GENERIC(STATX_INO
),
1194 FLAG_GENERIC(STATX_SIZE
),
1197 FLAG_GENERIC(STATX_BLOCKS
),
1200 FLAG_GENERIC(STATX_BTIME
),
1205 UNUSED
static struct flags falloc_flags
[] = {
1206 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE
),
1207 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE
),
1208 #ifdef FALLOC_FL_NO_HIDE_STALE
1209 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE
),
1211 #ifdef FALLOC_FL_COLLAPSE_RANGE
1212 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE
),
1214 #ifdef FALLOC_FL_ZERO_RANGE
1215 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE
),
1217 #ifdef FALLOC_FL_INSERT_RANGE
1218 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE
),
1220 #ifdef FALLOC_FL_UNSHARE_RANGE
1221 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE
),
1225 UNUSED
static struct flags termios_iflags
[] = {
1226 FLAG_TARGET(IGNBRK
),
1227 FLAG_TARGET(BRKINT
),
1228 FLAG_TARGET(IGNPAR
),
1229 FLAG_TARGET(PARMRK
),
1231 FLAG_TARGET(ISTRIP
),
1239 FLAG_TARGET(IMAXBEL
),
1244 UNUSED
static struct flags termios_oflags
[] = {
1250 FLAG_TARGET(ONLRET
),
1256 UNUSED
static struct enums termios_oflags_NLDLY
[] = {
1262 UNUSED
static struct enums termios_oflags_CRDLY
[] = {
1270 UNUSED
static struct enums termios_oflags_TABDLY
[] = {
1278 UNUSED
static struct enums termios_oflags_VTDLY
[] = {
1284 UNUSED
static struct enums termios_oflags_FFDLY
[] = {
1290 UNUSED
static struct enums termios_oflags_BSDLY
[] = {
1296 UNUSED
static struct enums termios_cflags_CBAUD
[] = {
1311 ENUM_TARGET(B19200
),
1312 ENUM_TARGET(B38400
),
1313 ENUM_TARGET(B57600
),
1314 ENUM_TARGET(B115200
),
1315 ENUM_TARGET(B230400
),
1316 ENUM_TARGET(B460800
),
1320 UNUSED
static struct enums termios_cflags_CSIZE
[] = {
1328 UNUSED
static struct flags termios_cflags
[] = {
1329 FLAG_TARGET(CSTOPB
),
1331 FLAG_TARGET(PARENB
),
1332 FLAG_TARGET(PARODD
),
1334 FLAG_TARGET(CLOCAL
),
1335 FLAG_TARGET(CRTSCTS
),
1339 UNUSED
static struct flags termios_lflags
[] = {
1341 FLAG_TARGET(ICANON
),
1346 FLAG_TARGET(ECHONL
),
1347 FLAG_TARGET(NOFLSH
),
1348 FLAG_TARGET(TOSTOP
),
1349 FLAG_TARGET(ECHOCTL
),
1350 FLAG_TARGET(ECHOPRT
),
1351 FLAG_TARGET(ECHOKE
),
1352 FLAG_TARGET(FLUSHO
),
1353 FLAG_TARGET(PENDIN
),
1354 FLAG_TARGET(IEXTEN
),
1355 FLAG_TARGET(EXTPROC
),
1359 UNUSED
static struct flags mlockall_flags
[] = {
1360 FLAG_TARGET(MCL_CURRENT
),
1361 FLAG_TARGET(MCL_FUTURE
),
1363 FLAG_TARGET(MCL_ONFAULT
),
1368 /* IDs of the various system clocks */
1369 #define TARGET_CLOCK_REALTIME 0
1370 #define TARGET_CLOCK_MONOTONIC 1
1371 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1372 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1373 #define TARGET_CLOCK_MONOTONIC_RAW 4
1374 #define TARGET_CLOCK_REALTIME_COARSE 5
1375 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1376 #define TARGET_CLOCK_BOOTTIME 7
1377 #define TARGET_CLOCK_REALTIME_ALARM 8
1378 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1379 #define TARGET_CLOCK_SGI_CYCLE 10
1380 #define TARGET_CLOCK_TAI 11
1382 UNUSED
static struct enums clockids
[] = {
1383 ENUM_TARGET(CLOCK_REALTIME
),
1384 ENUM_TARGET(CLOCK_MONOTONIC
),
1385 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID
),
1386 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID
),
1387 ENUM_TARGET(CLOCK_MONOTONIC_RAW
),
1388 ENUM_TARGET(CLOCK_REALTIME_COARSE
),
1389 ENUM_TARGET(CLOCK_MONOTONIC_COARSE
),
1390 ENUM_TARGET(CLOCK_BOOTTIME
),
1391 ENUM_TARGET(CLOCK_REALTIME_ALARM
),
1392 ENUM_TARGET(CLOCK_BOOTTIME_ALARM
),
1393 ENUM_TARGET(CLOCK_SGI_CYCLE
),
1394 ENUM_TARGET(CLOCK_TAI
),
1398 UNUSED
static struct enums itimer_types
[] = {
1399 ENUM_GENERIC(ITIMER_REAL
),
1400 ENUM_GENERIC(ITIMER_VIRTUAL
),
1401 ENUM_GENERIC(ITIMER_PROF
),
1406 * print_xxx utility functions. These are used to print syscall
1407 * parameters in certain format. All of these have parameter
1408 * named 'last'. This parameter is used to add comma to output
1415 return ((last
) ? "" : ",");
1419 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1421 const char *sep
= "";
1424 if ((flags
== 0) && (f
->f_value
== 0)) {
1425 qemu_log("%s%s", f
->f_string
, get_comma(last
));
1428 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1429 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1430 qemu_log("%s%s", sep
, f
->f_string
);
1431 flags
&= ~f
->f_value
;
1438 /* print rest of the flags as numeric */
1440 qemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1442 qemu_log("%s", get_comma(last
));
1445 /* no string version of flags found, print them in hex then */
1446 qemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1451 print_enums(const struct enums
*e
, abi_long enum_arg
, int last
)
1453 for (; e
->e_string
!= NULL
; e
++) {
1454 if (e
->e_value
== enum_arg
) {
1455 qemu_log("%s", e
->e_string
);
1460 if (e
->e_string
== NULL
) {
1461 qemu_log("%#x", (unsigned int)enum_arg
);
1464 qemu_log("%s", get_comma(last
));
1468 print_at_dirfd(abi_long dirfd
, int last
)
1471 if (dirfd
== AT_FDCWD
) {
1472 qemu_log("AT_FDCWD%s", get_comma(last
));
1476 qemu_log("%d%s", (int)dirfd
, get_comma(last
));
1480 print_file_mode(abi_long mode
, int last
)
1482 const char *sep
= "";
1483 const struct flags
*m
;
1485 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1486 if ((m
->f_value
& mode
) == m
->f_value
) {
1487 qemu_log("%s%s", m
->f_string
, sep
);
1489 mode
&= ~m
->f_value
;
1495 /* print rest of the mode as octal */
1497 qemu_log("%s%#o", sep
, (unsigned int)mode
);
1499 qemu_log("%s", get_comma(last
));
1503 print_open_flags(abi_long flags
, int last
)
1505 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1506 flags
&= ~TARGET_O_ACCMODE
;
1508 qemu_log("%s", get_comma(last
));
1512 print_flags(open_flags
, flags
, last
);
1516 print_syscall_prologue(const struct syscallname
*sc
)
1518 qemu_log("%s(", sc
->name
);
1523 print_syscall_epilogue(const struct syscallname
*sc
)
1530 print_string(abi_long addr
, int last
)
1534 if ((s
= lock_user_string(addr
)) != NULL
) {
1535 qemu_log("\"%s\"%s", s
, get_comma(last
));
1536 unlock_user(s
, addr
, 0);
1538 /* can't get string out of it, so print it as pointer */
1539 print_pointer(addr
, last
);
1543 #define MAX_PRINT_BUF 40
1545 print_buf(abi_long addr
, abi_long len
, int last
)
1550 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1553 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1554 if (isprint(s
[i
])) {
1555 qemu_log("%c", s
[i
]);
1557 qemu_log("\\%o", s
[i
]);
1567 unlock_user(s
, addr
, 0);
1569 print_pointer(addr
, last
);
1574 * Prints out raw parameter using given format. Caller needs
1575 * to do byte swapping if needed.
1578 print_raw_param(const char *fmt
, abi_long param
, int last
)
1582 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1583 qemu_log(format
, param
);
1587 print_pointer(abi_long p
, int last
)
1590 qemu_log("NULL%s", get_comma(last
));
1592 qemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1596 * Reads 32-bit (int) number from guest address space from
1597 * address 'addr' and prints it.
1600 print_number(abi_long addr
, int last
)
1603 qemu_log("NULL%s", get_comma(last
));
1607 get_user_s32(num
, addr
);
1608 qemu_log("[%d]%s", num
, get_comma(last
));
1613 print_timeval(abi_ulong tv_addr
, int last
)
1616 struct target_timeval
*tv
;
1618 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1620 print_pointer(tv_addr
, last
);
1623 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1624 ",tv_usec = " TARGET_ABI_FMT_ld
"}%s",
1625 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1626 unlock_user(tv
, tv_addr
, 0);
1628 qemu_log("NULL%s", get_comma(last
));
1632 print_timespec(abi_ulong ts_addr
, int last
)
1635 struct target_timespec
*ts
;
1637 ts
= lock_user(VERIFY_READ
, ts_addr
, sizeof(*ts
), 1);
1639 print_pointer(ts_addr
, last
);
1642 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1643 ",tv_nsec = " TARGET_ABI_FMT_ld
"}%s",
1644 tswapal(ts
->tv_sec
), tswapal(ts
->tv_nsec
), get_comma(last
));
1645 unlock_user(ts
, ts_addr
, 0);
1647 qemu_log("NULL%s", get_comma(last
));
1652 print_timezone(abi_ulong tz_addr
, int last
)
1655 struct target_timezone
*tz
;
1657 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1659 print_pointer(tz_addr
, last
);
1662 qemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1663 tswap32(tz
->tz_dsttime
), get_comma(last
));
1664 unlock_user(tz
, tz_addr
, 0);
1666 qemu_log("NULL%s", get_comma(last
));
1671 print_itimerval(abi_ulong it_addr
, int last
)
1674 qemu_log("{it_interval=");
1675 print_timeval(it_addr
+
1676 offsetof(struct target_itimerval
, it_interval
), 0);
1677 qemu_log("it_value=");
1678 print_timeval(it_addr
+
1679 offsetof(struct target_itimerval
, it_value
), 0);
1680 qemu_log("}%s", get_comma(last
));
1682 qemu_log("NULL%s", get_comma(last
));
1687 print_termios(void *arg
)
1689 const struct target_termios
*target
= arg
;
1691 target_tcflag_t iflags
= tswap32(target
->c_iflag
);
1692 target_tcflag_t oflags
= tswap32(target
->c_oflag
);
1693 target_tcflag_t cflags
= tswap32(target
->c_cflag
);
1694 target_tcflag_t lflags
= tswap32(target
->c_lflag
);
1698 qemu_log("c_iflag = ");
1699 print_flags(termios_iflags
, iflags
, 0);
1701 qemu_log("c_oflag = ");
1702 target_tcflag_t oflags_clean
= oflags
& ~(TARGET_NLDLY
| TARGET_CRDLY
|
1703 TARGET_TABDLY
| TARGET_BSDLY
|
1704 TARGET_VTDLY
| TARGET_FFDLY
);
1705 print_flags(termios_oflags
, oflags_clean
, 0);
1706 if (oflags
& TARGET_NLDLY
) {
1707 print_enums(termios_oflags_NLDLY
, oflags
& TARGET_NLDLY
, 0);
1709 if (oflags
& TARGET_CRDLY
) {
1710 print_enums(termios_oflags_CRDLY
, oflags
& TARGET_CRDLY
, 0);
1712 if (oflags
& TARGET_TABDLY
) {
1713 print_enums(termios_oflags_TABDLY
, oflags
& TARGET_TABDLY
, 0);
1715 if (oflags
& TARGET_BSDLY
) {
1716 print_enums(termios_oflags_BSDLY
, oflags
& TARGET_BSDLY
, 0);
1718 if (oflags
& TARGET_VTDLY
) {
1719 print_enums(termios_oflags_VTDLY
, oflags
& TARGET_VTDLY
, 0);
1721 if (oflags
& TARGET_FFDLY
) {
1722 print_enums(termios_oflags_FFDLY
, oflags
& TARGET_FFDLY
, 0);
1725 qemu_log("c_cflag = ");
1726 if (cflags
& TARGET_CBAUD
) {
1727 print_enums(termios_cflags_CBAUD
, cflags
& TARGET_CBAUD
, 0);
1729 if (cflags
& TARGET_CSIZE
) {
1730 print_enums(termios_cflags_CSIZE
, cflags
& TARGET_CSIZE
, 0);
1732 target_tcflag_t cflags_clean
= cflags
& ~(TARGET_CBAUD
| TARGET_CSIZE
);
1733 print_flags(termios_cflags
, cflags_clean
, 0);
1735 qemu_log("c_lflag = ");
1736 print_flags(termios_lflags
, lflags
, 0);
1738 qemu_log("c_cc = ");
1739 qemu_log("\"%s\",", target
->c_cc
);
1741 qemu_log("c_line = ");
1742 print_raw_param("\'%c\'", target
->c_line
, 1);
1749 #ifdef TARGET_NR_accept
1751 print_accept(void *cpu_env
, const struct syscallname
*name
,
1752 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1753 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1755 print_syscall_prologue(name
);
1756 print_raw_param("%d", arg0
, 0);
1757 print_pointer(arg1
, 0);
1758 print_number(arg2
, 1);
1759 print_syscall_epilogue(name
);
1763 #ifdef TARGET_NR_access
1765 print_access(void *cpu_env
, const struct syscallname
*name
,
1766 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1767 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1769 print_syscall_prologue(name
);
1770 print_string(arg0
, 0);
1771 print_flags(access_flags
, arg1
, 1);
1772 print_syscall_epilogue(name
);
1776 #ifdef TARGET_NR_acct
1778 print_acct(void *cpu_env
, const struct syscallname
*name
,
1779 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1780 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1782 print_syscall_prologue(name
);
1783 print_string(arg0
, 1);
1784 print_syscall_epilogue(name
);
1788 #ifdef TARGET_NR_brk
1790 print_brk(void *cpu_env
, const struct syscallname
*name
,
1791 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1792 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1794 print_syscall_prologue(name
);
1795 print_pointer(arg0
, 1);
1796 print_syscall_epilogue(name
);
1800 #ifdef TARGET_NR_chdir
1802 print_chdir(void *cpu_env
, const struct syscallname
*name
,
1803 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1804 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1806 print_syscall_prologue(name
);
1807 print_string(arg0
, 1);
1808 print_syscall_epilogue(name
);
1812 #ifdef TARGET_NR_chroot
1814 print_chroot(void *cpu_env
, const struct syscallname
*name
,
1815 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1816 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1818 print_syscall_prologue(name
);
1819 print_string(arg0
, 1);
1820 print_syscall_epilogue(name
);
1824 #ifdef TARGET_NR_chmod
1826 print_chmod(void *cpu_env
, const struct syscallname
*name
,
1827 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1828 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1830 print_syscall_prologue(name
);
1831 print_string(arg0
, 0);
1832 print_file_mode(arg1
, 1);
1833 print_syscall_epilogue(name
);
1837 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1839 print_chown(void *cpu_env
, const struct syscallname
*name
,
1840 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1841 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1843 print_syscall_prologue(name
);
1844 print_string(arg0
, 0);
1845 print_raw_param("%d", arg1
, 0);
1846 print_raw_param("%d", arg2
, 1);
1847 print_syscall_epilogue(name
);
1849 #define print_lchown print_chown
1852 #ifdef TARGET_NR_clock_adjtime
1854 print_clock_adjtime(void *cpu_env
, const struct syscallname
*name
,
1855 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1856 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1858 print_syscall_prologue(name
);
1859 print_enums(clockids
, arg0
, 0);
1860 print_pointer(arg1
, 1);
1861 print_syscall_epilogue(name
);
1865 #ifdef TARGET_NR_clone
1866 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1867 abi_ulong parent_tidptr
, target_ulong newtls
,
1868 abi_ulong child_tidptr
)
1870 print_flags(clone_flags
, flags
, 0);
1871 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1872 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1873 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1874 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1878 print_clone(void *cpu_env
, const struct syscallname
*name
,
1879 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1880 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1882 print_syscall_prologue(name
);
1883 #if defined(TARGET_MICROBLAZE)
1884 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1885 #elif defined(TARGET_CLONE_BACKWARDS)
1886 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1887 #elif defined(TARGET_CLONE_BACKWARDS2)
1888 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1890 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1892 print_syscall_epilogue(name
);
1896 #ifdef TARGET_NR_creat
1898 print_creat(void *cpu_env
, const struct syscallname
*name
,
1899 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1900 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1902 print_syscall_prologue(name
);
1903 print_string(arg0
, 0);
1904 print_file_mode(arg1
, 1);
1905 print_syscall_epilogue(name
);
1909 #ifdef TARGET_NR_execv
1911 print_execv(void *cpu_env
, const struct syscallname
*name
,
1912 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1913 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1915 print_syscall_prologue(name
);
1916 print_string(arg0
, 0);
1917 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1918 print_syscall_epilogue(name
);
1922 #ifdef TARGET_NR_faccessat
1924 print_faccessat(void *cpu_env
, const struct syscallname
*name
,
1925 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1926 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1928 print_syscall_prologue(name
);
1929 print_at_dirfd(arg0
, 0);
1930 print_string(arg1
, 0);
1931 print_flags(access_flags
, arg2
, 0);
1932 print_flags(at_file_flags
, arg3
, 1);
1933 print_syscall_epilogue(name
);
1937 #ifdef TARGET_NR_fallocate
1939 print_fallocate(void *cpu_env
, const struct syscallname
*name
,
1940 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1941 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1943 print_syscall_prologue(name
);
1944 print_raw_param("%d", arg0
, 0);
1945 print_flags(falloc_flags
, arg1
, 0);
1946 #if TARGET_ABI_BITS == 32
1947 print_raw_param("%" PRIu64
, target_offset64(arg2
, arg3
), 0);
1948 print_raw_param("%" PRIu64
, target_offset64(arg4
, arg5
), 1);
1950 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1951 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 1);
1953 print_syscall_epilogue(name
);
1957 #ifdef TARGET_NR_fchmodat
1959 print_fchmodat(void *cpu_env
, const struct syscallname
*name
,
1960 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1961 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1963 print_syscall_prologue(name
);
1964 print_at_dirfd(arg0
, 0);
1965 print_string(arg1
, 0);
1966 print_file_mode(arg2
, 0);
1967 print_flags(at_file_flags
, arg3
, 1);
1968 print_syscall_epilogue(name
);
1972 #ifdef TARGET_NR_fchownat
1974 print_fchownat(void *cpu_env
, const struct syscallname
*name
,
1975 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1976 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1978 print_syscall_prologue(name
);
1979 print_at_dirfd(arg0
, 0);
1980 print_string(arg1
, 0);
1981 print_raw_param("%d", arg2
, 0);
1982 print_raw_param("%d", arg3
, 0);
1983 print_flags(at_file_flags
, arg4
, 1);
1984 print_syscall_epilogue(name
);
1988 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1990 print_fcntl(void *cpu_env
, const struct syscallname
*name
,
1991 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1992 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1994 print_syscall_prologue(name
);
1995 print_raw_param("%d", arg0
, 0);
1997 case TARGET_F_DUPFD
:
1998 qemu_log("F_DUPFD,");
1999 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2001 case TARGET_F_GETFD
:
2002 qemu_log("F_GETFD");
2004 case TARGET_F_SETFD
:
2005 qemu_log("F_SETFD,");
2006 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2008 case TARGET_F_GETFL
:
2009 qemu_log("F_GETFL");
2011 case TARGET_F_SETFL
:
2012 qemu_log("F_SETFL,");
2013 print_open_flags(arg2
, 1);
2015 case TARGET_F_GETLK
:
2016 qemu_log("F_GETLK,");
2017 print_pointer(arg2
, 1);
2019 case TARGET_F_SETLK
:
2020 qemu_log("F_SETLK,");
2021 print_pointer(arg2
, 1);
2023 case TARGET_F_SETLKW
:
2024 qemu_log("F_SETLKW,");
2025 print_pointer(arg2
, 1);
2027 case TARGET_F_GETOWN
:
2028 qemu_log("F_GETOWN");
2030 case TARGET_F_SETOWN
:
2031 qemu_log("F_SETOWN,");
2032 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2034 case TARGET_F_GETSIG
:
2035 qemu_log("F_GETSIG");
2037 case TARGET_F_SETSIG
:
2038 qemu_log("F_SETSIG,");
2039 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2041 #if TARGET_ABI_BITS == 32
2042 case TARGET_F_GETLK64
:
2043 qemu_log("F_GETLK64,");
2044 print_pointer(arg2
, 1);
2046 case TARGET_F_SETLK64
:
2047 qemu_log("F_SETLK64,");
2048 print_pointer(arg2
, 1);
2050 case TARGET_F_SETLKW64
:
2051 qemu_log("F_SETLKW64,");
2052 print_pointer(arg2
, 1);
2055 case TARGET_F_OFD_GETLK
:
2056 qemu_log("F_OFD_GETLK,");
2057 print_pointer(arg2
, 1);
2059 case TARGET_F_OFD_SETLK
:
2060 qemu_log("F_OFD_SETLK,");
2061 print_pointer(arg2
, 1);
2063 case TARGET_F_OFD_SETLKW
:
2064 qemu_log("F_OFD_SETLKW,");
2065 print_pointer(arg2
, 1);
2067 case TARGET_F_SETLEASE
:
2068 qemu_log("F_SETLEASE,");
2069 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2071 case TARGET_F_GETLEASE
:
2072 qemu_log("F_GETLEASE");
2074 #ifdef F_DUPFD_CLOEXEC
2075 case TARGET_F_DUPFD_CLOEXEC
:
2076 qemu_log("F_DUPFD_CLOEXEC,");
2077 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2080 case TARGET_F_NOTIFY
:
2081 qemu_log("F_NOTIFY,");
2082 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2085 case TARGET_F_GETOWN_EX
:
2086 qemu_log("F_GETOWN_EX,");
2087 print_pointer(arg2
, 1);
2091 case TARGET_F_SETOWN_EX
:
2092 qemu_log("F_SETOWN_EX,");
2093 print_pointer(arg2
, 1);
2097 case TARGET_F_SETPIPE_SZ
:
2098 qemu_log("F_SETPIPE_SZ,");
2099 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2101 case TARGET_F_GETPIPE_SZ
:
2102 qemu_log("F_GETPIPE_SZ");
2106 case TARGET_F_ADD_SEALS
:
2107 qemu_log("F_ADD_SEALS,");
2108 print_raw_param("0x"TARGET_ABI_FMT_lx
, arg2
, 1);
2110 case TARGET_F_GET_SEALS
:
2111 qemu_log("F_GET_SEALS");
2115 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2116 print_pointer(arg2
, 1);
2119 print_syscall_epilogue(name
);
2121 #define print_fcntl64 print_fcntl
2124 #ifdef TARGET_NR_fgetxattr
2126 print_fgetxattr(void *cpu_env
, const struct syscallname
*name
,
2127 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2128 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2130 print_syscall_prologue(name
);
2131 print_raw_param("%d", arg0
, 0);
2132 print_string(arg1
, 0);
2133 print_pointer(arg2
, 0);
2134 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2135 print_syscall_epilogue(name
);
2139 #ifdef TARGET_NR_flistxattr
2141 print_flistxattr(void *cpu_env
, const struct syscallname
*name
,
2142 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2143 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2145 print_syscall_prologue(name
);
2146 print_raw_param("%d", arg0
, 0);
2147 print_pointer(arg1
, 0);
2148 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2149 print_syscall_epilogue(name
);
2153 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2155 print_getxattr(void *cpu_env
, const struct syscallname
*name
,
2156 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2157 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2159 print_syscall_prologue(name
);
2160 print_string(arg0
, 0);
2161 print_string(arg1
, 0);
2162 print_pointer(arg2
, 0);
2163 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2164 print_syscall_epilogue(name
);
2166 #define print_lgetxattr print_getxattr
2169 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2171 print_listxattr(void *cpu_env
, const struct syscallname
*name
,
2172 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2173 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2175 print_syscall_prologue(name
);
2176 print_string(arg0
, 0);
2177 print_pointer(arg1
, 0);
2178 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2179 print_syscall_epilogue(name
);
2181 #define print_llistxattr print_listxattr
2184 #if defined(TARGET_NR_fremovexattr)
2186 print_fremovexattr(void *cpu_env
, const struct syscallname
*name
,
2187 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2188 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2190 print_syscall_prologue(name
);
2191 print_raw_param("%d", arg0
, 0);
2192 print_string(arg1
, 1);
2193 print_syscall_epilogue(name
);
2197 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2199 print_removexattr(void *cpu_env
, const struct syscallname
*name
,
2200 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2201 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2203 print_syscall_prologue(name
);
2204 print_string(arg0
, 0);
2205 print_string(arg1
, 1);
2206 print_syscall_epilogue(name
);
2208 #define print_lremovexattr print_removexattr
2211 #ifdef TARGET_NR_futimesat
2213 print_futimesat(void *cpu_env
, const struct syscallname
*name
,
2214 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2215 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2217 print_syscall_prologue(name
);
2218 print_at_dirfd(arg0
, 0);
2219 print_string(arg1
, 0);
2220 print_timeval(arg2
, 0);
2221 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
2222 print_syscall_epilogue(name
);
2226 #ifdef TARGET_NR_gettimeofday
2228 print_gettimeofday(void *cpu_env
, const struct syscallname
*name
,
2229 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2230 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2232 print_syscall_prologue(name
);
2233 print_pointer(arg0
, 0);
2234 print_pointer(arg1
, 1);
2235 print_syscall_epilogue(name
);
2239 #ifdef TARGET_NR_settimeofday
2241 print_settimeofday(void *cpu_env
, const struct syscallname
*name
,
2242 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2243 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2245 print_syscall_prologue(name
);
2246 print_timeval(arg0
, 0);
2247 print_timezone(arg1
, 1);
2248 print_syscall_epilogue(name
);
2252 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2254 print_clock_gettime(void *cpu_env
, const struct syscallname
*name
,
2255 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2256 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2258 print_syscall_prologue(name
);
2259 print_enums(clockids
, arg0
, 0);
2260 print_pointer(arg1
, 1);
2261 print_syscall_epilogue(name
);
2263 #define print_clock_getres print_clock_gettime
2266 #ifdef TARGET_NR_clock_settime
2268 print_clock_settime(void *cpu_env
, const struct syscallname
*name
,
2269 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2270 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2272 print_syscall_prologue(name
);
2273 print_enums(clockids
, arg0
, 0);
2274 print_timespec(arg1
, 1);
2275 print_syscall_epilogue(name
);
2279 #ifdef TARGET_NR_getitimer
2281 print_getitimer(void *cpu_env
, const struct syscallname
*name
,
2282 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2283 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2285 print_syscall_prologue(name
);
2286 print_enums(itimer_types
, arg0
, 0);
2287 print_pointer(arg1
, 1);
2288 print_syscall_epilogue(name
);
2292 #ifdef TARGET_NR_setitimer
2294 print_setitimer(void *cpu_env
, const struct syscallname
*name
,
2295 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2296 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2298 print_syscall_prologue(name
);
2299 print_enums(itimer_types
, arg0
, 0);
2300 print_itimerval(arg1
, 0);
2301 print_pointer(arg2
, 1);
2302 print_syscall_epilogue(name
);
2306 #ifdef TARGET_NR_link
2308 print_link(void *cpu_env
, const struct syscallname
*name
,
2309 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2310 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2312 print_syscall_prologue(name
);
2313 print_string(arg0
, 0);
2314 print_string(arg1
, 1);
2315 print_syscall_epilogue(name
);
2319 #ifdef TARGET_NR_linkat
2321 print_linkat(void *cpu_env
, const struct syscallname
*name
,
2322 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2323 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2325 print_syscall_prologue(name
);
2326 print_at_dirfd(arg0
, 0);
2327 print_string(arg1
, 0);
2328 print_at_dirfd(arg2
, 0);
2329 print_string(arg3
, 0);
2330 print_flags(at_file_flags
, arg4
, 1);
2331 print_syscall_epilogue(name
);
2335 #ifdef TARGET_NR__llseek
2337 print__llseek(void *cpu_env
, const struct syscallname
*name
,
2338 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2339 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2341 const char *whence
= "UNKNOWN";
2342 print_syscall_prologue(name
);
2343 print_raw_param("%d", arg0
, 0);
2344 print_raw_param("%ld", arg1
, 0);
2345 print_raw_param("%ld", arg2
, 0);
2346 print_pointer(arg3
, 0);
2348 case SEEK_SET
: whence
= "SEEK_SET"; break;
2349 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
2350 case SEEK_END
: whence
= "SEEK_END"; break;
2352 qemu_log("%s", whence
);
2353 print_syscall_epilogue(name
);
2357 #ifdef TARGET_NR_lseek
2359 print_lseek(void *cpu_env
, const struct syscallname
*name
,
2360 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2361 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2363 print_syscall_prologue(name
);
2364 print_raw_param("%d", arg0
, 0);
2365 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2368 qemu_log("SEEK_SET"); break;
2370 qemu_log("SEEK_CUR"); break;
2372 qemu_log("SEEK_END"); break;
2375 qemu_log("SEEK_DATA"); break;
2379 qemu_log("SEEK_HOLE"); break;
2382 print_raw_param("%#x", arg2
, 1);
2384 print_syscall_epilogue(name
);
2388 #ifdef TARGET_NR_truncate
2390 print_truncate(void *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_raw_param(TARGET_ABI_FMT_ld
, arg1
, 1);
2397 print_syscall_epilogue(name
);
2401 #ifdef TARGET_NR_truncate64
2403 print_truncate64(void *cpu_env
, const struct syscallname
*name
,
2404 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2405 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2407 print_syscall_prologue(name
);
2408 print_string(arg0
, 0);
2409 if (regpairs_aligned(cpu_env
, TARGET_NR_truncate64
)) {
2413 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2414 print_syscall_epilogue(name
);
2418 #ifdef TARGET_NR_ftruncate64
2420 print_ftruncate64(void *cpu_env
, const struct syscallname
*name
,
2421 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2422 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2424 print_syscall_prologue(name
);
2425 print_raw_param("%d", arg0
, 0);
2426 if (regpairs_aligned(cpu_env
, TARGET_NR_ftruncate64
)) {
2430 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2431 print_syscall_epilogue(name
);
2435 #ifdef TARGET_NR_mlockall
2437 print_mlockall(void *cpu_env
, const struct syscallname
*name
,
2438 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2439 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2441 print_syscall_prologue(name
);
2442 print_flags(mlockall_flags
, arg0
, 1);
2443 print_syscall_epilogue(name
);
2447 #if defined(TARGET_NR_socket)
2449 print_socket(void *cpu_env
, const struct syscallname
*name
,
2450 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2451 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2453 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
2455 print_syscall_prologue(name
);
2456 print_socket_domain(domain
);
2458 print_socket_type(type
);
2460 if (domain
== AF_PACKET
||
2461 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2462 protocol
= tswap16(protocol
);
2464 print_socket_protocol(domain
, type
, protocol
);
2465 print_syscall_epilogue(name
);
2470 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2472 static void print_sockfd(abi_long sockfd
, int last
)
2474 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
2479 #if defined(TARGET_NR_socketcall)
2481 #define get_user_ualx(x, gaddr, idx) \
2482 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2484 static void do_print_socket(const char *name
, abi_long arg1
)
2486 abi_ulong domain
, type
, protocol
;
2488 get_user_ualx(domain
, arg1
, 0);
2489 get_user_ualx(type
, arg1
, 1);
2490 get_user_ualx(protocol
, arg1
, 2);
2491 qemu_log("%s(", name
);
2492 print_socket_domain(domain
);
2494 print_socket_type(type
);
2496 if (domain
== AF_PACKET
||
2497 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2498 protocol
= tswap16(protocol
);
2500 print_socket_protocol(domain
, type
, protocol
);
2504 static void do_print_sockaddr(const char *name
, abi_long arg1
)
2506 abi_ulong sockfd
, addr
, addrlen
;
2508 get_user_ualx(sockfd
, arg1
, 0);
2509 get_user_ualx(addr
, arg1
, 1);
2510 get_user_ualx(addrlen
, arg1
, 2);
2512 qemu_log("%s(", name
);
2513 print_sockfd(sockfd
, 0);
2514 print_sockaddr(addr
, addrlen
, 0);
2518 static void do_print_listen(const char *name
, abi_long arg1
)
2520 abi_ulong sockfd
, backlog
;
2522 get_user_ualx(sockfd
, arg1
, 0);
2523 get_user_ualx(backlog
, arg1
, 1);
2525 qemu_log("%s(", name
);
2526 print_sockfd(sockfd
, 0);
2527 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
2531 static void do_print_socketpair(const char *name
, abi_long arg1
)
2533 abi_ulong domain
, type
, protocol
, tab
;
2535 get_user_ualx(domain
, arg1
, 0);
2536 get_user_ualx(type
, arg1
, 1);
2537 get_user_ualx(protocol
, arg1
, 2);
2538 get_user_ualx(tab
, arg1
, 3);
2540 qemu_log("%s(", name
);
2541 print_socket_domain(domain
);
2543 print_socket_type(type
);
2545 print_socket_protocol(domain
, type
, protocol
);
2547 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
2551 static void do_print_sendrecv(const char *name
, abi_long arg1
)
2553 abi_ulong sockfd
, msg
, len
, flags
;
2555 get_user_ualx(sockfd
, arg1
, 0);
2556 get_user_ualx(msg
, arg1
, 1);
2557 get_user_ualx(len
, arg1
, 2);
2558 get_user_ualx(flags
, arg1
, 3);
2560 qemu_log("%s(", name
);
2561 print_sockfd(sockfd
, 0);
2562 print_buf(msg
, len
, 0);
2563 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2564 print_flags(msg_flags
, flags
, 1);
2568 static void do_print_msgaddr(const char *name
, abi_long arg1
)
2570 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
2572 get_user_ualx(sockfd
, arg1
, 0);
2573 get_user_ualx(msg
, arg1
, 1);
2574 get_user_ualx(len
, arg1
, 2);
2575 get_user_ualx(flags
, arg1
, 3);
2576 get_user_ualx(addr
, arg1
, 4);
2577 get_user_ualx(addrlen
, arg1
, 5);
2579 qemu_log("%s(", name
);
2580 print_sockfd(sockfd
, 0);
2581 print_buf(msg
, len
, 0);
2582 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2583 print_flags(msg_flags
, flags
, 0);
2584 print_sockaddr(addr
, addrlen
, 0);
2588 static void do_print_shutdown(const char *name
, abi_long arg1
)
2590 abi_ulong sockfd
, how
;
2592 get_user_ualx(sockfd
, arg1
, 0);
2593 get_user_ualx(how
, arg1
, 1);
2595 qemu_log("shutdown(");
2596 print_sockfd(sockfd
, 0);
2599 qemu_log("SHUT_RD");
2602 qemu_log("SHUT_WR");
2605 qemu_log("SHUT_RDWR");
2608 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
2614 static void do_print_msg(const char *name
, abi_long arg1
)
2616 abi_ulong sockfd
, msg
, flags
;
2618 get_user_ualx(sockfd
, arg1
, 0);
2619 get_user_ualx(msg
, arg1
, 1);
2620 get_user_ualx(flags
, arg1
, 2);
2622 qemu_log("%s(", name
);
2623 print_sockfd(sockfd
, 0);
2624 print_pointer(msg
, 0);
2625 print_flags(msg_flags
, flags
, 1);
2629 static void do_print_sockopt(const char *name
, abi_long arg1
)
2631 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
2633 get_user_ualx(sockfd
, arg1
, 0);
2634 get_user_ualx(level
, arg1
, 1);
2635 get_user_ualx(optname
, arg1
, 2);
2636 get_user_ualx(optval
, arg1
, 3);
2637 get_user_ualx(optlen
, arg1
, 4);
2639 qemu_log("%s(", name
);
2640 print_sockfd(sockfd
, 0);
2643 qemu_log("SOL_TCP,");
2644 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2645 print_pointer(optval
, 0);
2648 qemu_log("SOL_IP,");
2649 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2650 print_pointer(optval
, 0);
2653 qemu_log("SOL_RAW,");
2654 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2655 print_pointer(optval
, 0);
2657 case TARGET_SOL_SOCKET
:
2658 qemu_log("SOL_SOCKET,");
2660 case TARGET_SO_DEBUG
:
2661 qemu_log("SO_DEBUG,");
2663 print_number(optval
, 0);
2665 case TARGET_SO_REUSEADDR
:
2666 qemu_log("SO_REUSEADDR,");
2668 case TARGET_SO_REUSEPORT
:
2669 qemu_log("SO_REUSEPORT,");
2671 case TARGET_SO_TYPE
:
2672 qemu_log("SO_TYPE,");
2674 case TARGET_SO_ERROR
:
2675 qemu_log("SO_ERROR,");
2677 case TARGET_SO_DONTROUTE
:
2678 qemu_log("SO_DONTROUTE,");
2680 case TARGET_SO_BROADCAST
:
2681 qemu_log("SO_BROADCAST,");
2683 case TARGET_SO_SNDBUF
:
2684 qemu_log("SO_SNDBUF,");
2686 case TARGET_SO_RCVBUF
:
2687 qemu_log("SO_RCVBUF,");
2689 case TARGET_SO_KEEPALIVE
:
2690 qemu_log("SO_KEEPALIVE,");
2692 case TARGET_SO_OOBINLINE
:
2693 qemu_log("SO_OOBINLINE,");
2695 case TARGET_SO_NO_CHECK
:
2696 qemu_log("SO_NO_CHECK,");
2698 case TARGET_SO_PRIORITY
:
2699 qemu_log("SO_PRIORITY,");
2701 case TARGET_SO_BSDCOMPAT
:
2702 qemu_log("SO_BSDCOMPAT,");
2704 case TARGET_SO_PASSCRED
:
2705 qemu_log("SO_PASSCRED,");
2707 case TARGET_SO_TIMESTAMP
:
2708 qemu_log("SO_TIMESTAMP,");
2710 case TARGET_SO_RCVLOWAT
:
2711 qemu_log("SO_RCVLOWAT,");
2713 case TARGET_SO_RCVTIMEO
:
2714 qemu_log("SO_RCVTIMEO,");
2715 print_timeval(optval
, 0);
2717 case TARGET_SO_SNDTIMEO
:
2718 qemu_log("SO_SNDTIMEO,");
2719 print_timeval(optval
, 0);
2721 case TARGET_SO_ATTACH_FILTER
: {
2722 struct target_sock_fprog
*fprog
;
2724 qemu_log("SO_ATTACH_FILTER,");
2726 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
2727 struct target_sock_filter
*filter
;
2729 if (lock_user_struct(VERIFY_READ
, filter
,
2730 tswapal(fprog
->filter
), 0)) {
2732 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
2733 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2734 i
, tswap16(filter
[i
].code
),
2735 filter
[i
].jt
, filter
[i
].jf
,
2736 tswap32(filter
[i
].k
));
2738 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2739 i
, tswap16(filter
[i
].code
),
2740 filter
[i
].jt
, filter
[i
].jf
,
2741 tswap32(filter
[i
].k
));
2743 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
2745 qemu_log(",%d},", tswap16(fprog
->len
));
2746 unlock_user(fprog
, optval
, 0);
2748 print_pointer(optval
, 0);
2753 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2754 print_pointer(optval
, 0);
2759 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
2760 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2761 print_pointer(optval
, 0);
2764 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
2768 #define PRINT_SOCKOP(name, func) \
2769 [TARGET_SYS_##name] = { #name, func }
2773 void (*print
)(const char *, abi_long
);
2775 PRINT_SOCKOP(SOCKET
, do_print_socket
),
2776 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
2777 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
2778 PRINT_SOCKOP(LISTEN
, do_print_listen
),
2779 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
2780 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
2781 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
2782 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
2783 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
2784 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
2785 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
2786 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
2787 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
2788 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
2789 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
2790 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
2791 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
2792 PRINT_SOCKOP(ACCEPT4
, NULL
),
2793 PRINT_SOCKOP(RECVMMSG
, NULL
),
2794 PRINT_SOCKOP(SENDMMSG
, NULL
),
2798 print_socketcall(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 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
2803 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
2806 print_syscall_prologue(name
);
2807 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
2808 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2809 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2810 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
2811 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
2812 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
2813 print_syscall_epilogue(name
);
2817 #if defined(TARGET_NR_bind)
2819 print_bind(void *cpu_env
, const struct syscallname
*name
,
2820 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2821 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2823 print_syscall_prologue(name
);
2824 print_sockfd(arg0
, 0);
2825 print_sockaddr(arg1
, arg2
, 1);
2826 print_syscall_epilogue(name
);
2830 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2831 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2833 print_stat(void *cpu_env
, const struct syscallname
*name
,
2834 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2835 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2837 print_syscall_prologue(name
);
2838 print_string(arg0
, 0);
2839 print_pointer(arg1
, 1);
2840 print_syscall_epilogue(name
);
2842 #define print_lstat print_stat
2843 #define print_stat64 print_stat
2844 #define print_lstat64 print_stat
2847 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2849 print_fstat(void *cpu_env
, const struct syscallname
*name
,
2850 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2851 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2853 print_syscall_prologue(name
);
2854 print_raw_param("%d", arg0
, 0);
2855 print_pointer(arg1
, 1);
2856 print_syscall_epilogue(name
);
2858 #define print_fstat64 print_fstat
2861 #ifdef TARGET_NR_mkdir
2863 print_mkdir(void *cpu_env
, const struct syscallname
*name
,
2864 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2865 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2867 print_syscall_prologue(name
);
2868 print_string(arg0
, 0);
2869 print_file_mode(arg1
, 1);
2870 print_syscall_epilogue(name
);
2874 #ifdef TARGET_NR_mkdirat
2876 print_mkdirat(void *cpu_env
, const struct syscallname
*name
,
2877 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2878 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2880 print_syscall_prologue(name
);
2881 print_at_dirfd(arg0
, 0);
2882 print_string(arg1
, 0);
2883 print_file_mode(arg2
, 1);
2884 print_syscall_epilogue(name
);
2888 #ifdef TARGET_NR_rmdir
2890 print_rmdir(void *cpu_env
, const struct syscallname
*name
,
2891 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2892 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2894 print_syscall_prologue(name
);
2895 print_string(arg0
, 0);
2896 print_syscall_epilogue(name
);
2900 #ifdef TARGET_NR_rt_sigaction
2902 print_rt_sigaction(void *cpu_env
, const struct syscallname
*name
,
2903 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2904 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2906 print_syscall_prologue(name
);
2907 print_signal(arg0
, 0);
2908 print_pointer(arg1
, 0);
2909 print_pointer(arg2
, 1);
2910 print_syscall_epilogue(name
);
2914 #ifdef TARGET_NR_rt_sigprocmask
2916 print_rt_sigprocmask(void *cpu_env
, const struct syscallname
*name
,
2917 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2918 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2920 const char *how
= "UNKNOWN";
2921 print_syscall_prologue(name
);
2923 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2924 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2925 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2927 qemu_log("%s,", how
);
2928 print_pointer(arg1
, 0);
2929 print_pointer(arg2
, 1);
2930 print_syscall_epilogue(name
);
2934 #ifdef TARGET_NR_rt_sigqueueinfo
2936 print_rt_sigqueueinfo(void *cpu_env
, const struct syscallname
*name
,
2937 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2938 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2941 target_siginfo_t uinfo
;
2943 print_syscall_prologue(name
);
2944 print_raw_param("%d", arg0
, 0);
2945 print_signal(arg1
, 0);
2946 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2948 get_target_siginfo(&uinfo
, p
);
2949 print_siginfo(&uinfo
);
2951 unlock_user(p
, arg2
, 0);
2953 print_pointer(arg2
, 1);
2955 print_syscall_epilogue(name
);
2959 #ifdef TARGET_NR_rt_tgsigqueueinfo
2961 print_rt_tgsigqueueinfo(void *cpu_env
, const struct syscallname
*name
,
2962 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2963 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2966 target_siginfo_t uinfo
;
2968 print_syscall_prologue(name
);
2969 print_raw_param("%d", arg0
, 0);
2970 print_raw_param("%d", arg1
, 0);
2971 print_signal(arg2
, 0);
2972 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2974 get_target_siginfo(&uinfo
, p
);
2975 print_siginfo(&uinfo
);
2977 unlock_user(p
, arg3
, 0);
2979 print_pointer(arg3
, 1);
2981 print_syscall_epilogue(name
);
2985 #ifdef TARGET_NR_syslog
2987 print_syslog_action(abi_ulong arg
, int last
)
2992 case TARGET_SYSLOG_ACTION_CLOSE
: {
2993 type
= "SYSLOG_ACTION_CLOSE";
2996 case TARGET_SYSLOG_ACTION_OPEN
: {
2997 type
= "SYSLOG_ACTION_OPEN";
3000 case TARGET_SYSLOG_ACTION_READ
: {
3001 type
= "SYSLOG_ACTION_READ";
3004 case TARGET_SYSLOG_ACTION_READ_ALL
: {
3005 type
= "SYSLOG_ACTION_READ_ALL";
3008 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
3009 type
= "SYSLOG_ACTION_READ_CLEAR";
3012 case TARGET_SYSLOG_ACTION_CLEAR
: {
3013 type
= "SYSLOG_ACTION_CLEAR";
3016 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
3017 type
= "SYSLOG_ACTION_CONSOLE_OFF";
3020 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
3021 type
= "SYSLOG_ACTION_CONSOLE_ON";
3024 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
3025 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
3028 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
3029 type
= "SYSLOG_ACTION_SIZE_UNREAD";
3032 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
3033 type
= "SYSLOG_ACTION_SIZE_BUFFER";
3037 print_raw_param("%ld", arg
, last
);
3041 qemu_log("%s%s", type
, get_comma(last
));
3045 print_syslog(void *cpu_env
, const struct syscallname
*name
,
3046 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3047 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3049 print_syscall_prologue(name
);
3050 print_syslog_action(arg0
, 0);
3051 print_pointer(arg1
, 0);
3052 print_raw_param("%d", arg2
, 1);
3053 print_syscall_epilogue(name
);
3057 #ifdef TARGET_NR_mknod
3059 print_mknod(void *cpu_env
, const struct syscallname
*name
,
3060 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3061 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3063 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
3065 print_syscall_prologue(name
);
3066 print_string(arg0
, 0);
3067 print_file_mode(arg1
, (hasdev
== 0));
3069 print_raw_param("makedev(%d", major(arg2
), 0);
3070 print_raw_param("%d)", minor(arg2
), 1);
3072 print_syscall_epilogue(name
);
3076 #ifdef TARGET_NR_mknodat
3078 print_mknodat(void *cpu_env
, const struct syscallname
*name
,
3079 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3080 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3082 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
3084 print_syscall_prologue(name
);
3085 print_at_dirfd(arg0
, 0);
3086 print_string(arg1
, 0);
3087 print_file_mode(arg2
, (hasdev
== 0));
3089 print_raw_param("makedev(%d", major(arg3
), 0);
3090 print_raw_param("%d)", minor(arg3
), 1);
3092 print_syscall_epilogue(name
);
3096 #ifdef TARGET_NR_mq_open
3098 print_mq_open(void *cpu_env
, const struct syscallname
*name
,
3099 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3100 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3102 int is_creat
= (arg1
& TARGET_O_CREAT
);
3104 print_syscall_prologue(name
);
3105 print_string(arg0
, 0);
3106 print_open_flags(arg1
, (is_creat
== 0));
3108 print_file_mode(arg2
, 0);
3109 print_pointer(arg3
, 1);
3111 print_syscall_epilogue(name
);
3115 #ifdef TARGET_NR_open
3117 print_open(void *cpu_env
, const struct syscallname
*name
,
3118 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3119 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3121 int is_creat
= (arg1
& TARGET_O_CREAT
);
3123 print_syscall_prologue(name
);
3124 print_string(arg0
, 0);
3125 print_open_flags(arg1
, (is_creat
== 0));
3127 print_file_mode(arg2
, 1);
3128 print_syscall_epilogue(name
);
3132 #ifdef TARGET_NR_openat
3134 print_openat(void *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 int is_creat
= (arg2
& TARGET_O_CREAT
);
3140 print_syscall_prologue(name
);
3141 print_at_dirfd(arg0
, 0);
3142 print_string(arg1
, 0);
3143 print_open_flags(arg2
, (is_creat
== 0));
3145 print_file_mode(arg3
, 1);
3146 print_syscall_epilogue(name
);
3150 #ifdef TARGET_NR_mq_unlink
3152 print_mq_unlink(void *cpu_env
, const struct syscallname
*name
,
3153 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3154 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3156 print_syscall_prologue(name
);
3157 print_string(arg0
, 1);
3158 print_syscall_epilogue(name
);
3162 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3164 print_fstatat64(void *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_at_dirfd(arg0
, 0);
3170 print_string(arg1
, 0);
3171 print_pointer(arg2
, 0);
3172 print_flags(at_file_flags
, arg3
, 1);
3173 print_syscall_epilogue(name
);
3175 #define print_newfstatat print_fstatat64
3178 #ifdef TARGET_NR_readlink
3180 print_readlink(void *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
, 0);
3187 print_raw_param("%u", arg2
, 1);
3188 print_syscall_epilogue(name
);
3192 #ifdef TARGET_NR_readlinkat
3194 print_readlinkat(void *cpu_env
, const struct syscallname
*name
,
3195 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3196 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3198 print_syscall_prologue(name
);
3199 print_at_dirfd(arg0
, 0);
3200 print_string(arg1
, 0);
3201 print_pointer(arg2
, 0);
3202 print_raw_param("%u", arg3
, 1);
3203 print_syscall_epilogue(name
);
3207 #ifdef TARGET_NR_rename
3209 print_rename(void *cpu_env
, const struct syscallname
*name
,
3210 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3211 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3213 print_syscall_prologue(name
);
3214 print_string(arg0
, 0);
3215 print_string(arg1
, 1);
3216 print_syscall_epilogue(name
);
3220 #ifdef TARGET_NR_renameat
3222 print_renameat(void *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_at_dirfd(arg0
, 0);
3228 print_string(arg1
, 0);
3229 print_at_dirfd(arg2
, 0);
3230 print_string(arg3
, 1);
3231 print_syscall_epilogue(name
);
3235 #ifdef TARGET_NR_statfs
3237 print_statfs(void *cpu_env
, const struct syscallname
*name
,
3238 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3239 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3241 print_syscall_prologue(name
);
3242 print_string(arg0
, 0);
3243 print_pointer(arg1
, 1);
3244 print_syscall_epilogue(name
);
3248 #ifdef TARGET_NR_statfs64
3250 print_statfs64(void *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_pointer(arg1
, 1);
3257 print_syscall_epilogue(name
);
3261 #ifdef TARGET_NR_symlink
3263 print_symlink(void *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_string(arg0
, 0);
3269 print_string(arg1
, 1);
3270 print_syscall_epilogue(name
);
3274 #ifdef TARGET_NR_symlinkat
3276 print_symlinkat(void *cpu_env
, const struct syscallname
*name
,
3277 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3278 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3280 print_syscall_prologue(name
);
3281 print_string(arg0
, 0);
3282 print_at_dirfd(arg1
, 0);
3283 print_string(arg2
, 1);
3284 print_syscall_epilogue(name
);
3288 #ifdef TARGET_NR_mount
3290 print_mount(void *cpu_env
, const struct syscallname
*name
,
3291 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3292 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3294 print_syscall_prologue(name
);
3295 print_string(arg0
, 0);
3296 print_string(arg1
, 0);
3297 print_string(arg2
, 0);
3298 print_flags(mount_flags
, arg3
, 0);
3299 print_pointer(arg4
, 1);
3300 print_syscall_epilogue(name
);
3304 #ifdef TARGET_NR_umount
3306 print_umount(void *cpu_env
, const struct syscallname
*name
,
3307 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3308 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3310 print_syscall_prologue(name
);
3311 print_string(arg0
, 1);
3312 print_syscall_epilogue(name
);
3316 #ifdef TARGET_NR_umount2
3318 print_umount2(void *cpu_env
, const struct syscallname
*name
,
3319 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3320 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3322 print_syscall_prologue(name
);
3323 print_string(arg0
, 0);
3324 print_flags(umount2_flags
, arg1
, 1);
3325 print_syscall_epilogue(name
);
3329 #ifdef TARGET_NR_unlink
3331 print_unlink(void *cpu_env
, const struct syscallname
*name
,
3332 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3333 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3335 print_syscall_prologue(name
);
3336 print_string(arg0
, 1);
3337 print_syscall_epilogue(name
);
3341 #ifdef TARGET_NR_unlinkat
3343 print_unlinkat(void *cpu_env
, const struct syscallname
*name
,
3344 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3345 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3347 print_syscall_prologue(name
);
3348 print_at_dirfd(arg0
, 0);
3349 print_string(arg1
, 0);
3350 print_flags(unlinkat_flags
, arg2
, 1);
3351 print_syscall_epilogue(name
);
3355 #ifdef TARGET_NR_utime
3357 print_utime(void *cpu_env
, const struct syscallname
*name
,
3358 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3359 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3361 print_syscall_prologue(name
);
3362 print_string(arg0
, 0);
3363 print_pointer(arg1
, 1);
3364 print_syscall_epilogue(name
);
3368 #ifdef TARGET_NR_utimes
3370 print_utimes(void *cpu_env
, const struct syscallname
*name
,
3371 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3372 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3374 print_syscall_prologue(name
);
3375 print_string(arg0
, 0);
3376 print_pointer(arg1
, 1);
3377 print_syscall_epilogue(name
);
3381 #ifdef TARGET_NR_utimensat
3383 print_utimensat(void *cpu_env
, const struct syscallname
*name
,
3384 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3385 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3387 print_syscall_prologue(name
);
3388 print_at_dirfd(arg0
, 0);
3389 print_string(arg1
, 0);
3390 print_pointer(arg2
, 0);
3391 print_flags(at_file_flags
, arg3
, 1);
3392 print_syscall_epilogue(name
);
3396 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3398 print_mmap(void *cpu_env
, const struct syscallname
*name
,
3399 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3400 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3402 print_syscall_prologue(name
);
3403 print_pointer(arg0
, 0);
3404 print_raw_param("%d", arg1
, 0);
3405 print_flags(mmap_prot_flags
, arg2
, 0);
3406 print_flags(mmap_flags
, arg3
, 0);
3407 print_raw_param("%d", arg4
, 0);
3408 print_raw_param("%#x", arg5
, 1);
3409 print_syscall_epilogue(name
);
3411 #define print_mmap2 print_mmap
3414 #ifdef TARGET_NR_mprotect
3416 print_mprotect(void *cpu_env
, const struct syscallname
*name
,
3417 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3418 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3420 print_syscall_prologue(name
);
3421 print_pointer(arg0
, 0);
3422 print_raw_param("%d", arg1
, 0);
3423 print_flags(mmap_prot_flags
, arg2
, 1);
3424 print_syscall_epilogue(name
);
3428 #ifdef TARGET_NR_munmap
3430 print_munmap(void *cpu_env
, const struct syscallname
*name
,
3431 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3432 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3434 print_syscall_prologue(name
);
3435 print_pointer(arg0
, 0);
3436 print_raw_param("%d", arg1
, 1);
3437 print_syscall_epilogue(name
);
3441 #ifdef TARGET_NR_futex
3442 static void print_futex_op(abi_long tflag
, int last
)
3444 #define print_op(val) \
3445 if( cmd == val ) { \
3450 int cmd
= (int)tflag
;
3451 #ifdef FUTEX_PRIVATE_FLAG
3452 if (cmd
& FUTEX_PRIVATE_FLAG
) {
3453 qemu_log("FUTEX_PRIVATE_FLAG|");
3454 cmd
&= ~FUTEX_PRIVATE_FLAG
;
3457 #ifdef FUTEX_CLOCK_REALTIME
3458 if (cmd
& FUTEX_CLOCK_REALTIME
) {
3459 qemu_log("FUTEX_CLOCK_REALTIME|");
3460 cmd
&= ~FUTEX_CLOCK_REALTIME
;
3463 print_op(FUTEX_WAIT
)
3464 print_op(FUTEX_WAKE
)
3466 print_op(FUTEX_REQUEUE
)
3467 print_op(FUTEX_CMP_REQUEUE
)
3468 print_op(FUTEX_WAKE_OP
)
3469 print_op(FUTEX_LOCK_PI
)
3470 print_op(FUTEX_UNLOCK_PI
)
3471 print_op(FUTEX_TRYLOCK_PI
)
3472 #ifdef FUTEX_WAIT_BITSET
3473 print_op(FUTEX_WAIT_BITSET
)
3475 #ifdef FUTEX_WAKE_BITSET
3476 print_op(FUTEX_WAKE_BITSET
)
3478 /* unknown values */
3479 qemu_log("%d", cmd
);
3483 print_futex(void *cpu_env
, const struct syscallname
*name
,
3484 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3485 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3487 print_syscall_prologue(name
);
3488 print_pointer(arg0
, 0);
3489 print_futex_op(arg1
, 0);
3490 print_raw_param(",%d", arg2
, 0);
3491 print_pointer(arg3
, 0); /* struct timespec */
3492 print_pointer(arg4
, 0);
3493 print_raw_param("%d", arg4
, 1);
3494 print_syscall_epilogue(name
);
3498 #ifdef TARGET_NR_kill
3500 print_kill(void *cpu_env
, const struct syscallname
*name
,
3501 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3502 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3504 print_syscall_prologue(name
);
3505 print_raw_param("%d", arg0
, 0);
3506 print_signal(arg1
, 1);
3507 print_syscall_epilogue(name
);
3511 #ifdef TARGET_NR_tkill
3513 print_tkill(void *cpu_env
, const struct syscallname
*name
,
3514 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3515 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3517 print_syscall_prologue(name
);
3518 print_raw_param("%d", arg0
, 0);
3519 print_signal(arg1
, 1);
3520 print_syscall_epilogue(name
);
3524 #ifdef TARGET_NR_tgkill
3526 print_tgkill(void *cpu_env
, const struct syscallname
*name
,
3527 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3528 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3530 print_syscall_prologue(name
);
3531 print_raw_param("%d", arg0
, 0);
3532 print_raw_param("%d", arg1
, 0);
3533 print_signal(arg2
, 1);
3534 print_syscall_epilogue(name
);
3538 #ifdef TARGET_NR_statx
3540 print_statx(void *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 print_syscall_prologue(name
);
3545 print_at_dirfd(arg0
, 0);
3546 print_string(arg1
, 0);
3547 print_flags(statx_flags
, arg2
, 0);
3548 print_flags(statx_mask
, arg3
, 0);
3549 print_pointer(arg4
, 1);
3550 print_syscall_epilogue(name
);
3554 #ifdef TARGET_NR_ioctl
3556 print_ioctl(void *cpu_env
, const struct syscallname
*name
,
3557 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3558 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3560 print_syscall_prologue(name
);
3561 print_raw_param("%d", arg0
, 0);
3563 const IOCTLEntry
*ie
;
3564 const argtype
*arg_type
;
3568 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
3569 if (ie
->target_cmd
== arg1
) {
3574 if (ie
->target_cmd
== 0) {
3575 print_raw_param("%#x", arg1
, 0);
3576 print_raw_param("%#x", arg2
, 1);
3578 qemu_log("%s", ie
->name
);
3579 arg_type
= ie
->arg_type
;
3581 if (arg_type
[0] != TYPE_NULL
) {
3584 switch (arg_type
[0]) {
3586 print_pointer(arg2
, 1);
3591 print_raw_param("%d", arg2
, 1);
3594 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
3597 print_raw_param(TARGET_ABI_FMT_lu
, arg2
, 1);
3600 switch (ie
->access
) {
3602 print_pointer(arg2
, 1);
3607 target_size
= thunk_type_size(arg_type
, 0);
3608 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
3610 thunk_print(argptr
, arg_type
);
3611 unlock_user(argptr
, arg2
, target_size
);
3613 print_pointer(arg2
, 1);
3619 g_assert_not_reached();
3623 print_syscall_epilogue(name
);
3628 * An array of all of the syscalls we know about
3631 static const struct syscallname scnames
[] = {
3632 #include "strace.list"
3635 static int nsyscalls
= ARRAY_SIZE(scnames
);
3638 * The public interface to this module.
3641 print_syscall(void *cpu_env
, int num
,
3642 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3643 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3646 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
")";
3648 qemu_log("%d ", getpid());
3650 for(i
=0;i
<nsyscalls
;i
++)
3651 if( scnames
[i
].nr
== num
) {
3652 if( scnames
[i
].call
!= NULL
) {
3654 cpu_env
, &scnames
[i
], arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3656 /* XXX: this format system is broken because it uses
3657 host types and host pointers for strings */
3658 if( scnames
[i
].format
!= NULL
)
3659 format
= scnames
[i
].format
;
3661 scnames
[i
].name
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3665 qemu_log("Unknown syscall %d\n", num
);
3670 print_syscall_ret(void *cpu_env
, int num
, abi_long ret
,
3671 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3672 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3676 for(i
=0;i
<nsyscalls
;i
++)
3677 if( scnames
[i
].nr
== num
) {
3678 if( scnames
[i
].result
!= NULL
) {
3679 scnames
[i
].result(cpu_env
, &scnames
[i
], ret
,
3683 if (!print_syscall_err(ret
)) {
3684 qemu_log(TARGET_ABI_FMT_ld
, ret
);
3692 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
3694 /* Print the strace output for a signal being taken:
3695 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3698 print_signal(target_signum
, 1);
3700 print_siginfo(tinfo
);