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