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>
21 void (*call
)(const struct syscallname
*,
22 abi_long
, abi_long
, abi_long
,
23 abi_long
, abi_long
, abi_long
);
24 void (*result
)(const struct syscallname
*, abi_long
);
29 * It is possible that target doesn't have syscall that uses
30 * following flags but we don't want the compiler to warn
31 * us about them being unused. Same applies to utility print
32 * functions. It is ok to keep them while not used.
34 #define UNUSED __attribute__ ((unused))
40 * Structure used to translate flag values into strings. This is
41 * similar that is in the actual strace tool.
44 abi_long f_value
; /* flag */
45 const char *f_string
; /* stringified flag */
48 /* common flags for all architectures */
49 #define FLAG_GENERIC(name) { name, #name }
50 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
51 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
52 /* end of flags array */
53 #define FLAG_END { 0, NULL }
55 UNUSED
static const char *get_comma(int);
56 UNUSED
static void print_pointer(abi_long
, int);
57 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
58 UNUSED
static void print_at_dirfd(abi_long
, int);
59 UNUSED
static void print_file_mode(abi_long
, int);
60 UNUSED
static void print_open_flags(abi_long
, int);
61 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
62 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
63 UNUSED
static void print_string(abi_long
, int);
64 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
65 UNUSED
static void print_raw_param(const char *, abi_long
, int);
66 UNUSED
static void print_timeval(abi_ulong
, int);
67 UNUSED
static void print_timezone(abi_ulong
, int);
68 UNUSED
static void print_number(abi_long
, int);
69 UNUSED
static void print_signal(abi_ulong
, int);
70 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
71 UNUSED
static void print_socket_domain(int domain
);
72 UNUSED
static void print_socket_type(int type
);
73 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
79 print_ipc_cmd(int cmd
)
81 #define output_cmd(val) \
89 /* General IPC commands */
90 output_cmd( IPC_RMID
);
91 output_cmd( IPC_SET
);
92 output_cmd( IPC_STAT
);
93 output_cmd( IPC_INFO
);
94 /* msgctl() commands */
95 output_cmd( MSG_STAT
);
96 output_cmd( MSG_INFO
);
97 /* shmctl() commands */
98 output_cmd( SHM_LOCK
);
99 output_cmd( SHM_UNLOCK
);
100 output_cmd( SHM_STAT
);
101 output_cmd( SHM_INFO
);
102 /* semctl() commands */
103 output_cmd( GETPID
);
104 output_cmd( GETVAL
);
105 output_cmd( GETALL
);
106 output_cmd( GETNCNT
);
107 output_cmd( GETZCNT
);
108 output_cmd( SETVAL
);
109 output_cmd( SETALL
);
110 output_cmd( SEM_STAT
);
111 output_cmd( SEM_INFO
);
112 output_cmd( IPC_RMID
);
113 output_cmd( IPC_RMID
);
114 output_cmd( IPC_RMID
);
115 output_cmd( IPC_RMID
);
116 output_cmd( IPC_RMID
);
117 output_cmd( IPC_RMID
);
118 output_cmd( IPC_RMID
);
119 output_cmd( IPC_RMID
);
120 output_cmd( IPC_RMID
);
122 /* Some value we don't recognize */
127 print_signal(abi_ulong arg
, int last
)
129 const char *signal_name
= NULL
;
131 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
132 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
133 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
134 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
135 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
136 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
137 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
138 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
139 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
140 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
141 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
142 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
143 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
144 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
145 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
146 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
147 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
148 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
150 if (signal_name
== NULL
) {
151 print_raw_param("%ld", arg
, last
);
154 gemu_log("%s%s", signal_name
, get_comma(last
));
157 static void print_si_code(int arg
)
159 const char *codename
= NULL
;
163 codename
= "SI_USER";
166 codename
= "SI_KERNEL";
169 codename
= "SI_QUEUE";
172 codename
= "SI_TIMER";
175 codename
= "SI_MESGQ";
178 codename
= "SI_ASYNCIO";
181 codename
= "SI_SIGIO";
184 codename
= "SI_TKILL";
190 gemu_log("%s", codename
);
193 static void get_target_siginfo(target_siginfo_t
*tinfo
,
194 const target_siginfo_t
*info
)
203 __get_user(sig
, &info
->si_signo
);
204 __get_user(si_errno
, &tinfo
->si_errno
);
205 __get_user(si_code
, &info
->si_code
);
207 tinfo
->si_signo
= sig
;
208 tinfo
->si_errno
= si_errno
;
209 tinfo
->si_code
= si_code
;
211 /* Ensure we don't leak random junk to the guest later */
212 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
214 /* This is awkward, because we have to use a combination of
215 * the si_code and si_signo to figure out which of the union's
216 * members are valid. (Within the host kernel it is always possible
217 * to tell, but the kernel carefully avoids giving userspace the
218 * high 16 bits of si_code, so we don't have the information to
219 * do this the easy way...) We therefore make our best guess,
220 * bearing in mind that a guest can spoof most of the si_codes
221 * via rt_sigqueueinfo() if it likes.
223 * Once we have made our guess, we record it in the top 16 bits of
224 * the si_code, so that print_siginfo() later can use it.
225 * print_siginfo() will strip these top bits out before printing
233 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
234 * These are the only unspoofable si_code values.
236 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
237 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
238 si_type
= QEMU_SI_KILL
;
241 /* Everything else is spoofable. Make best guess based on signal */
244 __get_user(tinfo
->_sifields
._sigchld
._pid
,
245 &info
->_sifields
._sigchld
._pid
);
246 __get_user(tinfo
->_sifields
._sigchld
._uid
,
247 &info
->_sifields
._sigchld
._uid
);
248 __get_user(tinfo
->_sifields
._sigchld
._status
,
249 &info
->_sifields
._sigchld
._status
);
250 __get_user(tinfo
->_sifields
._sigchld
._utime
,
251 &info
->_sifields
._sigchld
._utime
);
252 __get_user(tinfo
->_sifields
._sigchld
._stime
,
253 &info
->_sifields
._sigchld
._stime
);
254 si_type
= QEMU_SI_CHLD
;
257 __get_user(tinfo
->_sifields
._sigpoll
._band
,
258 &info
->_sifields
._sigpoll
._band
);
259 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
260 &info
->_sifields
._sigpoll
._fd
);
261 si_type
= QEMU_SI_POLL
;
264 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
265 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
266 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
267 /* XXX: potential problem if 64 bit */
268 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
269 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
271 si_type
= QEMU_SI_RT
;
277 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
280 static void print_siginfo(const target_siginfo_t
*tinfo
)
282 /* Print a target_siginfo_t in the format desired for printing
283 * signals being taken. We assume the target_siginfo_t is in the
284 * internal form where the top 16 bits of si_code indicate which
285 * part of the union is valid, rather than in the guest-visible
286 * form where the bottom 16 bits are sign-extended into the top 16.
288 int si_type
= extract32(tinfo
->si_code
, 16, 16);
289 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
291 gemu_log("{si_signo=");
292 print_signal(tinfo
->si_signo
, 1);
293 gemu_log(", si_code=");
294 print_si_code(si_code
);
298 gemu_log(", si_pid=%u, si_uid=%u",
299 (unsigned int)tinfo
->_sifields
._kill
._pid
,
300 (unsigned int)tinfo
->_sifields
._kill
._uid
);
303 gemu_log(", si_timer1=%u, si_timer2=%u",
304 tinfo
->_sifields
._timer
._timer1
,
305 tinfo
->_sifields
._timer
._timer2
);
308 gemu_log(", si_band=%d, si_fd=%d",
309 tinfo
->_sifields
._sigpoll
._band
,
310 tinfo
->_sifields
._sigpoll
._fd
);
313 gemu_log(", si_addr=");
314 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
317 gemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
318 ", si_utime=" TARGET_ABI_FMT_ld
319 ", si_stime=" TARGET_ABI_FMT_ld
,
320 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
321 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
322 tinfo
->_sifields
._sigchld
._status
,
323 tinfo
->_sifields
._sigchld
._utime
,
324 tinfo
->_sifields
._sigchld
._stime
);
327 gemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
328 (unsigned int)tinfo
->_sifields
._rt
._pid
,
329 (unsigned int)tinfo
->_sifields
._rt
._uid
,
330 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
333 g_assert_not_reached();
339 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
341 struct target_sockaddr
*sa
;
345 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
347 sa_family
= tswap16(sa
->sa_family
);
350 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
352 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
353 for (i
= 0; i
< addrlen
-
354 offsetof(struct target_sockaddr_un
, sun_path
) &&
355 un
->sun_path
[i
]; i
++) {
356 gemu_log("%c", un
->sun_path
[i
]);
362 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
363 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
364 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
365 ntohs(in
->sin_port
));
366 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
367 c
[0], c
[1], c
[2], c
[3]);
372 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
373 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
374 gemu_log("{sll_family=AF_PACKET,"
375 "sll_protocol=htons(0x%04x),if%d,pkttype=",
376 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
377 switch (ll
->sll_pkttype
) {
379 gemu_log("PACKET_HOST");
381 case PACKET_BROADCAST
:
382 gemu_log("PACKET_BROADCAST");
384 case PACKET_MULTICAST
:
385 gemu_log("PACKET_MULTICAST");
387 case PACKET_OTHERHOST
:
388 gemu_log("PACKET_OTHERHOST");
390 case PACKET_OUTGOING
:
391 gemu_log("PACKET_OUTGOING");
394 gemu_log("%d", ll
->sll_pkttype
);
397 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
398 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
403 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
404 gemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
405 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
409 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
410 for (i
= 0; i
< 13; i
++) {
411 gemu_log("%02x, ", sa
->sa_data
[i
]);
413 gemu_log("%02x}", sa
->sa_data
[i
]);
417 unlock_user(sa
, addr
, 0);
419 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
421 gemu_log(", "TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
425 print_socket_domain(int domain
)
435 gemu_log("PF_NETLINK");
438 gemu_log("PF_PACKET");
441 gemu_log("%d", domain
);
447 print_socket_type(int type
)
450 case TARGET_SOCK_DGRAM
:
451 gemu_log("SOCK_DGRAM");
453 case TARGET_SOCK_STREAM
:
454 gemu_log("SOCK_STREAM");
456 case TARGET_SOCK_RAW
:
457 gemu_log("SOCK_RAW");
459 case TARGET_SOCK_RDM
:
460 gemu_log("SOCK_RDM");
462 case TARGET_SOCK_SEQPACKET
:
463 gemu_log("SOCK_SEQPACKET");
465 case TARGET_SOCK_PACKET
:
466 gemu_log("SOCK_PACKET");
472 print_socket_protocol(int domain
, int type
, int protocol
)
474 if (domain
== AF_PACKET
||
475 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
478 gemu_log("ETH_P_ALL");
481 gemu_log("%d", protocol
);
486 if (domain
== PF_NETLINK
) {
489 gemu_log("NETLINK_ROUTE");
492 gemu_log("NETLINK_AUDIT");
494 case NETLINK_NETFILTER
:
495 gemu_log("NETLINK_NETFILTER");
497 case NETLINK_KOBJECT_UEVENT
:
498 gemu_log("NETLINK_KOBJECT_UEVENT");
501 gemu_log("NETLINK_RDMA");
504 gemu_log("NETLINK_CRYPTO");
507 gemu_log("%d", protocol
);
515 gemu_log("IPPROTO_IP");
518 gemu_log("IPPROTO_TCP");
521 gemu_log("IPPROTO_UDP");
524 gemu_log("IPPROTO_RAW");
527 gemu_log("%d", protocol
);
533 #ifdef TARGET_NR__newselect
535 print_fdset(int n
, abi_ulong target_fds_addr
)
540 if( target_fds_addr
) {
541 abi_long
*target_fds
;
543 target_fds
= lock_user(VERIFY_READ
,
545 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
551 for (i
=n
; i
>=0; i
--) {
552 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
555 unlock_user(target_fds
, target_fds_addr
, 0);
561 #ifdef TARGET_NR_clock_adjtime
562 /* IDs of the various system clocks */
563 #define TARGET_CLOCK_REALTIME 0
564 #define TARGET_CLOCK_MONOTONIC 1
565 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
566 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
567 #define TARGET_CLOCK_MONOTONIC_RAW 4
568 #define TARGET_CLOCK_REALTIME_COARSE 5
569 #define TARGET_CLOCK_MONOTONIC_COARSE 6
570 #define TARGET_CLOCK_BOOTTIME 7
571 #define TARGET_CLOCK_REALTIME_ALARM 8
572 #define TARGET_CLOCK_BOOTTIME_ALARM 9
573 #define TARGET_CLOCK_SGI_CYCLE 10
574 #define TARGET_CLOCK_TAI 11
577 print_clockid(int clockid
, int last
)
580 case TARGET_CLOCK_REALTIME
:
581 gemu_log("CLOCK_REALTIME");
583 case TARGET_CLOCK_MONOTONIC
:
584 gemu_log("CLOCK_MONOTONIC");
586 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
587 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
589 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
590 gemu_log("CLOCK_THREAD_CPUTIME_ID");
592 case TARGET_CLOCK_MONOTONIC_RAW
:
593 gemu_log("CLOCK_MONOTONIC_RAW");
595 case TARGET_CLOCK_REALTIME_COARSE
:
596 gemu_log("CLOCK_REALTIME_COARSE");
598 case TARGET_CLOCK_MONOTONIC_COARSE
:
599 gemu_log("CLOCK_MONOTONIC_COARSE");
601 case TARGET_CLOCK_BOOTTIME
:
602 gemu_log("CLOCK_BOOTTIME");
604 case TARGET_CLOCK_REALTIME_ALARM
:
605 gemu_log("CLOCK_REALTIME_ALARM");
607 case TARGET_CLOCK_BOOTTIME_ALARM
:
608 gemu_log("CLOCK_BOOTTIME_ALARM");
610 case TARGET_CLOCK_SGI_CYCLE
:
611 gemu_log("CLOCK_SGI_CYCLE");
613 case TARGET_CLOCK_TAI
:
614 gemu_log("CLOCK_TAI");
617 gemu_log("%d", clockid
);
620 gemu_log("%s", get_comma(last
));
625 * Sysycall specific output functions
629 #ifdef TARGET_NR__newselect
630 static long newselect_arg1
= 0;
631 static long newselect_arg2
= 0;
632 static long newselect_arg3
= 0;
633 static long newselect_arg4
= 0;
634 static long newselect_arg5
= 0;
637 print_newselect(const struct syscallname
*name
,
638 abi_long arg1
, abi_long arg2
, abi_long arg3
,
639 abi_long arg4
, abi_long arg5
, abi_long arg6
)
641 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
642 print_fdset(arg1
, arg2
);
644 print_fdset(arg1
, arg3
);
646 print_fdset(arg1
, arg4
);
648 print_timeval(arg5
, 1);
651 /* save for use in the return output function below */
660 #ifdef TARGET_NR_semctl
662 print_semctl(const struct syscallname
*name
,
663 abi_long arg1
, abi_long arg2
, abi_long arg3
,
664 abi_long arg4
, abi_long arg5
, abi_long arg6
)
666 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
668 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
673 print_execve(const struct syscallname
*name
,
674 abi_long arg1
, abi_long arg2
, abi_long arg3
,
675 abi_long arg4
, abi_long arg5
, abi_long arg6
)
677 abi_ulong arg_ptr_addr
;
680 if (!(s
= lock_user_string(arg1
)))
682 gemu_log("%s(\"%s\",{", name
->name
, s
);
683 unlock_user(s
, arg1
, 0);
685 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
686 abi_ulong
*arg_ptr
, arg_addr
;
688 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
691 arg_addr
= tswapal(*arg_ptr
);
692 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
695 if ((s
= lock_user_string(arg_addr
))) {
696 gemu_log("\"%s\",", s
);
697 unlock_user(s
, arg_addr
, 0);
706 print_ipc(const struct syscallname
*name
,
707 abi_long arg1
, abi_long arg2
, abi_long arg3
,
708 abi_long arg4
, abi_long arg5
, abi_long arg6
)
712 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
714 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
717 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
718 name
->name
, arg1
, arg2
, arg3
, arg4
);
724 * Variants for the return value output function
728 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
730 const char *errstr
= NULL
;
733 errstr
= target_strerror(-ret
);
736 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
738 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
742 #if 0 /* currently unused */
744 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
746 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
750 #ifdef TARGET_NR__newselect
752 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
754 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
755 print_fdset(newselect_arg1
,newselect_arg2
);
757 print_fdset(newselect_arg1
,newselect_arg3
);
759 print_fdset(newselect_arg1
,newselect_arg4
);
761 print_timeval(newselect_arg5
, 1);
766 /* special meanings of adjtimex()' non-negative return values */
767 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
768 #define TARGET_TIME_INS 1 /* insert leap second */
769 #define TARGET_TIME_DEL 2 /* delete leap second */
770 #define TARGET_TIME_OOP 3 /* leap second in progress */
771 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
772 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
774 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
776 const char *errstr
= NULL
;
780 gemu_log("-1 errno=%d", errno
);
781 errstr
= target_strerror(-ret
);
783 gemu_log(" (%s)", errstr
);
786 gemu_log(TARGET_ABI_FMT_ld
, ret
);
789 gemu_log(" TIME_OK (clock synchronized, no leap second)");
791 case TARGET_TIME_INS
:
792 gemu_log(" TIME_INS (insert leap second)");
794 case TARGET_TIME_DEL
:
795 gemu_log(" TIME_DEL (delete leap second)");
797 case TARGET_TIME_OOP
:
798 gemu_log(" TIME_OOP (leap second in progress)");
800 case TARGET_TIME_WAIT
:
801 gemu_log(" TIME_WAIT (leap second has occurred)");
803 case TARGET_TIME_ERROR
:
804 gemu_log(" TIME_ERROR (clock not synchronized)");
812 UNUSED
static struct flags access_flags
[] = {
820 UNUSED
static struct flags at_file_flags
[] = {
822 FLAG_GENERIC(AT_EACCESS
),
824 #ifdef AT_SYMLINK_NOFOLLOW
825 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
830 UNUSED
static struct flags unlinkat_flags
[] = {
832 FLAG_GENERIC(AT_REMOVEDIR
),
837 UNUSED
static struct flags mode_flags
[] = {
838 FLAG_GENERIC(S_IFSOCK
),
839 FLAG_GENERIC(S_IFLNK
),
840 FLAG_GENERIC(S_IFREG
),
841 FLAG_GENERIC(S_IFBLK
),
842 FLAG_GENERIC(S_IFDIR
),
843 FLAG_GENERIC(S_IFCHR
),
844 FLAG_GENERIC(S_IFIFO
),
848 UNUSED
static struct flags open_access_flags
[] = {
849 FLAG_TARGET(O_RDONLY
),
850 FLAG_TARGET(O_WRONLY
),
855 UNUSED
static struct flags open_flags
[] = {
856 FLAG_TARGET(O_APPEND
),
857 FLAG_TARGET(O_CREAT
),
858 FLAG_TARGET(O_DIRECTORY
),
860 FLAG_TARGET(O_LARGEFILE
),
861 FLAG_TARGET(O_NOCTTY
),
862 FLAG_TARGET(O_NOFOLLOW
),
863 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
864 FLAG_TARGET(O_DSYNC
),
865 FLAG_TARGET(__O_SYNC
),
866 FLAG_TARGET(O_TRUNC
),
868 FLAG_TARGET(O_DIRECT
),
871 FLAG_TARGET(O_NOATIME
),
874 FLAG_TARGET(O_CLOEXEC
),
880 FLAG_TARGET(O_TMPFILE
),
881 FLAG_TARGET(__O_TMPFILE
),
886 UNUSED
static struct flags mount_flags
[] = {
888 FLAG_GENERIC(MS_BIND
),
891 FLAG_GENERIC(MS_DIRSYNC
),
893 FLAG_GENERIC(MS_MANDLOCK
),
895 FLAG_GENERIC(MS_MOVE
),
897 FLAG_GENERIC(MS_NOATIME
),
898 FLAG_GENERIC(MS_NODEV
),
899 FLAG_GENERIC(MS_NODIRATIME
),
900 FLAG_GENERIC(MS_NOEXEC
),
901 FLAG_GENERIC(MS_NOSUID
),
902 FLAG_GENERIC(MS_RDONLY
),
904 FLAG_GENERIC(MS_RELATIME
),
906 FLAG_GENERIC(MS_REMOUNT
),
907 FLAG_GENERIC(MS_SYNCHRONOUS
),
911 UNUSED
static struct flags umount2_flags
[] = {
913 FLAG_GENERIC(MNT_FORCE
),
916 FLAG_GENERIC(MNT_DETACH
),
919 FLAG_GENERIC(MNT_EXPIRE
),
924 UNUSED
static struct flags mmap_prot_flags
[] = {
925 FLAG_GENERIC(PROT_NONE
),
926 FLAG_GENERIC(PROT_EXEC
),
927 FLAG_GENERIC(PROT_READ
),
928 FLAG_GENERIC(PROT_WRITE
),
929 FLAG_TARGET(PROT_SEM
),
930 FLAG_GENERIC(PROT_GROWSDOWN
),
931 FLAG_GENERIC(PROT_GROWSUP
),
935 UNUSED
static struct flags mmap_flags
[] = {
936 FLAG_TARGET(MAP_SHARED
),
937 FLAG_TARGET(MAP_PRIVATE
),
938 FLAG_TARGET(MAP_ANONYMOUS
),
939 FLAG_TARGET(MAP_DENYWRITE
),
940 FLAG_TARGET(MAP_FIXED
),
941 FLAG_TARGET(MAP_GROWSDOWN
),
942 FLAG_TARGET(MAP_EXECUTABLE
),
944 FLAG_TARGET(MAP_LOCKED
),
947 FLAG_TARGET(MAP_NONBLOCK
),
949 FLAG_TARGET(MAP_NORESERVE
),
951 FLAG_TARGET(MAP_POPULATE
),
953 #ifdef TARGET_MAP_UNINITIALIZED
954 FLAG_TARGET(MAP_UNINITIALIZED
),
959 UNUSED
static struct flags clone_flags
[] = {
960 FLAG_GENERIC(CLONE_VM
),
961 FLAG_GENERIC(CLONE_FS
),
962 FLAG_GENERIC(CLONE_FILES
),
963 FLAG_GENERIC(CLONE_SIGHAND
),
964 FLAG_GENERIC(CLONE_PTRACE
),
965 FLAG_GENERIC(CLONE_VFORK
),
966 FLAG_GENERIC(CLONE_PARENT
),
967 FLAG_GENERIC(CLONE_THREAD
),
968 FLAG_GENERIC(CLONE_NEWNS
),
969 FLAG_GENERIC(CLONE_SYSVSEM
),
970 FLAG_GENERIC(CLONE_SETTLS
),
971 FLAG_GENERIC(CLONE_PARENT_SETTID
),
972 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
973 FLAG_GENERIC(CLONE_DETACHED
),
974 FLAG_GENERIC(CLONE_UNTRACED
),
975 FLAG_GENERIC(CLONE_CHILD_SETTID
),
976 #if defined(CLONE_NEWUTS)
977 FLAG_GENERIC(CLONE_NEWUTS
),
979 #if defined(CLONE_NEWIPC)
980 FLAG_GENERIC(CLONE_NEWIPC
),
982 #if defined(CLONE_NEWUSER)
983 FLAG_GENERIC(CLONE_NEWUSER
),
985 #if defined(CLONE_NEWPID)
986 FLAG_GENERIC(CLONE_NEWPID
),
988 #if defined(CLONE_NEWNET)
989 FLAG_GENERIC(CLONE_NEWNET
),
991 #if defined(CLONE_IO)
992 FLAG_GENERIC(CLONE_IO
),
997 UNUSED
static struct flags msg_flags
[] = {
999 FLAG_GENERIC(MSG_CONFIRM
),
1000 FLAG_GENERIC(MSG_DONTROUTE
),
1001 FLAG_GENERIC(MSG_DONTWAIT
),
1002 FLAG_GENERIC(MSG_EOR
),
1003 FLAG_GENERIC(MSG_MORE
),
1004 FLAG_GENERIC(MSG_NOSIGNAL
),
1005 FLAG_GENERIC(MSG_OOB
),
1007 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1008 FLAG_GENERIC(MSG_ERRQUEUE
),
1009 FLAG_GENERIC(MSG_PEEK
),
1010 FLAG_GENERIC(MSG_TRUNC
),
1011 FLAG_GENERIC(MSG_WAITALL
),
1013 FLAG_GENERIC(MSG_CTRUNC
),
1017 UNUSED
static struct flags statx_flags
[] = {
1018 #ifdef AT_EMPTY_PATH
1019 FLAG_GENERIC(AT_EMPTY_PATH
),
1021 #ifdef AT_NO_AUTOMOUNT
1022 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1024 #ifdef AT_SYMLINK_NOFOLLOW
1025 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1027 #ifdef AT_STATX_SYNC_AS_STAT
1028 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT
),
1030 #ifdef AT_STATX_FORCE_SYNC
1031 FLAG_GENERIC(AT_STATX_FORCE_SYNC
),
1033 #ifdef AT_STATX_DONT_SYNC
1034 FLAG_GENERIC(AT_STATX_DONT_SYNC
),
1039 UNUSED
static struct flags statx_mask
[] = {
1040 /* This must come first, because it includes everything. */
1042 FLAG_GENERIC(STATX_ALL
),
1044 /* This must come second; it includes everything except STATX_BTIME. */
1045 #ifdef STATX_BASIC_STATS
1046 FLAG_GENERIC(STATX_BASIC_STATS
),
1049 FLAG_GENERIC(STATX_TYPE
),
1052 FLAG_GENERIC(STATX_MODE
),
1055 FLAG_GENERIC(STATX_NLINK
),
1058 FLAG_GENERIC(STATX_UID
),
1061 FLAG_GENERIC(STATX_GID
),
1064 FLAG_GENERIC(STATX_ATIME
),
1067 FLAG_GENERIC(STATX_MTIME
),
1070 FLAG_GENERIC(STATX_CTIME
),
1073 FLAG_GENERIC(STATX_INO
),
1076 FLAG_GENERIC(STATX_SIZE
),
1079 FLAG_GENERIC(STATX_BLOCKS
),
1082 FLAG_GENERIC(STATX_BTIME
),
1088 * print_xxx utility functions. These are used to print syscall
1089 * parameters in certain format. All of these have parameter
1090 * named 'last'. This parameter is used to add comma to output
1097 return ((last
) ? "" : ",");
1101 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1103 const char *sep
= "";
1106 if ((flags
== 0) && (f
->f_value
== 0)) {
1107 gemu_log("%s%s", f
->f_string
, get_comma(last
));
1110 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1111 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1112 gemu_log("%s%s", sep
, f
->f_string
);
1113 flags
&= ~f
->f_value
;
1120 /* print rest of the flags as numeric */
1122 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1124 gemu_log("%s", get_comma(last
));
1127 /* no string version of flags found, print them in hex then */
1128 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1133 print_at_dirfd(abi_long dirfd
, int last
)
1136 if (dirfd
== AT_FDCWD
) {
1137 gemu_log("AT_FDCWD%s", get_comma(last
));
1141 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
1145 print_file_mode(abi_long mode
, int last
)
1147 const char *sep
= "";
1148 const struct flags
*m
;
1150 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1151 if ((m
->f_value
& mode
) == m
->f_value
) {
1152 gemu_log("%s%s", m
->f_string
, sep
);
1154 mode
&= ~m
->f_value
;
1160 /* print rest of the mode as octal */
1162 gemu_log("%s%#o", sep
, (unsigned int)mode
);
1164 gemu_log("%s", get_comma(last
));
1168 print_open_flags(abi_long flags
, int last
)
1170 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1171 flags
&= ~TARGET_O_ACCMODE
;
1173 gemu_log("%s", get_comma(last
));
1177 print_flags(open_flags
, flags
, last
);
1181 print_syscall_prologue(const struct syscallname
*sc
)
1183 gemu_log("%s(", sc
->name
);
1188 print_syscall_epilogue(const struct syscallname
*sc
)
1195 print_string(abi_long addr
, int last
)
1199 if ((s
= lock_user_string(addr
)) != NULL
) {
1200 gemu_log("\"%s\"%s", s
, get_comma(last
));
1201 unlock_user(s
, addr
, 0);
1203 /* can't get string out of it, so print it as pointer */
1204 print_pointer(addr
, last
);
1208 #define MAX_PRINT_BUF 40
1210 print_buf(abi_long addr
, abi_long len
, int last
)
1215 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1218 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1219 if (isprint(s
[i
])) {
1220 gemu_log("%c", s
[i
]);
1222 gemu_log("\\%o", s
[i
]);
1232 unlock_user(s
, addr
, 0);
1234 print_pointer(addr
, last
);
1239 * Prints out raw parameter using given format. Caller needs
1240 * to do byte swapping if needed.
1243 print_raw_param(const char *fmt
, abi_long param
, int last
)
1247 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1248 gemu_log(format
, param
);
1252 print_pointer(abi_long p
, int last
)
1255 gemu_log("NULL%s", get_comma(last
));
1257 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1261 * Reads 32-bit (int) number from guest address space from
1262 * address 'addr' and prints it.
1265 print_number(abi_long addr
, int last
)
1268 gemu_log("NULL%s", get_comma(last
));
1272 get_user_s32(num
, addr
);
1273 gemu_log("[%d]%s", num
, get_comma(last
));
1278 print_timeval(abi_ulong tv_addr
, int last
)
1281 struct target_timeval
*tv
;
1283 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1285 print_pointer(tv_addr
, last
);
1288 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1289 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1290 unlock_user(tv
, tv_addr
, 0);
1292 gemu_log("NULL%s", get_comma(last
));
1296 print_timezone(abi_ulong tz_addr
, int last
)
1299 struct target_timezone
*tz
;
1301 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1303 print_pointer(tz_addr
, last
);
1306 gemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1307 tswap32(tz
->tz_dsttime
), get_comma(last
));
1308 unlock_user(tz
, tz_addr
, 0);
1310 gemu_log("NULL%s", get_comma(last
));
1316 #ifdef TARGET_NR_accept
1318 print_accept(const struct syscallname
*name
,
1319 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1320 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1322 print_syscall_prologue(name
);
1323 print_raw_param("%d", arg0
, 0);
1324 print_pointer(arg1
, 0);
1325 print_number(arg2
, 1);
1326 print_syscall_epilogue(name
);
1330 #ifdef TARGET_NR_access
1332 print_access(const struct syscallname
*name
,
1333 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1334 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1336 print_syscall_prologue(name
);
1337 print_string(arg0
, 0);
1338 print_flags(access_flags
, arg1
, 1);
1339 print_syscall_epilogue(name
);
1343 #ifdef TARGET_NR_brk
1345 print_brk(const struct syscallname
*name
,
1346 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1347 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1349 print_syscall_prologue(name
);
1350 print_pointer(arg0
, 1);
1351 print_syscall_epilogue(name
);
1355 #ifdef TARGET_NR_chdir
1357 print_chdir(const struct syscallname
*name
,
1358 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1359 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1361 print_syscall_prologue(name
);
1362 print_string(arg0
, 1);
1363 print_syscall_epilogue(name
);
1367 #ifdef TARGET_NR_chroot
1369 print_chroot(const struct syscallname
*name
,
1370 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1371 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1373 print_syscall_prologue(name
);
1374 print_string(arg0
, 1);
1375 print_syscall_epilogue(name
);
1379 #ifdef TARGET_NR_chmod
1381 print_chmod(const struct syscallname
*name
,
1382 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1383 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1385 print_syscall_prologue(name
);
1386 print_string(arg0
, 0);
1387 print_file_mode(arg1
, 1);
1388 print_syscall_epilogue(name
);
1392 #ifdef TARGET_NR_clock_adjtime
1394 print_clock_adjtime(const struct syscallname
*name
,
1395 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1396 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1398 print_syscall_prologue(name
);
1399 print_clockid(arg0
, 0);
1400 print_pointer(arg1
, 1);
1401 print_syscall_epilogue(name
);
1405 #ifdef TARGET_NR_clone
1406 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1407 abi_ulong parent_tidptr
, target_ulong newtls
,
1408 abi_ulong child_tidptr
)
1410 print_flags(clone_flags
, flags
, 0);
1411 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1412 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1413 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1414 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1418 print_clone(const struct syscallname
*name
,
1419 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1420 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1422 print_syscall_prologue(name
);
1423 #if defined(TARGET_MICROBLAZE)
1424 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1425 #elif defined(TARGET_CLONE_BACKWARDS)
1426 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1427 #elif defined(TARGET_CLONE_BACKWARDS2)
1428 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1430 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1432 print_syscall_epilogue(name
);
1436 #ifdef TARGET_NR_creat
1438 print_creat(const struct syscallname
*name
,
1439 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1440 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1442 print_syscall_prologue(name
);
1443 print_string(arg0
, 0);
1444 print_file_mode(arg1
, 1);
1445 print_syscall_epilogue(name
);
1449 #ifdef TARGET_NR_execv
1451 print_execv(const struct syscallname
*name
,
1452 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1453 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1455 print_syscall_prologue(name
);
1456 print_string(arg0
, 0);
1457 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1458 print_syscall_epilogue(name
);
1462 #ifdef TARGET_NR_faccessat
1464 print_faccessat(const struct syscallname
*name
,
1465 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1466 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1468 print_syscall_prologue(name
);
1469 print_at_dirfd(arg0
, 0);
1470 print_string(arg1
, 0);
1471 print_flags(access_flags
, arg2
, 0);
1472 print_flags(at_file_flags
, arg3
, 1);
1473 print_syscall_epilogue(name
);
1477 #ifdef TARGET_NR_fchmodat
1479 print_fchmodat(const struct syscallname
*name
,
1480 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1481 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1483 print_syscall_prologue(name
);
1484 print_at_dirfd(arg0
, 0);
1485 print_string(arg1
, 0);
1486 print_file_mode(arg2
, 0);
1487 print_flags(at_file_flags
, arg3
, 1);
1488 print_syscall_epilogue(name
);
1492 #ifdef TARGET_NR_fchownat
1494 print_fchownat(const struct syscallname
*name
,
1495 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1496 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1498 print_syscall_prologue(name
);
1499 print_at_dirfd(arg0
, 0);
1500 print_string(arg1
, 0);
1501 print_raw_param("%d", arg2
, 0);
1502 print_raw_param("%d", arg3
, 0);
1503 print_flags(at_file_flags
, arg4
, 1);
1504 print_syscall_epilogue(name
);
1508 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1510 print_fcntl(const struct syscallname
*name
,
1511 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1512 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1514 print_syscall_prologue(name
);
1515 print_raw_param("%d", arg0
, 0);
1517 case TARGET_F_DUPFD
:
1518 gemu_log("F_DUPFD,");
1519 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1521 case TARGET_F_GETFD
:
1522 gemu_log("F_GETFD");
1524 case TARGET_F_SETFD
:
1525 gemu_log("F_SETFD,");
1526 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1528 case TARGET_F_GETFL
:
1529 gemu_log("F_GETFL");
1531 case TARGET_F_SETFL
:
1532 gemu_log("F_SETFL,");
1533 print_open_flags(arg2
, 1);
1535 case TARGET_F_GETLK
:
1536 gemu_log("F_GETLK,");
1537 print_pointer(arg2
, 1);
1539 case TARGET_F_SETLK
:
1540 gemu_log("F_SETLK,");
1541 print_pointer(arg2
, 1);
1543 case TARGET_F_SETLKW
:
1544 gemu_log("F_SETLKW,");
1545 print_pointer(arg2
, 1);
1547 case TARGET_F_GETOWN
:
1548 gemu_log("F_GETOWN");
1550 case TARGET_F_SETOWN
:
1551 gemu_log("F_SETOWN,");
1552 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1554 case TARGET_F_GETSIG
:
1555 gemu_log("F_GETSIG");
1557 case TARGET_F_SETSIG
:
1558 gemu_log("F_SETSIG,");
1559 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1561 #if TARGET_ABI_BITS == 32
1562 case TARGET_F_GETLK64
:
1563 gemu_log("F_GETLK64,");
1564 print_pointer(arg2
, 1);
1566 case TARGET_F_SETLK64
:
1567 gemu_log("F_SETLK64,");
1568 print_pointer(arg2
, 1);
1570 case TARGET_F_SETLKW64
:
1571 gemu_log("F_SETLKW64,");
1572 print_pointer(arg2
, 1);
1575 case TARGET_F_SETLEASE
:
1576 gemu_log("F_SETLEASE,");
1577 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1579 case TARGET_F_GETLEASE
:
1580 gemu_log("F_GETLEASE");
1582 case TARGET_F_SETPIPE_SZ
:
1583 gemu_log("F_SETPIPE_SZ,");
1584 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1586 case TARGET_F_GETPIPE_SZ
:
1587 gemu_log("F_GETPIPE_SZ");
1589 case TARGET_F_DUPFD_CLOEXEC
:
1590 gemu_log("F_DUPFD_CLOEXEC,");
1591 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1593 case TARGET_F_NOTIFY
:
1594 gemu_log("F_NOTIFY,");
1595 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1598 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1599 print_pointer(arg2
, 1);
1602 print_syscall_epilogue(name
);
1604 #define print_fcntl64 print_fcntl
1608 #ifdef TARGET_NR_futimesat
1610 print_futimesat(const struct syscallname
*name
,
1611 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1612 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1614 print_syscall_prologue(name
);
1615 print_at_dirfd(arg0
, 0);
1616 print_string(arg1
, 0);
1617 print_timeval(arg2
, 0);
1618 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1619 print_syscall_epilogue(name
);
1623 #ifdef TARGET_NR_settimeofday
1625 print_settimeofday(const struct syscallname
*name
,
1626 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1627 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1629 print_syscall_prologue(name
);
1630 print_timeval(arg0
, 0);
1631 print_timezone(arg1
, 1);
1632 print_syscall_epilogue(name
);
1636 #ifdef TARGET_NR_link
1638 print_link(const struct syscallname
*name
,
1639 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1640 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1642 print_syscall_prologue(name
);
1643 print_string(arg0
, 0);
1644 print_string(arg1
, 1);
1645 print_syscall_epilogue(name
);
1649 #ifdef TARGET_NR_linkat
1651 print_linkat(const struct syscallname
*name
,
1652 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1653 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1655 print_syscall_prologue(name
);
1656 print_at_dirfd(arg0
, 0);
1657 print_string(arg1
, 0);
1658 print_at_dirfd(arg2
, 0);
1659 print_string(arg3
, 0);
1660 print_flags(at_file_flags
, arg4
, 1);
1661 print_syscall_epilogue(name
);
1665 #ifdef TARGET_NR__llseek
1667 print__llseek(const struct syscallname
*name
,
1668 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1669 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1671 const char *whence
= "UNKNOWN";
1672 print_syscall_prologue(name
);
1673 print_raw_param("%d", arg0
, 0);
1674 print_raw_param("%ld", arg1
, 0);
1675 print_raw_param("%ld", arg2
, 0);
1676 print_pointer(arg3
, 0);
1678 case SEEK_SET
: whence
= "SEEK_SET"; break;
1679 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1680 case SEEK_END
: whence
= "SEEK_END"; break;
1682 gemu_log("%s",whence
);
1683 print_syscall_epilogue(name
);
1687 #if defined(TARGET_NR_socket)
1689 print_socket(const struct syscallname
*name
,
1690 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1691 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1693 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1695 print_syscall_prologue(name
);
1696 print_socket_domain(domain
);
1698 print_socket_type(type
);
1700 if (domain
== AF_PACKET
||
1701 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1702 protocol
= tswap16(protocol
);
1704 print_socket_protocol(domain
, type
, protocol
);
1705 print_syscall_epilogue(name
);
1710 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
1712 static void print_sockfd(abi_long sockfd
, int last
)
1714 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
1719 #if defined(TARGET_NR_socketcall)
1721 #define get_user_ualx(x, gaddr, idx) \
1722 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1724 static void do_print_socket(const char *name
, abi_long arg1
)
1726 abi_ulong domain
, type
, protocol
;
1728 get_user_ualx(domain
, arg1
, 0);
1729 get_user_ualx(type
, arg1
, 1);
1730 get_user_ualx(protocol
, arg1
, 2);
1731 gemu_log("%s(", name
);
1732 print_socket_domain(domain
);
1734 print_socket_type(type
);
1736 if (domain
== AF_PACKET
||
1737 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1738 protocol
= tswap16(protocol
);
1740 print_socket_protocol(domain
, type
, protocol
);
1744 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1746 abi_ulong sockfd
, addr
, addrlen
;
1748 get_user_ualx(sockfd
, arg1
, 0);
1749 get_user_ualx(addr
, arg1
, 1);
1750 get_user_ualx(addrlen
, arg1
, 2);
1752 gemu_log("%s(", name
);
1753 print_sockfd(sockfd
, 0);
1754 print_sockaddr(addr
, addrlen
, 0);
1758 static void do_print_listen(const char *name
, abi_long arg1
)
1760 abi_ulong sockfd
, backlog
;
1762 get_user_ualx(sockfd
, arg1
, 0);
1763 get_user_ualx(backlog
, arg1
, 1);
1765 gemu_log("%s(", name
);
1766 print_sockfd(sockfd
, 0);
1767 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1771 static void do_print_socketpair(const char *name
, abi_long arg1
)
1773 abi_ulong domain
, type
, protocol
, tab
;
1775 get_user_ualx(domain
, arg1
, 0);
1776 get_user_ualx(type
, arg1
, 1);
1777 get_user_ualx(protocol
, arg1
, 2);
1778 get_user_ualx(tab
, arg1
, 3);
1780 gemu_log("%s(", name
);
1781 print_socket_domain(domain
);
1783 print_socket_type(type
);
1785 print_socket_protocol(domain
, type
, protocol
);
1787 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1791 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1793 abi_ulong sockfd
, msg
, len
, flags
;
1795 get_user_ualx(sockfd
, arg1
, 0);
1796 get_user_ualx(msg
, arg1
, 1);
1797 get_user_ualx(len
, arg1
, 2);
1798 get_user_ualx(flags
, arg1
, 3);
1800 gemu_log("%s(", name
);
1801 print_sockfd(sockfd
, 0);
1802 print_buf(msg
, len
, 0);
1803 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1804 print_flags(msg_flags
, flags
, 1);
1808 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1810 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1812 get_user_ualx(sockfd
, arg1
, 0);
1813 get_user_ualx(msg
, arg1
, 1);
1814 get_user_ualx(len
, arg1
, 2);
1815 get_user_ualx(flags
, arg1
, 3);
1816 get_user_ualx(addr
, arg1
, 4);
1817 get_user_ualx(addrlen
, arg1
, 5);
1819 gemu_log("%s(", name
);
1820 print_sockfd(sockfd
, 0);
1821 print_buf(msg
, len
, 0);
1822 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1823 print_flags(msg_flags
, flags
, 0);
1824 print_sockaddr(addr
, addrlen
, 0);
1828 static void do_print_shutdown(const char *name
, abi_long arg1
)
1830 abi_ulong sockfd
, how
;
1832 get_user_ualx(sockfd
, arg1
, 0);
1833 get_user_ualx(how
, arg1
, 1);
1835 gemu_log("shutdown(");
1836 print_sockfd(sockfd
, 0);
1839 gemu_log("SHUT_RD");
1842 gemu_log("SHUT_WR");
1845 gemu_log("SHUT_RDWR");
1848 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1854 static void do_print_msg(const char *name
, abi_long arg1
)
1856 abi_ulong sockfd
, msg
, flags
;
1858 get_user_ualx(sockfd
, arg1
, 0);
1859 get_user_ualx(msg
, arg1
, 1);
1860 get_user_ualx(flags
, arg1
, 2);
1862 gemu_log("%s(", name
);
1863 print_sockfd(sockfd
, 0);
1864 print_pointer(msg
, 0);
1865 print_flags(msg_flags
, flags
, 1);
1869 static void do_print_sockopt(const char *name
, abi_long arg1
)
1871 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1873 get_user_ualx(sockfd
, arg1
, 0);
1874 get_user_ualx(level
, arg1
, 1);
1875 get_user_ualx(optname
, arg1
, 2);
1876 get_user_ualx(optval
, arg1
, 3);
1877 get_user_ualx(optlen
, arg1
, 4);
1879 gemu_log("%s(", name
);
1880 print_sockfd(sockfd
, 0);
1883 gemu_log("SOL_TCP,");
1884 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1885 print_pointer(optval
, 0);
1888 gemu_log("SOL_IP,");
1889 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1890 print_pointer(optval
, 0);
1893 gemu_log("SOL_RAW,");
1894 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1895 print_pointer(optval
, 0);
1897 case TARGET_SOL_SOCKET
:
1898 gemu_log("SOL_SOCKET,");
1900 case TARGET_SO_DEBUG
:
1901 gemu_log("SO_DEBUG,");
1903 print_number(optval
, 0);
1905 case TARGET_SO_REUSEADDR
:
1906 gemu_log("SO_REUSEADDR,");
1908 case TARGET_SO_REUSEPORT
:
1909 gemu_log("SO_REUSEPORT,");
1911 case TARGET_SO_TYPE
:
1912 gemu_log("SO_TYPE,");
1914 case TARGET_SO_ERROR
:
1915 gemu_log("SO_ERROR,");
1917 case TARGET_SO_DONTROUTE
:
1918 gemu_log("SO_DONTROUTE,");
1920 case TARGET_SO_BROADCAST
:
1921 gemu_log("SO_BROADCAST,");
1923 case TARGET_SO_SNDBUF
:
1924 gemu_log("SO_SNDBUF,");
1926 case TARGET_SO_RCVBUF
:
1927 gemu_log("SO_RCVBUF,");
1929 case TARGET_SO_KEEPALIVE
:
1930 gemu_log("SO_KEEPALIVE,");
1932 case TARGET_SO_OOBINLINE
:
1933 gemu_log("SO_OOBINLINE,");
1935 case TARGET_SO_NO_CHECK
:
1936 gemu_log("SO_NO_CHECK,");
1938 case TARGET_SO_PRIORITY
:
1939 gemu_log("SO_PRIORITY,");
1941 case TARGET_SO_BSDCOMPAT
:
1942 gemu_log("SO_BSDCOMPAT,");
1944 case TARGET_SO_PASSCRED
:
1945 gemu_log("SO_PASSCRED,");
1947 case TARGET_SO_TIMESTAMP
:
1948 gemu_log("SO_TIMESTAMP,");
1950 case TARGET_SO_RCVLOWAT
:
1951 gemu_log("SO_RCVLOWAT,");
1953 case TARGET_SO_RCVTIMEO
:
1954 gemu_log("SO_RCVTIMEO,");
1955 print_timeval(optval
, 0);
1957 case TARGET_SO_SNDTIMEO
:
1958 gemu_log("SO_SNDTIMEO,");
1959 print_timeval(optval
, 0);
1961 case TARGET_SO_ATTACH_FILTER
: {
1962 struct target_sock_fprog
*fprog
;
1964 gemu_log("SO_ATTACH_FILTER,");
1966 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1967 struct target_sock_filter
*filter
;
1969 if (lock_user_struct(VERIFY_READ
, filter
,
1970 tswapal(fprog
->filter
), 0)) {
1972 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1973 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1974 i
, tswap16(filter
[i
].code
),
1975 filter
[i
].jt
, filter
[i
].jf
,
1976 tswap32(filter
[i
].k
));
1978 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1979 i
, tswap16(filter
[i
].code
),
1980 filter
[i
].jt
, filter
[i
].jf
,
1981 tswap32(filter
[i
].k
));
1983 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1985 gemu_log(",%d},", tswap16(fprog
->len
));
1986 unlock_user(fprog
, optval
, 0);
1988 print_pointer(optval
, 0);
1993 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1994 print_pointer(optval
, 0);
1999 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
2000 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2001 print_pointer(optval
, 0);
2004 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
2008 #define PRINT_SOCKOP(name, func) \
2009 [TARGET_SYS_##name] = { #name, func }
2013 void (*print
)(const char *, abi_long
);
2015 PRINT_SOCKOP(SOCKET
, do_print_socket
),
2016 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
2017 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
2018 PRINT_SOCKOP(LISTEN
, do_print_listen
),
2019 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
2020 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
2021 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
2022 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
2023 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
2024 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
2025 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
2026 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
2027 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
2028 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
2029 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
2030 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
2031 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
2032 PRINT_SOCKOP(ACCEPT4
, NULL
),
2033 PRINT_SOCKOP(RECVMMSG
, NULL
),
2034 PRINT_SOCKOP(SENDMMSG
, NULL
),
2038 print_socketcall(const struct syscallname
*name
,
2039 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2040 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2042 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
2043 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
2046 print_syscall_prologue(name
);
2047 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
2048 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2049 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2050 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
2051 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
2052 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
2053 print_syscall_epilogue(name
);
2057 #if defined(TARGET_NR_bind)
2059 print_bind(const struct syscallname
*name
,
2060 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2061 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2063 print_syscall_prologue(name
);
2064 print_sockfd(arg0
, 0);
2065 print_sockaddr(arg1
, arg2
, 1);
2066 print_syscall_epilogue(name
);
2070 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2071 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2073 print_stat(const struct syscallname
*name
,
2074 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2075 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2077 print_syscall_prologue(name
);
2078 print_string(arg0
, 0);
2079 print_pointer(arg1
, 1);
2080 print_syscall_epilogue(name
);
2082 #define print_lstat print_stat
2083 #define print_stat64 print_stat
2084 #define print_lstat64 print_stat
2087 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2089 print_fstat(const struct syscallname
*name
,
2090 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2091 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2093 print_syscall_prologue(name
);
2094 print_raw_param("%d", arg0
, 0);
2095 print_pointer(arg1
, 1);
2096 print_syscall_epilogue(name
);
2098 #define print_fstat64 print_fstat
2101 #ifdef TARGET_NR_mkdir
2103 print_mkdir(const struct syscallname
*name
,
2104 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2105 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2107 print_syscall_prologue(name
);
2108 print_string(arg0
, 0);
2109 print_file_mode(arg1
, 1);
2110 print_syscall_epilogue(name
);
2114 #ifdef TARGET_NR_mkdirat
2116 print_mkdirat(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_at_dirfd(arg0
, 0);
2122 print_string(arg1
, 0);
2123 print_file_mode(arg2
, 1);
2124 print_syscall_epilogue(name
);
2128 #ifdef TARGET_NR_rmdir
2130 print_rmdir(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_syscall_epilogue(name
);
2140 #ifdef TARGET_NR_rt_sigaction
2142 print_rt_sigaction(const struct syscallname
*name
,
2143 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2144 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2146 print_syscall_prologue(name
);
2147 print_signal(arg0
, 0);
2148 print_pointer(arg1
, 0);
2149 print_pointer(arg2
, 1);
2150 print_syscall_epilogue(name
);
2154 #ifdef TARGET_NR_rt_sigprocmask
2156 print_rt_sigprocmask(const struct syscallname
*name
,
2157 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2158 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2160 const char *how
= "UNKNOWN";
2161 print_syscall_prologue(name
);
2163 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2164 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2165 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2167 gemu_log("%s,",how
);
2168 print_pointer(arg1
, 0);
2169 print_pointer(arg2
, 1);
2170 print_syscall_epilogue(name
);
2174 #ifdef TARGET_NR_rt_sigqueueinfo
2176 print_rt_sigqueueinfo(const struct syscallname
*name
,
2177 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2178 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2181 target_siginfo_t uinfo
;
2183 print_syscall_prologue(name
);
2184 print_raw_param("%d", arg0
, 0);
2185 print_signal(arg1
, 0);
2186 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2188 get_target_siginfo(&uinfo
, p
);
2189 print_siginfo(&uinfo
);
2191 unlock_user(p
, arg2
, 0);
2193 print_pointer(arg2
, 1);
2195 print_syscall_epilogue(name
);
2199 #ifdef TARGET_NR_rt_tgsigqueueinfo
2201 print_rt_tgsigqueueinfo(const struct syscallname
*name
,
2202 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2203 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2206 target_siginfo_t uinfo
;
2208 print_syscall_prologue(name
);
2209 print_raw_param("%d", arg0
, 0);
2210 print_raw_param("%d", arg1
, 0);
2211 print_signal(arg2
, 0);
2212 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2214 get_target_siginfo(&uinfo
, p
);
2215 print_siginfo(&uinfo
);
2217 unlock_user(p
, arg3
, 0);
2219 print_pointer(arg3
, 1);
2221 print_syscall_epilogue(name
);
2225 #ifdef TARGET_NR_syslog
2227 print_syslog_action(abi_ulong arg
, int last
)
2232 case TARGET_SYSLOG_ACTION_CLOSE
: {
2233 type
= "SYSLOG_ACTION_CLOSE";
2236 case TARGET_SYSLOG_ACTION_OPEN
: {
2237 type
= "SYSLOG_ACTION_OPEN";
2240 case TARGET_SYSLOG_ACTION_READ
: {
2241 type
= "SYSLOG_ACTION_READ";
2244 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2245 type
= "SYSLOG_ACTION_READ_ALL";
2248 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2249 type
= "SYSLOG_ACTION_READ_CLEAR";
2252 case TARGET_SYSLOG_ACTION_CLEAR
: {
2253 type
= "SYSLOG_ACTION_CLEAR";
2256 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2257 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2260 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
2261 type
= "SYSLOG_ACTION_CONSOLE_ON";
2264 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
2265 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
2268 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
2269 type
= "SYSLOG_ACTION_SIZE_UNREAD";
2272 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
2273 type
= "SYSLOG_ACTION_SIZE_BUFFER";
2277 print_raw_param("%ld", arg
, last
);
2281 gemu_log("%s%s", type
, get_comma(last
));
2285 print_syslog(const struct syscallname
*name
,
2286 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2287 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2289 print_syscall_prologue(name
);
2290 print_syslog_action(arg0
, 0);
2291 print_pointer(arg1
, 0);
2292 print_raw_param("%d", arg2
, 1);
2293 print_syscall_epilogue(name
);
2297 #ifdef TARGET_NR_mknod
2299 print_mknod(const struct syscallname
*name
,
2300 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2301 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2303 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
2305 print_syscall_prologue(name
);
2306 print_string(arg0
, 0);
2307 print_file_mode(arg1
, (hasdev
== 0));
2309 print_raw_param("makedev(%d", major(arg2
), 0);
2310 print_raw_param("%d)", minor(arg2
), 1);
2312 print_syscall_epilogue(name
);
2316 #ifdef TARGET_NR_mknodat
2318 print_mknodat(const struct syscallname
*name
,
2319 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2320 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2322 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2324 print_syscall_prologue(name
);
2325 print_at_dirfd(arg0
, 0);
2326 print_string(arg1
, 0);
2327 print_file_mode(arg2
, (hasdev
== 0));
2329 print_raw_param("makedev(%d", major(arg3
), 0);
2330 print_raw_param("%d)", minor(arg3
), 1);
2332 print_syscall_epilogue(name
);
2336 #ifdef TARGET_NR_mq_open
2338 print_mq_open(const struct syscallname
*name
,
2339 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2340 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2342 int is_creat
= (arg1
& TARGET_O_CREAT
);
2344 print_syscall_prologue(name
);
2345 print_string(arg0
, 0);
2346 print_open_flags(arg1
, (is_creat
== 0));
2348 print_file_mode(arg2
, 0);
2349 print_pointer(arg3
, 1);
2351 print_syscall_epilogue(name
);
2355 #ifdef TARGET_NR_open
2357 print_open(const struct syscallname
*name
,
2358 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2359 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2361 int is_creat
= (arg1
& TARGET_O_CREAT
);
2363 print_syscall_prologue(name
);
2364 print_string(arg0
, 0);
2365 print_open_flags(arg1
, (is_creat
== 0));
2367 print_file_mode(arg2
, 1);
2368 print_syscall_epilogue(name
);
2372 #ifdef TARGET_NR_openat
2374 print_openat(const struct syscallname
*name
,
2375 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2376 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2378 int is_creat
= (arg2
& TARGET_O_CREAT
);
2380 print_syscall_prologue(name
);
2381 print_at_dirfd(arg0
, 0);
2382 print_string(arg1
, 0);
2383 print_open_flags(arg2
, (is_creat
== 0));
2385 print_file_mode(arg3
, 1);
2386 print_syscall_epilogue(name
);
2390 #ifdef TARGET_NR_mq_unlink
2392 print_mq_unlink(const struct syscallname
*name
,
2393 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2394 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2396 print_syscall_prologue(name
);
2397 print_string(arg0
, 1);
2398 print_syscall_epilogue(name
);
2402 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2404 print_fstatat64(const struct syscallname
*name
,
2405 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2406 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2408 print_syscall_prologue(name
);
2409 print_at_dirfd(arg0
, 0);
2410 print_string(arg1
, 0);
2411 print_pointer(arg2
, 0);
2412 print_flags(at_file_flags
, arg3
, 1);
2413 print_syscall_epilogue(name
);
2415 #define print_newfstatat print_fstatat64
2418 #ifdef TARGET_NR_readlink
2420 print_readlink(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_string(arg0
, 0);
2426 print_pointer(arg1
, 0);
2427 print_raw_param("%u", arg2
, 1);
2428 print_syscall_epilogue(name
);
2432 #ifdef TARGET_NR_readlinkat
2434 print_readlinkat(const struct syscallname
*name
,
2435 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2436 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2438 print_syscall_prologue(name
);
2439 print_at_dirfd(arg0
, 0);
2440 print_string(arg1
, 0);
2441 print_pointer(arg2
, 0);
2442 print_raw_param("%u", arg3
, 1);
2443 print_syscall_epilogue(name
);
2447 #ifdef TARGET_NR_rename
2449 print_rename(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 print_syscall_prologue(name
);
2454 print_string(arg0
, 0);
2455 print_string(arg1
, 1);
2456 print_syscall_epilogue(name
);
2460 #ifdef TARGET_NR_renameat
2462 print_renameat(const struct syscallname
*name
,
2463 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2464 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2466 print_syscall_prologue(name
);
2467 print_at_dirfd(arg0
, 0);
2468 print_string(arg1
, 0);
2469 print_at_dirfd(arg2
, 0);
2470 print_string(arg3
, 1);
2471 print_syscall_epilogue(name
);
2475 #ifdef TARGET_NR_statfs
2477 print_statfs(const struct syscallname
*name
,
2478 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2479 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2481 print_syscall_prologue(name
);
2482 print_string(arg0
, 0);
2483 print_pointer(arg1
, 1);
2484 print_syscall_epilogue(name
);
2488 #ifdef TARGET_NR_statfs64
2490 print_statfs64(const struct syscallname
*name
,
2491 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2492 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2494 print_syscall_prologue(name
);
2495 print_string(arg0
, 0);
2496 print_pointer(arg1
, 1);
2497 print_syscall_epilogue(name
);
2501 #ifdef TARGET_NR_symlink
2503 print_symlink(const struct syscallname
*name
,
2504 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2505 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2507 print_syscall_prologue(name
);
2508 print_string(arg0
, 0);
2509 print_string(arg1
, 1);
2510 print_syscall_epilogue(name
);
2514 #ifdef TARGET_NR_symlinkat
2516 print_symlinkat(const struct syscallname
*name
,
2517 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2518 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2520 print_syscall_prologue(name
);
2521 print_string(arg0
, 0);
2522 print_at_dirfd(arg1
, 0);
2523 print_string(arg2
, 1);
2524 print_syscall_epilogue(name
);
2528 #ifdef TARGET_NR_mount
2530 print_mount(const struct syscallname
*name
,
2531 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2532 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2534 print_syscall_prologue(name
);
2535 print_string(arg0
, 0);
2536 print_string(arg1
, 0);
2537 print_string(arg2
, 0);
2538 print_flags(mount_flags
, arg3
, 0);
2539 print_pointer(arg4
, 1);
2540 print_syscall_epilogue(name
);
2544 #ifdef TARGET_NR_umount
2546 print_umount(const struct syscallname
*name
,
2547 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2548 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2550 print_syscall_prologue(name
);
2551 print_string(arg0
, 1);
2552 print_syscall_epilogue(name
);
2556 #ifdef TARGET_NR_umount2
2558 print_umount2(const struct syscallname
*name
,
2559 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2560 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2562 print_syscall_prologue(name
);
2563 print_string(arg0
, 0);
2564 print_flags(umount2_flags
, arg1
, 1);
2565 print_syscall_epilogue(name
);
2569 #ifdef TARGET_NR_unlink
2571 print_unlink(const struct syscallname
*name
,
2572 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2573 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2575 print_syscall_prologue(name
);
2576 print_string(arg0
, 1);
2577 print_syscall_epilogue(name
);
2581 #ifdef TARGET_NR_unlinkat
2583 print_unlinkat(const struct syscallname
*name
,
2584 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2585 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2587 print_syscall_prologue(name
);
2588 print_at_dirfd(arg0
, 0);
2589 print_string(arg1
, 0);
2590 print_flags(unlinkat_flags
, arg2
, 1);
2591 print_syscall_epilogue(name
);
2595 #ifdef TARGET_NR_utime
2597 print_utime(const struct syscallname
*name
,
2598 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2599 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2601 print_syscall_prologue(name
);
2602 print_string(arg0
, 0);
2603 print_pointer(arg1
, 1);
2604 print_syscall_epilogue(name
);
2608 #ifdef TARGET_NR_utimes
2610 print_utimes(const struct syscallname
*name
,
2611 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2612 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2614 print_syscall_prologue(name
);
2615 print_string(arg0
, 0);
2616 print_pointer(arg1
, 1);
2617 print_syscall_epilogue(name
);
2621 #ifdef TARGET_NR_utimensat
2623 print_utimensat(const struct syscallname
*name
,
2624 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2625 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2627 print_syscall_prologue(name
);
2628 print_at_dirfd(arg0
, 0);
2629 print_string(arg1
, 0);
2630 print_pointer(arg2
, 0);
2631 print_flags(at_file_flags
, arg3
, 1);
2632 print_syscall_epilogue(name
);
2636 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2638 print_mmap(const struct syscallname
*name
,
2639 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2640 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2642 print_syscall_prologue(name
);
2643 print_pointer(arg0
, 0);
2644 print_raw_param("%d", arg1
, 0);
2645 print_flags(mmap_prot_flags
, arg2
, 0);
2646 print_flags(mmap_flags
, arg3
, 0);
2647 print_raw_param("%d", arg4
, 0);
2648 print_raw_param("%#x", arg5
, 1);
2649 print_syscall_epilogue(name
);
2651 #define print_mmap2 print_mmap
2654 #ifdef TARGET_NR_mprotect
2656 print_mprotect(const struct syscallname
*name
,
2657 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2658 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2660 print_syscall_prologue(name
);
2661 print_pointer(arg0
, 0);
2662 print_raw_param("%d", arg1
, 0);
2663 print_flags(mmap_prot_flags
, arg2
, 1);
2664 print_syscall_epilogue(name
);
2668 #ifdef TARGET_NR_munmap
2670 print_munmap(const struct syscallname
*name
,
2671 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2672 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2674 print_syscall_prologue(name
);
2675 print_pointer(arg0
, 0);
2676 print_raw_param("%d", arg1
, 1);
2677 print_syscall_epilogue(name
);
2681 #ifdef TARGET_NR_futex
2682 static void print_futex_op(abi_long tflag
, int last
)
2684 #define print_op(val) \
2685 if( cmd == val ) { \
2690 int cmd
= (int)tflag
;
2691 #ifdef FUTEX_PRIVATE_FLAG
2692 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2693 gemu_log("FUTEX_PRIVATE_FLAG|");
2694 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2697 #ifdef FUTEX_CLOCK_REALTIME
2698 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2699 gemu_log("FUTEX_CLOCK_REALTIME|");
2700 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2703 print_op(FUTEX_WAIT
)
2704 print_op(FUTEX_WAKE
)
2706 print_op(FUTEX_REQUEUE
)
2707 print_op(FUTEX_CMP_REQUEUE
)
2708 print_op(FUTEX_WAKE_OP
)
2709 print_op(FUTEX_LOCK_PI
)
2710 print_op(FUTEX_UNLOCK_PI
)
2711 print_op(FUTEX_TRYLOCK_PI
)
2712 #ifdef FUTEX_WAIT_BITSET
2713 print_op(FUTEX_WAIT_BITSET
)
2715 #ifdef FUTEX_WAKE_BITSET
2716 print_op(FUTEX_WAKE_BITSET
)
2718 /* unknown values */
2723 print_futex(const struct syscallname
*name
,
2724 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2725 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2727 print_syscall_prologue(name
);
2728 print_pointer(arg0
, 0);
2729 print_futex_op(arg1
, 0);
2730 print_raw_param(",%d", arg2
, 0);
2731 print_pointer(arg3
, 0); /* struct timespec */
2732 print_pointer(arg4
, 0);
2733 print_raw_param("%d", arg4
, 1);
2734 print_syscall_epilogue(name
);
2738 #ifdef TARGET_NR_kill
2740 print_kill(const struct syscallname
*name
,
2741 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2742 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2744 print_syscall_prologue(name
);
2745 print_raw_param("%d", arg0
, 0);
2746 print_signal(arg1
, 1);
2747 print_syscall_epilogue(name
);
2751 #ifdef TARGET_NR_tkill
2753 print_tkill(const struct syscallname
*name
,
2754 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2755 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2757 print_syscall_prologue(name
);
2758 print_raw_param("%d", arg0
, 0);
2759 print_signal(arg1
, 1);
2760 print_syscall_epilogue(name
);
2764 #ifdef TARGET_NR_tgkill
2766 print_tgkill(const struct syscallname
*name
,
2767 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2768 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2770 print_syscall_prologue(name
);
2771 print_raw_param("%d", arg0
, 0);
2772 print_raw_param("%d", arg1
, 0);
2773 print_signal(arg2
, 1);
2774 print_syscall_epilogue(name
);
2778 #ifdef TARGET_NR_statx
2780 print_statx(const struct syscallname
*name
,
2781 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2782 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2784 print_syscall_prologue(name
);
2785 print_at_dirfd(arg0
, 0);
2786 print_string(arg1
, 0);
2787 print_flags(statx_flags
, arg2
, 0);
2788 print_flags(statx_mask
, arg3
, 0);
2789 print_pointer(arg4
, 1);
2790 print_syscall_epilogue(name
);
2795 * An array of all of the syscalls we know about
2798 static const struct syscallname scnames
[] = {
2799 #include "strace.list"
2802 static int nsyscalls
= ARRAY_SIZE(scnames
);
2805 * The public interface to this module.
2808 print_syscall(int num
,
2809 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2810 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2813 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
")";
2815 gemu_log("%d ", getpid() );
2817 for(i
=0;i
<nsyscalls
;i
++)
2818 if( scnames
[i
].nr
== num
) {
2819 if( scnames
[i
].call
!= NULL
) {
2820 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2822 /* XXX: this format system is broken because it uses
2823 host types and host pointers for strings */
2824 if( scnames
[i
].format
!= NULL
)
2825 format
= scnames
[i
].format
;
2826 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2830 gemu_log("Unknown syscall %d\n", num
);
2835 print_syscall_ret(int num
, abi_long ret
)
2838 const char *errstr
= NULL
;
2840 for(i
=0;i
<nsyscalls
;i
++)
2841 if( scnames
[i
].nr
== num
) {
2842 if( scnames
[i
].result
!= NULL
) {
2843 scnames
[i
].result(&scnames
[i
],ret
);
2846 errstr
= target_strerror(-ret
);
2849 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2852 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2859 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2861 /* Print the strace output for a signal being taken:
2862 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2865 print_signal(target_signum
, 1);
2867 print_siginfo(tinfo
);