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
, 0);
2071 case TARGET_F_GETLEASE
:
2072 qemu_log("F_GETLEASE");
2074 case TARGET_F_SETPIPE_SZ
:
2075 qemu_log("F_SETPIPE_SZ,");
2076 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2078 case TARGET_F_GETPIPE_SZ
:
2079 qemu_log("F_GETPIPE_SZ");
2081 case TARGET_F_DUPFD_CLOEXEC
:
2082 qemu_log("F_DUPFD_CLOEXEC,");
2083 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
2085 case TARGET_F_NOTIFY
:
2086 qemu_log("F_NOTIFY,");
2087 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2090 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2091 print_pointer(arg2
, 1);
2094 print_syscall_epilogue(name
);
2096 #define print_fcntl64 print_fcntl
2099 #ifdef TARGET_NR_fgetxattr
2101 print_fgetxattr(void *cpu_env
, const struct syscallname
*name
,
2102 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2103 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2105 print_syscall_prologue(name
);
2106 print_raw_param("%d", arg0
, 0);
2107 print_string(arg1
, 0);
2108 print_pointer(arg2
, 0);
2109 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2110 print_syscall_epilogue(name
);
2114 #ifdef TARGET_NR_flistxattr
2116 print_flistxattr(void *cpu_env
, const struct syscallname
*name
,
2117 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2118 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2120 print_syscall_prologue(name
);
2121 print_raw_param("%d", arg0
, 0);
2122 print_pointer(arg1
, 0);
2123 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2124 print_syscall_epilogue(name
);
2128 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2130 print_getxattr(void *cpu_env
, const struct syscallname
*name
,
2131 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2132 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2134 print_syscall_prologue(name
);
2135 print_string(arg0
, 0);
2136 print_string(arg1
, 0);
2137 print_pointer(arg2
, 0);
2138 print_raw_param(TARGET_FMT_lu
, arg3
, 1);
2139 print_syscall_epilogue(name
);
2141 #define print_lgetxattr print_getxattr
2144 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2146 print_listxattr(void *cpu_env
, const struct syscallname
*name
,
2147 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2148 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2150 print_syscall_prologue(name
);
2151 print_string(arg0
, 0);
2152 print_pointer(arg1
, 0);
2153 print_raw_param(TARGET_FMT_lu
, arg2
, 1);
2154 print_syscall_epilogue(name
);
2156 #define print_llistxattr print_listxattr
2159 #if defined(TARGET_NR_fremovexattr)
2161 print_fremovexattr(void *cpu_env
, const struct syscallname
*name
,
2162 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2163 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2165 print_syscall_prologue(name
);
2166 print_raw_param("%d", arg0
, 0);
2167 print_string(arg1
, 1);
2168 print_syscall_epilogue(name
);
2172 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2174 print_removexattr(void *cpu_env
, const struct syscallname
*name
,
2175 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2176 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2178 print_syscall_prologue(name
);
2179 print_string(arg0
, 0);
2180 print_string(arg1
, 1);
2181 print_syscall_epilogue(name
);
2183 #define print_lremovexattr print_removexattr
2186 #ifdef TARGET_NR_futimesat
2188 print_futimesat(void *cpu_env
, const struct syscallname
*name
,
2189 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2190 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2192 print_syscall_prologue(name
);
2193 print_at_dirfd(arg0
, 0);
2194 print_string(arg1
, 0);
2195 print_timeval(arg2
, 0);
2196 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
2197 print_syscall_epilogue(name
);
2201 #ifdef TARGET_NR_gettimeofday
2203 print_gettimeofday(void *cpu_env
, const struct syscallname
*name
,
2204 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2205 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2207 print_syscall_prologue(name
);
2208 print_pointer(arg0
, 0);
2209 print_pointer(arg1
, 1);
2210 print_syscall_epilogue(name
);
2214 #ifdef TARGET_NR_settimeofday
2216 print_settimeofday(void *cpu_env
, const struct syscallname
*name
,
2217 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2218 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2220 print_syscall_prologue(name
);
2221 print_timeval(arg0
, 0);
2222 print_timezone(arg1
, 1);
2223 print_syscall_epilogue(name
);
2227 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2229 print_clock_gettime(void *cpu_env
, const struct syscallname
*name
,
2230 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2231 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2233 print_syscall_prologue(name
);
2234 print_enums(clockids
, arg0
, 0);
2235 print_pointer(arg1
, 1);
2236 print_syscall_epilogue(name
);
2238 #define print_clock_getres print_clock_gettime
2241 #ifdef TARGET_NR_clock_settime
2243 print_clock_settime(void *cpu_env
, const struct syscallname
*name
,
2244 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2245 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2247 print_syscall_prologue(name
);
2248 print_enums(clockids
, arg0
, 0);
2249 print_timespec(arg1
, 1);
2250 print_syscall_epilogue(name
);
2254 #ifdef TARGET_NR_getitimer
2256 print_getitimer(void *cpu_env
, const struct syscallname
*name
,
2257 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2258 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2260 print_syscall_prologue(name
);
2261 print_enums(itimer_types
, arg0
, 0);
2262 print_pointer(arg1
, 1);
2263 print_syscall_epilogue(name
);
2267 #ifdef TARGET_NR_setitimer
2269 print_setitimer(void *cpu_env
, const struct syscallname
*name
,
2270 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2271 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2273 print_syscall_prologue(name
);
2274 print_enums(itimer_types
, arg0
, 0);
2275 print_itimerval(arg1
, 0);
2276 print_pointer(arg2
, 1);
2277 print_syscall_epilogue(name
);
2281 #ifdef TARGET_NR_link
2283 print_link(void *cpu_env
, const struct syscallname
*name
,
2284 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2285 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2287 print_syscall_prologue(name
);
2288 print_string(arg0
, 0);
2289 print_string(arg1
, 1);
2290 print_syscall_epilogue(name
);
2294 #ifdef TARGET_NR_linkat
2296 print_linkat(void *cpu_env
, const struct syscallname
*name
,
2297 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2298 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2300 print_syscall_prologue(name
);
2301 print_at_dirfd(arg0
, 0);
2302 print_string(arg1
, 0);
2303 print_at_dirfd(arg2
, 0);
2304 print_string(arg3
, 0);
2305 print_flags(at_file_flags
, arg4
, 1);
2306 print_syscall_epilogue(name
);
2310 #ifdef TARGET_NR__llseek
2312 print__llseek(void *cpu_env
, const struct syscallname
*name
,
2313 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2314 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2316 const char *whence
= "UNKNOWN";
2317 print_syscall_prologue(name
);
2318 print_raw_param("%d", arg0
, 0);
2319 print_raw_param("%ld", arg1
, 0);
2320 print_raw_param("%ld", arg2
, 0);
2321 print_pointer(arg3
, 0);
2323 case SEEK_SET
: whence
= "SEEK_SET"; break;
2324 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
2325 case SEEK_END
: whence
= "SEEK_END"; break;
2327 qemu_log("%s", whence
);
2328 print_syscall_epilogue(name
);
2332 #ifdef TARGET_NR_lseek
2334 print_lseek(void *cpu_env
, const struct syscallname
*name
,
2335 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2336 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2338 print_syscall_prologue(name
);
2339 print_raw_param("%d", arg0
, 0);
2340 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2343 qemu_log("SEEK_SET"); break;
2345 qemu_log("SEEK_CUR"); break;
2347 qemu_log("SEEK_END"); break;
2350 qemu_log("SEEK_DATA"); break;
2354 qemu_log("SEEK_HOLE"); break;
2357 print_raw_param("%#x", arg2
, 1);
2359 print_syscall_epilogue(name
);
2363 #ifdef TARGET_NR_truncate
2365 print_truncate(void *cpu_env
, const struct syscallname
*name
,
2366 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2367 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2369 print_syscall_prologue(name
);
2370 print_string(arg0
, 0);
2371 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 1);
2372 print_syscall_epilogue(name
);
2376 #ifdef TARGET_NR_truncate64
2378 print_truncate64(void *cpu_env
, const struct syscallname
*name
,
2379 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2380 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2382 print_syscall_prologue(name
);
2383 print_string(arg0
, 0);
2384 if (regpairs_aligned(cpu_env
, TARGET_NR_truncate64
)) {
2388 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2389 print_syscall_epilogue(name
);
2393 #ifdef TARGET_NR_ftruncate64
2395 print_ftruncate64(void *cpu_env
, const struct syscallname
*name
,
2396 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2397 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2399 print_syscall_prologue(name
);
2400 print_raw_param("%d", arg0
, 0);
2401 if (regpairs_aligned(cpu_env
, TARGET_NR_ftruncate64
)) {
2405 print_raw_param("%" PRIu64
, target_offset64(arg1
, arg2
), 1);
2406 print_syscall_epilogue(name
);
2410 #ifdef TARGET_NR_mlockall
2412 print_mlockall(void *cpu_env
, const struct syscallname
*name
,
2413 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2414 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2416 print_syscall_prologue(name
);
2417 print_flags(mlockall_flags
, arg0
, 1);
2418 print_syscall_epilogue(name
);
2422 #if defined(TARGET_NR_socket)
2424 print_socket(void *cpu_env
, const struct syscallname
*name
,
2425 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2426 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2428 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
2430 print_syscall_prologue(name
);
2431 print_socket_domain(domain
);
2433 print_socket_type(type
);
2435 if (domain
== AF_PACKET
||
2436 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2437 protocol
= tswap16(protocol
);
2439 print_socket_protocol(domain
, type
, protocol
);
2440 print_syscall_epilogue(name
);
2445 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2447 static void print_sockfd(abi_long sockfd
, int last
)
2449 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
2454 #if defined(TARGET_NR_socketcall)
2456 #define get_user_ualx(x, gaddr, idx) \
2457 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2459 static void do_print_socket(const char *name
, abi_long arg1
)
2461 abi_ulong domain
, type
, protocol
;
2463 get_user_ualx(domain
, arg1
, 0);
2464 get_user_ualx(type
, arg1
, 1);
2465 get_user_ualx(protocol
, arg1
, 2);
2466 qemu_log("%s(", name
);
2467 print_socket_domain(domain
);
2469 print_socket_type(type
);
2471 if (domain
== AF_PACKET
||
2472 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
2473 protocol
= tswap16(protocol
);
2475 print_socket_protocol(domain
, type
, protocol
);
2479 static void do_print_sockaddr(const char *name
, abi_long arg1
)
2481 abi_ulong sockfd
, addr
, addrlen
;
2483 get_user_ualx(sockfd
, arg1
, 0);
2484 get_user_ualx(addr
, arg1
, 1);
2485 get_user_ualx(addrlen
, arg1
, 2);
2487 qemu_log("%s(", name
);
2488 print_sockfd(sockfd
, 0);
2489 print_sockaddr(addr
, addrlen
, 0);
2493 static void do_print_listen(const char *name
, abi_long arg1
)
2495 abi_ulong sockfd
, backlog
;
2497 get_user_ualx(sockfd
, arg1
, 0);
2498 get_user_ualx(backlog
, arg1
, 1);
2500 qemu_log("%s(", name
);
2501 print_sockfd(sockfd
, 0);
2502 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
2506 static void do_print_socketpair(const char *name
, abi_long arg1
)
2508 abi_ulong domain
, type
, protocol
, tab
;
2510 get_user_ualx(domain
, arg1
, 0);
2511 get_user_ualx(type
, arg1
, 1);
2512 get_user_ualx(protocol
, arg1
, 2);
2513 get_user_ualx(tab
, arg1
, 3);
2515 qemu_log("%s(", name
);
2516 print_socket_domain(domain
);
2518 print_socket_type(type
);
2520 print_socket_protocol(domain
, type
, protocol
);
2522 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
2526 static void do_print_sendrecv(const char *name
, abi_long arg1
)
2528 abi_ulong sockfd
, msg
, len
, flags
;
2530 get_user_ualx(sockfd
, arg1
, 0);
2531 get_user_ualx(msg
, arg1
, 1);
2532 get_user_ualx(len
, arg1
, 2);
2533 get_user_ualx(flags
, arg1
, 3);
2535 qemu_log("%s(", name
);
2536 print_sockfd(sockfd
, 0);
2537 print_buf(msg
, len
, 0);
2538 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2539 print_flags(msg_flags
, flags
, 1);
2543 static void do_print_msgaddr(const char *name
, abi_long arg1
)
2545 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
2547 get_user_ualx(sockfd
, arg1
, 0);
2548 get_user_ualx(msg
, arg1
, 1);
2549 get_user_ualx(len
, arg1
, 2);
2550 get_user_ualx(flags
, arg1
, 3);
2551 get_user_ualx(addr
, arg1
, 4);
2552 get_user_ualx(addrlen
, arg1
, 5);
2554 qemu_log("%s(", name
);
2555 print_sockfd(sockfd
, 0);
2556 print_buf(msg
, len
, 0);
2557 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
2558 print_flags(msg_flags
, flags
, 0);
2559 print_sockaddr(addr
, addrlen
, 0);
2563 static void do_print_shutdown(const char *name
, abi_long arg1
)
2565 abi_ulong sockfd
, how
;
2567 get_user_ualx(sockfd
, arg1
, 0);
2568 get_user_ualx(how
, arg1
, 1);
2570 qemu_log("shutdown(");
2571 print_sockfd(sockfd
, 0);
2574 qemu_log("SHUT_RD");
2577 qemu_log("SHUT_WR");
2580 qemu_log("SHUT_RDWR");
2583 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
2589 static void do_print_msg(const char *name
, abi_long arg1
)
2591 abi_ulong sockfd
, msg
, flags
;
2593 get_user_ualx(sockfd
, arg1
, 0);
2594 get_user_ualx(msg
, arg1
, 1);
2595 get_user_ualx(flags
, arg1
, 2);
2597 qemu_log("%s(", name
);
2598 print_sockfd(sockfd
, 0);
2599 print_pointer(msg
, 0);
2600 print_flags(msg_flags
, flags
, 1);
2604 static void do_print_sockopt(const char *name
, abi_long arg1
)
2606 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
2608 get_user_ualx(sockfd
, arg1
, 0);
2609 get_user_ualx(level
, arg1
, 1);
2610 get_user_ualx(optname
, arg1
, 2);
2611 get_user_ualx(optval
, arg1
, 3);
2612 get_user_ualx(optlen
, arg1
, 4);
2614 qemu_log("%s(", name
);
2615 print_sockfd(sockfd
, 0);
2618 qemu_log("SOL_TCP,");
2619 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2620 print_pointer(optval
, 0);
2623 qemu_log("SOL_IP,");
2624 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2625 print_pointer(optval
, 0);
2628 qemu_log("SOL_RAW,");
2629 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2630 print_pointer(optval
, 0);
2632 case TARGET_SOL_SOCKET
:
2633 qemu_log("SOL_SOCKET,");
2635 case TARGET_SO_DEBUG
:
2636 qemu_log("SO_DEBUG,");
2638 print_number(optval
, 0);
2640 case TARGET_SO_REUSEADDR
:
2641 qemu_log("SO_REUSEADDR,");
2643 case TARGET_SO_REUSEPORT
:
2644 qemu_log("SO_REUSEPORT,");
2646 case TARGET_SO_TYPE
:
2647 qemu_log("SO_TYPE,");
2649 case TARGET_SO_ERROR
:
2650 qemu_log("SO_ERROR,");
2652 case TARGET_SO_DONTROUTE
:
2653 qemu_log("SO_DONTROUTE,");
2655 case TARGET_SO_BROADCAST
:
2656 qemu_log("SO_BROADCAST,");
2658 case TARGET_SO_SNDBUF
:
2659 qemu_log("SO_SNDBUF,");
2661 case TARGET_SO_RCVBUF
:
2662 qemu_log("SO_RCVBUF,");
2664 case TARGET_SO_KEEPALIVE
:
2665 qemu_log("SO_KEEPALIVE,");
2667 case TARGET_SO_OOBINLINE
:
2668 qemu_log("SO_OOBINLINE,");
2670 case TARGET_SO_NO_CHECK
:
2671 qemu_log("SO_NO_CHECK,");
2673 case TARGET_SO_PRIORITY
:
2674 qemu_log("SO_PRIORITY,");
2676 case TARGET_SO_BSDCOMPAT
:
2677 qemu_log("SO_BSDCOMPAT,");
2679 case TARGET_SO_PASSCRED
:
2680 qemu_log("SO_PASSCRED,");
2682 case TARGET_SO_TIMESTAMP
:
2683 qemu_log("SO_TIMESTAMP,");
2685 case TARGET_SO_RCVLOWAT
:
2686 qemu_log("SO_RCVLOWAT,");
2688 case TARGET_SO_RCVTIMEO
:
2689 qemu_log("SO_RCVTIMEO,");
2690 print_timeval(optval
, 0);
2692 case TARGET_SO_SNDTIMEO
:
2693 qemu_log("SO_SNDTIMEO,");
2694 print_timeval(optval
, 0);
2696 case TARGET_SO_ATTACH_FILTER
: {
2697 struct target_sock_fprog
*fprog
;
2699 qemu_log("SO_ATTACH_FILTER,");
2701 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
2702 struct target_sock_filter
*filter
;
2704 if (lock_user_struct(VERIFY_READ
, filter
,
2705 tswapal(fprog
->filter
), 0)) {
2707 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
2708 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2709 i
, tswap16(filter
[i
].code
),
2710 filter
[i
].jt
, filter
[i
].jf
,
2711 tswap32(filter
[i
].k
));
2713 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2714 i
, tswap16(filter
[i
].code
),
2715 filter
[i
].jt
, filter
[i
].jf
,
2716 tswap32(filter
[i
].k
));
2718 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
2720 qemu_log(",%d},", tswap16(fprog
->len
));
2721 unlock_user(fprog
, optval
, 0);
2723 print_pointer(optval
, 0);
2728 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2729 print_pointer(optval
, 0);
2734 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
2735 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2736 print_pointer(optval
, 0);
2739 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
2743 #define PRINT_SOCKOP(name, func) \
2744 [TARGET_SYS_##name] = { #name, func }
2748 void (*print
)(const char *, abi_long
);
2750 PRINT_SOCKOP(SOCKET
, do_print_socket
),
2751 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
2752 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
2753 PRINT_SOCKOP(LISTEN
, do_print_listen
),
2754 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
2755 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
2756 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
2757 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
2758 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
2759 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
2760 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
2761 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
2762 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
2763 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
2764 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
2765 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
2766 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
2767 PRINT_SOCKOP(ACCEPT4
, NULL
),
2768 PRINT_SOCKOP(RECVMMSG
, NULL
),
2769 PRINT_SOCKOP(SENDMMSG
, NULL
),
2773 print_socketcall(void *cpu_env
, const struct syscallname
*name
,
2774 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2775 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2777 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
2778 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
2781 print_syscall_prologue(name
);
2782 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
2783 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2784 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2785 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
2786 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
2787 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
2788 print_syscall_epilogue(name
);
2792 #if defined(TARGET_NR_bind)
2794 print_bind(void *cpu_env
, const struct syscallname
*name
,
2795 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2796 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2798 print_syscall_prologue(name
);
2799 print_sockfd(arg0
, 0);
2800 print_sockaddr(arg1
, arg2
, 1);
2801 print_syscall_epilogue(name
);
2805 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2806 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2808 print_stat(void *cpu_env
, const struct syscallname
*name
,
2809 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2810 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2812 print_syscall_prologue(name
);
2813 print_string(arg0
, 0);
2814 print_pointer(arg1
, 1);
2815 print_syscall_epilogue(name
);
2817 #define print_lstat print_stat
2818 #define print_stat64 print_stat
2819 #define print_lstat64 print_stat
2822 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2824 print_fstat(void *cpu_env
, const struct syscallname
*name
,
2825 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2826 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2828 print_syscall_prologue(name
);
2829 print_raw_param("%d", arg0
, 0);
2830 print_pointer(arg1
, 1);
2831 print_syscall_epilogue(name
);
2833 #define print_fstat64 print_fstat
2836 #ifdef TARGET_NR_mkdir
2838 print_mkdir(void *cpu_env
, const struct syscallname
*name
,
2839 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2840 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2842 print_syscall_prologue(name
);
2843 print_string(arg0
, 0);
2844 print_file_mode(arg1
, 1);
2845 print_syscall_epilogue(name
);
2849 #ifdef TARGET_NR_mkdirat
2851 print_mkdirat(void *cpu_env
, const struct syscallname
*name
,
2852 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2853 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2855 print_syscall_prologue(name
);
2856 print_at_dirfd(arg0
, 0);
2857 print_string(arg1
, 0);
2858 print_file_mode(arg2
, 1);
2859 print_syscall_epilogue(name
);
2863 #ifdef TARGET_NR_rmdir
2865 print_rmdir(void *cpu_env
, const struct syscallname
*name
,
2866 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2867 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2869 print_syscall_prologue(name
);
2870 print_string(arg0
, 0);
2871 print_syscall_epilogue(name
);
2875 #ifdef TARGET_NR_rt_sigaction
2877 print_rt_sigaction(void *cpu_env
, const struct syscallname
*name
,
2878 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2879 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2881 print_syscall_prologue(name
);
2882 print_signal(arg0
, 0);
2883 print_pointer(arg1
, 0);
2884 print_pointer(arg2
, 1);
2885 print_syscall_epilogue(name
);
2889 #ifdef TARGET_NR_rt_sigprocmask
2891 print_rt_sigprocmask(void *cpu_env
, const struct syscallname
*name
,
2892 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2893 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2895 const char *how
= "UNKNOWN";
2896 print_syscall_prologue(name
);
2898 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2899 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2900 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2902 qemu_log("%s,", how
);
2903 print_pointer(arg1
, 0);
2904 print_pointer(arg2
, 1);
2905 print_syscall_epilogue(name
);
2909 #ifdef TARGET_NR_rt_sigqueueinfo
2911 print_rt_sigqueueinfo(void *cpu_env
, const struct syscallname
*name
,
2912 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2913 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2916 target_siginfo_t uinfo
;
2918 print_syscall_prologue(name
);
2919 print_raw_param("%d", arg0
, 0);
2920 print_signal(arg1
, 0);
2921 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2923 get_target_siginfo(&uinfo
, p
);
2924 print_siginfo(&uinfo
);
2926 unlock_user(p
, arg2
, 0);
2928 print_pointer(arg2
, 1);
2930 print_syscall_epilogue(name
);
2934 #ifdef TARGET_NR_rt_tgsigqueueinfo
2936 print_rt_tgsigqueueinfo(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_raw_param("%d", arg1
, 0);
2946 print_signal(arg2
, 0);
2947 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2949 get_target_siginfo(&uinfo
, p
);
2950 print_siginfo(&uinfo
);
2952 unlock_user(p
, arg3
, 0);
2954 print_pointer(arg3
, 1);
2956 print_syscall_epilogue(name
);
2960 #ifdef TARGET_NR_syslog
2962 print_syslog_action(abi_ulong arg
, int last
)
2967 case TARGET_SYSLOG_ACTION_CLOSE
: {
2968 type
= "SYSLOG_ACTION_CLOSE";
2971 case TARGET_SYSLOG_ACTION_OPEN
: {
2972 type
= "SYSLOG_ACTION_OPEN";
2975 case TARGET_SYSLOG_ACTION_READ
: {
2976 type
= "SYSLOG_ACTION_READ";
2979 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2980 type
= "SYSLOG_ACTION_READ_ALL";
2983 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2984 type
= "SYSLOG_ACTION_READ_CLEAR";
2987 case TARGET_SYSLOG_ACTION_CLEAR
: {
2988 type
= "SYSLOG_ACTION_CLEAR";
2991 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2992 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2995 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
2996 type
= "SYSLOG_ACTION_CONSOLE_ON";
2999 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
3000 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
3003 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
3004 type
= "SYSLOG_ACTION_SIZE_UNREAD";
3007 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
3008 type
= "SYSLOG_ACTION_SIZE_BUFFER";
3012 print_raw_param("%ld", arg
, last
);
3016 qemu_log("%s%s", type
, get_comma(last
));
3020 print_syslog(void *cpu_env
, const struct syscallname
*name
,
3021 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3022 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3024 print_syscall_prologue(name
);
3025 print_syslog_action(arg0
, 0);
3026 print_pointer(arg1
, 0);
3027 print_raw_param("%d", arg2
, 1);
3028 print_syscall_epilogue(name
);
3032 #ifdef TARGET_NR_mknod
3034 print_mknod(void *cpu_env
, const struct syscallname
*name
,
3035 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3036 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3038 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
3040 print_syscall_prologue(name
);
3041 print_string(arg0
, 0);
3042 print_file_mode(arg1
, (hasdev
== 0));
3044 print_raw_param("makedev(%d", major(arg2
), 0);
3045 print_raw_param("%d)", minor(arg2
), 1);
3047 print_syscall_epilogue(name
);
3051 #ifdef TARGET_NR_mknodat
3053 print_mknodat(void *cpu_env
, const struct syscallname
*name
,
3054 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3055 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3057 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
3059 print_syscall_prologue(name
);
3060 print_at_dirfd(arg0
, 0);
3061 print_string(arg1
, 0);
3062 print_file_mode(arg2
, (hasdev
== 0));
3064 print_raw_param("makedev(%d", major(arg3
), 0);
3065 print_raw_param("%d)", minor(arg3
), 1);
3067 print_syscall_epilogue(name
);
3071 #ifdef TARGET_NR_mq_open
3073 print_mq_open(void *cpu_env
, const struct syscallname
*name
,
3074 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3075 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3077 int is_creat
= (arg1
& TARGET_O_CREAT
);
3079 print_syscall_prologue(name
);
3080 print_string(arg0
, 0);
3081 print_open_flags(arg1
, (is_creat
== 0));
3083 print_file_mode(arg2
, 0);
3084 print_pointer(arg3
, 1);
3086 print_syscall_epilogue(name
);
3090 #ifdef TARGET_NR_open
3092 print_open(void *cpu_env
, const struct syscallname
*name
,
3093 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3094 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3096 int is_creat
= (arg1
& TARGET_O_CREAT
);
3098 print_syscall_prologue(name
);
3099 print_string(arg0
, 0);
3100 print_open_flags(arg1
, (is_creat
== 0));
3102 print_file_mode(arg2
, 1);
3103 print_syscall_epilogue(name
);
3107 #ifdef TARGET_NR_openat
3109 print_openat(void *cpu_env
, const struct syscallname
*name
,
3110 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3111 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3113 int is_creat
= (arg2
& TARGET_O_CREAT
);
3115 print_syscall_prologue(name
);
3116 print_at_dirfd(arg0
, 0);
3117 print_string(arg1
, 0);
3118 print_open_flags(arg2
, (is_creat
== 0));
3120 print_file_mode(arg3
, 1);
3121 print_syscall_epilogue(name
);
3125 #ifdef TARGET_NR_mq_unlink
3127 print_mq_unlink(void *cpu_env
, const struct syscallname
*name
,
3128 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3129 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3131 print_syscall_prologue(name
);
3132 print_string(arg0
, 1);
3133 print_syscall_epilogue(name
);
3137 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3139 print_fstatat64(void *cpu_env
, const struct syscallname
*name
,
3140 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3141 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3143 print_syscall_prologue(name
);
3144 print_at_dirfd(arg0
, 0);
3145 print_string(arg1
, 0);
3146 print_pointer(arg2
, 0);
3147 print_flags(at_file_flags
, arg3
, 1);
3148 print_syscall_epilogue(name
);
3150 #define print_newfstatat print_fstatat64
3153 #ifdef TARGET_NR_readlink
3155 print_readlink(void *cpu_env
, const struct syscallname
*name
,
3156 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3157 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3159 print_syscall_prologue(name
);
3160 print_string(arg0
, 0);
3161 print_pointer(arg1
, 0);
3162 print_raw_param("%u", arg2
, 1);
3163 print_syscall_epilogue(name
);
3167 #ifdef TARGET_NR_readlinkat
3169 print_readlinkat(void *cpu_env
, const struct syscallname
*name
,
3170 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3171 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3173 print_syscall_prologue(name
);
3174 print_at_dirfd(arg0
, 0);
3175 print_string(arg1
, 0);
3176 print_pointer(arg2
, 0);
3177 print_raw_param("%u", arg3
, 1);
3178 print_syscall_epilogue(name
);
3182 #ifdef TARGET_NR_rename
3184 print_rename(void *cpu_env
, const struct syscallname
*name
,
3185 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3186 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3188 print_syscall_prologue(name
);
3189 print_string(arg0
, 0);
3190 print_string(arg1
, 1);
3191 print_syscall_epilogue(name
);
3195 #ifdef TARGET_NR_renameat
3197 print_renameat(void *cpu_env
, const struct syscallname
*name
,
3198 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3199 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3201 print_syscall_prologue(name
);
3202 print_at_dirfd(arg0
, 0);
3203 print_string(arg1
, 0);
3204 print_at_dirfd(arg2
, 0);
3205 print_string(arg3
, 1);
3206 print_syscall_epilogue(name
);
3210 #ifdef TARGET_NR_statfs
3212 print_statfs(void *cpu_env
, const struct syscallname
*name
,
3213 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3214 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3216 print_syscall_prologue(name
);
3217 print_string(arg0
, 0);
3218 print_pointer(arg1
, 1);
3219 print_syscall_epilogue(name
);
3223 #ifdef TARGET_NR_statfs64
3225 print_statfs64(void *cpu_env
, const struct syscallname
*name
,
3226 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3227 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3229 print_syscall_prologue(name
);
3230 print_string(arg0
, 0);
3231 print_pointer(arg1
, 1);
3232 print_syscall_epilogue(name
);
3236 #ifdef TARGET_NR_symlink
3238 print_symlink(void *cpu_env
, const struct syscallname
*name
,
3239 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3240 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3242 print_syscall_prologue(name
);
3243 print_string(arg0
, 0);
3244 print_string(arg1
, 1);
3245 print_syscall_epilogue(name
);
3249 #ifdef TARGET_NR_symlinkat
3251 print_symlinkat(void *cpu_env
, const struct syscallname
*name
,
3252 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3253 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3255 print_syscall_prologue(name
);
3256 print_string(arg0
, 0);
3257 print_at_dirfd(arg1
, 0);
3258 print_string(arg2
, 1);
3259 print_syscall_epilogue(name
);
3263 #ifdef TARGET_NR_mount
3265 print_mount(void *cpu_env
, const struct syscallname
*name
,
3266 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3267 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3269 print_syscall_prologue(name
);
3270 print_string(arg0
, 0);
3271 print_string(arg1
, 0);
3272 print_string(arg2
, 0);
3273 print_flags(mount_flags
, arg3
, 0);
3274 print_pointer(arg4
, 1);
3275 print_syscall_epilogue(name
);
3279 #ifdef TARGET_NR_umount
3281 print_umount(void *cpu_env
, const struct syscallname
*name
,
3282 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3283 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3285 print_syscall_prologue(name
);
3286 print_string(arg0
, 1);
3287 print_syscall_epilogue(name
);
3291 #ifdef TARGET_NR_umount2
3293 print_umount2(void *cpu_env
, const struct syscallname
*name
,
3294 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3295 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3297 print_syscall_prologue(name
);
3298 print_string(arg0
, 0);
3299 print_flags(umount2_flags
, arg1
, 1);
3300 print_syscall_epilogue(name
);
3304 #ifdef TARGET_NR_unlink
3306 print_unlink(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_unlinkat
3318 print_unlinkat(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_at_dirfd(arg0
, 0);
3324 print_string(arg1
, 0);
3325 print_flags(unlinkat_flags
, arg2
, 1);
3326 print_syscall_epilogue(name
);
3330 #ifdef TARGET_NR_utime
3332 print_utime(void *cpu_env
, const struct syscallname
*name
,
3333 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3334 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3336 print_syscall_prologue(name
);
3337 print_string(arg0
, 0);
3338 print_pointer(arg1
, 1);
3339 print_syscall_epilogue(name
);
3343 #ifdef TARGET_NR_utimes
3345 print_utimes(void *cpu_env
, const struct syscallname
*name
,
3346 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3347 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3349 print_syscall_prologue(name
);
3350 print_string(arg0
, 0);
3351 print_pointer(arg1
, 1);
3352 print_syscall_epilogue(name
);
3356 #ifdef TARGET_NR_utimensat
3358 print_utimensat(void *cpu_env
, const struct syscallname
*name
,
3359 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3360 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3362 print_syscall_prologue(name
);
3363 print_at_dirfd(arg0
, 0);
3364 print_string(arg1
, 0);
3365 print_pointer(arg2
, 0);
3366 print_flags(at_file_flags
, arg3
, 1);
3367 print_syscall_epilogue(name
);
3371 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3373 print_mmap(void *cpu_env
, const struct syscallname
*name
,
3374 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3375 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3377 print_syscall_prologue(name
);
3378 print_pointer(arg0
, 0);
3379 print_raw_param("%d", arg1
, 0);
3380 print_flags(mmap_prot_flags
, arg2
, 0);
3381 print_flags(mmap_flags
, arg3
, 0);
3382 print_raw_param("%d", arg4
, 0);
3383 print_raw_param("%#x", arg5
, 1);
3384 print_syscall_epilogue(name
);
3386 #define print_mmap2 print_mmap
3389 #ifdef TARGET_NR_mprotect
3391 print_mprotect(void *cpu_env
, const struct syscallname
*name
,
3392 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3393 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3395 print_syscall_prologue(name
);
3396 print_pointer(arg0
, 0);
3397 print_raw_param("%d", arg1
, 0);
3398 print_flags(mmap_prot_flags
, arg2
, 1);
3399 print_syscall_epilogue(name
);
3403 #ifdef TARGET_NR_munmap
3405 print_munmap(void *cpu_env
, const struct syscallname
*name
,
3406 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3407 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3409 print_syscall_prologue(name
);
3410 print_pointer(arg0
, 0);
3411 print_raw_param("%d", arg1
, 1);
3412 print_syscall_epilogue(name
);
3416 #ifdef TARGET_NR_futex
3417 static void print_futex_op(abi_long tflag
, int last
)
3419 #define print_op(val) \
3420 if( cmd == val ) { \
3425 int cmd
= (int)tflag
;
3426 #ifdef FUTEX_PRIVATE_FLAG
3427 if (cmd
& FUTEX_PRIVATE_FLAG
) {
3428 qemu_log("FUTEX_PRIVATE_FLAG|");
3429 cmd
&= ~FUTEX_PRIVATE_FLAG
;
3432 #ifdef FUTEX_CLOCK_REALTIME
3433 if (cmd
& FUTEX_CLOCK_REALTIME
) {
3434 qemu_log("FUTEX_CLOCK_REALTIME|");
3435 cmd
&= ~FUTEX_CLOCK_REALTIME
;
3438 print_op(FUTEX_WAIT
)
3439 print_op(FUTEX_WAKE
)
3441 print_op(FUTEX_REQUEUE
)
3442 print_op(FUTEX_CMP_REQUEUE
)
3443 print_op(FUTEX_WAKE_OP
)
3444 print_op(FUTEX_LOCK_PI
)
3445 print_op(FUTEX_UNLOCK_PI
)
3446 print_op(FUTEX_TRYLOCK_PI
)
3447 #ifdef FUTEX_WAIT_BITSET
3448 print_op(FUTEX_WAIT_BITSET
)
3450 #ifdef FUTEX_WAKE_BITSET
3451 print_op(FUTEX_WAKE_BITSET
)
3453 /* unknown values */
3454 qemu_log("%d", cmd
);
3458 print_futex(void *cpu_env
, const struct syscallname
*name
,
3459 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3460 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3462 print_syscall_prologue(name
);
3463 print_pointer(arg0
, 0);
3464 print_futex_op(arg1
, 0);
3465 print_raw_param(",%d", arg2
, 0);
3466 print_pointer(arg3
, 0); /* struct timespec */
3467 print_pointer(arg4
, 0);
3468 print_raw_param("%d", arg4
, 1);
3469 print_syscall_epilogue(name
);
3473 #ifdef TARGET_NR_kill
3475 print_kill(void *cpu_env
, const struct syscallname
*name
,
3476 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3477 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3479 print_syscall_prologue(name
);
3480 print_raw_param("%d", arg0
, 0);
3481 print_signal(arg1
, 1);
3482 print_syscall_epilogue(name
);
3486 #ifdef TARGET_NR_tkill
3488 print_tkill(void *cpu_env
, const struct syscallname
*name
,
3489 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3490 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3492 print_syscall_prologue(name
);
3493 print_raw_param("%d", arg0
, 0);
3494 print_signal(arg1
, 1);
3495 print_syscall_epilogue(name
);
3499 #ifdef TARGET_NR_tgkill
3501 print_tgkill(void *cpu_env
, const struct syscallname
*name
,
3502 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3503 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3505 print_syscall_prologue(name
);
3506 print_raw_param("%d", arg0
, 0);
3507 print_raw_param("%d", arg1
, 0);
3508 print_signal(arg2
, 1);
3509 print_syscall_epilogue(name
);
3513 #ifdef TARGET_NR_statx
3515 print_statx(void *cpu_env
, const struct syscallname
*name
,
3516 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3517 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3519 print_syscall_prologue(name
);
3520 print_at_dirfd(arg0
, 0);
3521 print_string(arg1
, 0);
3522 print_flags(statx_flags
, arg2
, 0);
3523 print_flags(statx_mask
, arg3
, 0);
3524 print_pointer(arg4
, 1);
3525 print_syscall_epilogue(name
);
3529 #ifdef TARGET_NR_ioctl
3531 print_ioctl(void *cpu_env
, const struct syscallname
*name
,
3532 abi_long arg0
, abi_long arg1
, abi_long arg2
,
3533 abi_long arg3
, abi_long arg4
, abi_long arg5
)
3535 print_syscall_prologue(name
);
3536 print_raw_param("%d", arg0
, 0);
3538 const IOCTLEntry
*ie
;
3539 const argtype
*arg_type
;
3543 for (ie
= ioctl_entries
; ie
->target_cmd
!= 0; ie
++) {
3544 if (ie
->target_cmd
== arg1
) {
3549 if (ie
->target_cmd
== 0) {
3550 print_raw_param("%#x", arg1
, 0);
3551 print_raw_param("%#x", arg2
, 1);
3553 qemu_log("%s", ie
->name
);
3554 arg_type
= ie
->arg_type
;
3556 if (arg_type
[0] != TYPE_NULL
) {
3559 switch (arg_type
[0]) {
3561 print_pointer(arg2
, 1);
3566 print_raw_param("%d", arg2
, 1);
3569 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
3572 print_raw_param(TARGET_ABI_FMT_lu
, arg2
, 1);
3575 switch (ie
->access
) {
3577 print_pointer(arg2
, 1);
3582 target_size
= thunk_type_size(arg_type
, 0);
3583 argptr
= lock_user(VERIFY_READ
, arg2
, target_size
, 1);
3585 thunk_print(argptr
, arg_type
);
3586 unlock_user(argptr
, arg2
, target_size
);
3588 print_pointer(arg2
, 1);
3594 g_assert_not_reached();
3598 print_syscall_epilogue(name
);
3603 * An array of all of the syscalls we know about
3606 static const struct syscallname scnames
[] = {
3607 #include "strace.list"
3610 static int nsyscalls
= ARRAY_SIZE(scnames
);
3613 * The public interface to this module.
3616 print_syscall(void *cpu_env
, int num
,
3617 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3618 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3621 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
")";
3623 qemu_log("%d ", getpid());
3625 for(i
=0;i
<nsyscalls
;i
++)
3626 if( scnames
[i
].nr
== num
) {
3627 if( scnames
[i
].call
!= NULL
) {
3629 cpu_env
, &scnames
[i
], arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3631 /* XXX: this format system is broken because it uses
3632 host types and host pointers for strings */
3633 if( scnames
[i
].format
!= NULL
)
3634 format
= scnames
[i
].format
;
3636 scnames
[i
].name
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
3640 qemu_log("Unknown syscall %d\n", num
);
3645 print_syscall_ret(void *cpu_env
, int num
, abi_long ret
,
3646 abi_long arg1
, abi_long arg2
, abi_long arg3
,
3647 abi_long arg4
, abi_long arg5
, abi_long arg6
)
3651 for(i
=0;i
<nsyscalls
;i
++)
3652 if( scnames
[i
].nr
== num
) {
3653 if( scnames
[i
].result
!= NULL
) {
3654 scnames
[i
].result(cpu_env
, &scnames
[i
], ret
,
3658 if (!print_syscall_err(ret
)) {
3659 qemu_log(TARGET_ABI_FMT_ld
, ret
);
3667 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
3669 /* Print the strace output for a signal being taken:
3670 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3673 print_signal(target_signum
, 1);
3675 print_siginfo(tinfo
);