target/arm: Implement VFP fp16 VCMP
[qemu.git] / linux-user / strace.c
1 #include "qemu/osdep.h"
2 #include <sys/ipc.h>
3 #include <sys/msg.h>
4 #include <sys/sem.h>
5 #include <sys/shm.h>
6 #include <sys/select.h>
7 #include <sys/mount.h>
8 #include <arpa/inet.h>
9 #include <netinet/tcp.h>
10 #include <linux/if_packet.h>
11 #include <linux/netlink.h>
12 #include <sched.h>
13 #include "qemu.h"
14
15 struct syscallname {
16 int nr;
17 const char *name;
18 const char *format;
19 void (*call)(void *, const struct syscallname *,
20 abi_long, abi_long, abi_long,
21 abi_long, abi_long, abi_long);
22 void (*result)(void *, const struct syscallname *, abi_long,
23 abi_long, abi_long, abi_long,
24 abi_long, abi_long, abi_long);
25 };
26
27 #ifdef __GNUC__
28 /*
29 * It is possible that target doesn't have syscall that uses
30 * following flags but we don't want the compiler to warn
31 * us about them being unused. Same applies to utility print
32 * functions. It is ok to keep them while not used.
33 */
34 #define UNUSED __attribute__ ((unused))
35 #else
36 #define UNUSED
37 #endif
38
39 /*
40 * Structure used to translate flag values into strings. This is
41 * similar that is in the actual strace tool.
42 */
43 struct flags {
44 abi_long f_value; /* flag */
45 const char *f_string; /* stringified flag */
46 };
47
48 /* common flags for all architectures */
49 #define FLAG_GENERIC(name) { name, #name }
50 /* target specific flags (syscall_defs.h has TARGET_<flag>) */
51 #define FLAG_TARGET(name) { TARGET_ ## name, #name }
52 /* end of flags array */
53 #define FLAG_END { 0, NULL }
54
55 /* Structure used to translate enumerated values into strings */
56 struct enums {
57 abi_long e_value; /* enum value */
58 const char *e_string; /* stringified enum */
59 };
60
61 /* common enums for all architectures */
62 #define ENUM_GENERIC(name) { name, #name }
63 /* target specific enums */
64 #define ENUM_TARGET(name) { TARGET_ ## name, #name }
65 /* end of enums array */
66 #define ENUM_END { 0, NULL }
67
68 UNUSED static const char *get_comma(int);
69 UNUSED static void print_pointer(abi_long, int);
70 UNUSED static void print_flags(const struct flags *, abi_long, int);
71 UNUSED static void print_enums(const struct enums *, abi_long, int);
72 UNUSED static void print_at_dirfd(abi_long, int);
73 UNUSED static void print_file_mode(abi_long, int);
74 UNUSED static void print_open_flags(abi_long, int);
75 UNUSED static void print_syscall_prologue(const struct syscallname *);
76 UNUSED static void print_syscall_epilogue(const struct syscallname *);
77 UNUSED static void print_string(abi_long, int);
78 UNUSED static void print_buf(abi_long addr, abi_long len, int last);
79 UNUSED static void print_raw_param(const char *, abi_long, int);
80 UNUSED static void print_timeval(abi_ulong, int);
81 UNUSED static void print_timespec(abi_ulong, int);
82 UNUSED static void print_timezone(abi_ulong, int);
83 UNUSED static void print_itimerval(abi_ulong, int);
84 UNUSED static void print_number(abi_long, int);
85 UNUSED static void print_signal(abi_ulong, int);
86 UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
87 UNUSED static void print_socket_domain(int domain);
88 UNUSED static void print_socket_type(int type);
89 UNUSED static void print_socket_protocol(int domain, int type, int protocol);
90
91 /*
92 * Utility functions
93 */
94 static void
95 print_ipc_cmd(int cmd)
96 {
97 #define output_cmd(val) \
98 if( cmd == val ) { \
99 qemu_log(#val); \
100 return; \
101 }
102
103 cmd &= 0xff;
104
105 /* General IPC commands */
106 output_cmd( IPC_RMID );
107 output_cmd( IPC_SET );
108 output_cmd( IPC_STAT );
109 output_cmd( IPC_INFO );
110 /* msgctl() commands */
111 output_cmd( MSG_STAT );
112 output_cmd( MSG_INFO );
113 /* shmctl() commands */
114 output_cmd( SHM_LOCK );
115 output_cmd( SHM_UNLOCK );
116 output_cmd( SHM_STAT );
117 output_cmd( SHM_INFO );
118 /* semctl() commands */
119 output_cmd( GETPID );
120 output_cmd( GETVAL );
121 output_cmd( GETALL );
122 output_cmd( GETNCNT );
123 output_cmd( GETZCNT );
124 output_cmd( SETVAL );
125 output_cmd( SETALL );
126 output_cmd( SEM_STAT );
127 output_cmd( SEM_INFO );
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 );
136 output_cmd( IPC_RMID );
137
138 /* Some value we don't recognize */
139 qemu_log("%d", cmd);
140 }
141
142 static void
143 print_signal(abi_ulong arg, int last)
144 {
145 const char *signal_name = NULL;
146 switch(arg) {
147 case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
148 case TARGET_SIGINT: signal_name = "SIGINT"; break;
149 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
150 case TARGET_SIGILL: signal_name = "SIGILL"; break;
151 case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
152 case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
153 case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
154 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
155 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
156 case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
157 case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
158 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
159 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
160 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
161 case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
162 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
163 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
164 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
165 }
166 if (signal_name == NULL) {
167 print_raw_param("%ld", arg, last);
168 return;
169 }
170 qemu_log("%s%s", signal_name, get_comma(last));
171 }
172
173 static void print_si_code(int arg)
174 {
175 const char *codename = NULL;
176
177 switch (arg) {
178 case SI_USER:
179 codename = "SI_USER";
180 break;
181 case SI_KERNEL:
182 codename = "SI_KERNEL";
183 break;
184 case SI_QUEUE:
185 codename = "SI_QUEUE";
186 break;
187 case SI_TIMER:
188 codename = "SI_TIMER";
189 break;
190 case SI_MESGQ:
191 codename = "SI_MESGQ";
192 break;
193 case SI_ASYNCIO:
194 codename = "SI_ASYNCIO";
195 break;
196 case SI_SIGIO:
197 codename = "SI_SIGIO";
198 break;
199 case SI_TKILL:
200 codename = "SI_TKILL";
201 break;
202 default:
203 qemu_log("%d", arg);
204 return;
205 }
206 qemu_log("%s", codename);
207 }
208
209 static void get_target_siginfo(target_siginfo_t *tinfo,
210 const target_siginfo_t *info)
211 {
212 abi_ulong sival_ptr;
213
214 int sig;
215 int si_errno;
216 int si_code;
217 int si_type;
218
219 __get_user(sig, &info->si_signo);
220 __get_user(si_errno, &tinfo->si_errno);
221 __get_user(si_code, &info->si_code);
222
223 tinfo->si_signo = sig;
224 tinfo->si_errno = si_errno;
225 tinfo->si_code = si_code;
226
227 /* Ensure we don't leak random junk to the guest later */
228 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
229
230 /* This is awkward, because we have to use a combination of
231 * the si_code and si_signo to figure out which of the union's
232 * members are valid. (Within the host kernel it is always possible
233 * to tell, but the kernel carefully avoids giving userspace the
234 * high 16 bits of si_code, so we don't have the information to
235 * do this the easy way...) We therefore make our best guess,
236 * bearing in mind that a guest can spoof most of the si_codes
237 * via rt_sigqueueinfo() if it likes.
238 *
239 * Once we have made our guess, we record it in the top 16 bits of
240 * the si_code, so that print_siginfo() later can use it.
241 * print_siginfo() will strip these top bits out before printing
242 * the si_code.
243 */
244
245 switch (si_code) {
246 case SI_USER:
247 case SI_TKILL:
248 case SI_KERNEL:
249 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
250 * These are the only unspoofable si_code values.
251 */
252 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
253 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
254 si_type = QEMU_SI_KILL;
255 break;
256 default:
257 /* Everything else is spoofable. Make best guess based on signal */
258 switch (sig) {
259 case TARGET_SIGCHLD:
260 __get_user(tinfo->_sifields._sigchld._pid,
261 &info->_sifields._sigchld._pid);
262 __get_user(tinfo->_sifields._sigchld._uid,
263 &info->_sifields._sigchld._uid);
264 __get_user(tinfo->_sifields._sigchld._status,
265 &info->_sifields._sigchld._status);
266 __get_user(tinfo->_sifields._sigchld._utime,
267 &info->_sifields._sigchld._utime);
268 __get_user(tinfo->_sifields._sigchld._stime,
269 &info->_sifields._sigchld._stime);
270 si_type = QEMU_SI_CHLD;
271 break;
272 case TARGET_SIGIO:
273 __get_user(tinfo->_sifields._sigpoll._band,
274 &info->_sifields._sigpoll._band);
275 __get_user(tinfo->_sifields._sigpoll._fd,
276 &info->_sifields._sigpoll._fd);
277 si_type = QEMU_SI_POLL;
278 break;
279 default:
280 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
281 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
282 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
283 /* XXX: potential problem if 64 bit */
284 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
285 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
286
287 si_type = QEMU_SI_RT;
288 break;
289 }
290 break;
291 }
292
293 tinfo->si_code = deposit32(si_code, 16, 16, si_type);
294 }
295
296 static void print_siginfo(const target_siginfo_t *tinfo)
297 {
298 /* Print a target_siginfo_t in the format desired for printing
299 * signals being taken. We assume the target_siginfo_t is in the
300 * internal form where the top 16 bits of si_code indicate which
301 * part of the union is valid, rather than in the guest-visible
302 * form where the bottom 16 bits are sign-extended into the top 16.
303 */
304 int si_type = extract32(tinfo->si_code, 16, 16);
305 int si_code = sextract32(tinfo->si_code, 0, 16);
306
307 qemu_log("{si_signo=");
308 print_signal(tinfo->si_signo, 1);
309 qemu_log(", si_code=");
310 print_si_code(si_code);
311
312 switch (si_type) {
313 case QEMU_SI_KILL:
314 qemu_log(", si_pid=%u, si_uid=%u",
315 (unsigned int)tinfo->_sifields._kill._pid,
316 (unsigned int)tinfo->_sifields._kill._uid);
317 break;
318 case QEMU_SI_TIMER:
319 qemu_log(", si_timer1=%u, si_timer2=%u",
320 tinfo->_sifields._timer._timer1,
321 tinfo->_sifields._timer._timer2);
322 break;
323 case QEMU_SI_POLL:
324 qemu_log(", si_band=%d, si_fd=%d",
325 tinfo->_sifields._sigpoll._band,
326 tinfo->_sifields._sigpoll._fd);
327 break;
328 case QEMU_SI_FAULT:
329 qemu_log(", si_addr=");
330 print_pointer(tinfo->_sifields._sigfault._addr, 1);
331 break;
332 case QEMU_SI_CHLD:
333 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
334 ", si_utime=" TARGET_ABI_FMT_ld
335 ", si_stime=" TARGET_ABI_FMT_ld,
336 (unsigned int)(tinfo->_sifields._sigchld._pid),
337 (unsigned int)(tinfo->_sifields._sigchld._uid),
338 tinfo->_sifields._sigchld._status,
339 tinfo->_sifields._sigchld._utime,
340 tinfo->_sifields._sigchld._stime);
341 break;
342 case QEMU_SI_RT:
343 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
344 (unsigned int)tinfo->_sifields._rt._pid,
345 (unsigned int)tinfo->_sifields._rt._uid,
346 tinfo->_sifields._rt._sigval.sival_ptr);
347 break;
348 default:
349 g_assert_not_reached();
350 }
351 qemu_log("}");
352 }
353
354 static void
355 print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
356 {
357 struct target_sockaddr *sa;
358 int i;
359 int sa_family;
360
361 sa = lock_user(VERIFY_READ, addr, addrlen, 1);
362 if (sa) {
363 sa_family = tswap16(sa->sa_family);
364 switch (sa_family) {
365 case AF_UNIX: {
366 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
367 int i;
368 qemu_log("{sun_family=AF_UNIX,sun_path=\"");
369 for (i = 0; i < addrlen -
370 offsetof(struct target_sockaddr_un, sun_path) &&
371 un->sun_path[i]; i++) {
372 qemu_log("%c", un->sun_path[i]);
373 }
374 qemu_log("\"}");
375 break;
376 }
377 case AF_INET: {
378 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
379 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
380 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
381 ntohs(in->sin_port));
382 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
383 c[0], c[1], c[2], c[3]);
384 qemu_log("}");
385 break;
386 }
387 case AF_PACKET: {
388 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
389 uint8_t *c = (uint8_t *)&ll->sll_addr;
390 qemu_log("{sll_family=AF_PACKET,"
391 "sll_protocol=htons(0x%04x),if%d,pkttype=",
392 ntohs(ll->sll_protocol), ll->sll_ifindex);
393 switch (ll->sll_pkttype) {
394 case PACKET_HOST:
395 qemu_log("PACKET_HOST");
396 break;
397 case PACKET_BROADCAST:
398 qemu_log("PACKET_BROADCAST");
399 break;
400 case PACKET_MULTICAST:
401 qemu_log("PACKET_MULTICAST");
402 break;
403 case PACKET_OTHERHOST:
404 qemu_log("PACKET_OTHERHOST");
405 break;
406 case PACKET_OUTGOING:
407 qemu_log("PACKET_OUTGOING");
408 break;
409 default:
410 qemu_log("%d", ll->sll_pkttype);
411 break;
412 }
413 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
414 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
415 qemu_log("}");
416 break;
417 }
418 case AF_NETLINK: {
419 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
420 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
421 tswap32(nl->nl_pid), tswap32(nl->nl_groups));
422 break;
423 }
424 default:
425 qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
426 for (i = 0; i < 13; i++) {
427 qemu_log("%02x, ", sa->sa_data[i]);
428 }
429 qemu_log("%02x}", sa->sa_data[i]);
430 qemu_log("}");
431 break;
432 }
433 unlock_user(sa, addr, 0);
434 } else {
435 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
436 }
437 qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
438 }
439
440 static void
441 print_socket_domain(int domain)
442 {
443 switch (domain) {
444 case PF_UNIX:
445 qemu_log("PF_UNIX");
446 break;
447 case PF_INET:
448 qemu_log("PF_INET");
449 break;
450 case PF_NETLINK:
451 qemu_log("PF_NETLINK");
452 break;
453 case PF_PACKET:
454 qemu_log("PF_PACKET");
455 break;
456 default:
457 qemu_log("%d", domain);
458 break;
459 }
460 }
461
462 static void
463 print_socket_type(int type)
464 {
465 switch (type & TARGET_SOCK_TYPE_MASK) {
466 case TARGET_SOCK_DGRAM:
467 qemu_log("SOCK_DGRAM");
468 break;
469 case TARGET_SOCK_STREAM:
470 qemu_log("SOCK_STREAM");
471 break;
472 case TARGET_SOCK_RAW:
473 qemu_log("SOCK_RAW");
474 break;
475 case TARGET_SOCK_RDM:
476 qemu_log("SOCK_RDM");
477 break;
478 case TARGET_SOCK_SEQPACKET:
479 qemu_log("SOCK_SEQPACKET");
480 break;
481 case TARGET_SOCK_PACKET:
482 qemu_log("SOCK_PACKET");
483 break;
484 }
485 if (type & TARGET_SOCK_CLOEXEC) {
486 qemu_log("|SOCK_CLOEXEC");
487 }
488 if (type & TARGET_SOCK_NONBLOCK) {
489 qemu_log("|SOCK_NONBLOCK");
490 }
491 }
492
493 static void
494 print_socket_protocol(int domain, int type, int protocol)
495 {
496 if (domain == AF_PACKET ||
497 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
498 switch (protocol) {
499 case 0x0003:
500 qemu_log("ETH_P_ALL");
501 break;
502 default:
503 qemu_log("%d", protocol);
504 }
505 return;
506 }
507
508 if (domain == PF_NETLINK) {
509 switch (protocol) {
510 case NETLINK_ROUTE:
511 qemu_log("NETLINK_ROUTE");
512 break;
513 case NETLINK_AUDIT:
514 qemu_log("NETLINK_AUDIT");
515 break;
516 case NETLINK_NETFILTER:
517 qemu_log("NETLINK_NETFILTER");
518 break;
519 case NETLINK_KOBJECT_UEVENT:
520 qemu_log("NETLINK_KOBJECT_UEVENT");
521 break;
522 case NETLINK_RDMA:
523 qemu_log("NETLINK_RDMA");
524 break;
525 case NETLINK_CRYPTO:
526 qemu_log("NETLINK_CRYPTO");
527 break;
528 default:
529 qemu_log("%d", protocol);
530 break;
531 }
532 return;
533 }
534
535 switch (protocol) {
536 case IPPROTO_IP:
537 qemu_log("IPPROTO_IP");
538 break;
539 case IPPROTO_TCP:
540 qemu_log("IPPROTO_TCP");
541 break;
542 case IPPROTO_UDP:
543 qemu_log("IPPROTO_UDP");
544 break;
545 case IPPROTO_RAW:
546 qemu_log("IPPROTO_RAW");
547 break;
548 default:
549 qemu_log("%d", protocol);
550 break;
551 }
552 }
553
554
555 #ifdef TARGET_NR__newselect
556 static void
557 print_fdset(int n, abi_ulong target_fds_addr)
558 {
559 int i;
560 int first = 1;
561
562 qemu_log("[");
563 if( target_fds_addr ) {
564 abi_long *target_fds;
565
566 target_fds = lock_user(VERIFY_READ,
567 target_fds_addr,
568 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
569 1);
570
571 if (!target_fds)
572 return;
573
574 for (i=n; i>=0; i--) {
575 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
576 (i & (TARGET_ABI_BITS - 1))) & 1) {
577 qemu_log("%s%d", get_comma(first), i);
578 first = 0;
579 }
580 }
581 unlock_user(target_fds, target_fds_addr, 0);
582 }
583 qemu_log("]");
584 }
585 #endif
586
587 /*
588 * Sysycall specific output functions
589 */
590
591 /* select */
592 #ifdef TARGET_NR__newselect
593 static void
594 print_newselect(void *cpu_env, const struct syscallname *name,
595 abi_long arg1, abi_long arg2, abi_long arg3,
596 abi_long arg4, abi_long arg5, abi_long arg6)
597 {
598 print_syscall_prologue(name);
599 print_fdset(arg1, arg2);
600 qemu_log(",");
601 print_fdset(arg1, arg3);
602 qemu_log(",");
603 print_fdset(arg1, arg4);
604 qemu_log(",");
605 print_timeval(arg5, 1);
606 print_syscall_epilogue(name);
607 }
608 #endif
609
610 #ifdef TARGET_NR_semctl
611 static void
612 print_semctl(void *cpu_env, const struct syscallname *name,
613 abi_long arg1, abi_long arg2, abi_long arg3,
614 abi_long arg4, abi_long arg5, abi_long arg6)
615 {
616 qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
617 name->name, arg1, arg2);
618 print_ipc_cmd(arg3);
619 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
620 }
621 #endif
622
623 static void
624 print_execve(void *cpu_env, const struct syscallname *name,
625 abi_long arg1, abi_long arg2, abi_long arg3,
626 abi_long arg4, abi_long arg5, abi_long arg6)
627 {
628 abi_ulong arg_ptr_addr;
629 char *s;
630
631 if (!(s = lock_user_string(arg1)))
632 return;
633 qemu_log("%s(\"%s\",{", name->name, s);
634 unlock_user(s, arg1, 0);
635
636 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
637 abi_ulong *arg_ptr, arg_addr;
638
639 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
640 if (!arg_ptr)
641 return;
642 arg_addr = tswapal(*arg_ptr);
643 unlock_user(arg_ptr, arg_ptr_addr, 0);
644 if (!arg_addr)
645 break;
646 if ((s = lock_user_string(arg_addr))) {
647 qemu_log("\"%s\",", s);
648 unlock_user(s, arg_addr, 0);
649 }
650 }
651
652 qemu_log("NULL})");
653 }
654
655 #ifdef TARGET_NR_ipc
656 static void
657 print_ipc(void *cpu_env, const struct syscallname *name,
658 abi_long arg1, abi_long arg2, abi_long arg3,
659 abi_long arg4, abi_long arg5, abi_long arg6)
660 {
661 switch(arg1) {
662 case IPCOP_semctl:
663 qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
664 arg1, arg2);
665 print_ipc_cmd(arg3);
666 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
667 break;
668 default:
669 qemu_log(("%s("
670 TARGET_ABI_FMT_ld ","
671 TARGET_ABI_FMT_ld ","
672 TARGET_ABI_FMT_ld ","
673 TARGET_ABI_FMT_ld
674 ")"),
675 name->name, arg1, arg2, arg3, arg4);
676 }
677 }
678 #endif
679
680 /*
681 * Variants for the return value output function
682 */
683
684 static bool
685 print_syscall_err(abi_long ret)
686 {
687 const char *errstr;
688
689 qemu_log(" = ");
690 if (ret < 0) {
691 errstr = target_strerror(-ret);
692 if (errstr) {
693 qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
694 return true;
695 }
696 }
697 return false;
698 }
699
700 static void
701 print_syscall_ret_addr(void *cpu_env, const struct syscallname *name,
702 abi_long ret, abi_long arg0, abi_long arg1,
703 abi_long arg2, abi_long arg3, abi_long arg4,
704 abi_long arg5)
705 {
706 if (!print_syscall_err(ret)) {
707 qemu_log("0x" TARGET_ABI_FMT_lx, ret);
708 }
709 qemu_log("\n");
710 }
711
712 #if 0 /* currently unused */
713 static void
714 print_syscall_ret_raw(struct syscallname *name, abi_long ret)
715 {
716 qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
717 }
718 #endif
719
720 #ifdef TARGET_NR__newselect
721 static void
722 print_syscall_ret_newselect(void *cpu_env, const struct syscallname *name,
723 abi_long ret, abi_long arg0, abi_long arg1,
724 abi_long arg2, abi_long arg3, abi_long arg4,
725 abi_long arg5)
726 {
727 if (!print_syscall_err(ret)) {
728 qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
729 print_fdset(arg0, arg1);
730 qemu_log(",");
731 print_fdset(arg0, arg2);
732 qemu_log(",");
733 print_fdset(arg0, arg3);
734 qemu_log(",");
735 print_timeval(arg4, 1);
736 qemu_log(")");
737 }
738
739 qemu_log("\n");
740 }
741 #endif
742
743 /* special meanings of adjtimex()' non-negative return values */
744 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
745 #define TARGET_TIME_INS 1 /* insert leap second */
746 #define TARGET_TIME_DEL 2 /* delete leap second */
747 #define TARGET_TIME_OOP 3 /* leap second in progress */
748 #define TARGET_TIME_WAIT 4 /* leap second has occurred */
749 #define TARGET_TIME_ERROR 5 /* clock not synchronized */
750 #ifdef TARGET_NR_adjtimex
751 static void
752 print_syscall_ret_adjtimex(void *cpu_env, const struct syscallname *name,
753 abi_long ret, abi_long arg0, abi_long arg1,
754 abi_long arg2, abi_long arg3, abi_long arg4,
755 abi_long arg5)
756 {
757 if (!print_syscall_err(ret)) {
758 qemu_log(TARGET_ABI_FMT_ld, ret);
759 switch (ret) {
760 case TARGET_TIME_OK:
761 qemu_log(" TIME_OK (clock synchronized, no leap second)");
762 break;
763 case TARGET_TIME_INS:
764 qemu_log(" TIME_INS (insert leap second)");
765 break;
766 case TARGET_TIME_DEL:
767 qemu_log(" TIME_DEL (delete leap second)");
768 break;
769 case TARGET_TIME_OOP:
770 qemu_log(" TIME_OOP (leap second in progress)");
771 break;
772 case TARGET_TIME_WAIT:
773 qemu_log(" TIME_WAIT (leap second has occurred)");
774 break;
775 case TARGET_TIME_ERROR:
776 qemu_log(" TIME_ERROR (clock not synchronized)");
777 break;
778 }
779 }
780
781 qemu_log("\n");
782 }
783 #endif
784
785 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
786 static void
787 print_syscall_ret_clock_gettime(void *cpu_env, const struct syscallname *name,
788 abi_long ret, abi_long arg0, abi_long arg1,
789 abi_long arg2, abi_long arg3, abi_long arg4,
790 abi_long arg5)
791 {
792 if (!print_syscall_err(ret)) {
793 qemu_log(TARGET_ABI_FMT_ld, ret);
794 qemu_log(" (");
795 print_timespec(arg1, 1);
796 qemu_log(")");
797 }
798
799 qemu_log("\n");
800 }
801 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
802 #endif
803
804 #ifdef TARGET_NR_gettimeofday
805 static void
806 print_syscall_ret_gettimeofday(void *cpu_env, const struct syscallname *name,
807 abi_long ret, abi_long arg0, abi_long arg1,
808 abi_long arg2, abi_long arg3, abi_long arg4,
809 abi_long arg5)
810 {
811 if (!print_syscall_err(ret)) {
812 qemu_log(TARGET_ABI_FMT_ld, ret);
813 qemu_log(" (");
814 print_timeval(arg0, 0);
815 print_timezone(arg1, 1);
816 qemu_log(")");
817 }
818
819 qemu_log("\n");
820 }
821 #endif
822
823 #ifdef TARGET_NR_getitimer
824 static void
825 print_syscall_ret_getitimer(void *cpu_env, const struct syscallname *name,
826 abi_long ret, abi_long arg0, abi_long arg1,
827 abi_long arg2, abi_long arg3, abi_long arg4,
828 abi_long arg5)
829 {
830 if (!print_syscall_err(ret)) {
831 qemu_log(TARGET_ABI_FMT_ld, ret);
832 qemu_log(" (");
833 print_itimerval(arg1, 1);
834 qemu_log(")");
835 }
836
837 qemu_log("\n");
838 }
839 #endif
840
841
842 #ifdef TARGET_NR_getitimer
843 static void
844 print_syscall_ret_setitimer(void *cpu_env, const struct syscallname *name,
845 abi_long ret, abi_long arg0, abi_long arg1,
846 abi_long arg2, abi_long arg3, abi_long arg4,
847 abi_long arg5)
848 {
849 if (!print_syscall_err(ret)) {
850 qemu_log(TARGET_ABI_FMT_ld, ret);
851 qemu_log(" (old_value = ");
852 print_itimerval(arg2, 1);
853 qemu_log(")");
854 }
855
856 qemu_log("\n");
857 }
858 #endif
859
860 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
861 || defined(TARGGET_NR_flistxattr)
862 static void
863 print_syscall_ret_listxattr(void *cpu_env, const struct syscallname *name,
864 abi_long ret, abi_long arg0, abi_long arg1,
865 abi_long arg2, abi_long arg3, abi_long arg4,
866 abi_long arg5)
867 {
868 if (!print_syscall_err(ret)) {
869 qemu_log(TARGET_ABI_FMT_ld, ret);
870 qemu_log(" (list = ");
871 if (arg1 != 0) {
872 abi_long attr = arg1;
873 while (ret) {
874 if (attr != arg1) {
875 qemu_log(",");
876 }
877 print_string(attr, 1);
878 ret -= target_strlen(attr) + 1;
879 attr += target_strlen(attr) + 1;
880 }
881 } else {
882 qemu_log("NULL");
883 }
884 qemu_log(")");
885 }
886
887 qemu_log("\n");
888 }
889 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
890 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
891 #endif
892
893 #ifdef TARGET_NR_ioctl
894 static void
895 print_syscall_ret_ioctl(void *cpu_env, const struct syscallname *name,
896 abi_long ret, abi_long arg0, abi_long arg1,
897 abi_long arg2, abi_long arg3, abi_long arg4,
898 abi_long arg5)
899 {
900 if (!print_syscall_err(ret)) {
901 qemu_log(TARGET_ABI_FMT_ld, ret);
902
903 const IOCTLEntry *ie;
904 const argtype *arg_type;
905 void *argptr;
906 int target_size;
907
908 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
909 if (ie->target_cmd == arg1) {
910 break;
911 }
912 }
913
914 if (ie->target_cmd == arg1 &&
915 (ie->access == IOC_R || ie->access == IOC_RW)) {
916 arg_type = ie->arg_type;
917 qemu_log(" (");
918 arg_type++;
919 target_size = thunk_type_size(arg_type, 0);
920 argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
921 if (argptr) {
922 thunk_print(argptr, arg_type);
923 unlock_user(argptr, arg2, target_size);
924 } else {
925 print_pointer(arg2, 1);
926 }
927 qemu_log(")");
928 }
929 }
930 qemu_log("\n");
931 }
932 #endif
933
934 UNUSED static struct flags access_flags[] = {
935 FLAG_GENERIC(F_OK),
936 FLAG_GENERIC(R_OK),
937 FLAG_GENERIC(W_OK),
938 FLAG_GENERIC(X_OK),
939 FLAG_END,
940 };
941
942 UNUSED static struct flags at_file_flags[] = {
943 #ifdef AT_EACCESS
944 FLAG_GENERIC(AT_EACCESS),
945 #endif
946 #ifdef AT_SYMLINK_NOFOLLOW
947 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
948 #endif
949 FLAG_END,
950 };
951
952 UNUSED static struct flags unlinkat_flags[] = {
953 #ifdef AT_REMOVEDIR
954 FLAG_GENERIC(AT_REMOVEDIR),
955 #endif
956 FLAG_END,
957 };
958
959 UNUSED static struct flags mode_flags[] = {
960 FLAG_GENERIC(S_IFSOCK),
961 FLAG_GENERIC(S_IFLNK),
962 FLAG_GENERIC(S_IFREG),
963 FLAG_GENERIC(S_IFBLK),
964 FLAG_GENERIC(S_IFDIR),
965 FLAG_GENERIC(S_IFCHR),
966 FLAG_GENERIC(S_IFIFO),
967 FLAG_END,
968 };
969
970 UNUSED static struct flags open_access_flags[] = {
971 FLAG_TARGET(O_RDONLY),
972 FLAG_TARGET(O_WRONLY),
973 FLAG_TARGET(O_RDWR),
974 FLAG_END,
975 };
976
977 UNUSED static struct flags open_flags[] = {
978 FLAG_TARGET(O_APPEND),
979 FLAG_TARGET(O_CREAT),
980 FLAG_TARGET(O_DIRECTORY),
981 FLAG_TARGET(O_EXCL),
982 FLAG_TARGET(O_LARGEFILE),
983 FLAG_TARGET(O_NOCTTY),
984 FLAG_TARGET(O_NOFOLLOW),
985 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
986 FLAG_TARGET(O_DSYNC),
987 FLAG_TARGET(__O_SYNC),
988 FLAG_TARGET(O_TRUNC),
989 #ifdef O_DIRECT
990 FLAG_TARGET(O_DIRECT),
991 #endif
992 #ifdef O_NOATIME
993 FLAG_TARGET(O_NOATIME),
994 #endif
995 #ifdef O_CLOEXEC
996 FLAG_TARGET(O_CLOEXEC),
997 #endif
998 #ifdef O_PATH
999 FLAG_TARGET(O_PATH),
1000 #endif
1001 #ifdef O_TMPFILE
1002 FLAG_TARGET(O_TMPFILE),
1003 FLAG_TARGET(__O_TMPFILE),
1004 #endif
1005 FLAG_END,
1006 };
1007
1008 UNUSED static struct flags mount_flags[] = {
1009 #ifdef MS_BIND
1010 FLAG_GENERIC(MS_BIND),
1011 #endif
1012 #ifdef MS_DIRSYNC
1013 FLAG_GENERIC(MS_DIRSYNC),
1014 #endif
1015 FLAG_GENERIC(MS_MANDLOCK),
1016 #ifdef MS_MOVE
1017 FLAG_GENERIC(MS_MOVE),
1018 #endif
1019 FLAG_GENERIC(MS_NOATIME),
1020 FLAG_GENERIC(MS_NODEV),
1021 FLAG_GENERIC(MS_NODIRATIME),
1022 FLAG_GENERIC(MS_NOEXEC),
1023 FLAG_GENERIC(MS_NOSUID),
1024 FLAG_GENERIC(MS_RDONLY),
1025 #ifdef MS_RELATIME
1026 FLAG_GENERIC(MS_RELATIME),
1027 #endif
1028 FLAG_GENERIC(MS_REMOUNT),
1029 FLAG_GENERIC(MS_SYNCHRONOUS),
1030 FLAG_END,
1031 };
1032
1033 UNUSED static struct flags umount2_flags[] = {
1034 #ifdef MNT_FORCE
1035 FLAG_GENERIC(MNT_FORCE),
1036 #endif
1037 #ifdef MNT_DETACH
1038 FLAG_GENERIC(MNT_DETACH),
1039 #endif
1040 #ifdef MNT_EXPIRE
1041 FLAG_GENERIC(MNT_EXPIRE),
1042 #endif
1043 FLAG_END,
1044 };
1045
1046 UNUSED static struct flags mmap_prot_flags[] = {
1047 FLAG_GENERIC(PROT_NONE),
1048 FLAG_GENERIC(PROT_EXEC),
1049 FLAG_GENERIC(PROT_READ),
1050 FLAG_GENERIC(PROT_WRITE),
1051 FLAG_TARGET(PROT_SEM),
1052 FLAG_GENERIC(PROT_GROWSDOWN),
1053 FLAG_GENERIC(PROT_GROWSUP),
1054 FLAG_END,
1055 };
1056
1057 UNUSED static struct flags mmap_flags[] = {
1058 FLAG_TARGET(MAP_SHARED),
1059 FLAG_TARGET(MAP_PRIVATE),
1060 FLAG_TARGET(MAP_ANONYMOUS),
1061 FLAG_TARGET(MAP_DENYWRITE),
1062 FLAG_TARGET(MAP_FIXED),
1063 FLAG_TARGET(MAP_GROWSDOWN),
1064 FLAG_TARGET(MAP_EXECUTABLE),
1065 #ifdef MAP_LOCKED
1066 FLAG_TARGET(MAP_LOCKED),
1067 #endif
1068 #ifdef MAP_NONBLOCK
1069 FLAG_TARGET(MAP_NONBLOCK),
1070 #endif
1071 FLAG_TARGET(MAP_NORESERVE),
1072 #ifdef MAP_POPULATE
1073 FLAG_TARGET(MAP_POPULATE),
1074 #endif
1075 #ifdef TARGET_MAP_UNINITIALIZED
1076 FLAG_TARGET(MAP_UNINITIALIZED),
1077 #endif
1078 FLAG_END,
1079 };
1080
1081 UNUSED static struct flags clone_flags[] = {
1082 FLAG_GENERIC(CLONE_VM),
1083 FLAG_GENERIC(CLONE_FS),
1084 FLAG_GENERIC(CLONE_FILES),
1085 FLAG_GENERIC(CLONE_SIGHAND),
1086 FLAG_GENERIC(CLONE_PTRACE),
1087 FLAG_GENERIC(CLONE_VFORK),
1088 FLAG_GENERIC(CLONE_PARENT),
1089 FLAG_GENERIC(CLONE_THREAD),
1090 FLAG_GENERIC(CLONE_NEWNS),
1091 FLAG_GENERIC(CLONE_SYSVSEM),
1092 FLAG_GENERIC(CLONE_SETTLS),
1093 FLAG_GENERIC(CLONE_PARENT_SETTID),
1094 FLAG_GENERIC(CLONE_CHILD_CLEARTID),
1095 FLAG_GENERIC(CLONE_DETACHED),
1096 FLAG_GENERIC(CLONE_UNTRACED),
1097 FLAG_GENERIC(CLONE_CHILD_SETTID),
1098 #if defined(CLONE_NEWUTS)
1099 FLAG_GENERIC(CLONE_NEWUTS),
1100 #endif
1101 #if defined(CLONE_NEWIPC)
1102 FLAG_GENERIC(CLONE_NEWIPC),
1103 #endif
1104 #if defined(CLONE_NEWUSER)
1105 FLAG_GENERIC(CLONE_NEWUSER),
1106 #endif
1107 #if defined(CLONE_NEWPID)
1108 FLAG_GENERIC(CLONE_NEWPID),
1109 #endif
1110 #if defined(CLONE_NEWNET)
1111 FLAG_GENERIC(CLONE_NEWNET),
1112 #endif
1113 #if defined(CLONE_IO)
1114 FLAG_GENERIC(CLONE_IO),
1115 #endif
1116 FLAG_END,
1117 };
1118
1119 UNUSED static struct flags msg_flags[] = {
1120 /* send */
1121 FLAG_GENERIC(MSG_CONFIRM),
1122 FLAG_GENERIC(MSG_DONTROUTE),
1123 FLAG_GENERIC(MSG_DONTWAIT),
1124 FLAG_GENERIC(MSG_EOR),
1125 FLAG_GENERIC(MSG_MORE),
1126 FLAG_GENERIC(MSG_NOSIGNAL),
1127 FLAG_GENERIC(MSG_OOB),
1128 /* recv */
1129 FLAG_GENERIC(MSG_CMSG_CLOEXEC),
1130 FLAG_GENERIC(MSG_ERRQUEUE),
1131 FLAG_GENERIC(MSG_PEEK),
1132 FLAG_GENERIC(MSG_TRUNC),
1133 FLAG_GENERIC(MSG_WAITALL),
1134 /* recvmsg */
1135 FLAG_GENERIC(MSG_CTRUNC),
1136 FLAG_END,
1137 };
1138
1139 UNUSED static struct flags statx_flags[] = {
1140 #ifdef AT_EMPTY_PATH
1141 FLAG_GENERIC(AT_EMPTY_PATH),
1142 #endif
1143 #ifdef AT_NO_AUTOMOUNT
1144 FLAG_GENERIC(AT_NO_AUTOMOUNT),
1145 #endif
1146 #ifdef AT_SYMLINK_NOFOLLOW
1147 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
1148 #endif
1149 #ifdef AT_STATX_SYNC_AS_STAT
1150 FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
1151 #endif
1152 #ifdef AT_STATX_FORCE_SYNC
1153 FLAG_GENERIC(AT_STATX_FORCE_SYNC),
1154 #endif
1155 #ifdef AT_STATX_DONT_SYNC
1156 FLAG_GENERIC(AT_STATX_DONT_SYNC),
1157 #endif
1158 FLAG_END,
1159 };
1160
1161 UNUSED static struct flags statx_mask[] = {
1162 /* This must come first, because it includes everything. */
1163 #ifdef STATX_ALL
1164 FLAG_GENERIC(STATX_ALL),
1165 #endif
1166 /* This must come second; it includes everything except STATX_BTIME. */
1167 #ifdef STATX_BASIC_STATS
1168 FLAG_GENERIC(STATX_BASIC_STATS),
1169 #endif
1170 #ifdef STATX_TYPE
1171 FLAG_GENERIC(STATX_TYPE),
1172 #endif
1173 #ifdef STATX_MODE
1174 FLAG_GENERIC(STATX_MODE),
1175 #endif
1176 #ifdef STATX_NLINK
1177 FLAG_GENERIC(STATX_NLINK),
1178 #endif
1179 #ifdef STATX_UID
1180 FLAG_GENERIC(STATX_UID),
1181 #endif
1182 #ifdef STATX_GID
1183 FLAG_GENERIC(STATX_GID),
1184 #endif
1185 #ifdef STATX_ATIME
1186 FLAG_GENERIC(STATX_ATIME),
1187 #endif
1188 #ifdef STATX_MTIME
1189 FLAG_GENERIC(STATX_MTIME),
1190 #endif
1191 #ifdef STATX_CTIME
1192 FLAG_GENERIC(STATX_CTIME),
1193 #endif
1194 #ifdef STATX_INO
1195 FLAG_GENERIC(STATX_INO),
1196 #endif
1197 #ifdef STATX_SIZE
1198 FLAG_GENERIC(STATX_SIZE),
1199 #endif
1200 #ifdef STATX_BLOCKS
1201 FLAG_GENERIC(STATX_BLOCKS),
1202 #endif
1203 #ifdef STATX_BTIME
1204 FLAG_GENERIC(STATX_BTIME),
1205 #endif
1206 FLAG_END,
1207 };
1208
1209 UNUSED static struct flags falloc_flags[] = {
1210 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
1211 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
1212 #ifdef FALLOC_FL_NO_HIDE_STALE
1213 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
1214 #endif
1215 #ifdef FALLOC_FL_COLLAPSE_RANGE
1216 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
1217 #endif
1218 #ifdef FALLOC_FL_ZERO_RANGE
1219 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
1220 #endif
1221 #ifdef FALLOC_FL_INSERT_RANGE
1222 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
1223 #endif
1224 #ifdef FALLOC_FL_UNSHARE_RANGE
1225 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
1226 #endif
1227 };
1228
1229 UNUSED static struct flags termios_iflags[] = {
1230 FLAG_TARGET(IGNBRK),
1231 FLAG_TARGET(BRKINT),
1232 FLAG_TARGET(IGNPAR),
1233 FLAG_TARGET(PARMRK),
1234 FLAG_TARGET(INPCK),
1235 FLAG_TARGET(ISTRIP),
1236 FLAG_TARGET(INLCR),
1237 FLAG_TARGET(IGNCR),
1238 FLAG_TARGET(ICRNL),
1239 FLAG_TARGET(IUCLC),
1240 FLAG_TARGET(IXON),
1241 FLAG_TARGET(IXANY),
1242 FLAG_TARGET(IXOFF),
1243 FLAG_TARGET(IMAXBEL),
1244 FLAG_TARGET(IUTF8),
1245 FLAG_END,
1246 };
1247
1248 UNUSED static struct flags termios_oflags[] = {
1249 FLAG_TARGET(OPOST),
1250 FLAG_TARGET(OLCUC),
1251 FLAG_TARGET(ONLCR),
1252 FLAG_TARGET(OCRNL),
1253 FLAG_TARGET(ONOCR),
1254 FLAG_TARGET(ONLRET),
1255 FLAG_TARGET(OFILL),
1256 FLAG_TARGET(OFDEL),
1257 FLAG_END,
1258 };
1259
1260 UNUSED static struct enums termios_oflags_NLDLY[] = {
1261 ENUM_TARGET(NL0),
1262 ENUM_TARGET(NL1),
1263 ENUM_END,
1264 };
1265
1266 UNUSED static struct enums termios_oflags_CRDLY[] = {
1267 ENUM_TARGET(CR0),
1268 ENUM_TARGET(CR1),
1269 ENUM_TARGET(CR2),
1270 ENUM_TARGET(CR3),
1271 ENUM_END,
1272 };
1273
1274 UNUSED static struct enums termios_oflags_TABDLY[] = {
1275 ENUM_TARGET(TAB0),
1276 ENUM_TARGET(TAB1),
1277 ENUM_TARGET(TAB2),
1278 ENUM_TARGET(TAB3),
1279 ENUM_END,
1280 };
1281
1282 UNUSED static struct enums termios_oflags_VTDLY[] = {
1283 ENUM_TARGET(VT0),
1284 ENUM_TARGET(VT1),
1285 ENUM_END,
1286 };
1287
1288 UNUSED static struct enums termios_oflags_FFDLY[] = {
1289 ENUM_TARGET(FF0),
1290 ENUM_TARGET(FF1),
1291 ENUM_END,
1292 };
1293
1294 UNUSED static struct enums termios_oflags_BSDLY[] = {
1295 ENUM_TARGET(BS0),
1296 ENUM_TARGET(BS1),
1297 ENUM_END,
1298 };
1299
1300 UNUSED static struct enums termios_cflags_CBAUD[] = {
1301 ENUM_TARGET(B0),
1302 ENUM_TARGET(B50),
1303 ENUM_TARGET(B75),
1304 ENUM_TARGET(B110),
1305 ENUM_TARGET(B134),
1306 ENUM_TARGET(B150),
1307 ENUM_TARGET(B200),
1308 ENUM_TARGET(B300),
1309 ENUM_TARGET(B600),
1310 ENUM_TARGET(B1200),
1311 ENUM_TARGET(B1800),
1312 ENUM_TARGET(B2400),
1313 ENUM_TARGET(B4800),
1314 ENUM_TARGET(B9600),
1315 ENUM_TARGET(B19200),
1316 ENUM_TARGET(B38400),
1317 ENUM_TARGET(B57600),
1318 ENUM_TARGET(B115200),
1319 ENUM_TARGET(B230400),
1320 ENUM_TARGET(B460800),
1321 ENUM_END,
1322 };
1323
1324 UNUSED static struct enums termios_cflags_CSIZE[] = {
1325 ENUM_TARGET(CS5),
1326 ENUM_TARGET(CS6),
1327 ENUM_TARGET(CS7),
1328 ENUM_TARGET(CS8),
1329 ENUM_END,
1330 };
1331
1332 UNUSED static struct flags termios_cflags[] = {
1333 FLAG_TARGET(CSTOPB),
1334 FLAG_TARGET(CREAD),
1335 FLAG_TARGET(PARENB),
1336 FLAG_TARGET(PARODD),
1337 FLAG_TARGET(HUPCL),
1338 FLAG_TARGET(CLOCAL),
1339 FLAG_TARGET(CRTSCTS),
1340 FLAG_END,
1341 };
1342
1343 UNUSED static struct flags termios_lflags[] = {
1344 FLAG_TARGET(ISIG),
1345 FLAG_TARGET(ICANON),
1346 FLAG_TARGET(XCASE),
1347 FLAG_TARGET(ECHO),
1348 FLAG_TARGET(ECHOE),
1349 FLAG_TARGET(ECHOK),
1350 FLAG_TARGET(ECHONL),
1351 FLAG_TARGET(NOFLSH),
1352 FLAG_TARGET(TOSTOP),
1353 FLAG_TARGET(ECHOCTL),
1354 FLAG_TARGET(ECHOPRT),
1355 FLAG_TARGET(ECHOKE),
1356 FLAG_TARGET(FLUSHO),
1357 FLAG_TARGET(PENDIN),
1358 FLAG_TARGET(IEXTEN),
1359 FLAG_TARGET(EXTPROC),
1360 FLAG_END,
1361 };
1362
1363 UNUSED static struct flags mlockall_flags[] = {
1364 FLAG_TARGET(MCL_CURRENT),
1365 FLAG_TARGET(MCL_FUTURE),
1366 #ifdef MCL_ONFAULT
1367 FLAG_TARGET(MCL_ONFAULT),
1368 #endif
1369 FLAG_END,
1370 };
1371
1372 /* IDs of the various system clocks */
1373 #define TARGET_CLOCK_REALTIME 0
1374 #define TARGET_CLOCK_MONOTONIC 1
1375 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
1376 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
1377 #define TARGET_CLOCK_MONOTONIC_RAW 4
1378 #define TARGET_CLOCK_REALTIME_COARSE 5
1379 #define TARGET_CLOCK_MONOTONIC_COARSE 6
1380 #define TARGET_CLOCK_BOOTTIME 7
1381 #define TARGET_CLOCK_REALTIME_ALARM 8
1382 #define TARGET_CLOCK_BOOTTIME_ALARM 9
1383 #define TARGET_CLOCK_SGI_CYCLE 10
1384 #define TARGET_CLOCK_TAI 11
1385
1386 UNUSED static struct enums clockids[] = {
1387 ENUM_TARGET(CLOCK_REALTIME),
1388 ENUM_TARGET(CLOCK_MONOTONIC),
1389 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
1390 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
1391 ENUM_TARGET(CLOCK_MONOTONIC_RAW),
1392 ENUM_TARGET(CLOCK_REALTIME_COARSE),
1393 ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
1394 ENUM_TARGET(CLOCK_BOOTTIME),
1395 ENUM_TARGET(CLOCK_REALTIME_ALARM),
1396 ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
1397 ENUM_TARGET(CLOCK_SGI_CYCLE),
1398 ENUM_TARGET(CLOCK_TAI),
1399 ENUM_END,
1400 };
1401
1402 UNUSED static struct enums itimer_types[] = {
1403 ENUM_GENERIC(ITIMER_REAL),
1404 ENUM_GENERIC(ITIMER_VIRTUAL),
1405 ENUM_GENERIC(ITIMER_PROF),
1406 ENUM_END,
1407 };
1408
1409 /*
1410 * print_xxx utility functions. These are used to print syscall
1411 * parameters in certain format. All of these have parameter
1412 * named 'last'. This parameter is used to add comma to output
1413 * when last == 0.
1414 */
1415
1416 static const char *
1417 get_comma(int last)
1418 {
1419 return ((last) ? "" : ",");
1420 }
1421
1422 static void
1423 print_flags(const struct flags *f, abi_long flags, int last)
1424 {
1425 const char *sep = "";
1426 int n;
1427
1428 if ((flags == 0) && (f->f_value == 0)) {
1429 qemu_log("%s%s", f->f_string, get_comma(last));
1430 return;
1431 }
1432 for (n = 0; f->f_string != NULL; f++) {
1433 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
1434 qemu_log("%s%s", sep, f->f_string);
1435 flags &= ~f->f_value;
1436 sep = "|";
1437 n++;
1438 }
1439 }
1440
1441 if (n > 0) {
1442 /* print rest of the flags as numeric */
1443 if (flags != 0) {
1444 qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
1445 } else {
1446 qemu_log("%s", get_comma(last));
1447 }
1448 } else {
1449 /* no string version of flags found, print them in hex then */
1450 qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
1451 }
1452 }
1453
1454 static void
1455 print_enums(const struct enums *e, abi_long enum_arg, int last)
1456 {
1457 for (; e->e_string != NULL; e++) {
1458 if (e->e_value == enum_arg) {
1459 qemu_log("%s", e->e_string);
1460 break;
1461 }
1462 }
1463
1464 if (e->e_string == NULL) {
1465 qemu_log("%#x", (unsigned int)enum_arg);
1466 }
1467
1468 qemu_log("%s", get_comma(last));
1469 }
1470
1471 static void
1472 print_at_dirfd(abi_long dirfd, int last)
1473 {
1474 #ifdef AT_FDCWD
1475 if (dirfd == AT_FDCWD) {
1476 qemu_log("AT_FDCWD%s", get_comma(last));
1477 return;
1478 }
1479 #endif
1480 qemu_log("%d%s", (int)dirfd, get_comma(last));
1481 }
1482
1483 static void
1484 print_file_mode(abi_long mode, int last)
1485 {
1486 const char *sep = "";
1487 const struct flags *m;
1488
1489 for (m = &mode_flags[0]; m->f_string != NULL; m++) {
1490 if ((m->f_value & mode) == m->f_value) {
1491 qemu_log("%s%s", m->f_string, sep);
1492 sep = "|";
1493 mode &= ~m->f_value;
1494 break;
1495 }
1496 }
1497
1498 mode &= ~S_IFMT;
1499 /* print rest of the mode as octal */
1500 if (mode != 0)
1501 qemu_log("%s%#o", sep, (unsigned int)mode);
1502
1503 qemu_log("%s", get_comma(last));
1504 }
1505
1506 static void
1507 print_open_flags(abi_long flags, int last)
1508 {
1509 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
1510 flags &= ~TARGET_O_ACCMODE;
1511 if (flags == 0) {
1512 qemu_log("%s", get_comma(last));
1513 return;
1514 }
1515 qemu_log("|");
1516 print_flags(open_flags, flags, last);
1517 }
1518
1519 static void
1520 print_syscall_prologue(const struct syscallname *sc)
1521 {
1522 qemu_log("%s(", sc->name);
1523 }
1524
1525 /*ARGSUSED*/
1526 static void
1527 print_syscall_epilogue(const struct syscallname *sc)
1528 {
1529 (void)sc;
1530 qemu_log(")");
1531 }
1532
1533 static void
1534 print_string(abi_long addr, int last)
1535 {
1536 char *s;
1537
1538 if ((s = lock_user_string(addr)) != NULL) {
1539 qemu_log("\"%s\"%s", s, get_comma(last));
1540 unlock_user(s, addr, 0);
1541 } else {
1542 /* can't get string out of it, so print it as pointer */
1543 print_pointer(addr, last);
1544 }
1545 }
1546
1547 #define MAX_PRINT_BUF 40
1548 static void
1549 print_buf(abi_long addr, abi_long len, int last)
1550 {
1551 uint8_t *s;
1552 int i;
1553
1554 s = lock_user(VERIFY_READ, addr, len, 1);
1555 if (s) {
1556 qemu_log("\"");
1557 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
1558 if (isprint(s[i])) {
1559 qemu_log("%c", s[i]);
1560 } else {
1561 qemu_log("\\%o", s[i]);
1562 }
1563 }
1564 qemu_log("\"");
1565 if (i != len) {
1566 qemu_log("...");
1567 }
1568 if (!last) {
1569 qemu_log(",");
1570 }
1571 unlock_user(s, addr, 0);
1572 } else {
1573 print_pointer(addr, last);
1574 }
1575 }
1576
1577 /*
1578 * Prints out raw parameter using given format. Caller needs
1579 * to do byte swapping if needed.
1580 */
1581 static void
1582 print_raw_param(const char *fmt, abi_long param, int last)
1583 {
1584 char format[64];
1585
1586 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
1587 qemu_log(format, param);
1588 }
1589
1590 static void
1591 print_pointer(abi_long p, int last)
1592 {
1593 if (p == 0)
1594 qemu_log("NULL%s", get_comma(last));
1595 else
1596 qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
1597 }
1598
1599 /*
1600 * Reads 32-bit (int) number from guest address space from
1601 * address 'addr' and prints it.
1602 */
1603 static void
1604 print_number(abi_long addr, int last)
1605 {
1606 if (addr == 0) {
1607 qemu_log("NULL%s", get_comma(last));
1608 } else {
1609 int num;
1610
1611 get_user_s32(num, addr);
1612 qemu_log("[%d]%s", num, get_comma(last));
1613 }
1614 }
1615
1616 static void
1617 print_timeval(abi_ulong tv_addr, int last)
1618 {
1619 if( tv_addr ) {
1620 struct target_timeval *tv;
1621
1622 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
1623 if (!tv) {
1624 print_pointer(tv_addr, last);
1625 return;
1626 }
1627 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1628 ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
1629 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
1630 unlock_user(tv, tv_addr, 0);
1631 } else
1632 qemu_log("NULL%s", get_comma(last));
1633 }
1634
1635 static void
1636 print_timespec(abi_ulong ts_addr, int last)
1637 {
1638 if (ts_addr) {
1639 struct target_timespec *ts;
1640
1641 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
1642 if (!ts) {
1643 print_pointer(ts_addr, last);
1644 return;
1645 }
1646 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
1647 ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
1648 tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
1649 unlock_user(ts, ts_addr, 0);
1650 } else {
1651 qemu_log("NULL%s", get_comma(last));
1652 }
1653 }
1654
1655 static void
1656 print_timezone(abi_ulong tz_addr, int last)
1657 {
1658 if (tz_addr) {
1659 struct target_timezone *tz;
1660
1661 tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
1662 if (!tz) {
1663 print_pointer(tz_addr, last);
1664 return;
1665 }
1666 qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
1667 tswap32(tz->tz_dsttime), get_comma(last));
1668 unlock_user(tz, tz_addr, 0);
1669 } else {
1670 qemu_log("NULL%s", get_comma(last));
1671 }
1672 }
1673
1674 static void
1675 print_itimerval(abi_ulong it_addr, int last)
1676 {
1677 if (it_addr) {
1678 qemu_log("{it_interval=");
1679 print_timeval(it_addr +
1680 offsetof(struct target_itimerval, it_interval), 0);
1681 qemu_log("it_value=");
1682 print_timeval(it_addr +
1683 offsetof(struct target_itimerval, it_value), 0);
1684 qemu_log("}%s", get_comma(last));
1685 } else {
1686 qemu_log("NULL%s", get_comma(last));
1687 }
1688 }
1689
1690 void
1691 print_termios(void *arg)
1692 {
1693 const struct target_termios *target = arg;
1694
1695 target_tcflag_t iflags = tswap32(target->c_iflag);
1696 target_tcflag_t oflags = tswap32(target->c_oflag);
1697 target_tcflag_t cflags = tswap32(target->c_cflag);
1698 target_tcflag_t lflags = tswap32(target->c_lflag);
1699
1700 qemu_log("{");
1701
1702 qemu_log("c_iflag = ");
1703 print_flags(termios_iflags, iflags, 0);
1704
1705 qemu_log("c_oflag = ");
1706 target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
1707 TARGET_TABDLY | TARGET_BSDLY |
1708 TARGET_VTDLY | TARGET_FFDLY);
1709 print_flags(termios_oflags, oflags_clean, 0);
1710 if (oflags & TARGET_NLDLY) {
1711 print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
1712 }
1713 if (oflags & TARGET_CRDLY) {
1714 print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
1715 }
1716 if (oflags & TARGET_TABDLY) {
1717 print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
1718 }
1719 if (oflags & TARGET_BSDLY) {
1720 print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
1721 }
1722 if (oflags & TARGET_VTDLY) {
1723 print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
1724 }
1725 if (oflags & TARGET_FFDLY) {
1726 print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
1727 }
1728
1729 qemu_log("c_cflag = ");
1730 if (cflags & TARGET_CBAUD) {
1731 print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
1732 }
1733 if (cflags & TARGET_CSIZE) {
1734 print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
1735 }
1736 target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
1737 print_flags(termios_cflags, cflags_clean, 0);
1738
1739 qemu_log("c_lflag = ");
1740 print_flags(termios_lflags, lflags, 0);
1741
1742 qemu_log("c_cc = ");
1743 qemu_log("\"%s\",", target->c_cc);
1744
1745 qemu_log("c_line = ");
1746 print_raw_param("\'%c\'", target->c_line, 1);
1747
1748 qemu_log("}");
1749 }
1750
1751 #undef UNUSED
1752
1753 #ifdef TARGET_NR_accept
1754 static void
1755 print_accept(void *cpu_env, const struct syscallname *name,
1756 abi_long arg0, abi_long arg1, abi_long arg2,
1757 abi_long arg3, abi_long arg4, abi_long arg5)
1758 {
1759 print_syscall_prologue(name);
1760 print_raw_param("%d", arg0, 0);
1761 print_pointer(arg1, 0);
1762 print_number(arg2, 1);
1763 print_syscall_epilogue(name);
1764 }
1765 #endif
1766
1767 #ifdef TARGET_NR_access
1768 static void
1769 print_access(void *cpu_env, const struct syscallname *name,
1770 abi_long arg0, abi_long arg1, abi_long arg2,
1771 abi_long arg3, abi_long arg4, abi_long arg5)
1772 {
1773 print_syscall_prologue(name);
1774 print_string(arg0, 0);
1775 print_flags(access_flags, arg1, 1);
1776 print_syscall_epilogue(name);
1777 }
1778 #endif
1779
1780 #ifdef TARGET_NR_acct
1781 static void
1782 print_acct(void *cpu_env, const struct syscallname *name,
1783 abi_long arg0, abi_long arg1, abi_long arg2,
1784 abi_long arg3, abi_long arg4, abi_long arg5)
1785 {
1786 print_syscall_prologue(name);
1787 print_string(arg0, 1);
1788 print_syscall_epilogue(name);
1789 }
1790 #endif
1791
1792 #ifdef TARGET_NR_brk
1793 static void
1794 print_brk(void *cpu_env, const struct syscallname *name,
1795 abi_long arg0, abi_long arg1, abi_long arg2,
1796 abi_long arg3, abi_long arg4, abi_long arg5)
1797 {
1798 print_syscall_prologue(name);
1799 print_pointer(arg0, 1);
1800 print_syscall_epilogue(name);
1801 }
1802 #endif
1803
1804 #ifdef TARGET_NR_chdir
1805 static void
1806 print_chdir(void *cpu_env, const struct syscallname *name,
1807 abi_long arg0, abi_long arg1, abi_long arg2,
1808 abi_long arg3, abi_long arg4, abi_long arg5)
1809 {
1810 print_syscall_prologue(name);
1811 print_string(arg0, 1);
1812 print_syscall_epilogue(name);
1813 }
1814 #endif
1815
1816 #ifdef TARGET_NR_chroot
1817 static void
1818 print_chroot(void *cpu_env, const struct syscallname *name,
1819 abi_long arg0, abi_long arg1, abi_long arg2,
1820 abi_long arg3, abi_long arg4, abi_long arg5)
1821 {
1822 print_syscall_prologue(name);
1823 print_string(arg0, 1);
1824 print_syscall_epilogue(name);
1825 }
1826 #endif
1827
1828 #ifdef TARGET_NR_chmod
1829 static void
1830 print_chmod(void *cpu_env, const struct syscallname *name,
1831 abi_long arg0, abi_long arg1, abi_long arg2,
1832 abi_long arg3, abi_long arg4, abi_long arg5)
1833 {
1834 print_syscall_prologue(name);
1835 print_string(arg0, 0);
1836 print_file_mode(arg1, 1);
1837 print_syscall_epilogue(name);
1838 }
1839 #endif
1840
1841 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
1842 static void
1843 print_chown(void *cpu_env, const struct syscallname *name,
1844 abi_long arg0, abi_long arg1, abi_long arg2,
1845 abi_long arg3, abi_long arg4, abi_long arg5)
1846 {
1847 print_syscall_prologue(name);
1848 print_string(arg0, 0);
1849 print_raw_param("%d", arg1, 0);
1850 print_raw_param("%d", arg2, 1);
1851 print_syscall_epilogue(name);
1852 }
1853 #define print_lchown print_chown
1854 #endif
1855
1856 #ifdef TARGET_NR_clock_adjtime
1857 static void
1858 print_clock_adjtime(void *cpu_env, const struct syscallname *name,
1859 abi_long arg0, abi_long arg1, abi_long arg2,
1860 abi_long arg3, abi_long arg4, abi_long arg5)
1861 {
1862 print_syscall_prologue(name);
1863 print_enums(clockids, arg0, 0);
1864 print_pointer(arg1, 1);
1865 print_syscall_epilogue(name);
1866 }
1867 #endif
1868
1869 #ifdef TARGET_NR_clone
1870 static void do_print_clone(unsigned int flags, abi_ulong newsp,
1871 abi_ulong parent_tidptr, target_ulong newtls,
1872 abi_ulong child_tidptr)
1873 {
1874 print_flags(clone_flags, flags, 0);
1875 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
1876 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
1877 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
1878 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
1879 }
1880
1881 static void
1882 print_clone(void *cpu_env, const struct syscallname *name,
1883 abi_long arg1, abi_long arg2, abi_long arg3,
1884 abi_long arg4, abi_long arg5, abi_long arg6)
1885 {
1886 print_syscall_prologue(name);
1887 #if defined(TARGET_MICROBLAZE)
1888 do_print_clone(arg1, arg2, arg4, arg6, arg5);
1889 #elif defined(TARGET_CLONE_BACKWARDS)
1890 do_print_clone(arg1, arg2, arg3, arg4, arg5);
1891 #elif defined(TARGET_CLONE_BACKWARDS2)
1892 do_print_clone(arg2, arg1, arg3, arg5, arg4);
1893 #else
1894 do_print_clone(arg1, arg2, arg3, arg5, arg4);
1895 #endif
1896 print_syscall_epilogue(name);
1897 }
1898 #endif
1899
1900 #ifdef TARGET_NR_creat
1901 static void
1902 print_creat(void *cpu_env, const struct syscallname *name,
1903 abi_long arg0, abi_long arg1, abi_long arg2,
1904 abi_long arg3, abi_long arg4, abi_long arg5)
1905 {
1906 print_syscall_prologue(name);
1907 print_string(arg0, 0);
1908 print_file_mode(arg1, 1);
1909 print_syscall_epilogue(name);
1910 }
1911 #endif
1912
1913 #ifdef TARGET_NR_execv
1914 static void
1915 print_execv(void *cpu_env, const struct syscallname *name,
1916 abi_long arg0, abi_long arg1, abi_long arg2,
1917 abi_long arg3, abi_long arg4, abi_long arg5)
1918 {
1919 print_syscall_prologue(name);
1920 print_string(arg0, 0);
1921 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
1922 print_syscall_epilogue(name);
1923 }
1924 #endif
1925
1926 #ifdef TARGET_NR_faccessat
1927 static void
1928 print_faccessat(void *cpu_env, const struct syscallname *name,
1929 abi_long arg0, abi_long arg1, abi_long arg2,
1930 abi_long arg3, abi_long arg4, abi_long arg5)
1931 {
1932 print_syscall_prologue(name);
1933 print_at_dirfd(arg0, 0);
1934 print_string(arg1, 0);
1935 print_flags(access_flags, arg2, 0);
1936 print_flags(at_file_flags, arg3, 1);
1937 print_syscall_epilogue(name);
1938 }
1939 #endif
1940
1941 #ifdef TARGET_NR_fallocate
1942 static void
1943 print_fallocate(void *cpu_env, const struct syscallname *name,
1944 abi_long arg0, abi_long arg1, abi_long arg2,
1945 abi_long arg3, abi_long arg4, abi_long arg5)
1946 {
1947 print_syscall_prologue(name);
1948 print_raw_param("%d", arg0, 0);
1949 print_flags(falloc_flags, arg1, 0);
1950 #if TARGET_ABI_BITS == 32
1951 print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
1952 print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
1953 #else
1954 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
1955 print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
1956 #endif
1957 print_syscall_epilogue(name);
1958 }
1959 #endif
1960
1961 #ifdef TARGET_NR_fchmodat
1962 static void
1963 print_fchmodat(void *cpu_env, const struct syscallname *name,
1964 abi_long arg0, abi_long arg1, abi_long arg2,
1965 abi_long arg3, abi_long arg4, abi_long arg5)
1966 {
1967 print_syscall_prologue(name);
1968 print_at_dirfd(arg0, 0);
1969 print_string(arg1, 0);
1970 print_file_mode(arg2, 0);
1971 print_flags(at_file_flags, arg3, 1);
1972 print_syscall_epilogue(name);
1973 }
1974 #endif
1975
1976 #ifdef TARGET_NR_fchownat
1977 static void
1978 print_fchownat(void *cpu_env, const struct syscallname *name,
1979 abi_long arg0, abi_long arg1, abi_long arg2,
1980 abi_long arg3, abi_long arg4, abi_long arg5)
1981 {
1982 print_syscall_prologue(name);
1983 print_at_dirfd(arg0, 0);
1984 print_string(arg1, 0);
1985 print_raw_param("%d", arg2, 0);
1986 print_raw_param("%d", arg3, 0);
1987 print_flags(at_file_flags, arg4, 1);
1988 print_syscall_epilogue(name);
1989 }
1990 #endif
1991
1992 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
1993 static void
1994 print_fcntl(void *cpu_env, const struct syscallname *name,
1995 abi_long arg0, abi_long arg1, abi_long arg2,
1996 abi_long arg3, abi_long arg4, abi_long arg5)
1997 {
1998 print_syscall_prologue(name);
1999 print_raw_param("%d", arg0, 0);
2000 switch(arg1) {
2001 case TARGET_F_DUPFD:
2002 qemu_log("F_DUPFD,");
2003 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2004 break;
2005 case TARGET_F_GETFD:
2006 qemu_log("F_GETFD");
2007 break;
2008 case TARGET_F_SETFD:
2009 qemu_log("F_SETFD,");
2010 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2011 break;
2012 case TARGET_F_GETFL:
2013 qemu_log("F_GETFL");
2014 break;
2015 case TARGET_F_SETFL:
2016 qemu_log("F_SETFL,");
2017 print_open_flags(arg2, 1);
2018 break;
2019 case TARGET_F_GETLK:
2020 qemu_log("F_GETLK,");
2021 print_pointer(arg2, 1);
2022 break;
2023 case TARGET_F_SETLK:
2024 qemu_log("F_SETLK,");
2025 print_pointer(arg2, 1);
2026 break;
2027 case TARGET_F_SETLKW:
2028 qemu_log("F_SETLKW,");
2029 print_pointer(arg2, 1);
2030 break;
2031 case TARGET_F_GETOWN:
2032 qemu_log("F_GETOWN");
2033 break;
2034 case TARGET_F_SETOWN:
2035 qemu_log("F_SETOWN,");
2036 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2037 break;
2038 case TARGET_F_GETSIG:
2039 qemu_log("F_GETSIG");
2040 break;
2041 case TARGET_F_SETSIG:
2042 qemu_log("F_SETSIG,");
2043 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2044 break;
2045 #if TARGET_ABI_BITS == 32
2046 case TARGET_F_GETLK64:
2047 qemu_log("F_GETLK64,");
2048 print_pointer(arg2, 1);
2049 break;
2050 case TARGET_F_SETLK64:
2051 qemu_log("F_SETLK64,");
2052 print_pointer(arg2, 1);
2053 break;
2054 case TARGET_F_SETLKW64:
2055 qemu_log("F_SETLKW64,");
2056 print_pointer(arg2, 1);
2057 break;
2058 #endif
2059 case TARGET_F_SETLEASE:
2060 qemu_log("F_SETLEASE,");
2061 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2062 break;
2063 case TARGET_F_GETLEASE:
2064 qemu_log("F_GETLEASE");
2065 break;
2066 case TARGET_F_SETPIPE_SZ:
2067 qemu_log("F_SETPIPE_SZ,");
2068 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2069 break;
2070 case TARGET_F_GETPIPE_SZ:
2071 qemu_log("F_GETPIPE_SZ");
2072 break;
2073 case TARGET_F_DUPFD_CLOEXEC:
2074 qemu_log("F_DUPFD_CLOEXEC,");
2075 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
2076 break;
2077 case TARGET_F_NOTIFY:
2078 qemu_log("F_NOTIFY,");
2079 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2080 break;
2081 default:
2082 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2083 print_pointer(arg2, 1);
2084 break;
2085 }
2086 print_syscall_epilogue(name);
2087 }
2088 #define print_fcntl64 print_fcntl
2089 #endif
2090
2091 #ifdef TARGET_NR_fgetxattr
2092 static void
2093 print_fgetxattr(void *cpu_env, const struct syscallname *name,
2094 abi_long arg0, abi_long arg1, abi_long arg2,
2095 abi_long arg3, abi_long arg4, abi_long arg5)
2096 {
2097 print_syscall_prologue(name);
2098 print_raw_param("%d", arg0, 0);
2099 print_string(arg1, 0);
2100 print_pointer(arg2, 0);
2101 print_raw_param(TARGET_FMT_lu, arg3, 1);
2102 print_syscall_epilogue(name);
2103 }
2104 #endif
2105
2106 #ifdef TARGET_NR_flistxattr
2107 static void
2108 print_flistxattr(void *cpu_env, const struct syscallname *name,
2109 abi_long arg0, abi_long arg1, abi_long arg2,
2110 abi_long arg3, abi_long arg4, abi_long arg5)
2111 {
2112 print_syscall_prologue(name);
2113 print_raw_param("%d", arg0, 0);
2114 print_pointer(arg1, 0);
2115 print_raw_param(TARGET_FMT_lu, arg2, 1);
2116 print_syscall_epilogue(name);
2117 }
2118 #endif
2119
2120 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
2121 static void
2122 print_getxattr(void *cpu_env, const struct syscallname *name,
2123 abi_long arg0, abi_long arg1, abi_long arg2,
2124 abi_long arg3, abi_long arg4, abi_long arg5)
2125 {
2126 print_syscall_prologue(name);
2127 print_string(arg0, 0);
2128 print_string(arg1, 0);
2129 print_pointer(arg2, 0);
2130 print_raw_param(TARGET_FMT_lu, arg3, 1);
2131 print_syscall_epilogue(name);
2132 }
2133 #define print_lgetxattr print_getxattr
2134 #endif
2135
2136 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
2137 static void
2138 print_listxattr(void *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)
2141 {
2142 print_syscall_prologue(name);
2143 print_string(arg0, 0);
2144 print_pointer(arg1, 0);
2145 print_raw_param(TARGET_FMT_lu, arg2, 1);
2146 print_syscall_epilogue(name);
2147 }
2148 #define print_llistxattr print_listxattr
2149 #endif
2150
2151 #if defined(TARGET_NR_fremovexattr)
2152 static void
2153 print_fremovexattr(void *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)
2156 {
2157 print_syscall_prologue(name);
2158 print_raw_param("%d", arg0, 0);
2159 print_string(arg1, 1);
2160 print_syscall_epilogue(name);
2161 }
2162 #endif
2163
2164 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
2165 static void
2166 print_removexattr(void *cpu_env, const struct syscallname *name,
2167 abi_long arg0, abi_long arg1, abi_long arg2,
2168 abi_long arg3, abi_long arg4, abi_long arg5)
2169 {
2170 print_syscall_prologue(name);
2171 print_string(arg0, 0);
2172 print_string(arg1, 1);
2173 print_syscall_epilogue(name);
2174 }
2175 #define print_lremovexattr print_removexattr
2176 #endif
2177
2178 #ifdef TARGET_NR_futimesat
2179 static void
2180 print_futimesat(void *cpu_env, const struct syscallname *name,
2181 abi_long arg0, abi_long arg1, abi_long arg2,
2182 abi_long arg3, abi_long arg4, abi_long arg5)
2183 {
2184 print_syscall_prologue(name);
2185 print_at_dirfd(arg0, 0);
2186 print_string(arg1, 0);
2187 print_timeval(arg2, 0);
2188 print_timeval(arg2 + sizeof (struct target_timeval), 1);
2189 print_syscall_epilogue(name);
2190 }
2191 #endif
2192
2193 #ifdef TARGET_NR_gettimeofday
2194 static void
2195 print_gettimeofday(void *cpu_env, const struct syscallname *name,
2196 abi_long arg0, abi_long arg1, abi_long arg2,
2197 abi_long arg3, abi_long arg4, abi_long arg5)
2198 {
2199 print_syscall_prologue(name);
2200 print_pointer(arg0, 0);
2201 print_pointer(arg1, 1);
2202 print_syscall_epilogue(name);
2203 }
2204 #endif
2205
2206 #ifdef TARGET_NR_settimeofday
2207 static void
2208 print_settimeofday(void *cpu_env, const struct syscallname *name,
2209 abi_long arg0, abi_long arg1, abi_long arg2,
2210 abi_long arg3, abi_long arg4, abi_long arg5)
2211 {
2212 print_syscall_prologue(name);
2213 print_timeval(arg0, 0);
2214 print_timezone(arg1, 1);
2215 print_syscall_epilogue(name);
2216 }
2217 #endif
2218
2219 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
2220 static void
2221 print_clock_gettime(void *cpu_env, const struct syscallname *name,
2222 abi_long arg0, abi_long arg1, abi_long arg2,
2223 abi_long arg3, abi_long arg4, abi_long arg5)
2224 {
2225 print_syscall_prologue(name);
2226 print_enums(clockids, arg0, 0);
2227 print_pointer(arg1, 1);
2228 print_syscall_epilogue(name);
2229 }
2230 #define print_clock_getres print_clock_gettime
2231 #endif
2232
2233 #ifdef TARGET_NR_clock_settime
2234 static void
2235 print_clock_settime(void *cpu_env, const struct syscallname *name,
2236 abi_long arg0, abi_long arg1, abi_long arg2,
2237 abi_long arg3, abi_long arg4, abi_long arg5)
2238 {
2239 print_syscall_prologue(name);
2240 print_enums(clockids, arg0, 0);
2241 print_timespec(arg1, 1);
2242 print_syscall_epilogue(name);
2243 }
2244 #endif
2245
2246 #ifdef TARGET_NR_getitimer
2247 static void
2248 print_getitimer(void *cpu_env, const struct syscallname *name,
2249 abi_long arg0, abi_long arg1, abi_long arg2,
2250 abi_long arg3, abi_long arg4, abi_long arg5)
2251 {
2252 print_syscall_prologue(name);
2253 print_enums(itimer_types, arg0, 0);
2254 print_pointer(arg1, 1);
2255 print_syscall_epilogue(name);
2256 }
2257 #endif
2258
2259 #ifdef TARGET_NR_setitimer
2260 static void
2261 print_setitimer(void *cpu_env, const struct syscallname *name,
2262 abi_long arg0, abi_long arg1, abi_long arg2,
2263 abi_long arg3, abi_long arg4, abi_long arg5)
2264 {
2265 print_syscall_prologue(name);
2266 print_enums(itimer_types, arg0, 0);
2267 print_itimerval(arg1, 0);
2268 print_pointer(arg2, 1);
2269 print_syscall_epilogue(name);
2270 }
2271 #endif
2272
2273 #ifdef TARGET_NR_link
2274 static void
2275 print_link(void *cpu_env, const struct syscallname *name,
2276 abi_long arg0, abi_long arg1, abi_long arg2,
2277 abi_long arg3, abi_long arg4, abi_long arg5)
2278 {
2279 print_syscall_prologue(name);
2280 print_string(arg0, 0);
2281 print_string(arg1, 1);
2282 print_syscall_epilogue(name);
2283 }
2284 #endif
2285
2286 #ifdef TARGET_NR_linkat
2287 static void
2288 print_linkat(void *cpu_env, const struct syscallname *name,
2289 abi_long arg0, abi_long arg1, abi_long arg2,
2290 abi_long arg3, abi_long arg4, abi_long arg5)
2291 {
2292 print_syscall_prologue(name);
2293 print_at_dirfd(arg0, 0);
2294 print_string(arg1, 0);
2295 print_at_dirfd(arg2, 0);
2296 print_string(arg3, 0);
2297 print_flags(at_file_flags, arg4, 1);
2298 print_syscall_epilogue(name);
2299 }
2300 #endif
2301
2302 #ifdef TARGET_NR__llseek
2303 static void
2304 print__llseek(void *cpu_env, const struct syscallname *name,
2305 abi_long arg0, abi_long arg1, abi_long arg2,
2306 abi_long arg3, abi_long arg4, abi_long arg5)
2307 {
2308 const char *whence = "UNKNOWN";
2309 print_syscall_prologue(name);
2310 print_raw_param("%d", arg0, 0);
2311 print_raw_param("%ld", arg1, 0);
2312 print_raw_param("%ld", arg2, 0);
2313 print_pointer(arg3, 0);
2314 switch(arg4) {
2315 case SEEK_SET: whence = "SEEK_SET"; break;
2316 case SEEK_CUR: whence = "SEEK_CUR"; break;
2317 case SEEK_END: whence = "SEEK_END"; break;
2318 }
2319 qemu_log("%s", whence);
2320 print_syscall_epilogue(name);
2321 }
2322 #endif
2323
2324 #ifdef TARGET_NR_lseek
2325 static void
2326 print_lseek(void *cpu_env, const struct syscallname *name,
2327 abi_long arg0, abi_long arg1, abi_long arg2,
2328 abi_long arg3, abi_long arg4, abi_long arg5)
2329 {
2330 print_syscall_prologue(name);
2331 print_raw_param("%d", arg0, 0);
2332 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2333 switch (arg2) {
2334 case SEEK_SET:
2335 qemu_log("SEEK_SET"); break;
2336 case SEEK_CUR:
2337 qemu_log("SEEK_CUR"); break;
2338 case SEEK_END:
2339 qemu_log("SEEK_END"); break;
2340 #ifdef SEEK_DATA
2341 case SEEK_DATA:
2342 qemu_log("SEEK_DATA"); break;
2343 #endif
2344 #ifdef SEEK_HOLE
2345 case SEEK_HOLE:
2346 qemu_log("SEEK_HOLE"); break;
2347 #endif
2348 default:
2349 print_raw_param("%#x", arg2, 1);
2350 }
2351 print_syscall_epilogue(name);
2352 }
2353 #endif
2354
2355 #ifdef TARGET_NR_truncate
2356 static void
2357 print_truncate(void *cpu_env, const struct syscallname *name,
2358 abi_long arg0, abi_long arg1, abi_long arg2,
2359 abi_long arg3, abi_long arg4, abi_long arg5)
2360 {
2361 print_syscall_prologue(name);
2362 print_string(arg0, 0);
2363 print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
2364 print_syscall_epilogue(name);
2365 }
2366 #endif
2367
2368 #ifdef TARGET_NR_truncate64
2369 static void
2370 print_truncate64(void *cpu_env, const struct syscallname *name,
2371 abi_long arg0, abi_long arg1, abi_long arg2,
2372 abi_long arg3, abi_long arg4, abi_long arg5)
2373 {
2374 print_syscall_prologue(name);
2375 print_string(arg0, 0);
2376 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
2377 arg1 = arg2;
2378 arg2 = arg3;
2379 }
2380 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2381 print_syscall_epilogue(name);
2382 }
2383 #endif
2384
2385 #ifdef TARGET_NR_ftruncate64
2386 static void
2387 print_ftruncate64(void *cpu_env, const struct syscallname *name,
2388 abi_long arg0, abi_long arg1, abi_long arg2,
2389 abi_long arg3, abi_long arg4, abi_long arg5)
2390 {
2391 print_syscall_prologue(name);
2392 print_raw_param("%d", arg0, 0);
2393 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
2394 arg1 = arg2;
2395 arg2 = arg3;
2396 }
2397 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
2398 print_syscall_epilogue(name);
2399 }
2400 #endif
2401
2402 #ifdef TARGET_NR_mlockall
2403 static void
2404 print_mlockall(void *cpu_env, const struct syscallname *name,
2405 abi_long arg0, abi_long arg1, abi_long arg2,
2406 abi_long arg3, abi_long arg4, abi_long arg5)
2407 {
2408 print_syscall_prologue(name);
2409 print_flags(mlockall_flags, arg0, 1);
2410 print_syscall_epilogue(name);
2411 }
2412 #endif
2413
2414 #if defined(TARGET_NR_socket)
2415 static void
2416 print_socket(void *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)
2419 {
2420 abi_ulong domain = arg0, type = arg1, protocol = arg2;
2421
2422 print_syscall_prologue(name);
2423 print_socket_domain(domain);
2424 qemu_log(",");
2425 print_socket_type(type);
2426 qemu_log(",");
2427 if (domain == AF_PACKET ||
2428 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2429 protocol = tswap16(protocol);
2430 }
2431 print_socket_protocol(domain, type, protocol);
2432 print_syscall_epilogue(name);
2433 }
2434
2435 #endif
2436
2437 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
2438
2439 static void print_sockfd(abi_long sockfd, int last)
2440 {
2441 print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
2442 }
2443
2444 #endif
2445
2446 #if defined(TARGET_NR_socketcall)
2447
2448 #define get_user_ualx(x, gaddr, idx) \
2449 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
2450
2451 static void do_print_socket(const char *name, abi_long arg1)
2452 {
2453 abi_ulong domain, type, protocol;
2454
2455 get_user_ualx(domain, arg1, 0);
2456 get_user_ualx(type, arg1, 1);
2457 get_user_ualx(protocol, arg1, 2);
2458 qemu_log("%s(", name);
2459 print_socket_domain(domain);
2460 qemu_log(",");
2461 print_socket_type(type);
2462 qemu_log(",");
2463 if (domain == AF_PACKET ||
2464 (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
2465 protocol = tswap16(protocol);
2466 }
2467 print_socket_protocol(domain, type, protocol);
2468 qemu_log(")");
2469 }
2470
2471 static void do_print_sockaddr(const char *name, abi_long arg1)
2472 {
2473 abi_ulong sockfd, addr, addrlen;
2474
2475 get_user_ualx(sockfd, arg1, 0);
2476 get_user_ualx(addr, arg1, 1);
2477 get_user_ualx(addrlen, arg1, 2);
2478
2479 qemu_log("%s(", name);
2480 print_sockfd(sockfd, 0);
2481 print_sockaddr(addr, addrlen, 0);
2482 qemu_log(")");
2483 }
2484
2485 static void do_print_listen(const char *name, abi_long arg1)
2486 {
2487 abi_ulong sockfd, backlog;
2488
2489 get_user_ualx(sockfd, arg1, 0);
2490 get_user_ualx(backlog, arg1, 1);
2491
2492 qemu_log("%s(", name);
2493 print_sockfd(sockfd, 0);
2494 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
2495 qemu_log(")");
2496 }
2497
2498 static void do_print_socketpair(const char *name, abi_long arg1)
2499 {
2500 abi_ulong domain, type, protocol, tab;
2501
2502 get_user_ualx(domain, arg1, 0);
2503 get_user_ualx(type, arg1, 1);
2504 get_user_ualx(protocol, arg1, 2);
2505 get_user_ualx(tab, arg1, 3);
2506
2507 qemu_log("%s(", name);
2508 print_socket_domain(domain);
2509 qemu_log(",");
2510 print_socket_type(type);
2511 qemu_log(",");
2512 print_socket_protocol(domain, type, protocol);
2513 qemu_log(",");
2514 print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
2515 qemu_log(")");
2516 }
2517
2518 static void do_print_sendrecv(const char *name, abi_long arg1)
2519 {
2520 abi_ulong sockfd, msg, len, flags;
2521
2522 get_user_ualx(sockfd, arg1, 0);
2523 get_user_ualx(msg, arg1, 1);
2524 get_user_ualx(len, arg1, 2);
2525 get_user_ualx(flags, arg1, 3);
2526
2527 qemu_log("%s(", name);
2528 print_sockfd(sockfd, 0);
2529 print_buf(msg, len, 0);
2530 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2531 print_flags(msg_flags, flags, 1);
2532 qemu_log(")");
2533 }
2534
2535 static void do_print_msgaddr(const char *name, abi_long arg1)
2536 {
2537 abi_ulong sockfd, msg, len, flags, addr, addrlen;
2538
2539 get_user_ualx(sockfd, arg1, 0);
2540 get_user_ualx(msg, arg1, 1);
2541 get_user_ualx(len, arg1, 2);
2542 get_user_ualx(flags, arg1, 3);
2543 get_user_ualx(addr, arg1, 4);
2544 get_user_ualx(addrlen, arg1, 5);
2545
2546 qemu_log("%s(", name);
2547 print_sockfd(sockfd, 0);
2548 print_buf(msg, len, 0);
2549 print_raw_param(TARGET_ABI_FMT_ld, len, 0);
2550 print_flags(msg_flags, flags, 0);
2551 print_sockaddr(addr, addrlen, 0);
2552 qemu_log(")");
2553 }
2554
2555 static void do_print_shutdown(const char *name, abi_long arg1)
2556 {
2557 abi_ulong sockfd, how;
2558
2559 get_user_ualx(sockfd, arg1, 0);
2560 get_user_ualx(how, arg1, 1);
2561
2562 qemu_log("shutdown(");
2563 print_sockfd(sockfd, 0);
2564 switch (how) {
2565 case SHUT_RD:
2566 qemu_log("SHUT_RD");
2567 break;
2568 case SHUT_WR:
2569 qemu_log("SHUT_WR");
2570 break;
2571 case SHUT_RDWR:
2572 qemu_log("SHUT_RDWR");
2573 break;
2574 default:
2575 print_raw_param(TARGET_ABI_FMT_ld, how, 1);
2576 break;
2577 }
2578 qemu_log(")");
2579 }
2580
2581 static void do_print_msg(const char *name, abi_long arg1)
2582 {
2583 abi_ulong sockfd, msg, flags;
2584
2585 get_user_ualx(sockfd, arg1, 0);
2586 get_user_ualx(msg, arg1, 1);
2587 get_user_ualx(flags, arg1, 2);
2588
2589 qemu_log("%s(", name);
2590 print_sockfd(sockfd, 0);
2591 print_pointer(msg, 0);
2592 print_flags(msg_flags, flags, 1);
2593 qemu_log(")");
2594 }
2595
2596 static void do_print_sockopt(const char *name, abi_long arg1)
2597 {
2598 abi_ulong sockfd, level, optname, optval, optlen;
2599
2600 get_user_ualx(sockfd, arg1, 0);
2601 get_user_ualx(level, arg1, 1);
2602 get_user_ualx(optname, arg1, 2);
2603 get_user_ualx(optval, arg1, 3);
2604 get_user_ualx(optlen, arg1, 4);
2605
2606 qemu_log("%s(", name);
2607 print_sockfd(sockfd, 0);
2608 switch (level) {
2609 case SOL_TCP:
2610 qemu_log("SOL_TCP,");
2611 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2612 print_pointer(optval, 0);
2613 break;
2614 case SOL_IP:
2615 qemu_log("SOL_IP,");
2616 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2617 print_pointer(optval, 0);
2618 break;
2619 case SOL_RAW:
2620 qemu_log("SOL_RAW,");
2621 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2622 print_pointer(optval, 0);
2623 break;
2624 case TARGET_SOL_SOCKET:
2625 qemu_log("SOL_SOCKET,");
2626 switch (optname) {
2627 case TARGET_SO_DEBUG:
2628 qemu_log("SO_DEBUG,");
2629 print_optint:
2630 print_number(optval, 0);
2631 break;
2632 case TARGET_SO_REUSEADDR:
2633 qemu_log("SO_REUSEADDR,");
2634 goto print_optint;
2635 case TARGET_SO_REUSEPORT:
2636 qemu_log("SO_REUSEPORT,");
2637 goto print_optint;
2638 case TARGET_SO_TYPE:
2639 qemu_log("SO_TYPE,");
2640 goto print_optint;
2641 case TARGET_SO_ERROR:
2642 qemu_log("SO_ERROR,");
2643 goto print_optint;
2644 case TARGET_SO_DONTROUTE:
2645 qemu_log("SO_DONTROUTE,");
2646 goto print_optint;
2647 case TARGET_SO_BROADCAST:
2648 qemu_log("SO_BROADCAST,");
2649 goto print_optint;
2650 case TARGET_SO_SNDBUF:
2651 qemu_log("SO_SNDBUF,");
2652 goto print_optint;
2653 case TARGET_SO_RCVBUF:
2654 qemu_log("SO_RCVBUF,");
2655 goto print_optint;
2656 case TARGET_SO_KEEPALIVE:
2657 qemu_log("SO_KEEPALIVE,");
2658 goto print_optint;
2659 case TARGET_SO_OOBINLINE:
2660 qemu_log("SO_OOBINLINE,");
2661 goto print_optint;
2662 case TARGET_SO_NO_CHECK:
2663 qemu_log("SO_NO_CHECK,");
2664 goto print_optint;
2665 case TARGET_SO_PRIORITY:
2666 qemu_log("SO_PRIORITY,");
2667 goto print_optint;
2668 case TARGET_SO_BSDCOMPAT:
2669 qemu_log("SO_BSDCOMPAT,");
2670 goto print_optint;
2671 case TARGET_SO_PASSCRED:
2672 qemu_log("SO_PASSCRED,");
2673 goto print_optint;
2674 case TARGET_SO_TIMESTAMP:
2675 qemu_log("SO_TIMESTAMP,");
2676 goto print_optint;
2677 case TARGET_SO_RCVLOWAT:
2678 qemu_log("SO_RCVLOWAT,");
2679 goto print_optint;
2680 case TARGET_SO_RCVTIMEO:
2681 qemu_log("SO_RCVTIMEO,");
2682 print_timeval(optval, 0);
2683 break;
2684 case TARGET_SO_SNDTIMEO:
2685 qemu_log("SO_SNDTIMEO,");
2686 print_timeval(optval, 0);
2687 break;
2688 case TARGET_SO_ATTACH_FILTER: {
2689 struct target_sock_fprog *fprog;
2690
2691 qemu_log("SO_ATTACH_FILTER,");
2692
2693 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
2694 struct target_sock_filter *filter;
2695 qemu_log("{");
2696 if (lock_user_struct(VERIFY_READ, filter,
2697 tswapal(fprog->filter), 0)) {
2698 int i;
2699 for (i = 0; i < tswap16(fprog->len) - 1; i++) {
2700 qemu_log("[%d]{0x%x,%d,%d,0x%x},",
2701 i, tswap16(filter[i].code),
2702 filter[i].jt, filter[i].jf,
2703 tswap32(filter[i].k));
2704 }
2705 qemu_log("[%d]{0x%x,%d,%d,0x%x}",
2706 i, tswap16(filter[i].code),
2707 filter[i].jt, filter[i].jf,
2708 tswap32(filter[i].k));
2709 } else {
2710 qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
2711 }
2712 qemu_log(",%d},", tswap16(fprog->len));
2713 unlock_user(fprog, optval, 0);
2714 } else {
2715 print_pointer(optval, 0);
2716 }
2717 break;
2718 }
2719 default:
2720 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2721 print_pointer(optval, 0);
2722 break;
2723 }
2724 break;
2725 default:
2726 print_raw_param(TARGET_ABI_FMT_ld, level, 0);
2727 print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
2728 print_pointer(optval, 0);
2729 break;
2730 }
2731 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
2732 qemu_log(")");
2733 }
2734
2735 #define PRINT_SOCKOP(name, func) \
2736 [TARGET_SYS_##name] = { #name, func }
2737
2738 static struct {
2739 const char *name;
2740 void (*print)(const char *, abi_long);
2741 } scall[] = {
2742 PRINT_SOCKOP(SOCKET, do_print_socket),
2743 PRINT_SOCKOP(BIND, do_print_sockaddr),
2744 PRINT_SOCKOP(CONNECT, do_print_sockaddr),
2745 PRINT_SOCKOP(LISTEN, do_print_listen),
2746 PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
2747 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
2748 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
2749 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
2750 PRINT_SOCKOP(SEND, do_print_sendrecv),
2751 PRINT_SOCKOP(RECV, do_print_sendrecv),
2752 PRINT_SOCKOP(SENDTO, do_print_msgaddr),
2753 PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
2754 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
2755 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
2756 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
2757 PRINT_SOCKOP(SENDMSG, do_print_msg),
2758 PRINT_SOCKOP(RECVMSG, do_print_msg),
2759 PRINT_SOCKOP(ACCEPT4, NULL),
2760 PRINT_SOCKOP(RECVMMSG, NULL),
2761 PRINT_SOCKOP(SENDMMSG, NULL),
2762 };
2763
2764 static void
2765 print_socketcall(void *cpu_env, const struct syscallname *name,
2766 abi_long arg0, abi_long arg1, abi_long arg2,
2767 abi_long arg3, abi_long arg4, abi_long arg5)
2768 {
2769 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
2770 scall[arg0].print(scall[arg0].name, arg1);
2771 return;
2772 }
2773 print_syscall_prologue(name);
2774 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
2775 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
2776 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
2777 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
2778 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
2779 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
2780 print_syscall_epilogue(name);
2781 }
2782 #endif
2783
2784 #if defined(TARGET_NR_bind)
2785 static void
2786 print_bind(void *cpu_env, const struct syscallname *name,
2787 abi_long arg0, abi_long arg1, abi_long arg2,
2788 abi_long arg3, abi_long arg4, abi_long arg5)
2789 {
2790 print_syscall_prologue(name);
2791 print_sockfd(arg0, 0);
2792 print_sockaddr(arg1, arg2, 1);
2793 print_syscall_epilogue(name);
2794 }
2795 #endif
2796
2797 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
2798 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
2799 static void
2800 print_stat(void *cpu_env, const struct syscallname *name,
2801 abi_long arg0, abi_long arg1, abi_long arg2,
2802 abi_long arg3, abi_long arg4, abi_long arg5)
2803 {
2804 print_syscall_prologue(name);
2805 print_string(arg0, 0);
2806 print_pointer(arg1, 1);
2807 print_syscall_epilogue(name);
2808 }
2809 #define print_lstat print_stat
2810 #define print_stat64 print_stat
2811 #define print_lstat64 print_stat
2812 #endif
2813
2814 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
2815 static void
2816 print_fstat(void *cpu_env, const struct syscallname *name,
2817 abi_long arg0, abi_long arg1, abi_long arg2,
2818 abi_long arg3, abi_long arg4, abi_long arg5)
2819 {
2820 print_syscall_prologue(name);
2821 print_raw_param("%d", arg0, 0);
2822 print_pointer(arg1, 1);
2823 print_syscall_epilogue(name);
2824 }
2825 #define print_fstat64 print_fstat
2826 #endif
2827
2828 #ifdef TARGET_NR_mkdir
2829 static void
2830 print_mkdir(void *cpu_env, const struct syscallname *name,
2831 abi_long arg0, abi_long arg1, abi_long arg2,
2832 abi_long arg3, abi_long arg4, abi_long arg5)
2833 {
2834 print_syscall_prologue(name);
2835 print_string(arg0, 0);
2836 print_file_mode(arg1, 1);
2837 print_syscall_epilogue(name);
2838 }
2839 #endif
2840
2841 #ifdef TARGET_NR_mkdirat
2842 static void
2843 print_mkdirat(void *cpu_env, const struct syscallname *name,
2844 abi_long arg0, abi_long arg1, abi_long arg2,
2845 abi_long arg3, abi_long arg4, abi_long arg5)
2846 {
2847 print_syscall_prologue(name);
2848 print_at_dirfd(arg0, 0);
2849 print_string(arg1, 0);
2850 print_file_mode(arg2, 1);
2851 print_syscall_epilogue(name);
2852 }
2853 #endif
2854
2855 #ifdef TARGET_NR_rmdir
2856 static void
2857 print_rmdir(void *cpu_env, const struct syscallname *name,
2858 abi_long arg0, abi_long arg1, abi_long arg2,
2859 abi_long arg3, abi_long arg4, abi_long arg5)
2860 {
2861 print_syscall_prologue(name);
2862 print_string(arg0, 0);
2863 print_syscall_epilogue(name);
2864 }
2865 #endif
2866
2867 #ifdef TARGET_NR_rt_sigaction
2868 static void
2869 print_rt_sigaction(void *cpu_env, const struct syscallname *name,
2870 abi_long arg0, abi_long arg1, abi_long arg2,
2871 abi_long arg3, abi_long arg4, abi_long arg5)
2872 {
2873 print_syscall_prologue(name);
2874 print_signal(arg0, 0);
2875 print_pointer(arg1, 0);
2876 print_pointer(arg2, 1);
2877 print_syscall_epilogue(name);
2878 }
2879 #endif
2880
2881 #ifdef TARGET_NR_rt_sigprocmask
2882 static void
2883 print_rt_sigprocmask(void *cpu_env, const struct syscallname *name,
2884 abi_long arg0, abi_long arg1, abi_long arg2,
2885 abi_long arg3, abi_long arg4, abi_long arg5)
2886 {
2887 const char *how = "UNKNOWN";
2888 print_syscall_prologue(name);
2889 switch(arg0) {
2890 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
2891 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
2892 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
2893 }
2894 qemu_log("%s,", how);
2895 print_pointer(arg1, 0);
2896 print_pointer(arg2, 1);
2897 print_syscall_epilogue(name);
2898 }
2899 #endif
2900
2901 #ifdef TARGET_NR_rt_sigqueueinfo
2902 static void
2903 print_rt_sigqueueinfo(void *cpu_env, const struct syscallname *name,
2904 abi_long arg0, abi_long arg1, abi_long arg2,
2905 abi_long arg3, abi_long arg4, abi_long arg5)
2906 {
2907 void *p;
2908 target_siginfo_t uinfo;
2909
2910 print_syscall_prologue(name);
2911 print_raw_param("%d", arg0, 0);
2912 print_signal(arg1, 0);
2913 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
2914 if (p) {
2915 get_target_siginfo(&uinfo, p);
2916 print_siginfo(&uinfo);
2917
2918 unlock_user(p, arg2, 0);
2919 } else {
2920 print_pointer(arg2, 1);
2921 }
2922 print_syscall_epilogue(name);
2923 }
2924 #endif
2925
2926 #ifdef TARGET_NR_rt_tgsigqueueinfo
2927 static void
2928 print_rt_tgsigqueueinfo(void *cpu_env, const struct syscallname *name,
2929 abi_long arg0, abi_long arg1, abi_long arg2,
2930 abi_long arg3, abi_long arg4, abi_long arg5)
2931 {
2932 void *p;
2933 target_siginfo_t uinfo;
2934
2935 print_syscall_prologue(name);
2936 print_raw_param("%d", arg0, 0);
2937 print_raw_param("%d", arg1, 0);
2938 print_signal(arg2, 0);
2939 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
2940 if (p) {
2941 get_target_siginfo(&uinfo, p);
2942 print_siginfo(&uinfo);
2943
2944 unlock_user(p, arg3, 0);
2945 } else {
2946 print_pointer(arg3, 1);
2947 }
2948 print_syscall_epilogue(name);
2949 }
2950 #endif
2951
2952 #ifdef TARGET_NR_syslog
2953 static void
2954 print_syslog_action(abi_ulong arg, int last)
2955 {
2956 const char *type;
2957
2958 switch (arg) {
2959 case TARGET_SYSLOG_ACTION_CLOSE: {
2960 type = "SYSLOG_ACTION_CLOSE";
2961 break;
2962 }
2963 case TARGET_SYSLOG_ACTION_OPEN: {
2964 type = "SYSLOG_ACTION_OPEN";
2965 break;
2966 }
2967 case TARGET_SYSLOG_ACTION_READ: {
2968 type = "SYSLOG_ACTION_READ";
2969 break;
2970 }
2971 case TARGET_SYSLOG_ACTION_READ_ALL: {
2972 type = "SYSLOG_ACTION_READ_ALL";
2973 break;
2974 }
2975 case TARGET_SYSLOG_ACTION_READ_CLEAR: {
2976 type = "SYSLOG_ACTION_READ_CLEAR";
2977 break;
2978 }
2979 case TARGET_SYSLOG_ACTION_CLEAR: {
2980 type = "SYSLOG_ACTION_CLEAR";
2981 break;
2982 }
2983 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
2984 type = "SYSLOG_ACTION_CONSOLE_OFF";
2985 break;
2986 }
2987 case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
2988 type = "SYSLOG_ACTION_CONSOLE_ON";
2989 break;
2990 }
2991 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
2992 type = "SYSLOG_ACTION_CONSOLE_LEVEL";
2993 break;
2994 }
2995 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
2996 type = "SYSLOG_ACTION_SIZE_UNREAD";
2997 break;
2998 }
2999 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
3000 type = "SYSLOG_ACTION_SIZE_BUFFER";
3001 break;
3002 }
3003 default: {
3004 print_raw_param("%ld", arg, last);
3005 return;
3006 }
3007 }
3008 qemu_log("%s%s", type, get_comma(last));
3009 }
3010
3011 static void
3012 print_syslog(void *cpu_env, const struct syscallname *name,
3013 abi_long arg0, abi_long arg1, abi_long arg2,
3014 abi_long arg3, abi_long arg4, abi_long arg5)
3015 {
3016 print_syscall_prologue(name);
3017 print_syslog_action(arg0, 0);
3018 print_pointer(arg1, 0);
3019 print_raw_param("%d", arg2, 1);
3020 print_syscall_epilogue(name);
3021 }
3022 #endif
3023
3024 #ifdef TARGET_NR_mknod
3025 static void
3026 print_mknod(void *cpu_env, const struct syscallname *name,
3027 abi_long arg0, abi_long arg1, abi_long arg2,
3028 abi_long arg3, abi_long arg4, abi_long arg5)
3029 {
3030 int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
3031
3032 print_syscall_prologue(name);
3033 print_string(arg0, 0);
3034 print_file_mode(arg1, (hasdev == 0));
3035 if (hasdev) {
3036 print_raw_param("makedev(%d", major(arg2), 0);
3037 print_raw_param("%d)", minor(arg2), 1);
3038 }
3039 print_syscall_epilogue(name);
3040 }
3041 #endif
3042
3043 #ifdef TARGET_NR_mknodat
3044 static void
3045 print_mknodat(void *cpu_env, const struct syscallname *name,
3046 abi_long arg0, abi_long arg1, abi_long arg2,
3047 abi_long arg3, abi_long arg4, abi_long arg5)
3048 {
3049 int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
3050
3051 print_syscall_prologue(name);
3052 print_at_dirfd(arg0, 0);
3053 print_string(arg1, 0);
3054 print_file_mode(arg2, (hasdev == 0));
3055 if (hasdev) {
3056 print_raw_param("makedev(%d", major(arg3), 0);
3057 print_raw_param("%d)", minor(arg3), 1);
3058 }
3059 print_syscall_epilogue(name);
3060 }
3061 #endif
3062
3063 #ifdef TARGET_NR_mq_open
3064 static void
3065 print_mq_open(void *cpu_env, const struct syscallname *name,
3066 abi_long arg0, abi_long arg1, abi_long arg2,
3067 abi_long arg3, abi_long arg4, abi_long arg5)
3068 {
3069 int is_creat = (arg1 & TARGET_O_CREAT);
3070
3071 print_syscall_prologue(name);
3072 print_string(arg0, 0);
3073 print_open_flags(arg1, (is_creat == 0));
3074 if (is_creat) {
3075 print_file_mode(arg2, 0);
3076 print_pointer(arg3, 1);
3077 }
3078 print_syscall_epilogue(name);
3079 }
3080 #endif
3081
3082 #ifdef TARGET_NR_open
3083 static void
3084 print_open(void *cpu_env, const struct syscallname *name,
3085 abi_long arg0, abi_long arg1, abi_long arg2,
3086 abi_long arg3, abi_long arg4, abi_long arg5)
3087 {
3088 int is_creat = (arg1 & TARGET_O_CREAT);
3089
3090 print_syscall_prologue(name);
3091 print_string(arg0, 0);
3092 print_open_flags(arg1, (is_creat == 0));
3093 if (is_creat)
3094 print_file_mode(arg2, 1);
3095 print_syscall_epilogue(name);
3096 }
3097 #endif
3098
3099 #ifdef TARGET_NR_openat
3100 static void
3101 print_openat(void *cpu_env, const struct syscallname *name,
3102 abi_long arg0, abi_long arg1, abi_long arg2,
3103 abi_long arg3, abi_long arg4, abi_long arg5)
3104 {
3105 int is_creat = (arg2 & TARGET_O_CREAT);
3106
3107 print_syscall_prologue(name);
3108 print_at_dirfd(arg0, 0);
3109 print_string(arg1, 0);
3110 print_open_flags(arg2, (is_creat == 0));
3111 if (is_creat)
3112 print_file_mode(arg3, 1);
3113 print_syscall_epilogue(name);
3114 }
3115 #endif
3116
3117 #ifdef TARGET_NR_mq_unlink
3118 static void
3119 print_mq_unlink(void *cpu_env, const struct syscallname *name,
3120 abi_long arg0, abi_long arg1, abi_long arg2,
3121 abi_long arg3, abi_long arg4, abi_long arg5)
3122 {
3123 print_syscall_prologue(name);
3124 print_string(arg0, 1);
3125 print_syscall_epilogue(name);
3126 }
3127 #endif
3128
3129 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
3130 static void
3131 print_fstatat64(void *cpu_env, const struct syscallname *name,
3132 abi_long arg0, abi_long arg1, abi_long arg2,
3133 abi_long arg3, abi_long arg4, abi_long arg5)
3134 {
3135 print_syscall_prologue(name);
3136 print_at_dirfd(arg0, 0);
3137 print_string(arg1, 0);
3138 print_pointer(arg2, 0);
3139 print_flags(at_file_flags, arg3, 1);
3140 print_syscall_epilogue(name);
3141 }
3142 #define print_newfstatat print_fstatat64
3143 #endif
3144
3145 #ifdef TARGET_NR_readlink
3146 static void
3147 print_readlink(void *cpu_env, const struct syscallname *name,
3148 abi_long arg0, abi_long arg1, abi_long arg2,
3149 abi_long arg3, abi_long arg4, abi_long arg5)
3150 {
3151 print_syscall_prologue(name);
3152 print_string(arg0, 0);
3153 print_pointer(arg1, 0);
3154 print_raw_param("%u", arg2, 1);
3155 print_syscall_epilogue(name);
3156 }
3157 #endif
3158
3159 #ifdef TARGET_NR_readlinkat
3160 static void
3161 print_readlinkat(void *cpu_env, const struct syscallname *name,
3162 abi_long arg0, abi_long arg1, abi_long arg2,
3163 abi_long arg3, abi_long arg4, abi_long arg5)
3164 {
3165 print_syscall_prologue(name);
3166 print_at_dirfd(arg0, 0);
3167 print_string(arg1, 0);
3168 print_pointer(arg2, 0);
3169 print_raw_param("%u", arg3, 1);
3170 print_syscall_epilogue(name);
3171 }
3172 #endif
3173
3174 #ifdef TARGET_NR_rename
3175 static void
3176 print_rename(void *cpu_env, const struct syscallname *name,
3177 abi_long arg0, abi_long arg1, abi_long arg2,
3178 abi_long arg3, abi_long arg4, abi_long arg5)
3179 {
3180 print_syscall_prologue(name);
3181 print_string(arg0, 0);
3182 print_string(arg1, 1);
3183 print_syscall_epilogue(name);
3184 }
3185 #endif
3186
3187 #ifdef TARGET_NR_renameat
3188 static void
3189 print_renameat(void *cpu_env, const struct syscallname *name,
3190 abi_long arg0, abi_long arg1, abi_long arg2,
3191 abi_long arg3, abi_long arg4, abi_long arg5)
3192 {
3193 print_syscall_prologue(name);
3194 print_at_dirfd(arg0, 0);
3195 print_string(arg1, 0);
3196 print_at_dirfd(arg2, 0);
3197 print_string(arg3, 1);
3198 print_syscall_epilogue(name);
3199 }
3200 #endif
3201
3202 #ifdef TARGET_NR_statfs
3203 static void
3204 print_statfs(void *cpu_env, const struct syscallname *name,
3205 abi_long arg0, abi_long arg1, abi_long arg2,
3206 abi_long arg3, abi_long arg4, abi_long arg5)
3207 {
3208 print_syscall_prologue(name);
3209 print_string(arg0, 0);
3210 print_pointer(arg1, 1);
3211 print_syscall_epilogue(name);
3212 }
3213 #endif
3214
3215 #ifdef TARGET_NR_statfs64
3216 static void
3217 print_statfs64(void *cpu_env, const struct syscallname *name,
3218 abi_long arg0, abi_long arg1, abi_long arg2,
3219 abi_long arg3, abi_long arg4, abi_long arg5)
3220 {
3221 print_syscall_prologue(name);
3222 print_string(arg0, 0);
3223 print_pointer(arg1, 1);
3224 print_syscall_epilogue(name);
3225 }
3226 #endif
3227
3228 #ifdef TARGET_NR_symlink
3229 static void
3230 print_symlink(void *cpu_env, const struct syscallname *name,
3231 abi_long arg0, abi_long arg1, abi_long arg2,
3232 abi_long arg3, abi_long arg4, abi_long arg5)
3233 {
3234 print_syscall_prologue(name);
3235 print_string(arg0, 0);
3236 print_string(arg1, 1);
3237 print_syscall_epilogue(name);
3238 }
3239 #endif
3240
3241 #ifdef TARGET_NR_symlinkat
3242 static void
3243 print_symlinkat(void *cpu_env, const struct syscallname *name,
3244 abi_long arg0, abi_long arg1, abi_long arg2,
3245 abi_long arg3, abi_long arg4, abi_long arg5)
3246 {
3247 print_syscall_prologue(name);
3248 print_string(arg0, 0);
3249 print_at_dirfd(arg1, 0);
3250 print_string(arg2, 1);
3251 print_syscall_epilogue(name);
3252 }
3253 #endif
3254
3255 #ifdef TARGET_NR_mount
3256 static void
3257 print_mount(void *cpu_env, const struct syscallname *name,
3258 abi_long arg0, abi_long arg1, abi_long arg2,
3259 abi_long arg3, abi_long arg4, abi_long arg5)
3260 {
3261 print_syscall_prologue(name);
3262 print_string(arg0, 0);
3263 print_string(arg1, 0);
3264 print_string(arg2, 0);
3265 print_flags(mount_flags, arg3, 0);
3266 print_pointer(arg4, 1);
3267 print_syscall_epilogue(name);
3268 }
3269 #endif
3270
3271 #ifdef TARGET_NR_umount
3272 static void
3273 print_umount(void *cpu_env, const struct syscallname *name,
3274 abi_long arg0, abi_long arg1, abi_long arg2,
3275 abi_long arg3, abi_long arg4, abi_long arg5)
3276 {
3277 print_syscall_prologue(name);
3278 print_string(arg0, 1);
3279 print_syscall_epilogue(name);
3280 }
3281 #endif
3282
3283 #ifdef TARGET_NR_umount2
3284 static void
3285 print_umount2(void *cpu_env, const struct syscallname *name,
3286 abi_long arg0, abi_long arg1, abi_long arg2,
3287 abi_long arg3, abi_long arg4, abi_long arg5)
3288 {
3289 print_syscall_prologue(name);
3290 print_string(arg0, 0);
3291 print_flags(umount2_flags, arg1, 1);
3292 print_syscall_epilogue(name);
3293 }
3294 #endif
3295
3296 #ifdef TARGET_NR_unlink
3297 static void
3298 print_unlink(void *cpu_env, const struct syscallname *name,
3299 abi_long arg0, abi_long arg1, abi_long arg2,
3300 abi_long arg3, abi_long arg4, abi_long arg5)
3301 {
3302 print_syscall_prologue(name);
3303 print_string(arg0, 1);
3304 print_syscall_epilogue(name);
3305 }
3306 #endif
3307
3308 #ifdef TARGET_NR_unlinkat
3309 static void
3310 print_unlinkat(void *cpu_env, const struct syscallname *name,
3311 abi_long arg0, abi_long arg1, abi_long arg2,
3312 abi_long arg3, abi_long arg4, abi_long arg5)
3313 {
3314 print_syscall_prologue(name);
3315 print_at_dirfd(arg0, 0);
3316 print_string(arg1, 0);
3317 print_flags(unlinkat_flags, arg2, 1);
3318 print_syscall_epilogue(name);
3319 }
3320 #endif
3321
3322 #ifdef TARGET_NR_utime
3323 static void
3324 print_utime(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)
3327 {
3328 print_syscall_prologue(name);
3329 print_string(arg0, 0);
3330 print_pointer(arg1, 1);
3331 print_syscall_epilogue(name);
3332 }
3333 #endif
3334
3335 #ifdef TARGET_NR_utimes
3336 static void
3337 print_utimes(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)
3340 {
3341 print_syscall_prologue(name);
3342 print_string(arg0, 0);
3343 print_pointer(arg1, 1);
3344 print_syscall_epilogue(name);
3345 }
3346 #endif