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