1 #include "qemu/osdep.h"
6 #include <sys/select.h>
9 #include <netinet/in.h>
10 #include <netinet/tcp.h>
11 #include <netinet/udp.h>
12 #include <linux/if_packet.h>
13 #include <linux/in6.h>
14 #include <linux/netlink.h>
22 void (*call)(void *, const struct syscallname *,
23 abi_long, abi_long, abi_long,
24 abi_long, abi_long, abi_long);
25 void (*result)(void *, const struct syscallname *, abi_long,
26 abi_long, abi_long, abi_long,
27 abi_long, abi_long, abi_long);
31 * It is possible that target doesn't have syscall that uses
32 * following flags but we don't want the compiler to warn
33 * us about them being unused. Same applies to utility print
34 * functions. It is ok to keep them while not used.
36 #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 /* Structure used to translate enumerated values into strings */
56 abi_long e_value; /* enum value */
57 const char *e_string; /* stringified enum */
60 /* common enums for all architectures */
61 #define ENUM_GENERIC(name) { name, #name }
62 /* target specific enums */
63 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
64 /* end of enums array */
65 #define ENUM_END { 0, NULL }
67 UNUSED static const char *get_comma(int);
68 UNUSED static void print_pointer(abi_long, int);
69 UNUSED static void print_flags(const struct flags *, abi_long, int);
70 UNUSED static void print_enums(const struct enums *, abi_long, int);
71 UNUSED static void print_at_dirfd(abi_long, int);
72 UNUSED static void print_file_mode(abi_long, int);
73 UNUSED static void print_open_flags(abi_long, int);
74 UNUSED static void print_syscall_prologue(const struct syscallname *);
75 UNUSED static void print_syscall_epilogue(const struct syscallname *);
76 UNUSED static void print_string(abi_long, int);
77 UNUSED static void print_buf(abi_long addr, abi_long len, int last);
78 UNUSED static void print_raw_param(const char *, abi_long, int);
79 UNUSED static void print_timeval(abi_ulong, int);
80 UNUSED static void print_timespec(abi_ulong, int);
81 UNUSED static void print_timezone(abi_ulong, int);
82 UNUSED static void print_itimerval(abi_ulong, int);
83 UNUSED static void print_number(abi_long, int);
84 UNUSED static void print_signal(abi_ulong, int);
85 UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
86 UNUSED static void print_socket_domain(int domain);
87 UNUSED static void print_socket_type(int type);
88 UNUSED static void print_socket_protocol(int domain, int type, int protocol);
94 print_ipc_cmd(int cmd)
96 #define output_cmd(val) \
104 /* General IPC commands */
105 output_cmd( IPC_RMID );
106 output_cmd( IPC_SET );
107 output_cmd( IPC_STAT );
108 output_cmd( IPC_INFO );
109 /* msgctl() commands */
110 output_cmd( MSG_STAT );
111 output_cmd( MSG_INFO );
112 /* shmctl() commands */
113 output_cmd( SHM_LOCK );
114 output_cmd( SHM_UNLOCK );
115 output_cmd( SHM_STAT );
116 output_cmd( SHM_INFO );
117 /* semctl() commands */
118 output_cmd( GETPID );
119 output_cmd( GETVAL );
120 output_cmd( GETALL );
121 output_cmd( GETNCNT );
122 output_cmd( GETZCNT );
123 output_cmd( SETVAL );
124 output_cmd( SETALL );
125 output_cmd( SEM_STAT );
126 output_cmd( SEM_INFO );
127 output_cmd( IPC_RMID );
128 output_cmd( IPC_RMID );
129 output_cmd( IPC_RMID );
130 output_cmd( IPC_RMID );
131 output_cmd( IPC_RMID );
132 output_cmd( IPC_RMID );
133 output_cmd( IPC_RMID );
134 output_cmd( IPC_RMID );
135 output_cmd( IPC_RMID );
137 /* Some value we don't recognize */
142 print_signal(abi_ulong arg, int last)
144 const char *signal_name = NULL;
146 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
147 case TARGET_SIGINT: signal_name = "SIGINT"; break;
148 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
149 case TARGET_SIGILL: signal_name = "SIGILL"; break;
150 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
151 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
152 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
153 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
154 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
155 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
156 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
157 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
158 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
159 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
160 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
161 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
162 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
163 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
165 if (signal_name == NULL) {
166 print_raw_param("%ld", arg, last);
169 qemu_log("%s%s", signal_name, get_comma(last));
172 static void print_si_code(int arg)
174 const char *codename = NULL;
178 codename = "SI_USER";
181 codename = "SI_KERNEL";
184 codename = "SI_QUEUE";
187 codename = "SI_TIMER";
190 codename = "SI_MESGQ";
193 codename = "SI_ASYNCIO";
196 codename = "SI_SIGIO";
199 codename = "SI_TKILL";
205 qemu_log("%s", codename);
208 static void get_target_siginfo(target_siginfo_t *tinfo,
209 const target_siginfo_t *info)
218 __get_user(sig, &info->si_signo);
219 __get_user(si_errno, &tinfo->si_errno);
220 __get_user(si_code, &info->si_code);
222 tinfo->si_signo = sig;
223 tinfo->si_errno = si_errno;
224 tinfo->si_code = si_code;
226 /* Ensure we don't leak random junk to the guest later */
227 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
229 /* This is awkward, because we have to use a combination of
230 * the si_code and si_signo to figure out which of the union's
231 * members are valid. (Within the host kernel it is always possible
232 * to tell, but the kernel carefully avoids giving userspace the
233 * high 16 bits of si_code, so we don't have the information to
234 * do this the easy way...) We therefore make our best guess,
235 * bearing in mind that a guest can spoof most of the si_codes
236 * via rt_sigqueueinfo() if it likes.
238 * Once we have made our guess, we record it in the top 16 bits of
239 * the si_code, so that print_siginfo() later can use it.
240 * print_siginfo() will strip these top bits out before printing
248 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
249 * These are the only unspoofable si_code values.
251 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
252 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
253 si_type = QEMU_SI_KILL;
256 /* Everything else is spoofable. Make best guess based on signal */
259 __get_user(tinfo->_sifields._sigchld._pid,
260 &info->_sifields._sigchld._pid);
261 __get_user(tinfo->_sifields._sigchld._uid,
262 &info->_sifields._sigchld._uid);
263 __get_user(tinfo->_sifields._sigchld._status,
264 &info->_sifields._sigchld._status);
265 __get_user(tinfo->_sifields._sigchld._utime,
266 &info->_sifields._sigchld._utime);
267 __get_user(tinfo->_sifields._sigchld._stime,
268 &info->_sifields._sigchld._stime);
269 si_type = QEMU_SI_CHLD;
272 __get_user(tinfo->_sifields._sigpoll._band,
273 &info->_sifields._sigpoll._band);
274 __get_user(tinfo->_sifields._sigpoll._fd,
275 &info->_sifields._sigpoll._fd);
276 si_type = QEMU_SI_POLL;
279 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
280 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
281 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
282 /* XXX: potential problem if 64 bit */
283 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
284 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
286 si_type = QEMU_SI_RT;
292 tinfo->si_code = deposit32(si_code, 16, 16, si_type);
295 static void print_siginfo(const target_siginfo_t *tinfo)
297 /* Print a target_siginfo_t in the format desired for printing
298 * signals being taken. We assume the target_siginfo_t is in the
299 * internal form where the top 16 bits of si_code indicate which
300 * part of the union is valid, rather than in the guest-visible
301 * form where the bottom 16 bits are sign-extended into the top 16.
303 int si_type = extract32(tinfo->si_code, 16, 16);
304 int si_code = sextract32(tinfo->si_code, 0, 16);
306 qemu_log("{si_signo=");
307 print_signal(tinfo->si_signo, 1);
308 qemu_log(", si_code=");
309 print_si_code(si_code);
313 qemu_log(", si_pid=%u, si_uid=%u",
314 (unsigned int)tinfo->_sifields._kill._pid,
315 (unsigned int)tinfo->_sifields._kill._uid);
318 qemu_log(", si_timer1=%u, si_timer2=%u",
319 tinfo->_sifields._timer._timer1,
320 tinfo->_sifields._timer._timer2);
323 qemu_log(", si_band=%d, si_fd=%d",
324 tinfo->_sifields._sigpoll._band,
325 tinfo->_sifields._sigpoll._fd);
328 qemu_log(", si_addr=");
329 print_pointer(tinfo->_sifields._sigfault._addr, 1);
332 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
333 ", si_utime=" TARGET_ABI_FMT_ld
334 ", si_stime=" TARGET_ABI_FMT_ld,
335 (unsigned int)(tinfo->_sifields._sigchld._pid),
336 (unsigned int)(tinfo->_sifields._sigchld._uid),
337 tinfo->_sifields._sigchld._status,
338 tinfo->_sifields._sigchld._utime,
339 tinfo->_sifields._sigchld._stime);
342 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
343 (unsigned int)tinfo->_sifields._rt._pid,
344 (unsigned int)tinfo->_sifields._rt._uid,
345 tinfo->_sifields._rt._sigval.sival_ptr);
348 g_assert_not_reached();
354 print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
356 struct target_sockaddr *sa;
360 sa = lock_user(VERIFY_READ, addr, addrlen, 1);
362 sa_family = tswap16(sa->sa_family);
365 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
367 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
368 for (i = 0; i < addrlen -
369 offsetof(struct target_sockaddr_un, sun_path) &&
370 un->sun_path[i]; i++) {
371 qemu_log("%c", un->sun_path[i]);
377 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
378 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
379 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
380 ntohs(in->sin_port));
381 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
382 c[0], c[1], c[2], c[3]);
387 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
388 uint8_t *c = (uint8_t *)&ll->sll_addr;
389 qemu_log("{sll_family=AF_PACKET,"
390 "sll_protocol=htons(0x%04x),if%d,pkttype=",
391 ntohs(ll->sll_protocol), ll->sll_ifindex);
392 switch (ll->sll_pkttype) {
394 qemu_log("PACKET_HOST");
396 case PACKET_BROADCAST:
397 qemu_log("PACKET_BROADCAST");
399 case PACKET_MULTICAST:
400 qemu_log("PACKET_MULTICAST");
402 case PACKET_OTHERHOST:
403 qemu_log("PACKET_OTHERHOST");
405 case PACKET_OUTGOING:
406 qemu_log("PACKET_OUTGOING");
409 qemu_log("%d", ll->sll_pkttype);
412 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
413 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
418 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
419 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
420 tswap32(nl->nl_pid), tswap32(nl->nl_groups));
424 qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
425 for (i = 0; i < 13; i++) {
426 qemu_log("%02x, ", sa->sa_data[i]);
428 qemu_log("%02x}", sa->sa_data[i]);
432 unlock_user(sa, addr, 0);
434 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
436 qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
440 print_socket_domain(int domain)
450 qemu_log("PF_NETLINK");
453 qemu_log("PF_PACKET");
456 qemu_log("%d", domain);
462 print_socket_type(int type)
464 switch (type & TARGET_SOCK_TYPE_MASK) {
465 case TARGET_SOCK_DGRAM:
466 qemu_log("SOCK_DGRAM");
468 case TARGET_SOCK_STREAM:
469 qemu_log("SOCK_STREAM");
471 case TARGET_SOCK_RAW:
472 qemu_log("SOCK_RAW");
474 case TARGET_SOCK_RDM:
475 qemu_log("SOCK_RDM");
477 case TARGET_SOCK_SEQPACKET:
478 qemu_log("SOCK_SEQPACKET");
480 case TARGET_SOCK_PACKET:
481 qemu_log("SOCK_PACKET");
484 if (type & TARGET_SOCK_CLOEXEC) {
485 qemu_log("|SOCK_CLOEXEC");
487 if (type & TARGET_SOCK_NONBLOCK) {
488 qemu_log("|SOCK_NONBLOCK");
493 print_socket_protocol(int domain, int type, int protocol)
495 if (domain == AF_PACKET ||
496 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
499 qemu_log("ETH_P_ALL");
502 qemu_log("%d", protocol);
507 if (domain == PF_NETLINK) {
510 qemu_log("NETLINK_ROUTE");
513 qemu_log("NETLINK_AUDIT");
515 case NETLINK_NETFILTER:
516 qemu_log("NETLINK_NETFILTER");
518 case NETLINK_KOBJECT_UEVENT:
519 qemu_log("NETLINK_KOBJECT_UEVENT");
522 qemu_log("NETLINK_RDMA");
525 qemu_log("NETLINK_CRYPTO");
528 qemu_log("%d", protocol);
536 qemu_log("IPPROTO_IP");
539 qemu_log("IPPROTO_TCP");
542 qemu_log("IPPROTO_UDP");
545 qemu_log("IPPROTO_RAW");
548 qemu_log("%d", protocol);
554 #ifdef TARGET_NR__newselect
556 print_fdset(int n, abi_ulong target_fds_addr)
562 if( target_fds_addr ) {
563 abi_long *target_fds;
565 target_fds = lock_user(VERIFY_READ,
567 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
573 for (i=n; i>=0; i--) {
574 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
575 (i & (TARGET_ABI_BITS - 1))) & 1) {
576 qemu_log("%s%d", get_comma(first), i);
580 unlock_user(target_fds, target_fds_addr, 0);
587 * Sysycall specific output functions
591 #ifdef TARGET_NR__newselect
593 print_newselect(void *cpu_env, const struct syscallname *name,
594 abi_long arg1, abi_long arg2, abi_long arg3,
595 abi_long arg4, abi_long arg5, abi_long arg6)
597 print_syscall_prologue(name);
598 print_fdset(arg1, arg2);
600 print_fdset(arg1, arg3);
602 print_fdset(arg1, arg4);
604 print_timeval(arg5, 1);
605 print_syscall_epilogue(name);
609 #ifdef TARGET_NR_semctl
611 print_semctl(void *cpu_env, const struct syscallname *name,
612 abi_long arg1, abi_long arg2, abi_long arg3,
613 abi_long arg4, abi_long arg5, abi_long arg6)
615 qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
616 name->name, arg1, arg2);
618 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
623 print_execve(void *cpu_env, const struct syscallname *name,
624 abi_long arg1, abi_long arg2, abi_long arg3,
625 abi_long arg4, abi_long arg5, abi_long arg6)
627 abi_ulong arg_ptr_addr;
630 if (!(s = lock_user_string(arg1)))
632 qemu_log("%s(\"%s\",{", name->name, s);
633 unlock_user(s, arg1, 0);
635 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
636 abi_ulong *arg_ptr, arg_addr;
638 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
641 arg_addr = tswapal(*arg_ptr);
642 unlock_user(arg_ptr, arg_ptr_addr, 0);
645 if ((s = lock_user_string(arg_addr))) {
646 qemu_log("\"%s\",", s);
647 unlock_user(s, arg_addr, 0);
656 print_ipc(void *cpu_env, const struct syscallname *name,
657 abi_long arg1, abi_long arg2, abi_long arg3,
658 abi_long arg4, abi_long arg5, abi_long arg6)
662 qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
665 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
669 TARGET_ABI_FMT_ld ","
670 TARGET_ABI_FMT_ld ","
671 TARGET_ABI_FMT_ld ","
674 name->name, arg1, arg2, arg3, arg4);
680 * Variants for the return value output function
684 print_syscall_err(abi_long ret)
690 errstr = target_strerror(-ret);
692 qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
700 print_syscall_ret_addr(void *cpu_env, const struct syscallname *name,
701 abi_long ret, abi_long arg0, abi_long arg1,
702 abi_long arg2, abi_long arg3, abi_long arg4,
705 if (!print_syscall_err(ret)) {
706 qemu_log("0x" TARGET_ABI_FMT_lx, ret);
711 #if 0 /* currently unused */
713 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
715 qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
719 #ifdef TARGET_NR__newselect
721 print_syscall_ret_newselect(void *cpu_env, const struct syscallname *name,
722 abi_long ret, abi_long arg0, abi_long arg1,
723 abi_long arg2, abi_long arg3, abi_long arg4,
726 if (!print_syscall_err(ret)) {
727 qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
728 print_fdset(arg0, arg1);
730 print_fdset(arg0, arg2);
732 print_fdset(arg0, arg3);
734 print_timeval(arg4, 1);
742 /* special meanings of adjtimex()' non-negative return values */
743 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
744 #define TARGET_TIME_INS 1 /* insert leap second */
745 #define TARGET_TIME_DEL 2 /* delete leap second */
746 #define TARGET_TIME_OOP 3 /* leap second in progress */
747 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
748 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
749 #ifdef TARGET_NR_adjtimex
751 print_syscall_ret_adjtimex(void *cpu_env, const struct syscallname *name,
752 abi_long ret, abi_long arg0, abi_long arg1,
753 abi_long arg2, abi_long arg3, abi_long arg4,
756 if (!print_syscall_err(ret)) {
757 qemu_log(TARGET_ABI_FMT_ld, ret);
760 qemu_log(" TIME_OK (clock synchronized, no leap second)");
762 case TARGET_TIME_INS:
763 qemu_log(" TIME_INS (insert leap second)");
765 case TARGET_TIME_DEL:
766 qemu_log(" TIME_DEL (delete leap second)");
768 case TARGET_TIME_OOP:
769 qemu_log(" TIME_OOP (leap second in progress)");
771 case TARGET_TIME_WAIT:
772 qemu_log(" TIME_WAIT (leap second has occurred)");
774 case TARGET_TIME_ERROR:
775 qemu_log(" TIME_ERROR (clock not synchronized)");
784 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
786 print_syscall_ret_clock_gettime(void *cpu_env, const struct syscallname *name,
787 abi_long ret, abi_long arg0, abi_long arg1,
788 abi_long arg2, abi_long arg3, abi_long arg4,
791 if (!print_syscall_err(ret)) {
792 qemu_log(TARGET_ABI_FMT_ld, ret);
794 print_timespec(arg1, 1);
800 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
803 #ifdef TARGET_NR_gettimeofday
805 print_syscall_ret_gettimeofday(void *cpu_env, const struct syscallname *name,
806 abi_long ret, abi_long arg0, abi_long arg1,
807 abi_long arg2, abi_long arg3, abi_long arg4,
810 if (!print_syscall_err(ret)) {
811 qemu_log(TARGET_ABI_FMT_ld, ret);
813 print_timeval(arg0, 0);
814 print_timezone(arg1, 1);
822 #ifdef TARGET_NR_getitimer
824 print_syscall_ret_getitimer(void *cpu_env, const struct syscallname *name,
825 abi_long ret, abi_long arg0, abi_long arg1,
826 abi_long arg2, abi_long arg3, abi_long arg4,
829 if (!print_syscall_err(ret)) {
830 qemu_log(TARGET_ABI_FMT_ld, ret);
832 print_itimerval(arg1, 1);
841 #ifdef TARGET_NR_getitimer
843 print_syscall_ret_setitimer(void *cpu_env, const struct syscallname *name,
844 abi_long ret, abi_long arg0, abi_long arg1,
845 abi_long arg2, abi_long arg3, abi_long arg4,
848 if (!print_syscall_err(ret)) {
849 qemu_log(TARGET_ABI_FMT_ld, ret);
850 qemu_log(" (old_value = ");
851 print_itimerval(arg2, 1);
859 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
860 || defined(TARGGET_NR_flistxattr)
862 print_syscall_ret_listxattr(void *cpu_env, const struct syscallname *name,
863 abi_long ret, abi_long arg0, abi_long arg1,
864 abi_long arg2, abi_long arg3, abi_long arg4,
867 if (!print_syscall_err(ret)) {
868 qemu_log(TARGET_ABI_FMT_ld, ret);
869 qemu_log(" (list = ");
871 abi_long attr = arg1;
876 print_string(attr, 1);
877 ret -= target_strlen(attr) + 1;
878 attr += target_strlen(attr) + 1;
888 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
889 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
892 #ifdef TARGET_NR_ioctl
894 print_syscall_ret_ioctl(void *cpu_env, const struct syscallname *name,
895 abi_long ret, abi_long arg0, abi_long arg1,
896 abi_long arg2, abi_long arg3, abi_long arg4,
899 if (!print_syscall_err(ret)) {
900 qemu_log(TARGET_ABI_FMT_ld, ret);
902 const IOCTLEntry *ie;
903 const argtype *arg_type;
907 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
908 if (ie->target_cmd == arg1) {
913 if (ie->target_cmd == arg1 &&
914 (ie->access == IOC_R || ie->access == IOC_RW)) {
915 arg_type = ie->arg_type;
918 target_size = thunk_type_size(arg_type, 0);
919 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
921 thunk_print(argptr, arg_type);
922 unlock_user(argptr, arg2, target_size);
924 print_pointer(arg2, 1);
933 UNUSED static struct flags access_flags[] = {
941 UNUSED static struct flags at_file_flags[] = {
943 FLAG_GENERIC(AT_EACCESS),
945 #ifdef AT_SYMLINK_NOFOLLOW
946 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
951 UNUSED static struct flags unlinkat_flags[] = {
953 FLAG_GENERIC(AT_REMOVEDIR),
958 UNUSED static struct flags mode_flags[] = {
959 FLAG_GENERIC(S_IFSOCK),
960 FLAG_GENERIC(S_IFLNK),
961 FLAG_GENERIC(S_IFREG),
962 FLAG_GENERIC(S_IFBLK),
963 FLAG_GENERIC(S_IFDIR),
964 FLAG_GENERIC(S_IFCHR),
965 FLAG_GENERIC(S_IFIFO),
969 UNUSED static struct flags open_access_flags[] = {
970 FLAG_TARGET(O_RDONLY),
971 FLAG_TARGET(O_WRONLY),
976 UNUSED static struct flags open_flags[] = {
977 FLAG_TARGET(O_APPEND),
978 FLAG_TARGET(O_CREAT),
979 FLAG_TARGET(O_DIRECTORY),
981 FLAG_TARGET(O_LARGEFILE),
982 FLAG_TARGET(O_NOCTTY),
983 FLAG_TARGET(O_NOFOLLOW),
984 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
985 FLAG_TARGET(O_DSYNC),
986 FLAG_TARGET(__O_SYNC),
987 FLAG_TARGET(O_TRUNC),
989 FLAG_TARGET(O_DIRECT),
992 FLAG_TARGET(O_NOATIME),
995 FLAG_TARGET(O_CLOEXEC),
1001 FLAG_TARGET(O_TMPFILE),
1002 FLAG_TARGET(__O_TMPFILE),
1007 UNUSED static struct flags mount_flags[] = {
1009 FLAG_GENERIC(MS_BIND),
1012 FLAG_GENERIC(MS_DIRSYNC),
1014 FLAG_GENERIC(MS_MANDLOCK),
1016 FLAG_GENERIC(MS_MOVE),
1018 FLAG_GENERIC(MS_NOATIME),
1019 FLAG_GENERIC(MS_NODEV),
1020 FLAG_GENERIC(MS_NODIRATIME),
1021 FLAG_GENERIC(MS_NOEXEC),
1022 FLAG_GENERIC(MS_NOSUID),
1023 FLAG_GENERIC(MS_RDONLY),
1025 FLAG_GENERIC(MS_RELATIME),
1027 FLAG_GENERIC(MS_REMOUNT),
1028 FLAG_GENERIC(MS_SYNCHRONOUS),
1032 UNUSED static struct flags umount2_flags[] = {
1034 FLAG_GENERIC(MNT_FORCE),
1037 FLAG_GENERIC(MNT_DETACH),
1040 FLAG_GENERIC(MNT_EXPIRE),
1045 UNUSED static struct flags mmap_prot_flags[] = {
1046 FLAG_GENERIC(PROT_NONE),
1047 FLAG_GENERIC(PROT_EXEC),
1048 FLAG_GENERIC(PROT_READ),
1049 FLAG_GENERIC(PROT_WRITE),
1050 FLAG_TARGET(PROT_SEM),
1051 FLAG_GENERIC(PROT_GROWSDOWN),
1052 FLAG_GENERIC(PROT_GROWSUP),
1056 UNUSED static struct flags mmap_flags[] = {
1057 FLAG_TARGET(MAP_SHARED),
1058 FLAG_TARGET(MAP_PRIVATE),
1059 FLAG_TARGET(MAP_ANONYMOUS),
1060 FLAG_TARGET(MAP_DENYWRITE),
1061 FLAG_TARGET(MAP_FIXED),
1062 FLAG_TARGET(MAP_GROWSDOWN),
1063 FLAG_TARGET(MAP_EXECUTABLE),
1065 FLAG_TARGET(MAP_LOCKED),
1068 FLAG_TARGET(MAP_NONBLOCK),
1070 FLAG_TARGET(MAP_NORESERVE),
1072 FLAG_TARGET(MAP_POPULATE),
1074 #ifdef TARGET_MAP_UNINITIALIZED
1075 FLAG_TARGET(MAP_UNINITIALIZED),
1080 UNUSED static struct flags clone_flags[] = {
1081 FLAG_GENERIC(CLONE_VM),
1082 FLAG_GENERIC(CLONE_FS),
1083 FLAG_GENERIC(CLONE_FILES),
1084 FLAG_GENERIC(CLONE_SIGHAND),
1085 FLAG_GENERIC(CLONE_PTRACE),
1086 FLAG_GENERIC(CLONE_VFORK),
1087 FLAG_GENERIC(CLONE_PARENT),
1088 FLAG_GENERIC(CLONE_THREAD),
1089 FLAG_GENERIC(CLONE_NEWNS),
1090 FLAG_GENERIC(CLONE_SYSVSEM),
1091 FLAG_GENERIC(CLONE_SETTLS),
1092 FLAG_GENERIC(CLONE_PARENT_SETTID),
1093 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
1094 FLAG_GENERIC(CLONE_DETACHED),
1095 FLAG_GENERIC(CLONE_UNTRACED),
1096 FLAG_GENERIC(CLONE_CHILD_SETTID),
1097 #if defined(CLONE_NEWUTS)
1098 FLAG_GENERIC(CLONE_NEWUTS),
1100 #if defined(CLONE_NEWIPC)
1101 FLAG_GENERIC(CLONE_NEWIPC),
1103 #if defined(CLONE_NEWUSER)
1104 FLAG_GENERIC(CLONE_NEWUSER),
1106 #if defined(CLONE_NEWPID)
1107 FLAG_GENERIC(CLONE_NEWPID),
1109 #if defined(CLONE_NEWNET)
1110 FLAG_GENERIC(CLONE_NEWNET),
1112 #if defined(CLONE_IO)
1113 FLAG_GENERIC(CLONE_IO),
1118 UNUSED static struct flags msg_flags[] = {
1120 FLAG_GENERIC(MSG_CONFIRM),
1121 FLAG_GENERIC(MSG_DONTROUTE),
1122 FLAG_GENERIC(MSG_DONTWAIT),
1123 FLAG_GENERIC(MSG_EOR),
1124 FLAG_GENERIC(MSG_MORE),
1125 FLAG_GENERIC(MSG_NOSIGNAL),
1126 FLAG_GENERIC(MSG_OOB),
1128 FLAG_GENERIC(MSG_CMSG_CLOEXEC),
1129 FLAG_GENERIC(MSG_ERRQUEUE),
1130 FLAG_GENERIC(MSG_PEEK),
1131 FLAG_GENERIC(MSG_TRUNC),
1132 FLAG_GENERIC(MSG_WAITALL),
1134 FLAG_GENERIC(MSG_CTRUNC),
1138 UNUSED static struct flags statx_flags[] = {
1139 #ifdef AT_EMPTY_PATH
1140 FLAG_GENERIC(AT_EMPTY_PATH),
1142 #ifdef AT_NO_AUTOMOUNT
1143 FLAG_GENERIC(AT_NO_AUTOMOUNT),
1145 #ifdef AT_SYMLINK_NOFOLLOW
1146 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
1148 #ifdef AT_STATX_SYNC_AS_STAT
1149 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
1151 #ifdef AT_STATX_FORCE_SYNC
1152 FLAG_GENERIC(AT_STATX_FORCE_SYNC),
1154 #ifdef AT_STATX_DONT_SYNC
1155 FLAG_GENERIC(AT_STATX_DONT_SYNC),
1160 UNUSED static struct flags statx_mask[] = {
1161 /* This must come first, because it includes everything. */
1163 FLAG_GENERIC(STATX_ALL),
1165 /* This must come second; it includes everything except STATX_BTIME. */
1166 #ifdef STATX_BASIC_STATS
1167 FLAG_GENERIC(STATX_BASIC_STATS),
1170 FLAG_GENERIC(STATX_TYPE),
1173 FLAG_GENERIC(STATX_MODE),
1176 FLAG_GENERIC(STATX_NLINK),
1179 FLAG_GENERIC(STATX_UID),
1182 FLAG_GENERIC(STATX_GID),
1185 FLAG_GENERIC(STATX_ATIME),
1188 FLAG_GENERIC(STATX_MTIME),
1191 FLAG_GENERIC(STATX_CTIME),
1194 FLAG_GENERIC(STATX_INO),
1197 FLAG_GENERIC(STATX_SIZE),
1200 FLAG_GENERIC(STATX_BLOCKS),
1203 FLAG_GENERIC(STATX_BTIME),
1208 UNUSED static struct flags falloc_flags[] = {
1209 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
1210 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
1211 #ifdef FALLOC_FL_NO_HIDE_STALE
1212 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
1214 #ifdef FALLOC_FL_COLLAPSE_RANGE
1215 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
1217 #ifdef FALLOC_FL_ZERO_RANGE
1218 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
1220 #ifdef FALLOC_FL_INSERT_RANGE
1221 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
1223 #ifdef FALLOC_FL_UNSHARE_RANGE
1224 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
1228 UNUSED static struct flags termios_iflags[] = {
1229 FLAG_TARGET(IGNBRK),
1230 FLAG_TARGET(BRKINT),
1231 FLAG_TARGET(IGNPAR),
1232 FLAG_TARGET(PARMRK),
1234 FLAG_TARGET(ISTRIP),
1242 FLAG_TARGET(IMAXBEL),
1247 UNUSED static struct flags termios_oflags[] = {
1253 FLAG_TARGET(ONLRET),
1259 UNUSED static struct enums termios_oflags_NLDLY[] = {
1265 UNUSED static struct enums termios_oflags_CRDLY[] = {
1273 UNUSED static struct enums termios_oflags_TABDLY[] = {
1281 UNUSED static struct enums termios_oflags_VTDLY[] = {
1287 UNUSED static struct enums termios_oflags_FFDLY[] = {
1293 UNUSED static struct enums termios_oflags_BSDLY[] = {
1299 UNUSED static struct enums termios_cflags_CBAUD[] = {
1314 ENUM_TARGET(B19200),
1315 ENUM_TARGET(B38400),
1316 ENUM_TARGET(B57600),
1317 ENUM_TARGET(B115200),
1318 ENUM_TARGET(B230400),
1319 ENUM_TARGET(B460800),
1323 UNUSED static struct enums termios_cflags_CSIZE[] = {
1331 UNUSED static struct flags termios_cflags[] = {
1332 FLAG_TARGET(CSTOPB),
1334 FLAG_TARGET(PARENB),
1335 FLAG_TARGET(PARODD),
1337 FLAG_TARGET(CLOCAL),
1338 FLAG_TARGET(CRTSCTS),
1342 UNUSED static struct flags termios_lflags[] = {
1344 FLAG_TARGET(ICANON),
1349 FLAG_TARGET(ECHONL),
1350 FLAG_TARGET(NOFLSH),
1351 FLAG_TARGET(TOSTOP),
1352 FLAG_TARGET(ECHOCTL),
1353 FLAG_TARGET(ECHOPRT),
1354 FLAG_TARGET(ECHOKE),
1355 FLAG_TARGET(FLUSHO),
1356 FLAG_TARGET(PENDIN),
1357 FLAG_TARGET(IEXTEN),
1358 FLAG_TARGET(EXTPROC),
1362 UNUSED static struct flags mlockall_flags[] = {
1363 FLAG_TARGET(MCL_CURRENT),
1364 FLAG_TARGET(MCL_FUTURE),
1366 FLAG_TARGET(MCL_ONFAULT),
1371 /* IDs of the various system clocks */
1372 #define TARGET_CLOCK_REALTIME 0
1373 #define TARGET_CLOCK_MONOTONIC 1
1374 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1375 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1376 #define TARGET_CLOCK_MONOTONIC_RAW 4
1377 #define TARGET_CLOCK_REALTIME_COARSE 5
1378 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1379 #define TARGET_CLOCK_BOOTTIME 7
1380 #define TARGET_CLOCK_REALTIME_ALARM 8
1381 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1382 #define TARGET_CLOCK_SGI_CYCLE 10
1383 #define TARGET_CLOCK_TAI 11
1385 UNUSED static struct enums clockids[] = {
1386 ENUM_TARGET(CLOCK_REALTIME),
1387 ENUM_TARGET(CLOCK_MONOTONIC),
1388 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
1389 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
1390 ENUM_TARGET(CLOCK_MONOTONIC_RAW),
1391 ENUM_TARGET(CLOCK_REALTIME_COARSE),
1392 ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
1393 ENUM_TARGET(CLOCK_BOOTTIME),
1394 ENUM_TARGET(CLOCK_REALTIME_ALARM),
1395 ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
1396 ENUM_TARGET(CLOCK_SGI_CYCLE),
1397 ENUM_TARGET(CLOCK_TAI),
1401 UNUSED static struct enums itimer_types[] = {
1402 ENUM_GENERIC(ITIMER_REAL),
1403 ENUM_GENERIC(ITIMER_VIRTUAL),
1404 ENUM_GENERIC(ITIMER_PROF),
1409 * print_xxx utility functions. These are used to print syscall
1410 * parameters in certain format. All of these have parameter
1411 * named 'last'. This parameter is used to add comma to output
1418 return ((last) ? "" : ",");
1422 print_flags(const struct flags *f, abi_long flags, int last)
1424 const char *sep = "";
1427 if ((flags == 0) && (f->f_value == 0)) {
1428 qemu_log("%s%s", f->f_string, get_comma(last));
1431 for (n = 0; f->f_string != NULL; f++) {
1432 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
1433 qemu_log("%s%s", sep, f->f_string);
1434 flags &= ~f->f_value;
1441 /* print rest of the flags as numeric */
1443 qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
1445 qemu_log("%s", get_comma(last));
1448 /* no string version of flags found, print them in hex then */
1449 qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
1454 print_enums(const struct enums *e, abi_long enum_arg, int last)
1456 for (; e->e_string != NULL; e++) {
1457 if (e->e_value == enum_arg) {
1458 qemu_log("%s", e->e_string);
1463 if (e->e_string == NULL) {
1464 qemu_log("%#x", (unsigned int)enum_arg);
1467 qemu_log("%s", get_comma(last));
1471 print_at_dirfd(abi_long dirfd, int last)
1474 if (dirfd == AT_FDCWD) {
1475 qemu_log("AT_FDCWD%s", get_comma(last));
1479 qemu_log("%d%s", (int)dirfd, get_comma(last));
1483 print_file_mode(abi_long mode, int last)
1485 const char *sep = "";
1486 const struct flags *m;
1488 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
1489 if ((m->f_value & mode) == m->f_value) {
1490 qemu_log("%s%s", m->f_string, sep);
1492 mode &= ~m->f_value;
1498 /* print rest of the mode as octal */
1500 qemu_log("%s%#o", sep, (unsigned int)mode);
1502 qemu_log("%s", get_comma(last));
1506 print_open_flags(abi_long flags, int last)
1508 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
1509 flags &= ~TARGET_O_ACCMODE;
1511 qemu_log("%s", get_comma(last));
1515 print_flags(open_flags, flags, last);
1519 print_syscall_prologue(const struct syscallname *sc)
1521 qemu_log("%s(", sc->name);
1526 print_syscall_epilogue(const struct syscallname *sc)
1533 print_string(abi_long addr, int last)
1537 if ((s = lock_user_string(addr)) != NULL) {
1538 qemu_log("\"%s\"%s", s, get_comma(last));
1539 unlock_user(s, addr, 0);
1541 /* can't get string out of it, so print it as pointer */
1542 print_pointer(addr, last);
1546 #define MAX_PRINT_BUF 40
1548 print_buf(abi_long addr, abi_long len, int last)
1553 s = lock_user(VERIFY_READ, addr, len, 1);
1556 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
1557 if (isprint(s[i])) {
1558 qemu_log("%c", s[i]);
1560 qemu_log("\\%o", s[i]);
1570 unlock_user(s, addr, 0);
1572 print_pointer(addr, last);
1577 * Prints out raw parameter using given format. Caller needs
1578 * to do byte swapping if needed.
1581 print_raw_param(const char *fmt, abi_long param, int last)
1585 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
1586 qemu_log(format, param);
1590 print_pointer(abi_long p, int last)
1593 qemu_log("NULL%s", get_comma(last));
1595 qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
1599 * Reads 32-bit (int) number from guest address space from
1600 * address 'addr' and prints it.
1603 print_number(abi_long addr, int last)
1606 qemu_log("NULL%s", get_comma(last));
1610 get_user_s32(num, addr);
1611 qemu_log("[%d]%s", num, get_comma(last));
1616 print_timeval(abi_ulong tv_addr, int last)
1619 struct target_timeval *tv;
1621 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
1623 print_pointer(tv_addr, last);
1626 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1627 ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
1628 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
1629 unlock_user(tv, tv_addr, 0);
1631 qemu_log("NULL%s", get_comma(last));
1635 print_timespec(abi_ulong ts_addr, int last)
1638 struct target_timespec *ts;
1640 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
1642 print_pointer(ts_addr, last);
1645 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1646 ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
1647 tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
1648 unlock_user(ts, ts_addr, 0);
1650 qemu_log("NULL%s", get_comma(last));
1655 print_timezone(abi_ulong tz_addr, int last)
1658 struct target_timezone *tz;
1660 tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
1662 print_pointer(tz_addr, last);
1665 qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
1666 tswap32(tz->tz_dsttime), get_comma(last));
1667 unlock_user(tz, tz_addr, 0);
1669 qemu_log("NULL%s", get_comma(last));
1674 print_itimerval(abi_ulong it_addr, int last)
1677 qemu_log("{it_interval=");
1678 print_timeval(it_addr +
1679 offsetof(struct target_itimerval, it_interval), 0);
1680 qemu_log("it_value=");
1681 print_timeval(it_addr +
1682 offsetof(struct target_itimerval, it_value), 0);
1683 qemu_log("}%s", get_comma(last));
1685 qemu_log("NULL%s", get_comma(last));
1690 print_termios(void *arg)
1692 const struct target_termios *target = arg;
1694 target_tcflag_t iflags = tswap32(target->c_iflag);
1695 target_tcflag_t oflags = tswap32(target->c_oflag);
1696 target_tcflag_t cflags = tswap32(target->c_cflag);
1697 target_tcflag_t lflags = tswap32(target->c_lflag);
1701 qemu_log("c_iflag = ");
1702 print_flags(termios_iflags, iflags, 0);
1704 qemu_log("c_oflag = ");
1705 target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
1706 TARGET_TABDLY | TARGET_BSDLY |
1707 TARGET_VTDLY | TARGET_FFDLY);
1708 print_flags(termios_oflags, oflags_clean, 0);
1709 if (oflags & TARGET_NLDLY) {
1710 print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
1712 if (oflags & TARGET_CRDLY) {
1713 print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
1715 if (oflags & TARGET_TABDLY) {
1716 print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
1718 if (oflags & TARGET_BSDLY) {
1719 print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
1721 if (oflags & TARGET_VTDLY) {
1722 print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
1724 if (oflags & TARGET_FFDLY) {
1725 print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
1728 qemu_log("c_cflag = ");
1729 if (cflags & TARGET_CBAUD) {
1730 print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
1732 if (cflags & TARGET_CSIZE) {
1733 print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
1735 target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
1736 print_flags(termios_cflags, cflags_clean, 0);
1738 qemu_log("c_lflag = ");
1739 print_flags(termios_lflags, lflags, 0);
1741 qemu_log("c_cc = ");
1742 qemu_log("\"%s\",", target->c_cc);
1744 qemu_log("c_line = ");
1745 print_raw_param("\'%c\'", target->c_line, 1);
1752 #ifdef TARGET_NR_accept
1754 print_accept(void *cpu_env, const struct syscallname *name,
1755 abi_long arg0, abi_long arg1, abi_long arg2,
1756 abi_long arg3, abi_long arg4, abi_long arg5)
1758 print_syscall_prologue(name);
1759 print_raw_param("%d", arg0, 0);
1760 print_pointer(arg1, 0);
1761 print_number(arg2, 1);
1762 print_syscall_epilogue(name);
1766 #ifdef TARGET_NR_access
1768 print_access(void *cpu_env, const struct syscallname *name,
1769 abi_long arg0, abi_long arg1, abi_long arg2,
1770 abi_long arg3, abi_long arg4, abi_long arg5)
1772 print_syscall_prologue(name);
1773 print_string(arg0, 0);
1774 print_flags(access_flags, arg1, 1);
1775 print_syscall_epilogue(name);
1779 #ifdef TARGET_NR_acct
1781 print_acct(void *cpu_env, const struct syscallname *name,
1782 abi_long arg0, abi_long arg1, abi_long arg2,
1783 abi_long arg3, abi_long arg4, abi_long arg5)
1785 print_syscall_prologue(name);
1786 print_string(arg0, 1);
1787 print_syscall_epilogue(name);
1791 #ifdef TARGET_NR_brk
1793 print_brk(void *cpu_env, const struct syscallname *name,
1794 abi_long arg0, abi_long arg1, abi_long arg2,
1795 abi_long arg3, abi_long arg4, abi_long arg5)
1797 print_syscall_prologue(name);
1798 print_pointer(arg0, 1);
1799 print_syscall_epilogue(name);
1803 #ifdef TARGET_NR_chdir
1805 print_chdir(void *cpu_env, const struct syscallname *name,
1806 abi_long arg0, abi_long arg1, abi_long arg2,
1807 abi_long arg3, abi_long arg4, abi_long arg5)
1809 print_syscall_prologue(name);
1810 print_string(arg0, 1);
1811 print_syscall_epilogue(name);
1815 #ifdef TARGET_NR_chroot
1817 print_chroot(void *cpu_env, const struct syscallname *name,
1818 abi_long arg0, abi_long arg1, abi_long arg2,
1819 abi_long arg3, abi_long arg4, abi_long arg5)
1821 print_syscall_prologue(name);
1822 print_string(arg0, 1);
1823 print_syscall_epilogue(name);
1827 #ifdef TARGET_NR_chmod
1829 print_chmod(void *cpu_env, const struct syscallname *name,
1830 abi_long arg0, abi_long arg1, abi_long arg2,
1831 abi_long arg3, abi_long arg4, abi_long arg5)
1833 print_syscall_prologue(name);
1834 print_string(arg0, 0);
1835 print_file_mode(arg1, 1);
1836 print_syscall_epilogue(name);
1840 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1842 print_chown(void *cpu_env, const struct syscallname *name,
1843 abi_long arg0, abi_long arg1, abi_long arg2,
1844 abi_long arg3, abi_long arg4, abi_long arg5)
1846 print_syscall_prologue(name);
1847 print_string(arg0, 0);
1848 print_raw_param("%d", arg1, 0);
1849 print_raw_param("%d", arg2, 1);
1850 print_syscall_epilogue(name);
1852 #define print_lchown print_chown
1855 #ifdef TARGET_NR_clock_adjtime
1857 print_clock_adjtime(void *cpu_env, const struct syscallname *name,
1858 abi_long arg0, abi_long arg1, abi_long arg2,
1859 abi_long arg3, abi_long arg4, abi_long arg5)
1861 print_syscall_prologue(name);
1862 print_enums(clockids, arg0, 0);
1863 print_pointer(arg1, 1);
1864 print_syscall_epilogue(name);
1868 #ifdef TARGET_NR_clone
1869 static void do_print_clone(unsigned int flags, abi_ulong newsp,
1870 abi_ulong parent_tidptr, target_ulong newtls,
1871 abi_ulong child_tidptr)
1873 print_flags(clone_flags, flags, 0);
1874 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
1875 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
1876 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
1877 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
1881 print_clone(void *cpu_env, const struct syscallname *name,
1882 abi_long arg1, abi_long arg2, abi_long arg3,
1883 abi_long arg4, abi_long arg5, abi_long arg6)
1885 print_syscall_prologue(name);
1886 #if defined(TARGET_MICROBLAZE)
1887 do_print_clone(arg1, arg2, arg4, arg6, arg5);
1888 #elif defined(TARGET_CLONE_BACKWARDS)
1889 do_print_clone(arg1, arg2, arg3, arg4, arg5);
1890 #elif defined(TARGET_CLONE_BACKWARDS2)
1891 do_print_clone(arg2, arg1, arg3, arg5, arg4);
1893 do_print_clone(arg1, arg2, arg3, arg5, arg4);
1895 print_syscall_epilogue(name);
1899 #ifdef TARGET_NR_creat
1901 print_creat(void *cpu_env, const struct syscallname *name,
1902 abi_long arg0, abi_long arg1, abi_long arg2,
1903 abi_long arg3, abi_long arg4, abi_long arg5)
1905 print_syscall_prologue(name);
1906 print_string(arg0, 0);
1907 print_file_mode(arg1, 1);
1908 print_syscall_epilogue(name);
1912 #ifdef TARGET_NR_execv
1914 print_execv(void *cpu_env, const struct syscallname *name,
1915 abi_long arg0, abi_long arg1, abi_long arg2,
1916 abi_long arg3, abi_long arg4, abi_long arg5)
1918 print_syscall_prologue(name);
1919 print_string(arg0, 0);
1920 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
1921 print_syscall_epilogue(name);
1925 #ifdef TARGET_NR_faccessat
1927 print_faccessat(void *cpu_env, const struct syscallname *name,
1928 abi_long arg0, abi_long arg1, abi_long arg2,
1929 abi_long arg3, abi_long arg4, abi_long arg5)
1931 print_syscall_prologue(name);
1932 print_at_dirfd(arg0, 0);
1933 print_string(arg1, 0);
1934 print_flags(access_flags, arg2, 0);
1935 print_flags(at_file_flags, arg3, 1);
1936 print_syscall_epilogue(name);
1940 #ifdef TARGET_NR_fallocate
1942 print_fallocate(void *cpu_env, const struct syscallname *name,
1943 abi_long arg0, abi_long arg1, abi_long arg2,
1944 abi_long arg3, abi_long arg4, abi_long arg5)
1946 print_syscall_prologue(name);
1947 print_raw_param("%d", arg0, 0);
1948 print_flags(falloc_flags, arg1, 0);
1949 #if TARGET_ABI_BITS == 32
1950 print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
1951 print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
1953 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1954 print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
1956 print_syscall_epilogue(name);
1960 #ifdef TARGET_NR_fchmodat
1962 print_fchmodat(void *cpu_env, const struct syscallname *name,
1963 abi_long arg0, abi_long arg1, abi_long arg2,
1964 abi_long arg3, abi_long arg4, abi_long arg5)
1966 print_syscall_prologue(name);
1967 print_at_dirfd(arg0, 0);
1968 print_string(arg1, 0);
1969 print_file_mode(arg2, 0);
1970 print_flags(at_file_flags, arg3, 1);
1971 print_syscall_epilogue(name);
1975 #ifdef TARGET_NR_fchownat
1977 print_fchownat(void *cpu_env, const struct syscallname *name,
1978 abi_long arg0, abi_long arg1, abi_long arg2,
1979 abi_long arg3, abi_long arg4, abi_long arg5)
1981 print_syscall_prologue(name);
1982 print_at_dirfd(arg0, 0);
1983 print_string(arg1, 0);
1984 print_raw_param("%d", arg2, 0);
1985 print_raw_param("%d", arg3, 0);
1986 print_flags(at_file_flags, arg4, 1);
1987 print_syscall_epilogue(name);
1991 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1993 print_fcntl(void *cpu_env, const struct syscallname *name,
1994 abi_long arg0, abi_long arg1, abi_long arg2,
1995 abi_long arg3, abi_long arg4, abi_long arg5)
1997 print_syscall_prologue(name);
1998 print_raw_param("%d", arg0, 0);
2000 case TARGET_F_DUPFD:
2001 qemu_log("F_DUPFD,");
2002 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2004 case TARGET_F_GETFD:
2005 qemu_log("F_GETFD");
2007 case TARGET_F_SETFD:
2008 qemu_log("F_SETFD,");
2009 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2011 case TARGET_F_GETFL:
2012 qemu_log("F_GETFL");
2014 case TARGET_F_SETFL:
2015 qemu_log("F_SETFL,");
2016 print_open_flags(arg2, 1);
2018 case TARGET_F_GETLK:
2019 qemu_log("F_GETLK,");
2020 print_pointer(arg2, 1);
2022 case TARGET_F_SETLK:
2023 qemu_log("F_SETLK,");
2024 print_pointer(arg2, 1);
2026 case TARGET_F_SETLKW:
2027 qemu_log("F_SETLKW,");
2028 print_pointer(arg2, 1);
2030 case TARGET_F_GETOWN:
2031 qemu_log("F_GETOWN");
2033 case TARGET_F_SETOWN:
2034 qemu_log("F_SETOWN,");
2035 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2037 case TARGET_F_GETSIG:
2038 qemu_log("F_GETSIG");
2040 case TARGET_F_SETSIG:
2041 qemu_log("F_SETSIG,");
2042 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2044 #if TARGET_ABI_BITS == 32
2045 case TARGET_F_GETLK64:
2046 qemu_log("F_GETLK64,");
2047 print_pointer(arg2, 1);
2049 case TARGET_F_SETLK64:
2050 qemu_log("F_SETLK64,");
2051 print_pointer(arg2, 1);
2053 case TARGET_F_SETLKW64:
2054 qemu_log("F_SETLKW64,");
2055 print_pointer(arg2, 1);
2058 case TARGET_F_OFD_GETLK:
2059 qemu_log("F_OFD_GETLK,");
2060 print_pointer(arg2, 1);
2062 case TARGET_F_OFD_SETLK:
2063 qemu_log("F_OFD_SETLK,");
2064 print_pointer(arg2, 1);
2066 case TARGET_F_OFD_SETLKW:
2067 qemu_log("F_OFD_SETLKW,");
2068 print_pointer(arg2, 1);
2070 case TARGET_F_SETLEASE:
2071 qemu_log("F_SETLEASE,");
2072 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2074 case TARGET_F_GETLEASE:
2075 qemu_log("F_GETLEASE");
2077 #ifdef F_DUPFD_CLOEXEC
2078 case TARGET_F_DUPFD_CLOEXEC:
2079 qemu_log("F_DUPFD_CLOEXEC,");
2080 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2083 case TARGET_F_NOTIFY:
2084 qemu_log("F_NOTIFY,");
2085 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2088 case TARGET_F_GETOWN_EX:
2089 qemu_log("F_GETOWN_EX,");
2090 print_pointer(arg2, 1);
2094 case TARGET_F_SETOWN_EX:
2095 qemu_log("F_SETOWN_EX,");
2096 print_pointer(arg2, 1);
2100 case TARGET_F_SETPIPE_SZ:
2101 qemu_log("F_SETPIPE_SZ,");
2102 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2104 case TARGET_F_GETPIPE_SZ:
2105 qemu_log("F_GETPIPE_SZ");
2109 case TARGET_F_ADD_SEALS:
2110 qemu_log("F_ADD_SEALS,");
2111 print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1);
2113 case TARGET_F_GET_SEALS:
2114 qemu_log("F_GET_SEALS");
2118 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2119 print_pointer(arg2, 1);
2122 print_syscall_epilogue(name);
2124 #define print_fcntl64 print_fcntl
2127 #ifdef TARGET_NR_fgetxattr
2129 print_fgetxattr(void *cpu_env, const struct syscallname *name,
2130 abi_long arg0, abi_long arg1, abi_long arg2,
2131 abi_long arg3, abi_long arg4, abi_long arg5)
2133 print_syscall_prologue(name);
2134 print_raw_param("%d", arg0, 0);
2135 print_string(arg1, 0);
2136 print_pointer(arg2, 0);
2137 print_raw_param(TARGET_FMT_lu, arg3, 1);
2138 print_syscall_epilogue(name);
2142 #ifdef TARGET_NR_flistxattr
2144 print_flistxattr(void *cpu_env, const struct syscallname *name,
2145 abi_long arg0, abi_long arg1, abi_long arg2,
2146 abi_long arg3, abi_long arg4, abi_long arg5)
2148 print_syscall_prologue(name);
2149 print_raw_param("%d", arg0, 0);
2150 print_pointer(arg1, 0);
2151 print_raw_param(TARGET_FMT_lu, arg2, 1);
2152 print_syscall_epilogue(name);
2156 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2158 print_getxattr(void *cpu_env, const struct syscallname *name,
2159 abi_long arg0, abi_long arg1, abi_long arg2,
2160 abi_long arg3, abi_long arg4, abi_long arg5)
2162 print_syscall_prologue(name);
2163 print_string(arg0, 0);
2164 print_string(arg1, 0);
2165 print_pointer(arg2, 0);
2166 print_raw_param(TARGET_FMT_lu, arg3, 1);
2167 print_syscall_epilogue(name);
2169 #define print_lgetxattr print_getxattr
2172 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2174 print_listxattr(void *cpu_env, 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 print_syscall_prologue(name);
2179 print_string(arg0, 0);
2180 print_pointer(arg1, 0);
2181 print_raw_param(TARGET_FMT_lu, arg2, 1);
2182 print_syscall_epilogue(name);
2184 #define print_llistxattr print_listxattr
2187 #if defined(TARGET_NR_fremovexattr)
2189 print_fremovexattr(void *cpu_env, const struct syscallname *name,
2190 abi_long arg0, abi_long arg1, abi_long arg2,
2191 abi_long arg3, abi_long arg4, abi_long arg5)
2193 print_syscall_prologue(name);
2194 print_raw_param("%d", arg0, 0);
2195 print_string(arg1, 1);
2196 print_syscall_epilogue(name);
2200 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2202 print_removexattr(void *cpu_env, const struct syscallname *name,
2203 abi_long arg0, abi_long arg1, abi_long arg2,
2204 abi_long arg3, abi_long arg4, abi_long arg5)
2206 print_syscall_prologue(name);
2207 print_string(arg0, 0);
2208 print_string(arg1, 1);
2209 print_syscall_epilogue(name);
2211 #define print_lremovexattr print_removexattr
2214 #ifdef TARGET_NR_futimesat
2216 print_futimesat(void *cpu_env, const struct syscallname *name,
2217 abi_long arg0, abi_long arg1, abi_long arg2,
2218 abi_long arg3, abi_long arg4, abi_long arg5)
2220 print_syscall_prologue(name);
2221 print_at_dirfd(arg0, 0);
2222 print_string(arg1, 0);
2223 print_timeval(arg2, 0);
2224 print_timeval(arg2 + sizeof (struct target_timeval), 1);
2225 print_syscall_epilogue(name);
2229 #ifdef TARGET_NR_gettimeofday
2231 print_gettimeofday(void *cpu_env, const struct syscallname *name,
2232 abi_long arg0, abi_long arg1, abi_long arg2,
2233 abi_long arg3, abi_long arg4, abi_long arg5)
2235 print_syscall_prologue(name);
2236 print_pointer(arg0, 0);
2237 print_pointer(arg1, 1);
2238 print_syscall_epilogue(name);
2242 #ifdef TARGET_NR_settimeofday
2244 print_settimeofday(void *cpu_env, const struct syscallname *name,
2245 abi_long arg0, abi_long arg1, abi_long arg2,
2246 abi_long arg3, abi_long arg4, abi_long arg5)
2248 print_syscall_prologue(name);
2249 print_timeval(arg0, 0);
2250 print_timezone(arg1, 1);
2251 print_syscall_epilogue(name);
2255 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2257 print_clock_gettime(void *cpu_env, const struct syscallname *name,
2258 abi_long arg0, abi_long arg1, abi_long arg2,
2259 abi_long arg3, abi_long arg4, abi_long arg5)
2261 print_syscall_prologue(name);
2262 print_enums(clockids, arg0, 0);
2263 print_pointer(arg1, 1);
2264 print_syscall_epilogue(name);
2266 #define print_clock_getres print_clock_gettime
2269 #ifdef TARGET_NR_clock_settime
2271 print_clock_settime(void *cpu_env, const struct syscallname *name,
2272 abi_long arg0, abi_long arg1, abi_long arg2,
2273 abi_long arg3, abi_long arg4, abi_long arg5)
2275 print_syscall_prologue(name);
2276 print_enums(clockids, arg0, 0);
2277 print_timespec(arg1, 1);
2278 print_syscall_epilogue(name);
2282 #ifdef TARGET_NR_getitimer
2284 print_getitimer(void *cpu_env, const struct syscallname *name,
2285 abi_long arg0, abi_long arg1, abi_long arg2,
2286 abi_long arg3, abi_long arg4, abi_long arg5)
2288 print_syscall_prologue(name);
2289 print_enums(itimer_types, arg0, 0);
2290 print_pointer(arg1, 1);
2291 print_syscall_epilogue(name);
2295 #ifdef TARGET_NR_setitimer
2297 print_setitimer(void *cpu_env, const struct syscallname *name,
2298 abi_long arg0, abi_long arg1, abi_long arg2,
2299 abi_long arg3, abi_long arg4, abi_long arg5)
2301 print_syscall_prologue(name);
2302 print_enums(itimer_types, arg0, 0);
2303 print_itimerval(arg1, 0);
2304 print_pointer(arg2, 1);
2305 print_syscall_epilogue(name);
2309 #ifdef TARGET_NR_link
2311 print_link(void *cpu_env, const struct syscallname *name,
2312 abi_long arg0, abi_long arg1, abi_long arg2,
2313 abi_long arg3, abi_long arg4, abi_long arg5)
2315 print_syscall_prologue(name);
2316 print_string(arg0, 0);
2317 print_string(arg1, 1);
2318 print_syscall_epilogue(name);
2322 #ifdef TARGET_NR_linkat
2324 print_linkat(void *cpu_env, const struct syscallname *name,
2325 abi_long arg0, abi_long arg1, abi_long arg2,
2326 abi_long arg3, abi_long arg4, abi_long arg5)
2328 print_syscall_prologue(name);
2329 print_at_dirfd(arg0, 0);
2330 print_string(arg1, 0);
2331 print_at_dirfd(arg2, 0);
2332 print_string(arg3, 0);
2333 print_flags(at_file_flags, arg4, 1);
2334 print_syscall_epilogue(name);
2338 #ifdef TARGET_NR__llseek
2340 print__llseek(void *cpu_env, const struct syscallname *name,
2341 abi_long arg0, abi_long arg1, abi_long arg2,
2342 abi_long arg3, abi_long arg4, abi_long arg5)
2344 const char *whence = "UNKNOWN";
2345 print_syscall_prologue(name);
2346 print_raw_param("%d", arg0, 0);
2347 print_raw_param("%ld", arg1, 0);
2348 print_raw_param("%ld", arg2, 0);
2349 print_pointer(arg3, 0);
2351 case SEEK_SET: whence = "SEEK_SET"; break;
2352 case SEEK_CUR: whence = "SEEK_CUR"; break;
2353 case SEEK_END: whence = "SEEK_END"; break;
2355 qemu_log("%s", whence);
2356 print_syscall_epilogue(name);
2360 #ifdef TARGET_NR_lseek
2362 print_lseek(void *cpu_env, const struct syscallname *name,
2363 abi_long arg0, abi_long arg1, abi_long arg2,
2364 abi_long arg3, abi_long arg4, abi_long arg5)
2366 print_syscall_prologue(name);
2367 print_raw_param("%d", arg0, 0);
2368 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2371 qemu_log("SEEK_SET"); break;
2373 qemu_log("SEEK_CUR"); break;
2375 qemu_log("SEEK_END"); break;
2378 qemu_log("SEEK_DATA"); break;
2382 qemu_log("SEEK_HOLE"); break;
2385 print_raw_param("%#x", arg2, 1);
2387 print_syscall_epilogue(name);
2391 #ifdef TARGET_NR_truncate
2393 print_truncate(void *cpu_env, const struct syscallname *name,
2394 abi_long arg0, abi_long arg1, abi_long arg2,
2395 abi_long arg3, abi_long arg4, abi_long arg5)
2397 print_syscall_prologue(name);
2398 print_string(arg0, 0);
2399 print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
2400 print_syscall_epilogue(name);
2404 #ifdef TARGET_NR_truncate64
2406 print_truncate64(void *cpu_env, const struct syscallname *name,
2407 abi_long arg0, abi_long arg1, abi_long arg2,
2408 abi_long arg3, abi_long arg4, abi_long arg5)
2410 print_syscall_prologue(name);
2411 print_string(arg0, 0);
2412 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
2416 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2417 print_syscall_epilogue(name);
2421 #ifdef TARGET_NR_ftruncate64
2423 print_ftruncate64(void *cpu_env, const struct syscallname *name,
2424 abi_long arg0, abi_long arg1, abi_long arg2,
2425 abi_long arg3, abi_long arg4, abi_long arg5)
2427 print_syscall_prologue(name);
2428 print_raw_param("%d", arg0, 0);
2429 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
2433 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2434 print_syscall_epilogue(name);
2438 #ifdef TARGET_NR_mlockall
2440 print_mlockall(void *cpu_env, const struct syscallname *name,
2441 abi_long arg0, abi_long arg1, abi_long arg2,
2442 abi_long arg3, abi_long arg4, abi_long arg5)
2444 print_syscall_prologue(name);
2445 print_flags(mlockall_flags, arg0, 1);
2446 print_syscall_epilogue(name);
2450 #if defined(TARGET_NR_socket)
2452 print_socket(void *cpu_env, const struct syscallname *name,
2453 abi_long arg0, abi_long arg1, abi_long arg2,
2454 abi_long arg3, abi_long arg4, abi_long arg5)
2456 abi_ulong domain = arg0, type = arg1, protocol = arg2;
2458 print_syscall_prologue(name);
2459 print_socket_domain(domain);
2461 print_socket_type(type);
2463 if (domain == AF_PACKET ||
2464 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2465 protocol = tswap16(protocol);
2467 print_socket_protocol(domain, type, protocol);
2468 print_syscall_epilogue(name);
2473 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2475 static void print_sockfd(abi_long sockfd, int last)
2477 print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
2482 #if defined(TARGET_NR_socketcall)
2484 #define get_user_ualx(x, gaddr, idx) \
2485 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2487 static void do_print_socket(const char *name, abi_long arg1)
2489 abi_ulong domain, type, protocol;
2491 get_user_ualx(domain, arg1, 0);
2492 get_user_ualx(type, arg1, 1);
2493 get_user_ualx(protocol, arg1, 2);
2494 qemu_log("%s(", name);
2495 print_socket_domain(domain);
2497 print_socket_type(type);
2499 if (domain == AF_PACKET ||
2500 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2501 protocol = tswap16(protocol);
2503 print_socket_protocol(domain, type, protocol);
2507 static void do_print_sockaddr(const char *name, abi_long arg1)
2509 abi_ulong sockfd, addr, addrlen;
2511 get_user_ualx(sockfd, arg1, 0);
2512 get_user_ualx(addr, arg1, 1);
2513 get_user_ualx(addrlen, arg1, 2);
2515 qemu_log("%s(", name);
2516 print_sockfd(sockfd, 0);
2517 print_sockaddr(addr, addrlen, 0);
2521 static void do_print_listen(const char *name, abi_long arg1)
2523 abi_ulong sockfd, backlog;
2525 get_user_ualx(sockfd, arg1, 0);
2526 get_user_ualx(backlog, arg1, 1);
2528 qemu_log("%s(", name);
2529 print_sockfd(sockfd, 0);
2530 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
2534 static void do_print_socketpair(const char *name, abi_long arg1)
2536 abi_ulong domain, type, protocol, tab;
2538 get_user_ualx(domain, arg1, 0);
2539 get_user_ualx(type, arg1, 1);
2540 get_user_ualx(protocol, arg1, 2);
2541 get_user_ualx(tab, arg1, 3);
2543 qemu_log("%s(", name);
2544 print_socket_domain(domain);
2546 print_socket_type(type);
2548 print_socket_protocol(domain, type, protocol);
2550 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
2554 static void do_print_sendrecv(const char *name, abi_long arg1)
2556 abi_ulong sockfd, msg, len, flags;
2558 get_user_ualx(sockfd, arg1, 0);
2559 get_user_ualx(msg, arg1, 1);
2560 get_user_ualx(len, arg1, 2);
2561 get_user_ualx(flags, arg1, 3);
2563 qemu_log("%s(", name);
2564 print_sockfd(sockfd, 0);
2565 print_buf(msg, len, 0);
2566 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2567 print_flags(msg_flags, flags, 1);
2571 static void do_print_msgaddr(const char *name, abi_long arg1)
2573 abi_ulong sockfd, msg, len, flags, addr, addrlen;
2575 get_user_ualx(sockfd, arg1, 0);
2576 get_user_ualx(msg, arg1, 1);
2577 get_user_ualx(len, arg1, 2);
2578 get_user_ualx(flags, arg1, 3);
2579 get_user_ualx(addr, arg1, 4);
2580 get_user_ualx(addrlen, arg1, 5);
2582 qemu_log("%s(", name);
2583 print_sockfd(sockfd, 0);
2584 print_buf(msg, len, 0);
2585 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2586 print_flags(msg_flags, flags, 0);
2587 print_sockaddr(addr, addrlen, 0);
2591 static void do_print_shutdown(const char *name, abi_long arg1)
2593 abi_ulong sockfd, how;
2595 get_user_ualx(sockfd, arg1, 0);
2596 get_user_ualx(how, arg1, 1);
2598 qemu_log("shutdown(");
2599 print_sockfd(sockfd, 0);
2602 qemu_log("SHUT_RD");
2605 qemu_log("SHUT_WR");
2608 qemu_log("SHUT_RDWR");
2611 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
2617 static void do_print_msg(const char *name, abi_long arg1)
2619 abi_ulong sockfd, msg, flags;
2621 get_user_ualx(sockfd, arg1, 0);
2622 get_user_ualx(msg, arg1, 1);
2623 get_user_ualx(flags, arg1, 2);
2625 qemu_log("%s(", name);
2626 print_sockfd(sockfd, 0);
2627 print_pointer(msg, 0);
2628 print_flags(msg_flags, flags, 1);
2632 static void do_print_sockopt(const char *name, abi_long arg1)
2634 abi_ulong sockfd, level, optname, optval, optlen;
2636 get_user_ualx(sockfd, arg1, 0);
2637 get_user_ualx(level, arg1, 1);
2638 get_user_ualx(optname, arg1, 2);
2639 get_user_ualx(optval, arg1, 3);
2640 get_user_ualx(optlen, arg1, 4);
2642 qemu_log("%s(", name);
2643 print_sockfd(sockfd, 0);
2646 qemu_log("SOL_TCP,");
2647 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2648 print_pointer(optval, 0);
2651 qemu_log("SOL_UDP,");
2652 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2653 print_pointer(optval, 0);
2656 qemu_log("SOL_IP,");
2657 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2658 print_pointer(optval, 0);
2661 qemu_log("SOL_RAW,");
2662 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2663 print_pointer(optval, 0);
2665 case TARGET_SOL_SOCKET:
2666 qemu_log("SOL_SOCKET,");
2668 case TARGET_SO_DEBUG:
2669 qemu_log("SO_DEBUG,");
2671 print_number(optval, 0);
2673 case TARGET_SO_REUSEADDR:
2674 qemu_log("SO_REUSEADDR,");
2676 case TARGET_SO_REUSEPORT:
2677 qemu_log("SO_REUSEPORT,");
2679 case TARGET_SO_TYPE:
2680 qemu_log("SO_TYPE,");
2682 case TARGET_SO_ERROR:
2683 qemu_log("SO_ERROR,");
2685 case TARGET_SO_DONTROUTE:
2686 qemu_log("SO_DONTROUTE,");
2688 case TARGET_SO_BROADCAST:
2689 qemu_log("SO_BROADCAST,");
2691 case TARGET_SO_SNDBUF:
2692 qemu_log("SO_SNDBUF,");
2694 case TARGET_SO_RCVBUF:
2695 qemu_log("SO_RCVBUF,");
2697 case TARGET_SO_KEEPALIVE:
2698 qemu_log("SO_KEEPALIVE,");
2700 case TARGET_SO_OOBINLINE:
2701 qemu_log("SO_OOBINLINE,");
2703 case TARGET_SO_NO_CHECK:
2704 qemu_log("SO_NO_CHECK,");
2706 case TARGET_SO_PRIORITY:
2707 qemu_log("SO_PRIORITY,");
2709 case TARGET_SO_BSDCOMPAT:
2710 qemu_log("SO_BSDCOMPAT,");
2712 case TARGET_SO_PASSCRED:
2713 qemu_log("SO_PASSCRED,");
2715 case TARGET_SO_TIMESTAMP:
2716 qemu_log("SO_TIMESTAMP,");
2718 case TARGET_SO_RCVLOWAT:
2719 qemu_log("SO_RCVLOWAT,");
2721 case TARGET_SO_RCVTIMEO:
2722 qemu_log("SO_RCVTIMEO,");
2723 print_timeval(optval, 0);
2725 case TARGET_SO_SNDTIMEO:
2726 qemu_log("SO_SNDTIMEO,");
2727 print_timeval(optval, 0);
2729 case TARGET_SO_ATTACH_FILTER: {
2730 struct target_sock_fprog *fprog;
2732 qemu_log("SO_ATTACH_FILTER,");
2734 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
2735 struct target_sock_filter *filter;
2737 if (lock_user_struct(VERIFY_READ, filter,
2738 tswapal(fprog->filter), 0)) {
2740 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
2741 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2742 i, tswap16(filter[i].code),
2743 filter[i].jt, filter[i].jf,
2744 tswap32(filter[i].k));
2746 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2747 i, tswap16(filter[i].code),
2748 filter[i].jt, filter[i].jf,
2749 tswap32(filter[i].k));
2751 qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
2753 qemu_log(",%d},", tswap16(fprog->len));
2754 unlock_user(fprog, optval, 0);
2756 print_pointer(optval, 0);
2761 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2762 print_pointer(optval, 0);
2767 qemu_log("SOL_IPV6,");
2769 case IPV6_MTU_DISCOVER:
2770 qemu_log("IPV6_MTU_DISCOVER,");
2773 qemu_log("IPV6_MTU,");
2776 qemu_log("IPV6_V6ONLY,");
2778 case IPV6_RECVPKTINFO:
2779 qemu_log("IPV6_RECVPKTINFO,");
2781 case IPV6_UNICAST_HOPS:
2782 qemu_log("IPV6_UNICAST_HOPS,");
2784 case IPV6_MULTICAST_HOPS:
2785 qemu_log("IPV6_MULTICAST_HOPS,");
2787 case IPV6_MULTICAST_LOOP:
2788 qemu_log("IPV6_MULTICAST_LOOP,");
2791 qemu_log("IPV6_RECVERR,");
2793 case IPV6_RECVHOPLIMIT:
2794 qemu_log("IPV6_RECVHOPLIMIT,");
2796 case IPV6_2292HOPLIMIT:
2797 qemu_log("IPV6_2292HOPLIMIT,");
2800 qemu_log("IPV6_CHECKSUM,");
2803 qemu_log("IPV6_ADDRFORM,");
2805 case IPV6_2292PKTINFO:
2806 qemu_log("IPV6_2292PKTINFO,");
2808 case IPV6_RECVTCLASS:
2809 qemu_log("IPV6_RECVTCLASS,");
2811 case IPV6_RECVRTHDR:
2812 qemu_log("IPV6_RECVRTHDR,");
2814 case IPV6_2292RTHDR:
2815 qemu_log("IPV6_2292RTHDR,");
2817 case IPV6_RECVHOPOPTS:
2818 qemu_log("IPV6_RECVHOPOPTS,");
2820 case IPV6_2292HOPOPTS:
2821 qemu_log("IPV6_2292HOPOPTS,");
2823 case IPV6_RECVDSTOPTS:
2824 qemu_log("IPV6_RECVDSTOPTS,");
2826 case IPV6_2292DSTOPTS:
2827 qemu_log("IPV6_2292DSTOPTS,");
2830 qemu_log("IPV6_TCLASS,");
2832 case IPV6_ADDR_PREFERENCES:
2833 qemu_log("IPV6_ADDR_PREFERENCES,");
2835 #ifdef IPV6_RECVPATHMTU
2836 case IPV6_RECVPATHMTU:
2837 qemu_log("IPV6_RECVPATHMTU,");
2840 #ifdef IPV6_TRANSPARENT
2841 case IPV6_TRANSPARENT:
2842 qemu_log("IPV6_TRANSPARENT,");
2845 #ifdef IPV6_FREEBIND
2847 qemu_log("IPV6_FREEBIND,");
2850 #ifdef IPV6_RECVORIGDSTADDR
2851 case IPV6_RECVORIGDSTADDR:
2852 qemu_log("IPV6_RECVORIGDSTADDR,");
2856 qemu_log("IPV6_PKTINFO,");
2857 print_pointer(optval, 0);
2859 case IPV6_ADD_MEMBERSHIP:
2860 qemu_log("IPV6_ADD_MEMBERSHIP,");
2861 print_pointer(optval, 0);
2863 case IPV6_DROP_MEMBERSHIP:
2864 qemu_log("IPV6_DROP_MEMBERSHIP,");
2865 print_pointer(optval, 0);
2868 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2869 print_pointer(optval, 0);
2874 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
2875 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2876 print_pointer(optval, 0);
2879 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
2883 #define PRINT_SOCKOP(name, func) \
2884 [TARGET_SYS_##name] = { #name, func }
2888 void (*print)(const char *, abi_long);
2890 PRINT_SOCKOP(SOCKET, do_print_socket),
2891 PRINT_SOCKOP(BIND, do_print_sockaddr),
2892 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
2893 PRINT_SOCKOP(LISTEN, do_print_listen),
2894 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
2895 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
2896 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
2897 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
2898 PRINT_SOCKOP(SEND, do_print_sendrecv),
2899 PRINT_SOCKOP(RECV, do_print_sendrecv),
2900 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
2901 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
2902 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
2903 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
2904 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
2905 PRINT_SOCKOP(SENDMSG, do_print_msg),
2906 PRINT_SOCKOP(RECVMSG, do_print_msg),
2907 PRINT_SOCKOP(ACCEPT4, NULL),
2908 PRINT_SOCKOP(RECVMMSG, NULL),
2909 PRINT_SOCKOP(SENDMMSG, NULL),
2913 print_socketcall(void *cpu_env, const struct syscallname *name,
2914 abi_long arg0, abi_long arg1, abi_long arg2,
2915 abi_long arg3, abi_long arg4, abi_long arg5)
2917 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
2918 scall[arg0].print(scall[arg0].name, arg1);
2921 print_syscall_prologue(name);
2922 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
2923 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2924 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2925 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
2926 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
2927 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
2928 print_syscall_epilogue(name);
2932 #if defined(TARGET_NR_bind)
2934 print_bind(void *cpu_env, const struct syscallname *name,
2935 abi_long arg0, abi_long arg1, abi_long arg2,
2936 abi_long arg3, abi_long arg4, abi_long arg5)
2938 print_syscall_prologue(name);
2939 print_sockfd(arg0, 0);
2940 print_sockaddr(arg1, arg2, 1);
2941 print_syscall_epilogue(name);
2945 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2946 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2948 print_stat(void *cpu_env, const struct syscallname *name,
2949 abi_long arg0, abi_long arg1, abi_long arg2,
2950 abi_long arg3, abi_long arg4, abi_long arg5)
2952 print_syscall_prologue(name);
2953 print_string(arg0, 0);
2954 print_pointer(arg1, 1);
2955 print_syscall_epilogue(name);
2957 #define print_lstat print_stat
2958 #define print_stat64 print_stat
2959 #define print_lstat64 print_stat
2962 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2964 print_fstat(void *cpu_env, const struct syscallname *name,
2965 abi_long arg0, abi_long arg1, abi_long arg2,
2966 abi_long arg3, abi_long arg4, abi_long arg5)
2968 print_syscall_prologue(name);
2969 print_raw_param("%d", arg0, 0);
2970 print_pointer(arg1, 1);
2971 print_syscall_epilogue(name);
2973 #define print_fstat64 print_fstat
2976 #ifdef TARGET_NR_mkdir
2978 print_mkdir(void *cpu_env, const struct syscallname *name,
2979 abi_long arg0, abi_long arg1, abi_long arg2,
2980 abi_long arg3, abi_long arg4, abi_long arg5)
2982 print_syscall_prologue(name);
2983 print_string(arg0, 0);
2984 print_file_mode(arg1, 1);
2985 print_syscall_epilogue(name);
2989 #ifdef TARGET_NR_mkdirat
2991 print_mkdirat(void *cpu_env, const struct syscallname *name,
2992 abi_long arg0, abi_long arg1, abi_long arg2,
2993 abi_long arg3, abi_long arg4, abi_long arg5)
2995 print_syscall_prologue(name);
2996 print_at_dirfd(arg0, 0);
2997 print_string(arg1, 0);
2998 print_file_mode(arg2, 1);
2999 print_syscall_epilogue(name);
3003 #ifdef TARGET_NR_rmdir
3005 print_rmdir(void *cpu_env, const struct syscallname *name,
3006 abi_long arg0, abi_long arg1, abi_long arg2,
3007 abi_long arg3, abi_long arg4, abi_long arg5)
3009 print_syscall_prologue(name);
3010 print_string(arg0, 0);
3011 print_syscall_epilogue(name);
3015 #ifdef TARGET_NR_rt_sigaction
3017 print_rt_sigaction(void *cpu_env, const struct syscallname *name,
3018 abi_long arg0, abi_long arg1, abi_long arg2,
3019 abi_long arg3, abi_long arg4, abi_long arg5)
3021 print_syscall_prologue(name);
3022 print_signal(arg0, 0);
3023 print_pointer(arg1, 0);
3024 print_pointer(arg2, 1);
3025 print_syscall_epilogue(name);
3029 #ifdef TARGET_NR_rt_sigprocmask
3031 print_rt_sigprocmask(void *cpu_env, const struct syscallname *name,
3032 abi_long arg0, abi_long arg1, abi_long arg2,
3033 abi_long arg3, abi_long arg4, abi_long arg5)
3035 const char *how = "UNKNOWN";
3036 print_syscall_prologue(name);
3038 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
3039 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
3040 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
3042 qemu_log("%s,", how);
3043 print_pointer(arg1, 0);
3044 print_pointer(arg2, 1);
3045 print_syscall_epilogue(name);
3049 #ifdef TARGET_NR_rt_sigqueueinfo
3051 print_rt_sigqueueinfo(void *cpu_env, const struct syscallname *name,
3052 abi_long arg0, abi_long arg1, abi_long arg2,
3053 abi_long arg3, abi_long arg4, abi_long arg5)
3056 target_siginfo_t uinfo;
3058 print_syscall_prologue(name);
3059 print_raw_param("%d", arg0, 0);
3060 print_signal(arg1, 0);
3061 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
3063 get_target_siginfo(&uinfo, p);
3064 print_siginfo(&uinfo);
3066 unlock_user(p, arg2, 0);
3068 print_pointer(arg2, 1);
3070 print_syscall_epilogue(name);
3074 #ifdef TARGET_NR_rt_tgsigqueueinfo
3076 print_rt_tgsigqueueinfo(void *cpu_env, const struct syscallname *name,
3077 abi_long arg0, abi_long arg1, abi_long arg2,
3078 abi_long arg3, abi_long arg4, abi_long arg5)
3081 target_siginfo_t uinfo;
3083 print_syscall_prologue(name);
3084 print_raw_param("%d", arg0, 0);
3085 print_raw_param("%d", arg1, 0);
3086 print_signal(arg2, 0);
3087 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
3089 get_target_siginfo(&uinfo, p);
3090 print_siginfo(&uinfo);
3092 unlock_user(p, arg3, 0);
3094 print_pointer(arg3, 1);
3096 print_syscall_epilogue(name);
3100 #ifdef TARGET_NR_syslog
3102 print_syslog_action(abi_ulong arg, int last)
3107 case TARGET_SYSLOG_ACTION_CLOSE: {
3108 type = "SYSLOG_ACTION_CLOSE";
3111 case TARGET_SYSLOG_ACTION_OPEN: {
3112 type = "SYSLOG_ACTION_OPEN";
3115 case TARGET_SYSLOG_ACTION_READ: {
3116 type = "SYSLOG_ACTION_READ";
3119 case TARGET_SYSLOG_ACTION_READ_ALL: {
3120 type = "SYSLOG_ACTION_READ_ALL";
3123 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
3124 type = "SYSLOG_ACTION_READ_CLEAR";
3127 case TARGET_SYSLOG_ACTION_CLEAR: {
3128 type = "SYSLOG_ACTION_CLEAR";
3131 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
3132 type = "SYSLOG_ACTION_CONSOLE_OFF";
3135 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
3136 type = "SYSLOG_ACTION_CONSOLE_ON";
3139 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
3140 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
3143 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
3144 type = "SYSLOG_ACTION_SIZE_UNREAD";
3147 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
3148 type = "SYSLOG_ACTION_SIZE_BUFFER";
3152 print_raw_param("%ld", arg, last);
3156 qemu_log("%s%s", type, get_comma(last));
3160 print_syslog(void *cpu_env, const struct syscallname *name,
3161 abi_long arg0, abi_long arg1, abi_long arg2,
3162 abi_long arg3, abi_long arg4, abi_long arg5)
3164 print_syscall_prologue(name);
3165 print_syslog_action(arg0, 0);
3166 print_pointer(arg1, 0);
3167 print_raw_param("%d", arg2, 1);
3168 print_syscall_epilogue(name);
3172 #ifdef TARGET_NR_mknod
3174 print_mknod(void *cpu_env, const struct syscallname *name,
3175 abi_long arg0, abi_long arg1, abi_long arg2,
3176 abi_long arg3, abi_long arg4, abi_long arg5)
3178 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
3180 print_syscall_prologue(name);
3181 print_string(arg0, 0);
3182 print_file_mode(arg1, (hasdev == 0));
3184 print_raw_param("makedev(%d", major(arg2), 0);
3185 print_raw_param("%d)", minor(arg2), 1);
3187 print_syscall_epilogue(name);
3191 #ifdef TARGET_NR_mknodat
3193 print_mknodat(void *cpu_env, const struct syscallname *name,
3194 abi_long arg0, abi_long arg1, abi_long arg2,
3195 abi_long arg3, abi_long arg4, abi_long arg5)
3197 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
3199 print_syscall_prologue(name);
3200 print_at_dirfd(arg0, 0);
3201 print_string(arg1, 0);
3202 print_file_mode(arg2, (hasdev == 0));
3204 print_raw_param("makedev(%d", major(arg3), 0);
3205 print_raw_param("%d)", minor(arg3), 1);
3207 print_syscall_epilogue(name);
3211 #ifdef TARGET_NR_mq_open
3213 print_mq_open(void *cpu_env, const struct syscallname *name,
3214 abi_long arg0, abi_long arg1, abi_long arg2,
3215 abi_long arg3, abi_long arg4, abi_long arg5)
3217 int is_creat = (arg1 & TARGET_O_CREAT);
3219 print_syscall_prologue(name);
3220 print_string(arg0, 0);
3221 print_open_flags(arg1, (is_creat == 0));
3223 print_file_mode(arg2, 0);
3224 print_pointer(arg3, 1);
3226 print_syscall_epilogue(name);
3230 #ifdef TARGET_NR_open
3232 print_open(void *cpu_env, const struct syscallname *name,
3233 abi_long arg0, abi_long arg1, abi_long arg2,
3234 abi_long arg3, abi_long arg4, abi_long arg5)
3236 int is_creat = (arg1 & TARGET_O_CREAT);
3238 print_syscall_prologue(name);
3239 print_string(arg0, 0);
3240 print_open_flags(arg1, (is_creat == 0));
3242 print_file_mode(arg2, 1);
3243 print_syscall_epilogue(name);
3247 #ifdef TARGET_NR_openat
3249 print_openat(void *cpu_env, const struct syscallname *name,
3250 abi_long arg0, abi_long arg1, abi_long arg2,
3251 abi_long arg3, abi_long arg4, abi_long arg5)
3253 int is_creat = (arg2 & TARGET_O_CREAT);
3255 print_syscall_prologue(name);
3256 print_at_dirfd(arg0, 0);
3257 print_string(arg1, 0);
3258 print_open_flags(arg2, (is_creat == 0));
3260 print_file_mode(arg3, 1);
3261 print_syscall_epilogue(name);
3265 #ifdef TARGET_NR_mq_unlink
3267 print_mq_unlink(void *cpu_env, const struct syscallname *name,
3268 abi_long arg0, abi_long arg1, abi_long arg2,
3269 abi_long arg3, abi_long arg4, abi_long arg5)
3271 print_syscall_prologue(name);
3272 print_string(arg0, 1);
3273 print_syscall_epilogue(name);
3277 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3279 print_fstatat64(void *cpu_env, const struct syscallname *name,
3280 abi_long arg0, abi_long arg1, abi_long arg2,
3281 abi_long arg3, abi_long arg4, abi_long arg5)
3283 print_syscall_prologue(name);
3284 print_at_dirfd(arg0, 0);
3285 print_string(arg1, 0);
3286 print_pointer(arg2, 0);
3287 print_flags(at_file_flags, arg3, 1);
3288 print_syscall_epilogue(name);
3290 #define print_newfstatat print_fstatat64
3293 #ifdef TARGET_NR_readlink
3295 print_readlink(void *cpu_env, const struct syscallname *name,
3296 abi_long arg0, abi_long arg1, abi_long arg2,
3297 abi_long arg3, abi_long arg4, abi_long arg5)
3299 print_syscall_prologue(name);
3300 print_string(arg0, 0);
3301 print_pointer(arg1, 0);
3302 print_raw_param("%u", arg2, 1);
3303 print_syscall_epilogue(name);
3307 #ifdef TARGET_NR_readlinkat
3309 print_readlinkat(void *cpu_env, const struct syscallname *name,
3310 abi_long arg0, abi_long arg1, abi_long arg2,
3311 abi_long arg3, abi_long arg4, abi_long arg5)
3313 print_syscall_prologue(name);
3314 print_at_dirfd(arg0, 0);
3315 print_string(arg1, 0);
3316 print_pointer(arg2, 0);
3317 print_raw_param("%u", arg3, 1);
3318 print_syscall_epilogue(name);
3322 #ifdef TARGET_NR_rename
3324 print_rename(void *cpu_env, const struct syscallname *name,
3325 abi_long arg0, abi_long arg1, abi_long arg2,
3326 abi_long arg3, abi_long arg4, abi_long arg5)
3328 print_syscall_prologue(name);
3329 print_string(arg0, 0);
3330 print_string(arg1, 1);
3331 print_syscall_epilogue(name);
3335 #ifdef TARGET_NR_renameat
3337 print_renameat(void *cpu_env, const struct syscallname *name,
3338 abi_long arg0, abi_long arg1, abi_long arg2,
3339 abi_long arg3, abi_long arg4, abi_long arg5)
3341 print_syscall_prologue(name);
3342 print_at_dirfd(arg0, 0);
3343 print_string(arg1, 0);
3344 print_at_dirfd(arg2, 0);
3345 print_string(arg3, 1);
3346 print_syscall_epilogue(name);
3350 #ifdef TARGET_NR_statfs
3352 print_statfs(void *cpu_env, const struct syscallname *name,
3353 abi_long arg0, abi_long arg1, abi_long arg2,
3354 abi_long arg3, abi_long arg4, abi_long arg5)
3356 print_syscall_prologue(name);
3357 print_string(arg0, 0);
3358 print_pointer(arg1, 1);
3359 print_syscall_epilogue(name);
3363 #ifdef TARGET_NR_statfs64
3365 print_statfs64(void *cpu_env, const struct syscallname *name,
3366 abi_long arg0, abi_long arg1, abi_long arg2,
3367 abi_long arg3, abi_long arg4, abi_long arg5)
3369 print_syscall_prologue(name);
3370 print_string(arg0, 0);
3371 print_pointer(arg1, 1);
3372 print_syscall_epilogue(name);
3376 #ifdef TARGET_NR_symlink
3378 print_symlink(void *cpu_env, const struct syscallname *name,
3379 abi_long arg0, abi_long arg1, abi_long arg2,
3380 abi_long arg3, abi_long arg4, abi_long arg5)
3382 print_syscall_prologue(name);
3383 print_string(arg0, 0);
3384 print_string(arg1, 1);
3385 print_syscall_epilogue(name);
3389 #ifdef TARGET_NR_symlinkat
3391 print_symlinkat(void *cpu_env, const struct syscallname *name,
3392 abi_long arg0, abi_long arg1, abi_long arg2,
3393 abi_long arg3, abi_long arg4, abi_long arg5)
3395 print_syscall_prologue(name);
3396 print_string(arg0, 0);
3397 print_at_dirfd(arg1, 0);
3398 print_string(arg2, 1);
3399 print_syscall_epilogue(name);
3403 #ifdef TARGET_NR_mount
3405 print_mount(void *cpu_env, const struct syscallname *name,
3406 abi_long arg0, abi_long arg1, abi_long arg2,
3407 abi_long arg3, abi_long arg4, abi_long arg5)
3409 print_syscall_prologue(name);
3410 print_string(arg0, 0);
3411 print_string(arg1, 0);
3412 print_string(arg2, 0);
3413 print_flags(mount_flags, arg3, 0);
3414 print_pointer(arg4, 1);
3415 print_syscall_epilogue(name);
3419 #ifdef TARGET_NR_umount
3421 print_umount(void *cpu_env, const struct syscallname *name,
3422 abi_long arg0, abi_long arg1, abi_long arg2,
3423 abi_long arg3, abi_long arg4, abi_long arg5)
3425 print_syscall_prologue(name);
3426 print_string(arg0, 1);
3427 print_syscall_epilogue(name);
3431 #ifdef TARGET_NR_umount2
3433 print_umount2(void *cpu_env, const struct syscallname *name,
3434 abi_long arg0, abi_long arg1, abi_long arg2,
3435 abi_long arg3, abi_long arg4, abi_long arg5)
3437 print_syscall_prologue(name);
3438 print_string(arg0, 0);
3439 print_flags(umount2_flags, arg1, 1);
3440 print_syscall_epilogue(name);
3444 #ifdef TARGET_NR_unlink
3446 print_unlink(void *cpu_env, const struct syscallname *name,
3447 abi_long arg0, abi_long arg1, abi_long arg2,
3448 abi_long arg3, abi_long arg4, abi_long arg5)
3450 print_syscall_prologue(name);
3451 print_string(arg0, 1);
3452 print_syscall_epilogue(name);
3456 #ifdef TARGET_NR_unlinkat
3458 print_unlinkat(void *cpu_env, const struct syscallname *name,
3459 abi_long arg0, abi_long arg1, abi_long arg2,
3460 abi_long arg3, abi_long arg4, abi_long arg5)
3462 print_syscall_prologue(name);
3463 print_at_dirfd(arg0, 0);
3464 print_string(arg1, 0);
3465 print_flags(unlinkat_flags, arg2, 1);
3466 print_syscall_epilogue(name);
3470 #ifdef TARGET_NR_utime
3472 print_utime(void *cpu_env, const struct syscallname *name,
3473 abi_long arg0, abi_long arg1, abi_long arg2,
3474 abi_long arg3, abi_long arg4, abi_long arg5)
3476 print_syscall_prologue(name);
3477 print_string(arg0, 0);
3478 print_pointer(arg1, 1);
3479 print_syscall_epilogue(name);
3483 #ifdef TARGET_NR_utimes
3485 print_utimes(void *cpu_env, const struct syscallname *name,
3486 abi_long arg0, abi_long arg1, abi_long arg2,
3487 abi_long arg3, abi_long arg4, abi_long arg5)
3489 print_syscall_prologue(name);
3490 print_string(arg0, 0);
3491 print_pointer(arg1, 1);
3492 print_syscall_epilogue(name);
3496 #ifdef TARGET_NR_utimensat
3498 print_utimensat(void *cpu_env, const struct syscallname *name,
3499 abi_long arg0, abi_long arg1, abi_long arg2,
3500 abi_long arg3, abi_long arg4, abi_long arg5)
3502 print_syscall_prologue(name);
3503 print_at_dirfd(arg0, 0);
3504 print_string(arg1, 0);
3505 print_pointer(arg2, 0);
3506 print_flags(at_file_flags, arg3, 1);
3507 print_syscall_epilogue(name);
3511 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3513 print_mmap(void *cpu_env, const struct syscallname *name,
3514 abi_long arg0, abi_long arg1, abi_long arg2,
3515 abi_long arg3, abi_long arg4, abi_long arg5)
3517 print_syscall_prologue(name);
3518 print_pointer(arg0, 0);
3519 print_raw_param("%d", arg1, 0);
3520 print_flags(mmap_prot_flags, arg2, 0);
3521 print_flags(mmap_flags, arg3, 0);
3522 print_raw_param("%d", arg4, 0);
3523 print_raw_param("%#x", arg5, 1);
3524 print_syscall_epilogue(name);
3526 #define print_mmap2 print_mmap
3529 #ifdef TARGET_NR_mprotect
3531 print_mprotect(void *cpu_env, const struct syscallname *name,
3532 abi_long arg0, abi_long arg1, abi_long arg2,
3533 abi_long arg3, abi_long arg4, abi_long arg5)
3535 print_syscall_prologue(name);
3536 print_pointer(arg0, 0);
3537 print_raw_param("%d", arg1, 0);
3538 print_flags(mmap_prot_flags, arg2, 1);
3539 print_syscall_epilogue(name);
3543 #ifdef TARGET_NR_munmap
3545 print_munmap(void *cpu_env, const struct syscallname *name,
3546 abi_long arg0, abi_long arg1, abi_long arg2,
3547 abi_long arg3, abi_long arg4, abi_long arg5)
3549 print_syscall_prologue(name);
3550 print_pointer(arg0, 0);
3551 print_raw_param("%d", arg1, 1);
3552 print_syscall_epilogue(name);
3556 #ifdef TARGET_NR_futex
3557 static void print_futex_op(abi_long tflag, int last)
3559 #define print_op(val) \
3560 if( cmd == val ) { \
3565 int cmd = (int)tflag;
3566 #ifdef FUTEX_PRIVATE_FLAG
3567 if (cmd & FUTEX_PRIVATE_FLAG) {
3568 qemu_log("FUTEX_PRIVATE_FLAG|");
3569 cmd &= ~FUTEX_PRIVATE_FLAG;
3572 #ifdef FUTEX_CLOCK_REALTIME
3573 if (cmd & FUTEX_CLOCK_REALTIME) {
3574 qemu_log("FUTEX_CLOCK_REALTIME|");
3575 cmd &= ~FUTEX_CLOCK_REALTIME;
3578 print_op(FUTEX_WAIT)
3579 print_op(FUTEX_WAKE)
3581 print_op(FUTEX_REQUEUE)
3582 print_op(FUTEX_CMP_REQUEUE)
3583 print_op(FUTEX_WAKE_OP)
3584 print_op(FUTEX_LOCK_PI)
3585 print_op(FUTEX_UNLOCK_PI)
3586 print_op(FUTEX_TRYLOCK_PI)
3587 #ifdef FUTEX_WAIT_BITSET
3588 print_op(FUTEX_WAIT_BITSET)
3590 #ifdef FUTEX_WAKE_BITSET
3591 print_op(FUTEX_WAKE_BITSET)
3593 /* unknown values */
3594 qemu_log("%d", cmd);
3598 print_futex(void *cpu_env, const struct syscallname *name,
3599 abi_long arg0, abi_long arg1, abi_long arg2,
3600 abi_long arg3, abi_long arg4, abi_long arg5)
3602 print_syscall_prologue(name);
3603 print_pointer(arg0, 0);
3604 print_futex_op(arg1, 0);
3605 print_raw_param(",%d", arg2, 0);
3606 print_pointer(arg3, 0); /* struct timespec */
3607 print_pointer(arg4, 0);
3608 print_raw_param("%d", arg4, 1);
3609 print_syscall_epilogue(name);
3613 #ifdef TARGET_NR_kill
3615 print_kill(void *cpu_env, const struct syscallname *name,
3616 abi_long arg0, abi_long arg1, abi_long arg2,
3617 abi_long arg3, abi_long arg4, abi_long arg5)
3619 print_syscall_prologue(name);
3620 print_raw_param("%d", arg0, 0);
3621 print_signal(arg1, 1);
3622 print_syscall_epilogue(name);
3626 #ifdef TARGET_NR_tkill
3628 print_tkill(void *cpu_env, const struct syscallname *name,
3629 abi_long arg0, abi_long arg1, abi_long arg2,
3630 abi_long arg3, abi_long arg4, abi_long arg5)
3632 print_syscall_prologue(name);
3633 print_raw_param("%d", arg0, 0);
3634 print_signal(arg1, 1);
3635 print_syscall_epilogue(name);
3639 #ifdef TARGET_NR_tgkill
3641 print_tgkill(void *cpu_env, const struct syscallname *name,
3642 abi_long arg0, abi_long arg1, abi_long arg2,
3643 abi_long arg3, abi_long arg4, abi_long arg5)
3645 print_syscall_prologue(name);
3646 print_raw_param("%d", arg0, 0);
3647 print_raw_param("%d", arg1, 0);
3648 print_signal(arg2, 1);
3649 print_syscall_epilogue(name);
3653 #ifdef TARGET_NR_statx
3655 print_statx(void *cpu_env, const struct syscallname *name,
3656 abi_long arg0, abi_long arg1, abi_long arg2,
3657 abi_long arg3, abi_long arg4, abi_long arg5)
3659 print_syscall_prologue(name);
3660 print_at_dirfd(arg0, 0);
3661 print_string(arg1, 0);
3662 print_flags(statx_flags, arg2, 0);
3663 print_flags(statx_mask, arg3, 0);
3664 print_pointer(arg4, 1);
3665 print_syscall_epilogue(name);
3669 #ifdef TARGET_NR_ioctl
3671 print_ioctl(void *cpu_env, const struct syscallname *name,
3672 abi_long arg0, abi_long arg1, abi_long arg2,
3673 abi_long arg3, abi_long arg4, abi_long arg5)
3675 print_syscall_prologue(name);
3676 print_raw_param("%d", arg0, 0);
3678 const IOCTLEntry *ie;
3679 const argtype *arg_type;
3683 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
3684 if (ie->target_cmd == arg1) {
3689 if (ie->target_cmd == 0) {
3690 print_raw_param("%#x", arg1, 0);
3691 print_raw_param("%#x", arg2, 1);
3693 qemu_log("%s", ie->name);
3694 arg_type = ie->arg_type;
3696 if (arg_type[0] != TYPE_NULL) {
3699 switch (arg_type[0]) {
3701 print_pointer(arg2, 1);
3706 print_raw_param("%d", arg2, 1);
3709 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
3712 print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
3715 switch (ie->access) {
3717 print_pointer(arg2, 1);
3722 target_size = thunk_type_size(arg_type, 0);
3723 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
3725 thunk_print(argptr, arg_type);
3726 unlock_user(argptr, arg2, target_size);
3728 print_pointer(arg2, 1);
3734 g_assert_not_reached();
3738 print_syscall_epilogue(name);
3743 * An array of all of the syscalls we know about
3746 static const struct syscallname scnames[] = {
3747 #include "strace.list"
3750 static int nsyscalls = ARRAY_SIZE(scnames);
3753 * The public interface to this module.
3756 print_syscall(void *cpu_env, int num,
3757 abi_long arg1, abi_long arg2, abi_long arg3,
3758 abi_long arg4, abi_long arg5, abi_long arg6)
3761 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 ")";
3763 qemu_log("%d ", getpid());
3765 for(i=0;i<nsyscalls;i++)
3766 if( scnames[i].nr == num ) {
3767 if( scnames[i].call != NULL ) {
3769 cpu_env, &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6);
3771 /* XXX: this format system is broken because it uses
3772 host types and host pointers for strings */
3773 if( scnames[i].format != NULL )
3774 format = scnames[i].format;
3776 scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6);
3780 qemu_log("Unknown syscall %d\n", num);
3785 print_syscall_ret(void *cpu_env, int num, abi_long ret,
3786 abi_long arg1, abi_long arg2, abi_long arg3,
3787 abi_long arg4, abi_long arg5, abi_long arg6)
3791 for(i=0;i<nsyscalls;i++)
3792 if( scnames[i].nr == num ) {
3793 if( scnames[i].result != NULL ) {
3794 scnames[i].result(cpu_env, &scnames[i], ret,
3798 if (!print_syscall_err(ret)) {
3799 qemu_log(TARGET_ABI_FMT_ld, ret);
3807 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
3809 /* Print the strace output for a signal being taken:
3810 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3813 print_signal(target_signum, 1);
3815 print_siginfo(tinfo);