1 #include "qemu/osdep.h"
7 #include <sys/select.h>
10 #include <netinet/in.h>
11 #include <netinet/tcp.h>
12 #include <netinet/udp.h>
13 #include <linux/if_packet.h>
14 #include <linux/in6.h>
15 #include <linux/netlink.h>
18 #include "user-internals.h"
25 void (*call)(CPUArchState *, const struct syscallname *,
26 abi_long, abi_long, abi_long,
27 abi_long, abi_long, abi_long);
28 void (*result)(CPUArchState *, const struct syscallname *, abi_long,
29 abi_long, abi_long, abi_long,
30 abi_long, abi_long, abi_long);
34 * It is possible that target doesn't have syscall that uses
35 * following flags but we don't want the compiler to warn
36 * us about them being unused. Same applies to utility print
37 * functions. It is ok to keep them while not used.
39 #define UNUSED __attribute__ ((unused))
42 * Structure used to translate flag values into strings. This is
43 * similar that is in the actual strace tool.
46 abi_long f_value; /* flag */
47 const char *f_string; /* stringified flag */
50 /* common flags for all architectures */
51 #define FLAG_GENERIC(name) { name, #name }
52 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
53 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
54 /* end of flags array */
55 #define FLAG_END { 0, NULL }
57 /* Structure used to translate enumerated values into strings */
59 abi_long e_value; /* enum value */
60 const char *e_string; /* stringified enum */
63 /* common enums for all architectures */
64 #define ENUM_GENERIC(name) { name, #name }
65 /* target specific enums */
66 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
67 /* end of enums array */
68 #define ENUM_END { 0, NULL }
70 UNUSED static const char *get_comma(int);
71 UNUSED static void print_pointer(abi_long, int);
72 UNUSED static void print_flags(const struct flags *, abi_long, int);
73 UNUSED static void print_enums(const struct enums *, abi_long, int);
74 UNUSED static void print_at_dirfd(abi_long, int);
75 UNUSED static void print_file_mode(abi_long, int);
76 UNUSED static void print_open_flags(abi_long, int);
77 UNUSED static void print_syscall_prologue(const struct syscallname *);
78 UNUSED static void print_syscall_epilogue(const struct syscallname *);
79 UNUSED static void print_string(abi_long, int);
80 UNUSED static void print_buf(abi_long addr, abi_long len, int last);
81 UNUSED static void print_raw_param(const char *, abi_long, int);
82 UNUSED static void print_timeval(abi_ulong, int);
83 UNUSED static void print_timespec(abi_ulong, int);
84 UNUSED static void print_timezone(abi_ulong, int);
85 UNUSED static void print_itimerval(abi_ulong, int);
86 UNUSED static void print_number(abi_long, int);
87 UNUSED static void print_signal(abi_ulong, int);
88 UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
89 UNUSED static void print_socket_domain(int domain);
90 UNUSED static void print_socket_type(int type);
91 UNUSED static void print_socket_protocol(int domain, int type, int protocol);
97 print_ipc_cmd(int cmd)
99 #define output_cmd(val) \
107 /* General IPC commands */
108 output_cmd( IPC_RMID );
109 output_cmd( IPC_SET );
110 output_cmd( IPC_STAT );
111 output_cmd( IPC_INFO );
112 /* msgctl() commands */
113 output_cmd( MSG_STAT );
114 output_cmd( MSG_INFO );
115 /* shmctl() commands */
116 output_cmd( SHM_LOCK );
117 output_cmd( SHM_UNLOCK );
118 output_cmd( SHM_STAT );
119 output_cmd( SHM_INFO );
120 /* semctl() commands */
121 output_cmd( GETPID );
122 output_cmd( GETVAL );
123 output_cmd( GETALL );
124 output_cmd( GETNCNT );
125 output_cmd( GETZCNT );
126 output_cmd( SETVAL );
127 output_cmd( SETALL );
128 output_cmd( SEM_STAT );
129 output_cmd( SEM_INFO );
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 );
136 output_cmd( IPC_RMID );
137 output_cmd( IPC_RMID );
138 output_cmd( IPC_RMID );
140 /* Some value we don't recognize */
145 print_signal(abi_ulong arg, int last)
147 const char *signal_name = NULL;
149 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
150 case TARGET_SIGINT: signal_name = "SIGINT"; break;
151 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
152 case TARGET_SIGILL: signal_name = "SIGILL"; break;
153 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
154 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
155 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
156 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
157 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
158 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
159 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
160 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
161 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
162 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
163 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
164 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
165 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
166 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
168 if (signal_name == NULL) {
169 print_raw_param("%ld", arg, last);
172 qemu_log("%s%s", signal_name, get_comma(last));
175 static void print_si_code(int arg)
177 const char *codename = NULL;
181 codename = "SI_USER";
184 codename = "SI_KERNEL";
187 codename = "SI_QUEUE";
190 codename = "SI_TIMER";
193 codename = "SI_MESGQ";
196 codename = "SI_ASYNCIO";
199 codename = "SI_SIGIO";
202 codename = "SI_TKILL";
208 qemu_log("%s", codename);
211 static void get_target_siginfo(target_siginfo_t *tinfo,
212 const target_siginfo_t *info)
221 __get_user(sig, &info->si_signo);
222 __get_user(si_errno, &tinfo->si_errno);
223 __get_user(si_code, &info->si_code);
225 tinfo->si_signo = sig;
226 tinfo->si_errno = si_errno;
227 tinfo->si_code = si_code;
229 /* Ensure we don't leak random junk to the guest later */
230 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
232 /* This is awkward, because we have to use a combination of
233 * the si_code and si_signo to figure out which of the union's
234 * members are valid. (Within the host kernel it is always possible
235 * to tell, but the kernel carefully avoids giving userspace the
236 * high 16 bits of si_code, so we don't have the information to
237 * do this the easy way...) We therefore make our best guess,
238 * bearing in mind that a guest can spoof most of the si_codes
239 * via rt_sigqueueinfo() if it likes.
241 * Once we have made our guess, we record it in the top 16 bits of
242 * the si_code, so that print_siginfo() later can use it.
243 * print_siginfo() will strip these top bits out before printing
251 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
252 * These are the only unspoofable si_code values.
254 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
255 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
256 si_type = QEMU_SI_KILL;
259 /* Everything else is spoofable. Make best guess based on signal */
262 __get_user(tinfo->_sifields._sigchld._pid,
263 &info->_sifields._sigchld._pid);
264 __get_user(tinfo->_sifields._sigchld._uid,
265 &info->_sifields._sigchld._uid);
266 __get_user(tinfo->_sifields._sigchld._status,
267 &info->_sifields._sigchld._status);
268 __get_user(tinfo->_sifields._sigchld._utime,
269 &info->_sifields._sigchld._utime);
270 __get_user(tinfo->_sifields._sigchld._stime,
271 &info->_sifields._sigchld._stime);
272 si_type = QEMU_SI_CHLD;
275 __get_user(tinfo->_sifields._sigpoll._band,
276 &info->_sifields._sigpoll._band);
277 __get_user(tinfo->_sifields._sigpoll._fd,
278 &info->_sifields._sigpoll._fd);
279 si_type = QEMU_SI_POLL;
282 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
283 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
284 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
285 /* XXX: potential problem if 64 bit */
286 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
287 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
289 si_type = QEMU_SI_RT;
295 tinfo->si_code = deposit32(si_code, 16, 16, si_type);
298 static void print_siginfo(const target_siginfo_t *tinfo)
300 /* Print a target_siginfo_t in the format desired for printing
301 * signals being taken. We assume the target_siginfo_t is in the
302 * internal form where the top 16 bits of si_code indicate which
303 * part of the union is valid, rather than in the guest-visible
304 * form where the bottom 16 bits are sign-extended into the top 16.
306 int si_type = extract32(tinfo->si_code, 16, 16);
307 int si_code = sextract32(tinfo->si_code, 0, 16);
309 qemu_log("{si_signo=");
310 print_signal(tinfo->si_signo, 1);
311 qemu_log(", si_code=");
312 print_si_code(si_code);
316 qemu_log(", si_pid=%u, si_uid=%u",
317 (unsigned int)tinfo->_sifields._kill._pid,
318 (unsigned int)tinfo->_sifields._kill._uid);
321 qemu_log(", si_timer1=%u, si_timer2=%u",
322 tinfo->_sifields._timer._timer1,
323 tinfo->_sifields._timer._timer2);
326 qemu_log(", si_band=%d, si_fd=%d",
327 tinfo->_sifields._sigpoll._band,
328 tinfo->_sifields._sigpoll._fd);
331 qemu_log(", si_addr=");
332 print_pointer(tinfo->_sifields._sigfault._addr, 1);
335 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
336 ", si_utime=" TARGET_ABI_FMT_ld
337 ", si_stime=" TARGET_ABI_FMT_ld,
338 (unsigned int)(tinfo->_sifields._sigchld._pid),
339 (unsigned int)(tinfo->_sifields._sigchld._uid),
340 tinfo->_sifields._sigchld._status,
341 tinfo->_sifields._sigchld._utime,
342 tinfo->_sifields._sigchld._stime);
345 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
346 (unsigned int)tinfo->_sifields._rt._pid,
347 (unsigned int)tinfo->_sifields._rt._uid,
348 tinfo->_sifields._rt._sigval.sival_ptr);
351 g_assert_not_reached();
357 print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
359 struct target_sockaddr *sa;
363 sa = lock_user(VERIFY_READ, addr, addrlen, 1);
365 sa_family = tswap16(sa->sa_family);
368 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
370 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
371 for (i = 0; i < addrlen -
372 offsetof(struct target_sockaddr_un, sun_path) &&
373 un->sun_path[i]; i++) {
374 qemu_log("%c", un->sun_path[i]);
380 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
381 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
382 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
383 ntohs(in->sin_port));
384 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
385 c[0], c[1], c[2], c[3]);
390 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
391 uint8_t *c = (uint8_t *)&ll->sll_addr;
392 qemu_log("{sll_family=AF_PACKET,"
393 "sll_protocol=htons(0x%04x),if%d,pkttype=",
394 ntohs(ll->sll_protocol), ll->sll_ifindex);
395 switch (ll->sll_pkttype) {
397 qemu_log("PACKET_HOST");
399 case PACKET_BROADCAST:
400 qemu_log("PACKET_BROADCAST");
402 case PACKET_MULTICAST:
403 qemu_log("PACKET_MULTICAST");
405 case PACKET_OTHERHOST:
406 qemu_log("PACKET_OTHERHOST");
408 case PACKET_OUTGOING:
409 qemu_log("PACKET_OUTGOING");
412 qemu_log("%d", ll->sll_pkttype);
415 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
416 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
421 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
422 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
423 tswap32(nl->nl_pid), tswap32(nl->nl_groups));
427 qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
428 for (i = 0; i < 13; i++) {
429 qemu_log("%02x, ", sa->sa_data[i]);
431 qemu_log("%02x}", sa->sa_data[i]);
435 unlock_user(sa, addr, 0);
437 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
439 qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
443 print_socket_domain(int domain)
453 qemu_log("PF_NETLINK");
456 qemu_log("PF_PACKET");
459 qemu_log("%d", domain);
465 print_socket_type(int type)
467 switch (type & TARGET_SOCK_TYPE_MASK) {
468 case TARGET_SOCK_DGRAM:
469 qemu_log("SOCK_DGRAM");
471 case TARGET_SOCK_STREAM:
472 qemu_log("SOCK_STREAM");
474 case TARGET_SOCK_RAW:
475 qemu_log("SOCK_RAW");
477 case TARGET_SOCK_RDM:
478 qemu_log("SOCK_RDM");
480 case TARGET_SOCK_SEQPACKET:
481 qemu_log("SOCK_SEQPACKET");
483 case TARGET_SOCK_PACKET:
484 qemu_log("SOCK_PACKET");
487 if (type & TARGET_SOCK_CLOEXEC) {
488 qemu_log("|SOCK_CLOEXEC");
490 if (type & TARGET_SOCK_NONBLOCK) {
491 qemu_log("|SOCK_NONBLOCK");
496 print_socket_protocol(int domain, int type, int protocol)
498 if (domain == AF_PACKET ||
499 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
502 qemu_log("ETH_P_ALL");
505 qemu_log("%d", protocol);
510 if (domain == PF_NETLINK) {
513 qemu_log("NETLINK_ROUTE");
516 qemu_log("NETLINK_AUDIT");
518 case NETLINK_NETFILTER:
519 qemu_log("NETLINK_NETFILTER");
521 case NETLINK_KOBJECT_UEVENT:
522 qemu_log("NETLINK_KOBJECT_UEVENT");
525 qemu_log("NETLINK_RDMA");
528 qemu_log("NETLINK_CRYPTO");
531 qemu_log("%d", protocol);
539 qemu_log("IPPROTO_IP");
542 qemu_log("IPPROTO_TCP");
545 qemu_log("IPPROTO_UDP");
548 qemu_log("IPPROTO_RAW");
551 qemu_log("%d", protocol);
557 #ifdef TARGET_NR__newselect
559 print_fdset(int n, abi_ulong target_fds_addr)
565 if( target_fds_addr ) {
566 abi_long *target_fds;
568 target_fds = lock_user(VERIFY_READ,
570 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
576 for (i=n; i>=0; i--) {
577 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
578 (i & (TARGET_ABI_BITS - 1))) & 1) {
579 qemu_log("%s%d", get_comma(first), i);
583 unlock_user(target_fds, target_fds_addr, 0);
590 * Sysycall specific output functions
594 #ifdef TARGET_NR__newselect
596 print_newselect(CPUArchState *cpu_env, const struct syscallname *name,
597 abi_long arg1, abi_long arg2, abi_long arg3,
598 abi_long arg4, abi_long arg5, abi_long arg6)
600 print_syscall_prologue(name);
601 print_fdset(arg1, arg2);
603 print_fdset(arg1, arg3);
605 print_fdset(arg1, arg4);
607 print_timeval(arg5, 1);
608 print_syscall_epilogue(name);
612 #ifdef TARGET_NR_semctl
614 print_semctl(CPUArchState *cpu_env, const struct syscallname *name,
615 abi_long arg1, abi_long arg2, abi_long arg3,
616 abi_long arg4, abi_long arg5, abi_long arg6)
618 qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
619 name->name, arg1, arg2);
621 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
626 print_execve(CPUArchState *cpu_env, const struct syscallname *name,
627 abi_long arg1, abi_long arg2, abi_long arg3,
628 abi_long arg4, abi_long arg5, abi_long arg6)
630 abi_ulong arg_ptr_addr;
633 if (!(s = lock_user_string(arg1)))
635 qemu_log("%s(\"%s\",{", name->name, s);
636 unlock_user(s, arg1, 0);
638 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
639 abi_ulong *arg_ptr, arg_addr;
641 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
644 arg_addr = tswapal(*arg_ptr);
645 unlock_user(arg_ptr, arg_ptr_addr, 0);
648 if ((s = lock_user_string(arg_addr))) {
649 qemu_log("\"%s\",", s);
650 unlock_user(s, arg_addr, 0);
659 print_ipc(CPUArchState *cpu_env, const struct syscallname *name,
660 abi_long arg1, abi_long arg2, abi_long arg3,
661 abi_long arg4, abi_long arg5, abi_long arg6)
665 qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
668 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
672 TARGET_ABI_FMT_ld ","
673 TARGET_ABI_FMT_ld ","
674 TARGET_ABI_FMT_ld ","
677 name->name, arg1, arg2, arg3, arg4);
683 * Variants for the return value output function
687 print_syscall_err(abi_long ret)
693 errstr = target_strerror(-ret);
695 qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
703 print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name,
704 abi_long ret, abi_long arg0, abi_long arg1,
705 abi_long arg2, abi_long arg3, abi_long arg4,
708 if (!print_syscall_err(ret)) {
709 qemu_log("0x" TARGET_ABI_FMT_lx, ret);
714 #if 0 /* currently unused */
716 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
718 qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
722 #ifdef TARGET_NR__newselect
724 print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name,
725 abi_long ret, abi_long arg0, abi_long arg1,
726 abi_long arg2, abi_long arg3, abi_long arg4,
729 if (!print_syscall_err(ret)) {
730 qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
731 print_fdset(arg0, arg1);
733 print_fdset(arg0, arg2);
735 print_fdset(arg0, arg3);
737 print_timeval(arg4, 1);
745 /* special meanings of adjtimex()' non-negative return values */
746 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
747 #define TARGET_TIME_INS 1 /* insert leap second */
748 #define TARGET_TIME_DEL 2 /* delete leap second */
749 #define TARGET_TIME_OOP 3 /* leap second in progress */
750 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
751 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
752 #ifdef TARGET_NR_adjtimex
754 print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name,
755 abi_long ret, abi_long arg0, abi_long arg1,
756 abi_long arg2, abi_long arg3, abi_long arg4,
759 if (!print_syscall_err(ret)) {
760 qemu_log(TARGET_ABI_FMT_ld, ret);
763 qemu_log(" TIME_OK (clock synchronized, no leap second)");
765 case TARGET_TIME_INS:
766 qemu_log(" TIME_INS (insert leap second)");
768 case TARGET_TIME_DEL:
769 qemu_log(" TIME_DEL (delete leap second)");
771 case TARGET_TIME_OOP:
772 qemu_log(" TIME_OOP (leap second in progress)");
774 case TARGET_TIME_WAIT:
775 qemu_log(" TIME_WAIT (leap second has occurred)");
777 case TARGET_TIME_ERROR:
778 qemu_log(" TIME_ERROR (clock not synchronized)");
787 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
789 print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
790 abi_long ret, abi_long arg0, abi_long arg1,
791 abi_long arg2, abi_long arg3, abi_long arg4,
794 if (!print_syscall_err(ret)) {
795 qemu_log(TARGET_ABI_FMT_ld, ret);
797 print_timespec(arg1, 1);
803 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
806 #ifdef TARGET_NR_gettimeofday
808 print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
809 abi_long ret, abi_long arg0, abi_long arg1,
810 abi_long arg2, abi_long arg3, abi_long arg4,
813 if (!print_syscall_err(ret)) {
814 qemu_log(TARGET_ABI_FMT_ld, ret);
816 print_timeval(arg0, 0);
817 print_timezone(arg1, 1);
825 #ifdef TARGET_NR_getitimer
827 print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
828 abi_long ret, abi_long arg0, abi_long arg1,
829 abi_long arg2, abi_long arg3, abi_long arg4,
832 if (!print_syscall_err(ret)) {
833 qemu_log(TARGET_ABI_FMT_ld, ret);
835 print_itimerval(arg1, 1);
844 #ifdef TARGET_NR_getitimer
846 print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
847 abi_long ret, abi_long arg0, abi_long arg1,
848 abi_long arg2, abi_long arg3, abi_long arg4,
851 if (!print_syscall_err(ret)) {
852 qemu_log(TARGET_ABI_FMT_ld, ret);
853 qemu_log(" (old_value = ");
854 print_itimerval(arg2, 1);
862 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
863 || defined(TARGGET_NR_flistxattr)
865 print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
866 abi_long ret, abi_long arg0, abi_long arg1,
867 abi_long arg2, abi_long arg3, abi_long arg4,
870 if (!print_syscall_err(ret)) {
871 qemu_log(TARGET_ABI_FMT_ld, ret);
872 qemu_log(" (list = ");
874 abi_long attr = arg1;
879 print_string(attr, 1);
880 ret -= target_strlen(attr) + 1;
881 attr += target_strlen(attr) + 1;
891 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
892 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
895 #ifdef TARGET_NR_ioctl
897 print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
898 abi_long ret, abi_long arg0, abi_long arg1,
899 abi_long arg2, abi_long arg3, abi_long arg4,
902 if (!print_syscall_err(ret)) {
903 qemu_log(TARGET_ABI_FMT_ld, ret);
905 const IOCTLEntry *ie;
906 const argtype *arg_type;
910 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
911 if (ie->target_cmd == arg1) {
916 if (ie->target_cmd == arg1 &&
917 (ie->access == IOC_R || ie->access == IOC_RW)) {
918 arg_type = ie->arg_type;
921 target_size = thunk_type_size(arg_type, 0);
922 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
924 thunk_print(argptr, arg_type);
925 unlock_user(argptr, arg2, target_size);
927 print_pointer(arg2, 1);
936 UNUSED static struct flags access_flags[] = {
944 UNUSED static struct flags at_file_flags[] = {
946 FLAG_GENERIC(AT_EACCESS),
948 #ifdef AT_SYMLINK_NOFOLLOW
949 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
954 UNUSED static struct flags unlinkat_flags[] = {
956 FLAG_GENERIC(AT_REMOVEDIR),
961 UNUSED static struct flags mode_flags[] = {
962 FLAG_GENERIC(S_IFSOCK),
963 FLAG_GENERIC(S_IFLNK),
964 FLAG_GENERIC(S_IFREG),
965 FLAG_GENERIC(S_IFBLK),
966 FLAG_GENERIC(S_IFDIR),
967 FLAG_GENERIC(S_IFCHR),
968 FLAG_GENERIC(S_IFIFO),
972 UNUSED static struct flags open_access_flags[] = {
973 FLAG_TARGET(O_RDONLY),
974 FLAG_TARGET(O_WRONLY),
979 UNUSED static struct flags open_flags[] = {
980 FLAG_TARGET(O_APPEND),
981 FLAG_TARGET(O_CREAT),
982 FLAG_TARGET(O_DIRECTORY),
984 FLAG_TARGET(O_LARGEFILE),
985 FLAG_TARGET(O_NOCTTY),
986 FLAG_TARGET(O_NOFOLLOW),
987 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
988 FLAG_TARGET(O_DSYNC),
989 FLAG_TARGET(__O_SYNC),
990 FLAG_TARGET(O_TRUNC),
992 FLAG_TARGET(O_DIRECT),
995 FLAG_TARGET(O_NOATIME),
998 FLAG_TARGET(O_CLOEXEC),
1001 FLAG_TARGET(O_PATH),
1004 FLAG_TARGET(O_TMPFILE),
1005 FLAG_TARGET(__O_TMPFILE),
1010 UNUSED static struct flags mount_flags[] = {
1012 FLAG_GENERIC(MS_BIND),
1015 FLAG_GENERIC(MS_DIRSYNC),
1017 FLAG_GENERIC(MS_MANDLOCK),
1019 FLAG_GENERIC(MS_MOVE),
1021 FLAG_GENERIC(MS_NOATIME),
1022 FLAG_GENERIC(MS_NODEV),
1023 FLAG_GENERIC(MS_NODIRATIME),
1024 FLAG_GENERIC(MS_NOEXEC),
1025 FLAG_GENERIC(MS_NOSUID),
1026 FLAG_GENERIC(MS_RDONLY),
1028 FLAG_GENERIC(MS_RELATIME),
1030 FLAG_GENERIC(MS_REMOUNT),
1031 FLAG_GENERIC(MS_SYNCHRONOUS),
1035 UNUSED static struct flags umount2_flags[] = {
1037 FLAG_GENERIC(MNT_FORCE),
1040 FLAG_GENERIC(MNT_DETACH),
1043 FLAG_GENERIC(MNT_EXPIRE),
1048 UNUSED static struct flags mmap_prot_flags[] = {
1049 FLAG_GENERIC(PROT_NONE),
1050 FLAG_GENERIC(PROT_EXEC),
1051 FLAG_GENERIC(PROT_READ),
1052 FLAG_GENERIC(PROT_WRITE),
1053 FLAG_TARGET(PROT_SEM),
1054 FLAG_GENERIC(PROT_GROWSDOWN),
1055 FLAG_GENERIC(PROT_GROWSUP),
1059 UNUSED static struct flags mmap_flags[] = {
1060 FLAG_TARGET(MAP_SHARED),
1061 FLAG_TARGET(MAP_PRIVATE),
1062 FLAG_TARGET(MAP_ANONYMOUS),
1063 FLAG_TARGET(MAP_DENYWRITE),
1064 FLAG_TARGET(MAP_FIXED),
1065 FLAG_TARGET(MAP_GROWSDOWN),
1066 FLAG_TARGET(MAP_EXECUTABLE),
1068 FLAG_TARGET(MAP_LOCKED),
1071 FLAG_TARGET(MAP_NONBLOCK),
1073 FLAG_TARGET(MAP_NORESERVE),
1075 FLAG_TARGET(MAP_POPULATE),
1077 #ifdef TARGET_MAP_UNINITIALIZED
1078 FLAG_TARGET(MAP_UNINITIALIZED),
1083 UNUSED static struct flags clone_flags[] = {
1084 FLAG_GENERIC(CLONE_VM),
1085 FLAG_GENERIC(CLONE_FS),
1086 FLAG_GENERIC(CLONE_FILES),
1087 FLAG_GENERIC(CLONE_SIGHAND),
1088 FLAG_GENERIC(CLONE_PTRACE),
1089 FLAG_GENERIC(CLONE_VFORK),
1090 FLAG_GENERIC(CLONE_PARENT),
1091 FLAG_GENERIC(CLONE_THREAD),
1092 FLAG_GENERIC(CLONE_NEWNS),
1093 FLAG_GENERIC(CLONE_SYSVSEM),
1094 FLAG_GENERIC(CLONE_SETTLS),
1095 FLAG_GENERIC(CLONE_PARENT_SETTID),
1096 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
1097 FLAG_GENERIC(CLONE_DETACHED),
1098 FLAG_GENERIC(CLONE_UNTRACED),
1099 FLAG_GENERIC(CLONE_CHILD_SETTID),
1100 #if defined(CLONE_NEWUTS)
1101 FLAG_GENERIC(CLONE_NEWUTS),
1103 #if defined(CLONE_NEWIPC)
1104 FLAG_GENERIC(CLONE_NEWIPC),
1106 #if defined(CLONE_NEWUSER)
1107 FLAG_GENERIC(CLONE_NEWUSER),
1109 #if defined(CLONE_NEWPID)
1110 FLAG_GENERIC(CLONE_NEWPID),
1112 #if defined(CLONE_NEWNET)
1113 FLAG_GENERIC(CLONE_NEWNET),
1115 #if defined(CLONE_NEWCGROUP)
1116 FLAG_GENERIC(CLONE_NEWCGROUP),
1118 #if defined(CLONE_NEWTIME)
1119 FLAG_GENERIC(CLONE_NEWTIME),
1121 #if defined(CLONE_IO)
1122 FLAG_GENERIC(CLONE_IO),
1127 UNUSED static struct flags msg_flags[] = {
1129 FLAG_GENERIC(MSG_CONFIRM),
1130 FLAG_GENERIC(MSG_DONTROUTE),
1131 FLAG_GENERIC(MSG_DONTWAIT),
1132 FLAG_GENERIC(MSG_EOR),
1133 FLAG_GENERIC(MSG_MORE),
1134 FLAG_GENERIC(MSG_NOSIGNAL),
1135 FLAG_GENERIC(MSG_OOB),
1137 FLAG_GENERIC(MSG_CMSG_CLOEXEC),
1138 FLAG_GENERIC(MSG_ERRQUEUE),
1139 FLAG_GENERIC(MSG_PEEK),
1140 FLAG_GENERIC(MSG_TRUNC),
1141 FLAG_GENERIC(MSG_WAITALL),
1143 FLAG_GENERIC(MSG_CTRUNC),
1147 UNUSED static struct flags statx_flags[] = {
1148 #ifdef AT_EMPTY_PATH
1149 FLAG_GENERIC(AT_EMPTY_PATH),
1151 #ifdef AT_NO_AUTOMOUNT
1152 FLAG_GENERIC(AT_NO_AUTOMOUNT),
1154 #ifdef AT_SYMLINK_NOFOLLOW
1155 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
1157 #ifdef AT_STATX_SYNC_AS_STAT
1158 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
1160 #ifdef AT_STATX_FORCE_SYNC
1161 FLAG_GENERIC(AT_STATX_FORCE_SYNC),
1163 #ifdef AT_STATX_DONT_SYNC
1164 FLAG_GENERIC(AT_STATX_DONT_SYNC),
1169 UNUSED static struct flags statx_mask[] = {
1170 /* This must come first, because it includes everything. */
1172 FLAG_GENERIC(STATX_ALL),
1174 /* This must come second; it includes everything except STATX_BTIME. */
1175 #ifdef STATX_BASIC_STATS
1176 FLAG_GENERIC(STATX_BASIC_STATS),
1179 FLAG_GENERIC(STATX_TYPE),
1182 FLAG_GENERIC(STATX_MODE),
1185 FLAG_GENERIC(STATX_NLINK),
1188 FLAG_GENERIC(STATX_UID),
1191 FLAG_GENERIC(STATX_GID),
1194 FLAG_GENERIC(STATX_ATIME),
1197 FLAG_GENERIC(STATX_MTIME),
1200 FLAG_GENERIC(STATX_CTIME),
1203 FLAG_GENERIC(STATX_INO),
1206 FLAG_GENERIC(STATX_SIZE),
1209 FLAG_GENERIC(STATX_BLOCKS),
1212 FLAG_GENERIC(STATX_BTIME),
1217 UNUSED static struct flags falloc_flags[] = {
1218 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
1219 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
1220 #ifdef FALLOC_FL_NO_HIDE_STALE
1221 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
1223 #ifdef FALLOC_FL_COLLAPSE_RANGE
1224 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
1226 #ifdef FALLOC_FL_ZERO_RANGE
1227 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
1229 #ifdef FALLOC_FL_INSERT_RANGE
1230 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
1232 #ifdef FALLOC_FL_UNSHARE_RANGE
1233 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
1237 UNUSED static struct flags termios_iflags[] = {
1238 FLAG_TARGET(IGNBRK),
1239 FLAG_TARGET(BRKINT),
1240 FLAG_TARGET(IGNPAR),
1241 FLAG_TARGET(PARMRK),
1243 FLAG_TARGET(ISTRIP),
1251 FLAG_TARGET(IMAXBEL),
1256 UNUSED static struct flags termios_oflags[] = {
1262 FLAG_TARGET(ONLRET),
1268 UNUSED static struct enums termios_oflags_NLDLY[] = {
1274 UNUSED static struct enums termios_oflags_CRDLY[] = {
1282 UNUSED static struct enums termios_oflags_TABDLY[] = {
1290 UNUSED static struct enums termios_oflags_VTDLY[] = {
1296 UNUSED static struct enums termios_oflags_FFDLY[] = {
1302 UNUSED static struct enums termios_oflags_BSDLY[] = {
1308 UNUSED static struct enums termios_cflags_CBAUD[] = {
1323 ENUM_TARGET(B19200),
1324 ENUM_TARGET(B38400),
1325 ENUM_TARGET(B57600),
1326 ENUM_TARGET(B115200),
1327 ENUM_TARGET(B230400),
1328 ENUM_TARGET(B460800),
1332 UNUSED static struct enums termios_cflags_CSIZE[] = {
1340 UNUSED static struct flags termios_cflags[] = {
1341 FLAG_TARGET(CSTOPB),
1343 FLAG_TARGET(PARENB),
1344 FLAG_TARGET(PARODD),
1346 FLAG_TARGET(CLOCAL),
1347 FLAG_TARGET(CRTSCTS),
1351 UNUSED static struct flags termios_lflags[] = {
1353 FLAG_TARGET(ICANON),
1358 FLAG_TARGET(ECHONL),
1359 FLAG_TARGET(NOFLSH),
1360 FLAG_TARGET(TOSTOP),
1361 FLAG_TARGET(ECHOCTL),
1362 FLAG_TARGET(ECHOPRT),
1363 FLAG_TARGET(ECHOKE),
1364 FLAG_TARGET(FLUSHO),
1365 FLAG_TARGET(PENDIN),
1366 FLAG_TARGET(IEXTEN),
1367 FLAG_TARGET(EXTPROC),
1371 UNUSED static struct flags mlockall_flags[] = {
1372 FLAG_TARGET(MCL_CURRENT),
1373 FLAG_TARGET(MCL_FUTURE),
1375 FLAG_TARGET(MCL_ONFAULT),
1380 /* IDs of the various system clocks */
1381 #define TARGET_CLOCK_REALTIME 0
1382 #define TARGET_CLOCK_MONOTONIC 1
1383 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1384 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1385 #define TARGET_CLOCK_MONOTONIC_RAW 4
1386 #define TARGET_CLOCK_REALTIME_COARSE 5
1387 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1388 #define TARGET_CLOCK_BOOTTIME 7
1389 #define TARGET_CLOCK_REALTIME_ALARM 8
1390 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1391 #define TARGET_CLOCK_SGI_CYCLE 10
1392 #define TARGET_CLOCK_TAI 11
1394 UNUSED static struct enums clockids[] = {
1395 ENUM_TARGET(CLOCK_REALTIME),
1396 ENUM_TARGET(CLOCK_MONOTONIC),
1397 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
1398 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
1399 ENUM_TARGET(CLOCK_MONOTONIC_RAW),
1400 ENUM_TARGET(CLOCK_REALTIME_COARSE),
1401 ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
1402 ENUM_TARGET(CLOCK_BOOTTIME),
1403 ENUM_TARGET(CLOCK_REALTIME_ALARM),
1404 ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
1405 ENUM_TARGET(CLOCK_SGI_CYCLE),
1406 ENUM_TARGET(CLOCK_TAI),
1410 UNUSED static struct enums itimer_types[] = {
1411 ENUM_GENERIC(ITIMER_REAL),
1412 ENUM_GENERIC(ITIMER_VIRTUAL),
1413 ENUM_GENERIC(ITIMER_PROF),
1418 * print_xxx utility functions. These are used to print syscall
1419 * parameters in certain format. All of these have parameter
1420 * named 'last'. This parameter is used to add comma to output
1427 return ((last) ? "" : ",");
1431 print_flags(const struct flags *f, abi_long flags, int last)
1433 const char *sep = "";
1436 if ((flags == 0) && (f->f_value == 0)) {
1437 qemu_log("%s%s", f->f_string, get_comma(last));
1440 for (n = 0; f->f_string != NULL; f++) {
1441 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
1442 qemu_log("%s%s", sep, f->f_string);
1443 flags &= ~f->f_value;
1450 /* print rest of the flags as numeric */
1452 qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
1454 qemu_log("%s", get_comma(last));
1457 /* no string version of flags found, print them in hex then */
1458 qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
1463 print_enums(const struct enums *e, abi_long enum_arg, int last)
1465 for (; e->e_string != NULL; e++) {
1466 if (e->e_value == enum_arg) {
1467 qemu_log("%s", e->e_string);
1472 if (e->e_string == NULL) {
1473 qemu_log("%#x", (unsigned int)enum_arg);
1476 qemu_log("%s", get_comma(last));
1480 print_at_dirfd(abi_long dirfd, int last)
1483 if (dirfd == AT_FDCWD) {
1484 qemu_log("AT_FDCWD%s", get_comma(last));
1488 qemu_log("%d%s", (int)dirfd, get_comma(last));
1492 print_file_mode(abi_long mode, int last)
1494 const char *sep = "";
1495 const struct flags *m;
1497 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
1498 if ((m->f_value & mode) == m->f_value) {
1499 qemu_log("%s%s", m->f_string, sep);
1501 mode &= ~m->f_value;
1507 /* print rest of the mode as octal */
1509 qemu_log("%s%#o", sep, (unsigned int)mode);
1511 qemu_log("%s", get_comma(last));
1515 print_open_flags(abi_long flags, int last)
1517 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
1518 flags &= ~TARGET_O_ACCMODE;
1520 qemu_log("%s", get_comma(last));
1524 print_flags(open_flags, flags, last);
1528 print_syscall_prologue(const struct syscallname *sc)
1530 qemu_log("%s(", sc->name);
1535 print_syscall_epilogue(const struct syscallname *sc)
1542 print_string(abi_long addr, int last)
1546 if ((s = lock_user_string(addr)) != NULL) {
1547 qemu_log("\"%s\"%s", s, get_comma(last));
1548 unlock_user(s, addr, 0);
1550 /* can't get string out of it, so print it as pointer */
1551 print_pointer(addr, last);
1555 #define MAX_PRINT_BUF 40
1557 print_buf(abi_long addr, abi_long len, int last)
1562 s = lock_user(VERIFY_READ, addr, len, 1);
1565 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
1566 if (isprint(s[i])) {
1567 qemu_log("%c", s[i]);
1569 qemu_log("\\%o", s[i]);
1579 unlock_user(s, addr, 0);
1581 print_pointer(addr, last);
1586 * Prints out raw parameter using given format. Caller needs
1587 * to do byte swapping if needed.
1590 print_raw_param(const char *fmt, abi_long param, int last)
1594 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
1595 qemu_log(format, param);
1599 print_pointer(abi_long p, int last)
1602 qemu_log("NULL%s", get_comma(last));
1604 qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
1608 * Reads 32-bit (int) number from guest address space from
1609 * address 'addr' and prints it.
1612 print_number(abi_long addr, int last)
1615 qemu_log("NULL%s", get_comma(last));
1619 get_user_s32(num, addr);
1620 qemu_log("[%d]%s", num, get_comma(last));
1625 print_timeval(abi_ulong tv_addr, int last)
1628 struct target_timeval *tv;
1630 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
1632 print_pointer(tv_addr, last);
1635 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1636 ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
1637 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
1638 unlock_user(tv, tv_addr, 0);
1640 qemu_log("NULL%s", get_comma(last));
1644 print_timespec(abi_ulong ts_addr, int last)
1647 struct target_timespec *ts;
1649 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
1651 print_pointer(ts_addr, last);
1654 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1655 ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
1656 tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
1657 unlock_user(ts, ts_addr, 0);
1659 qemu_log("NULL%s", get_comma(last));
1664 print_timezone(abi_ulong tz_addr, int last)
1667 struct target_timezone *tz;
1669 tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
1671 print_pointer(tz_addr, last);
1674 qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
1675 tswap32(tz->tz_dsttime), get_comma(last));
1676 unlock_user(tz, tz_addr, 0);
1678 qemu_log("NULL%s", get_comma(last));
1683 print_itimerval(abi_ulong it_addr, int last)
1686 qemu_log("{it_interval=");
1687 print_timeval(it_addr +
1688 offsetof(struct target_itimerval, it_interval), 0);
1689 qemu_log("it_value=");
1690 print_timeval(it_addr +
1691 offsetof(struct target_itimerval, it_value), 0);
1692 qemu_log("}%s", get_comma(last));
1694 qemu_log("NULL%s", get_comma(last));
1699 print_termios(void *arg)
1701 const struct target_termios *target = arg;
1703 target_tcflag_t iflags = tswap32(target->c_iflag);
1704 target_tcflag_t oflags = tswap32(target->c_oflag);
1705 target_tcflag_t cflags = tswap32(target->c_cflag);
1706 target_tcflag_t lflags = tswap32(target->c_lflag);
1710 qemu_log("c_iflag = ");
1711 print_flags(termios_iflags, iflags, 0);
1713 qemu_log("c_oflag = ");
1714 target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
1715 TARGET_TABDLY | TARGET_BSDLY |
1716 TARGET_VTDLY | TARGET_FFDLY);
1717 print_flags(termios_oflags, oflags_clean, 0);
1718 if (oflags & TARGET_NLDLY) {
1719 print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
1721 if (oflags & TARGET_CRDLY) {
1722 print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
1724 if (oflags & TARGET_TABDLY) {
1725 print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
1727 if (oflags & TARGET_BSDLY) {
1728 print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
1730 if (oflags & TARGET_VTDLY) {
1731 print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
1733 if (oflags & TARGET_FFDLY) {
1734 print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
1737 qemu_log("c_cflag = ");
1738 if (cflags & TARGET_CBAUD) {
1739 print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
1741 if (cflags & TARGET_CSIZE) {
1742 print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
1744 target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
1745 print_flags(termios_cflags, cflags_clean, 0);
1747 qemu_log("c_lflag = ");
1748 print_flags(termios_lflags, lflags, 0);
1750 qemu_log("c_cc = ");
1751 qemu_log("\"%s\",", target->c_cc);
1753 qemu_log("c_line = ");
1754 print_raw_param("\'%c\'", target->c_line, 1);
1761 #ifdef TARGET_NR_accept
1763 print_accept(CPUArchState *cpu_env, const struct syscallname *name,
1764 abi_long arg0, abi_long arg1, abi_long arg2,
1765 abi_long arg3, abi_long arg4, abi_long arg5)
1767 print_syscall_prologue(name);
1768 print_raw_param("%d", arg0, 0);
1769 print_pointer(arg1, 0);
1770 print_number(arg2, 1);
1771 print_syscall_epilogue(name);
1775 #ifdef TARGET_NR_access
1777 print_access(CPUArchState *cpu_env, const struct syscallname *name,
1778 abi_long arg0, abi_long arg1, abi_long arg2,
1779 abi_long arg3, abi_long arg4, abi_long arg5)
1781 print_syscall_prologue(name);
1782 print_string(arg0, 0);
1783 print_flags(access_flags, arg1, 1);
1784 print_syscall_epilogue(name);
1788 #ifdef TARGET_NR_acct
1790 print_acct(CPUArchState *cpu_env, const struct syscallname *name,
1791 abi_long arg0, abi_long arg1, abi_long arg2,
1792 abi_long arg3, abi_long arg4, abi_long arg5)
1794 print_syscall_prologue(name);
1795 print_string(arg0, 1);
1796 print_syscall_epilogue(name);
1800 #ifdef TARGET_NR_brk
1802 print_brk(CPUArchState *cpu_env, const struct syscallname *name,
1803 abi_long arg0, abi_long arg1, abi_long arg2,
1804 abi_long arg3, abi_long arg4, abi_long arg5)
1806 print_syscall_prologue(name);
1807 print_pointer(arg0, 1);
1808 print_syscall_epilogue(name);
1812 #ifdef TARGET_NR_chdir
1814 print_chdir(CPUArchState *cpu_env, const struct syscallname *name,
1815 abi_long arg0, abi_long arg1, abi_long arg2,
1816 abi_long arg3, abi_long arg4, abi_long arg5)
1818 print_syscall_prologue(name);
1819 print_string(arg0, 1);
1820 print_syscall_epilogue(name);
1824 #ifdef TARGET_NR_chroot
1826 print_chroot(CPUArchState *cpu_env, const struct syscallname *name,
1827 abi_long arg0, abi_long arg1, abi_long arg2,
1828 abi_long arg3, abi_long arg4, abi_long arg5)
1830 print_syscall_prologue(name);
1831 print_string(arg0, 1);
1832 print_syscall_epilogue(name);
1836 #ifdef TARGET_NR_chmod
1838 print_chmod(CPUArchState *cpu_env, const struct syscallname *name,
1839 abi_long arg0, abi_long arg1, abi_long arg2,
1840 abi_long arg3, abi_long arg4, abi_long arg5)
1842 print_syscall_prologue(name);
1843 print_string(arg0, 0);
1844 print_file_mode(arg1, 1);
1845 print_syscall_epilogue(name);
1849 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1851 print_chown(CPUArchState *cpu_env, const struct syscallname *name,
1852 abi_long arg0, abi_long arg1, abi_long arg2,
1853 abi_long arg3, abi_long arg4, abi_long arg5)
1855 print_syscall_prologue(name);
1856 print_string(arg0, 0);
1857 print_raw_param("%d", arg1, 0);
1858 print_raw_param("%d", arg2, 1);
1859 print_syscall_epilogue(name);
1861 #define print_lchown print_chown
1864 #ifdef TARGET_NR_clock_adjtime
1866 print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name,
1867 abi_long arg0, abi_long arg1, abi_long arg2,
1868 abi_long arg3, abi_long arg4, abi_long arg5)
1870 print_syscall_prologue(name);
1871 print_enums(clockids, arg0, 0);
1872 print_pointer(arg1, 1);
1873 print_syscall_epilogue(name);
1877 #ifdef TARGET_NR_clone
1878 static void do_print_clone(unsigned int flags, abi_ulong newsp,
1879 abi_ulong parent_tidptr, target_ulong newtls,
1880 abi_ulong child_tidptr)
1882 print_flags(clone_flags, flags, 0);
1883 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
1884 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
1885 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
1886 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
1890 print_clone(CPUArchState *cpu_env, const struct syscallname *name,
1891 abi_long arg1, abi_long arg2, abi_long arg3,
1892 abi_long arg4, abi_long arg5, abi_long arg6)
1894 print_syscall_prologue(name);
1895 #if defined(TARGET_MICROBLAZE)
1896 do_print_clone(arg1, arg2, arg4, arg6, arg5);
1897 #elif defined(TARGET_CLONE_BACKWARDS)
1898 do_print_clone(arg1, arg2, arg3, arg4, arg5);
1899 #elif defined(TARGET_CLONE_BACKWARDS2)
1900 do_print_clone(arg2, arg1, arg3, arg5, arg4);
1902 do_print_clone(arg1, arg2, arg3, arg5, arg4);
1904 print_syscall_epilogue(name);
1908 #ifdef TARGET_NR_creat
1910 print_creat(CPUArchState *cpu_env, const struct syscallname *name,
1911 abi_long arg0, abi_long arg1, abi_long arg2,
1912 abi_long arg3, abi_long arg4, abi_long arg5)
1914 print_syscall_prologue(name);
1915 print_string(arg0, 0);
1916 print_file_mode(arg1, 1);
1917 print_syscall_epilogue(name);
1921 #ifdef TARGET_NR_execv
1923 print_execv(CPUArchState *cpu_env, const struct syscallname *name,
1924 abi_long arg0, abi_long arg1, abi_long arg2,
1925 abi_long arg3, abi_long arg4, abi_long arg5)
1927 print_syscall_prologue(name);
1928 print_string(arg0, 0);
1929 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
1930 print_syscall_epilogue(name);
1934 #ifdef TARGET_NR_faccessat
1936 print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
1937 abi_long arg0, abi_long arg1, abi_long arg2,
1938 abi_long arg3, abi_long arg4, abi_long arg5)
1940 print_syscall_prologue(name);
1941 print_at_dirfd(arg0, 0);
1942 print_string(arg1, 0);
1943 print_flags(access_flags, arg2, 0);
1944 print_flags(at_file_flags, arg3, 1);
1945 print_syscall_epilogue(name);
1949 #ifdef TARGET_NR_fallocate
1951 print_fallocate(CPUArchState *cpu_env, const struct syscallname *name,
1952 abi_long arg0, abi_long arg1, abi_long arg2,
1953 abi_long arg3, abi_long arg4, abi_long arg5)
1955 print_syscall_prologue(name);
1956 print_raw_param("%d", arg0, 0);
1957 print_flags(falloc_flags, arg1, 0);
1958 #if TARGET_ABI_BITS == 32
1959 print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
1960 print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
1962 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1963 print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
1965 print_syscall_epilogue(name);
1969 #ifdef TARGET_NR_fchmodat
1971 print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name,
1972 abi_long arg0, abi_long arg1, abi_long arg2,
1973 abi_long arg3, abi_long arg4, abi_long arg5)
1975 print_syscall_prologue(name);
1976 print_at_dirfd(arg0, 0);
1977 print_string(arg1, 0);
1978 print_file_mode(arg2, 0);
1979 print_flags(at_file_flags, arg3, 1);
1980 print_syscall_epilogue(name);
1984 #ifdef TARGET_NR_fchownat
1986 print_fchownat(CPUArchState *cpu_env, const struct syscallname *name,
1987 abi_long arg0, abi_long arg1, abi_long arg2,
1988 abi_long arg3, abi_long arg4, abi_long arg5)
1990 print_syscall_prologue(name);
1991 print_at_dirfd(arg0, 0);
1992 print_string(arg1, 0);
1993 print_raw_param("%d", arg2, 0);
1994 print_raw_param("%d", arg3, 0);
1995 print_flags(at_file_flags, arg4, 1);
1996 print_syscall_epilogue(name);
2000 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
2002 print_fcntl(CPUArchState *cpu_env, const struct syscallname *name,
2003 abi_long arg0, abi_long arg1, abi_long arg2,
2004 abi_long arg3, abi_long arg4, abi_long arg5)
2006 print_syscall_prologue(name);
2007 print_raw_param("%d", arg0, 0);
2009 case TARGET_F_DUPFD:
2010 qemu_log("F_DUPFD,");
2011 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2013 case TARGET_F_GETFD:
2014 qemu_log("F_GETFD");
2016 case TARGET_F_SETFD:
2017 qemu_log("F_SETFD,");
2018 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2020 case TARGET_F_GETFL:
2021 qemu_log("F_GETFL");
2023 case TARGET_F_SETFL:
2024 qemu_log("F_SETFL,");
2025 print_open_flags(arg2, 1);
2027 case TARGET_F_GETLK:
2028 qemu_log("F_GETLK,");
2029 print_pointer(arg2, 1);
2031 case TARGET_F_SETLK:
2032 qemu_log("F_SETLK,");
2033 print_pointer(arg2, 1);
2035 case TARGET_F_SETLKW:
2036 qemu_log("F_SETLKW,");
2037 print_pointer(arg2, 1);
2039 case TARGET_F_GETOWN:
2040 qemu_log("F_GETOWN");
2042 case TARGET_F_SETOWN:
2043 qemu_log("F_SETOWN,");
2044 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2046 case TARGET_F_GETSIG:
2047 qemu_log("F_GETSIG");
2049 case TARGET_F_SETSIG:
2050 qemu_log("F_SETSIG,");
2051 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2053 #if TARGET_ABI_BITS == 32
2054 case TARGET_F_GETLK64:
2055 qemu_log("F_GETLK64,");
2056 print_pointer(arg2, 1);
2058 case TARGET_F_SETLK64:
2059 qemu_log("F_SETLK64,");
2060 print_pointer(arg2, 1);
2062 case TARGET_F_SETLKW64:
2063 qemu_log("F_SETLKW64,");
2064 print_pointer(arg2, 1);
2067 case TARGET_F_OFD_GETLK:
2068 qemu_log("F_OFD_GETLK,");
2069 print_pointer(arg2, 1);
2071 case TARGET_F_OFD_SETLK:
2072 qemu_log("F_OFD_SETLK,");
2073 print_pointer(arg2, 1);
2075 case TARGET_F_OFD_SETLKW:
2076 qemu_log("F_OFD_SETLKW,");
2077 print_pointer(arg2, 1);
2079 case TARGET_F_SETLEASE:
2080 qemu_log("F_SETLEASE,");
2081 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2083 case TARGET_F_GETLEASE:
2084 qemu_log("F_GETLEASE");
2086 #ifdef F_DUPFD_CLOEXEC
2087 case TARGET_F_DUPFD_CLOEXEC:
2088 qemu_log("F_DUPFD_CLOEXEC,");
2089 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2092 case TARGET_F_NOTIFY:
2093 qemu_log("F_NOTIFY,");
2094 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2097 case TARGET_F_GETOWN_EX:
2098 qemu_log("F_GETOWN_EX,");
2099 print_pointer(arg2, 1);
2103 case TARGET_F_SETOWN_EX:
2104 qemu_log("F_SETOWN_EX,");
2105 print_pointer(arg2, 1);
2109 case TARGET_F_SETPIPE_SZ:
2110 qemu_log("F_SETPIPE_SZ,");
2111 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2113 case TARGET_F_GETPIPE_SZ:
2114 qemu_log("F_GETPIPE_SZ");
2118 case TARGET_F_ADD_SEALS:
2119 qemu_log("F_ADD_SEALS,");
2120 print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1);
2122 case TARGET_F_GET_SEALS:
2123 qemu_log("F_GET_SEALS");
2127 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2128 print_pointer(arg2, 1);
2131 print_syscall_epilogue(name);
2133 #define print_fcntl64 print_fcntl
2136 #ifdef TARGET_NR_fgetxattr
2138 print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name,
2139 abi_long arg0, abi_long arg1, abi_long arg2,
2140 abi_long arg3, abi_long arg4, abi_long arg5)
2142 print_syscall_prologue(name);
2143 print_raw_param("%d", arg0, 0);
2144 print_string(arg1, 0);
2145 print_pointer(arg2, 0);
2146 print_raw_param(TARGET_FMT_lu, arg3, 1);
2147 print_syscall_epilogue(name);
2151 #ifdef TARGET_NR_flistxattr
2153 print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name,
2154 abi_long arg0, abi_long arg1, abi_long arg2,
2155 abi_long arg3, abi_long arg4, abi_long arg5)
2157 print_syscall_prologue(name);
2158 print_raw_param("%d", arg0, 0);
2159 print_pointer(arg1, 0);
2160 print_raw_param(TARGET_FMT_lu, arg2, 1);
2161 print_syscall_epilogue(name);
2165 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2167 print_getxattr(CPUArchState *cpu_env, const struct syscallname *name,
2168 abi_long arg0, abi_long arg1, abi_long arg2,
2169 abi_long arg3, abi_long arg4, abi_long arg5)
2171 print_syscall_prologue(name);
2172 print_string(arg0, 0);
2173 print_string(arg1, 0);
2174 print_pointer(arg2, 0);
2175 print_raw_param(TARGET_FMT_lu, arg3, 1);
2176 print_syscall_epilogue(name);
2178 #define print_lgetxattr print_getxattr
2181 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2183 print_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
2184 abi_long arg0, abi_long arg1, abi_long arg2,
2185 abi_long arg3, abi_long arg4, abi_long arg5)
2187 print_syscall_prologue(name);
2188 print_string(arg0, 0);
2189 print_pointer(arg1, 0);
2190 print_raw_param(TARGET_FMT_lu, arg2, 1);
2191 print_syscall_epilogue(name);
2193 #define print_llistxattr print_listxattr
2196 #if defined(TARGET_NR_fremovexattr)
2198 print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name,
2199 abi_long arg0, abi_long arg1, abi_long arg2,
2200 abi_long arg3, abi_long arg4, abi_long arg5)
2202 print_syscall_prologue(name);
2203 print_raw_param("%d", arg0, 0);
2204 print_string(arg1, 1);
2205 print_syscall_epilogue(name);
2209 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2211 print_removexattr(CPUArchState *cpu_env, const struct syscallname *name,
2212 abi_long arg0, abi_long arg1, abi_long arg2,
2213 abi_long arg3, abi_long arg4, abi_long arg5)
2215 print_syscall_prologue(name);
2216 print_string(arg0, 0);
2217 print_string(arg1, 1);
2218 print_syscall_epilogue(name);
2220 #define print_lremovexattr print_removexattr
2223 #ifdef TARGET_NR_futimesat
2225 print_futimesat(CPUArchState *cpu_env, const struct syscallname *name,
2226 abi_long arg0, abi_long arg1, abi_long arg2,
2227 abi_long arg3, abi_long arg4, abi_long arg5)
2229 print_syscall_prologue(name);
2230 print_at_dirfd(arg0, 0);
2231 print_string(arg1, 0);
2232 print_timeval(arg2, 0);
2233 print_timeval(arg2 + sizeof (struct target_timeval), 1);
2234 print_syscall_epilogue(name);
2238 #ifdef TARGET_NR_gettimeofday
2240 print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
2241 abi_long arg0, abi_long arg1, abi_long arg2,
2242 abi_long arg3, abi_long arg4, abi_long arg5)
2244 print_syscall_prologue(name);
2245 print_pointer(arg0, 0);
2246 print_pointer(arg1, 1);
2247 print_syscall_epilogue(name);
2251 #ifdef TARGET_NR_settimeofday
2253 print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name,
2254 abi_long arg0, abi_long arg1, abi_long arg2,
2255 abi_long arg3, abi_long arg4, abi_long arg5)
2257 print_syscall_prologue(name);
2258 print_timeval(arg0, 0);
2259 print_timezone(arg1, 1);
2260 print_syscall_epilogue(name);
2264 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2266 print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
2267 abi_long arg0, abi_long arg1, abi_long arg2,
2268 abi_long arg3, abi_long arg4, abi_long arg5)
2270 print_syscall_prologue(name);
2271 print_enums(clockids, arg0, 0);
2272 print_pointer(arg1, 1);
2273 print_syscall_epilogue(name);
2275 #define print_clock_getres print_clock_gettime
2278 #ifdef TARGET_NR_clock_settime
2280 print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name,
2281 abi_long arg0, abi_long arg1, abi_long arg2,
2282 abi_long arg3, abi_long arg4, abi_long arg5)
2284 print_syscall_prologue(name);
2285 print_enums(clockids, arg0, 0);
2286 print_timespec(arg1, 1);
2287 print_syscall_epilogue(name);
2291 #ifdef TARGET_NR_getitimer
2293 print_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
2294 abi_long arg0, abi_long arg1, abi_long arg2,
2295 abi_long arg3, abi_long arg4, abi_long arg5)
2297 print_syscall_prologue(name);
2298 print_enums(itimer_types, arg0, 0);
2299 print_pointer(arg1, 1);
2300 print_syscall_epilogue(name);
2304 #ifdef TARGET_NR_setitimer
2306 print_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
2307 abi_long arg0, abi_long arg1, abi_long arg2,
2308 abi_long arg3, abi_long arg4, abi_long arg5)
2310 print_syscall_prologue(name);
2311 print_enums(itimer_types, arg0, 0);
2312 print_itimerval(arg1, 0);
2313 print_pointer(arg2, 1);
2314 print_syscall_epilogue(name);
2318 #ifdef TARGET_NR_link
2320 print_link(CPUArchState *cpu_env, const struct syscallname *name,
2321 abi_long arg0, abi_long arg1, abi_long arg2,
2322 abi_long arg3, abi_long arg4, abi_long arg5)
2324 print_syscall_prologue(name);
2325 print_string(arg0, 0);
2326 print_string(arg1, 1);
2327 print_syscall_epilogue(name);
2331 #ifdef TARGET_NR_linkat
2333 print_linkat(CPUArchState *cpu_env, 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_at_dirfd(arg0, 0);
2339 print_string(arg1, 0);
2340 print_at_dirfd(arg2, 0);
2341 print_string(arg3, 0);
2342 print_flags(at_file_flags, arg4, 1);
2343 print_syscall_epilogue(name);
2347 #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
2349 print__llseek(CPUArchState *cpu_env, const struct syscallname *name,
2350 abi_long arg0, abi_long arg1, abi_long arg2,
2351 abi_long arg3, abi_long arg4, abi_long arg5)
2353 const char *whence = "UNKNOWN";
2354 print_syscall_prologue(name);
2355 print_raw_param("%d", arg0, 0);
2356 print_raw_param("%ld", arg1, 0);
2357 print_raw_param("%ld", arg2, 0);
2358 print_pointer(arg3, 0);
2360 case SEEK_SET: whence = "SEEK_SET"; break;
2361 case SEEK_CUR: whence = "SEEK_CUR"; break;
2362 case SEEK_END: whence = "SEEK_END"; break;
2364 qemu_log("%s", whence);
2365 print_syscall_epilogue(name);
2367 #define print_llseek print__llseek
2370 #ifdef TARGET_NR_lseek
2372 print_lseek(CPUArchState *cpu_env, const struct syscallname *name,
2373 abi_long arg0, abi_long arg1, abi_long arg2,
2374 abi_long arg3, abi_long arg4, abi_long arg5)
2376 print_syscall_prologue(name);
2377 print_raw_param("%d", arg0, 0);
2378 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2381 qemu_log("SEEK_SET"); break;
2383 qemu_log("SEEK_CUR"); break;
2385 qemu_log("SEEK_END"); break;
2388 qemu_log("SEEK_DATA"); break;
2392 qemu_log("SEEK_HOLE"); break;
2395 print_raw_param("%#x", arg2, 1);
2397 print_syscall_epilogue(name);
2401 #ifdef TARGET_NR_truncate
2403 print_truncate(CPUArchState *cpu_env, 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_string(arg0, 0);
2409 print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
2410 print_syscall_epilogue(name);
2414 #ifdef TARGET_NR_truncate64
2416 print_truncate64(CPUArchState *cpu_env, const struct syscallname *name,
2417 abi_long arg0, abi_long arg1, abi_long arg2,
2418 abi_long arg3, abi_long arg4, abi_long arg5)
2420 print_syscall_prologue(name);
2421 print_string(arg0, 0);
2422 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
2426 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2427 print_syscall_epilogue(name);
2431 #ifdef TARGET_NR_ftruncate64
2433 print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name,
2434 abi_long arg0, abi_long arg1, abi_long arg2,
2435 abi_long arg3, abi_long arg4, abi_long arg5)
2437 print_syscall_prologue(name);
2438 print_raw_param("%d", arg0, 0);
2439 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
2443 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2444 print_syscall_epilogue(name);
2448 #ifdef TARGET_NR_mlockall
2450 print_mlockall(CPUArchState *cpu_env, const struct syscallname *name,
2451 abi_long arg0, abi_long arg1, abi_long arg2,
2452 abi_long arg3, abi_long arg4, abi_long arg5)
2454 print_syscall_prologue(name);
2455 print_flags(mlockall_flags, arg0, 1);
2456 print_syscall_epilogue(name);
2460 #if defined(TARGET_NR_socket)
2462 print_socket(CPUArchState *cpu_env, const struct syscallname *name,
2463 abi_long arg0, abi_long arg1, abi_long arg2,
2464 abi_long arg3, abi_long arg4, abi_long arg5)
2466 abi_ulong domain = arg0, type = arg1, protocol = arg2;
2468 print_syscall_prologue(name);
2469 print_socket_domain(domain);
2471 print_socket_type(type);
2473 if (domain == AF_PACKET ||
2474 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2475 protocol = tswap16(protocol);
2477 print_socket_protocol(domain, type, protocol);
2478 print_syscall_epilogue(name);
2483 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2485 static void print_sockfd(abi_long sockfd, int last)
2487 print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
2492 #if defined(TARGET_NR_socketcall)
2494 #define get_user_ualx(x, gaddr, idx) \
2495 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2497 static void do_print_socket(const char *name, abi_long arg1)
2499 abi_ulong domain, type, protocol;
2501 get_user_ualx(domain, arg1, 0);
2502 get_user_ualx(type, arg1, 1);
2503 get_user_ualx(protocol, arg1, 2);
2504 qemu_log("%s(", name);
2505 print_socket_domain(domain);
2507 print_socket_type(type);
2509 if (domain == AF_PACKET ||
2510 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2511 protocol = tswap16(protocol);
2513 print_socket_protocol(domain, type, protocol);
2517 static void do_print_sockaddr(const char *name, abi_long arg1)
2519 abi_ulong sockfd, addr, addrlen;
2521 get_user_ualx(sockfd, arg1, 0);
2522 get_user_ualx(addr, arg1, 1);
2523 get_user_ualx(addrlen, arg1, 2);
2525 qemu_log("%s(", name);
2526 print_sockfd(sockfd, 0);
2527 print_sockaddr(addr, addrlen, 0);
2531 static void do_print_listen(const char *name, abi_long arg1)
2533 abi_ulong sockfd, backlog;
2535 get_user_ualx(sockfd, arg1, 0);
2536 get_user_ualx(backlog, arg1, 1);
2538 qemu_log("%s(", name);
2539 print_sockfd(sockfd, 0);
2540 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
2544 static void do_print_socketpair(const char *name, abi_long arg1)
2546 abi_ulong domain, type, protocol, tab;
2548 get_user_ualx(domain, arg1, 0);
2549 get_user_ualx(type, arg1, 1);
2550 get_user_ualx(protocol, arg1, 2);
2551 get_user_ualx(tab, arg1, 3);
2553 qemu_log("%s(", name);
2554 print_socket_domain(domain);
2556 print_socket_type(type);
2558 print_socket_protocol(domain, type, protocol);
2560 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
2564 static void do_print_sendrecv(const char *name, abi_long arg1)
2566 abi_ulong sockfd, msg, len, flags;
2568 get_user_ualx(sockfd, arg1, 0);
2569 get_user_ualx(msg, arg1, 1);
2570 get_user_ualx(len, arg1, 2);
2571 get_user_ualx(flags, arg1, 3);
2573 qemu_log("%s(", name);
2574 print_sockfd(sockfd, 0);
2575 print_buf(msg, len, 0);
2576 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2577 print_flags(msg_flags, flags, 1);
2581 static void do_print_msgaddr(const char *name, abi_long arg1)
2583 abi_ulong sockfd, msg, len, flags, addr, addrlen;
2585 get_user_ualx(sockfd, arg1, 0);
2586 get_user_ualx(msg, arg1, 1);
2587 get_user_ualx(len, arg1, 2);
2588 get_user_ualx(flags, arg1, 3);
2589 get_user_ualx(addr, arg1, 4);
2590 get_user_ualx(addrlen, arg1, 5);
2592 qemu_log("%s(", name);
2593 print_sockfd(sockfd, 0);
2594 print_buf(msg, len, 0);
2595 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2596 print_flags(msg_flags, flags, 0);
2597 print_sockaddr(addr, addrlen, 0);
2601 static void do_print_shutdown(const char *name, abi_long arg1)
2603 abi_ulong sockfd, how;
2605 get_user_ualx(sockfd, arg1, 0);
2606 get_user_ualx(how, arg1, 1);
2608 qemu_log("shutdown(");
2609 print_sockfd(sockfd, 0);
2612 qemu_log("SHUT_RD");
2615 qemu_log("SHUT_WR");
2618 qemu_log("SHUT_RDWR");
2621 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
2627 static void do_print_msg(const char *name, abi_long arg1)
2629 abi_ulong sockfd, msg, flags;
2631 get_user_ualx(sockfd, arg1, 0);
2632 get_user_ualx(msg, arg1, 1);
2633 get_user_ualx(flags, arg1, 2);
2635 qemu_log("%s(", name);
2636 print_sockfd(sockfd, 0);
2637 print_pointer(msg, 0);
2638 print_flags(msg_flags, flags, 1);
2642 static void do_print_sockopt(const char *name, abi_long arg1)
2644 abi_ulong sockfd, level, optname, optval, optlen;
2646 get_user_ualx(sockfd, arg1, 0);
2647 get_user_ualx(level, arg1, 1);
2648 get_user_ualx(optname, arg1, 2);
2649 get_user_ualx(optval, arg1, 3);
2650 get_user_ualx(optlen, arg1, 4);
2652 qemu_log("%s(", name);
2653 print_sockfd(sockfd, 0);
2656 qemu_log("SOL_TCP,");
2657 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2658 print_pointer(optval, 0);
2661 qemu_log("SOL_UDP,");
2662 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2663 print_pointer(optval, 0);
2666 qemu_log("SOL_IP,");
2667 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2668 print_pointer(optval, 0);
2671 qemu_log("SOL_RAW,");
2672 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2673 print_pointer(optval, 0);
2675 case TARGET_SOL_SOCKET:
2676 qemu_log("SOL_SOCKET,");
2678 case TARGET_SO_DEBUG:
2679 qemu_log("SO_DEBUG,");
2681 print_number(optval, 0);
2683 case TARGET_SO_REUSEADDR:
2684 qemu_log("SO_REUSEADDR,");
2686 case TARGET_SO_REUSEPORT:
2687 qemu_log("SO_REUSEPORT,");
2689 case TARGET_SO_TYPE:
2690 qemu_log("SO_TYPE,");
2692 case TARGET_SO_ERROR:
2693 qemu_log("SO_ERROR,");
2695 case TARGET_SO_DONTROUTE:
2696 qemu_log("SO_DONTROUTE,");
2698 case TARGET_SO_BROADCAST:
2699 qemu_log("SO_BROADCAST,");
2701 case TARGET_SO_SNDBUF:
2702 qemu_log("SO_SNDBUF,");
2704 case TARGET_SO_RCVBUF:
2705 qemu_log("SO_RCVBUF,");
2707 case TARGET_SO_KEEPALIVE:
2708 qemu_log("SO_KEEPALIVE,");
2710 case TARGET_SO_OOBINLINE:
2711 qemu_log("SO_OOBINLINE,");
2713 case TARGET_SO_NO_CHECK:
2714 qemu_log("SO_NO_CHECK,");
2716 case TARGET_SO_PRIORITY:
2717 qemu_log("SO_PRIORITY,");
2719 case TARGET_SO_BSDCOMPAT:
2720 qemu_log("SO_BSDCOMPAT,");
2722 case TARGET_SO_PASSCRED:
2723 qemu_log("SO_PASSCRED,");
2725 case TARGET_SO_TIMESTAMP:
2726 qemu_log("SO_TIMESTAMP,");
2728 case TARGET_SO_RCVLOWAT:
2729 qemu_log("SO_RCVLOWAT,");
2731 case TARGET_SO_RCVTIMEO:
2732 qemu_log("SO_RCVTIMEO,");
2733 print_timeval(optval, 0);
2735 case TARGET_SO_SNDTIMEO:
2736 qemu_log("SO_SNDTIMEO,");
2737 print_timeval(optval, 0);
2739 case TARGET_SO_ATTACH_FILTER: {
2740 struct target_sock_fprog *fprog;
2742 qemu_log("SO_ATTACH_FILTER,");
2744 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
2745 struct target_sock_filter *filter;
2747 if (lock_user_struct(VERIFY_READ, filter,
2748 tswapal(fprog->filter), 0)) {
2750 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
2751 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2752 i, tswap16(filter[i].code),
2753 filter[i].jt, filter[i].jf,
2754 tswap32(filter[i].k));
2756 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2757 i, tswap16(filter[i].code),
2758 filter[i].jt, filter[i].jf,
2759 tswap32(filter[i].k));
2761 qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
2763 qemu_log(",%d},", tswap16(fprog->len));
2764 unlock_user(fprog, optval, 0);
2766 print_pointer(optval, 0);
2771 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2772 print_pointer(optval, 0);
2777 qemu_log("SOL_IPV6,");
2779 case IPV6_MTU_DISCOVER:
2780 qemu_log("IPV6_MTU_DISCOVER,");
2783 qemu_log("IPV6_MTU,");
2786 qemu_log("IPV6_V6ONLY,");
2788 case IPV6_RECVPKTINFO:
2789 qemu_log("IPV6_RECVPKTINFO,");
2791 case IPV6_UNICAST_HOPS:
2792 qemu_log("IPV6_UNICAST_HOPS,");
2794 case IPV6_MULTICAST_HOPS:
2795 qemu_log("IPV6_MULTICAST_HOPS,");
2797 case IPV6_MULTICAST_LOOP:
2798 qemu_log("IPV6_MULTICAST_LOOP,");
2801 qemu_log("IPV6_RECVERR,");
2803 case IPV6_RECVHOPLIMIT:
2804 qemu_log("IPV6_RECVHOPLIMIT,");
2806 case IPV6_2292HOPLIMIT:
2807 qemu_log("IPV6_2292HOPLIMIT,");
2810 qemu_log("IPV6_CHECKSUM,");
2813 qemu_log("IPV6_ADDRFORM,");
2815 case IPV6_2292PKTINFO:
2816 qemu_log("IPV6_2292PKTINFO,");
2818 case IPV6_RECVTCLASS:
2819 qemu_log("IPV6_RECVTCLASS,");
2821 case IPV6_RECVRTHDR:
2822 qemu_log("IPV6_RECVRTHDR,");
2824 case IPV6_2292RTHDR:
2825 qemu_log("IPV6_2292RTHDR,");
2827 case IPV6_RECVHOPOPTS:
2828 qemu_log("IPV6_RECVHOPOPTS,");
2830 case IPV6_2292HOPOPTS:
2831 qemu_log("IPV6_2292HOPOPTS,");
2833 case IPV6_RECVDSTOPTS:
2834 qemu_log("IPV6_RECVDSTOPTS,");
2836 case IPV6_2292DSTOPTS:
2837 qemu_log("IPV6_2292DSTOPTS,");
2840 qemu_log("IPV6_TCLASS,");
2842 case IPV6_ADDR_PREFERENCES:
2843 qemu_log("IPV6_ADDR_PREFERENCES,");
2845 #ifdef IPV6_RECVPATHMTU
2846 case IPV6_RECVPATHMTU:
2847 qemu_log("IPV6_RECVPATHMTU,");
2850 #ifdef IPV6_TRANSPARENT
2851 case IPV6_TRANSPARENT:
2852 qemu_log("IPV6_TRANSPARENT,");
2855 #ifdef IPV6_FREEBIND
2857 qemu_log("IPV6_FREEBIND,");
2860 #ifdef IPV6_RECVORIGDSTADDR
2861 case IPV6_RECVORIGDSTADDR:
2862 qemu_log("IPV6_RECVORIGDSTADDR,");
2866 qemu_log("IPV6_PKTINFO,");
2867 print_pointer(optval, 0);
2869 case IPV6_ADD_MEMBERSHIP:
2870 qemu_log("IPV6_ADD_MEMBERSHIP,");
2871 print_pointer(optval, 0);
2873 case IPV6_DROP_MEMBERSHIP:
2874 qemu_log("IPV6_DROP_MEMBERSHIP,");
2875 print_pointer(optval, 0);
2878 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2879 print_pointer(optval, 0);
2884 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
2885 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2886 print_pointer(optval, 0);
2889 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
2893 #define PRINT_SOCKOP(name, func) \
2894 [TARGET_SYS_##name] = { #name, func }
2898 void (*print)(const char *, abi_long);
2900 PRINT_SOCKOP(SOCKET, do_print_socket),
2901 PRINT_SOCKOP(BIND, do_print_sockaddr),
2902 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
2903 PRINT_SOCKOP(LISTEN, do_print_listen),
2904 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
2905 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
2906 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
2907 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
2908 PRINT_SOCKOP(SEND, do_print_sendrecv),
2909 PRINT_SOCKOP(RECV, do_print_sendrecv),
2910 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
2911 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
2912 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
2913 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
2914 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
2915 PRINT_SOCKOP(SENDMSG, do_print_msg),
2916 PRINT_SOCKOP(RECVMSG, do_print_msg),
2917 PRINT_SOCKOP(ACCEPT4, NULL),
2918 PRINT_SOCKOP(RECVMMSG, NULL),
2919 PRINT_SOCKOP(SENDMMSG, NULL),
2923 print_socketcall(CPUArchState *cpu_env, const struct syscallname *name,
2924 abi_long arg0, abi_long arg1, abi_long arg2,
2925 abi_long arg3, abi_long arg4, abi_long arg5)
2927 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
2928 scall[arg0].print(scall[arg0].name, arg1);
2931 print_syscall_prologue(name);
2932 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
2933 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2934 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2935 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
2936 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
2937 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
2938 print_syscall_epilogue(name);
2942 #if defined(TARGET_NR_bind)
2944 print_bind(CPUArchState *cpu_env, const struct syscallname *name,
2945 abi_long arg0, abi_long arg1, abi_long arg2,
2946 abi_long arg3, abi_long arg4, abi_long arg5)
2948 print_syscall_prologue(name);
2949 print_sockfd(arg0, 0);
2950 print_sockaddr(arg1, arg2, 1);
2951 print_syscall_epilogue(name);
2955 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2956 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2958 print_stat(CPUArchState *cpu_env, const struct syscallname *name,
2959 abi_long arg0, abi_long arg1, abi_long arg2,
2960 abi_long arg3, abi_long arg4, abi_long arg5)
2962 print_syscall_prologue(name);
2963 print_string(arg0, 0);
2964 print_pointer(arg1, 1);
2965 print_syscall_epilogue(name);
2967 #define print_lstat print_stat
2968 #define print_stat64 print_stat
2969 #define print_lstat64 print_stat
2972 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2974 print_fstat(CPUArchState *cpu_env, const struct syscallname *name,
2975 abi_long arg0, abi_long arg1, abi_long arg2,
2976 abi_long arg3, abi_long arg4, abi_long arg5)
2978 print_syscall_prologue(name);
2979 print_raw_param("%d", arg0, 0);
2980 print_pointer(arg1, 1);
2981 print_syscall_epilogue(name);
2983 #define print_fstat64 print_fstat
2986 #ifdef TARGET_NR_mkdir
2988 print_mkdir(CPUArchState *cpu_env, const struct syscallname *name,
2989 abi_long arg0, abi_long arg1, abi_long arg2,
2990 abi_long arg3, abi_long arg4, abi_long arg5)
2992 print_syscall_prologue(name);
2993 print_string(arg0, 0);
2994 print_file_mode(arg1, 1);
2995 print_syscall_epilogue(name);
2999 #ifdef TARGET_NR_mkdirat
3001 print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name,
3002 abi_long arg0, abi_long arg1, abi_long arg2,
3003 abi_long arg3, abi_long arg4, abi_long arg5)
3005 print_syscall_prologue(name);
3006 print_at_dirfd(arg0, 0);
3007 print_string(arg1, 0);
3008 print_file_mode(arg2, 1);
3009 print_syscall_epilogue(name);
3013 #ifdef TARGET_NR_rmdir
3015 print_rmdir(CPUArchState *cpu_env, const struct syscallname *name,
3016 abi_long arg0, abi_long arg1, abi_long arg2,
3017 abi_long arg3, abi_long arg4, abi_long arg5)
3019 print_syscall_prologue(name);
3020 print_string(arg0, 0);
3021 print_syscall_epilogue(name);
3025 #ifdef TARGET_NR_rt_sigaction
3027 print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name,
3028 abi_long arg0, abi_long arg1, abi_long arg2,
3029 abi_long arg3, abi_long arg4, abi_long arg5)
3031 print_syscall_prologue(name);
3032 print_signal(arg0, 0);
3033 print_pointer(arg1, 0);
3034 print_pointer(arg2, 1);
3035 print_syscall_epilogue(name);
3039 #ifdef TARGET_NR_rt_sigprocmask
3041 print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
3042 abi_long arg0, abi_long arg1, abi_long arg2,
3043 abi_long arg3, abi_long arg4, abi_long arg5)
3045 const char *how = "UNKNOWN";
3046 print_syscall_prologue(name);
3048 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
3049 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
3050 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
3052 qemu_log("%s,", how);
3053 print_pointer(arg1, 0);
3054 print_pointer(arg2, 1);
3055 print_syscall_epilogue(name);
3059 #ifdef TARGET_NR_rt_sigqueueinfo
3061 print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
3062 abi_long arg0, abi_long arg1, abi_long arg2,
3063 abi_long arg3, abi_long arg4, abi_long arg5)
3066 target_siginfo_t uinfo;
3068 print_syscall_prologue(name);
3069 print_raw_param("%d", arg0, 0);
3070 print_signal(arg1, 0);
3071 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
3073 get_target_siginfo(&uinfo, p);
3074 print_siginfo(&uinfo);
3076 unlock_user(p, arg2, 0);
3078 print_pointer(arg2, 1);
3080 print_syscall_epilogue(name);
3084 #ifdef TARGET_NR_rt_tgsigqueueinfo
3086 print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
3087 abi_long arg0, abi_long arg1, abi_long arg2,
3088 abi_long arg3, abi_long arg4, abi_long arg5)
3091 target_siginfo_t uinfo;
3093 print_syscall_prologue(name);
3094 print_raw_param("%d", arg0, 0);
3095 print_raw_param("%d", arg1, 0);
3096 print_signal(arg2, 0);
3097 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
3099 get_target_siginfo(&uinfo, p);
3100 print_siginfo(&uinfo);
3102 unlock_user(p, arg3, 0);
3104 print_pointer(arg3, 1);
3106 print_syscall_epilogue(name);
3110 #ifdef TARGET_NR_syslog
3112 print_syslog_action(abi_ulong arg, int last)
3117 case TARGET_SYSLOG_ACTION_CLOSE: {
3118 type = "SYSLOG_ACTION_CLOSE";
3121 case TARGET_SYSLOG_ACTION_OPEN: {
3122 type = "SYSLOG_ACTION_OPEN";
3125 case TARGET_SYSLOG_ACTION_READ: {
3126 type = "SYSLOG_ACTION_READ";
3129 case TARGET_SYSLOG_ACTION_READ_ALL: {
3130 type = "SYSLOG_ACTION_READ_ALL";
3133 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
3134 type = "SYSLOG_ACTION_READ_CLEAR";
3137 case TARGET_SYSLOG_ACTION_CLEAR: {
3138 type = "SYSLOG_ACTION_CLEAR";
3141 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
3142 type = "SYSLOG_ACTION_CONSOLE_OFF";
3145 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
3146 type = "SYSLOG_ACTION_CONSOLE_ON";
3149 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
3150 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
3153 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
3154 type = "SYSLOG_ACTION_SIZE_UNREAD";
3157 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
3158 type = "SYSLOG_ACTION_SIZE_BUFFER";
3162 print_raw_param("%ld", arg, last);
3166 qemu_log("%s%s", type, get_comma(last));
3170 print_syslog(CPUArchState *cpu_env, const struct syscallname *name,
3171 abi_long arg0, abi_long arg1, abi_long arg2,
3172 abi_long arg3, abi_long arg4, abi_long arg5)
3174 print_syscall_prologue(name);
3175 print_syslog_action(arg0, 0);
3176 print_pointer(arg1, 0);
3177 print_raw_param("%d", arg2, 1);
3178 print_syscall_epilogue(name);
3182 #ifdef TARGET_NR_mknod
3184 print_mknod(CPUArchState *cpu_env, const struct syscallname *name,
3185 abi_long arg0, abi_long arg1, abi_long arg2,
3186 abi_long arg3, abi_long arg4, abi_long arg5)
3188 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
3190 print_syscall_prologue(name);
3191 print_string(arg0, 0);
3192 print_file_mode(arg1, (hasdev == 0));
3194 print_raw_param("makedev(%d", major(arg2), 0);
3195 print_raw_param("%d)", minor(arg2), 1);
3197 print_syscall_epilogue(name);
3201 #ifdef TARGET_NR_mknodat
3203 print_mknodat(CPUArchState *cpu_env, const struct syscallname *name,
3204 abi_long arg0, abi_long arg1, abi_long arg2,
3205 abi_long arg3, abi_long arg4, abi_long arg5)
3207 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
3209 print_syscall_prologue(name);
3210 print_at_dirfd(arg0, 0);
3211 print_string(arg1, 0);
3212 print_file_mode(arg2, (hasdev == 0));
3214 print_raw_param("makedev(%d", major(arg3), 0);
3215 print_raw_param("%d)", minor(arg3), 1);
3217 print_syscall_epilogue(name);
3221 #ifdef TARGET_NR_mq_open
3223 print_mq_open(CPUArchState *cpu_env, const struct syscallname *name,
3224 abi_long arg0, abi_long arg1, abi_long arg2,
3225 abi_long arg3, abi_long arg4, abi_long arg5)
3227 int is_creat = (arg1 & TARGET_O_CREAT);
3229 print_syscall_prologue(name);
3230 print_string(arg0, 0);
3231 print_open_flags(arg1, (is_creat == 0));
3233 print_file_mode(arg2, 0);
3234 print_pointer(arg3, 1);
3236 print_syscall_epilogue(name);
3240 #ifdef TARGET_NR_open
3242 print_open(CPUArchState *cpu_env, const struct syscallname *name,
3243 abi_long arg0, abi_long arg1, abi_long arg2,
3244 abi_long arg3, abi_long arg4, abi_long arg5)
3246 int is_creat = (arg1 & TARGET_O_CREAT);
3248 print_syscall_prologue(name);
3249 print_string(arg0, 0);
3250 print_open_flags(arg1, (is_creat == 0));
3252 print_file_mode(arg2, 1);
3253 print_syscall_epilogue(name);
3257 #ifdef TARGET_NR_openat
3259 print_openat(CPUArchState *cpu_env, const struct syscallname *name,
3260 abi_long arg0, abi_long arg1, abi_long arg2,
3261 abi_long arg3, abi_long arg4, abi_long arg5)
3263 int is_creat = (arg2 & TARGET_O_CREAT);
3265 print_syscall_prologue(name);
3266 print_at_dirfd(arg0, 0);
3267 print_string(arg1, 0);
3268 print_open_flags(arg2, (is_creat == 0));
3270 print_file_mode(arg3, 1);
3271 print_syscall_epilogue(name);
3275 #ifdef TARGET_NR_mq_unlink
3277 print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name,
3278 abi_long arg0, abi_long arg1, abi_long arg2,
3279 abi_long arg3, abi_long arg4, abi_long arg5)
3281 print_syscall_prologue(name);
3282 print_string(arg0, 1);
3283 print_syscall_epilogue(name);
3287 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3289 print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name,
3290 abi_long arg0, abi_long arg1, abi_long arg2,
3291 abi_long arg3, abi_long arg4, abi_long arg5)
3293 print_syscall_prologue(name);
3294 print_at_dirfd(arg0, 0);
3295 print_string(arg1, 0);
3296 print_pointer(arg2, 0);
3297 print_flags(at_file_flags, arg3, 1);
3298 print_syscall_epilogue(name);
3300 #define print_newfstatat print_fstatat64
3303 #ifdef TARGET_NR_readlink
3305 print_readlink(CPUArchState *cpu_env, const struct syscallname *name,
3306 abi_long arg0, abi_long arg1, abi_long arg2,
3307 abi_long arg3, abi_long arg4, abi_long arg5)
3309 print_syscall_prologue(name);
3310 print_string(arg0, 0);
3311 print_pointer(arg1, 0);
3312 print_raw_param("%u", arg2, 1);
3313 print_syscall_epilogue(name);
3317 #ifdef TARGET_NR_readlinkat
3319 print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name,
3320 abi_long arg0, abi_long arg1, abi_long arg2,
3321 abi_long arg3, abi_long arg4, abi_long arg5)
3323 print_syscall_prologue(name);
3324 print_at_dirfd(arg0, 0);
3325 print_string(arg1, 0);
3326 print_pointer(arg2, 0);
3327 print_raw_param("%u", arg3, 1);
3328 print_syscall_epilogue(name);
3332 #ifdef TARGET_NR_rename
3334 print_rename(CPUArchState *cpu_env, const struct syscallname *name,
3335 abi_long arg0, abi_long arg1, abi_long arg2,
3336 abi_long arg3, abi_long arg4, abi_long arg5)
3338 print_syscall_prologue(name);
3339 print_string(arg0, 0);
3340 print_string(arg1, 1);
3341 print_syscall_epilogue(name);
3345 #ifdef TARGET_NR_renameat
3347 print_renameat(CPUArchState *cpu_env, const struct syscallname *name,
3348 abi_long arg0, abi_long arg1, abi_long arg2,
3349 abi_long arg3, abi_long arg4, abi_long arg5)
3351 print_syscall_prologue(name);
3352 print_at_dirfd(arg0, 0);
3353 print_string(arg1, 0);
3354 print_at_dirfd(arg2, 0);
3355 print_string(arg3, 1);
3356 print_syscall_epilogue(name);
3360 #ifdef TARGET_NR_statfs
3362 print_statfs(CPUArchState *cpu_env, const struct syscallname *name,
3363 abi_long arg0, abi_long arg1, abi_long arg2,
3364 abi_long arg3, abi_long arg4, abi_long arg5)
3366 print_syscall_prologue(name);
3367 print_string(arg0, 0);
3368 print_pointer(arg1, 1);
3369 print_syscall_epilogue(name);
3373 #ifdef TARGET_NR_statfs64
3375 print_statfs64(CPUArchState *cpu_env, const struct syscallname *name,
3376 abi_long arg0, abi_long arg1, abi_long arg2,
3377 abi_long arg3, abi_long arg4, abi_long arg5)
3379 print_syscall_prologue(name);
3380 print_string(arg0, 0);
3381 print_pointer(arg1, 1);
3382 print_syscall_epilogue(name);
3386 #ifdef TARGET_NR_symlink
3388 print_symlink(CPUArchState *cpu_env, const struct syscallname *name,
3389 abi_long arg0, abi_long arg1, abi_long arg2,
3390 abi_long arg3, abi_long arg4, abi_long arg5)
3392 print_syscall_prologue(name);
3393 print_string(arg0, 0);
3394 print_string(arg1, 1);
3395 print_syscall_epilogue(name);
3399 #ifdef TARGET_NR_symlinkat
3401 print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name,
3402 abi_long arg0, abi_long arg1, abi_long arg2,
3403 abi_long arg3, abi_long arg4, abi_long arg5)
3405 print_syscall_prologue(name);
3406 print_string(arg0, 0);
3407 print_at_dirfd(arg1, 0);
3408 print_string(arg2, 1);
3409 print_syscall_epilogue(name);
3413 #ifdef TARGET_NR_mount
3415 print_mount(CPUArchState *cpu_env, const struct syscallname *name,
3416 abi_long arg0, abi_long arg1, abi_long arg2,
3417 abi_long arg3, abi_long arg4, abi_long arg5)
3419 print_syscall_prologue(name);
3420 print_string(arg0, 0);
3421 print_string(arg1, 0);
3422 print_string(arg2, 0);
3423 print_flags(mount_flags, arg3, 0);
3424 print_pointer(arg4, 1);
3425 print_syscall_epilogue(name);
3429 #ifdef TARGET_NR_umount
3431 print_umount(CPUArchState *cpu_env, const struct syscallname *name,
3432 abi_long arg0, abi_long arg1, abi_long arg2,
3433 abi_long arg3, abi_long arg4, abi_long arg5)
3435 print_syscall_prologue(name);
3436 print_string(arg0, 1);
3437 print_syscall_epilogue(name);
3441 #ifdef TARGET_NR_umount2
3443 print_umount2(CPUArchState *cpu_env, const struct syscallname *name,
3444 abi_long arg0, abi_long arg1, abi_long arg2,
3445 abi_long arg3, abi_long arg4, abi_long arg5)
3447 print_syscall_prologue(name);
3448 print_string(arg0, 0);
3449 print_flags(umount2_flags, arg1, 1);
3450 print_syscall_epilogue(name);
3454 #ifdef TARGET_NR_unlink
3456 print_unlink(CPUArchState *cpu_env, const struct syscallname *name,
3457 abi_long arg0, abi_long arg1, abi_long arg2,
3458 abi_long arg3, abi_long arg4, abi_long arg5)
3460 print_syscall_prologue(name);
3461 print_string(arg0, 1);
3462 print_syscall_epilogue(name);
3466 #ifdef TARGET_NR_unlinkat
3468 print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name,
3469 abi_long arg0, abi_long arg1, abi_long arg2,
3470 abi_long arg3, abi_long arg4, abi_long arg5)
3472 print_syscall_prologue(name);
3473 print_at_dirfd(arg0, 0);
3474 print_string(arg1, 0);
3475 print_flags(unlinkat_flags, arg2, 1);
3476 print_syscall_epilogue(name);
3480 #ifdef TARGET_NR_unshare
3482 print_unshare(CPUArchState *cpu_env, const struct syscallname *name,
3483 abi_long arg0, abi_long arg1, abi_long arg2,
3484 abi_long arg3, abi_long arg4, abi_long arg5)
3486 print_syscall_prologue(name);
3487 print_flags(clone_flags, arg0, 1);
3488 print_syscall_epilogue(name);
3492 #ifdef TARGET_NR_utime
3494 print_utime(CPUArchState *cpu_env, const struct syscallname *name,
3495 abi_long arg0, abi_long arg1, abi_long arg2,
3496 abi_long arg3, abi_long arg4, abi_long arg5)
3498 print_syscall_prologue(name);
3499 print_string(arg0, 0);
3500 print_pointer(arg1, 1);
3501 print_syscall_epilogue(name);
3505 #ifdef TARGET_NR_utimes
3507 print_utimes(CPUArchState *cpu_env, const struct syscallname *name,
3508 abi_long arg0, abi_long arg1, abi_long arg2,
3509 abi_long arg3, abi_long arg4, abi_long arg5)
3511 print_syscall_prologue(name);
3512 print_string(arg0, 0);
3513 print_pointer(arg1, 1);
3514 print_syscall_epilogue(name);
3518 #ifdef TARGET_NR_utimensat
3520 print_utimensat(CPUArchState *cpu_env, const struct syscallname *name,
3521 abi_long arg0, abi_long arg1, abi_long arg2,
3522 abi_long arg3, abi_long arg4, abi_long arg5)
3524 print_syscall_prologue(name);
3525 print_at_dirfd(arg0, 0);
3526 print_string(arg1, 0);
3527 print_pointer(arg2, 0);
3528 print_flags(at_file_flags, arg3, 1);
3529 print_syscall_epilogue(name);
3533 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
3535 print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
3536 abi_long arg0, abi_long arg1, abi_long arg2,
3537 abi_long arg3, abi_long arg4, abi_long arg5)
3539 print_syscall_prologue(name);
3540 print_pointer(arg0, 0);
3541 print_raw_param("%d", arg1, 0);
3542 print_flags(mmap_prot_flags, arg2, 0);
3543 print_flags(mmap_flags, arg3, 0);
3544 print_raw_param("%d", arg4, 0);
3545 print_raw_param("%#x", arg5, 1);
3546 print_syscall_epilogue(name);
3548 #define print_mmap2 print_mmap
3551 #ifdef TARGET_NR_mprotect
3553 print_mprotect(CPUArchState *cpu_env, const struct syscallname *name,
3554 abi_long arg0, abi_long arg1, abi_long arg2,
3555 abi_long arg3, abi_long arg4, abi_long arg5)
3557 print_syscall_prologue(name);
3558 print_pointer(arg0, 0);
3559 print_raw_param("%d", arg1, 0);
3560 print_flags(mmap_prot_flags, arg2, 1);
3561 print_syscall_epilogue(name);
3565 #ifdef TARGET_NR_munmap
3567 print_munmap(CPUArchState *cpu_env, const struct syscallname *name,
3568 abi_long arg0, abi_long arg1, abi_long arg2,
3569 abi_long arg3, abi_long arg4, abi_long arg5)
3571 print_syscall_prologue(name);
3572 print_pointer(arg0, 0);
3573 print_raw_param("%d", arg1, 1);
3574 print_syscall_epilogue(name);
3578 #ifdef TARGET_NR_futex
3579 static void print_futex_op(abi_long tflag, int last)
3581 #define print_op(val) \
3582 if( cmd == val ) { \
3587 int cmd = (int)tflag;
3588 #ifdef FUTEX_PRIVATE_FLAG
3589 if (cmd & FUTEX_PRIVATE_FLAG) {
3590 qemu_log("FUTEX_PRIVATE_FLAG|");
3591 cmd &= ~FUTEX_PRIVATE_FLAG;
3594 #ifdef FUTEX_CLOCK_REALTIME
3595 if (cmd & FUTEX_CLOCK_REALTIME) {
3596 qemu_log("FUTEX_CLOCK_REALTIME|");
3597 cmd &= ~FUTEX_CLOCK_REALTIME;
3600 print_op(FUTEX_WAIT)
3601 print_op(FUTEX_WAKE)
3603 print_op(FUTEX_REQUEUE)
3604 print_op(FUTEX_CMP_REQUEUE)
3605 print_op(FUTEX_WAKE_OP)
3606 print_op(FUTEX_LOCK_PI)
3607 print_op(FUTEX_UNLOCK_PI)
3608 print_op(FUTEX_TRYLOCK_PI)
3609 #ifdef FUTEX_WAIT_BITSET
3610 print_op(FUTEX_WAIT_BITSET)
3612 #ifdef FUTEX_WAKE_BITSET
3613 print_op(FUTEX_WAKE_BITSET)
3615 /* unknown values */
3616 qemu_log("%d", cmd);
3620 print_futex(CPUArchState *cpu_env, const struct syscallname *name,
3621 abi_long arg0, abi_long arg1, abi_long arg2,
3622 abi_long arg3, abi_long arg4, abi_long arg5)
3624 print_syscall_prologue(name);
3625 print_pointer(arg0, 0);
3626 print_futex_op(arg1, 0);
3627 print_raw_param(",%d", arg2, 0);
3628 print_pointer(arg3, 0); /* struct timespec */
3629 print_pointer(arg4, 0);
3630 print_raw_param("%d", arg4, 1);
3631 print_syscall_epilogue(name);
3635 #ifdef TARGET_NR_kill
3637 print_kill(CPUArchState *cpu_env, const struct syscallname *name,
3638 abi_long arg0, abi_long arg1, abi_long arg2,
3639 abi_long arg3, abi_long arg4, abi_long arg5)
3641 print_syscall_prologue(name);
3642 print_raw_param("%d", arg0, 0);
3643 print_signal(arg1, 1);
3644 print_syscall_epilogue(name);
3648 #ifdef TARGET_NR_tkill
3650 print_tkill(CPUArchState *cpu_env, const struct syscallname *name,
3651 abi_long arg0, abi_long arg1, abi_long arg2,
3652 abi_long arg3, abi_long arg4, abi_long arg5)
3654 print_syscall_prologue(name);
3655 print_raw_param("%d", arg0, 0);
3656 print_signal(arg1, 1);
3657 print_syscall_epilogue(name);
3661 #ifdef TARGET_NR_tgkill
3663 print_tgkill(CPUArchState *cpu_env, const struct syscallname *name,
3664 abi_long arg0, abi_long arg1, abi_long arg2,
3665 abi_long arg3, abi_long arg4, abi_long arg5)
3667 print_syscall_prologue(name);
3668 print_raw_param("%d", arg0, 0);
3669 print_raw_param("%d", arg1, 0);
3670 print_signal(arg2, 1);
3671 print_syscall_epilogue(name);
3675 #ifdef TARGET_NR_statx
3677 print_statx(CPUArchState *cpu_env, const struct syscallname *name,
3678 abi_long arg0, abi_long arg1, abi_long arg2,
3679 abi_long arg3, abi_long arg4, abi_long arg5)
3681 print_syscall_prologue(name);
3682 print_at_dirfd(arg0, 0);
3683 print_string(arg1, 0);
3684 print_flags(statx_flags, arg2, 0);
3685 print_flags(statx_mask, arg3, 0);
3686 print_pointer(arg4, 1);
3687 print_syscall_epilogue(name);
3691 #ifdef TARGET_NR_ioctl
3693 print_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
3694 abi_long arg0, abi_long arg1, abi_long arg2,
3695 abi_long arg3, abi_long arg4, abi_long arg5)
3697 print_syscall_prologue(name);
3698 print_raw_param("%d", arg0, 0);
3700 const IOCTLEntry *ie;
3701 const argtype *arg_type;
3705 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
3706 if (ie->target_cmd == arg1) {
3711 if (ie->target_cmd == 0) {
3712 print_raw_param("%#x", arg1, 0);
3713 print_raw_param("%#x", arg2, 1);
3715 qemu_log("%s", ie->name);
3716 arg_type = ie->arg_type;
3718 if (arg_type[0] != TYPE_NULL) {
3721 switch (arg_type[0]) {
3723 print_pointer(arg2, 1);
3728 print_raw_param("%d", arg2, 1);
3731 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
3734 print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
3737 switch (ie->access) {
3739 print_pointer(arg2, 1);
3744 target_size = thunk_type_size(arg_type, 0);
3745 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
3747 thunk_print(argptr, arg_type);
3748 unlock_user(argptr, arg2, target_size);
3750 print_pointer(arg2, 1);
3756 g_assert_not_reached();
3760 print_syscall_epilogue(name);
3765 * An array of all of the syscalls we know about
3768 static const struct syscallname scnames[] = {
3769 #include "strace.list"
3772 static int nsyscalls = ARRAY_SIZE(scnames);
3775 * The public interface to this module.
3778 print_syscall(CPUArchState *cpu_env, int num,
3779 abi_long arg1, abi_long arg2, abi_long arg3,
3780 abi_long arg4, abi_long arg5, abi_long arg6)
3783 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 ")";
3785 qemu_log("%d ", getpid());
3787 for(i=0;i<nsyscalls;i++)
3788 if( scnames[i].nr == num ) {
3789 if( scnames[i].call != NULL ) {
3791 cpu_env, &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6);
3793 /* XXX: this format system is broken because it uses
3794 host types and host pointers for strings */
3795 if( scnames[i].format != NULL )
3796 format = scnames[i].format;
3798 scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6);
3802 qemu_log("Unknown syscall %d\n", num);
3807 print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret,
3808 abi_long arg1, abi_long arg2, abi_long arg3,
3809 abi_long arg4, abi_long arg5, abi_long arg6)
3813 for(i=0;i<nsyscalls;i++)
3814 if( scnames[i].nr == num ) {
3815 if( scnames[i].result != NULL ) {
3816 scnames[i].result(cpu_env, &scnames[i], ret,
3820 if (!print_syscall_err(ret)) {
3821 qemu_log(TARGET_ABI_FMT_ld, ret);
3829 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
3831 /* Print the strace output for a signal being taken:
3832 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
3835 print_signal(target_signum, 1);
3837 print_siginfo(tinfo);