1 #include "qemu/osdep.h"
6 #include <sys/select.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.h>
20 void (*call
)(const struct syscallname
*,
21 abi_long
, abi_long
, abi_long
,
22 abi_long
, abi_long
, abi_long
);
23 void (*result
)(const struct syscallname
*, abi_long
);
28 * It is possible that target doesn't have syscall that uses
29 * following flags but we don't want the compiler to warn
30 * us about them being unused. Same applies to utility print
31 * functions. It is ok to keep them while not used.
33 #define UNUSED __attribute__ ((unused))
39 * Structure used to translate flag values into strings. This is
40 * similar that is in the actual strace tool.
43 abi_long f_value
; /* flag */
44 const char *f_string
; /* stringified flag */
47 /* common flags for all architectures */
48 #define FLAG_GENERIC(name) { name, #name }
49 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
50 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
51 /* end of flags array */
52 #define FLAG_END { 0, NULL }
54 UNUSED
static const char *get_comma(int);
55 UNUSED
static void print_pointer(abi_long
, int);
56 UNUSED
static void print_flags(const struct flags
*, abi_long
, int);
57 UNUSED
static void print_at_dirfd(abi_long
, int);
58 UNUSED
static void print_file_mode(abi_long
, int);
59 UNUSED
static void print_open_flags(abi_long
, int);
60 UNUSED
static void print_syscall_prologue(const struct syscallname
*);
61 UNUSED
static void print_syscall_epilogue(const struct syscallname
*);
62 UNUSED
static void print_string(abi_long
, int);
63 UNUSED
static void print_buf(abi_long addr
, abi_long len
, int last
);
64 UNUSED
static void print_raw_param(const char *, abi_long
, int);
65 UNUSED
static void print_timeval(abi_ulong
, int);
66 UNUSED
static void print_timezone(abi_ulong
, int);
67 UNUSED
static void print_number(abi_long
, int);
68 UNUSED
static void print_signal(abi_ulong
, int);
69 UNUSED
static void print_sockaddr(abi_ulong addr
, abi_long addrlen
);
70 UNUSED
static void print_socket_domain(int domain
);
71 UNUSED
static void print_socket_type(int type
);
72 UNUSED
static void print_socket_protocol(int domain
, int type
, int protocol
);
78 print_ipc_cmd(int cmd
)
80 #define output_cmd(val) \
88 /* General IPC commands */
89 output_cmd( IPC_RMID
);
90 output_cmd( IPC_SET
);
91 output_cmd( IPC_STAT
);
92 output_cmd( IPC_INFO
);
93 /* msgctl() commands */
94 output_cmd( MSG_STAT
);
95 output_cmd( MSG_INFO
);
96 /* shmctl() commands */
97 output_cmd( SHM_LOCK
);
98 output_cmd( SHM_UNLOCK
);
99 output_cmd( SHM_STAT
);
100 output_cmd( SHM_INFO
);
101 /* semctl() commands */
102 output_cmd( GETPID
);
103 output_cmd( GETVAL
);
104 output_cmd( GETALL
);
105 output_cmd( GETNCNT
);
106 output_cmd( GETZCNT
);
107 output_cmd( SETVAL
);
108 output_cmd( SETALL
);
109 output_cmd( SEM_STAT
);
110 output_cmd( SEM_INFO
);
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
);
119 output_cmd( IPC_RMID
);
121 /* Some value we don't recognize */
126 print_signal(abi_ulong arg
, int last
)
128 const char *signal_name
= NULL
;
130 case TARGET_SIGHUP
: signal_name
= "SIGHUP"; break;
131 case TARGET_SIGINT
: signal_name
= "SIGINT"; break;
132 case TARGET_SIGQUIT
: signal_name
= "SIGQUIT"; break;
133 case TARGET_SIGILL
: signal_name
= "SIGILL"; break;
134 case TARGET_SIGABRT
: signal_name
= "SIGABRT"; break;
135 case TARGET_SIGFPE
: signal_name
= "SIGFPE"; break;
136 case TARGET_SIGKILL
: signal_name
= "SIGKILL"; break;
137 case TARGET_SIGSEGV
: signal_name
= "SIGSEGV"; break;
138 case TARGET_SIGPIPE
: signal_name
= "SIGPIPE"; break;
139 case TARGET_SIGALRM
: signal_name
= "SIGALRM"; break;
140 case TARGET_SIGTERM
: signal_name
= "SIGTERM"; break;
141 case TARGET_SIGUSR1
: signal_name
= "SIGUSR1"; break;
142 case TARGET_SIGUSR2
: signal_name
= "SIGUSR2"; break;
143 case TARGET_SIGCHLD
: signal_name
= "SIGCHLD"; break;
144 case TARGET_SIGCONT
: signal_name
= "SIGCONT"; break;
145 case TARGET_SIGSTOP
: signal_name
= "SIGSTOP"; break;
146 case TARGET_SIGTTIN
: signal_name
= "SIGTTIN"; break;
147 case TARGET_SIGTTOU
: signal_name
= "SIGTTOU"; break;
149 if (signal_name
== NULL
) {
150 print_raw_param("%ld", arg
, last
);
153 gemu_log("%s%s", signal_name
, get_comma(last
));
156 static void print_si_code(int arg
)
158 const char *codename
= NULL
;
162 codename
= "SI_USER";
165 codename
= "SI_KERNEL";
168 codename
= "SI_QUEUE";
171 codename
= "SI_TIMER";
174 codename
= "SI_MESGQ";
177 codename
= "SI_ASYNCIO";
180 codename
= "SI_SIGIO";
183 codename
= "SI_TKILL";
189 gemu_log("%s", codename
);
192 static void get_target_siginfo(target_siginfo_t
*tinfo
,
193 const target_siginfo_t
*info
)
202 __get_user(sig
, &info
->si_signo
);
203 __get_user(si_errno
, &tinfo
->si_errno
);
204 __get_user(si_code
, &info
->si_code
);
206 tinfo
->si_signo
= sig
;
207 tinfo
->si_errno
= si_errno
;
208 tinfo
->si_code
= si_code
;
210 /* Ensure we don't leak random junk to the guest later */
211 memset(tinfo
->_sifields
._pad
, 0, sizeof(tinfo
->_sifields
._pad
));
213 /* This is awkward, because we have to use a combination of
214 * the si_code and si_signo to figure out which of the union's
215 * members are valid. (Within the host kernel it is always possible
216 * to tell, but the kernel carefully avoids giving userspace the
217 * high 16 bits of si_code, so we don't have the information to
218 * do this the easy way...) We therefore make our best guess,
219 * bearing in mind that a guest can spoof most of the si_codes
220 * via rt_sigqueueinfo() if it likes.
222 * Once we have made our guess, we record it in the top 16 bits of
223 * the si_code, so that print_siginfo() later can use it.
224 * print_siginfo() will strip these top bits out before printing
232 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
233 * These are the only unspoofable si_code values.
235 __get_user(tinfo
->_sifields
._kill
._pid
, &info
->_sifields
._kill
._pid
);
236 __get_user(tinfo
->_sifields
._kill
._uid
, &info
->_sifields
._kill
._uid
);
237 si_type
= QEMU_SI_KILL
;
240 /* Everything else is spoofable. Make best guess based on signal */
243 __get_user(tinfo
->_sifields
._sigchld
._pid
,
244 &info
->_sifields
._sigchld
._pid
);
245 __get_user(tinfo
->_sifields
._sigchld
._uid
,
246 &info
->_sifields
._sigchld
._uid
);
247 __get_user(tinfo
->_sifields
._sigchld
._status
,
248 &info
->_sifields
._sigchld
._status
);
249 __get_user(tinfo
->_sifields
._sigchld
._utime
,
250 &info
->_sifields
._sigchld
._utime
);
251 __get_user(tinfo
->_sifields
._sigchld
._stime
,
252 &info
->_sifields
._sigchld
._stime
);
253 si_type
= QEMU_SI_CHLD
;
256 __get_user(tinfo
->_sifields
._sigpoll
._band
,
257 &info
->_sifields
._sigpoll
._band
);
258 __get_user(tinfo
->_sifields
._sigpoll
._fd
,
259 &info
->_sifields
._sigpoll
._fd
);
260 si_type
= QEMU_SI_POLL
;
263 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
264 __get_user(tinfo
->_sifields
._rt
._pid
, &info
->_sifields
._rt
._pid
);
265 __get_user(tinfo
->_sifields
._rt
._uid
, &info
->_sifields
._rt
._uid
);
266 /* XXX: potential problem if 64 bit */
267 __get_user(sival_ptr
, &info
->_sifields
._rt
._sigval
.sival_ptr
);
268 tinfo
->_sifields
._rt
._sigval
.sival_ptr
= sival_ptr
;
270 si_type
= QEMU_SI_RT
;
276 tinfo
->si_code
= deposit32(si_code
, 16, 16, si_type
);
279 static void print_siginfo(const target_siginfo_t
*tinfo
)
281 /* Print a target_siginfo_t in the format desired for printing
282 * signals being taken. We assume the target_siginfo_t is in the
283 * internal form where the top 16 bits of si_code indicate which
284 * part of the union is valid, rather than in the guest-visible
285 * form where the bottom 16 bits are sign-extended into the top 16.
287 int si_type
= extract32(tinfo
->si_code
, 16, 16);
288 int si_code
= sextract32(tinfo
->si_code
, 0, 16);
290 gemu_log("{si_signo=");
291 print_signal(tinfo
->si_signo
, 1);
292 gemu_log(", si_code=");
293 print_si_code(si_code
);
297 gemu_log(", si_pid=%u, si_uid=%u",
298 (unsigned int)tinfo
->_sifields
._kill
._pid
,
299 (unsigned int)tinfo
->_sifields
._kill
._uid
);
302 gemu_log(", si_timer1=%u, si_timer2=%u",
303 tinfo
->_sifields
._timer
._timer1
,
304 tinfo
->_sifields
._timer
._timer2
);
307 gemu_log(", si_band=%d, si_fd=%d",
308 tinfo
->_sifields
._sigpoll
._band
,
309 tinfo
->_sifields
._sigpoll
._fd
);
312 gemu_log(", si_addr=");
313 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
316 gemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
317 ", si_utime=" TARGET_ABI_FMT_ld
318 ", si_stime=" TARGET_ABI_FMT_ld
,
319 (unsigned int)(tinfo
->_sifields
._sigchld
._pid
),
320 (unsigned int)(tinfo
->_sifields
._sigchld
._uid
),
321 tinfo
->_sifields
._sigchld
._status
,
322 tinfo
->_sifields
._sigchld
._utime
,
323 tinfo
->_sifields
._sigchld
._stime
);
326 gemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld
,
327 (unsigned int)tinfo
->_sifields
._rt
._pid
,
328 (unsigned int)tinfo
->_sifields
._rt
._uid
,
329 tinfo
->_sifields
._rt
._sigval
.sival_ptr
);
332 g_assert_not_reached();
338 print_sockaddr(abi_ulong addr
, abi_long addrlen
)
340 struct target_sockaddr
*sa
;
344 sa
= lock_user(VERIFY_READ
, addr
, addrlen
, 1);
346 sa_family
= tswap16(sa
->sa_family
);
349 struct target_sockaddr_un
*un
= (struct target_sockaddr_un
*)sa
;
351 gemu_log("{sun_family=AF_UNIX,sun_path=\"");
352 for (i
= 0; i
< addrlen
-
353 offsetof(struct target_sockaddr_un
, sun_path
) &&
354 un
->sun_path
[i
]; i
++) {
355 gemu_log("%c", un
->sun_path
[i
]);
361 struct target_sockaddr_in
*in
= (struct target_sockaddr_in
*)sa
;
362 uint8_t *c
= (uint8_t *)&in
->sin_addr
.s_addr
;
363 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
364 ntohs(in
->sin_port
));
365 gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
366 c
[0], c
[1], c
[2], c
[3]);
371 struct target_sockaddr_ll
*ll
= (struct target_sockaddr_ll
*)sa
;
372 uint8_t *c
= (uint8_t *)&ll
->sll_addr
;
373 gemu_log("{sll_family=AF_PACKET,"
374 "sll_protocol=htons(0x%04x),if%d,pkttype=",
375 ntohs(ll
->sll_protocol
), ll
->sll_ifindex
);
376 switch (ll
->sll_pkttype
) {
378 gemu_log("PACKET_HOST");
380 case PACKET_BROADCAST
:
381 gemu_log("PACKET_BROADCAST");
383 case PACKET_MULTICAST
:
384 gemu_log("PACKET_MULTICAST");
386 case PACKET_OTHERHOST
:
387 gemu_log("PACKET_OTHERHOST");
389 case PACKET_OUTGOING
:
390 gemu_log("PACKET_OUTGOING");
393 gemu_log("%d", ll
->sll_pkttype
);
396 gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
397 c
[0], c
[1], c
[2], c
[3], c
[4], c
[5], c
[6], c
[7]);
402 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
403 for (i
= 0; i
< 13; i
++) {
404 gemu_log("%02x, ", sa
->sa_data
[i
]);
406 gemu_log("%02x}", sa
->sa_data
[i
]);
410 unlock_user(sa
, addr
, 0);
412 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
414 gemu_log(", "TARGET_ABI_FMT_ld
, addrlen
);
418 print_socket_domain(int domain
)
428 gemu_log("PF_PACKET");
431 gemu_log("%d", domain
);
437 print_socket_type(int type
)
440 case TARGET_SOCK_DGRAM
:
441 gemu_log("SOCK_DGRAM");
443 case TARGET_SOCK_STREAM
:
444 gemu_log("SOCK_STREAM");
446 case TARGET_SOCK_RAW
:
447 gemu_log("SOCK_RAW");
449 case TARGET_SOCK_RDM
:
450 gemu_log("SOCK_RDM");
452 case TARGET_SOCK_SEQPACKET
:
453 gemu_log("SOCK_SEQPACKET");
455 case TARGET_SOCK_PACKET
:
456 gemu_log("SOCK_PACKET");
462 print_socket_protocol(int domain
, int type
, int protocol
)
464 if (domain
== AF_PACKET
||
465 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
468 gemu_log("ETH_P_ALL");
471 gemu_log("%d", protocol
);
478 gemu_log("IPPROTO_IP");
481 gemu_log("IPPROTO_TCP");
484 gemu_log("IPPROTO_UDP");
487 gemu_log("IPPROTO_RAW");
490 gemu_log("%d", protocol
);
496 #ifdef TARGET_NR__newselect
498 print_fdset(int n
, abi_ulong target_fds_addr
)
503 if( target_fds_addr
) {
504 abi_long
*target_fds
;
506 target_fds
= lock_user(VERIFY_READ
,
508 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
514 for (i
=n
; i
>=0; i
--) {
515 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
518 unlock_user(target_fds
, target_fds_addr
, 0);
524 #ifdef TARGET_NR_clock_adjtime
525 /* IDs of the various system clocks */
526 #define TARGET_CLOCK_REALTIME 0
527 #define TARGET_CLOCK_MONOTONIC 1
528 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
529 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
530 #define TARGET_CLOCK_MONOTONIC_RAW 4
531 #define TARGET_CLOCK_REALTIME_COARSE 5
532 #define TARGET_CLOCK_MONOTONIC_COARSE 6
533 #define TARGET_CLOCK_BOOTTIME 7
534 #define TARGET_CLOCK_REALTIME_ALARM 8
535 #define TARGET_CLOCK_BOOTTIME_ALARM 9
536 #define TARGET_CLOCK_SGI_CYCLE 10
537 #define TARGET_CLOCK_TAI 11
540 print_clockid(int clockid
, int last
)
543 case TARGET_CLOCK_REALTIME
:
544 gemu_log("CLOCK_REALTIME");
546 case TARGET_CLOCK_MONOTONIC
:
547 gemu_log("CLOCK_MONOTONIC");
549 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
550 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
552 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
553 gemu_log("CLOCK_THREAD_CPUTIME_ID");
555 case TARGET_CLOCK_MONOTONIC_RAW
:
556 gemu_log("CLOCK_MONOTONIC_RAW");
558 case TARGET_CLOCK_REALTIME_COARSE
:
559 gemu_log("CLOCK_REALTIME_COARSE");
561 case TARGET_CLOCK_MONOTONIC_COARSE
:
562 gemu_log("CLOCK_MONOTONIC_COARSE");
564 case TARGET_CLOCK_BOOTTIME
:
565 gemu_log("CLOCK_BOOTTIME");
567 case TARGET_CLOCK_REALTIME_ALARM
:
568 gemu_log("CLOCK_REALTIME_ALARM");
570 case TARGET_CLOCK_BOOTTIME_ALARM
:
571 gemu_log("CLOCK_BOOTTIME_ALARM");
573 case TARGET_CLOCK_SGI_CYCLE
:
574 gemu_log("CLOCK_SGI_CYCLE");
576 case TARGET_CLOCK_TAI
:
577 gemu_log("CLOCK_TAI");
580 gemu_log("%d", clockid
);
583 gemu_log("%s", get_comma(last
));
588 * Sysycall specific output functions
592 #ifdef TARGET_NR__newselect
593 static long newselect_arg1
= 0;
594 static long newselect_arg2
= 0;
595 static long newselect_arg3
= 0;
596 static long newselect_arg4
= 0;
597 static long newselect_arg5
= 0;
600 print_newselect(const struct syscallname
*name
,
601 abi_long arg1
, abi_long arg2
, abi_long arg3
,
602 abi_long arg4
, abi_long arg5
, abi_long arg6
)
604 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
605 print_fdset(arg1
, arg2
);
607 print_fdset(arg1
, arg3
);
609 print_fdset(arg1
, arg4
);
611 print_timeval(arg5
, 1);
614 /* save for use in the return output function below */
623 #ifdef TARGET_NR_semctl
625 print_semctl(const struct syscallname
*name
,
626 abi_long arg1
, abi_long arg2
, abi_long arg3
,
627 abi_long arg4
, abi_long arg5
, abi_long arg6
)
629 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
631 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
636 print_execve(const struct syscallname
*name
,
637 abi_long arg1
, abi_long arg2
, abi_long arg3
,
638 abi_long arg4
, abi_long arg5
, abi_long arg6
)
640 abi_ulong arg_ptr_addr
;
643 if (!(s
= lock_user_string(arg1
)))
645 gemu_log("%s(\"%s\",{", name
->name
, s
);
646 unlock_user(s
, arg1
, 0);
648 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
649 abi_ulong
*arg_ptr
, arg_addr
;
651 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
654 arg_addr
= tswapal(*arg_ptr
);
655 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
658 if ((s
= lock_user_string(arg_addr
))) {
659 gemu_log("\"%s\",", s
);
660 unlock_user(s
, arg_addr
, 0);
669 print_ipc(const struct syscallname
*name
,
670 abi_long arg1
, abi_long arg2
, abi_long arg3
,
671 abi_long arg4
, abi_long arg5
, abi_long arg6
)
675 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
677 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
680 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
681 name
->name
, arg1
, arg2
, arg3
, arg4
);
687 * Variants for the return value output function
691 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
693 const char *errstr
= NULL
;
696 errstr
= target_strerror(-ret
);
699 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
701 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
705 #if 0 /* currently unused */
707 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
709 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
713 #ifdef TARGET_NR__newselect
715 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
717 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
718 print_fdset(newselect_arg1
,newselect_arg2
);
720 print_fdset(newselect_arg1
,newselect_arg3
);
722 print_fdset(newselect_arg1
,newselect_arg4
);
724 print_timeval(newselect_arg5
, 1);
729 /* special meanings of adjtimex()' non-negative return values */
730 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
731 #define TARGET_TIME_INS 1 /* insert leap second */
732 #define TARGET_TIME_DEL 2 /* delete leap second */
733 #define TARGET_TIME_OOP 3 /* leap second in progress */
734 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
735 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
737 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
739 const char *errstr
= NULL
;
743 gemu_log("-1 errno=%d", errno
);
744 errstr
= target_strerror(-ret
);
746 gemu_log(" (%s)", errstr
);
749 gemu_log(TARGET_ABI_FMT_ld
, ret
);
752 gemu_log(" TIME_OK (clock synchronized, no leap second)");
754 case TARGET_TIME_INS
:
755 gemu_log(" TIME_INS (insert leap second)");
757 case TARGET_TIME_DEL
:
758 gemu_log(" TIME_DEL (delete leap second)");
760 case TARGET_TIME_OOP
:
761 gemu_log(" TIME_OOP (leap second in progress)");
763 case TARGET_TIME_WAIT
:
764 gemu_log(" TIME_WAIT (leap second has occurred)");
766 case TARGET_TIME_ERROR
:
767 gemu_log(" TIME_ERROR (clock not synchronized)");
775 UNUSED
static struct flags access_flags
[] = {
783 UNUSED
static struct flags at_file_flags
[] = {
785 FLAG_GENERIC(AT_EACCESS
),
787 #ifdef AT_SYMLINK_NOFOLLOW
788 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
793 UNUSED
static struct flags unlinkat_flags
[] = {
795 FLAG_GENERIC(AT_REMOVEDIR
),
800 UNUSED
static struct flags mode_flags
[] = {
801 FLAG_GENERIC(S_IFSOCK
),
802 FLAG_GENERIC(S_IFLNK
),
803 FLAG_GENERIC(S_IFREG
),
804 FLAG_GENERIC(S_IFBLK
),
805 FLAG_GENERIC(S_IFDIR
),
806 FLAG_GENERIC(S_IFCHR
),
807 FLAG_GENERIC(S_IFIFO
),
811 UNUSED
static struct flags open_access_flags
[] = {
812 FLAG_TARGET(O_RDONLY
),
813 FLAG_TARGET(O_WRONLY
),
818 UNUSED
static struct flags open_flags
[] = {
819 FLAG_TARGET(O_APPEND
),
820 FLAG_TARGET(O_CREAT
),
821 FLAG_TARGET(O_DIRECTORY
),
823 FLAG_TARGET(O_LARGEFILE
),
824 FLAG_TARGET(O_NOCTTY
),
825 FLAG_TARGET(O_NOFOLLOW
),
826 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
827 FLAG_TARGET(O_DSYNC
),
828 FLAG_TARGET(__O_SYNC
),
829 FLAG_TARGET(O_TRUNC
),
831 FLAG_TARGET(O_DIRECT
),
834 FLAG_TARGET(O_NOATIME
),
837 FLAG_TARGET(O_CLOEXEC
),
843 FLAG_TARGET(O_TMPFILE
),
844 FLAG_TARGET(__O_TMPFILE
),
849 UNUSED
static struct flags mount_flags
[] = {
851 FLAG_GENERIC(MS_BIND
),
854 FLAG_GENERIC(MS_DIRSYNC
),
856 FLAG_GENERIC(MS_MANDLOCK
),
858 FLAG_GENERIC(MS_MOVE
),
860 FLAG_GENERIC(MS_NOATIME
),
861 FLAG_GENERIC(MS_NODEV
),
862 FLAG_GENERIC(MS_NODIRATIME
),
863 FLAG_GENERIC(MS_NOEXEC
),
864 FLAG_GENERIC(MS_NOSUID
),
865 FLAG_GENERIC(MS_RDONLY
),
867 FLAG_GENERIC(MS_RELATIME
),
869 FLAG_GENERIC(MS_REMOUNT
),
870 FLAG_GENERIC(MS_SYNCHRONOUS
),
874 UNUSED
static struct flags umount2_flags
[] = {
876 FLAG_GENERIC(MNT_FORCE
),
879 FLAG_GENERIC(MNT_DETACH
),
882 FLAG_GENERIC(MNT_EXPIRE
),
887 UNUSED
static struct flags mmap_prot_flags
[] = {
888 FLAG_GENERIC(PROT_NONE
),
889 FLAG_GENERIC(PROT_EXEC
),
890 FLAG_GENERIC(PROT_READ
),
891 FLAG_GENERIC(PROT_WRITE
),
892 FLAG_TARGET(PROT_SEM
),
893 FLAG_GENERIC(PROT_GROWSDOWN
),
894 FLAG_GENERIC(PROT_GROWSUP
),
898 UNUSED
static struct flags mmap_flags
[] = {
899 FLAG_TARGET(MAP_SHARED
),
900 FLAG_TARGET(MAP_PRIVATE
),
901 FLAG_TARGET(MAP_ANONYMOUS
),
902 FLAG_TARGET(MAP_DENYWRITE
),
903 FLAG_TARGET(MAP_FIXED
),
904 FLAG_TARGET(MAP_GROWSDOWN
),
905 FLAG_TARGET(MAP_EXECUTABLE
),
907 FLAG_TARGET(MAP_LOCKED
),
910 FLAG_TARGET(MAP_NONBLOCK
),
912 FLAG_TARGET(MAP_NORESERVE
),
914 FLAG_TARGET(MAP_POPULATE
),
916 #ifdef TARGET_MAP_UNINITIALIZED
917 FLAG_TARGET(MAP_UNINITIALIZED
),
922 UNUSED
static struct flags clone_flags
[] = {
923 FLAG_GENERIC(CLONE_VM
),
924 FLAG_GENERIC(CLONE_FS
),
925 FLAG_GENERIC(CLONE_FILES
),
926 FLAG_GENERIC(CLONE_SIGHAND
),
927 FLAG_GENERIC(CLONE_PTRACE
),
928 FLAG_GENERIC(CLONE_VFORK
),
929 FLAG_GENERIC(CLONE_PARENT
),
930 FLAG_GENERIC(CLONE_THREAD
),
931 FLAG_GENERIC(CLONE_NEWNS
),
932 FLAG_GENERIC(CLONE_SYSVSEM
),
933 FLAG_GENERIC(CLONE_SETTLS
),
934 FLAG_GENERIC(CLONE_PARENT_SETTID
),
935 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
936 FLAG_GENERIC(CLONE_DETACHED
),
937 FLAG_GENERIC(CLONE_UNTRACED
),
938 FLAG_GENERIC(CLONE_CHILD_SETTID
),
939 #if defined(CLONE_NEWUTS)
940 FLAG_GENERIC(CLONE_NEWUTS
),
942 #if defined(CLONE_NEWIPC)
943 FLAG_GENERIC(CLONE_NEWIPC
),
945 #if defined(CLONE_NEWUSER)
946 FLAG_GENERIC(CLONE_NEWUSER
),
948 #if defined(CLONE_NEWPID)
949 FLAG_GENERIC(CLONE_NEWPID
),
951 #if defined(CLONE_NEWNET)
952 FLAG_GENERIC(CLONE_NEWNET
),
954 #if defined(CLONE_IO)
955 FLAG_GENERIC(CLONE_IO
),
960 UNUSED
static struct flags msg_flags
[] = {
962 FLAG_GENERIC(MSG_CONFIRM
),
963 FLAG_GENERIC(MSG_DONTROUTE
),
964 FLAG_GENERIC(MSG_DONTWAIT
),
965 FLAG_GENERIC(MSG_EOR
),
966 FLAG_GENERIC(MSG_MORE
),
967 FLAG_GENERIC(MSG_NOSIGNAL
),
968 FLAG_GENERIC(MSG_OOB
),
970 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
971 FLAG_GENERIC(MSG_ERRQUEUE
),
972 FLAG_GENERIC(MSG_PEEK
),
973 FLAG_GENERIC(MSG_TRUNC
),
974 FLAG_GENERIC(MSG_WAITALL
),
976 FLAG_GENERIC(MSG_CTRUNC
),
980 UNUSED
static struct flags statx_flags
[] = {
982 FLAG_GENERIC(AT_EMPTY_PATH
),
984 #ifdef AT_NO_AUTOMOUNT
985 FLAG_GENERIC(AT_NO_AUTOMOUNT
),
987 #ifdef AT_SYMLINK_NOFOLLOW
988 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
990 #ifdef AT_STATX_SYNC_AS_STAT
991 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT
),
993 #ifdef AT_STATX_FORCE_SYNC
994 FLAG_GENERIC(AT_STATX_FORCE_SYNC
),
996 #ifdef AT_STATX_DONT_SYNC
997 FLAG_GENERIC(AT_STATX_DONT_SYNC
),
1002 UNUSED
static struct flags statx_mask
[] = {
1003 /* This must come first, because it includes everything. */
1005 FLAG_GENERIC(STATX_ALL
),
1007 /* This must come second; it includes everything except STATX_BTIME. */
1008 #ifdef STATX_BASIC_STATS
1009 FLAG_GENERIC(STATX_BASIC_STATS
),
1012 FLAG_GENERIC(STATX_TYPE
),
1015 FLAG_GENERIC(STATX_MODE
),
1018 FLAG_GENERIC(STATX_NLINK
),
1021 FLAG_GENERIC(STATX_UID
),
1024 FLAG_GENERIC(STATX_GID
),
1027 FLAG_GENERIC(STATX_ATIME
),
1030 FLAG_GENERIC(STATX_MTIME
),
1033 FLAG_GENERIC(STATX_CTIME
),
1036 FLAG_GENERIC(STATX_INO
),
1039 FLAG_GENERIC(STATX_SIZE
),
1042 FLAG_GENERIC(STATX_BLOCKS
),
1045 FLAG_GENERIC(STATX_BTIME
),
1051 * print_xxx utility functions. These are used to print syscall
1052 * parameters in certain format. All of these have parameter
1053 * named 'last'. This parameter is used to add comma to output
1060 return ((last
) ? "" : ",");
1064 print_flags(const struct flags
*f
, abi_long flags
, int last
)
1066 const char *sep
= "";
1069 if ((flags
== 0) && (f
->f_value
== 0)) {
1070 gemu_log("%s%s", f
->f_string
, get_comma(last
));
1073 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1074 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1075 gemu_log("%s%s", sep
, f
->f_string
);
1076 flags
&= ~f
->f_value
;
1083 /* print rest of the flags as numeric */
1085 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1087 gemu_log("%s", get_comma(last
));
1090 /* no string version of flags found, print them in hex then */
1091 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1096 print_at_dirfd(abi_long dirfd
, int last
)
1099 if (dirfd
== AT_FDCWD
) {
1100 gemu_log("AT_FDCWD%s", get_comma(last
));
1104 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
1108 print_file_mode(abi_long mode
, int last
)
1110 const char *sep
= "";
1111 const struct flags
*m
;
1113 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1114 if ((m
->f_value
& mode
) == m
->f_value
) {
1115 gemu_log("%s%s", m
->f_string
, sep
);
1117 mode
&= ~m
->f_value
;
1123 /* print rest of the mode as octal */
1125 gemu_log("%s%#o", sep
, (unsigned int)mode
);
1127 gemu_log("%s", get_comma(last
));
1131 print_open_flags(abi_long flags
, int last
)
1133 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1134 flags
&= ~TARGET_O_ACCMODE
;
1136 gemu_log("%s", get_comma(last
));
1140 print_flags(open_flags
, flags
, last
);
1144 print_syscall_prologue(const struct syscallname
*sc
)
1146 gemu_log("%s(", sc
->name
);
1151 print_syscall_epilogue(const struct syscallname
*sc
)
1158 print_string(abi_long addr
, int last
)
1162 if ((s
= lock_user_string(addr
)) != NULL
) {
1163 gemu_log("\"%s\"%s", s
, get_comma(last
));
1164 unlock_user(s
, addr
, 0);
1166 /* can't get string out of it, so print it as pointer */
1167 print_pointer(addr
, last
);
1171 #define MAX_PRINT_BUF 40
1173 print_buf(abi_long addr
, abi_long len
, int last
)
1178 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1181 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1182 if (isprint(s
[i
])) {
1183 gemu_log("%c", s
[i
]);
1185 gemu_log("\\%o", s
[i
]);
1195 unlock_user(s
, addr
, 0);
1197 print_pointer(addr
, last
);
1202 * Prints out raw parameter using given format. Caller needs
1203 * to do byte swapping if needed.
1206 print_raw_param(const char *fmt
, abi_long param
, int last
)
1210 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1211 gemu_log(format
, param
);
1215 print_pointer(abi_long p
, int last
)
1218 gemu_log("NULL%s", get_comma(last
));
1220 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1224 * Reads 32-bit (int) number from guest address space from
1225 * address 'addr' and prints it.
1228 print_number(abi_long addr
, int last
)
1231 gemu_log("NULL%s", get_comma(last
));
1235 get_user_s32(num
, addr
);
1236 gemu_log("[%d]%s", num
, get_comma(last
));
1241 print_timeval(abi_ulong tv_addr
, int last
)
1244 struct target_timeval
*tv
;
1246 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1248 print_pointer(tv_addr
, last
);
1251 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1252 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1253 unlock_user(tv
, tv_addr
, 0);
1255 gemu_log("NULL%s", get_comma(last
));
1259 print_timezone(abi_ulong tz_addr
, int last
)
1262 struct target_timezone
*tz
;
1264 tz
= lock_user(VERIFY_READ
, tz_addr
, sizeof(*tz
), 1);
1266 print_pointer(tz_addr
, last
);
1269 gemu_log("{%d,%d}%s", tswap32(tz
->tz_minuteswest
),
1270 tswap32(tz
->tz_dsttime
), get_comma(last
));
1271 unlock_user(tz
, tz_addr
, 0);
1273 gemu_log("NULL%s", get_comma(last
));
1279 #ifdef TARGET_NR_accept
1281 print_accept(const struct syscallname
*name
,
1282 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1283 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1285 print_syscall_prologue(name
);
1286 print_raw_param("%d", arg0
, 0);
1287 print_pointer(arg1
, 0);
1288 print_number(arg2
, 1);
1289 print_syscall_epilogue(name
);
1293 #ifdef TARGET_NR_access
1295 print_access(const struct syscallname
*name
,
1296 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1297 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1299 print_syscall_prologue(name
);
1300 print_string(arg0
, 0);
1301 print_flags(access_flags
, arg1
, 1);
1302 print_syscall_epilogue(name
);
1306 #ifdef TARGET_NR_brk
1308 print_brk(const struct syscallname
*name
,
1309 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1310 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1312 print_syscall_prologue(name
);
1313 print_pointer(arg0
, 1);
1314 print_syscall_epilogue(name
);
1318 #ifdef TARGET_NR_chdir
1320 print_chdir(const struct syscallname
*name
,
1321 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1322 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1324 print_syscall_prologue(name
);
1325 print_string(arg0
, 1);
1326 print_syscall_epilogue(name
);
1330 #ifdef TARGET_NR_chroot
1332 print_chroot(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
, 1);
1338 print_syscall_epilogue(name
);
1342 #ifdef TARGET_NR_chmod
1344 print_chmod(const struct syscallname
*name
,
1345 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1346 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1348 print_syscall_prologue(name
);
1349 print_string(arg0
, 0);
1350 print_file_mode(arg1
, 1);
1351 print_syscall_epilogue(name
);
1355 #ifdef TARGET_NR_clock_adjtime
1357 print_clock_adjtime(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_clockid(arg0
, 0);
1363 print_pointer(arg1
, 1);
1364 print_syscall_epilogue(name
);
1368 #ifdef TARGET_NR_clone
1369 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1370 abi_ulong parent_tidptr
, target_ulong newtls
,
1371 abi_ulong child_tidptr
)
1373 print_flags(clone_flags
, flags
, 0);
1374 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1375 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1376 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1377 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1381 print_clone(const struct syscallname
*name
,
1382 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1383 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1385 print_syscall_prologue(name
);
1386 #if defined(TARGET_MICROBLAZE)
1387 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1388 #elif defined(TARGET_CLONE_BACKWARDS)
1389 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1390 #elif defined(TARGET_CLONE_BACKWARDS2)
1391 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1393 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1395 print_syscall_epilogue(name
);
1399 #ifdef TARGET_NR_creat
1401 print_creat(const struct syscallname
*name
,
1402 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1403 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1405 print_syscall_prologue(name
);
1406 print_string(arg0
, 0);
1407 print_file_mode(arg1
, 1);
1408 print_syscall_epilogue(name
);
1412 #ifdef TARGET_NR_execv
1414 print_execv(const struct syscallname
*name
,
1415 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1416 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1418 print_syscall_prologue(name
);
1419 print_string(arg0
, 0);
1420 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1421 print_syscall_epilogue(name
);
1425 #ifdef TARGET_NR_faccessat
1427 print_faccessat(const struct syscallname
*name
,
1428 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1429 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1431 print_syscall_prologue(name
);
1432 print_at_dirfd(arg0
, 0);
1433 print_string(arg1
, 0);
1434 print_flags(access_flags
, arg2
, 0);
1435 print_flags(at_file_flags
, arg3
, 1);
1436 print_syscall_epilogue(name
);
1440 #ifdef TARGET_NR_fchmodat
1442 print_fchmodat(const struct syscallname
*name
,
1443 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1444 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1446 print_syscall_prologue(name
);
1447 print_at_dirfd(arg0
, 0);
1448 print_string(arg1
, 0);
1449 print_file_mode(arg2
, 0);
1450 print_flags(at_file_flags
, arg3
, 1);
1451 print_syscall_epilogue(name
);
1455 #ifdef TARGET_NR_fchownat
1457 print_fchownat(const struct syscallname
*name
,
1458 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1459 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1461 print_syscall_prologue(name
);
1462 print_at_dirfd(arg0
, 0);
1463 print_string(arg1
, 0);
1464 print_raw_param("%d", arg2
, 0);
1465 print_raw_param("%d", arg3
, 0);
1466 print_flags(at_file_flags
, arg4
, 1);
1467 print_syscall_epilogue(name
);
1471 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1473 print_fcntl(const struct syscallname
*name
,
1474 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1475 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1477 print_syscall_prologue(name
);
1478 print_raw_param("%d", arg0
, 0);
1480 case TARGET_F_DUPFD
:
1481 gemu_log("F_DUPFD,");
1482 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1484 case TARGET_F_GETFD
:
1485 gemu_log("F_GETFD");
1487 case TARGET_F_SETFD
:
1488 gemu_log("F_SETFD,");
1489 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1491 case TARGET_F_GETFL
:
1492 gemu_log("F_GETFL");
1494 case TARGET_F_SETFL
:
1495 gemu_log("F_SETFL,");
1496 print_open_flags(arg2
, 1);
1498 case TARGET_F_GETLK
:
1499 gemu_log("F_GETLK,");
1500 print_pointer(arg2
, 1);
1502 case TARGET_F_SETLK
:
1503 gemu_log("F_SETLK,");
1504 print_pointer(arg2
, 1);
1506 case TARGET_F_SETLKW
:
1507 gemu_log("F_SETLKW,");
1508 print_pointer(arg2
, 1);
1510 case TARGET_F_GETOWN
:
1511 gemu_log("F_GETOWN");
1513 case TARGET_F_SETOWN
:
1514 gemu_log("F_SETOWN,");
1515 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1517 case TARGET_F_GETSIG
:
1518 gemu_log("F_GETSIG");
1520 case TARGET_F_SETSIG
:
1521 gemu_log("F_SETSIG,");
1522 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1524 #if TARGET_ABI_BITS == 32
1525 case TARGET_F_GETLK64
:
1526 gemu_log("F_GETLK64,");
1527 print_pointer(arg2
, 1);
1529 case TARGET_F_SETLK64
:
1530 gemu_log("F_SETLK64,");
1531 print_pointer(arg2
, 1);
1533 case TARGET_F_SETLKW64
:
1534 gemu_log("F_SETLKW64,");
1535 print_pointer(arg2
, 1);
1538 case TARGET_F_SETLEASE
:
1539 gemu_log("F_SETLEASE,");
1540 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1542 case TARGET_F_GETLEASE
:
1543 gemu_log("F_GETLEASE");
1545 case TARGET_F_SETPIPE_SZ
:
1546 gemu_log("F_SETPIPE_SZ,");
1547 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1549 case TARGET_F_GETPIPE_SZ
:
1550 gemu_log("F_GETPIPE_SZ");
1552 case TARGET_F_DUPFD_CLOEXEC
:
1553 gemu_log("F_DUPFD_CLOEXEC,");
1554 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1556 case TARGET_F_NOTIFY
:
1557 gemu_log("F_NOTIFY,");
1558 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1561 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1562 print_pointer(arg2
, 1);
1565 print_syscall_epilogue(name
);
1567 #define print_fcntl64 print_fcntl
1571 #ifdef TARGET_NR_futimesat
1573 print_futimesat(const struct syscallname
*name
,
1574 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1575 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1577 print_syscall_prologue(name
);
1578 print_at_dirfd(arg0
, 0);
1579 print_string(arg1
, 0);
1580 print_timeval(arg2
, 0);
1581 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1582 print_syscall_epilogue(name
);
1586 #ifdef TARGET_NR_link
1588 print_link(const struct syscallname
*name
,
1589 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1590 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1592 print_syscall_prologue(name
);
1593 print_string(arg0
, 0);
1594 print_string(arg1
, 1);
1595 print_syscall_epilogue(name
);
1599 #ifdef TARGET_NR_linkat
1601 print_linkat(const struct syscallname
*name
,
1602 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1603 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1605 print_syscall_prologue(name
);
1606 print_at_dirfd(arg0
, 0);
1607 print_string(arg1
, 0);
1608 print_at_dirfd(arg2
, 0);
1609 print_string(arg3
, 0);
1610 print_flags(at_file_flags
, arg4
, 1);
1611 print_syscall_epilogue(name
);
1615 #ifdef TARGET_NR__llseek
1617 print__llseek(const struct syscallname
*name
,
1618 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1619 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1621 const char *whence
= "UNKNOWN";
1622 print_syscall_prologue(name
);
1623 print_raw_param("%d", arg0
, 0);
1624 print_raw_param("%ld", arg1
, 0);
1625 print_raw_param("%ld", arg2
, 0);
1626 print_pointer(arg3
, 0);
1628 case SEEK_SET
: whence
= "SEEK_SET"; break;
1629 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1630 case SEEK_END
: whence
= "SEEK_END"; break;
1632 gemu_log("%s",whence
);
1633 print_syscall_epilogue(name
);
1637 #if defined(TARGET_NR_socket)
1639 print_socket(const struct syscallname
*name
,
1640 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1641 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1643 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1645 print_syscall_prologue(name
);
1646 print_socket_domain(domain
);
1648 print_socket_type(type
);
1650 if (domain
== AF_PACKET
||
1651 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1652 protocol
= tswap16(protocol
);
1654 print_socket_protocol(domain
, type
, protocol
);
1655 print_syscall_epilogue(name
);
1660 #if defined(TARGET_NR_socketcall)
1662 #define get_user_ualx(x, gaddr, idx) \
1663 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1665 static void do_print_socket(const char *name
, abi_long arg1
)
1667 abi_ulong domain
, type
, protocol
;
1669 get_user_ualx(domain
, arg1
, 0);
1670 get_user_ualx(type
, arg1
, 1);
1671 get_user_ualx(protocol
, arg1
, 2);
1672 gemu_log("%s(", name
);
1673 print_socket_domain(domain
);
1675 print_socket_type(type
);
1677 if (domain
== AF_PACKET
||
1678 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1679 protocol
= tswap16(protocol
);
1681 print_socket_protocol(domain
, type
, protocol
);
1685 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1687 abi_ulong sockfd
, addr
, addrlen
;
1689 get_user_ualx(sockfd
, arg1
, 0);
1690 get_user_ualx(addr
, arg1
, 1);
1691 get_user_ualx(addrlen
, arg1
, 2);
1693 gemu_log("%s(", name
);
1694 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1695 print_sockaddr(addr
, addrlen
);
1699 static void do_print_listen(const char *name
, abi_long arg1
)
1701 abi_ulong sockfd
, backlog
;
1703 get_user_ualx(sockfd
, arg1
, 0);
1704 get_user_ualx(backlog
, arg1
, 1);
1706 gemu_log("%s(", name
);
1707 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1708 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1712 static void do_print_socketpair(const char *name
, abi_long arg1
)
1714 abi_ulong domain
, type
, protocol
, tab
;
1716 get_user_ualx(domain
, arg1
, 0);
1717 get_user_ualx(type
, arg1
, 1);
1718 get_user_ualx(protocol
, arg1
, 2);
1719 get_user_ualx(tab
, arg1
, 3);
1721 gemu_log("%s(", name
);
1722 print_socket_domain(domain
);
1724 print_socket_type(type
);
1726 print_socket_protocol(domain
, type
, protocol
);
1728 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1732 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1734 abi_ulong sockfd
, msg
, len
, flags
;
1736 get_user_ualx(sockfd
, arg1
, 0);
1737 get_user_ualx(msg
, arg1
, 1);
1738 get_user_ualx(len
, arg1
, 2);
1739 get_user_ualx(flags
, arg1
, 3);
1741 gemu_log("%s(", name
);
1742 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1743 print_buf(msg
, len
, 0);
1744 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1745 print_flags(msg_flags
, flags
, 1);
1749 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1751 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1753 get_user_ualx(sockfd
, arg1
, 0);
1754 get_user_ualx(msg
, arg1
, 1);
1755 get_user_ualx(len
, arg1
, 2);
1756 get_user_ualx(flags
, arg1
, 3);
1757 get_user_ualx(addr
, arg1
, 4);
1758 get_user_ualx(addrlen
, arg1
, 5);
1760 gemu_log("%s(", name
);
1761 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1762 print_buf(msg
, len
, 0);
1763 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1764 print_flags(msg_flags
, flags
, 0);
1765 print_sockaddr(addr
, addrlen
);
1769 static void do_print_shutdown(const char *name
, abi_long arg1
)
1771 abi_ulong sockfd
, how
;
1773 get_user_ualx(sockfd
, arg1
, 0);
1774 get_user_ualx(how
, arg1
, 1);
1776 gemu_log("shutdown(");
1777 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1780 gemu_log("SHUT_RD");
1783 gemu_log("SHUT_WR");
1786 gemu_log("SHUT_RDWR");
1789 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1795 static void do_print_msg(const char *name
, abi_long arg1
)
1797 abi_ulong sockfd
, msg
, flags
;
1799 get_user_ualx(sockfd
, arg1
, 0);
1800 get_user_ualx(msg
, arg1
, 1);
1801 get_user_ualx(flags
, arg1
, 2);
1803 gemu_log("%s(", name
);
1804 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1805 print_pointer(msg
, 0);
1806 print_flags(msg_flags
, flags
, 1);
1810 static void do_print_sockopt(const char *name
, abi_long arg1
)
1812 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1814 get_user_ualx(sockfd
, arg1
, 0);
1815 get_user_ualx(level
, arg1
, 1);
1816 get_user_ualx(optname
, arg1
, 2);
1817 get_user_ualx(optval
, arg1
, 3);
1818 get_user_ualx(optlen
, arg1
, 4);
1820 gemu_log("%s(", name
);
1821 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1824 gemu_log("SOL_TCP,");
1825 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1826 print_pointer(optval
, 0);
1829 gemu_log("SOL_IP,");
1830 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1831 print_pointer(optval
, 0);
1834 gemu_log("SOL_RAW,");
1835 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1836 print_pointer(optval
, 0);
1838 case TARGET_SOL_SOCKET
:
1839 gemu_log("SOL_SOCKET,");
1841 case TARGET_SO_DEBUG
:
1842 gemu_log("SO_DEBUG,");
1844 print_number(optval
, 0);
1846 case TARGET_SO_REUSEADDR
:
1847 gemu_log("SO_REUSEADDR,");
1849 case TARGET_SO_REUSEPORT
:
1850 gemu_log("SO_REUSEPORT,");
1852 case TARGET_SO_TYPE
:
1853 gemu_log("SO_TYPE,");
1855 case TARGET_SO_ERROR
:
1856 gemu_log("SO_ERROR,");
1858 case TARGET_SO_DONTROUTE
:
1859 gemu_log("SO_DONTROUTE,");
1861 case TARGET_SO_BROADCAST
:
1862 gemu_log("SO_BROADCAST,");
1864 case TARGET_SO_SNDBUF
:
1865 gemu_log("SO_SNDBUF,");
1867 case TARGET_SO_RCVBUF
:
1868 gemu_log("SO_RCVBUF,");
1870 case TARGET_SO_KEEPALIVE
:
1871 gemu_log("SO_KEEPALIVE,");
1873 case TARGET_SO_OOBINLINE
:
1874 gemu_log("SO_OOBINLINE,");
1876 case TARGET_SO_NO_CHECK
:
1877 gemu_log("SO_NO_CHECK,");
1879 case TARGET_SO_PRIORITY
:
1880 gemu_log("SO_PRIORITY,");
1882 case TARGET_SO_BSDCOMPAT
:
1883 gemu_log("SO_BSDCOMPAT,");
1885 case TARGET_SO_PASSCRED
:
1886 gemu_log("SO_PASSCRED,");
1888 case TARGET_SO_TIMESTAMP
:
1889 gemu_log("SO_TIMESTAMP,");
1891 case TARGET_SO_RCVLOWAT
:
1892 gemu_log("SO_RCVLOWAT,");
1894 case TARGET_SO_RCVTIMEO
:
1895 gemu_log("SO_RCVTIMEO,");
1896 print_timeval(optval
, 0);
1898 case TARGET_SO_SNDTIMEO
:
1899 gemu_log("SO_SNDTIMEO,");
1900 print_timeval(optval
, 0);
1902 case TARGET_SO_ATTACH_FILTER
: {
1903 struct target_sock_fprog
*fprog
;
1905 gemu_log("SO_ATTACH_FILTER,");
1907 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1908 struct target_sock_filter
*filter
;
1910 if (lock_user_struct(VERIFY_READ
, filter
,
1911 tswapal(fprog
->filter
), 0)) {
1913 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1914 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1915 i
, tswap16(filter
[i
].code
),
1916 filter
[i
].jt
, filter
[i
].jf
,
1917 tswap32(filter
[i
].k
));
1919 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1920 i
, tswap16(filter
[i
].code
),
1921 filter
[i
].jt
, filter
[i
].jf
,
1922 tswap32(filter
[i
].k
));
1924 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1926 gemu_log(",%d},", tswap16(fprog
->len
));
1927 unlock_user(fprog
, optval
, 0);
1929 print_pointer(optval
, 0);
1934 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1935 print_pointer(optval
, 0);
1940 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
1941 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1942 print_pointer(optval
, 0);
1945 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
1949 #define PRINT_SOCKOP(name, func) \
1950 [TARGET_SYS_##name] = { #name, func }
1954 void (*print
)(const char *, abi_long
);
1956 PRINT_SOCKOP(SOCKET
, do_print_socket
),
1957 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
1958 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
1959 PRINT_SOCKOP(LISTEN
, do_print_listen
),
1960 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
1961 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
1962 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
1963 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
1964 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
1965 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
1966 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
1967 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
1968 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
1969 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
1970 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
1971 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
1972 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
1973 PRINT_SOCKOP(ACCEPT4
, NULL
),
1974 PRINT_SOCKOP(RECVMMSG
, NULL
),
1975 PRINT_SOCKOP(SENDMMSG
, NULL
),
1979 print_socketcall(const struct syscallname
*name
,
1980 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1981 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1983 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
1984 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
1987 print_syscall_prologue(name
);
1988 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
1989 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1990 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1991 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
1992 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
1993 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
1994 print_syscall_epilogue(name
);
1998 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1999 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2001 print_stat(const struct syscallname
*name
,
2002 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2003 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2005 print_syscall_prologue(name
);
2006 print_string(arg0
, 0);
2007 print_pointer(arg1
, 1);
2008 print_syscall_epilogue(name
);
2010 #define print_lstat print_stat
2011 #define print_stat64 print_stat
2012 #define print_lstat64 print_stat
2015 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2017 print_fstat(const struct syscallname
*name
,
2018 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2019 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2021 print_syscall_prologue(name
);
2022 print_raw_param("%d", arg0
, 0);
2023 print_pointer(arg1
, 1);
2024 print_syscall_epilogue(name
);
2026 #define print_fstat64 print_fstat
2029 #ifdef TARGET_NR_mkdir
2031 print_mkdir(const struct syscallname
*name
,
2032 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2033 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2035 print_syscall_prologue(name
);
2036 print_string(arg0
, 0);
2037 print_file_mode(arg1
, 1);
2038 print_syscall_epilogue(name
);
2042 #ifdef TARGET_NR_mkdirat
2044 print_mkdirat(const struct syscallname
*name
,
2045 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2046 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2048 print_syscall_prologue(name
);
2049 print_at_dirfd(arg0
, 0);
2050 print_string(arg1
, 0);
2051 print_file_mode(arg2
, 1);
2052 print_syscall_epilogue(name
);
2056 #ifdef TARGET_NR_rmdir
2058 print_rmdir(const struct syscallname
*name
,
2059 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2060 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2062 print_syscall_prologue(name
);
2063 print_string(arg0
, 0);
2064 print_syscall_epilogue(name
);
2068 #ifdef TARGET_NR_rt_sigaction
2070 print_rt_sigaction(const struct syscallname
*name
,
2071 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2072 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2074 print_syscall_prologue(name
);
2075 print_signal(arg0
, 0);
2076 print_pointer(arg1
, 0);
2077 print_pointer(arg2
, 1);
2078 print_syscall_epilogue(name
);
2082 #ifdef TARGET_NR_rt_sigprocmask
2084 print_rt_sigprocmask(const struct syscallname
*name
,
2085 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2086 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2088 const char *how
= "UNKNOWN";
2089 print_syscall_prologue(name
);
2091 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2092 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2093 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2095 gemu_log("%s,",how
);
2096 print_pointer(arg1
, 0);
2097 print_pointer(arg2
, 1);
2098 print_syscall_epilogue(name
);
2102 #ifdef TARGET_NR_rt_sigqueueinfo
2104 print_rt_sigqueueinfo(const struct syscallname
*name
,
2105 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2106 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2109 target_siginfo_t uinfo
;
2111 print_syscall_prologue(name
);
2112 print_raw_param("%d", arg0
, 0);
2113 print_signal(arg1
, 0);
2114 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2116 get_target_siginfo(&uinfo
, p
);
2117 print_siginfo(&uinfo
);
2119 unlock_user(p
, arg2
, 0);
2121 print_pointer(arg2
, 1);
2123 print_syscall_epilogue(name
);
2127 #ifdef TARGET_NR_rt_tgsigqueueinfo
2129 print_rt_tgsigqueueinfo(const struct syscallname
*name
,
2130 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2131 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2134 target_siginfo_t uinfo
;
2136 print_syscall_prologue(name
);
2137 print_raw_param("%d", arg0
, 0);
2138 print_raw_param("%d", arg1
, 0);
2139 print_signal(arg2
, 0);
2140 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2142 get_target_siginfo(&uinfo
, p
);
2143 print_siginfo(&uinfo
);
2145 unlock_user(p
, arg3
, 0);
2147 print_pointer(arg3
, 1);
2149 print_syscall_epilogue(name
);
2153 #ifdef TARGET_NR_syslog
2155 print_syslog_action(abi_ulong arg
, int last
)
2160 case TARGET_SYSLOG_ACTION_CLOSE
: {
2161 type
= "SYSLOG_ACTION_CLOSE";
2164 case TARGET_SYSLOG_ACTION_OPEN
: {
2165 type
= "SYSLOG_ACTION_OPEN";
2168 case TARGET_SYSLOG_ACTION_READ
: {
2169 type
= "SYSLOG_ACTION_READ";
2172 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2173 type
= "SYSLOG_ACTION_READ_ALL";
2176 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2177 type
= "SYSLOG_ACTION_READ_CLEAR";
2180 case TARGET_SYSLOG_ACTION_CLEAR
: {
2181 type
= "SYSLOG_ACTION_CLEAR";
2184 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2185 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2188 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
2189 type
= "SYSLOG_ACTION_CONSOLE_ON";
2192 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
2193 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
2196 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
2197 type
= "SYSLOG_ACTION_SIZE_UNREAD";
2200 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
2201 type
= "SYSLOG_ACTION_SIZE_BUFFER";
2205 print_raw_param("%ld", arg
, last
);
2209 gemu_log("%s%s", type
, get_comma(last
));
2213 print_syslog(const struct syscallname
*name
,
2214 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2215 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2217 print_syscall_prologue(name
);
2218 print_syslog_action(arg0
, 0);
2219 print_pointer(arg1
, 0);
2220 print_raw_param("%d", arg2
, 1);
2221 print_syscall_epilogue(name
);
2225 #ifdef TARGET_NR_mknod
2227 print_mknod(const struct syscallname
*name
,
2228 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2229 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2231 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
2233 print_syscall_prologue(name
);
2234 print_string(arg0
, 0);
2235 print_file_mode(arg1
, (hasdev
== 0));
2237 print_raw_param("makedev(%d", major(arg2
), 0);
2238 print_raw_param("%d)", minor(arg2
), 1);
2240 print_syscall_epilogue(name
);
2244 #ifdef TARGET_NR_mknodat
2246 print_mknodat(const struct syscallname
*name
,
2247 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2248 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2250 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2252 print_syscall_prologue(name
);
2253 print_at_dirfd(arg0
, 0);
2254 print_string(arg1
, 0);
2255 print_file_mode(arg2
, (hasdev
== 0));
2257 print_raw_param("makedev(%d", major(arg3
), 0);
2258 print_raw_param("%d)", minor(arg3
), 1);
2260 print_syscall_epilogue(name
);
2264 #ifdef TARGET_NR_mq_open
2266 print_mq_open(const struct syscallname
*name
,
2267 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2268 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2270 int is_creat
= (arg1
& TARGET_O_CREAT
);
2272 print_syscall_prologue(name
);
2273 print_string(arg0
, 0);
2274 print_open_flags(arg1
, (is_creat
== 0));
2276 print_file_mode(arg2
, 0);
2277 print_pointer(arg3
, 1);
2279 print_syscall_epilogue(name
);
2283 #ifdef TARGET_NR_open
2285 print_open(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 int is_creat
= (arg1
& TARGET_O_CREAT
);
2291 print_syscall_prologue(name
);
2292 print_string(arg0
, 0);
2293 print_open_flags(arg1
, (is_creat
== 0));
2295 print_file_mode(arg2
, 1);
2296 print_syscall_epilogue(name
);
2300 #ifdef TARGET_NR_openat
2302 print_openat(const struct syscallname
*name
,
2303 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2304 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2306 int is_creat
= (arg2
& TARGET_O_CREAT
);
2308 print_syscall_prologue(name
);
2309 print_at_dirfd(arg0
, 0);
2310 print_string(arg1
, 0);
2311 print_open_flags(arg2
, (is_creat
== 0));
2313 print_file_mode(arg3
, 1);
2314 print_syscall_epilogue(name
);
2318 #ifdef TARGET_NR_mq_unlink
2320 print_mq_unlink(const struct syscallname
*name
,
2321 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2322 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2324 print_syscall_prologue(name
);
2325 print_string(arg0
, 1);
2326 print_syscall_epilogue(name
);
2330 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2332 print_fstatat64(const struct syscallname
*name
,
2333 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2334 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2336 print_syscall_prologue(name
);
2337 print_at_dirfd(arg0
, 0);
2338 print_string(arg1
, 0);
2339 print_pointer(arg2
, 0);
2340 print_flags(at_file_flags
, arg3
, 1);
2341 print_syscall_epilogue(name
);
2343 #define print_newfstatat print_fstatat64
2346 #ifdef TARGET_NR_readlink
2348 print_readlink(const struct syscallname
*name
,
2349 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2350 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2352 print_syscall_prologue(name
);
2353 print_string(arg0
, 0);
2354 print_pointer(arg1
, 0);
2355 print_raw_param("%u", arg2
, 1);
2356 print_syscall_epilogue(name
);
2360 #ifdef TARGET_NR_readlinkat
2362 print_readlinkat(const struct syscallname
*name
,
2363 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2364 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2366 print_syscall_prologue(name
);
2367 print_at_dirfd(arg0
, 0);
2368 print_string(arg1
, 0);
2369 print_pointer(arg2
, 0);
2370 print_raw_param("%u", arg3
, 1);
2371 print_syscall_epilogue(name
);
2375 #ifdef TARGET_NR_rename
2377 print_rename(const struct syscallname
*name
,
2378 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2379 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2381 print_syscall_prologue(name
);
2382 print_string(arg0
, 0);
2383 print_string(arg1
, 1);
2384 print_syscall_epilogue(name
);
2388 #ifdef TARGET_NR_renameat
2390 print_renameat(const struct syscallname
*name
,
2391 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2392 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2394 print_syscall_prologue(name
);
2395 print_at_dirfd(arg0
, 0);
2396 print_string(arg1
, 0);
2397 print_at_dirfd(arg2
, 0);
2398 print_string(arg3
, 1);
2399 print_syscall_epilogue(name
);
2403 #ifdef TARGET_NR_statfs
2405 print_statfs(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
, 0);
2411 print_pointer(arg1
, 1);
2412 print_syscall_epilogue(name
);
2416 #ifdef TARGET_NR_statfs64
2418 print_statfs64(const struct syscallname
*name
,
2419 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2420 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2422 print_syscall_prologue(name
);
2423 print_string(arg0
, 0);
2424 print_pointer(arg1
, 1);
2425 print_syscall_epilogue(name
);
2429 #ifdef TARGET_NR_symlink
2431 print_symlink(const struct syscallname
*name
,
2432 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2433 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2435 print_syscall_prologue(name
);
2436 print_string(arg0
, 0);
2437 print_string(arg1
, 1);
2438 print_syscall_epilogue(name
);
2442 #ifdef TARGET_NR_symlinkat
2444 print_symlinkat(const struct syscallname
*name
,
2445 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2446 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2448 print_syscall_prologue(name
);
2449 print_string(arg0
, 0);
2450 print_at_dirfd(arg1
, 0);
2451 print_string(arg2
, 1);
2452 print_syscall_epilogue(name
);
2456 #ifdef TARGET_NR_mount
2458 print_mount(const struct syscallname
*name
,
2459 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2460 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2462 print_syscall_prologue(name
);
2463 print_string(arg0
, 0);
2464 print_string(arg1
, 0);
2465 print_string(arg2
, 0);
2466 print_flags(mount_flags
, arg3
, 0);
2467 print_pointer(arg4
, 1);
2468 print_syscall_epilogue(name
);
2472 #ifdef TARGET_NR_umount
2474 print_umount(const struct syscallname
*name
,
2475 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2476 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2478 print_syscall_prologue(name
);
2479 print_string(arg0
, 1);
2480 print_syscall_epilogue(name
);
2484 #ifdef TARGET_NR_umount2
2486 print_umount2(const struct syscallname
*name
,
2487 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2488 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2490 print_syscall_prologue(name
);
2491 print_string(arg0
, 0);
2492 print_flags(umount2_flags
, arg1
, 1);
2493 print_syscall_epilogue(name
);
2497 #ifdef TARGET_NR_unlink
2499 print_unlink(const struct syscallname
*name
,
2500 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2501 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2503 print_syscall_prologue(name
);
2504 print_string(arg0
, 1);
2505 print_syscall_epilogue(name
);
2509 #ifdef TARGET_NR_unlinkat
2511 print_unlinkat(const struct syscallname
*name
,
2512 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2513 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2515 print_syscall_prologue(name
);
2516 print_at_dirfd(arg0
, 0);
2517 print_string(arg1
, 0);
2518 print_flags(unlinkat_flags
, arg2
, 1);
2519 print_syscall_epilogue(name
);
2523 #ifdef TARGET_NR_utime
2525 print_utime(const struct syscallname
*name
,
2526 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2527 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2529 print_syscall_prologue(name
);
2530 print_string(arg0
, 0);
2531 print_pointer(arg1
, 1);
2532 print_syscall_epilogue(name
);
2536 #ifdef TARGET_NR_utimes
2538 print_utimes(const struct syscallname
*name
,
2539 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2540 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2542 print_syscall_prologue(name
);
2543 print_string(arg0
, 0);
2544 print_pointer(arg1
, 1);
2545 print_syscall_epilogue(name
);
2549 #ifdef TARGET_NR_utimensat
2551 print_utimensat(const struct syscallname
*name
,
2552 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2553 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2555 print_syscall_prologue(name
);
2556 print_at_dirfd(arg0
, 0);
2557 print_string(arg1
, 0);
2558 print_pointer(arg2
, 0);
2559 print_flags(at_file_flags
, arg3
, 1);
2560 print_syscall_epilogue(name
);
2564 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2566 print_mmap(const struct syscallname
*name
,
2567 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2568 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2570 print_syscall_prologue(name
);
2571 print_pointer(arg0
, 0);
2572 print_raw_param("%d", arg1
, 0);
2573 print_flags(mmap_prot_flags
, arg2
, 0);
2574 print_flags(mmap_flags
, arg3
, 0);
2575 print_raw_param("%d", arg4
, 0);
2576 print_raw_param("%#x", arg5
, 1);
2577 print_syscall_epilogue(name
);
2579 #define print_mmap2 print_mmap
2582 #ifdef TARGET_NR_mprotect
2584 print_mprotect(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_pointer(arg0
, 0);
2590 print_raw_param("%d", arg1
, 0);
2591 print_flags(mmap_prot_flags
, arg2
, 1);
2592 print_syscall_epilogue(name
);
2596 #ifdef TARGET_NR_munmap
2598 print_munmap(const struct syscallname
*name
,
2599 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2600 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2602 print_syscall_prologue(name
);
2603 print_pointer(arg0
, 0);
2604 print_raw_param("%d", arg1
, 1);
2605 print_syscall_epilogue(name
);
2609 #ifdef TARGET_NR_futex
2610 static void print_futex_op(abi_long tflag
, int last
)
2612 #define print_op(val) \
2613 if( cmd == val ) { \
2618 int cmd
= (int)tflag
;
2619 #ifdef FUTEX_PRIVATE_FLAG
2620 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2621 gemu_log("FUTEX_PRIVATE_FLAG|");
2622 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2625 #ifdef FUTEX_CLOCK_REALTIME
2626 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2627 gemu_log("FUTEX_CLOCK_REALTIME|");
2628 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2631 print_op(FUTEX_WAIT
)
2632 print_op(FUTEX_WAKE
)
2634 print_op(FUTEX_REQUEUE
)
2635 print_op(FUTEX_CMP_REQUEUE
)
2636 print_op(FUTEX_WAKE_OP
)
2637 print_op(FUTEX_LOCK_PI
)
2638 print_op(FUTEX_UNLOCK_PI
)
2639 print_op(FUTEX_TRYLOCK_PI
)
2640 #ifdef FUTEX_WAIT_BITSET
2641 print_op(FUTEX_WAIT_BITSET
)
2643 #ifdef FUTEX_WAKE_BITSET
2644 print_op(FUTEX_WAKE_BITSET
)
2646 /* unknown values */
2651 print_futex(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_futex_op(arg1
, 0);
2658 print_raw_param(",%d", arg2
, 0);
2659 print_pointer(arg3
, 0); /* struct timespec */
2660 print_pointer(arg4
, 0);
2661 print_raw_param("%d", arg4
, 1);
2662 print_syscall_epilogue(name
);
2666 #ifdef TARGET_NR_kill
2668 print_kill(const struct syscallname
*name
,
2669 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2670 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2672 print_syscall_prologue(name
);
2673 print_raw_param("%d", arg0
, 0);
2674 print_signal(arg1
, 1);
2675 print_syscall_epilogue(name
);
2679 #ifdef TARGET_NR_tkill
2681 print_tkill(const struct syscallname
*name
,
2682 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2683 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2685 print_syscall_prologue(name
);
2686 print_raw_param("%d", arg0
, 0);
2687 print_signal(arg1
, 1);
2688 print_syscall_epilogue(name
);
2692 #ifdef TARGET_NR_tgkill
2694 print_tgkill(const struct syscallname
*name
,
2695 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2696 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2698 print_syscall_prologue(name
);
2699 print_raw_param("%d", arg0
, 0);
2700 print_raw_param("%d", arg1
, 0);
2701 print_signal(arg2
, 1);
2702 print_syscall_epilogue(name
);
2706 #ifdef TARGET_NR_statx
2708 print_statx(const struct syscallname
*name
,
2709 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2710 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2712 print_syscall_prologue(name
);
2713 print_at_dirfd(arg0
, 0);
2714 print_string(arg1
, 0);
2715 print_flags(statx_flags
, arg2
, 0);
2716 print_flags(statx_mask
, arg3
, 0);
2717 print_pointer(arg4
, 1);
2718 print_syscall_epilogue(name
);
2723 * An array of all of the syscalls we know about
2726 static const struct syscallname scnames
[] = {
2727 #include "strace.list"
2730 static int nsyscalls
= ARRAY_SIZE(scnames
);
2733 * The public interface to this module.
2736 print_syscall(int num
,
2737 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2738 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2741 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
")";
2743 gemu_log("%d ", getpid() );
2745 for(i
=0;i
<nsyscalls
;i
++)
2746 if( scnames
[i
].nr
== num
) {
2747 if( scnames
[i
].call
!= NULL
) {
2748 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2750 /* XXX: this format system is broken because it uses
2751 host types and host pointers for strings */
2752 if( scnames
[i
].format
!= NULL
)
2753 format
= scnames
[i
].format
;
2754 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2758 gemu_log("Unknown syscall %d\n", num
);
2763 print_syscall_ret(int num
, abi_long ret
)
2766 const char *errstr
= NULL
;
2768 for(i
=0;i
<nsyscalls
;i
++)
2769 if( scnames
[i
].nr
== num
) {
2770 if( scnames
[i
].result
!= NULL
) {
2771 scnames
[i
].result(&scnames
[i
],ret
);
2774 errstr
= target_strerror(-ret
);
2777 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2780 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2787 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2789 /* Print the strace output for a signal being taken:
2790 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2793 print_signal(target_signum
, 1);
2795 print_siginfo(tinfo
);