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