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
)(const struct syscallname
*,
20 abi_long
, abi_long
, abi_long
,
21 abi_long
, abi_long
, abi_long
);
22 void (*result
)(const struct syscallname
*, abi_long
);
27 * It is possible that target doesn't have syscall that uses
28 * following flags but we don't want the compiler to warn
29 * us about them being unused. Same applies to utility print
30 * functions. It is ok to keep them while not used.
32 #define UNUSED __attribute__ ((unused))
38 * Structure used to translate flag values into strings. This is
39 * similar that is in the actual strace tool.
42 abi_long f_value
; /* flag */
43 const char *f_string
; /* stringified flag */
46 /* common flags for all architectures */
47 #define FLAG_GENERIC(name) { name, #name }
48 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
49 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
50 /* end of flags array */
51 #define FLAG_END { 0, NULL }
53 UNUSED
static const char *get_comma(int);
54 UNUSED
static void print_pointer(abi_long
, int);
55 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
56 UNUSED
static void print_at_dirfd(abi_long
, int);
57 UNUSED
static void print_file_mode(abi_long
, int);
58 UNUSED
static void print_open_flags(abi_long
, int);
59 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
60 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
61 UNUSED
static void print_string(abi_long
, int);
62 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
63 UNUSED
static void print_raw_param(const char *, abi_long
, int);
64 UNUSED
static void print_timeval(abi_ulong
, int);
65 UNUSED
static void print_timezone(abi_ulong
, int);
66 UNUSED
static void print_number(abi_long
, int);
67 UNUSED
static void print_signal(abi_ulong
, int);
68 UNUSED
static void print_sockaddr(abi_ulong
, abi_long
, int);
69 UNUSED
static void print_socket_domain(int domain
);
70 UNUSED
static void print_socket_type(int type
);
71 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
77 print_ipc_cmd(int cmd
)
79 #define output_cmd(val) \
87 /* General IPC commands */
88 output_cmd( IPC_RMID
);
89 output_cmd( IPC_SET
);
90 output_cmd( IPC_STAT
);
91 output_cmd( IPC_INFO
);
92 /* msgctl() commands */
93 output_cmd( MSG_STAT
);
94 output_cmd( MSG_INFO
);
95 /* shmctl() commands */
96 output_cmd( SHM_LOCK
);
97 output_cmd( SHM_UNLOCK
);
98 output_cmd( SHM_STAT
);
99 output_cmd( SHM_INFO
);
100 /* semctl() commands */
101 output_cmd( GETPID
);
102 output_cmd( GETVAL
);
103 output_cmd( GETALL
);
104 output_cmd( GETNCNT
);
105 output_cmd( GETZCNT
);
106 output_cmd( SETVAL
);
107 output_cmd( SETALL
);
108 output_cmd( SEM_STAT
);
109 output_cmd( SEM_INFO
);
110 output_cmd( IPC_RMID
);
111 output_cmd( IPC_RMID
);
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
);
120 /* Some value we don't recognize */
125 print_signal(abi_ulong arg
, int last
)
127 const char *signal_name
= NULL
;
129 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
130 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
131 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
132 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
133 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
134 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
135 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
136 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
137 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
138 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
139 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
140 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
141 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
142 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
143 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
144 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
145 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
146 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
148 if (signal_name
== NULL
) {
149 print_raw_param("%ld", arg
, last
);
152 qemu_log("%s%s", signal_name
, get_comma(last
));
155 static void print_si_code(int arg
)
157 const char *codename
= NULL
;
161 codename
= "SI_USER";
164 codename
= "SI_KERNEL";
167 codename
= "SI_QUEUE";
170 codename
= "SI_TIMER";
173 codename
= "SI_MESGQ";
176 codename
= "SI_ASYNCIO";
179 codename
= "SI_SIGIO";
182 codename
= "SI_TKILL";
188 qemu_log("%s", codename
);
191 static void get_target_siginfo(target_siginfo_t
*tinfo
,
192 const target_siginfo_t
*info
)
201 __get_user(sig
, &info
->si_signo
);
202 __get_user(si_errno
, &tinfo
->si_errno
);
203 __get_user(si_code
, &info
->si_code
);
205 tinfo
->si_signo
= sig
;
206 tinfo
->si_errno
= si_errno
;
207 tinfo
->si_code
= si_code
;
209 /* Ensure we don't leak random junk to the guest later */
210 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
212 /* This is awkward, because we have to use a combination of
213 * the si_code and si_signo to figure out which of the union's
214 * members are valid. (Within the host kernel it is always possible
215 * to tell, but the kernel carefully avoids giving userspace the
216 * high 16 bits of si_code, so we don't have the information to
217 * do this the easy way...) We therefore make our best guess,
218 * bearing in mind that a guest can spoof most of the si_codes
219 * via rt_sigqueueinfo() if it likes.
221 * Once we have made our guess, we record it in the top 16 bits of
222 * the si_code, so that print_siginfo() later can use it.
223 * print_siginfo() will strip these top bits out before printing
231 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
232 * These are the only unspoofable si_code values.
234 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
235 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
236 si_type
= QEMU_SI_KILL
;
239 /* Everything else is spoofable. Make best guess based on signal */
242 __get_user(tinfo
->_sifields
._sigchld
._pid
,
243 &info
->_sifields
._sigchld
._pid
);
244 __get_user(tinfo
->_sifields
._sigchld
._uid
,
245 &info
->_sifields
._sigchld
._uid
);
246 __get_user(tinfo
->_sifields
._sigchld
._status
,
247 &info
->_sifields
._sigchld
._status
);
248 __get_user(tinfo
->_sifields
._sigchld
._utime
,
249 &info
->_sifields
._sigchld
._utime
);
250 __get_user(tinfo
->_sifields
._sigchld
._stime
,
251 &info
->_sifields
._sigchld
._stime
);
252 si_type
= QEMU_SI_CHLD
;
255 __get_user(tinfo
->_sifields
._sigpoll
._band
,
256 &info
->_sifields
._sigpoll
._band
);
257 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
258 &info
->_sifields
._sigpoll
._fd
);
259 si_type
= QEMU_SI_POLL
;
262 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
263 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
264 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
265 /* XXX: potential problem if 64 bit */
266 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
267 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
269 si_type
= QEMU_SI_RT
;
275 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
278 static void print_siginfo(const target_siginfo_t
*tinfo
)
280 /* Print a target_siginfo_t in the format desired for printing
281 * signals being taken. We assume the target_siginfo_t is in the
282 * internal form where the top 16 bits of si_code indicate which
283 * part of the union is valid, rather than in the guest-visible
284 * form where the bottom 16 bits are sign-extended into the top 16.
286 int si_type
= extract32(tinfo
->si_code
, 16, 16);
287 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
289 qemu_log("{si_signo=");
290 print_signal(tinfo
->si_signo
, 1);
291 qemu_log(", si_code=");
292 print_si_code(si_code
);
296 qemu_log(", si_pid=%u, si_uid=%u",
297 (unsigned int)tinfo
->_sifields
._kill
._pid
,
298 (unsigned int)tinfo
->_sifields
._kill
._uid
);
301 qemu_log(", si_timer1=%u, si_timer2=%u",
302 tinfo
->_sifields
._timer
._timer1
,
303 tinfo
->_sifields
._timer
._timer2
);
306 qemu_log(", si_band=%d, si_fd=%d",
307 tinfo
->_sifields
._sigpoll
._band
,
308 tinfo
->_sifields
._sigpoll
._fd
);
311 qemu_log(", si_addr=");
312 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
315 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
316 ", si_utime=" TARGET_ABI_FMT_ld
317 ", si_stime=" TARGET_ABI_FMT_ld
,
318 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
319 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
320 tinfo
->_sifields
._sigchld
._status
,
321 tinfo
->_sifields
._sigchld
._utime
,
322 tinfo
->_sifields
._sigchld
._stime
);
325 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
326 (unsigned int)tinfo
->_sifields
._rt
._pid
,
327 (unsigned int)tinfo
->_sifields
._rt
._uid
,
328 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
331 g_assert_not_reached();
337 print_sockaddr(abi_ulong addr
, abi_long addrlen
, int last
)
339 struct target_sockaddr
*sa
;
343 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
345 sa_family
= tswap16(sa
->sa_family
);
348 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
350 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
351 for (i
= 0; i
< addrlen
-
352 offsetof(struct target_sockaddr_un
, sun_path
) &&
353 un
->sun_path
[i
]; i
++) {
354 qemu_log("%c", un
->sun_path
[i
]);
360 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
361 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
362 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
363 ntohs(in
->sin_port
));
364 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
365 c
[0], c
[1], c
[2], c
[3]);
370 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
371 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
372 qemu_log("{sll_family=AF_PACKET,"
373 "sll_protocol=htons(0x%04x),if%d,pkttype=",
374 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
375 switch (ll
->sll_pkttype
) {
377 qemu_log("PACKET_HOST");
379 case PACKET_BROADCAST
:
380 qemu_log("PACKET_BROADCAST");
382 case PACKET_MULTICAST
:
383 qemu_log("PACKET_MULTICAST");
385 case PACKET_OTHERHOST
:
386 qemu_log("PACKET_OTHERHOST");
388 case PACKET_OUTGOING
:
389 qemu_log("PACKET_OUTGOING");
392 qemu_log("%d", ll
->sll_pkttype
);
395 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
396 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
401 struct target_sockaddr_nl
*nl
= (struct target_sockaddr_nl
*)sa
;
402 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
403 tswap32(nl
->nl_pid
), tswap32(nl
->nl_groups
));
407 qemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
408 for (i
= 0; i
< 13; i
++) {
409 qemu_log("%02x, ", sa
->sa_data
[i
]);
411 qemu_log("%02x}", sa
->sa_data
[i
]);
415 unlock_user(sa
, addr
, 0);
417 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
419 qemu_log(", "TARGET_ABI_FMT_ld
"%s", addrlen
, get_comma(last
));
423 print_socket_domain(int domain
)
433 qemu_log("PF_NETLINK");
436 qemu_log("PF_PACKET");
439 qemu_log("%d", domain
);
445 print_socket_type(int type
)
447 switch (type
& TARGET_SOCK_TYPE_MASK
) {
448 case TARGET_SOCK_DGRAM
:
449 qemu_log("SOCK_DGRAM");
451 case TARGET_SOCK_STREAM
:
452 qemu_log("SOCK_STREAM");
454 case TARGET_SOCK_RAW
:
455 qemu_log("SOCK_RAW");
457 case TARGET_SOCK_RDM
:
458 qemu_log("SOCK_RDM");
460 case TARGET_SOCK_SEQPACKET
:
461 qemu_log("SOCK_SEQPACKET");
463 case TARGET_SOCK_PACKET
:
464 qemu_log("SOCK_PACKET");
467 if (type
& TARGET_SOCK_CLOEXEC
) {
468 qemu_log("|SOCK_CLOEXEC");
470 if (type
& TARGET_SOCK_NONBLOCK
) {
471 qemu_log("|SOCK_NONBLOCK");
476 print_socket_protocol(int domain
, int type
, int protocol
)
478 if (domain
== AF_PACKET
||
479 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
482 qemu_log("ETH_P_ALL");
485 qemu_log("%d", protocol
);
490 if (domain
== PF_NETLINK
) {
493 qemu_log("NETLINK_ROUTE");
496 qemu_log("NETLINK_AUDIT");
498 case NETLINK_NETFILTER
:
499 qemu_log("NETLINK_NETFILTER");
501 case NETLINK_KOBJECT_UEVENT
:
502 qemu_log("NETLINK_KOBJECT_UEVENT");
505 qemu_log("NETLINK_RDMA");
508 qemu_log("NETLINK_CRYPTO");
511 qemu_log("%d", protocol
);
519 qemu_log("IPPROTO_IP");
522 qemu_log("IPPROTO_TCP");
525 qemu_log("IPPROTO_UDP");
528 qemu_log("IPPROTO_RAW");
531 qemu_log("%d", protocol
);
537 #ifdef TARGET_NR__newselect
539 print_fdset(int n
, abi_ulong target_fds_addr
)
544 if( target_fds_addr
) {
545 abi_long
*target_fds
;
547 target_fds
= lock_user(VERIFY_READ
,
549 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
555 for (i
=n
; i
>=0; i
--) {
556 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
559 unlock_user(target_fds
, target_fds_addr
, 0);
565 #ifdef TARGET_NR_clock_adjtime
566 /* IDs of the various system clocks */
567 #define TARGET_CLOCK_REALTIME 0
568 #define TARGET_CLOCK_MONOTONIC 1
569 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
570 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
571 #define TARGET_CLOCK_MONOTONIC_RAW 4
572 #define TARGET_CLOCK_REALTIME_COARSE 5
573 #define TARGET_CLOCK_MONOTONIC_COARSE 6
574 #define TARGET_CLOCK_BOOTTIME 7
575 #define TARGET_CLOCK_REALTIME_ALARM 8
576 #define TARGET_CLOCK_BOOTTIME_ALARM 9
577 #define TARGET_CLOCK_SGI_CYCLE 10
578 #define TARGET_CLOCK_TAI 11
581 print_clockid(int clockid
, int last
)
584 case TARGET_CLOCK_REALTIME
:
585 qemu_log("CLOCK_REALTIME");
587 case TARGET_CLOCK_MONOTONIC
:
588 qemu_log("CLOCK_MONOTONIC");
590 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
591 qemu_log("CLOCK_PROCESS_CPUTIME_ID");
593 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
594 qemu_log("CLOCK_THREAD_CPUTIME_ID");
596 case TARGET_CLOCK_MONOTONIC_RAW
:
597 qemu_log("CLOCK_MONOTONIC_RAW");
599 case TARGET_CLOCK_REALTIME_COARSE
:
600 qemu_log("CLOCK_REALTIME_COARSE");
602 case TARGET_CLOCK_MONOTONIC_COARSE
:
603 qemu_log("CLOCK_MONOTONIC_COARSE");
605 case TARGET_CLOCK_BOOTTIME
:
606 qemu_log("CLOCK_BOOTTIME");
608 case TARGET_CLOCK_REALTIME_ALARM
:
609 qemu_log("CLOCK_REALTIME_ALARM");
611 case TARGET_CLOCK_BOOTTIME_ALARM
:
612 qemu_log("CLOCK_BOOTTIME_ALARM");
614 case TARGET_CLOCK_SGI_CYCLE
:
615 qemu_log("CLOCK_SGI_CYCLE");
617 case TARGET_CLOCK_TAI
:
618 qemu_log("CLOCK_TAI");
621 qemu_log("%d", clockid
);
624 qemu_log("%s", get_comma(last
));
629 * Sysycall specific output functions
633 #ifdef TARGET_NR__newselect
634 static long newselect_arg1
= 0;
635 static long newselect_arg2
= 0;
636 static long newselect_arg3
= 0;
637 static long newselect_arg4
= 0;
638 static long newselect_arg5
= 0;
641 print_newselect(const struct syscallname
*name
,
642 abi_long arg1
, abi_long arg2
, abi_long arg3
,
643 abi_long arg4
, abi_long arg5
, abi_long arg6
)
645 qemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
646 print_fdset(arg1
, arg2
);
648 print_fdset(arg1
, arg3
);
650 print_fdset(arg1
, arg4
);
652 print_timeval(arg5
, 1);
655 /* save for use in the return output function below */
664 #ifdef TARGET_NR_semctl
666 print_semctl(const struct syscallname
*name
,
667 abi_long arg1
, abi_long arg2
, abi_long arg3
,
668 abi_long arg4
, abi_long arg5
, abi_long arg6
)
670 qemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
671 name
->name
, arg1
, arg2
);
673 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
678 print_execve(const struct syscallname
*name
,
679 abi_long arg1
, abi_long arg2
, abi_long arg3
,
680 abi_long arg4
, abi_long arg5
, abi_long arg6
)
682 abi_ulong arg_ptr_addr
;
685 if (!(s
= lock_user_string(arg1
)))
687 qemu_log("%s(\"%s\",{", name
->name
, s
);
688 unlock_user(s
, arg1
, 0);
690 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
691 abi_ulong
*arg_ptr
, arg_addr
;
693 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
696 arg_addr
= tswapal(*arg_ptr
);
697 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
700 if ((s
= lock_user_string(arg_addr
))) {
701 qemu_log("\"%s\",", s
);
702 unlock_user(s
, arg_addr
, 0);
711 print_ipc(const struct syscallname
*name
,
712 abi_long arg1
, abi_long arg2
, abi_long arg3
,
713 abi_long arg4
, abi_long arg5
, abi_long arg6
)
717 qemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",",
720 qemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
724 TARGET_ABI_FMT_ld
","
725 TARGET_ABI_FMT_ld
","
726 TARGET_ABI_FMT_ld
","
729 name
->name
, arg1
, arg2
, arg3
, arg4
);
735 * Variants for the return value output function
739 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
741 const char *errstr
= NULL
;
744 errstr
= target_strerror(-ret
);
747 qemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
749 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
753 #if 0 /* currently unused */
755 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
757 qemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
761 #ifdef TARGET_NR__newselect
763 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
765 qemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
766 print_fdset(newselect_arg1
,newselect_arg2
);
768 print_fdset(newselect_arg1
,newselect_arg3
);
770 print_fdset(newselect_arg1
,newselect_arg4
);
772 print_timeval(newselect_arg5
, 1);
777 /* special meanings of adjtimex()' non-negative return values */
778 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
779 #define TARGET_TIME_INS 1 /* insert leap second */
780 #define TARGET_TIME_DEL 2 /* delete leap second */
781 #define TARGET_TIME_OOP 3 /* leap second in progress */
782 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
783 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
784 #ifdef TARGET_NR_adjtimex
786 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
788 const char *errstr
= NULL
;
792 qemu_log("-1 errno=%d", errno
);
793 errstr
= target_strerror(-ret
);
795 qemu_log(" (%s)", errstr
);
798 qemu_log(TARGET_ABI_FMT_ld
, ret
);
801 qemu_log(" TIME_OK (clock synchronized, no leap second)");
803 case TARGET_TIME_INS
:
804 qemu_log(" TIME_INS (insert leap second)");
806 case TARGET_TIME_DEL
:
807 qemu_log(" TIME_DEL (delete leap second)");
809 case TARGET_TIME_OOP
:
810 qemu_log(" TIME_OOP (leap second in progress)");
812 case TARGET_TIME_WAIT
:
813 qemu_log(" TIME_WAIT (leap second has occurred)");
815 case TARGET_TIME_ERROR
:
816 qemu_log(" TIME_ERROR (clock not synchronized)");
825 UNUSED
static struct flags access_flags
[] = {
833 UNUSED
static struct flags at_file_flags
[] = {
835 FLAG_GENERIC(AT_EACCESS
),
837 #ifdef AT_SYMLINK_NOFOLLOW
838 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
843 UNUSED
static struct flags unlinkat_flags
[] = {
845 FLAG_GENERIC(AT_REMOVEDIR
),
850 UNUSED
static struct flags mode_flags
[] = {
851 FLAG_GENERIC(S_IFSOCK
),
852 FLAG_GENERIC(S_IFLNK
),
853 FLAG_GENERIC(S_IFREG
),
854 FLAG_GENERIC(S_IFBLK
),
855 FLAG_GENERIC(S_IFDIR
),
856 FLAG_GENERIC(S_IFCHR
),
857 FLAG_GENERIC(S_IFIFO
),
861 UNUSED
static struct flags open_access_flags
[] = {
862 FLAG_TARGET(O_RDONLY
),
863 FLAG_TARGET(O_WRONLY
),
868 UNUSED
static struct flags open_flags
[] = {
869 FLAG_TARGET(O_APPEND
),
870 FLAG_TARGET(O_CREAT
),
871 FLAG_TARGET(O_DIRECTORY
),
873 FLAG_TARGET(O_LARGEFILE
),
874 FLAG_TARGET(O_NOCTTY
),
875 FLAG_TARGET(O_NOFOLLOW
),
876 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
877 FLAG_TARGET(O_DSYNC
),
878 FLAG_TARGET(__O_SYNC
),
879 FLAG_TARGET(O_TRUNC
),
881 FLAG_TARGET(O_DIRECT
),
884 FLAG_TARGET(O_NOATIME
),
887 FLAG_TARGET(O_CLOEXEC
),
893 FLAG_TARGET(O_TMPFILE
),
894 FLAG_TARGET(__O_TMPFILE
),
899 UNUSED
static struct flags mount_flags
[] = {
901 FLAG_GENERIC(MS_BIND
),
904 FLAG_GENERIC(MS_DIRSYNC
),
906 FLAG_GENERIC(MS_MANDLOCK
),
908 FLAG_GENERIC(MS_MOVE
),
910 FLAG_GENERIC(MS_NOATIME
),
911 FLAG_GENERIC(MS_NODEV
),
912 FLAG_GENERIC(MS_NODIRATIME
),
913 FLAG_GENERIC(MS_NOEXEC
),
914 FLAG_GENERIC(MS_NOSUID
),
915 FLAG_GENERIC(MS_RDONLY
),
917 FLAG_GENERIC(MS_RELATIME
),
919 FLAG_GENERIC(MS_REMOUNT
),
920 FLAG_GENERIC(MS_SYNCHRONOUS
),
924 UNUSED
static struct flags umount2_flags
[] = {
926 FLAG_GENERIC(MNT_FORCE
),
929 FLAG_GENERIC(MNT_DETACH
),
932 FLAG_GENERIC(MNT_EXPIRE
),
937 UNUSED
static struct flags mmap_prot_flags
[] = {
938 FLAG_GENERIC(PROT_NONE
),
939 FLAG_GENERIC(PROT_EXEC
),
940 FLAG_GENERIC(PROT_READ
),
941 FLAG_GENERIC(PROT_WRITE
),
942 FLAG_TARGET(PROT_SEM
),
943 FLAG_GENERIC(PROT_GROWSDOWN
),
944 FLAG_GENERIC(PROT_GROWSUP
),
948 UNUSED
static struct flags mmap_flags
[] = {
949 FLAG_TARGET(MAP_SHARED
),
950 FLAG_TARGET(MAP_PRIVATE
),
951 FLAG_TARGET(MAP_ANONYMOUS
),
952 FLAG_TARGET(MAP_DENYWRITE
),
953 FLAG_TARGET(MAP_FIXED
),
954 FLAG_TARGET(MAP_GROWSDOWN
),
955 FLAG_TARGET(MAP_EXECUTABLE
),
957 FLAG_TARGET(MAP_LOCKED
),
960 FLAG_TARGET(MAP_NONBLOCK
),
962 FLAG_TARGET(MAP_NORESERVE
),
964 FLAG_TARGET(MAP_POPULATE
),
966 #ifdef TARGET_MAP_UNINITIALIZED
967 FLAG_TARGET(MAP_UNINITIALIZED
),
972 UNUSED
static struct flags clone_flags
[] = {
973 FLAG_GENERIC(CLONE_VM
),
974 FLAG_GENERIC(CLONE_FS
),
975 FLAG_GENERIC(CLONE_FILES
),
976 FLAG_GENERIC(CLONE_SIGHAND
),
977 FLAG_GENERIC(CLONE_PTRACE
),
978 FLAG_GENERIC(CLONE_VFORK
),
979 FLAG_GENERIC(CLONE_PARENT
),
980 FLAG_GENERIC(CLONE_THREAD
),
981 FLAG_GENERIC(CLONE_NEWNS
),
982 FLAG_GENERIC(CLONE_SYSVSEM
),
983 FLAG_GENERIC(CLONE_SETTLS
),
984 FLAG_GENERIC(CLONE_PARENT_SETTID
),
985 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
986 FLAG_GENERIC(CLONE_DETACHED
),
987 FLAG_GENERIC(CLONE_UNTRACED
),
988 FLAG_GENERIC(CLONE_CHILD_SETTID
),
989 #if defined(CLONE_NEWUTS)
990 FLAG_GENERIC(CLONE_NEWUTS
),
992 #if defined(CLONE_NEWIPC)
993 FLAG_GENERIC(CLONE_NEWIPC
),
995 #if defined(CLONE_NEWUSER)
996 FLAG_GENERIC(CLONE_NEWUSER
),
998 #if defined(CLONE_NEWPID)
999 FLAG_GENERIC(CLONE_NEWPID
),
1001 #if defined(CLONE_NEWNET)
1002 FLAG_GENERIC(CLONE_NEWNET
),
1004 #if defined(CLONE_IO)
1005 FLAG_GENERIC(CLONE_IO
),
1010 UNUSED
static struct flags msg_flags
[] = {
1012 FLAG_GENERIC(MSG_CONFIRM
),
1013 FLAG_GENERIC(MSG_DONTROUTE
),
1014 FLAG_GENERIC(MSG_DONTWAIT
),
1015 FLAG_GENERIC(MSG_EOR
),
1016 FLAG_GENERIC(MSG_MORE
),
1017 FLAG_GENERIC(MSG_NOSIGNAL
),
1018 FLAG_GENERIC(MSG_OOB
),
1020 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
1021 FLAG_GENERIC(MSG_ERRQUEUE
),
1022 FLAG_GENERIC(MSG_PEEK
),
1023 FLAG_GENERIC(MSG_TRUNC
),
1024 FLAG_GENERIC(MSG_WAITALL
),
1026 FLAG_GENERIC(MSG_CTRUNC
),
1030 UNUSED
static struct flags statx_flags
[] = {
1031 #ifdef AT_EMPTY_PATH
1032 FLAG_GENERIC(AT_EMPTY_PATH
),
1034 #ifdef AT_NO_AUTOMOUNT
1035 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
1037 #ifdef AT_SYMLINK_NOFOLLOW
1038 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
1040 #ifdef AT_STATX_SYNC_AS_STAT
1041 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT
),
1043 #ifdef AT_STATX_FORCE_SYNC
1044 FLAG_GENERIC(AT_STATX_FORCE_SYNC
),
1046 #ifdef AT_STATX_DONT_SYNC
1047 FLAG_GENERIC(AT_STATX_DONT_SYNC
),
1052 UNUSED
static struct flags statx_mask
[] = {
1053 /* This must come first, because it includes everything. */
1055 FLAG_GENERIC(STATX_ALL
),
1057 /* This must come second; it includes everything except STATX_BTIME. */
1058 #ifdef STATX_BASIC_STATS
1059 FLAG_GENERIC(STATX_BASIC_STATS
),
1062 FLAG_GENERIC(STATX_TYPE
),
1065 FLAG_GENERIC(STATX_MODE
),
1068 FLAG_GENERIC(STATX_NLINK
),
1071 FLAG_GENERIC(STATX_UID
),
1074 FLAG_GENERIC(STATX_GID
),
1077 FLAG_GENERIC(STATX_ATIME
),
1080 FLAG_GENERIC(STATX_MTIME
),
1083 FLAG_GENERIC(STATX_CTIME
),
1086 FLAG_GENERIC(STATX_INO
),
1089 FLAG_GENERIC(STATX_SIZE
),
1092 FLAG_GENERIC(STATX_BLOCKS
),
1095 FLAG_GENERIC(STATX_BTIME
),
1101 * print_xxx utility functions. These are used to print syscall
1102 * parameters in certain format. All of these have parameter
1103 * named 'last'. This parameter is used to add comma to output
1110 return ((last
) ? "" : ",");
1114 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1116 const char *sep
= "";
1119 if ((flags
== 0) && (f
->f_value
== 0)) {
1120 qemu_log("%s%s", f
->f_string
, get_comma(last
));
1123 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1124 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1125 qemu_log("%s%s", sep
, f
->f_string
);
1126 flags
&= ~f
->f_value
;
1133 /* print rest of the flags as numeric */
1135 qemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1137 qemu_log("%s", get_comma(last
));
1140 /* no string version of flags found, print them in hex then */
1141 qemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1146 print_at_dirfd(abi_long dirfd
, int last
)
1149 if (dirfd
== AT_FDCWD
) {
1150 qemu_log("AT_FDCWD%s", get_comma(last
));
1154 qemu_log("%d%s", (int)dirfd
, get_comma(last
));
1158 print_file_mode(abi_long mode
, int last
)
1160 const char *sep
= "";
1161 const struct flags
*m
;
1163 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1164 if ((m
->f_value
& mode
) == m
->f_value
) {
1165 qemu_log("%s%s", m
->f_string
, sep
);
1167 mode
&= ~m
->f_value
;
1173 /* print rest of the mode as octal */
1175 qemu_log("%s%#o", sep
, (unsigned int)mode
);
1177 qemu_log("%s", get_comma(last
));
1181 print_open_flags(abi_long flags
, int last
)
1183 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1184 flags
&= ~TARGET_O_ACCMODE
;
1186 qemu_log("%s", get_comma(last
));
1190 print_flags(open_flags
, flags
, last
);
1194 print_syscall_prologue(const struct syscallname
*sc
)
1196 qemu_log("%s(", sc
->name
);
1201 print_syscall_epilogue(const struct syscallname
*sc
)
1208 print_string(abi_long addr
, int last
)
1212 if ((s
= lock_user_string(addr
)) != NULL
) {
1213 qemu_log("\"%s\"%s", s
, get_comma(last
));
1214 unlock_user(s
, addr
, 0);
1216 /* can't get string out of it, so print it as pointer */
1217 print_pointer(addr
, last
);
1221 #define MAX_PRINT_BUF 40
1223 print_buf(abi_long addr
, abi_long len
, int last
)
1228 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1231 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1232 if (isprint(s
[i
])) {
1233 qemu_log("%c", s
[i
]);
1235 qemu_log("\\%o", s
[i
]);
1245 unlock_user(s
, addr
, 0);
1247 print_pointer(addr
, last
);
1252 * Prints out raw parameter using given format. Caller needs
1253 * to do byte swapping if needed.
1256 print_raw_param(const char *fmt
, abi_long param
, int last
)
1260 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1261 qemu_log(format
, param
);
1265 print_pointer(abi_long p
, int last
)
1268 qemu_log("NULL%s", get_comma(last
));
1270 qemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1274 * Reads 32-bit (int) number from guest address space from
1275 * address 'addr' and prints it.
1278 print_number(abi_long addr
, int last
)
1281 qemu_log("NULL%s", get_comma(last
));
1285 get_user_s32(num
, addr
);
1286 qemu_log("[%d]%s", num
, get_comma(last
));
1291 print_timeval(abi_ulong tv_addr
, int last
)
1294 struct target_timeval
*tv
;
1296 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1298 print_pointer(tv_addr
, last
);
1301 qemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1302 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1303 unlock_user(tv
, tv_addr
, 0);
1305 qemu_log("NULL%s", get_comma(last
));
1309 print_timezone(abi_ulong tz_addr
, int last
)
1312 struct target_timezone
*tz
;
1314 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1316 print_pointer(tz_addr
, last
);
1319 qemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1320 tswap32(tz
->tz_dsttime
), get_comma(last
));
1321 unlock_user(tz
, tz_addr
, 0);
1323 qemu_log("NULL%s", get_comma(last
));
1329 #ifdef TARGET_NR_accept
1331 print_accept(const struct syscallname
*name
,
1332 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1333 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1335 print_syscall_prologue(name
);
1336 print_raw_param("%d", arg0
, 0);
1337 print_pointer(arg1
, 0);
1338 print_number(arg2
, 1);
1339 print_syscall_epilogue(name
);
1343 #ifdef TARGET_NR_access
1345 print_access(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_string(arg0
, 0);
1351 print_flags(access_flags
, arg1
, 1);
1352 print_syscall_epilogue(name
);
1356 #ifdef TARGET_NR_brk
1358 print_brk(const struct syscallname
*name
,
1359 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1360 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1362 print_syscall_prologue(name
);
1363 print_pointer(arg0
, 1);
1364 print_syscall_epilogue(name
);
1368 #ifdef TARGET_NR_chdir
1370 print_chdir(const struct syscallname
*name
,
1371 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1372 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1374 print_syscall_prologue(name
);
1375 print_string(arg0
, 1);
1376 print_syscall_epilogue(name
);
1380 #ifdef TARGET_NR_chroot
1382 print_chroot(const struct syscallname
*name
,
1383 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1384 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1386 print_syscall_prologue(name
);
1387 print_string(arg0
, 1);
1388 print_syscall_epilogue(name
);
1392 #ifdef TARGET_NR_chmod
1394 print_chmod(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_string(arg0
, 0);
1400 print_file_mode(arg1
, 1);
1401 print_syscall_epilogue(name
);
1405 #ifdef TARGET_NR_clock_adjtime
1407 print_clock_adjtime(const struct syscallname
*name
,
1408 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1409 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1411 print_syscall_prologue(name
);
1412 print_clockid(arg0
, 0);
1413 print_pointer(arg1
, 1);
1414 print_syscall_epilogue(name
);
1418 #ifdef TARGET_NR_clone
1419 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1420 abi_ulong parent_tidptr
, target_ulong newtls
,
1421 abi_ulong child_tidptr
)
1423 print_flags(clone_flags
, flags
, 0);
1424 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1425 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1426 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1427 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1431 print_clone(const struct syscallname
*name
,
1432 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1433 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1435 print_syscall_prologue(name
);
1436 #if defined(TARGET_MICROBLAZE)
1437 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1438 #elif defined(TARGET_CLONE_BACKWARDS)
1439 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1440 #elif defined(TARGET_CLONE_BACKWARDS2)
1441 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1443 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1445 print_syscall_epilogue(name
);
1449 #ifdef TARGET_NR_creat
1451 print_creat(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_file_mode(arg1
, 1);
1458 print_syscall_epilogue(name
);
1462 #ifdef TARGET_NR_execv
1464 print_execv(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_string(arg0
, 0);
1470 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1471 print_syscall_epilogue(name
);
1475 #ifdef TARGET_NR_faccessat
1477 print_faccessat(const struct syscallname
*name
,
1478 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1479 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1481 print_syscall_prologue(name
);
1482 print_at_dirfd(arg0
, 0);
1483 print_string(arg1
, 0);
1484 print_flags(access_flags
, arg2
, 0);
1485 print_flags(at_file_flags
, arg3
, 1);
1486 print_syscall_epilogue(name
);
1490 #ifdef TARGET_NR_fchmodat
1492 print_fchmodat(const struct syscallname
*name
,
1493 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1494 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1496 print_syscall_prologue(name
);
1497 print_at_dirfd(arg0
, 0);
1498 print_string(arg1
, 0);
1499 print_file_mode(arg2
, 0);
1500 print_flags(at_file_flags
, arg3
, 1);
1501 print_syscall_epilogue(name
);
1505 #ifdef TARGET_NR_fchownat
1507 print_fchownat(const struct syscallname
*name
,
1508 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1509 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1511 print_syscall_prologue(name
);
1512 print_at_dirfd(arg0
, 0);
1513 print_string(arg1
, 0);
1514 print_raw_param("%d", arg2
, 0);
1515 print_raw_param("%d", arg3
, 0);
1516 print_flags(at_file_flags
, arg4
, 1);
1517 print_syscall_epilogue(name
);
1521 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1523 print_fcntl(const struct syscallname
*name
,
1524 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1525 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1527 print_syscall_prologue(name
);
1528 print_raw_param("%d", arg0
, 0);
1530 case TARGET_F_DUPFD
:
1531 qemu_log("F_DUPFD,");
1532 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1534 case TARGET_F_GETFD
:
1535 qemu_log("F_GETFD");
1537 case TARGET_F_SETFD
:
1538 qemu_log("F_SETFD,");
1539 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1541 case TARGET_F_GETFL
:
1542 qemu_log("F_GETFL");
1544 case TARGET_F_SETFL
:
1545 qemu_log("F_SETFL,");
1546 print_open_flags(arg2
, 1);
1548 case TARGET_F_GETLK
:
1549 qemu_log("F_GETLK,");
1550 print_pointer(arg2
, 1);
1552 case TARGET_F_SETLK
:
1553 qemu_log("F_SETLK,");
1554 print_pointer(arg2
, 1);
1556 case TARGET_F_SETLKW
:
1557 qemu_log("F_SETLKW,");
1558 print_pointer(arg2
, 1);
1560 case TARGET_F_GETOWN
:
1561 qemu_log("F_GETOWN");
1563 case TARGET_F_SETOWN
:
1564 qemu_log("F_SETOWN,");
1565 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1567 case TARGET_F_GETSIG
:
1568 qemu_log("F_GETSIG");
1570 case TARGET_F_SETSIG
:
1571 qemu_log("F_SETSIG,");
1572 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1574 #if TARGET_ABI_BITS == 32
1575 case TARGET_F_GETLK64
:
1576 qemu_log("F_GETLK64,");
1577 print_pointer(arg2
, 1);
1579 case TARGET_F_SETLK64
:
1580 qemu_log("F_SETLK64,");
1581 print_pointer(arg2
, 1);
1583 case TARGET_F_SETLKW64
:
1584 qemu_log("F_SETLKW64,");
1585 print_pointer(arg2
, 1);
1588 case TARGET_F_SETLEASE
:
1589 qemu_log("F_SETLEASE,");
1590 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1592 case TARGET_F_GETLEASE
:
1593 qemu_log("F_GETLEASE");
1595 case TARGET_F_SETPIPE_SZ
:
1596 qemu_log("F_SETPIPE_SZ,");
1597 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1599 case TARGET_F_GETPIPE_SZ
:
1600 qemu_log("F_GETPIPE_SZ");
1602 case TARGET_F_DUPFD_CLOEXEC
:
1603 qemu_log("F_DUPFD_CLOEXEC,");
1604 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1606 case TARGET_F_NOTIFY
:
1607 qemu_log("F_NOTIFY,");
1608 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1611 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1612 print_pointer(arg2
, 1);
1615 print_syscall_epilogue(name
);
1617 #define print_fcntl64 print_fcntl
1621 #ifdef TARGET_NR_futimesat
1623 print_futimesat(const struct syscallname
*name
,
1624 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1625 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1627 print_syscall_prologue(name
);
1628 print_at_dirfd(arg0
, 0);
1629 print_string(arg1
, 0);
1630 print_timeval(arg2
, 0);
1631 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1632 print_syscall_epilogue(name
);
1636 #ifdef TARGET_NR_settimeofday
1638 print_settimeofday(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_timeval(arg0
, 0);
1644 print_timezone(arg1
, 1);
1645 print_syscall_epilogue(name
);
1649 #ifdef TARGET_NR_link
1651 print_link(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_string(arg0
, 0);
1657 print_string(arg1
, 1);
1658 print_syscall_epilogue(name
);
1662 #ifdef TARGET_NR_linkat
1664 print_linkat(const struct syscallname
*name
,
1665 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1666 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1668 print_syscall_prologue(name
);
1669 print_at_dirfd(arg0
, 0);
1670 print_string(arg1
, 0);
1671 print_at_dirfd(arg2
, 0);
1672 print_string(arg3
, 0);
1673 print_flags(at_file_flags
, arg4
, 1);
1674 print_syscall_epilogue(name
);
1678 #ifdef TARGET_NR__llseek
1680 print__llseek(const struct syscallname
*name
,
1681 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1682 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1684 const char *whence
= "UNKNOWN";
1685 print_syscall_prologue(name
);
1686 print_raw_param("%d", arg0
, 0);
1687 print_raw_param("%ld", arg1
, 0);
1688 print_raw_param("%ld", arg2
, 0);
1689 print_pointer(arg3
, 0);
1691 case SEEK_SET
: whence
= "SEEK_SET"; break;
1692 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1693 case SEEK_END
: whence
= "SEEK_END"; break;
1695 qemu_log("%s", whence
);
1696 print_syscall_epilogue(name
);
1700 #if defined(TARGET_NR_socket)
1702 print_socket(const struct syscallname
*name
,
1703 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1704 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1706 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1708 print_syscall_prologue(name
);
1709 print_socket_domain(domain
);
1711 print_socket_type(type
);
1713 if (domain
== AF_PACKET
||
1714 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1715 protocol
= tswap16(protocol
);
1717 print_socket_protocol(domain
, type
, protocol
);
1718 print_syscall_epilogue(name
);
1723 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
1725 static void print_sockfd(abi_long sockfd
, int last
)
1727 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, last
);
1732 #if defined(TARGET_NR_socketcall)
1734 #define get_user_ualx(x, gaddr, idx) \
1735 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1737 static void do_print_socket(const char *name
, abi_long arg1
)
1739 abi_ulong domain
, type
, protocol
;
1741 get_user_ualx(domain
, arg1
, 0);
1742 get_user_ualx(type
, arg1
, 1);
1743 get_user_ualx(protocol
, arg1
, 2);
1744 qemu_log("%s(", name
);
1745 print_socket_domain(domain
);
1747 print_socket_type(type
);
1749 if (domain
== AF_PACKET
||
1750 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1751 protocol
= tswap16(protocol
);
1753 print_socket_protocol(domain
, type
, protocol
);
1757 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1759 abi_ulong sockfd
, addr
, addrlen
;
1761 get_user_ualx(sockfd
, arg1
, 0);
1762 get_user_ualx(addr
, arg1
, 1);
1763 get_user_ualx(addrlen
, arg1
, 2);
1765 qemu_log("%s(", name
);
1766 print_sockfd(sockfd
, 0);
1767 print_sockaddr(addr
, addrlen
, 0);
1771 static void do_print_listen(const char *name
, abi_long arg1
)
1773 abi_ulong sockfd
, backlog
;
1775 get_user_ualx(sockfd
, arg1
, 0);
1776 get_user_ualx(backlog
, arg1
, 1);
1778 qemu_log("%s(", name
);
1779 print_sockfd(sockfd
, 0);
1780 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1784 static void do_print_socketpair(const char *name
, abi_long arg1
)
1786 abi_ulong domain
, type
, protocol
, tab
;
1788 get_user_ualx(domain
, arg1
, 0);
1789 get_user_ualx(type
, arg1
, 1);
1790 get_user_ualx(protocol
, arg1
, 2);
1791 get_user_ualx(tab
, arg1
, 3);
1793 qemu_log("%s(", name
);
1794 print_socket_domain(domain
);
1796 print_socket_type(type
);
1798 print_socket_protocol(domain
, type
, protocol
);
1800 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1804 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1806 abi_ulong sockfd
, msg
, len
, flags
;
1808 get_user_ualx(sockfd
, arg1
, 0);
1809 get_user_ualx(msg
, arg1
, 1);
1810 get_user_ualx(len
, arg1
, 2);
1811 get_user_ualx(flags
, arg1
, 3);
1813 qemu_log("%s(", name
);
1814 print_sockfd(sockfd
, 0);
1815 print_buf(msg
, len
, 0);
1816 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1817 print_flags(msg_flags
, flags
, 1);
1821 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1823 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1825 get_user_ualx(sockfd
, arg1
, 0);
1826 get_user_ualx(msg
, arg1
, 1);
1827 get_user_ualx(len
, arg1
, 2);
1828 get_user_ualx(flags
, arg1
, 3);
1829 get_user_ualx(addr
, arg1
, 4);
1830 get_user_ualx(addrlen
, arg1
, 5);
1832 qemu_log("%s(", name
);
1833 print_sockfd(sockfd
, 0);
1834 print_buf(msg
, len
, 0);
1835 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1836 print_flags(msg_flags
, flags
, 0);
1837 print_sockaddr(addr
, addrlen
, 0);
1841 static void do_print_shutdown(const char *name
, abi_long arg1
)
1843 abi_ulong sockfd
, how
;
1845 get_user_ualx(sockfd
, arg1
, 0);
1846 get_user_ualx(how
, arg1
, 1);
1848 qemu_log("shutdown(");
1849 print_sockfd(sockfd
, 0);
1852 qemu_log("SHUT_RD");
1855 qemu_log("SHUT_WR");
1858 qemu_log("SHUT_RDWR");
1861 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1867 static void do_print_msg(const char *name
, abi_long arg1
)
1869 abi_ulong sockfd
, msg
, flags
;
1871 get_user_ualx(sockfd
, arg1
, 0);
1872 get_user_ualx(msg
, arg1
, 1);
1873 get_user_ualx(flags
, arg1
, 2);
1875 qemu_log("%s(", name
);
1876 print_sockfd(sockfd
, 0);
1877 print_pointer(msg
, 0);
1878 print_flags(msg_flags
, flags
, 1);
1882 static void do_print_sockopt(const char *name
, abi_long arg1
)
1884 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1886 get_user_ualx(sockfd
, arg1
, 0);
1887 get_user_ualx(level
, arg1
, 1);
1888 get_user_ualx(optname
, arg1
, 2);
1889 get_user_ualx(optval
, arg1
, 3);
1890 get_user_ualx(optlen
, arg1
, 4);
1892 qemu_log("%s(", name
);
1893 print_sockfd(sockfd
, 0);
1896 qemu_log("SOL_TCP,");
1897 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1898 print_pointer(optval
, 0);
1901 qemu_log("SOL_IP,");
1902 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1903 print_pointer(optval
, 0);
1906 qemu_log("SOL_RAW,");
1907 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1908 print_pointer(optval
, 0);
1910 case TARGET_SOL_SOCKET
:
1911 qemu_log("SOL_SOCKET,");
1913 case TARGET_SO_DEBUG
:
1914 qemu_log("SO_DEBUG,");
1916 print_number(optval
, 0);
1918 case TARGET_SO_REUSEADDR
:
1919 qemu_log("SO_REUSEADDR,");
1921 case TARGET_SO_REUSEPORT
:
1922 qemu_log("SO_REUSEPORT,");
1924 case TARGET_SO_TYPE
:
1925 qemu_log("SO_TYPE,");
1927 case TARGET_SO_ERROR
:
1928 qemu_log("SO_ERROR,");
1930 case TARGET_SO_DONTROUTE
:
1931 qemu_log("SO_DONTROUTE,");
1933 case TARGET_SO_BROADCAST
:
1934 qemu_log("SO_BROADCAST,");
1936 case TARGET_SO_SNDBUF
:
1937 qemu_log("SO_SNDBUF,");
1939 case TARGET_SO_RCVBUF
:
1940 qemu_log("SO_RCVBUF,");
1942 case TARGET_SO_KEEPALIVE
:
1943 qemu_log("SO_KEEPALIVE,");
1945 case TARGET_SO_OOBINLINE
:
1946 qemu_log("SO_OOBINLINE,");
1948 case TARGET_SO_NO_CHECK
:
1949 qemu_log("SO_NO_CHECK,");
1951 case TARGET_SO_PRIORITY
:
1952 qemu_log("SO_PRIORITY,");
1954 case TARGET_SO_BSDCOMPAT
:
1955 qemu_log("SO_BSDCOMPAT,");
1957 case TARGET_SO_PASSCRED
:
1958 qemu_log("SO_PASSCRED,");
1960 case TARGET_SO_TIMESTAMP
:
1961 qemu_log("SO_TIMESTAMP,");
1963 case TARGET_SO_RCVLOWAT
:
1964 qemu_log("SO_RCVLOWAT,");
1966 case TARGET_SO_RCVTIMEO
:
1967 qemu_log("SO_RCVTIMEO,");
1968 print_timeval(optval
, 0);
1970 case TARGET_SO_SNDTIMEO
:
1971 qemu_log("SO_SNDTIMEO,");
1972 print_timeval(optval
, 0);
1974 case TARGET_SO_ATTACH_FILTER
: {
1975 struct target_sock_fprog
*fprog
;
1977 qemu_log("SO_ATTACH_FILTER,");
1979 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1980 struct target_sock_filter
*filter
;
1982 if (lock_user_struct(VERIFY_READ
, filter
,
1983 tswapal(fprog
->filter
), 0)) {
1985 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1986 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
1987 i
, tswap16(filter
[i
].code
),
1988 filter
[i
].jt
, filter
[i
].jf
,
1989 tswap32(filter
[i
].k
));
1991 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
1992 i
, tswap16(filter
[i
].code
),
1993 filter
[i
].jt
, filter
[i
].jf
,
1994 tswap32(filter
[i
].k
));
1996 qemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1998 qemu_log(",%d},", tswap16(fprog
->len
));
1999 unlock_user(fprog
, optval
, 0);
2001 print_pointer(optval
, 0);
2006 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2007 print_pointer(optval
, 0);
2012 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
2013 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
2014 print_pointer(optval
, 0);
2017 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
2021 #define PRINT_SOCKOP(name, func) \
2022 [TARGET_SYS_##name] = { #name, func }
2026 void (*print
)(const char *, abi_long
);
2028 PRINT_SOCKOP(SOCKET
, do_print_socket
),
2029 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
2030 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
2031 PRINT_SOCKOP(LISTEN
, do_print_listen
),
2032 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
2033 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
2034 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
2035 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
2036 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
2037 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
2038 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
2039 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
2040 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
2041 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
2042 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
2043 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
2044 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
2045 PRINT_SOCKOP(ACCEPT4
, NULL
),
2046 PRINT_SOCKOP(RECVMMSG
, NULL
),
2047 PRINT_SOCKOP(SENDMMSG
, NULL
),
2051 print_socketcall(const struct syscallname
*name
,
2052 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2053 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2055 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
2056 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
2059 print_syscall_prologue(name
);
2060 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
2061 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
2062 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
2063 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
2064 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
2065 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
2066 print_syscall_epilogue(name
);
2070 #if defined(TARGET_NR_bind)
2072 print_bind(const struct syscallname
*name
,
2073 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2074 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2076 print_syscall_prologue(name
);
2077 print_sockfd(arg0
, 0);
2078 print_sockaddr(arg1
, arg2
, 1);
2079 print_syscall_epilogue(name
);
2083 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2084 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2086 print_stat(const struct syscallname
*name
,
2087 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2088 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2090 print_syscall_prologue(name
);
2091 print_string(arg0
, 0);
2092 print_pointer(arg1
, 1);
2093 print_syscall_epilogue(name
);
2095 #define print_lstat print_stat
2096 #define print_stat64 print_stat
2097 #define print_lstat64 print_stat
2100 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2102 print_fstat(const struct syscallname
*name
,
2103 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2104 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2106 print_syscall_prologue(name
);
2107 print_raw_param("%d", arg0
, 0);
2108 print_pointer(arg1
, 1);
2109 print_syscall_epilogue(name
);
2111 #define print_fstat64 print_fstat
2114 #ifdef TARGET_NR_mkdir
2116 print_mkdir(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_string(arg0
, 0);
2122 print_file_mode(arg1
, 1);
2123 print_syscall_epilogue(name
);
2127 #ifdef TARGET_NR_mkdirat
2129 print_mkdirat(const struct syscallname
*name
,
2130 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2131 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2133 print_syscall_prologue(name
);
2134 print_at_dirfd(arg0
, 0);
2135 print_string(arg1
, 0);
2136 print_file_mode(arg2
, 1);
2137 print_syscall_epilogue(name
);
2141 #ifdef TARGET_NR_rmdir
2143 print_rmdir(const struct syscallname
*name
,
2144 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2145 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2147 print_syscall_prologue(name
);
2148 print_string(arg0
, 0);
2149 print_syscall_epilogue(name
);
2153 #ifdef TARGET_NR_rt_sigaction
2155 print_rt_sigaction(const struct syscallname
*name
,
2156 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2157 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2159 print_syscall_prologue(name
);
2160 print_signal(arg0
, 0);
2161 print_pointer(arg1
, 0);
2162 print_pointer(arg2
, 1);
2163 print_syscall_epilogue(name
);
2167 #ifdef TARGET_NR_rt_sigprocmask
2169 print_rt_sigprocmask(const struct syscallname
*name
,
2170 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2171 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2173 const char *how
= "UNKNOWN";
2174 print_syscall_prologue(name
);
2176 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2177 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2178 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2180 qemu_log("%s,", how
);
2181 print_pointer(arg1
, 0);
2182 print_pointer(arg2
, 1);
2183 print_syscall_epilogue(name
);
2187 #ifdef TARGET_NR_rt_sigqueueinfo
2189 print_rt_sigqueueinfo(const struct syscallname
*name
,
2190 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2191 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2194 target_siginfo_t uinfo
;
2196 print_syscall_prologue(name
);
2197 print_raw_param("%d", arg0
, 0);
2198 print_signal(arg1
, 0);
2199 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2201 get_target_siginfo(&uinfo
, p
);
2202 print_siginfo(&uinfo
);
2204 unlock_user(p
, arg2
, 0);
2206 print_pointer(arg2
, 1);
2208 print_syscall_epilogue(name
);
2212 #ifdef TARGET_NR_rt_tgsigqueueinfo
2214 print_rt_tgsigqueueinfo(const struct syscallname
*name
,
2215 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2216 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2219 target_siginfo_t uinfo
;
2221 print_syscall_prologue(name
);
2222 print_raw_param("%d", arg0
, 0);
2223 print_raw_param("%d", arg1
, 0);
2224 print_signal(arg2
, 0);
2225 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2227 get_target_siginfo(&uinfo
, p
);
2228 print_siginfo(&uinfo
);
2230 unlock_user(p
, arg3
, 0);
2232 print_pointer(arg3
, 1);
2234 print_syscall_epilogue(name
);
2238 #ifdef TARGET_NR_syslog
2240 print_syslog_action(abi_ulong arg
, int last
)
2245 case TARGET_SYSLOG_ACTION_CLOSE
: {
2246 type
= "SYSLOG_ACTION_CLOSE";
2249 case TARGET_SYSLOG_ACTION_OPEN
: {
2250 type
= "SYSLOG_ACTION_OPEN";
2253 case TARGET_SYSLOG_ACTION_READ
: {
2254 type
= "SYSLOG_ACTION_READ";
2257 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2258 type
= "SYSLOG_ACTION_READ_ALL";
2261 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2262 type
= "SYSLOG_ACTION_READ_CLEAR";
2265 case TARGET_SYSLOG_ACTION_CLEAR
: {
2266 type
= "SYSLOG_ACTION_CLEAR";
2269 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2270 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2273 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
2274 type
= "SYSLOG_ACTION_CONSOLE_ON";
2277 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
2278 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
2281 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
2282 type
= "SYSLOG_ACTION_SIZE_UNREAD";
2285 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
2286 type
= "SYSLOG_ACTION_SIZE_BUFFER";
2290 print_raw_param("%ld", arg
, last
);
2294 qemu_log("%s%s", type
, get_comma(last
));
2298 print_syslog(const struct syscallname
*name
,
2299 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2300 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2302 print_syscall_prologue(name
);
2303 print_syslog_action(arg0
, 0);
2304 print_pointer(arg1
, 0);
2305 print_raw_param("%d", arg2
, 1);
2306 print_syscall_epilogue(name
);
2310 #ifdef TARGET_NR_mknod
2312 print_mknod(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 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
2318 print_syscall_prologue(name
);
2319 print_string(arg0
, 0);
2320 print_file_mode(arg1
, (hasdev
== 0));
2322 print_raw_param("makedev(%d", major(arg2
), 0);
2323 print_raw_param("%d)", minor(arg2
), 1);
2325 print_syscall_epilogue(name
);
2329 #ifdef TARGET_NR_mknodat
2331 print_mknodat(const struct syscallname
*name
,
2332 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2333 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2335 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2337 print_syscall_prologue(name
);
2338 print_at_dirfd(arg0
, 0);
2339 print_string(arg1
, 0);
2340 print_file_mode(arg2
, (hasdev
== 0));
2342 print_raw_param("makedev(%d", major(arg3
), 0);
2343 print_raw_param("%d)", minor(arg3
), 1);
2345 print_syscall_epilogue(name
);
2349 #ifdef TARGET_NR_mq_open
2351 print_mq_open(const struct syscallname
*name
,
2352 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2353 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2355 int is_creat
= (arg1
& TARGET_O_CREAT
);
2357 print_syscall_prologue(name
);
2358 print_string(arg0
, 0);
2359 print_open_flags(arg1
, (is_creat
== 0));
2361 print_file_mode(arg2
, 0);
2362 print_pointer(arg3
, 1);
2364 print_syscall_epilogue(name
);
2368 #ifdef TARGET_NR_open
2370 print_open(const struct syscallname
*name
,
2371 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2372 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2374 int is_creat
= (arg1
& TARGET_O_CREAT
);
2376 print_syscall_prologue(name
);
2377 print_string(arg0
, 0);
2378 print_open_flags(arg1
, (is_creat
== 0));
2380 print_file_mode(arg2
, 1);
2381 print_syscall_epilogue(name
);
2385 #ifdef TARGET_NR_openat
2387 print_openat(const struct syscallname
*name
,
2388 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2389 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2391 int is_creat
= (arg2
& TARGET_O_CREAT
);
2393 print_syscall_prologue(name
);
2394 print_at_dirfd(arg0
, 0);
2395 print_string(arg1
, 0);
2396 print_open_flags(arg2
, (is_creat
== 0));
2398 print_file_mode(arg3
, 1);
2399 print_syscall_epilogue(name
);
2403 #ifdef TARGET_NR_mq_unlink
2405 print_mq_unlink(const struct syscallname
*name
,
2406 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2407 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2409 print_syscall_prologue(name
);
2410 print_string(arg0
, 1);
2411 print_syscall_epilogue(name
);
2415 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2417 print_fstatat64(const struct syscallname
*name
,
2418 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2419 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2421 print_syscall_prologue(name
);
2422 print_at_dirfd(arg0
, 0);
2423 print_string(arg1
, 0);
2424 print_pointer(arg2
, 0);
2425 print_flags(at_file_flags
, arg3
, 1);
2426 print_syscall_epilogue(name
);
2428 #define print_newfstatat print_fstatat64
2431 #ifdef TARGET_NR_readlink
2433 print_readlink(const struct syscallname
*name
,
2434 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2435 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2437 print_syscall_prologue(name
);
2438 print_string(arg0
, 0);
2439 print_pointer(arg1
, 0);
2440 print_raw_param("%u", arg2
, 1);
2441 print_syscall_epilogue(name
);
2445 #ifdef TARGET_NR_readlinkat
2447 print_readlinkat(const struct syscallname
*name
,
2448 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2449 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2451 print_syscall_prologue(name
);
2452 print_at_dirfd(arg0
, 0);
2453 print_string(arg1
, 0);
2454 print_pointer(arg2
, 0);
2455 print_raw_param("%u", arg3
, 1);
2456 print_syscall_epilogue(name
);
2460 #ifdef TARGET_NR_rename
2462 print_rename(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_string(arg0
, 0);
2468 print_string(arg1
, 1);
2469 print_syscall_epilogue(name
);
2473 #ifdef TARGET_NR_renameat
2475 print_renameat(const struct syscallname
*name
,
2476 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2477 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2479 print_syscall_prologue(name
);
2480 print_at_dirfd(arg0
, 0);
2481 print_string(arg1
, 0);
2482 print_at_dirfd(arg2
, 0);
2483 print_string(arg3
, 1);
2484 print_syscall_epilogue(name
);
2488 #ifdef TARGET_NR_statfs
2490 print_statfs(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_statfs64
2503 print_statfs64(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_pointer(arg1
, 1);
2510 print_syscall_epilogue(name
);
2514 #ifdef TARGET_NR_symlink
2516 print_symlink(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_string(arg1
, 1);
2523 print_syscall_epilogue(name
);
2527 #ifdef TARGET_NR_symlinkat
2529 print_symlinkat(const struct syscallname
*name
,
2530 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2531 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2533 print_syscall_prologue(name
);
2534 print_string(arg0
, 0);
2535 print_at_dirfd(arg1
, 0);
2536 print_string(arg2
, 1);
2537 print_syscall_epilogue(name
);
2541 #ifdef TARGET_NR_mount
2543 print_mount(const struct syscallname
*name
,
2544 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2545 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2547 print_syscall_prologue(name
);
2548 print_string(arg0
, 0);
2549 print_string(arg1
, 0);
2550 print_string(arg2
, 0);
2551 print_flags(mount_flags
, arg3
, 0);
2552 print_pointer(arg4
, 1);
2553 print_syscall_epilogue(name
);
2557 #ifdef TARGET_NR_umount
2559 print_umount(const struct syscallname
*name
,
2560 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2561 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2563 print_syscall_prologue(name
);
2564 print_string(arg0
, 1);
2565 print_syscall_epilogue(name
);
2569 #ifdef TARGET_NR_umount2
2571 print_umount2(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
, 0);
2577 print_flags(umount2_flags
, arg1
, 1);
2578 print_syscall_epilogue(name
);
2582 #ifdef TARGET_NR_unlink
2584 print_unlink(const struct syscallname
*name
,
2585 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2586 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2588 print_syscall_prologue(name
);
2589 print_string(arg0
, 1);
2590 print_syscall_epilogue(name
);
2594 #ifdef TARGET_NR_unlinkat
2596 print_unlinkat(const struct syscallname
*name
,
2597 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2598 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2600 print_syscall_prologue(name
);
2601 print_at_dirfd(arg0
, 0);
2602 print_string(arg1
, 0);
2603 print_flags(unlinkat_flags
, arg2
, 1);
2604 print_syscall_epilogue(name
);
2608 #ifdef TARGET_NR_utime
2610 print_utime(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_utimes
2623 print_utimes(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_string(arg0
, 0);
2629 print_pointer(arg1
, 1);
2630 print_syscall_epilogue(name
);
2634 #ifdef TARGET_NR_utimensat
2636 print_utimensat(const struct syscallname
*name
,
2637 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2638 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2640 print_syscall_prologue(name
);
2641 print_at_dirfd(arg0
, 0);
2642 print_string(arg1
, 0);
2643 print_pointer(arg2
, 0);
2644 print_flags(at_file_flags
, arg3
, 1);
2645 print_syscall_epilogue(name
);
2649 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2651 print_mmap(const struct syscallname
*name
,
2652 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2653 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2655 print_syscall_prologue(name
);
2656 print_pointer(arg0
, 0);
2657 print_raw_param("%d", arg1
, 0);
2658 print_flags(mmap_prot_flags
, arg2
, 0);
2659 print_flags(mmap_flags
, arg3
, 0);
2660 print_raw_param("%d", arg4
, 0);
2661 print_raw_param("%#x", arg5
, 1);
2662 print_syscall_epilogue(name
);
2664 #define print_mmap2 print_mmap
2667 #ifdef TARGET_NR_mprotect
2669 print_mprotect(const struct syscallname
*name
,
2670 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2671 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2673 print_syscall_prologue(name
);
2674 print_pointer(arg0
, 0);
2675 print_raw_param("%d", arg1
, 0);
2676 print_flags(mmap_prot_flags
, arg2
, 1);
2677 print_syscall_epilogue(name
);
2681 #ifdef TARGET_NR_munmap
2683 print_munmap(const struct syscallname
*name
,
2684 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2685 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2687 print_syscall_prologue(name
);
2688 print_pointer(arg0
, 0);
2689 print_raw_param("%d", arg1
, 1);
2690 print_syscall_epilogue(name
);
2694 #ifdef TARGET_NR_futex
2695 static void print_futex_op(abi_long tflag
, int last
)
2697 #define print_op(val) \
2698 if( cmd == val ) { \
2703 int cmd
= (int)tflag
;
2704 #ifdef FUTEX_PRIVATE_FLAG
2705 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2706 qemu_log("FUTEX_PRIVATE_FLAG|");
2707 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2710 #ifdef FUTEX_CLOCK_REALTIME
2711 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2712 qemu_log("FUTEX_CLOCK_REALTIME|");
2713 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2716 print_op(FUTEX_WAIT
)
2717 print_op(FUTEX_WAKE
)
2719 print_op(FUTEX_REQUEUE
)
2720 print_op(FUTEX_CMP_REQUEUE
)
2721 print_op(FUTEX_WAKE_OP
)
2722 print_op(FUTEX_LOCK_PI
)
2723 print_op(FUTEX_UNLOCK_PI
)
2724 print_op(FUTEX_TRYLOCK_PI
)
2725 #ifdef FUTEX_WAIT_BITSET
2726 print_op(FUTEX_WAIT_BITSET
)
2728 #ifdef FUTEX_WAKE_BITSET
2729 print_op(FUTEX_WAKE_BITSET
)
2731 /* unknown values */
2732 qemu_log("%d", cmd
);
2736 print_futex(const struct syscallname
*name
,
2737 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2738 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2740 print_syscall_prologue(name
);
2741 print_pointer(arg0
, 0);
2742 print_futex_op(arg1
, 0);
2743 print_raw_param(",%d", arg2
, 0);
2744 print_pointer(arg3
, 0); /* struct timespec */
2745 print_pointer(arg4
, 0);
2746 print_raw_param("%d", arg4
, 1);
2747 print_syscall_epilogue(name
);
2751 #ifdef TARGET_NR_kill
2753 print_kill(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_tkill
2766 print_tkill(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_signal(arg1
, 1);
2773 print_syscall_epilogue(name
);
2777 #ifdef TARGET_NR_tgkill
2779 print_tgkill(const struct syscallname
*name
,
2780 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2781 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2783 print_syscall_prologue(name
);
2784 print_raw_param("%d", arg0
, 0);
2785 print_raw_param("%d", arg1
, 0);
2786 print_signal(arg2
, 1);
2787 print_syscall_epilogue(name
);
2791 #ifdef TARGET_NR_statx
2793 print_statx(const struct syscallname
*name
,
2794 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2795 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2797 print_syscall_prologue(name
);
2798 print_at_dirfd(arg0
, 0);
2799 print_string(arg1
, 0);
2800 print_flags(statx_flags
, arg2
, 0);
2801 print_flags(statx_mask
, arg3
, 0);
2802 print_pointer(arg4
, 1);
2803 print_syscall_epilogue(name
);
2808 * An array of all of the syscalls we know about
2811 static const struct syscallname scnames
[] = {
2812 #include "strace.list"
2815 static int nsyscalls
= ARRAY_SIZE(scnames
);
2818 * The public interface to this module.
2821 print_syscall(int num
,
2822 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2823 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2826 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
")";
2828 qemu_log("%d ", getpid());
2830 for(i
=0;i
<nsyscalls
;i
++)
2831 if( scnames
[i
].nr
== num
) {
2832 if( scnames
[i
].call
!= NULL
) {
2834 &scnames
[i
], arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
2836 /* XXX: this format system is broken because it uses
2837 host types and host pointers for strings */
2838 if( scnames
[i
].format
!= NULL
)
2839 format
= scnames
[i
].format
;
2841 scnames
[i
].name
, arg1
, arg2
, arg3
, arg4
, arg5
, arg6
);
2845 qemu_log("Unknown syscall %d\n", num
);
2850 print_syscall_ret(int num
, abi_long ret
)
2853 const char *errstr
= NULL
;
2855 for(i
=0;i
<nsyscalls
;i
++)
2856 if( scnames
[i
].nr
== num
) {
2857 if( scnames
[i
].result
!= NULL
) {
2858 scnames
[i
].result(&scnames
[i
], ret
);
2861 errstr
= target_strerror(-ret
);
2864 qemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2867 qemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2874 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2876 /* Print the strace output for a signal being taken:
2877 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2880 print_signal(target_signum
, 1);
2882 print_siginfo(tinfo
);