1 #include <stdio.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/types.h> 8 #include <sys/mount.h> 9 #include <sys/mman.h> 10 #include <unistd.h> 11 #include <sched.h> 12 #include "qemu.h" 13 14 int do_strace=0; 15 16 struct syscallname { 17 int nr; 18 const char *name; 19 const char *format; 20 void (*call)(const struct syscallname *, 21 abi_long, abi_long, abi_long, 22 abi_long, abi_long, abi_long); 23 void (*result)(const struct syscallname *, abi_long); 24 }; 25 26 #ifdef __GNUC__ 27 /* 28 * It is possible that target doesn't have syscall that uses 29 * following flags but we don't want the compiler to warn 30 * us about them being unused. Same applies to utility print 31 * functions. It is ok to keep them while not used. 32 */ 33 #define UNUSED __attribute__ ((unused)) 34 #else 35 #define UNUSED 36 #endif 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 UNUSED static const char *get_comma(int); 55 UNUSED static void print_pointer(abi_long, int); 56 UNUSED static void print_flags(const struct flags *, abi_long, int); 57 UNUSED static void print_at_dirfd(abi_long, int); 58 UNUSED static void print_file_mode(abi_long, int); 59 UNUSED static void print_open_flags(abi_long, int); 60 UNUSED static void print_syscall_prologue(const struct syscallname *); 61 UNUSED static void print_syscall_epilogue(const struct syscallname *); 62 UNUSED static void print_string(abi_long, int); 63 UNUSED static void print_raw_param(const char *, abi_long, int); 64 UNUSED static void print_timeval(abi_ulong, int); 65 UNUSED static void print_number(abi_long, int); 66 UNUSED static void print_signal(abi_ulong, int); 67 68 /* 69 * Utility functions 70 */ 71 static void 72 print_ipc_cmd(int cmd) 73 { 74 #define output_cmd(val) \ 75 if( cmd == val ) { \ 76 gemu_log(#val); \ 77 return; \ 78 } 79 80 cmd &= 0xff; 81 82 /* General IPC commands */ 83 output_cmd( IPC_RMID ); 84 output_cmd( IPC_SET ); 85 output_cmd( IPC_STAT ); 86 output_cmd( IPC_INFO ); 87 /* msgctl() commands */ 88 #ifdef __USER_MISC 89 output_cmd( MSG_STAT ); 90 output_cmd( MSG_INFO ); 91 #endif 92 /* shmctl() commands */ 93 output_cmd( SHM_LOCK ); 94 output_cmd( SHM_UNLOCK ); 95 output_cmd( SHM_STAT ); 96 output_cmd( SHM_INFO ); 97 /* semctl() commands */ 98 output_cmd( GETPID ); 99 output_cmd( GETVAL ); 100 output_cmd( GETALL ); 101 output_cmd( GETNCNT ); 102 output_cmd( GETZCNT ); 103 output_cmd( SETVAL ); 104 output_cmd( SETALL ); 105 output_cmd( SEM_STAT ); 106 output_cmd( SEM_INFO ); 107 output_cmd( IPC_RMID ); 108 output_cmd( IPC_RMID ); 109 output_cmd( IPC_RMID ); 110 output_cmd( IPC_RMID ); 111 output_cmd( IPC_RMID ); 112 output_cmd( IPC_RMID ); 113 output_cmd( IPC_RMID ); 114 output_cmd( IPC_RMID ); 115 output_cmd( IPC_RMID ); 116 117 /* Some value we don't recognize */ 118 gemu_log("%d",cmd); 119 } 120 121 static void 122 print_signal(abi_ulong arg, int last) 123 { 124 const char *signal_name = NULL; 125 switch(arg) { 126 case TARGET_SIGHUP: signal_name = "SIGHUP"; break; 127 case TARGET_SIGINT: signal_name = "SIGINT"; break; 128 case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; 129 case TARGET_SIGILL: signal_name = "SIGILL"; break; 130 case TARGET_SIGABRT: signal_name = "SIGABRT"; break; 131 case TARGET_SIGFPE: signal_name = "SIGFPE"; break; 132 case TARGET_SIGKILL: signal_name = "SIGKILL"; break; 133 case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; 134 case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; 135 case TARGET_SIGALRM: signal_name = "SIGALRM"; break; 136 case TARGET_SIGTERM: signal_name = "SIGTERM"; break; 137 case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; 138 case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; 139 case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; 140 case TARGET_SIGCONT: signal_name = "SIGCONT"; break; 141 case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; 142 case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; 143 case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; 144 } 145 if (signal_name == NULL) { 146 print_raw_param("%ld", arg, last); 147 return; 148 } 149 gemu_log("%s%s", signal_name, get_comma(last)); 150 } 151 152 #ifdef TARGET_NR__newselect 153 static void 154 print_fdset(int n, abi_ulong target_fds_addr) 155 { 156 int i; 157 158 gemu_log("["); 159 if( target_fds_addr ) { 160 abi_long *target_fds; 161 162 target_fds = lock_user(VERIFY_READ, 163 target_fds_addr, 164 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), 165 1); 166 167 if (!target_fds) 168 return; 169 170 for (i=n; i>=0; i--) { 171 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) 172 gemu_log("%d,", i ); 173 } 174 unlock_user(target_fds, target_fds_addr, 0); 175 } 176 gemu_log("]"); 177 } 178 #endif 179 180 /* 181 * Sysycall specific output functions 182 */ 183 184 /* select */ 185 #ifdef TARGET_NR__newselect 186 static long newselect_arg1 = 0; 187 static long newselect_arg2 = 0; 188 static long newselect_arg3 = 0; 189 static long newselect_arg4 = 0; 190 static long newselect_arg5 = 0; 191 192 static void 193 print_newselect(const struct syscallname *name, 194 abi_long arg1, abi_long arg2, abi_long arg3, 195 abi_long arg4, abi_long arg5, abi_long arg6) 196 { 197 gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); 198 print_fdset(arg1, arg2); 199 gemu_log(","); 200 print_fdset(arg1, arg3); 201 gemu_log(","); 202 print_fdset(arg1, arg4); 203 gemu_log(","); 204 print_timeval(arg5, 1); 205 gemu_log(")"); 206 207 /* save for use in the return output function below */ 208 newselect_arg1=arg1; 209 newselect_arg2=arg2; 210 newselect_arg3=arg3; 211 newselect_arg4=arg4; 212 newselect_arg5=arg5; 213 } 214 #endif 215 216 #ifdef TARGET_NR_semctl 217 static void 218 print_semctl(const struct syscallname *name, 219 abi_long arg1, abi_long arg2, abi_long arg3, 220 abi_long arg4, abi_long arg5, abi_long arg6) 221 { 222 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2); 223 print_ipc_cmd(arg3); 224 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 225 } 226 #endif 227 228 static void 229 print_execve(const struct syscallname *name, 230 abi_long arg1, abi_long arg2, abi_long arg3, 231 abi_long arg4, abi_long arg5, abi_long arg6) 232 { 233 abi_ulong arg_ptr_addr; 234 char *s; 235 236 if (!(s = lock_user_string(arg1))) 237 return; 238 gemu_log("%s(\"%s\",{", name->name, s); 239 unlock_user(s, arg1, 0); 240 241 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { 242 abi_ulong *arg_ptr, arg_addr; 243 244 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); 245 if (!arg_ptr) 246 return; 247 arg_addr = tswapal(*arg_ptr); 248 unlock_user(arg_ptr, arg_ptr_addr, 0); 249 if (!arg_addr) 250 break; 251 if ((s = lock_user_string(arg_addr))) { 252 gemu_log("\"%s\",", s); 253 unlock_user(s, arg_addr, 0); 254 } 255 } 256 257 gemu_log("NULL})"); 258 } 259 260 #ifdef TARGET_NR_ipc 261 static void 262 print_ipc(const struct syscallname *name, 263 abi_long arg1, abi_long arg2, abi_long arg3, 264 abi_long arg4, abi_long arg5, abi_long arg6) 265 { 266 switch(arg1) { 267 case IPCOP_semctl: 268 gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2); 269 print_ipc_cmd(arg3); 270 gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 271 break; 272 default: 273 gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")", 274 name->name, arg1, arg2, arg3, arg4); 275 } 276 } 277 #endif 278 279 /* 280 * Variants for the return value output function 281 */ 282 283 static void 284 print_syscall_ret_addr(const struct syscallname *name, abi_long ret) 285 { 286 char *errstr = NULL; 287 288 if (ret < 0) { 289 errstr = target_strerror(-ret); 290 } 291 if (errstr) { 292 gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); 293 } else { 294 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 295 } 296 } 297 298 #if 0 /* currently unused */ 299 static void 300 print_syscall_ret_raw(struct syscallname *name, abi_long ret) 301 { 302 gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 303 } 304 #endif 305 306 #ifdef TARGET_NR__newselect 307 static void 308 print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) 309 { 310 gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); 311 print_fdset(newselect_arg1,newselect_arg2); 312 gemu_log(","); 313 print_fdset(newselect_arg1,newselect_arg3); 314 gemu_log(","); 315 print_fdset(newselect_arg1,newselect_arg4); 316 gemu_log(","); 317 print_timeval(newselect_arg5, 1); 318 gemu_log(")\n"); 319 } 320 #endif 321 322 UNUSED static struct flags access_flags[] = { 323 FLAG_GENERIC(F_OK), 324 FLAG_GENERIC(R_OK), 325 FLAG_GENERIC(W_OK), 326 FLAG_GENERIC(X_OK), 327 FLAG_END, 328 }; 329 330 UNUSED static struct flags at_file_flags[] = { 331 #ifdef AT_EACCESS 332 FLAG_GENERIC(AT_EACCESS), 333 #endif 334 #ifdef AT_SYMLINK_NOFOLLOW 335 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), 336 #endif 337 FLAG_END, 338 }; 339 340 UNUSED static struct flags unlinkat_flags[] = { 341 #ifdef AT_REMOVEDIR 342 FLAG_GENERIC(AT_REMOVEDIR), 343 #endif 344 FLAG_END, 345 }; 346 347 UNUSED static struct flags mode_flags[] = { 348 FLAG_GENERIC(S_IFSOCK), 349 FLAG_GENERIC(S_IFLNK), 350 FLAG_GENERIC(S_IFREG), 351 FLAG_GENERIC(S_IFBLK), 352 FLAG_GENERIC(S_IFDIR), 353 FLAG_GENERIC(S_IFCHR), 354 FLAG_GENERIC(S_IFIFO), 355 FLAG_END, 356 }; 357 358 UNUSED static struct flags open_access_flags[] = { 359 FLAG_TARGET(O_RDONLY), 360 FLAG_TARGET(O_WRONLY), 361 FLAG_TARGET(O_RDWR), 362 FLAG_END, 363 }; 364 365 UNUSED static struct flags open_flags[] = { 366 FLAG_TARGET(O_APPEND), 367 FLAG_TARGET(O_CREAT), 368 FLAG_TARGET(O_DIRECTORY), 369 FLAG_TARGET(O_EXCL), 370 FLAG_TARGET(O_LARGEFILE), 371 FLAG_TARGET(O_NOCTTY), 372 FLAG_TARGET(O_NOFOLLOW), 373 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ 374 FLAG_TARGET(O_DSYNC), 375 FLAG_TARGET(__O_SYNC), 376 FLAG_TARGET(O_TRUNC), 377 #ifdef O_DIRECT 378 FLAG_TARGET(O_DIRECT), 379 #endif 380 #ifdef O_NOATIME 381 FLAG_TARGET(O_NOATIME), 382 #endif 383 #ifdef O_CLOEXEC 384 FLAG_TARGET(O_CLOEXEC), 385 #endif 386 #ifdef O_PATH 387 FLAG_TARGET(O_PATH), 388 #endif 389 FLAG_END, 390 }; 391 392 UNUSED static struct flags mount_flags[] = { 393 #ifdef MS_BIND 394 FLAG_GENERIC(MS_BIND), 395 #endif 396 #ifdef MS_DIRSYNC 397 FLAG_GENERIC(MS_DIRSYNC), 398 #endif 399 FLAG_GENERIC(MS_MANDLOCK), 400 #ifdef MS_MOVE 401 FLAG_GENERIC(MS_MOVE), 402 #endif 403 FLAG_GENERIC(MS_NOATIME), 404 FLAG_GENERIC(MS_NODEV), 405 FLAG_GENERIC(MS_NODIRATIME), 406 FLAG_GENERIC(MS_NOEXEC), 407 FLAG_GENERIC(MS_NOSUID), 408 FLAG_GENERIC(MS_RDONLY), 409 #ifdef MS_RELATIME 410 FLAG_GENERIC(MS_RELATIME), 411 #endif 412 FLAG_GENERIC(MS_REMOUNT), 413 FLAG_GENERIC(MS_SYNCHRONOUS), 414 FLAG_END, 415 }; 416 417 UNUSED static struct flags umount2_flags[] = { 418 #ifdef MNT_FORCE 419 FLAG_GENERIC(MNT_FORCE), 420 #endif 421 #ifdef MNT_DETACH 422 FLAG_GENERIC(MNT_DETACH), 423 #endif 424 #ifdef MNT_EXPIRE 425 FLAG_GENERIC(MNT_EXPIRE), 426 #endif 427 FLAG_END, 428 }; 429 430 UNUSED static struct flags mmap_prot_flags[] = { 431 FLAG_GENERIC(PROT_NONE), 432 FLAG_GENERIC(PROT_EXEC), 433 FLAG_GENERIC(PROT_READ), 434 FLAG_GENERIC(PROT_WRITE), 435 FLAG_TARGET(PROT_SEM), 436 FLAG_GENERIC(PROT_GROWSDOWN), 437 FLAG_GENERIC(PROT_GROWSUP), 438 FLAG_END, 439 }; 440 441 UNUSED static struct flags mmap_flags[] = { 442 FLAG_TARGET(MAP_SHARED), 443 FLAG_TARGET(MAP_PRIVATE), 444 FLAG_TARGET(MAP_ANONYMOUS), 445 FLAG_TARGET(MAP_DENYWRITE), 446 FLAG_TARGET(MAP_FIXED), 447 FLAG_TARGET(MAP_GROWSDOWN), 448 FLAG_TARGET(MAP_EXECUTABLE), 449 #ifdef MAP_LOCKED 450 FLAG_TARGET(MAP_LOCKED), 451 #endif 452 #ifdef MAP_NONBLOCK 453 FLAG_TARGET(MAP_NONBLOCK), 454 #endif 455 FLAG_TARGET(MAP_NORESERVE), 456 #ifdef MAP_POPULATE 457 FLAG_TARGET(MAP_POPULATE), 458 #endif 459 #ifdef TARGET_MAP_UNINITIALIZED 460 FLAG_TARGET(MAP_UNINITIALIZED), 461 #endif 462 FLAG_END, 463 }; 464 465 UNUSED static struct flags clone_flags[] = { 466 FLAG_GENERIC(CLONE_VM), 467 FLAG_GENERIC(CLONE_FS), 468 FLAG_GENERIC(CLONE_FILES), 469 FLAG_GENERIC(CLONE_SIGHAND), 470 FLAG_GENERIC(CLONE_PTRACE), 471 FLAG_GENERIC(CLONE_VFORK), 472 FLAG_GENERIC(CLONE_PARENT), 473 FLAG_GENERIC(CLONE_THREAD), 474 FLAG_GENERIC(CLONE_NEWNS), 475 FLAG_GENERIC(CLONE_SYSVSEM), 476 FLAG_GENERIC(CLONE_SETTLS), 477 FLAG_GENERIC(CLONE_PARENT_SETTID), 478 FLAG_GENERIC(CLONE_CHILD_CLEARTID), 479 FLAG_GENERIC(CLONE_DETACHED), 480 FLAG_GENERIC(CLONE_UNTRACED), 481 FLAG_GENERIC(CLONE_CHILD_SETTID), 482 #if defined(CLONE_NEWUTS) 483 FLAG_GENERIC(CLONE_NEWUTS), 484 #endif 485 #if defined(CLONE_NEWIPC) 486 FLAG_GENERIC(CLONE_NEWIPC), 487 #endif 488 #if defined(CLONE_NEWUSER) 489 FLAG_GENERIC(CLONE_NEWUSER), 490 #endif 491 #if defined(CLONE_NEWPID) 492 FLAG_GENERIC(CLONE_NEWPID), 493 #endif 494 #if defined(CLONE_NEWNET) 495 FLAG_GENERIC(CLONE_NEWNET), 496 #endif 497 #if defined(CLONE_IO) 498 FLAG_GENERIC(CLONE_IO), 499 #endif 500 FLAG_END, 501 }; 502 503 /* 504 * print_xxx utility functions. These are used to print syscall 505 * parameters in certain format. All of these have parameter 506 * named 'last'. This parameter is used to add comma to output 507 * when last == 0. 508 */ 509 510 static const char * 511 get_comma(int last) 512 { 513 return ((last) ? "" : ","); 514 } 515 516 static void 517 print_flags(const struct flags *f, abi_long flags, int last) 518 { 519 const char *sep = ""; 520 int n; 521 522 if ((flags == 0) && (f->f_value == 0)) { 523 gemu_log("%s%s", f->f_string, get_comma(last)); 524 return; 525 } 526 for (n = 0; f->f_string != NULL; f++) { 527 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { 528 gemu_log("%s%s", sep, f->f_string); 529 flags &= ~f->f_value; 530 sep = "|"; 531 n++; 532 } 533 } 534 535 if (n > 0) { 536 /* print rest of the flags as numeric */ 537 if (flags != 0) { 538 gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); 539 } else { 540 gemu_log("%s", get_comma(last)); 541 } 542 } else { 543 /* no string version of flags found, print them in hex then */ 544 gemu_log("%#x%s", (unsigned int)flags, get_comma(last)); 545 } 546 } 547 548 static void 549 print_at_dirfd(abi_long dirfd, int last) 550 { 551 #ifdef AT_FDCWD 552 if (dirfd == AT_FDCWD) { 553 gemu_log("AT_FDCWD%s", get_comma(last)); 554 return; 555 } 556 #endif 557 gemu_log("%d%s", (int)dirfd, get_comma(last)); 558 } 559 560 static void 561 print_file_mode(abi_long mode, int last) 562 { 563 const char *sep = ""; 564 const struct flags *m; 565 566 for (m = &mode_flags[0]; m->f_string != NULL; m++) { 567 if ((m->f_value & mode) == m->f_value) { 568 gemu_log("%s%s", m->f_string, sep); 569 sep = "|"; 570 mode &= ~m->f_value; 571 break; 572 } 573 } 574 575 mode &= ~S_IFMT; 576 /* print rest of the mode as octal */ 577 if (mode != 0) 578 gemu_log("%s%#o", sep, (unsigned int)mode); 579 580 gemu_log("%s", get_comma(last)); 581 } 582 583 static void 584 print_open_flags(abi_long flags, int last) 585 { 586 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); 587 flags &= ~TARGET_O_ACCMODE; 588 if (flags == 0) { 589 gemu_log("%s", get_comma(last)); 590 return; 591 } 592 gemu_log("|"); 593 print_flags(open_flags, flags, last); 594 } 595 596 static void 597 print_syscall_prologue(const struct syscallname *sc) 598 { 599 gemu_log("%s(", sc->name); 600 } 601 602 /*ARGSUSED*/ 603 static void 604 print_syscall_epilogue(const struct syscallname *sc) 605 { 606 (void)sc; 607 gemu_log(")"); 608 } 609 610 static void 611 print_string(abi_long addr, int last) 612 { 613 char *s; 614 615 if ((s = lock_user_string(addr)) != NULL) { 616 gemu_log("\"%s\"%s", s, get_comma(last)); 617 unlock_user(s, addr, 0); 618 } else { 619 /* can't get string out of it, so print it as pointer */ 620 print_pointer(addr, last); 621 } 622 } 623 624 /* 625 * Prints out raw parameter using given format. Caller needs 626 * to do byte swapping if needed. 627 */ 628 static void 629 print_raw_param(const char *fmt, abi_long param, int last) 630 { 631 char format[64]; 632 633 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); 634 gemu_log(format, param); 635 } 636 637 static void 638 print_pointer(abi_long p, int last) 639 { 640 if (p == 0) 641 gemu_log("NULL%s", get_comma(last)); 642 else 643 gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); 644 } 645 646 /* 647 * Reads 32-bit (int) number from guest address space from 648 * address 'addr' and prints it. 649 */ 650 static void 651 print_number(abi_long addr, int last) 652 { 653 if (addr == 0) { 654 gemu_log("NULL%s", get_comma(last)); 655 } else { 656 int num; 657 658 get_user_s32(num, addr); 659 gemu_log("[%d]%s", num, get_comma(last)); 660 } 661 } 662 663 static void 664 print_timeval(abi_ulong tv_addr, int last) 665 { 666 if( tv_addr ) { 667 struct target_timeval *tv; 668 669 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); 670 if (!tv) 671 return; 672 gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", 673 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); 674 unlock_user(tv, tv_addr, 0); 675 } else 676 gemu_log("NULL%s", get_comma(last)); 677 } 678 679 #undef UNUSED 680 681 #ifdef TARGET_NR_accept 682 static void 683 print_accept(const struct syscallname *name, 684 abi_long arg0, abi_long arg1, abi_long arg2, 685 abi_long arg3, abi_long arg4, abi_long arg5) 686 { 687 print_syscall_prologue(name); 688 print_raw_param("%d", arg0, 0); 689 print_pointer(arg1, 0); 690 print_number(arg2, 1); 691 print_syscall_epilogue(name); 692 } 693 #endif 694 695 #ifdef TARGET_NR_access 696 static void 697 print_access(const struct syscallname *name, 698 abi_long arg0, abi_long arg1, abi_long arg2, 699 abi_long arg3, abi_long arg4, abi_long arg5) 700 { 701 print_syscall_prologue(name); 702 print_string(arg0, 0); 703 print_flags(access_flags, arg1, 1); 704 print_syscall_epilogue(name); 705 } 706 #endif 707 708 #ifdef TARGET_NR_brk 709 static void 710 print_brk(const struct syscallname *name, 711 abi_long arg0, abi_long arg1, abi_long arg2, 712 abi_long arg3, abi_long arg4, abi_long arg5) 713 { 714 print_syscall_prologue(name); 715 print_pointer(arg0, 1); 716 print_syscall_epilogue(name); 717 } 718 #endif 719 720 #ifdef TARGET_NR_chdir 721 static void 722 print_chdir(const struct syscallname *name, 723 abi_long arg0, abi_long arg1, abi_long arg2, 724 abi_long arg3, abi_long arg4, abi_long arg5) 725 { 726 print_syscall_prologue(name); 727 print_string(arg0, 1); 728 print_syscall_epilogue(name); 729 } 730 #endif 731 732 #ifdef TARGET_NR_chmod 733 static void 734 print_chmod(const struct syscallname *name, 735 abi_long arg0, abi_long arg1, abi_long arg2, 736 abi_long arg3, abi_long arg4, abi_long arg5) 737 { 738 print_syscall_prologue(name); 739 print_string(arg0, 0); 740 print_file_mode(arg1, 1); 741 print_syscall_epilogue(name); 742 } 743 #endif 744 745 #ifdef TARGET_NR_clone 746 static void 747 print_clone(const struct syscallname *name, 748 abi_long arg0, abi_long arg1, abi_long arg2, 749 abi_long arg3, abi_long arg4, abi_long arg5) 750 { 751 print_syscall_prologue(name); 752 #if defined(TARGET_M68K) 753 print_flags(clone_flags, arg0, 0); 754 print_raw_param("newsp=0x" TARGET_ABI_FMT_lx, arg1, 1); 755 #elif defined(TARGET_SH4) || defined(TARGET_ALPHA) 756 print_flags(clone_flags, arg0, 0); 757 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0); 758 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); 759 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg3, 0); 760 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg4, 1); 761 #elif defined(TARGET_CRIS) 762 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg0, 0); 763 print_flags(clone_flags, arg1, 0); 764 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); 765 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0); 766 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1); 767 #else 768 print_flags(clone_flags, arg0, 0); 769 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, arg1, 0); 770 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, arg2, 0); 771 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, arg3, 0); 772 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, arg4, 1); 773 #endif 774 print_syscall_epilogue(name); 775 } 776 #endif 777 778 #ifdef TARGET_NR_creat 779 static void 780 print_creat(const struct syscallname *name, 781 abi_long arg0, abi_long arg1, abi_long arg2, 782 abi_long arg3, abi_long arg4, abi_long arg5) 783 { 784 print_syscall_prologue(name); 785 print_string(arg0, 0); 786 print_file_mode(arg1, 1); 787 print_syscall_epilogue(name); 788 } 789 #endif 790 791 #ifdef TARGET_NR_execv 792 static void 793 print_execv(const struct syscallname *name, 794 abi_long arg0, abi_long arg1, abi_long arg2, 795 abi_long arg3, abi_long arg4, abi_long arg5) 796 { 797 print_syscall_prologue(name); 798 print_string(arg0, 0); 799 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); 800 print_syscall_epilogue(name); 801 } 802 #endif 803 804 #ifdef TARGET_NR_faccessat 805 static void 806 print_faccessat(const struct syscallname *name, 807 abi_long arg0, abi_long arg1, abi_long arg2, 808 abi_long arg3, abi_long arg4, abi_long arg5) 809 { 810 print_syscall_prologue(name); 811 print_at_dirfd(arg0, 0); 812 print_string(arg1, 0); 813 print_flags(access_flags, arg2, 0); 814 print_flags(at_file_flags, arg3, 1); 815 print_syscall_epilogue(name); 816 } 817 #endif 818 819 #ifdef TARGET_NR_fchmodat 820 static void 821 print_fchmodat(const struct syscallname *name, 822 abi_long arg0, abi_long arg1, abi_long arg2, 823 abi_long arg3, abi_long arg4, abi_long arg5) 824 { 825 print_syscall_prologue(name); 826 print_at_dirfd(arg0, 0); 827 print_string(arg1, 0); 828 print_file_mode(arg2, 0); 829 print_flags(at_file_flags, arg3, 1); 830 print_syscall_epilogue(name); 831 } 832 #endif 833 834 #ifdef TARGET_NR_fchownat 835 static void 836 print_fchownat(const struct syscallname *name, 837 abi_long arg0, abi_long arg1, abi_long arg2, 838 abi_long arg3, abi_long arg4, abi_long arg5) 839 { 840 print_syscall_prologue(name); 841 print_at_dirfd(arg0, 0); 842 print_string(arg1, 0); 843 print_raw_param("%d", arg2, 0); 844 print_raw_param("%d", arg3, 0); 845 print_flags(at_file_flags, arg4, 1); 846 print_syscall_epilogue(name); 847 } 848 #endif 849 850 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) 851 static void 852 print_fcntl(const struct syscallname *name, 853 abi_long arg0, abi_long arg1, abi_long arg2, 854 abi_long arg3, abi_long arg4, abi_long arg5) 855 { 856 print_syscall_prologue(name); 857 print_raw_param("%d", arg0, 0); 858 switch(arg1) { 859 case TARGET_F_DUPFD: 860 gemu_log("F_DUPFD,"); 861 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 862 break; 863 case TARGET_F_GETFD: 864 gemu_log("F_GETFD"); 865 break; 866 case TARGET_F_SETFD: 867 gemu_log("F_SETFD,"); 868 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 869 break; 870 case TARGET_F_GETFL: 871 gemu_log("F_GETFL"); 872 break; 873 case TARGET_F_SETFL: 874 gemu_log("F_SETFL,"); 875 print_open_flags(arg2, 1); 876 break; 877 case TARGET_F_GETLK: 878 gemu_log("F_GETLK,"); 879 print_pointer(arg2, 1); 880 break; 881 case TARGET_F_SETLK: 882 gemu_log("F_SETLK,"); 883 print_pointer(arg2, 1); 884 break; 885 case TARGET_F_SETLKW: 886 gemu_log("F_SETLKW,"); 887 print_pointer(arg2, 1); 888 break; 889 case TARGET_F_GETOWN: 890 gemu_log("F_GETOWN"); 891 break; 892 case TARGET_F_SETOWN: 893 gemu_log("F_SETOWN,"); 894 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 895 break; 896 case TARGET_F_GETSIG: 897 gemu_log("F_GETSIG"); 898 break; 899 case TARGET_F_SETSIG: 900 gemu_log("F_SETSIG,"); 901 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 902 break; 903 #if TARGET_ABI_BITS == 32 904 case TARGET_F_GETLK64: 905 gemu_log("F_GETLK64,"); 906 print_pointer(arg2, 1); 907 break; 908 case TARGET_F_SETLK64: 909 gemu_log("F_SETLK64,"); 910 print_pointer(arg2, 1); 911 break; 912 case TARGET_F_SETLKW64: 913 gemu_log("F_SETLKW64,"); 914 print_pointer(arg2, 1); 915 break; 916 #endif 917 case TARGET_F_SETLEASE: 918 gemu_log("F_SETLEASE,"); 919 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 920 break; 921 case TARGET_F_GETLEASE: 922 gemu_log("F_GETLEASE"); 923 break; 924 case TARGET_F_DUPFD_CLOEXEC: 925 gemu_log("F_DUPFD_CLOEXEC,"); 926 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 927 break; 928 case TARGET_F_NOTIFY: 929 gemu_log("F_NOTIFY,"); 930 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 931 break; 932 default: 933 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); 934 print_pointer(arg2, 1); 935 break; 936 } 937 print_syscall_epilogue(name); 938 } 939 #define print_fcntl64 print_fcntl 940 #endif 941 942 943 #ifdef TARGET_NR_futimesat 944 static void 945 print_futimesat(const struct syscallname *name, 946 abi_long arg0, abi_long arg1, abi_long arg2, 947 abi_long arg3, abi_long arg4, abi_long arg5) 948 { 949 print_syscall_prologue(name); 950 print_at_dirfd(arg0, 0); 951 print_string(arg1, 0); 952 print_timeval(arg2, 0); 953 print_timeval(arg2 + sizeof (struct target_timeval), 1); 954 print_syscall_epilogue(name); 955 } 956 #endif 957 958 #ifdef TARGET_NR_link 959 static void 960 print_link(const struct syscallname *name, 961 abi_long arg0, abi_long arg1, abi_long arg2, 962 abi_long arg3, abi_long arg4, abi_long arg5) 963 { 964 print_syscall_prologue(name); 965 print_string(arg0, 0); 966 print_string(arg1, 1); 967 print_syscall_epilogue(name); 968 } 969 #endif 970 971 #ifdef TARGET_NR_linkat 972 static void 973 print_linkat(const struct syscallname *name, 974 abi_long arg0, abi_long arg1, abi_long arg2, 975 abi_long arg3, abi_long arg4, abi_long arg5) 976 { 977 print_syscall_prologue(name); 978 print_at_dirfd(arg0, 0); 979 print_string(arg1, 0); 980 print_at_dirfd(arg2, 0); 981 print_string(arg3, 0); 982 print_flags(at_file_flags, arg4, 1); 983 print_syscall_epilogue(name); 984 } 985 #endif 986 987 #ifdef TARGET_NR__llseek 988 static void 989 print__llseek(const struct syscallname *name, 990 abi_long arg0, abi_long arg1, abi_long arg2, 991 abi_long arg3, abi_long arg4, abi_long arg5) 992 { 993 const char *whence = "UNKNOWN"; 994 print_syscall_prologue(name); 995 print_raw_param("%d", arg0, 0); 996 print_raw_param("%ld", arg1, 0); 997 print_raw_param("%ld", arg2, 0); 998 print_pointer(arg3, 0); 999 switch(arg4) { 1000 case SEEK_SET: whence = "SEEK_SET"; break; 1001 case SEEK_CUR: whence = "SEEK_CUR"; break; 1002 case SEEK_END: whence = "SEEK_END"; break; 1003 } 1004 gemu_log("%s",whence); 1005 print_syscall_epilogue(name); 1006 } 1007 #endif 1008 1009 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ 1010 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) 1011 static void 1012 print_stat(const struct syscallname *name, 1013 abi_long arg0, abi_long arg1, abi_long arg2, 1014 abi_long arg3, abi_long arg4, abi_long arg5) 1015 { 1016 print_syscall_prologue(name); 1017 print_string(arg0, 0); 1018 print_pointer(arg1, 1); 1019 print_syscall_epilogue(name); 1020 } 1021 #define print_lstat print_stat 1022 #define print_stat64 print_stat 1023 #define print_lstat64 print_stat 1024 #endif 1025 1026 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) 1027 static void 1028 print_fstat(const struct syscallname *name, 1029 abi_long arg0, abi_long arg1, abi_long arg2, 1030 abi_long arg3, abi_long arg4, abi_long arg5) 1031 { 1032 print_syscall_prologue(name); 1033 print_raw_param("%d", arg0, 0); 1034 print_pointer(arg1, 1); 1035 print_syscall_epilogue(name); 1036 } 1037 #define print_fstat64 print_fstat 1038 #endif 1039 1040 #ifdef TARGET_NR_mkdir 1041 static void 1042 print_mkdir(const struct syscallname *name, 1043 abi_long arg0, abi_long arg1, abi_long arg2, 1044 abi_long arg3, abi_long arg4, abi_long arg5) 1045 { 1046 print_syscall_prologue(name); 1047 print_string(arg0, 0); 1048 print_file_mode(arg1, 1); 1049 print_syscall_epilogue(name); 1050 } 1051 #endif 1052 1053 #ifdef TARGET_NR_mkdirat 1054 static void 1055 print_mkdirat(const struct syscallname *name, 1056 abi_long arg0, abi_long arg1, abi_long arg2, 1057 abi_long arg3, abi_long arg4, abi_long arg5) 1058 { 1059 print_syscall_prologue(name); 1060 print_at_dirfd(arg0, 0); 1061 print_string(arg1, 0); 1062 print_file_mode(arg2, 1); 1063 print_syscall_epilogue(name); 1064 } 1065 #endif 1066 1067 #ifdef TARGET_NR_rmdir 1068 static void 1069 print_rmdir(const struct syscallname *name, 1070 abi_long arg0, abi_long arg1, abi_long arg2, 1071 abi_long arg3, abi_long arg4, abi_long arg5) 1072 { 1073 print_syscall_prologue(name); 1074 print_string(arg0, 0); 1075 print_syscall_epilogue(name); 1076 } 1077 #endif 1078 1079 #ifdef TARGET_NR_rt_sigaction 1080 static void 1081 print_rt_sigaction(const struct syscallname *name, 1082 abi_long arg0, abi_long arg1, abi_long arg2, 1083 abi_long arg3, abi_long arg4, abi_long arg5) 1084 { 1085 print_syscall_prologue(name); 1086 print_signal(arg0, 0); 1087 print_pointer(arg1, 0); 1088 print_pointer(arg2, 1); 1089 print_syscall_epilogue(name); 1090 } 1091 #endif 1092 1093 #ifdef TARGET_NR_rt_sigprocmask 1094 static void 1095 print_rt_sigprocmask(const struct syscallname *name, 1096 abi_long arg0, abi_long arg1, abi_long arg2, 1097 abi_long arg3, abi_long arg4, abi_long arg5) 1098 { 1099 const char *how = "UNKNOWN"; 1100 print_syscall_prologue(name); 1101 switch(arg0) { 1102 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; 1103 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; 1104 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; 1105 } 1106 gemu_log("%s,",how); 1107 print_pointer(arg1, 0); 1108 print_pointer(arg2, 1); 1109 print_syscall_epilogue(name); 1110 } 1111 #endif 1112 1113 #ifdef TARGET_NR_mknod 1114 static void 1115 print_mknod(const struct syscallname *name, 1116 abi_long arg0, abi_long arg1, abi_long arg2, 1117 abi_long arg3, abi_long arg4, abi_long arg5) 1118 { 1119 int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); 1120 1121 print_syscall_prologue(name); 1122 print_string(arg0, 0); 1123 print_file_mode(arg1, (hasdev == 0)); 1124 if (hasdev) { 1125 print_raw_param("makedev(%d", major(arg2), 0); 1126 print_raw_param("%d)", minor(arg2), 1); 1127 } 1128 print_syscall_epilogue(name); 1129 } 1130 #endif 1131 1132 #ifdef TARGET_NR_mknodat 1133 static void 1134 print_mknodat(const struct syscallname *name, 1135 abi_long arg0, abi_long arg1, abi_long arg2, 1136 abi_long arg3, abi_long arg4, abi_long arg5) 1137 { 1138 int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); 1139 1140 print_syscall_prologue(name); 1141 print_at_dirfd(arg0, 0); 1142 print_string(arg1, 0); 1143 print_file_mode(arg2, (hasdev == 0)); 1144 if (hasdev) { 1145 print_raw_param("makedev(%d", major(arg3), 0); 1146 print_raw_param("%d)", minor(arg3), 1); 1147 } 1148 print_syscall_epilogue(name); 1149 } 1150 #endif 1151 1152 #ifdef TARGET_NR_mq_open 1153 static void 1154 print_mq_open(const struct syscallname *name, 1155 abi_long arg0, abi_long arg1, abi_long arg2, 1156 abi_long arg3, abi_long arg4, abi_long arg5) 1157 { 1158 int is_creat = (arg1 & TARGET_O_CREAT); 1159 1160 print_syscall_prologue(name); 1161 print_string(arg0, 0); 1162 print_open_flags(arg1, (is_creat == 0)); 1163 if (is_creat) { 1164 print_file_mode(arg2, 0); 1165 print_pointer(arg3, 1); 1166 } 1167 print_syscall_epilogue(name); 1168 } 1169 #endif 1170 1171 #ifdef TARGET_NR_open 1172 static void 1173 print_open(const struct syscallname *name, 1174 abi_long arg0, abi_long arg1, abi_long arg2, 1175 abi_long arg3, abi_long arg4, abi_long arg5) 1176 { 1177 int is_creat = (arg1 & TARGET_O_CREAT); 1178 1179 print_syscall_prologue(name); 1180 print_string(arg0, 0); 1181 print_open_flags(arg1, (is_creat == 0)); 1182 if (is_creat) 1183 print_file_mode(arg2, 1); 1184 print_syscall_epilogue(name); 1185 } 1186 #endif 1187 1188 #ifdef TARGET_NR_openat 1189 static void 1190 print_openat(const struct syscallname *name, 1191 abi_long arg0, abi_long arg1, abi_long arg2, 1192 abi_long arg3, abi_long arg4, abi_long arg5) 1193 { 1194 int is_creat = (arg2 & TARGET_O_CREAT); 1195 1196 print_syscall_prologue(name); 1197 print_at_dirfd(arg0, 0); 1198 print_string(arg1, 0); 1199 print_open_flags(arg2, (is_creat == 0)); 1200 if (is_creat) 1201 print_file_mode(arg3, 1); 1202 print_syscall_epilogue(name); 1203 } 1204 #endif 1205 1206 #ifdef TARGET_NR_mq_unlink 1207 static void 1208 print_mq_unlink(const struct syscallname *name, 1209 abi_long arg0, abi_long arg1, abi_long arg2, 1210 abi_long arg3, abi_long arg4, abi_long arg5) 1211 { 1212 print_syscall_prologue(name); 1213 print_string(arg0, 1); 1214 print_syscall_epilogue(name); 1215 } 1216 #endif 1217 1218 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) 1219 static void 1220 print_fstatat64(const struct syscallname *name, 1221 abi_long arg0, abi_long arg1, abi_long arg2, 1222 abi_long arg3, abi_long arg4, abi_long arg5) 1223 { 1224 print_syscall_prologue(name); 1225 print_at_dirfd(arg0, 0); 1226 print_string(arg1, 0); 1227 print_pointer(arg2, 0); 1228 print_flags(at_file_flags, arg3, 1); 1229 print_syscall_epilogue(name); 1230 } 1231 #define print_newfstatat print_fstatat64 1232 #endif 1233 1234 #ifdef TARGET_NR_readlink 1235 static void 1236 print_readlink(const struct syscallname *name, 1237 abi_long arg0, abi_long arg1, abi_long arg2, 1238 abi_long arg3, abi_long arg4, abi_long arg5) 1239 { 1240 print_syscall_prologue(name); 1241 print_string(arg0, 0); 1242 print_pointer(arg1, 0); 1243 print_raw_param("%u", arg2, 1); 1244 print_syscall_epilogue(name); 1245 } 1246 #endif 1247 1248 #ifdef TARGET_NR_readlinkat 1249 static void 1250 print_readlinkat(const struct syscallname *name, 1251 abi_long arg0, abi_long arg1, abi_long arg2, 1252 abi_long arg3, abi_long arg4, abi_long arg5) 1253 { 1254 print_syscall_prologue(name); 1255 print_at_dirfd(arg0, 0); 1256 print_string(arg1, 0); 1257 print_pointer(arg2, 0); 1258 print_raw_param("%u", arg3, 1); 1259 print_syscall_epilogue(name); 1260 } 1261 #endif 1262 1263 #ifdef TARGET_NR_rename 1264 static void 1265 print_rename(const struct syscallname *name, 1266 abi_long arg0, abi_long arg1, abi_long arg2, 1267 abi_long arg3, abi_long arg4, abi_long arg5) 1268 { 1269 print_syscall_prologue(name); 1270 print_string(arg0, 0); 1271 print_string(arg1, 1); 1272 print_syscall_epilogue(name); 1273 } 1274 #endif 1275 1276 #ifdef TARGET_NR_renameat 1277 static void 1278 print_renameat(const struct syscallname *name, 1279 abi_long arg0, abi_long arg1, abi_long arg2, 1280 abi_long arg3, abi_long arg4, abi_long arg5) 1281 { 1282 print_syscall_prologue(name); 1283 print_at_dirfd(arg0, 0); 1284 print_string(arg1, 0); 1285 print_at_dirfd(arg2, 0); 1286 print_string(arg3, 1); 1287 print_syscall_epilogue(name); 1288 } 1289 #endif 1290 1291 #ifdef TARGET_NR_statfs 1292 static void 1293 print_statfs(const struct syscallname *name, 1294 abi_long arg0, abi_long arg1, abi_long arg2, 1295 abi_long arg3, abi_long arg4, abi_long arg5) 1296 { 1297 print_syscall_prologue(name); 1298 print_string(arg0, 0); 1299 print_pointer(arg1, 1); 1300 print_syscall_epilogue(name); 1301 } 1302 #define print_statfs64 print_statfs 1303 #endif 1304 1305 #ifdef TARGET_NR_symlink 1306 static void 1307 print_symlink(const struct syscallname *name, 1308 abi_long arg0, abi_long arg1, abi_long arg2, 1309 abi_long arg3, abi_long arg4, abi_long arg5) 1310 { 1311 print_syscall_prologue(name); 1312 print_string(arg0, 0); 1313 print_string(arg1, 1); 1314 print_syscall_epilogue(name); 1315 } 1316 #endif 1317 1318 #ifdef TARGET_NR_symlinkat 1319 static void 1320 print_symlinkat(const struct syscallname *name, 1321 abi_long arg0, abi_long arg1, abi_long arg2, 1322 abi_long arg3, abi_long arg4, abi_long arg5) 1323 { 1324 print_syscall_prologue(name); 1325 print_string(arg0, 0); 1326 print_at_dirfd(arg1, 0); 1327 print_string(arg2, 1); 1328 print_syscall_epilogue(name); 1329 } 1330 #endif 1331 1332 #ifdef TARGET_NR_mount 1333 static void 1334 print_mount(const struct syscallname *name, 1335 abi_long arg0, abi_long arg1, abi_long arg2, 1336 abi_long arg3, abi_long arg4, abi_long arg5) 1337 { 1338 print_syscall_prologue(name); 1339 print_string(arg0, 0); 1340 print_string(arg1, 0); 1341 print_string(arg2, 0); 1342 print_flags(mount_flags, arg3, 0); 1343 print_pointer(arg4, 1); 1344 print_syscall_epilogue(name); 1345 } 1346 #endif 1347 1348 #ifdef TARGET_NR_umount 1349 static void 1350 print_umount(const struct syscallname *name, 1351 abi_long arg0, abi_long arg1, abi_long arg2, 1352 abi_long arg3, abi_long arg4, abi_long arg5) 1353 { 1354 print_syscall_prologue(name); 1355 print_string(arg0, 1); 1356 print_syscall_epilogue(name); 1357 } 1358 #endif 1359 1360 #ifdef TARGET_NR_umount2 1361 static void 1362 print_umount2(const struct syscallname *name, 1363 abi_long arg0, abi_long arg1, abi_long arg2, 1364 abi_long arg3, abi_long arg4, abi_long arg5) 1365 { 1366 print_syscall_prologue(name); 1367 print_string(arg0, 0); 1368 print_flags(umount2_flags, arg1, 1); 1369 print_syscall_epilogue(name); 1370 } 1371 #endif 1372 1373 #ifdef TARGET_NR_unlink 1374 static void 1375 print_unlink(const struct syscallname *name, 1376 abi_long arg0, abi_long arg1, abi_long arg2, 1377 abi_long arg3, abi_long arg4, abi_long arg5) 1378 { 1379 print_syscall_prologue(name); 1380 print_string(arg0, 1); 1381 print_syscall_epilogue(name); 1382 } 1383 #endif 1384 1385 #ifdef TARGET_NR_unlinkat 1386 static void 1387 print_unlinkat(const struct syscallname *name, 1388 abi_long arg0, abi_long arg1, abi_long arg2, 1389 abi_long arg3, abi_long arg4, abi_long arg5) 1390 { 1391 print_syscall_prologue(name); 1392 print_at_dirfd(arg0, 0); 1393 print_string(arg1, 0); 1394 print_flags(unlinkat_flags, arg2, 1); 1395 print_syscall_epilogue(name); 1396 } 1397 #endif 1398 1399 #ifdef TARGET_NR_utime 1400 static void 1401 print_utime(const struct syscallname *name, 1402 abi_long arg0, abi_long arg1, abi_long arg2, 1403 abi_long arg3, abi_long arg4, abi_long arg5) 1404 { 1405 print_syscall_prologue(name); 1406 print_string(arg0, 0); 1407 print_pointer(arg1, 1); 1408 print_syscall_epilogue(name); 1409 } 1410 #endif 1411 1412 #ifdef TARGET_NR_utimes 1413 static void 1414 print_utimes(const struct syscallname *name, 1415 abi_long arg0, abi_long arg1, abi_long arg2, 1416 abi_long arg3, abi_long arg4, abi_long arg5) 1417 { 1418 print_syscall_prologue(name); 1419 print_string(arg0, 0); 1420 print_pointer(arg1, 1); 1421 print_syscall_epilogue(name); 1422 } 1423 #endif 1424 1425 #ifdef TARGET_NR_utimensat 1426 static void 1427 print_utimensat(const struct syscallname *name, 1428 abi_long arg0, abi_long arg1, abi_long arg2, 1429 abi_long arg3, abi_long arg4, abi_long arg5) 1430 { 1431 print_syscall_prologue(name); 1432 print_at_dirfd(arg0, 0); 1433 print_string(arg1, 0); 1434 print_pointer(arg2, 0); 1435 print_flags(at_file_flags, arg3, 1); 1436 print_syscall_epilogue(name); 1437 } 1438 #endif 1439 1440 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) 1441 static void 1442 print_mmap(const struct syscallname *name, 1443 abi_long arg0, abi_long arg1, abi_long arg2, 1444 abi_long arg3, abi_long arg4, abi_long arg5) 1445 { 1446 print_syscall_prologue(name); 1447 print_pointer(arg0, 0); 1448 print_raw_param("%d", arg1, 0); 1449 print_flags(mmap_prot_flags, arg2, 0); 1450 print_flags(mmap_flags, arg3, 0); 1451 print_raw_param("%d", arg4, 0); 1452 print_raw_param("%#x", arg5, 1); 1453 print_syscall_epilogue(name); 1454 } 1455 #define print_mmap2 print_mmap 1456 #endif 1457 1458 #ifdef TARGET_NR_mprotect 1459 static void 1460 print_mprotect(const struct syscallname *name, 1461 abi_long arg0, abi_long arg1, abi_long arg2, 1462 abi_long arg3, abi_long arg4, abi_long arg5) 1463 { 1464 print_syscall_prologue(name); 1465 print_pointer(arg0, 0); 1466 print_raw_param("%d", arg1, 0); 1467 print_flags(mmap_prot_flags, arg2, 1); 1468 print_syscall_epilogue(name); 1469 } 1470 #endif 1471 1472 #ifdef TARGET_NR_munmap 1473 static void 1474 print_munmap(const struct syscallname *name, 1475 abi_long arg0, abi_long arg1, abi_long arg2, 1476 abi_long arg3, abi_long arg4, abi_long arg5) 1477 { 1478 print_syscall_prologue(name); 1479 print_pointer(arg0, 0); 1480 print_raw_param("%d", arg1, 1); 1481 print_syscall_epilogue(name); 1482 } 1483 #endif 1484 1485 #ifdef TARGET_NR_futex 1486 static void print_futex_op(abi_long tflag, int last) 1487 { 1488 #define print_op(val) \ 1489 if( cmd == val ) { \ 1490 gemu_log(#val); \ 1491 return; \ 1492 } 1493 1494 int cmd = (int)tflag; 1495 #ifdef FUTEX_PRIVATE_FLAG 1496 if (cmd & FUTEX_PRIVATE_FLAG) { 1497 gemu_log("FUTEX_PRIVATE_FLAG|"); 1498 cmd &= ~FUTEX_PRIVATE_FLAG; 1499 } 1500 #endif 1501 #ifdef FUTEX_CLOCK_REALTIME 1502 if (cmd & FUTEX_CLOCK_REALTIME) { 1503 gemu_log("FUTEX_CLOCK_REALTIME|"); 1504 cmd &= ~FUTEX_CLOCK_REALTIME; 1505 } 1506 #endif 1507 print_op(FUTEX_WAIT) 1508 print_op(FUTEX_WAKE) 1509 print_op(FUTEX_FD) 1510 print_op(FUTEX_REQUEUE) 1511 print_op(FUTEX_CMP_REQUEUE) 1512 print_op(FUTEX_WAKE_OP) 1513 print_op(FUTEX_LOCK_PI) 1514 print_op(FUTEX_UNLOCK_PI) 1515 print_op(FUTEX_TRYLOCK_PI) 1516 #ifdef FUTEX_WAIT_BITSET 1517 print_op(FUTEX_WAIT_BITSET) 1518 #endif 1519 #ifdef FUTEX_WAKE_BITSET 1520 print_op(FUTEX_WAKE_BITSET) 1521 #endif 1522 /* unknown values */ 1523 gemu_log("%d",cmd); 1524 } 1525 1526 static void 1527 print_futex(const struct syscallname *name, 1528 abi_long arg0, abi_long arg1, abi_long arg2, 1529 abi_long arg3, abi_long arg4, abi_long arg5) 1530 { 1531 print_syscall_prologue(name); 1532 print_pointer(arg0, 0); 1533 print_futex_op(arg1, 0); 1534 print_raw_param(",%d", arg2, 0); 1535 print_pointer(arg3, 0); /* struct timespec */ 1536 print_pointer(arg4, 0); 1537 print_raw_param("%d", arg4, 1); 1538 print_syscall_epilogue(name); 1539 } 1540 #endif 1541 1542 #ifdef TARGET_NR_kill 1543 static void 1544 print_kill(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_raw_param("%d", arg0, 0); 1550 print_signal(arg1, 1); 1551 print_syscall_epilogue(name); 1552 } 1553 #endif 1554 1555 /* 1556 * An array of all of the syscalls we know about 1557 */ 1558 1559 static const struct syscallname scnames[] = { 1560 #include "strace.list" 1561 }; 1562 1563 static int nsyscalls = ARRAY_SIZE(scnames); 1564 1565 /* 1566 * The public interface to this module. 1567 */ 1568 void 1569 print_syscall(int num, 1570 abi_long arg1, abi_long arg2, abi_long arg3, 1571 abi_long arg4, abi_long arg5, abi_long arg6) 1572 { 1573 int i; 1574 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 ")"; 1575 1576 gemu_log("%d ", getpid() ); 1577 1578 for(i=0;i<nsyscalls;i++) 1579 if( scnames[i].nr == num ) { 1580 if( scnames[i].call != NULL ) { 1581 scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6); 1582 } else { 1583 /* XXX: this format system is broken because it uses 1584 host types and host pointers for strings */ 1585 if( scnames[i].format != NULL ) 1586 format = scnames[i].format; 1587 gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6); 1588 } 1589 return; 1590 } 1591 gemu_log("Unknown syscall %d\n", num); 1592 } 1593 1594 1595 void 1596 print_syscall_ret(int num, abi_long ret) 1597 { 1598 int i; 1599 char *errstr = NULL; 1600 1601 for(i=0;i<nsyscalls;i++) 1602 if( scnames[i].nr == num ) { 1603 if( scnames[i].result != NULL ) { 1604 scnames[i].result(&scnames[i],ret); 1605 } else { 1606 if (ret < 0) { 1607 errstr = target_strerror(-ret); 1608 } 1609 if (errstr) { 1610 gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", 1611 -ret, errstr); 1612 } else { 1613 gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); 1614 } 1615 } 1616 break; 1617 } 1618 } 1619