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