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