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