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_settimeofday
1588 print_settimeofday(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_timeval(arg0, 0);
1594 print_timezone(arg1, 1);
1595 print_syscall_epilogue(name);
1599 #ifdef TARGET_NR_link
1601 print_link(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_string(arg0, 0);
1607 print_string(arg1, 1);
1608 print_syscall_epilogue(name);
1612 #ifdef TARGET_NR_linkat
1614 print_linkat(const struct syscallname *name,
1615 abi_long arg0, abi_long arg1, abi_long arg2,
1616 abi_long arg3, abi_long arg4, abi_long arg5)
1618 print_syscall_prologue(name);
1619 print_at_dirfd(arg0, 0);
1620 print_string(arg1, 0);
1621 print_at_dirfd(arg2, 0);
1622 print_string(arg3, 0);
1623 print_flags(at_file_flags, arg4, 1);
1624 print_syscall_epilogue(name);
1628 #ifdef TARGET_NR__llseek
1630 print__llseek(const struct syscallname *name,
1631 abi_long arg0, abi_long arg1, abi_long arg2,
1632 abi_long arg3, abi_long arg4, abi_long arg5)
1634 const char *whence = "UNKNOWN";
1635 print_syscall_prologue(name);
1636 print_raw_param("%d", arg0, 0);
1637 print_raw_param("%ld", arg1, 0);
1638 print_raw_param("%ld", arg2, 0);
1639 print_pointer(arg3, 0);
1641 case SEEK_SET: whence = "SEEK_SET"; break;
1642 case SEEK_CUR: whence = "SEEK_CUR"; break;
1643 case SEEK_END: whence = "SEEK_END"; break;
1645 gemu_log("%s",whence);
1646 print_syscall_epilogue(name);
1650 #if defined(TARGET_NR_socket)
1652 print_socket(const struct syscallname *name,
1653 abi_long arg0, abi_long arg1, abi_long arg2,
1654 abi_long arg3, abi_long arg4, abi_long arg5)
1656 abi_ulong domain = arg0, type = arg1, protocol = arg2;
1658 print_syscall_prologue(name);
1659 print_socket_domain(domain);
1661 print_socket_type(type);
1663 if (domain == AF_PACKET ||
1664 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
1665 protocol = tswap16(protocol);
1667 print_socket_protocol(domain, type, protocol);
1668 print_syscall_epilogue(name);
1673 #if defined(TARGET_NR_socketcall)
1675 #define get_user_ualx(x, gaddr, idx) \
1676 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
1678 static void do_print_socket(const char *name, abi_long arg1)
1680 abi_ulong domain, type, protocol;
1682 get_user_ualx(domain, arg1, 0);
1683 get_user_ualx(type, arg1, 1);
1684 get_user_ualx(protocol, arg1, 2);
1685 gemu_log("%s(", name);
1686 print_socket_domain(domain);
1688 print_socket_type(type);
1690 if (domain == AF_PACKET ||
1691 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
1692 protocol = tswap16(protocol);
1694 print_socket_protocol(domain, type, protocol);
1698 static void do_print_sockaddr(const char *name, abi_long arg1)
1700 abi_ulong sockfd, addr, addrlen;
1702 get_user_ualx(sockfd, arg1, 0);
1703 get_user_ualx(addr, arg1, 1);
1704 get_user_ualx(addrlen, arg1, 2);
1706 gemu_log("%s(", name);
1707 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1708 print_sockaddr(addr, addrlen);
1712 static void do_print_listen(const char *name, abi_long arg1)
1714 abi_ulong sockfd, backlog;
1716 get_user_ualx(sockfd, arg1, 0);
1717 get_user_ualx(backlog, arg1, 1);
1719 gemu_log("%s(", name);
1720 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1721 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
1725 static void do_print_socketpair(const char *name, abi_long arg1)
1727 abi_ulong domain, type, protocol, tab;
1729 get_user_ualx(domain, arg1, 0);
1730 get_user_ualx(type, arg1, 1);
1731 get_user_ualx(protocol, arg1, 2);
1732 get_user_ualx(tab, arg1, 3);
1734 gemu_log("%s(", name);
1735 print_socket_domain(domain);
1737 print_socket_type(type);
1739 print_socket_protocol(domain, type, protocol);
1741 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
1745 static void do_print_sendrecv(const char *name, abi_long arg1)
1747 abi_ulong sockfd, msg, len, flags;
1749 get_user_ualx(sockfd, arg1, 0);
1750 get_user_ualx(msg, arg1, 1);
1751 get_user_ualx(len, arg1, 2);
1752 get_user_ualx(flags, arg1, 3);
1754 gemu_log("%s(", name);
1755 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1756 print_buf(msg, len, 0);
1757 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
1758 print_flags(msg_flags, flags, 1);
1762 static void do_print_msgaddr(const char *name, abi_long arg1)
1764 abi_ulong sockfd, msg, len, flags, addr, addrlen;
1766 get_user_ualx(sockfd, arg1, 0);
1767 get_user_ualx(msg, arg1, 1);
1768 get_user_ualx(len, arg1, 2);
1769 get_user_ualx(flags, arg1, 3);
1770 get_user_ualx(addr, arg1, 4);
1771 get_user_ualx(addrlen, arg1, 5);
1773 gemu_log("%s(", name);
1774 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1775 print_buf(msg, len, 0);
1776 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
1777 print_flags(msg_flags, flags, 0);
1778 print_sockaddr(addr, addrlen);
1782 static void do_print_shutdown(const char *name, abi_long arg1)
1784 abi_ulong sockfd, how;
1786 get_user_ualx(sockfd, arg1, 0);
1787 get_user_ualx(how, arg1, 1);
1789 gemu_log("shutdown(");
1790 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1793 gemu_log("SHUT_RD");
1796 gemu_log("SHUT_WR");
1799 gemu_log("SHUT_RDWR");
1802 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
1808 static void do_print_msg(const char *name, abi_long arg1)
1810 abi_ulong sockfd, msg, flags;
1812 get_user_ualx(sockfd, arg1, 0);
1813 get_user_ualx(msg, arg1, 1);
1814 get_user_ualx(flags, arg1, 2);
1816 gemu_log("%s(", name);
1817 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1818 print_pointer(msg, 0);
1819 print_flags(msg_flags, flags, 1);
1823 static void do_print_sockopt(const char *name, abi_long arg1)
1825 abi_ulong sockfd, level, optname, optval, optlen;
1827 get_user_ualx(sockfd, arg1, 0);
1828 get_user_ualx(level, arg1, 1);
1829 get_user_ualx(optname, arg1, 2);
1830 get_user_ualx(optval, arg1, 3);
1831 get_user_ualx(optlen, arg1, 4);
1833 gemu_log("%s(", name);
1834 print_raw_param(TARGET_ABI_FMT_ld, sockfd, 0);
1837 gemu_log("SOL_TCP,");
1838 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1839 print_pointer(optval, 0);
1842 gemu_log("SOL_IP,");
1843 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1844 print_pointer(optval, 0);
1847 gemu_log("SOL_RAW,");
1848 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1849 print_pointer(optval, 0);
1851 case TARGET_SOL_SOCKET:
1852 gemu_log("SOL_SOCKET,");
1854 case TARGET_SO_DEBUG:
1855 gemu_log("SO_DEBUG,");
1857 print_number(optval, 0);
1859 case TARGET_SO_REUSEADDR:
1860 gemu_log("SO_REUSEADDR,");
1862 case TARGET_SO_REUSEPORT:
1863 gemu_log("SO_REUSEPORT,");
1865 case TARGET_SO_TYPE:
1866 gemu_log("SO_TYPE,");
1868 case TARGET_SO_ERROR:
1869 gemu_log("SO_ERROR,");
1871 case TARGET_SO_DONTROUTE:
1872 gemu_log("SO_DONTROUTE,");
1874 case TARGET_SO_BROADCAST:
1875 gemu_log("SO_BROADCAST,");
1877 case TARGET_SO_SNDBUF:
1878 gemu_log("SO_SNDBUF,");
1880 case TARGET_SO_RCVBUF:
1881 gemu_log("SO_RCVBUF,");
1883 case TARGET_SO_KEEPALIVE:
1884 gemu_log("SO_KEEPALIVE,");
1886 case TARGET_SO_OOBINLINE:
1887 gemu_log("SO_OOBINLINE,");
1889 case TARGET_SO_NO_CHECK:
1890 gemu_log("SO_NO_CHECK,");
1892 case TARGET_SO_PRIORITY:
1893 gemu_log("SO_PRIORITY,");
1895 case TARGET_SO_BSDCOMPAT:
1896 gemu_log("SO_BSDCOMPAT,");
1898 case TARGET_SO_PASSCRED:
1899 gemu_log("SO_PASSCRED,");
1901 case TARGET_SO_TIMESTAMP:
1902 gemu_log("SO_TIMESTAMP,");
1904 case TARGET_SO_RCVLOWAT:
1905 gemu_log("SO_RCVLOWAT,");
1907 case TARGET_SO_RCVTIMEO:
1908 gemu_log("SO_RCVTIMEO,");
1909 print_timeval(optval, 0);
1911 case TARGET_SO_SNDTIMEO:
1912 gemu_log("SO_SNDTIMEO,");
1913 print_timeval(optval, 0);
1915 case TARGET_SO_ATTACH_FILTER: {
1916 struct target_sock_fprog *fprog;
1918 gemu_log("SO_ATTACH_FILTER,");
1920 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
1921 struct target_sock_filter *filter;
1923 if (lock_user_struct(VERIFY_READ, filter,
1924 tswapal(fprog->filter), 0)) {
1926 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
1927 gemu_log("[%d]{0x%x,%d,%d,0x%x},",
1928 i, tswap16(filter[i].code),
1929 filter[i].jt, filter[i].jf,
1930 tswap32(filter[i].k));
1932 gemu_log("[%d]{0x%x,%d,%d,0x%x}",
1933 i, tswap16(filter[i].code),
1934 filter[i].jt, filter[i].jf,
1935 tswap32(filter[i].k));
1937 gemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
1939 gemu_log(",%d},", tswap16(fprog->len));
1940 unlock_user(fprog, optval, 0);
1942 print_pointer(optval, 0);
1947 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1948 print_pointer(optval, 0);
1953 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
1954 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
1955 print_pointer(optval, 0);
1958 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
1962 #define PRINT_SOCKOP(name, func) \
1963 [TARGET_SYS_##name] = { #name, func }
1967 void (*print)(const char *, abi_long);
1969 PRINT_SOCKOP(SOCKET, do_print_socket),
1970 PRINT_SOCKOP(BIND, do_print_sockaddr),
1971 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
1972 PRINT_SOCKOP(LISTEN, do_print_listen),
1973 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
1974 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
1975 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
1976 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
1977 PRINT_SOCKOP(SEND, do_print_sendrecv),
1978 PRINT_SOCKOP(RECV, do_print_sendrecv),
1979 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
1980 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
1981 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
1982 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
1983 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
1984 PRINT_SOCKOP(SENDMSG, do_print_msg),
1985 PRINT_SOCKOP(RECVMSG, do_print_msg),
1986 PRINT_SOCKOP(ACCEPT4, NULL),
1987 PRINT_SOCKOP(RECVMMSG, NULL),
1988 PRINT_SOCKOP(SENDMMSG, NULL),
1992 print_socketcall(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 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
1997 scall[arg0].print(scall[arg0].name, arg1);
2000 print_syscall_prologue(name);
2001 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
2002 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2003 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2004 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
2005 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
2006 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
2007 print_syscall_epilogue(name);
2011 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2012 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2014 print_stat(const struct syscallname *name,
2015 abi_long arg0, abi_long arg1, abi_long arg2,
2016 abi_long arg3, abi_long arg4, abi_long arg5)
2018 print_syscall_prologue(name);
2019 print_string(arg0, 0);
2020 print_pointer(arg1, 1);
2021 print_syscall_epilogue(name);
2023 #define print_lstat print_stat
2024 #define print_stat64 print_stat
2025 #define print_lstat64 print_stat
2028 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2030 print_fstat(const struct syscallname *name,
2031 abi_long arg0, abi_long arg1, abi_long arg2,
2032 abi_long arg3, abi_long arg4, abi_long arg5)
2034 print_syscall_prologue(name);
2035 print_raw_param("%d", arg0, 0);
2036 print_pointer(arg1, 1);
2037 print_syscall_epilogue(name);
2039 #define print_fstat64 print_fstat
2042 #ifdef TARGET_NR_mkdir
2044 print_mkdir(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_string(arg0, 0);
2050 print_file_mode(arg1, 1);
2051 print_syscall_epilogue(name);
2055 #ifdef TARGET_NR_mkdirat
2057 print_mkdirat(const struct syscallname *name,
2058 abi_long arg0, abi_long arg1, abi_long arg2,
2059 abi_long arg3, abi_long arg4, abi_long arg5)
2061 print_syscall_prologue(name);
2062 print_at_dirfd(arg0, 0);
2063 print_string(arg1, 0);
2064 print_file_mode(arg2, 1);
2065 print_syscall_epilogue(name);
2069 #ifdef TARGET_NR_rmdir
2071 print_rmdir(const struct syscallname *name,
2072 abi_long arg0, abi_long arg1, abi_long arg2,
2073 abi_long arg3, abi_long arg4, abi_long arg5)
2075 print_syscall_prologue(name);
2076 print_string(arg0, 0);
2077 print_syscall_epilogue(name);
2081 #ifdef TARGET_NR_rt_sigaction
2083 print_rt_sigaction(const struct syscallname *name,
2084 abi_long arg0, abi_long arg1, abi_long arg2,
2085 abi_long arg3, abi_long arg4, abi_long arg5)
2087 print_syscall_prologue(name);
2088 print_signal(arg0, 0);
2089 print_pointer(arg1, 0);
2090 print_pointer(arg2, 1);
2091 print_syscall_epilogue(name);
2095 #ifdef TARGET_NR_rt_sigprocmask
2097 print_rt_sigprocmask(const struct syscallname *name,
2098 abi_long arg0, abi_long arg1, abi_long arg2,
2099 abi_long arg3, abi_long arg4, abi_long arg5)
2101 const char *how = "UNKNOWN";
2102 print_syscall_prologue(name);
2104 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
2105 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
2106 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
2108 gemu_log("%s,",how);
2109 print_pointer(arg1, 0);
2110 print_pointer(arg2, 1);
2111 print_syscall_epilogue(name);
2115 #ifdef TARGET_NR_rt_sigqueueinfo
2117 print_rt_sigqueueinfo(const struct syscallname *name,
2118 abi_long arg0, abi_long arg1, abi_long arg2,
2119 abi_long arg3, abi_long arg4, abi_long arg5)
2122 target_siginfo_t uinfo;
2124 print_syscall_prologue(name);
2125 print_raw_param("%d", arg0, 0);
2126 print_signal(arg1, 0);
2127 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
2129 get_target_siginfo(&uinfo, p);
2130 print_siginfo(&uinfo);
2132 unlock_user(p, arg2, 0);
2134 print_pointer(arg2, 1);
2136 print_syscall_epilogue(name);
2140 #ifdef TARGET_NR_rt_tgsigqueueinfo
2142 print_rt_tgsigqueueinfo(const struct syscallname *name,
2143 abi_long arg0, abi_long arg1, abi_long arg2,
2144 abi_long arg3, abi_long arg4, abi_long arg5)
2147 target_siginfo_t uinfo;
2149 print_syscall_prologue(name);
2150 print_raw_param("%d", arg0, 0);
2151 print_raw_param("%d", arg1, 0);
2152 print_signal(arg2, 0);
2153 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
2155 get_target_siginfo(&uinfo, p);
2156 print_siginfo(&uinfo);
2158 unlock_user(p, arg3, 0);
2160 print_pointer(arg3, 1);
2162 print_syscall_epilogue(name);
2166 #ifdef TARGET_NR_syslog
2168 print_syslog_action(abi_ulong arg, int last)
2173 case TARGET_SYSLOG_ACTION_CLOSE: {
2174 type = "SYSLOG_ACTION_CLOSE";
2177 case TARGET_SYSLOG_ACTION_OPEN: {
2178 type = "SYSLOG_ACTION_OPEN";
2181 case TARGET_SYSLOG_ACTION_READ: {
2182 type = "SYSLOG_ACTION_READ";
2185 case TARGET_SYSLOG_ACTION_READ_ALL: {
2186 type = "SYSLOG_ACTION_READ_ALL";
2189 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
2190 type = "SYSLOG_ACTION_READ_CLEAR";
2193 case TARGET_SYSLOG_ACTION_CLEAR: {
2194 type = "SYSLOG_ACTION_CLEAR";
2197 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
2198 type = "SYSLOG_ACTION_CONSOLE_OFF";
2201 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
2202 type = "SYSLOG_ACTION_CONSOLE_ON";
2205 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
2206 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
2209 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
2210 type = "SYSLOG_ACTION_SIZE_UNREAD";
2213 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
2214 type = "SYSLOG_ACTION_SIZE_BUFFER";
2218 print_raw_param("%ld", arg, last);
2222 gemu_log("%s%s", type, get_comma(last));
2226 print_syslog(const struct syscallname *name,
2227 abi_long arg0, abi_long arg1, abi_long arg2,
2228 abi_long arg3, abi_long arg4, abi_long arg5)
2230 print_syscall_prologue(name);
2231 print_syslog_action(arg0, 0);
2232 print_pointer(arg1, 0);
2233 print_raw_param("%d", arg2, 1);
2234 print_syscall_epilogue(name);
2238 #ifdef TARGET_NR_mknod
2240 print_mknod(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 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
2246 print_syscall_prologue(name);
2247 print_string(arg0, 0);
2248 print_file_mode(arg1, (hasdev == 0));
2250 print_raw_param("makedev(%d", major(arg2), 0);
2251 print_raw_param("%d)", minor(arg2), 1);
2253 print_syscall_epilogue(name);
2257 #ifdef TARGET_NR_mknodat
2259 print_mknodat(const struct syscallname *name,
2260 abi_long arg0, abi_long arg1, abi_long arg2,
2261 abi_long arg3, abi_long arg4, abi_long arg5)
2263 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
2265 print_syscall_prologue(name);
2266 print_at_dirfd(arg0, 0);
2267 print_string(arg1, 0);
2268 print_file_mode(arg2, (hasdev == 0));
2270 print_raw_param("makedev(%d", major(arg3), 0);
2271 print_raw_param("%d)", minor(arg3), 1);
2273 print_syscall_epilogue(name);
2277 #ifdef TARGET_NR_mq_open
2279 print_mq_open(const struct syscallname *name,
2280 abi_long arg0, abi_long arg1, abi_long arg2,
2281 abi_long arg3, abi_long arg4, abi_long arg5)
2283 int is_creat = (arg1 & TARGET_O_CREAT);
2285 print_syscall_prologue(name);
2286 print_string(arg0, 0);
2287 print_open_flags(arg1, (is_creat == 0));
2289 print_file_mode(arg2, 0);
2290 print_pointer(arg3, 1);
2292 print_syscall_epilogue(name);
2296 #ifdef TARGET_NR_open
2298 print_open(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 int is_creat = (arg1 & TARGET_O_CREAT);
2304 print_syscall_prologue(name);
2305 print_string(arg0, 0);
2306 print_open_flags(arg1, (is_creat == 0));
2308 print_file_mode(arg2, 1);
2309 print_syscall_epilogue(name);
2313 #ifdef TARGET_NR_openat
2315 print_openat(const struct syscallname *name,
2316 abi_long arg0, abi_long arg1, abi_long arg2,
2317 abi_long arg3, abi_long arg4, abi_long arg5)
2319 int is_creat = (arg2 & TARGET_O_CREAT);
2321 print_syscall_prologue(name);
2322 print_at_dirfd(arg0, 0);
2323 print_string(arg1, 0);
2324 print_open_flags(arg2, (is_creat == 0));
2326 print_file_mode(arg3, 1);
2327 print_syscall_epilogue(name);
2331 #ifdef TARGET_NR_mq_unlink
2333 print_mq_unlink(const struct syscallname *name,
2334 abi_long arg0, abi_long arg1, abi_long arg2,
2335 abi_long arg3, abi_long arg4, abi_long arg5)
2337 print_syscall_prologue(name);
2338 print_string(arg0, 1);
2339 print_syscall_epilogue(name);
2343 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
2345 print_fstatat64(const struct syscallname *name,
2346 abi_long arg0, abi_long arg1, abi_long arg2,
2347 abi_long arg3, abi_long arg4, abi_long arg5)
2349 print_syscall_prologue(name);
2350 print_at_dirfd(arg0, 0);
2351 print_string(arg1, 0);
2352 print_pointer(arg2, 0);
2353 print_flags(at_file_flags, arg3, 1);
2354 print_syscall_epilogue(name);
2356 #define print_newfstatat print_fstatat64
2359 #ifdef TARGET_NR_readlink
2361 print_readlink(const struct syscallname *name,
2362 abi_long arg0, abi_long arg1, abi_long arg2,
2363 abi_long arg3, abi_long arg4, abi_long arg5)
2365 print_syscall_prologue(name);
2366 print_string(arg0, 0);
2367 print_pointer(arg1, 0);
2368 print_raw_param("%u", arg2, 1);
2369 print_syscall_epilogue(name);
2373 #ifdef TARGET_NR_readlinkat
2375 print_readlinkat(const struct syscallname *name,
2376 abi_long arg0, abi_long arg1, abi_long arg2,
2377 abi_long arg3, abi_long arg4, abi_long arg5)
2379 print_syscall_prologue(name);
2380 print_at_dirfd(arg0, 0);
2381 print_string(arg1, 0);
2382 print_pointer(arg2, 0);
2383 print_raw_param("%u", arg3, 1);
2384 print_syscall_epilogue(name);
2388 #ifdef TARGET_NR_rename
2390 print_rename(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_string(arg0, 0);
2396 print_string(arg1, 1);
2397 print_syscall_epilogue(name);
2401 #ifdef TARGET_NR_renameat
2403 print_renameat(const struct syscallname *name,
2404 abi_long arg0, abi_long arg1, abi_long arg2,
2405 abi_long arg3, abi_long arg4, abi_long arg5)
2407 print_syscall_prologue(name);
2408 print_at_dirfd(arg0, 0);
2409 print_string(arg1, 0);
2410 print_at_dirfd(arg2, 0);
2411 print_string(arg3, 1);
2412 print_syscall_epilogue(name);
2416 #ifdef TARGET_NR_statfs
2418 print_statfs(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_statfs64
2431 print_statfs64(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_pointer(arg1, 1);
2438 print_syscall_epilogue(name);
2442 #ifdef TARGET_NR_symlink
2444 print_symlink(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_string(arg1, 1);
2451 print_syscall_epilogue(name);
2455 #ifdef TARGET_NR_symlinkat
2457 print_symlinkat(const struct syscallname *name,
2458 abi_long arg0, abi_long arg1, abi_long arg2,
2459 abi_long arg3, abi_long arg4, abi_long arg5)
2461 print_syscall_prologue(name);
2462 print_string(arg0, 0);
2463 print_at_dirfd(arg1, 0);
2464 print_string(arg2, 1);
2465 print_syscall_epilogue(name);
2469 #ifdef TARGET_NR_mount
2471 print_mount(const struct syscallname *name,
2472 abi_long arg0, abi_long arg1, abi_long arg2,
2473 abi_long arg3, abi_long arg4, abi_long arg5)
2475 print_syscall_prologue(name);
2476 print_string(arg0, 0);
2477 print_string(arg1, 0);
2478 print_string(arg2, 0);
2479 print_flags(mount_flags, arg3, 0);
2480 print_pointer(arg4, 1);
2481 print_syscall_epilogue(name);
2485 #ifdef TARGET_NR_umount
2487 print_umount(const struct syscallname *name,
2488 abi_long arg0, abi_long arg1, abi_long arg2,
2489 abi_long arg3, abi_long arg4, abi_long arg5)
2491 print_syscall_prologue(name);
2492 print_string(arg0, 1);
2493 print_syscall_epilogue(name);
2497 #ifdef TARGET_NR_umount2
2499 print_umount2(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, 0);
2505 print_flags(umount2_flags, arg1, 1);
2506 print_syscall_epilogue(name);
2510 #ifdef TARGET_NR_unlink
2512 print_unlink(const struct syscallname *name,
2513 abi_long arg0, abi_long arg1, abi_long arg2,
2514 abi_long arg3, abi_long arg4, abi_long arg5)
2516 print_syscall_prologue(name);
2517 print_string(arg0, 1);
2518 print_syscall_epilogue(name);
2522 #ifdef TARGET_NR_unlinkat
2524 print_unlinkat(const struct syscallname *name,
2525 abi_long arg0, abi_long arg1, abi_long arg2,
2526 abi_long arg3, abi_long arg4, abi_long arg5)
2528 print_syscall_prologue(name);
2529 print_at_dirfd(arg0, 0);
2530 print_string(arg1, 0);
2531 print_flags(unlinkat_flags, arg2, 1);
2532 print_syscall_epilogue(name);
2536 #ifdef TARGET_NR_utime
2538 print_utime(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_utimes
2551 print_utimes(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_string(arg0, 0);
2557 print_pointer(arg1, 1);
2558 print_syscall_epilogue(name);
2562 #ifdef TARGET_NR_utimensat
2564 print_utimensat(const struct syscallname *name,
2565 abi_long arg0, abi_long arg1, abi_long arg2,
2566 abi_long arg3, abi_long arg4, abi_long arg5)
2568 print_syscall_prologue(name);
2569 print_at_dirfd(arg0, 0);
2570 print_string(arg1, 0);
2571 print_pointer(arg2, 0);
2572 print_flags(at_file_flags, arg3, 1);
2573 print_syscall_epilogue(name);
2577 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
2579 print_mmap(const struct syscallname *name,
2580 abi_long arg0, abi_long arg1, abi_long arg2,
2581 abi_long arg3, abi_long arg4, abi_long arg5)
2583 print_syscall_prologue(name);
2584 print_pointer(arg0, 0);
2585 print_raw_param("%d", arg1, 0);
2586 print_flags(mmap_prot_flags, arg2, 0);
2587 print_flags(mmap_flags, arg3, 0);
2588 print_raw_param("%d", arg4, 0);
2589 print_raw_param("%#x", arg5, 1);
2590 print_syscall_epilogue(name);
2592 #define print_mmap2 print_mmap
2595 #ifdef TARGET_NR_mprotect
2597 print_mprotect(const struct syscallname *name,
2598 abi_long arg0, abi_long arg1, abi_long arg2,
2599 abi_long arg3, abi_long arg4, abi_long arg5)
2601 print_syscall_prologue(name);
2602 print_pointer(arg0, 0);
2603 print_raw_param("%d", arg1, 0);
2604 print_flags(mmap_prot_flags, arg2, 1);
2605 print_syscall_epilogue(name);
2609 #ifdef TARGET_NR_munmap
2611 print_munmap(const struct syscallname *name,
2612 abi_long arg0, abi_long arg1, abi_long arg2,
2613 abi_long arg3, abi_long arg4, abi_long arg5)
2615 print_syscall_prologue(name);
2616 print_pointer(arg0, 0);
2617 print_raw_param("%d", arg1, 1);
2618 print_syscall_epilogue(name);
2622 #ifdef TARGET_NR_futex
2623 static void print_futex_op(abi_long tflag, int last)
2625 #define print_op(val) \
2626 if( cmd == val ) { \
2631 int cmd = (int)tflag;
2632 #ifdef FUTEX_PRIVATE_FLAG
2633 if (cmd & FUTEX_PRIVATE_FLAG) {
2634 gemu_log("FUTEX_PRIVATE_FLAG|");
2635 cmd &= ~FUTEX_PRIVATE_FLAG;
2638 #ifdef FUTEX_CLOCK_REALTIME
2639 if (cmd & FUTEX_CLOCK_REALTIME) {
2640 gemu_log("FUTEX_CLOCK_REALTIME|");
2641 cmd &= ~FUTEX_CLOCK_REALTIME;
2644 print_op(FUTEX_WAIT)
2645 print_op(FUTEX_WAKE)
2647 print_op(FUTEX_REQUEUE)
2648 print_op(FUTEX_CMP_REQUEUE)
2649 print_op(FUTEX_WAKE_OP)
2650 print_op(FUTEX_LOCK_PI)
2651 print_op(FUTEX_UNLOCK_PI)
2652 print_op(FUTEX_TRYLOCK_PI)
2653 #ifdef FUTEX_WAIT_BITSET
2654 print_op(FUTEX_WAIT_BITSET)
2656 #ifdef FUTEX_WAKE_BITSET
2657 print_op(FUTEX_WAKE_BITSET)
2659 /* unknown values */
2664 print_futex(const struct syscallname *name,
2665 abi_long arg0, abi_long arg1, abi_long arg2,
2666 abi_long arg3, abi_long arg4, abi_long arg5)
2668 print_syscall_prologue(name);
2669 print_pointer(arg0, 0);
2670 print_futex_op(arg1, 0);
2671 print_raw_param(",%d", arg2, 0);
2672 print_pointer(arg3, 0); /* struct timespec */
2673 print_pointer(arg4, 0);
2674 print_raw_param("%d", arg4, 1);
2675 print_syscall_epilogue(name);
2679 #ifdef TARGET_NR_kill
2681 print_kill(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_tkill
2694 print_tkill(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_signal(arg1, 1);
2701 print_syscall_epilogue(name);
2705 #ifdef TARGET_NR_tgkill
2707 print_tgkill(const struct syscallname *name,
2708 abi_long arg0, abi_long arg1, abi_long arg2,
2709 abi_long arg3, abi_long arg4, abi_long arg5)
2711 print_syscall_prologue(name);
2712 print_raw_param("%d", arg0, 0);
2713 print_raw_param("%d", arg1, 0);
2714 print_signal(arg2, 1);
2715 print_syscall_epilogue(name);
2719 #ifdef TARGET_NR_statx
2721 print_statx(const struct syscallname *name,
2722 abi_long arg0, abi_long arg1, abi_long arg2,
2723 abi_long arg3, abi_long arg4, abi_long arg5)
2725 print_syscall_prologue(name);
2726 print_at_dirfd(arg0, 0);
2727 print_string(arg1, 0);
2728 print_flags(statx_flags, arg2, 0);
2729 print_flags(statx_mask, arg3, 0);
2730 print_pointer(arg4, 1);
2731 print_syscall_epilogue(name);
2736 * An array of all of the syscalls we know about
2739 static const struct syscallname scnames[] = {
2740 #include "strace.list"
2743 static int nsyscalls = ARRAY_SIZE(scnames);
2746 * The public interface to this module.
2749 print_syscall(int num,
2750 abi_long arg1, abi_long arg2, abi_long arg3,
2751 abi_long arg4, abi_long arg5, abi_long arg6)
2754 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 ")";
2756 gemu_log("%d ", getpid() );
2758 for(i=0;i<nsyscalls;i++)
2759 if( scnames[i].nr == num ) {
2760 if( scnames[i].call != NULL ) {
2761 scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6);
2763 /* XXX: this format system is broken because it uses
2764 host types and host pointers for strings */
2765 if( scnames[i].format != NULL )
2766 format = scnames[i].format;
2767 gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6);
2771 gemu_log("Unknown syscall %d\n", num);
2776 print_syscall_ret(int num, abi_long ret)
2779 const char *errstr = NULL;
2781 for(i=0;i<nsyscalls;i++)
2782 if( scnames[i].nr == num ) {
2783 if( scnames[i].result != NULL ) {
2784 scnames[i].result(&scnames[i],ret);
2787 errstr = target_strerror(-ret);
2790 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n",
2793 gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
2800 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
2802 /* Print the strace output for a signal being taken:
2803 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
2806 print_signal(target_signum, 1);
2808 print_siginfo(tinfo);