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_number(abi_long
, int);
67 UNUSED
static void print_signal(abi_ulong
, int);
68 UNUSED
static void print_sockaddr(abi_ulong addr
, abi_long addrlen
);
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 gemu_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 gemu_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 gemu_log("{si_signo=");
290 print_signal(tinfo
->si_signo
, 1);
291 gemu_log(", si_code=");
292 print_si_code(si_code
);
296 gemu_log(", si_pid=%u, si_uid=%u",
297 (unsigned int)tinfo
->_sifields
._kill
._pid
,
298 (unsigned int)tinfo
->_sifields
._kill
._uid
);
301 gemu_log(", si_timer1=%u, si_timer2=%u",
302 tinfo
->_sifields
._timer
._timer1
,
303 tinfo
->_sifields
._timer
._timer2
);
306 gemu_log(", si_band=%d, si_fd=%d",
307 tinfo
->_sifields
._sigpoll
._band
,
308 tinfo
->_sifields
._sigpoll
._fd
);
311 gemu_log(", si_addr=");
312 print_pointer(tinfo
->_sifields
._sigfault
._addr
, 1);
315 gemu_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 gemu_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
)
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 gemu_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 gemu_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 gemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
363 ntohs(in
->sin_port
));
364 gemu_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 gemu_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 gemu_log("PACKET_HOST");
379 case PACKET_BROADCAST
:
380 gemu_log("PACKET_BROADCAST");
382 case PACKET_MULTICAST
:
383 gemu_log("PACKET_MULTICAST");
385 case PACKET_OTHERHOST
:
386 gemu_log("PACKET_OTHERHOST");
388 case PACKET_OUTGOING
:
389 gemu_log("PACKET_OUTGOING");
392 gemu_log("%d", ll
->sll_pkttype
);
395 gemu_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 gemu_log("{sa_family=%d, sa_data={", sa
->sa_family
);
402 for (i
= 0; i
< 13; i
++) {
403 gemu_log("%02x, ", sa
->sa_data
[i
]);
405 gemu_log("%02x}", sa
->sa_data
[i
]);
409 unlock_user(sa
, addr
, 0);
411 print_raw_param("0x"TARGET_ABI_FMT_lx
, addr
, 0);
413 gemu_log(", "TARGET_ABI_FMT_ld
, addrlen
);
417 print_socket_domain(int domain
)
427 gemu_log("PF_PACKET");
430 gemu_log("%d", domain
);
436 print_socket_type(int type
)
439 case TARGET_SOCK_DGRAM
:
440 gemu_log("SOCK_DGRAM");
442 case TARGET_SOCK_STREAM
:
443 gemu_log("SOCK_STREAM");
445 case TARGET_SOCK_RAW
:
446 gemu_log("SOCK_RAW");
448 case TARGET_SOCK_RDM
:
449 gemu_log("SOCK_RDM");
451 case TARGET_SOCK_SEQPACKET
:
452 gemu_log("SOCK_SEQPACKET");
454 case TARGET_SOCK_PACKET
:
455 gemu_log("SOCK_PACKET");
461 print_socket_protocol(int domain
, int type
, int protocol
)
463 if (domain
== AF_PACKET
||
464 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
467 gemu_log("ETH_P_ALL");
470 gemu_log("%d", protocol
);
477 gemu_log("IPPROTO_IP");
480 gemu_log("IPPROTO_TCP");
483 gemu_log("IPPROTO_UDP");
486 gemu_log("IPPROTO_RAW");
489 gemu_log("%d", protocol
);
495 #ifdef TARGET_NR__newselect
497 print_fdset(int n
, abi_ulong target_fds_addr
)
502 if( target_fds_addr
) {
503 abi_long
*target_fds
;
505 target_fds
= lock_user(VERIFY_READ
,
507 sizeof(*target_fds
)*(n
/ TARGET_ABI_BITS
+ 1),
513 for (i
=n
; i
>=0; i
--) {
514 if ((tswapal(target_fds
[i
/ TARGET_ABI_BITS
]) >> (i
& (TARGET_ABI_BITS
- 1))) & 1)
517 unlock_user(target_fds
, target_fds_addr
, 0);
523 #ifdef TARGET_NR_clock_adjtime
524 /* IDs of the various system clocks */
525 #define TARGET_CLOCK_REALTIME 0
526 #define TARGET_CLOCK_MONOTONIC 1
527 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
528 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
529 #define TARGET_CLOCK_MONOTONIC_RAW 4
530 #define TARGET_CLOCK_REALTIME_COARSE 5
531 #define TARGET_CLOCK_MONOTONIC_COARSE 6
532 #define TARGET_CLOCK_BOOTTIME 7
533 #define TARGET_CLOCK_REALTIME_ALARM 8
534 #define TARGET_CLOCK_BOOTTIME_ALARM 9
535 #define TARGET_CLOCK_SGI_CYCLE 10
536 #define TARGET_CLOCK_TAI 11
539 print_clockid(int clockid
, int last
)
542 case TARGET_CLOCK_REALTIME
:
543 gemu_log("CLOCK_REALTIME");
545 case TARGET_CLOCK_MONOTONIC
:
546 gemu_log("CLOCK_MONOTONIC");
548 case TARGET_CLOCK_PROCESS_CPUTIME_ID
:
549 gemu_log("CLOCK_PROCESS_CPUTIME_ID");
551 case TARGET_CLOCK_THREAD_CPUTIME_ID
:
552 gemu_log("CLOCK_THREAD_CPUTIME_ID");
554 case TARGET_CLOCK_MONOTONIC_RAW
:
555 gemu_log("CLOCK_MONOTONIC_RAW");
557 case TARGET_CLOCK_REALTIME_COARSE
:
558 gemu_log("CLOCK_REALTIME_COARSE");
560 case TARGET_CLOCK_MONOTONIC_COARSE
:
561 gemu_log("CLOCK_MONOTONIC_COARSE");
563 case TARGET_CLOCK_BOOTTIME
:
564 gemu_log("CLOCK_BOOTTIME");
566 case TARGET_CLOCK_REALTIME_ALARM
:
567 gemu_log("CLOCK_REALTIME_ALARM");
569 case TARGET_CLOCK_BOOTTIME_ALARM
:
570 gemu_log("CLOCK_BOOTTIME_ALARM");
572 case TARGET_CLOCK_SGI_CYCLE
:
573 gemu_log("CLOCK_SGI_CYCLE");
575 case TARGET_CLOCK_TAI
:
576 gemu_log("CLOCK_TAI");
579 gemu_log("%d", clockid
);
582 gemu_log("%s", get_comma(last
));
587 * Sysycall specific output functions
591 #ifdef TARGET_NR__newselect
592 static long newselect_arg1
= 0;
593 static long newselect_arg2
= 0;
594 static long newselect_arg3
= 0;
595 static long newselect_arg4
= 0;
596 static long newselect_arg5
= 0;
599 print_newselect(const struct syscallname
*name
,
600 abi_long arg1
, abi_long arg2
, abi_long arg3
,
601 abi_long arg4
, abi_long arg5
, abi_long arg6
)
603 gemu_log("%s(" TARGET_ABI_FMT_ld
",", name
->name
, arg1
);
604 print_fdset(arg1
, arg2
);
606 print_fdset(arg1
, arg3
);
608 print_fdset(arg1
, arg4
);
610 print_timeval(arg5
, 1);
613 /* save for use in the return output function below */
622 #ifdef TARGET_NR_semctl
624 print_semctl(const struct syscallname
*name
,
625 abi_long arg1
, abi_long arg2
, abi_long arg3
,
626 abi_long arg4
, abi_long arg5
, abi_long arg6
)
628 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", name
->name
, arg1
, arg2
);
630 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
635 print_execve(const struct syscallname
*name
,
636 abi_long arg1
, abi_long arg2
, abi_long arg3
,
637 abi_long arg4
, abi_long arg5
, abi_long arg6
)
639 abi_ulong arg_ptr_addr
;
642 if (!(s
= lock_user_string(arg1
)))
644 gemu_log("%s(\"%s\",{", name
->name
, s
);
645 unlock_user(s
, arg1
, 0);
647 for (arg_ptr_addr
= arg2
; ; arg_ptr_addr
+= sizeof(abi_ulong
)) {
648 abi_ulong
*arg_ptr
, arg_addr
;
650 arg_ptr
= lock_user(VERIFY_READ
, arg_ptr_addr
, sizeof(abi_ulong
), 1);
653 arg_addr
= tswapal(*arg_ptr
);
654 unlock_user(arg_ptr
, arg_ptr_addr
, 0);
657 if ((s
= lock_user_string(arg_addr
))) {
658 gemu_log("\"%s\",", s
);
659 unlock_user(s
, arg_addr
, 0);
668 print_ipc(const struct syscallname
*name
,
669 abi_long arg1
, abi_long arg2
, abi_long arg3
,
670 abi_long arg4
, abi_long arg5
, abi_long arg6
)
674 gemu_log("semctl(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
",", arg1
, arg2
);
676 gemu_log(",0x" TARGET_ABI_FMT_lx
")", arg4
);
679 gemu_log("%s(" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
")",
680 name
->name
, arg1
, arg2
, arg3
, arg4
);
686 * Variants for the return value output function
690 print_syscall_ret_addr(const struct syscallname
*name
, abi_long ret
)
692 const char *errstr
= NULL
;
695 errstr
= target_strerror(-ret
);
698 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret
, errstr
);
700 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
704 #if 0 /* currently unused */
706 print_syscall_ret_raw(struct syscallname
*name
, abi_long ret
)
708 gemu_log(" = 0x" TARGET_ABI_FMT_lx
"\n", ret
);
712 #ifdef TARGET_NR__newselect
714 print_syscall_ret_newselect(const struct syscallname
*name
, abi_long ret
)
716 gemu_log(" = 0x" TARGET_ABI_FMT_lx
" (", ret
);
717 print_fdset(newselect_arg1
,newselect_arg2
);
719 print_fdset(newselect_arg1
,newselect_arg3
);
721 print_fdset(newselect_arg1
,newselect_arg4
);
723 print_timeval(newselect_arg5
, 1);
728 /* special meanings of adjtimex()' non-negative return values */
729 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
730 #define TARGET_TIME_INS 1 /* insert leap second */
731 #define TARGET_TIME_DEL 2 /* delete leap second */
732 #define TARGET_TIME_OOP 3 /* leap second in progress */
733 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
734 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
736 print_syscall_ret_adjtimex(const struct syscallname
*name
, abi_long ret
)
738 const char *errstr
= NULL
;
742 gemu_log("-1 errno=%d", errno
);
743 errstr
= target_strerror(-ret
);
745 gemu_log(" (%s)", errstr
);
748 gemu_log(TARGET_ABI_FMT_ld
, ret
);
751 gemu_log(" TIME_OK (clock synchronized, no leap second)");
753 case TARGET_TIME_INS
:
754 gemu_log(" TIME_INS (insert leap second)");
756 case TARGET_TIME_DEL
:
757 gemu_log(" TIME_DEL (delete leap second)");
759 case TARGET_TIME_OOP
:
760 gemu_log(" TIME_OOP (leap second in progress)");
762 case TARGET_TIME_WAIT
:
763 gemu_log(" TIME_WAIT (leap second has occurred)");
765 case TARGET_TIME_ERROR
:
766 gemu_log(" TIME_ERROR (clock not synchronized)");
774 UNUSED
static struct flags access_flags
[] = {
782 UNUSED
static struct flags at_file_flags
[] = {
784 FLAG_GENERIC(AT_EACCESS
),
786 #ifdef AT_SYMLINK_NOFOLLOW
787 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW
),
792 UNUSED
static struct flags unlinkat_flags
[] = {
794 FLAG_GENERIC(AT_REMOVEDIR
),
799 UNUSED
static struct flags mode_flags
[] = {
800 FLAG_GENERIC(S_IFSOCK
),
801 FLAG_GENERIC(S_IFLNK
),
802 FLAG_GENERIC(S_IFREG
),
803 FLAG_GENERIC(S_IFBLK
),
804 FLAG_GENERIC(S_IFDIR
),
805 FLAG_GENERIC(S_IFCHR
),
806 FLAG_GENERIC(S_IFIFO
),
810 UNUSED
static struct flags open_access_flags
[] = {
811 FLAG_TARGET(O_RDONLY
),
812 FLAG_TARGET(O_WRONLY
),
817 UNUSED
static struct flags open_flags
[] = {
818 FLAG_TARGET(O_APPEND
),
819 FLAG_TARGET(O_CREAT
),
820 FLAG_TARGET(O_DIRECTORY
),
822 FLAG_TARGET(O_LARGEFILE
),
823 FLAG_TARGET(O_NOCTTY
),
824 FLAG_TARGET(O_NOFOLLOW
),
825 FLAG_TARGET(O_NONBLOCK
), /* also O_NDELAY */
826 FLAG_TARGET(O_DSYNC
),
827 FLAG_TARGET(__O_SYNC
),
828 FLAG_TARGET(O_TRUNC
),
830 FLAG_TARGET(O_DIRECT
),
833 FLAG_TARGET(O_NOATIME
),
836 FLAG_TARGET(O_CLOEXEC
),
842 FLAG_TARGET(O_TMPFILE
),
843 FLAG_TARGET(__O_TMPFILE
),
848 UNUSED
static struct flags mount_flags
[] = {
850 FLAG_GENERIC(MS_BIND
),
853 FLAG_GENERIC(MS_DIRSYNC
),
855 FLAG_GENERIC(MS_MANDLOCK
),
857 FLAG_GENERIC(MS_MOVE
),
859 FLAG_GENERIC(MS_NOATIME
),
860 FLAG_GENERIC(MS_NODEV
),
861 FLAG_GENERIC(MS_NODIRATIME
),
862 FLAG_GENERIC(MS_NOEXEC
),
863 FLAG_GENERIC(MS_NOSUID
),
864 FLAG_GENERIC(MS_RDONLY
),
866 FLAG_GENERIC(MS_RELATIME
),
868 FLAG_GENERIC(MS_REMOUNT
),
869 FLAG_GENERIC(MS_SYNCHRONOUS
),
873 UNUSED
static struct flags umount2_flags
[] = {
875 FLAG_GENERIC(MNT_FORCE
),
878 FLAG_GENERIC(MNT_DETACH
),
881 FLAG_GENERIC(MNT_EXPIRE
),
886 UNUSED
static struct flags mmap_prot_flags
[] = {
887 FLAG_GENERIC(PROT_NONE
),
888 FLAG_GENERIC(PROT_EXEC
),
889 FLAG_GENERIC(PROT_READ
),
890 FLAG_GENERIC(PROT_WRITE
),
891 FLAG_TARGET(PROT_SEM
),
892 FLAG_GENERIC(PROT_GROWSDOWN
),
893 FLAG_GENERIC(PROT_GROWSUP
),
897 UNUSED
static struct flags mmap_flags
[] = {
898 FLAG_TARGET(MAP_SHARED
),
899 FLAG_TARGET(MAP_PRIVATE
),
900 FLAG_TARGET(MAP_ANONYMOUS
),
901 FLAG_TARGET(MAP_DENYWRITE
),
902 FLAG_TARGET(MAP_FIXED
),
903 FLAG_TARGET(MAP_GROWSDOWN
),
904 FLAG_TARGET(MAP_EXECUTABLE
),
906 FLAG_TARGET(MAP_LOCKED
),
909 FLAG_TARGET(MAP_NONBLOCK
),
911 FLAG_TARGET(MAP_NORESERVE
),
913 FLAG_TARGET(MAP_POPULATE
),
915 #ifdef TARGET_MAP_UNINITIALIZED
916 FLAG_TARGET(MAP_UNINITIALIZED
),
921 UNUSED
static struct flags clone_flags
[] = {
922 FLAG_GENERIC(CLONE_VM
),
923 FLAG_GENERIC(CLONE_FS
),
924 FLAG_GENERIC(CLONE_FILES
),
925 FLAG_GENERIC(CLONE_SIGHAND
),
926 FLAG_GENERIC(CLONE_PTRACE
),
927 FLAG_GENERIC(CLONE_VFORK
),
928 FLAG_GENERIC(CLONE_PARENT
),
929 FLAG_GENERIC(CLONE_THREAD
),
930 FLAG_GENERIC(CLONE_NEWNS
),
931 FLAG_GENERIC(CLONE_SYSVSEM
),
932 FLAG_GENERIC(CLONE_SETTLS
),
933 FLAG_GENERIC(CLONE_PARENT_SETTID
),
934 FLAG_GENERIC(CLONE_CHILD_CLEARTID
),
935 FLAG_GENERIC(CLONE_DETACHED
),
936 FLAG_GENERIC(CLONE_UNTRACED
),
937 FLAG_GENERIC(CLONE_CHILD_SETTID
),
938 #if defined(CLONE_NEWUTS)
939 FLAG_GENERIC(CLONE_NEWUTS
),
941 #if defined(CLONE_NEWIPC)
942 FLAG_GENERIC(CLONE_NEWIPC
),
944 #if defined(CLONE_NEWUSER)
945 FLAG_GENERIC(CLONE_NEWUSER
),
947 #if defined(CLONE_NEWPID)
948 FLAG_GENERIC(CLONE_NEWPID
),
950 #if defined(CLONE_NEWNET)
951 FLAG_GENERIC(CLONE_NEWNET
),
953 #if defined(CLONE_IO)
954 FLAG_GENERIC(CLONE_IO
),
959 UNUSED
static struct flags msg_flags
[] = {
961 FLAG_GENERIC(MSG_CONFIRM
),
962 FLAG_GENERIC(MSG_DONTROUTE
),
963 FLAG_GENERIC(MSG_DONTWAIT
),
964 FLAG_GENERIC(MSG_EOR
),
965 FLAG_GENERIC(MSG_MORE
),
966 FLAG_GENERIC(MSG_NOSIGNAL
),
967 FLAG_GENERIC(MSG_OOB
),
969 FLAG_GENERIC(MSG_CMSG_CLOEXEC
),
970 FLAG_GENERIC(MSG_ERRQUEUE
),
971 FLAG_GENERIC(MSG_PEEK
),
972 FLAG_GENERIC(MSG_TRUNC
),
973 FLAG_GENERIC(MSG_WAITALL
),
975 FLAG_GENERIC(MSG_CTRUNC
),
980 * print_xxx utility functions. These are used to print syscall
981 * parameters in certain format. All of these have parameter
982 * named 'last'. This parameter is used to add comma to output
989 return ((last
) ? "" : ",");
993 print_flags(const struct flags
*f
, abi_long flags
, int last
)
995 const char *sep
= "";
998 if ((flags
== 0) && (f
->f_value
== 0)) {
999 gemu_log("%s%s", f
->f_string
, get_comma(last
));
1002 for (n
= 0; f
->f_string
!= NULL
; f
++) {
1003 if ((f
->f_value
!= 0) && ((flags
& f
->f_value
) == f
->f_value
)) {
1004 gemu_log("%s%s", sep
, f
->f_string
);
1005 flags
&= ~f
->f_value
;
1012 /* print rest of the flags as numeric */
1014 gemu_log("%s%#x%s", sep
, (unsigned int)flags
, get_comma(last
));
1016 gemu_log("%s", get_comma(last
));
1019 /* no string version of flags found, print them in hex then */
1020 gemu_log("%#x%s", (unsigned int)flags
, get_comma(last
));
1025 print_at_dirfd(abi_long dirfd
, int last
)
1028 if (dirfd
== AT_FDCWD
) {
1029 gemu_log("AT_FDCWD%s", get_comma(last
));
1033 gemu_log("%d%s", (int)dirfd
, get_comma(last
));
1037 print_file_mode(abi_long mode
, int last
)
1039 const char *sep
= "";
1040 const struct flags
*m
;
1042 for (m
= &mode_flags
[0]; m
->f_string
!= NULL
; m
++) {
1043 if ((m
->f_value
& mode
) == m
->f_value
) {
1044 gemu_log("%s%s", m
->f_string
, sep
);
1046 mode
&= ~m
->f_value
;
1052 /* print rest of the mode as octal */
1054 gemu_log("%s%#o", sep
, (unsigned int)mode
);
1056 gemu_log("%s", get_comma(last
));
1060 print_open_flags(abi_long flags
, int last
)
1062 print_flags(open_access_flags
, flags
& TARGET_O_ACCMODE
, 1);
1063 flags
&= ~TARGET_O_ACCMODE
;
1065 gemu_log("%s", get_comma(last
));
1069 print_flags(open_flags
, flags
, last
);
1073 print_syscall_prologue(const struct syscallname
*sc
)
1075 gemu_log("%s(", sc
->name
);
1080 print_syscall_epilogue(const struct syscallname
*sc
)
1087 print_string(abi_long addr
, int last
)
1091 if ((s
= lock_user_string(addr
)) != NULL
) {
1092 gemu_log("\"%s\"%s", s
, get_comma(last
));
1093 unlock_user(s
, addr
, 0);
1095 /* can't get string out of it, so print it as pointer */
1096 print_pointer(addr
, last
);
1100 #define MAX_PRINT_BUF 40
1102 print_buf(abi_long addr
, abi_long len
, int last
)
1107 s
= lock_user(VERIFY_READ
, addr
, len
, 1);
1110 for (i
= 0; i
< MAX_PRINT_BUF
&& i
< len
; i
++) {
1111 if (isprint(s
[i
])) {
1112 gemu_log("%c", s
[i
]);
1114 gemu_log("\\%o", s
[i
]);
1124 unlock_user(s
, addr
, 0);
1126 print_pointer(addr
, last
);
1131 * Prints out raw parameter using given format. Caller needs
1132 * to do byte swapping if needed.
1135 print_raw_param(const char *fmt
, abi_long param
, int last
)
1139 (void) snprintf(format
, sizeof (format
), "%s%s", fmt
, get_comma(last
));
1140 gemu_log(format
, param
);
1144 print_pointer(abi_long p
, int last
)
1147 gemu_log("NULL%s", get_comma(last
));
1149 gemu_log("0x" TARGET_ABI_FMT_lx
"%s", p
, get_comma(last
));
1153 * Reads 32-bit (int) number from guest address space from
1154 * address 'addr' and prints it.
1157 print_number(abi_long addr
, int last
)
1160 gemu_log("NULL%s", get_comma(last
));
1164 get_user_s32(num
, addr
);
1165 gemu_log("[%d]%s", num
, get_comma(last
));
1170 print_timeval(abi_ulong tv_addr
, int last
)
1173 struct target_timeval
*tv
;
1175 tv
= lock_user(VERIFY_READ
, tv_addr
, sizeof(*tv
), 1);
1178 gemu_log("{" TARGET_ABI_FMT_ld
"," TARGET_ABI_FMT_ld
"}%s",
1179 tswapal(tv
->tv_sec
), tswapal(tv
->tv_usec
), get_comma(last
));
1180 unlock_user(tv
, tv_addr
, 0);
1182 gemu_log("NULL%s", get_comma(last
));
1187 #ifdef TARGET_NR_accept
1189 print_accept(const struct syscallname
*name
,
1190 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1191 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1193 print_syscall_prologue(name
);
1194 print_raw_param("%d", arg0
, 0);
1195 print_pointer(arg1
, 0);
1196 print_number(arg2
, 1);
1197 print_syscall_epilogue(name
);
1201 #ifdef TARGET_NR_access
1203 print_access(const struct syscallname
*name
,
1204 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1205 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1207 print_syscall_prologue(name
);
1208 print_string(arg0
, 0);
1209 print_flags(access_flags
, arg1
, 1);
1210 print_syscall_epilogue(name
);
1214 #ifdef TARGET_NR_brk
1216 print_brk(const struct syscallname
*name
,
1217 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1218 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1220 print_syscall_prologue(name
);
1221 print_pointer(arg0
, 1);
1222 print_syscall_epilogue(name
);
1226 #ifdef TARGET_NR_chdir
1228 print_chdir(const struct syscallname
*name
,
1229 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1230 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1232 print_syscall_prologue(name
);
1233 print_string(arg0
, 1);
1234 print_syscall_epilogue(name
);
1238 #ifdef TARGET_NR_chroot
1240 print_chroot(const struct syscallname
*name
,
1241 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1242 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1244 print_syscall_prologue(name
);
1245 print_string(arg0
, 1);
1246 print_syscall_epilogue(name
);
1250 #ifdef TARGET_NR_chmod
1252 print_chmod(const struct syscallname
*name
,
1253 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1254 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1256 print_syscall_prologue(name
);
1257 print_string(arg0
, 0);
1258 print_file_mode(arg1
, 1);
1259 print_syscall_epilogue(name
);
1263 #ifdef TARGET_NR_clock_adjtime
1265 print_clock_adjtime(const struct syscallname
*name
,
1266 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1267 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1269 print_syscall_prologue(name
);
1270 print_clockid(arg0
, 0);
1271 print_pointer(arg1
, 1);
1272 print_syscall_epilogue(name
);
1276 #ifdef TARGET_NR_clone
1277 static void do_print_clone(unsigned int flags
, abi_ulong newsp
,
1278 abi_ulong parent_tidptr
, target_ulong newtls
,
1279 abi_ulong child_tidptr
)
1281 print_flags(clone_flags
, flags
, 0);
1282 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx
, newsp
, 0);
1283 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx
, parent_tidptr
, 0);
1284 print_raw_param("tls=0x" TARGET_ABI_FMT_lx
, newtls
, 0);
1285 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx
, child_tidptr
, 1);
1289 print_clone(const struct syscallname
*name
,
1290 abi_long arg1
, abi_long arg2
, abi_long arg3
,
1291 abi_long arg4
, abi_long arg5
, abi_long arg6
)
1293 print_syscall_prologue(name
);
1294 #if defined(TARGET_MICROBLAZE)
1295 do_print_clone(arg1
, arg2
, arg4
, arg6
, arg5
);
1296 #elif defined(TARGET_CLONE_BACKWARDS)
1297 do_print_clone(arg1
, arg2
, arg3
, arg4
, arg5
);
1298 #elif defined(TARGET_CLONE_BACKWARDS2)
1299 do_print_clone(arg2
, arg1
, arg3
, arg5
, arg4
);
1301 do_print_clone(arg1
, arg2
, arg3
, arg5
, arg4
);
1303 print_syscall_epilogue(name
);
1307 #ifdef TARGET_NR_creat
1309 print_creat(const struct syscallname
*name
,
1310 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1311 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1313 print_syscall_prologue(name
);
1314 print_string(arg0
, 0);
1315 print_file_mode(arg1
, 1);
1316 print_syscall_epilogue(name
);
1320 #ifdef TARGET_NR_execv
1322 print_execv(const struct syscallname
*name
,
1323 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1324 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1326 print_syscall_prologue(name
);
1327 print_string(arg0
, 0);
1328 print_raw_param("0x" TARGET_ABI_FMT_lx
, arg1
, 1);
1329 print_syscall_epilogue(name
);
1333 #ifdef TARGET_NR_faccessat
1335 print_faccessat(const struct syscallname
*name
,
1336 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1337 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1339 print_syscall_prologue(name
);
1340 print_at_dirfd(arg0
, 0);
1341 print_string(arg1
, 0);
1342 print_flags(access_flags
, arg2
, 0);
1343 print_flags(at_file_flags
, arg3
, 1);
1344 print_syscall_epilogue(name
);
1348 #ifdef TARGET_NR_fchmodat
1350 print_fchmodat(const struct syscallname
*name
,
1351 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1352 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1354 print_syscall_prologue(name
);
1355 print_at_dirfd(arg0
, 0);
1356 print_string(arg1
, 0);
1357 print_file_mode(arg2
, 0);
1358 print_flags(at_file_flags
, arg3
, 1);
1359 print_syscall_epilogue(name
);
1363 #ifdef TARGET_NR_fchownat
1365 print_fchownat(const struct syscallname
*name
,
1366 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1367 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1369 print_syscall_prologue(name
);
1370 print_at_dirfd(arg0
, 0);
1371 print_string(arg1
, 0);
1372 print_raw_param("%d", arg2
, 0);
1373 print_raw_param("%d", arg3
, 0);
1374 print_flags(at_file_flags
, arg4
, 1);
1375 print_syscall_epilogue(name
);
1379 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1381 print_fcntl(const struct syscallname
*name
,
1382 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1383 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1385 print_syscall_prologue(name
);
1386 print_raw_param("%d", arg0
, 0);
1388 case TARGET_F_DUPFD
:
1389 gemu_log("F_DUPFD,");
1390 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1392 case TARGET_F_GETFD
:
1393 gemu_log("F_GETFD");
1395 case TARGET_F_SETFD
:
1396 gemu_log("F_SETFD,");
1397 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1399 case TARGET_F_GETFL
:
1400 gemu_log("F_GETFL");
1402 case TARGET_F_SETFL
:
1403 gemu_log("F_SETFL,");
1404 print_open_flags(arg2
, 1);
1406 case TARGET_F_GETLK
:
1407 gemu_log("F_GETLK,");
1408 print_pointer(arg2
, 1);
1410 case TARGET_F_SETLK
:
1411 gemu_log("F_SETLK,");
1412 print_pointer(arg2
, 1);
1414 case TARGET_F_SETLKW
:
1415 gemu_log("F_SETLKW,");
1416 print_pointer(arg2
, 1);
1418 case TARGET_F_GETOWN
:
1419 gemu_log("F_GETOWN");
1421 case TARGET_F_SETOWN
:
1422 gemu_log("F_SETOWN,");
1423 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1425 case TARGET_F_GETSIG
:
1426 gemu_log("F_GETSIG");
1428 case TARGET_F_SETSIG
:
1429 gemu_log("F_SETSIG,");
1430 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1432 #if TARGET_ABI_BITS == 32
1433 case TARGET_F_GETLK64
:
1434 gemu_log("F_GETLK64,");
1435 print_pointer(arg2
, 1);
1437 case TARGET_F_SETLK64
:
1438 gemu_log("F_SETLK64,");
1439 print_pointer(arg2
, 1);
1441 case TARGET_F_SETLKW64
:
1442 gemu_log("F_SETLKW64,");
1443 print_pointer(arg2
, 1);
1446 case TARGET_F_SETLEASE
:
1447 gemu_log("F_SETLEASE,");
1448 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1450 case TARGET_F_GETLEASE
:
1451 gemu_log("F_GETLEASE");
1453 case TARGET_F_SETPIPE_SZ
:
1454 gemu_log("F_SETPIPE_SZ,");
1455 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1457 case TARGET_F_GETPIPE_SZ
:
1458 gemu_log("F_GETPIPE_SZ");
1460 case TARGET_F_DUPFD_CLOEXEC
:
1461 gemu_log("F_DUPFD_CLOEXEC,");
1462 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 1);
1464 case TARGET_F_NOTIFY
:
1465 gemu_log("F_NOTIFY,");
1466 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1469 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1470 print_pointer(arg2
, 1);
1473 print_syscall_epilogue(name
);
1475 #define print_fcntl64 print_fcntl
1479 #ifdef TARGET_NR_futimesat
1481 print_futimesat(const struct syscallname
*name
,
1482 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1483 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1485 print_syscall_prologue(name
);
1486 print_at_dirfd(arg0
, 0);
1487 print_string(arg1
, 0);
1488 print_timeval(arg2
, 0);
1489 print_timeval(arg2
+ sizeof (struct target_timeval
), 1);
1490 print_syscall_epilogue(name
);
1494 #ifdef TARGET_NR_link
1496 print_link(const struct syscallname
*name
,
1497 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1498 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1500 print_syscall_prologue(name
);
1501 print_string(arg0
, 0);
1502 print_string(arg1
, 1);
1503 print_syscall_epilogue(name
);
1507 #ifdef TARGET_NR_linkat
1509 print_linkat(const struct syscallname
*name
,
1510 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1511 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1513 print_syscall_prologue(name
);
1514 print_at_dirfd(arg0
, 0);
1515 print_string(arg1
, 0);
1516 print_at_dirfd(arg2
, 0);
1517 print_string(arg3
, 0);
1518 print_flags(at_file_flags
, arg4
, 1);
1519 print_syscall_epilogue(name
);
1523 #ifdef TARGET_NR__llseek
1525 print__llseek(const struct syscallname
*name
,
1526 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1527 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1529 const char *whence
= "UNKNOWN";
1530 print_syscall_prologue(name
);
1531 print_raw_param("%d", arg0
, 0);
1532 print_raw_param("%ld", arg1
, 0);
1533 print_raw_param("%ld", arg2
, 0);
1534 print_pointer(arg3
, 0);
1536 case SEEK_SET
: whence
= "SEEK_SET"; break;
1537 case SEEK_CUR
: whence
= "SEEK_CUR"; break;
1538 case SEEK_END
: whence
= "SEEK_END"; break;
1540 gemu_log("%s",whence
);
1541 print_syscall_epilogue(name
);
1545 #if defined(TARGET_NR_socket)
1547 print_socket(const struct syscallname
*name
,
1548 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1549 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1551 abi_ulong domain
= arg0
, type
= arg1
, protocol
= arg2
;
1553 print_syscall_prologue(name
);
1554 print_socket_domain(domain
);
1556 print_socket_type(type
);
1558 if (domain
== AF_PACKET
||
1559 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1560 protocol
= tswap16(protocol
);
1562 print_socket_protocol(domain
, type
, protocol
);
1563 print_syscall_epilogue(name
);
1568 #if defined(TARGET_NR_socketcall)
1570 #define get_user_ualx(x, gaddr, idx) \
1571 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1573 static void do_print_socket(const char *name
, abi_long arg1
)
1575 abi_ulong domain
, type
, protocol
;
1577 get_user_ualx(domain
, arg1
, 0);
1578 get_user_ualx(type
, arg1
, 1);
1579 get_user_ualx(protocol
, arg1
, 2);
1580 gemu_log("%s(", name
);
1581 print_socket_domain(domain
);
1583 print_socket_type(type
);
1585 if (domain
== AF_PACKET
||
1586 (domain
== AF_INET
&& type
== TARGET_SOCK_PACKET
)) {
1587 protocol
= tswap16(protocol
);
1589 print_socket_protocol(domain
, type
, protocol
);
1593 static void do_print_sockaddr(const char *name
, abi_long arg1
)
1595 abi_ulong sockfd
, addr
, addrlen
;
1597 get_user_ualx(sockfd
, arg1
, 0);
1598 get_user_ualx(addr
, arg1
, 1);
1599 get_user_ualx(addrlen
, arg1
, 2);
1601 gemu_log("%s(", name
);
1602 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1603 print_sockaddr(addr
, addrlen
);
1607 static void do_print_listen(const char *name
, abi_long arg1
)
1609 abi_ulong sockfd
, backlog
;
1611 get_user_ualx(sockfd
, arg1
, 0);
1612 get_user_ualx(backlog
, arg1
, 1);
1614 gemu_log("%s(", name
);
1615 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1616 print_raw_param(TARGET_ABI_FMT_ld
, backlog
, 1);
1620 static void do_print_socketpair(const char *name
, abi_long arg1
)
1622 abi_ulong domain
, type
, protocol
, tab
;
1624 get_user_ualx(domain
, arg1
, 0);
1625 get_user_ualx(type
, arg1
, 1);
1626 get_user_ualx(protocol
, arg1
, 2);
1627 get_user_ualx(tab
, arg1
, 3);
1629 gemu_log("%s(", name
);
1630 print_socket_domain(domain
);
1632 print_socket_type(type
);
1634 print_socket_protocol(domain
, type
, protocol
);
1636 print_raw_param(TARGET_ABI_FMT_lx
, tab
, 1);
1640 static void do_print_sendrecv(const char *name
, abi_long arg1
)
1642 abi_ulong sockfd
, msg
, len
, flags
;
1644 get_user_ualx(sockfd
, arg1
, 0);
1645 get_user_ualx(msg
, arg1
, 1);
1646 get_user_ualx(len
, arg1
, 2);
1647 get_user_ualx(flags
, arg1
, 3);
1649 gemu_log("%s(", name
);
1650 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1651 print_buf(msg
, len
, 0);
1652 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1653 print_flags(msg_flags
, flags
, 1);
1657 static void do_print_msgaddr(const char *name
, abi_long arg1
)
1659 abi_ulong sockfd
, msg
, len
, flags
, addr
, addrlen
;
1661 get_user_ualx(sockfd
, arg1
, 0);
1662 get_user_ualx(msg
, arg1
, 1);
1663 get_user_ualx(len
, arg1
, 2);
1664 get_user_ualx(flags
, arg1
, 3);
1665 get_user_ualx(addr
, arg1
, 4);
1666 get_user_ualx(addrlen
, arg1
, 5);
1668 gemu_log("%s(", name
);
1669 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1670 print_buf(msg
, len
, 0);
1671 print_raw_param(TARGET_ABI_FMT_ld
, len
, 0);
1672 print_flags(msg_flags
, flags
, 0);
1673 print_sockaddr(addr
, addrlen
);
1677 static void do_print_shutdown(const char *name
, abi_long arg1
)
1679 abi_ulong sockfd
, how
;
1681 get_user_ualx(sockfd
, arg1
, 0);
1682 get_user_ualx(how
, arg1
, 1);
1684 gemu_log("shutdown(");
1685 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1688 gemu_log("SHUT_RD");
1691 gemu_log("SHUT_WR");
1694 gemu_log("SHUT_RDWR");
1697 print_raw_param(TARGET_ABI_FMT_ld
, how
, 1);
1703 static void do_print_msg(const char *name
, abi_long arg1
)
1705 abi_ulong sockfd
, msg
, flags
;
1707 get_user_ualx(sockfd
, arg1
, 0);
1708 get_user_ualx(msg
, arg1
, 1);
1709 get_user_ualx(flags
, arg1
, 2);
1711 gemu_log("%s(", name
);
1712 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1713 print_pointer(msg
, 0);
1714 print_flags(msg_flags
, flags
, 1);
1718 static void do_print_sockopt(const char *name
, abi_long arg1
)
1720 abi_ulong sockfd
, level
, optname
, optval
, optlen
;
1722 get_user_ualx(sockfd
, arg1
, 0);
1723 get_user_ualx(level
, arg1
, 1);
1724 get_user_ualx(optname
, arg1
, 2);
1725 get_user_ualx(optval
, arg1
, 3);
1726 get_user_ualx(optlen
, arg1
, 4);
1728 gemu_log("%s(", name
);
1729 print_raw_param(TARGET_ABI_FMT_ld
, sockfd
, 0);
1732 gemu_log("SOL_TCP,");
1733 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1734 print_pointer(optval
, 0);
1737 gemu_log("SOL_IP,");
1738 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1739 print_pointer(optval
, 0);
1742 gemu_log("SOL_RAW,");
1743 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1744 print_pointer(optval
, 0);
1746 case TARGET_SOL_SOCKET
:
1747 gemu_log("SOL_SOCKET,");
1749 case TARGET_SO_DEBUG
:
1750 gemu_log("SO_DEBUG,");
1752 print_number(optval
, 0);
1754 case TARGET_SO_REUSEADDR
:
1755 gemu_log("SO_REUSEADDR,");
1757 case TARGET_SO_REUSEPORT
:
1758 gemu_log("SO_REUSEPORT,");
1760 case TARGET_SO_TYPE
:
1761 gemu_log("SO_TYPE,");
1763 case TARGET_SO_ERROR
:
1764 gemu_log("SO_ERROR,");
1766 case TARGET_SO_DONTROUTE
:
1767 gemu_log("SO_DONTROUTE,");
1769 case TARGET_SO_BROADCAST
:
1770 gemu_log("SO_BROADCAST,");
1772 case TARGET_SO_SNDBUF
:
1773 gemu_log("SO_SNDBUF,");
1775 case TARGET_SO_RCVBUF
:
1776 gemu_log("SO_RCVBUF,");
1778 case TARGET_SO_KEEPALIVE
:
1779 gemu_log("SO_KEEPALIVE,");
1781 case TARGET_SO_OOBINLINE
:
1782 gemu_log("SO_OOBINLINE,");
1784 case TARGET_SO_NO_CHECK
:
1785 gemu_log("SO_NO_CHECK,");
1787 case TARGET_SO_PRIORITY
:
1788 gemu_log("SO_PRIORITY,");
1790 case TARGET_SO_BSDCOMPAT
:
1791 gemu_log("SO_BSDCOMPAT,");
1793 case TARGET_SO_PASSCRED
:
1794 gemu_log("SO_PASSCRED,");
1796 case TARGET_SO_TIMESTAMP
:
1797 gemu_log("SO_TIMESTAMP,");
1799 case TARGET_SO_RCVLOWAT
:
1800 gemu_log("SO_RCVLOWAT,");
1802 case TARGET_SO_RCVTIMEO
:
1803 gemu_log("SO_RCVTIMEO,");
1804 print_timeval(optval
, 0);
1806 case TARGET_SO_SNDTIMEO
:
1807 gemu_log("SO_SNDTIMEO,");
1808 print_timeval(optval
, 0);
1810 case TARGET_SO_ATTACH_FILTER
: {
1811 struct target_sock_fprog
*fprog
;
1813 gemu_log("SO_ATTACH_FILTER,");
1815 if (lock_user_struct(VERIFY_READ
, fprog
, optval
, 0)) {
1816 struct target_sock_filter
*filter
;
1818 if (lock_user_struct(VERIFY_READ
, filter
,
1819 tswapal(fprog
->filter
), 0)) {
1821 for (i
= 0; i
< tswap16(fprog
->len
) - 1; i
++) {
1822 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1823 i
, tswap16(filter
[i
].code
),
1824 filter
[i
].jt
, filter
[i
].jf
,
1825 tswap32(filter
[i
].k
));
1827 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1828 i
, tswap16(filter
[i
].code
),
1829 filter
[i
].jt
, filter
[i
].jf
,
1830 tswap32(filter
[i
].k
));
1832 gemu_log(TARGET_ABI_FMT_lx
, tswapal(fprog
->filter
));
1834 gemu_log(",%d},", tswap16(fprog
->len
));
1835 unlock_user(fprog
, optval
, 0);
1837 print_pointer(optval
, 0);
1842 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1843 print_pointer(optval
, 0);
1848 print_raw_param(TARGET_ABI_FMT_ld
, level
, 0);
1849 print_raw_param(TARGET_ABI_FMT_ld
, optname
, 0);
1850 print_pointer(optval
, 0);
1853 print_raw_param(TARGET_ABI_FMT_ld
, optlen
, 1);
1857 #define PRINT_SOCKOP(name, func) \
1858 [TARGET_SYS_##name] = { #name, func }
1862 void (*print
)(const char *, abi_long
);
1864 PRINT_SOCKOP(SOCKET
, do_print_socket
),
1865 PRINT_SOCKOP(BIND
, do_print_sockaddr
),
1866 PRINT_SOCKOP(CONNECT
, do_print_sockaddr
),
1867 PRINT_SOCKOP(LISTEN
, do_print_listen
),
1868 PRINT_SOCKOP(ACCEPT
, do_print_sockaddr
),
1869 PRINT_SOCKOP(GETSOCKNAME
, do_print_sockaddr
),
1870 PRINT_SOCKOP(GETPEERNAME
, do_print_sockaddr
),
1871 PRINT_SOCKOP(SOCKETPAIR
, do_print_socketpair
),
1872 PRINT_SOCKOP(SEND
, do_print_sendrecv
),
1873 PRINT_SOCKOP(RECV
, do_print_sendrecv
),
1874 PRINT_SOCKOP(SENDTO
, do_print_msgaddr
),
1875 PRINT_SOCKOP(RECVFROM
, do_print_msgaddr
),
1876 PRINT_SOCKOP(SHUTDOWN
, do_print_shutdown
),
1877 PRINT_SOCKOP(SETSOCKOPT
, do_print_sockopt
),
1878 PRINT_SOCKOP(GETSOCKOPT
, do_print_sockopt
),
1879 PRINT_SOCKOP(SENDMSG
, do_print_msg
),
1880 PRINT_SOCKOP(RECVMSG
, do_print_msg
),
1881 PRINT_SOCKOP(ACCEPT4
, NULL
),
1882 PRINT_SOCKOP(RECVMMSG
, NULL
),
1883 PRINT_SOCKOP(SENDMMSG
, NULL
),
1887 print_socketcall(const struct syscallname
*name
,
1888 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1889 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1891 if (arg0
>= 0 && arg0
< ARRAY_SIZE(scall
) && scall
[arg0
].print
) {
1892 scall
[arg0
].print(scall
[arg0
].name
, arg1
);
1895 print_syscall_prologue(name
);
1896 print_raw_param(TARGET_ABI_FMT_ld
, arg0
, 0);
1897 print_raw_param(TARGET_ABI_FMT_ld
, arg1
, 0);
1898 print_raw_param(TARGET_ABI_FMT_ld
, arg2
, 0);
1899 print_raw_param(TARGET_ABI_FMT_ld
, arg3
, 0);
1900 print_raw_param(TARGET_ABI_FMT_ld
, arg4
, 0);
1901 print_raw_param(TARGET_ABI_FMT_ld
, arg5
, 0);
1902 print_syscall_epilogue(name
);
1906 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
1907 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
1909 print_stat(const struct syscallname
*name
,
1910 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1911 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1913 print_syscall_prologue(name
);
1914 print_string(arg0
, 0);
1915 print_pointer(arg1
, 1);
1916 print_syscall_epilogue(name
);
1918 #define print_lstat print_stat
1919 #define print_stat64 print_stat
1920 #define print_lstat64 print_stat
1923 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
1925 print_fstat(const struct syscallname
*name
,
1926 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1927 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1929 print_syscall_prologue(name
);
1930 print_raw_param("%d", arg0
, 0);
1931 print_pointer(arg1
, 1);
1932 print_syscall_epilogue(name
);
1934 #define print_fstat64 print_fstat
1937 #ifdef TARGET_NR_mkdir
1939 print_mkdir(const struct syscallname
*name
,
1940 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1941 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1943 print_syscall_prologue(name
);
1944 print_string(arg0
, 0);
1945 print_file_mode(arg1
, 1);
1946 print_syscall_epilogue(name
);
1950 #ifdef TARGET_NR_mkdirat
1952 print_mkdirat(const struct syscallname
*name
,
1953 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1954 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1956 print_syscall_prologue(name
);
1957 print_at_dirfd(arg0
, 0);
1958 print_string(arg1
, 0);
1959 print_file_mode(arg2
, 1);
1960 print_syscall_epilogue(name
);
1964 #ifdef TARGET_NR_rmdir
1966 print_rmdir(const struct syscallname
*name
,
1967 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1968 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1970 print_syscall_prologue(name
);
1971 print_string(arg0
, 0);
1972 print_syscall_epilogue(name
);
1976 #ifdef TARGET_NR_rt_sigaction
1978 print_rt_sigaction(const struct syscallname
*name
,
1979 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1980 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1982 print_syscall_prologue(name
);
1983 print_signal(arg0
, 0);
1984 print_pointer(arg1
, 0);
1985 print_pointer(arg2
, 1);
1986 print_syscall_epilogue(name
);
1990 #ifdef TARGET_NR_rt_sigprocmask
1992 print_rt_sigprocmask(const struct syscallname
*name
,
1993 abi_long arg0
, abi_long arg1
, abi_long arg2
,
1994 abi_long arg3
, abi_long arg4
, abi_long arg5
)
1996 const char *how
= "UNKNOWN";
1997 print_syscall_prologue(name
);
1999 case TARGET_SIG_BLOCK
: how
= "SIG_BLOCK"; break;
2000 case TARGET_SIG_UNBLOCK
: how
= "SIG_UNBLOCK"; break;
2001 case TARGET_SIG_SETMASK
: how
= "SIG_SETMASK"; break;
2003 gemu_log("%s,",how
);
2004 print_pointer(arg1
, 0);
2005 print_pointer(arg2
, 1);
2006 print_syscall_epilogue(name
);
2010 #ifdef TARGET_NR_rt_sigqueueinfo
2012 print_rt_sigqueueinfo(const struct syscallname
*name
,
2013 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2014 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2017 target_siginfo_t uinfo
;
2019 print_syscall_prologue(name
);
2020 print_raw_param("%d", arg0
, 0);
2021 print_signal(arg1
, 0);
2022 p
= lock_user(VERIFY_READ
, arg2
, sizeof(target_siginfo_t
), 1);
2024 get_target_siginfo(&uinfo
, p
);
2025 print_siginfo(&uinfo
);
2027 unlock_user(p
, arg2
, 0);
2029 print_pointer(arg2
, 1);
2031 print_syscall_epilogue(name
);
2035 #ifdef TARGET_NR_rt_tgsigqueueinfo
2037 print_rt_tgsigqueueinfo(const struct syscallname
*name
,
2038 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2039 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2042 target_siginfo_t uinfo
;
2044 print_syscall_prologue(name
);
2045 print_raw_param("%d", arg0
, 0);
2046 print_raw_param("%d", arg1
, 0);
2047 print_signal(arg2
, 0);
2048 p
= lock_user(VERIFY_READ
, arg3
, sizeof(target_siginfo_t
), 1);
2050 get_target_siginfo(&uinfo
, p
);
2051 print_siginfo(&uinfo
);
2053 unlock_user(p
, arg3
, 0);
2055 print_pointer(arg3
, 1);
2057 print_syscall_epilogue(name
);
2061 #ifdef TARGET_NR_syslog
2063 print_syslog_action(abi_ulong arg
, int last
)
2068 case TARGET_SYSLOG_ACTION_CLOSE
: {
2069 type
= "SYSLOG_ACTION_CLOSE";
2072 case TARGET_SYSLOG_ACTION_OPEN
: {
2073 type
= "SYSLOG_ACTION_OPEN";
2076 case TARGET_SYSLOG_ACTION_READ
: {
2077 type
= "SYSLOG_ACTION_READ";
2080 case TARGET_SYSLOG_ACTION_READ_ALL
: {
2081 type
= "SYSLOG_ACTION_READ_ALL";
2084 case TARGET_SYSLOG_ACTION_READ_CLEAR
: {
2085 type
= "SYSLOG_ACTION_READ_CLEAR";
2088 case TARGET_SYSLOG_ACTION_CLEAR
: {
2089 type
= "SYSLOG_ACTION_CLEAR";
2092 case TARGET_SYSLOG_ACTION_CONSOLE_OFF
: {
2093 type
= "SYSLOG_ACTION_CONSOLE_OFF";
2096 case TARGET_SYSLOG_ACTION_CONSOLE_ON
: {
2097 type
= "SYSLOG_ACTION_CONSOLE_ON";
2100 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL
: {
2101 type
= "SYSLOG_ACTION_CONSOLE_LEVEL";
2104 case TARGET_SYSLOG_ACTION_SIZE_UNREAD
: {
2105 type
= "SYSLOG_ACTION_SIZE_UNREAD";
2108 case TARGET_SYSLOG_ACTION_SIZE_BUFFER
: {
2109 type
= "SYSLOG_ACTION_SIZE_BUFFER";
2113 print_raw_param("%ld", arg
, last
);
2117 gemu_log("%s%s", type
, get_comma(last
));
2121 print_syslog(const struct syscallname
*name
,
2122 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2123 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2125 print_syscall_prologue(name
);
2126 print_syslog_action(arg0
, 0);
2127 print_pointer(arg1
, 0);
2128 print_raw_param("%d", arg2
, 1);
2129 print_syscall_epilogue(name
);
2133 #ifdef TARGET_NR_mknod
2135 print_mknod(const struct syscallname
*name
,
2136 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2137 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2139 int hasdev
= (arg1
& (S_IFCHR
|S_IFBLK
));
2141 print_syscall_prologue(name
);
2142 print_string(arg0
, 0);
2143 print_file_mode(arg1
, (hasdev
== 0));
2145 print_raw_param("makedev(%d", major(arg2
), 0);
2146 print_raw_param("%d)", minor(arg2
), 1);
2148 print_syscall_epilogue(name
);
2152 #ifdef TARGET_NR_mknodat
2154 print_mknodat(const struct syscallname
*name
,
2155 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2156 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2158 int hasdev
= (arg2
& (S_IFCHR
|S_IFBLK
));
2160 print_syscall_prologue(name
);
2161 print_at_dirfd(arg0
, 0);
2162 print_string(arg1
, 0);
2163 print_file_mode(arg2
, (hasdev
== 0));
2165 print_raw_param("makedev(%d", major(arg3
), 0);
2166 print_raw_param("%d)", minor(arg3
), 1);
2168 print_syscall_epilogue(name
);
2172 #ifdef TARGET_NR_mq_open
2174 print_mq_open(const struct syscallname
*name
,
2175 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2176 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2178 int is_creat
= (arg1
& TARGET_O_CREAT
);
2180 print_syscall_prologue(name
);
2181 print_string(arg0
, 0);
2182 print_open_flags(arg1
, (is_creat
== 0));
2184 print_file_mode(arg2
, 0);
2185 print_pointer(arg3
, 1);
2187 print_syscall_epilogue(name
);
2191 #ifdef TARGET_NR_open
2193 print_open(const struct syscallname
*name
,
2194 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2195 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2197 int is_creat
= (arg1
& TARGET_O_CREAT
);
2199 print_syscall_prologue(name
);
2200 print_string(arg0
, 0);
2201 print_open_flags(arg1
, (is_creat
== 0));
2203 print_file_mode(arg2
, 1);
2204 print_syscall_epilogue(name
);
2208 #ifdef TARGET_NR_openat
2210 print_openat(const struct syscallname
*name
,
2211 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2212 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2214 int is_creat
= (arg2
& TARGET_O_CREAT
);
2216 print_syscall_prologue(name
);
2217 print_at_dirfd(arg0
, 0);
2218 print_string(arg1
, 0);
2219 print_open_flags(arg2
, (is_creat
== 0));
2221 print_file_mode(arg3
, 1);
2222 print_syscall_epilogue(name
);
2226 #ifdef TARGET_NR_mq_unlink
2228 print_mq_unlink(const struct syscallname
*name
,
2229 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2230 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2232 print_syscall_prologue(name
);
2233 print_string(arg0
, 1);
2234 print_syscall_epilogue(name
);
2238 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2240 print_fstatat64(const struct syscallname
*name
,
2241 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2242 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2244 print_syscall_prologue(name
);
2245 print_at_dirfd(arg0
, 0);
2246 print_string(arg1
, 0);
2247 print_pointer(arg2
, 0);
2248 print_flags(at_file_flags
, arg3
, 1);
2249 print_syscall_epilogue(name
);
2251 #define print_newfstatat print_fstatat64
2254 #ifdef TARGET_NR_readlink
2256 print_readlink(const struct syscallname
*name
,
2257 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2258 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2260 print_syscall_prologue(name
);
2261 print_string(arg0
, 0);
2262 print_pointer(arg1
, 0);
2263 print_raw_param("%u", arg2
, 1);
2264 print_syscall_epilogue(name
);
2268 #ifdef TARGET_NR_readlinkat
2270 print_readlinkat(const struct syscallname
*name
,
2271 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2272 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2274 print_syscall_prologue(name
);
2275 print_at_dirfd(arg0
, 0);
2276 print_string(arg1
, 0);
2277 print_pointer(arg2
, 0);
2278 print_raw_param("%u", arg3
, 1);
2279 print_syscall_epilogue(name
);
2283 #ifdef TARGET_NR_rename
2285 print_rename(const struct syscallname
*name
,
2286 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2287 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2289 print_syscall_prologue(name
);
2290 print_string(arg0
, 0);
2291 print_string(arg1
, 1);
2292 print_syscall_epilogue(name
);
2296 #ifdef TARGET_NR_renameat
2298 print_renameat(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_at_dirfd(arg0
, 0);
2304 print_string(arg1
, 0);
2305 print_at_dirfd(arg2
, 0);
2306 print_string(arg3
, 1);
2307 print_syscall_epilogue(name
);
2311 #ifdef TARGET_NR_statfs
2313 print_statfs(const struct syscallname
*name
,
2314 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2315 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2317 print_syscall_prologue(name
);
2318 print_string(arg0
, 0);
2319 print_pointer(arg1
, 1);
2320 print_syscall_epilogue(name
);
2324 #ifdef TARGET_NR_statfs64
2326 print_statfs64(const struct syscallname
*name
,
2327 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2328 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2330 print_syscall_prologue(name
);
2331 print_string(arg0
, 0);
2332 print_pointer(arg1
, 1);
2333 print_syscall_epilogue(name
);
2337 #ifdef TARGET_NR_symlink
2339 print_symlink(const struct syscallname
*name
,
2340 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2341 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2343 print_syscall_prologue(name
);
2344 print_string(arg0
, 0);
2345 print_string(arg1
, 1);
2346 print_syscall_epilogue(name
);
2350 #ifdef TARGET_NR_symlinkat
2352 print_symlinkat(const struct syscallname
*name
,
2353 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2354 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2356 print_syscall_prologue(name
);
2357 print_string(arg0
, 0);
2358 print_at_dirfd(arg1
, 0);
2359 print_string(arg2
, 1);
2360 print_syscall_epilogue(name
);
2364 #ifdef TARGET_NR_mount
2366 print_mount(const struct syscallname
*name
,
2367 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2368 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2370 print_syscall_prologue(name
);
2371 print_string(arg0
, 0);
2372 print_string(arg1
, 0);
2373 print_string(arg2
, 0);
2374 print_flags(mount_flags
, arg3
, 0);
2375 print_pointer(arg4
, 1);
2376 print_syscall_epilogue(name
);
2380 #ifdef TARGET_NR_umount
2382 print_umount(const struct syscallname
*name
,
2383 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2384 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2386 print_syscall_prologue(name
);
2387 print_string(arg0
, 1);
2388 print_syscall_epilogue(name
);
2392 #ifdef TARGET_NR_umount2
2394 print_umount2(const struct syscallname
*name
,
2395 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2396 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2398 print_syscall_prologue(name
);
2399 print_string(arg0
, 0);
2400 print_flags(umount2_flags
, arg1
, 1);
2401 print_syscall_epilogue(name
);
2405 #ifdef TARGET_NR_unlink
2407 print_unlink(const struct syscallname
*name
,
2408 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2409 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2411 print_syscall_prologue(name
);
2412 print_string(arg0
, 1);
2413 print_syscall_epilogue(name
);
2417 #ifdef TARGET_NR_unlinkat
2419 print_unlinkat(const struct syscallname
*name
,
2420 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2421 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2423 print_syscall_prologue(name
);
2424 print_at_dirfd(arg0
, 0);
2425 print_string(arg1
, 0);
2426 print_flags(unlinkat_flags
, arg2
, 1);
2427 print_syscall_epilogue(name
);
2431 #ifdef TARGET_NR_utime
2433 print_utime(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
, 1);
2440 print_syscall_epilogue(name
);
2444 #ifdef TARGET_NR_utimes
2446 print_utimes(const struct syscallname
*name
,
2447 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2448 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2450 print_syscall_prologue(name
);
2451 print_string(arg0
, 0);
2452 print_pointer(arg1
, 1);
2453 print_syscall_epilogue(name
);
2457 #ifdef TARGET_NR_utimensat
2459 print_utimensat(const struct syscallname
*name
,
2460 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2461 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2463 print_syscall_prologue(name
);
2464 print_at_dirfd(arg0
, 0);
2465 print_string(arg1
, 0);
2466 print_pointer(arg2
, 0);
2467 print_flags(at_file_flags
, arg3
, 1);
2468 print_syscall_epilogue(name
);
2472 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2474 print_mmap(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_pointer(arg0
, 0);
2480 print_raw_param("%d", arg1
, 0);
2481 print_flags(mmap_prot_flags
, arg2
, 0);
2482 print_flags(mmap_flags
, arg3
, 0);
2483 print_raw_param("%d", arg4
, 0);
2484 print_raw_param("%#x", arg5
, 1);
2485 print_syscall_epilogue(name
);
2487 #define print_mmap2 print_mmap
2490 #ifdef TARGET_NR_mprotect
2492 print_mprotect(const struct syscallname
*name
,
2493 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2494 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2496 print_syscall_prologue(name
);
2497 print_pointer(arg0
, 0);
2498 print_raw_param("%d", arg1
, 0);
2499 print_flags(mmap_prot_flags
, arg2
, 1);
2500 print_syscall_epilogue(name
);
2504 #ifdef TARGET_NR_munmap
2506 print_munmap(const struct syscallname
*name
,
2507 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2508 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2510 print_syscall_prologue(name
);
2511 print_pointer(arg0
, 0);
2512 print_raw_param("%d", arg1
, 1);
2513 print_syscall_epilogue(name
);
2517 #ifdef TARGET_NR_futex
2518 static void print_futex_op(abi_long tflag
, int last
)
2520 #define print_op(val) \
2521 if( cmd == val ) { \
2526 int cmd
= (int)tflag
;
2527 #ifdef FUTEX_PRIVATE_FLAG
2528 if (cmd
& FUTEX_PRIVATE_FLAG
) {
2529 gemu_log("FUTEX_PRIVATE_FLAG|");
2530 cmd
&= ~FUTEX_PRIVATE_FLAG
;
2533 #ifdef FUTEX_CLOCK_REALTIME
2534 if (cmd
& FUTEX_CLOCK_REALTIME
) {
2535 gemu_log("FUTEX_CLOCK_REALTIME|");
2536 cmd
&= ~FUTEX_CLOCK_REALTIME
;
2539 print_op(FUTEX_WAIT
)
2540 print_op(FUTEX_WAKE
)
2542 print_op(FUTEX_REQUEUE
)
2543 print_op(FUTEX_CMP_REQUEUE
)
2544 print_op(FUTEX_WAKE_OP
)
2545 print_op(FUTEX_LOCK_PI
)
2546 print_op(FUTEX_UNLOCK_PI
)
2547 print_op(FUTEX_TRYLOCK_PI
)
2548 #ifdef FUTEX_WAIT_BITSET
2549 print_op(FUTEX_WAIT_BITSET
)
2551 #ifdef FUTEX_WAKE_BITSET
2552 print_op(FUTEX_WAKE_BITSET
)
2554 /* unknown values */
2559 print_futex(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_pointer(arg0
, 0);
2565 print_futex_op(arg1
, 0);
2566 print_raw_param(",%d", arg2
, 0);
2567 print_pointer(arg3
, 0); /* struct timespec */
2568 print_pointer(arg4
, 0);
2569 print_raw_param("%d", arg4
, 1);
2570 print_syscall_epilogue(name
);
2574 #ifdef TARGET_NR_kill
2576 print_kill(const struct syscallname
*name
,
2577 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2578 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2580 print_syscall_prologue(name
);
2581 print_raw_param("%d", arg0
, 0);
2582 print_signal(arg1
, 1);
2583 print_syscall_epilogue(name
);
2587 #ifdef TARGET_NR_tkill
2589 print_tkill(const struct syscallname
*name
,
2590 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2591 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2593 print_syscall_prologue(name
);
2594 print_raw_param("%d", arg0
, 0);
2595 print_signal(arg1
, 1);
2596 print_syscall_epilogue(name
);
2600 #ifdef TARGET_NR_tgkill
2602 print_tgkill(const struct syscallname
*name
,
2603 abi_long arg0
, abi_long arg1
, abi_long arg2
,
2604 abi_long arg3
, abi_long arg4
, abi_long arg5
)
2606 print_syscall_prologue(name
);
2607 print_raw_param("%d", arg0
, 0);
2608 print_raw_param("%d", arg1
, 0);
2609 print_signal(arg2
, 1);
2610 print_syscall_epilogue(name
);
2615 * An array of all of the syscalls we know about
2618 static const struct syscallname scnames
[] = {
2619 #include "strace.list"
2622 static int nsyscalls
= ARRAY_SIZE(scnames
);
2625 * The public interface to this module.
2628 print_syscall(int num
,
2629 abi_long arg1
, abi_long arg2
, abi_long arg3
,
2630 abi_long arg4
, abi_long arg5
, abi_long arg6
)
2633 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
")";
2635 gemu_log("%d ", getpid() );
2637 for(i
=0;i
<nsyscalls
;i
++)
2638 if( scnames
[i
].nr
== num
) {
2639 if( scnames
[i
].call
!= NULL
) {
2640 scnames
[i
].call(&scnames
[i
],arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2642 /* XXX: this format system is broken because it uses
2643 host types and host pointers for strings */
2644 if( scnames
[i
].format
!= NULL
)
2645 format
= scnames
[i
].format
;
2646 gemu_log(format
,scnames
[i
].name
, arg1
,arg2
,arg3
,arg4
,arg5
,arg6
);
2650 gemu_log("Unknown syscall %d\n", num
);
2655 print_syscall_ret(int num
, abi_long ret
)
2658 const char *errstr
= NULL
;
2660 for(i
=0;i
<nsyscalls
;i
++)
2661 if( scnames
[i
].nr
== num
) {
2662 if( scnames
[i
].result
!= NULL
) {
2663 scnames
[i
].result(&scnames
[i
],ret
);
2666 errstr
= target_strerror(-ret
);
2669 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld
" (%s)\n",
2672 gemu_log(" = " TARGET_ABI_FMT_ld
"\n", ret
);
2679 void print_taken_signal(int target_signum
, const target_siginfo_t
*tinfo
)
2681 /* Print the strace output for a signal being taken:
2682 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2685 print_signal(target_signum
, 1);
2687 print_siginfo(tinfo
);