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