qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

linux-user: Use `qemu_log' for strace

This change switches linux-user strace logging to use the newer `qemu_log`
logging subsystem rather than the older `gemu_log` (notice the "g")
logger. `qemu_log` has several advantages, namely that it allows logging
to a file, and provides a more unified interface for configuration
of logging (via the QEMU_LOG environment variable or options).

This change introduces a new log mask: `LOG_STRACE` which is used for
logging of user-mode strace messages.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Josh Kunz <jkz@google.com>
Message-Id: <20200204025416.111409-3-jkz@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>

authored by

Josh Kunz and committed by
Laurent Vivier
4b25a506 39be5350

+278 -251
+2
include/qemu/log.h
··· 62 62 #define CPU_LOG_TB_OP_IND (1 << 16) 63 63 #define CPU_LOG_TB_FPU (1 << 17) 64 64 #define CPU_LOG_PLUGIN (1 << 18) 65 + /* LOG_STRACE is used for user-mode strace logging. */ 66 + #define LOG_STRACE (1 << 19) 65 67 66 68 /* Lock output for a series of related logs. Since this is not needed 67 69 * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we
+23 -7
linux-user/main.c
··· 61 61 int have_guest_base; 62 62 63 63 /* 64 + * Used to implement backwards-compatibility for the `-strace`, and 65 + * QEMU_STRACE options. Without this, the QEMU_LOG can be overwritten by 66 + * -strace, or vice versa. 67 + */ 68 + static bool enable_strace; 69 + 70 + /* 71 + * The last log mask given by the user in an environment variable or argument. 72 + * Used to support command line arguments overriding environment variables. 73 + */ 74 + static int last_log_mask; 75 + 76 + /* 64 77 * When running 32-on-64 we should make sure we can fit all of the possible 65 78 * guest address space into a contiguous chunk of virtual host memory. 66 79 * ··· 223 236 224 237 static void handle_arg_log(const char *arg) 225 238 { 226 - int mask; 227 - 228 - mask = qemu_str_to_log_mask(arg); 229 - if (!mask) { 239 + last_log_mask = qemu_str_to_log_mask(arg); 240 + if (!last_log_mask) { 230 241 qemu_print_log_usage(stdout); 231 242 exit(EXIT_FAILURE); 232 243 } 233 - qemu_log_needs_buffers(); 234 - qemu_set_log(mask); 235 244 } 236 245 237 246 static void handle_arg_dfilter(const char *arg) ··· 375 384 376 385 static void handle_arg_strace(const char *arg) 377 386 { 378 - do_strace = 1; 387 + enable_strace = true; 379 388 } 380 389 381 390 static void handle_arg_version(const char *arg) ··· 629 638 int i; 630 639 int ret; 631 640 int execfd; 641 + int log_mask; 632 642 unsigned long max_reserved_va; 633 643 634 644 error_init(argv[0]); ··· 660 670 qemu_plugin_add_opts(); 661 671 662 672 optind = parse_args(argc, argv); 673 + 674 + log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); 675 + if (log_mask) { 676 + qemu_log_needs_buffers(); 677 + qemu_set_log(log_mask); 678 + } 663 679 664 680 if (!trace_init_backends()) { 665 681 exit(1);
-1
linux-user/qemu.h
··· 386 386 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- 387 387 */ 388 388 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo); 389 - extern int do_strace; 390 389 391 390 /* signal.c */ 392 391 void process_pending_signals(CPUArchState *cpu_env);
+1 -1
linux-user/signal.c
··· 934 934 handler = sa->_sa_handler; 935 935 } 936 936 937 - if (do_strace) { 937 + if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { 938 938 print_taken_signal(sig, &k->info); 939 939 } 940 940
+243 -236
linux-user/strace.c
··· 12 12 #include <sched.h> 13 13 #include "qemu.h" 14 14 15 - int do_strace=0; 16 - 17 15 struct syscallname { 18 16 int nr; 19 17 const char *name; ··· 80 78 { 81 79 #define output_cmd(val) \ 82 80 if( cmd == val ) { \ 83 - gemu_log(#val); \ 81 + qemu_log(#val); \ 84 82 return; \ 85 83 } 86 84 ··· 120 118 output_cmd( IPC_RMID ); 121 119 122 120 /* Some value we don't recognize */ 123 - gemu_log("%d",cmd); 121 + qemu_log("%d", cmd); 124 122 } 125 123 126 124 static void ··· 151 149 print_raw_param("%ld", arg, last); 152 150 return; 153 151 } 154 - gemu_log("%s%s", signal_name, get_comma(last)); 152 + qemu_log("%s%s", signal_name, get_comma(last)); 155 153 } 156 154 157 155 static void print_si_code(int arg) ··· 184 182 codename = "SI_TKILL"; 185 183 break; 186 184 default: 187 - gemu_log("%d", arg); 185 + qemu_log("%d", arg); 188 186 return; 189 187 } 190 - gemu_log("%s", codename); 188 + qemu_log("%s", codename); 191 189 } 192 190 193 191 static void get_target_siginfo(target_siginfo_t *tinfo, ··· 288 286 int si_type = extract32(tinfo->si_code, 16, 16); 289 287 int si_code = sextract32(tinfo->si_code, 0, 16); 290 288 291 - gemu_log("{si_signo="); 289 + qemu_log("{si_signo="); 292 290 print_signal(tinfo->si_signo, 1); 293 - gemu_log(", si_code="); 291 + qemu_log(", si_code="); 294 292 print_si_code(si_code); 295 293 296 294 switch (si_type) { 297 295 case QEMU_SI_KILL: 298 - gemu_log(", si_pid=%u, si_uid=%u", 296 + qemu_log(", si_pid=%u, si_uid=%u", 299 297 (unsigned int)tinfo->_sifields._kill._pid, 300 298 (unsigned int)tinfo->_sifields._kill._uid); 301 299 break; 302 300 case QEMU_SI_TIMER: 303 - gemu_log(", si_timer1=%u, si_timer2=%u", 301 + qemu_log(", si_timer1=%u, si_timer2=%u", 304 302 tinfo->_sifields._timer._timer1, 305 303 tinfo->_sifields._timer._timer2); 306 304 break; 307 305 case QEMU_SI_POLL: 308 - gemu_log(", si_band=%d, si_fd=%d", 306 + qemu_log(", si_band=%d, si_fd=%d", 309 307 tinfo->_sifields._sigpoll._band, 310 308 tinfo->_sifields._sigpoll._fd); 311 309 break; 312 310 case QEMU_SI_FAULT: 313 - gemu_log(", si_addr="); 311 + qemu_log(", si_addr="); 314 312 print_pointer(tinfo->_sifields._sigfault._addr, 1); 315 313 break; 316 314 case QEMU_SI_CHLD: 317 - gemu_log(", si_pid=%u, si_uid=%u, si_status=%d" 315 + qemu_log(", si_pid=%u, si_uid=%u, si_status=%d" 318 316 ", si_utime=" TARGET_ABI_FMT_ld 319 317 ", si_stime=" TARGET_ABI_FMT_ld, 320 318 (unsigned int)(tinfo->_sifields._sigchld._pid), ··· 324 322 tinfo->_sifields._sigchld._stime); 325 323 break; 326 324 case QEMU_SI_RT: 327 - gemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, 325 + qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, 328 326 (unsigned int)tinfo->_sifields._rt._pid, 329 327 (unsigned int)tinfo->_sifields._rt._uid, 330 328 tinfo->_sifields._rt._sigval.sival_ptr); ··· 332 330 default: 333 331 g_assert_not_reached(); 334 332 } 335 - gemu_log("}"); 333 + qemu_log("}"); 336 334 } 337 335 338 336 static void ··· 349 347 case AF_UNIX: { 350 348 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; 351 349 int i; 352 - gemu_log("{sun_family=AF_UNIX,sun_path=\""); 350 + qemu_log("{sun_family=AF_UNIX,sun_path=\""); 353 351 for (i = 0; i < addrlen - 354 352 offsetof(struct target_sockaddr_un, sun_path) && 355 353 un->sun_path[i]; i++) { 356 - gemu_log("%c", un->sun_path[i]); 354 + qemu_log("%c", un->sun_path[i]); 357 355 } 358 - gemu_log("\"}"); 356 + qemu_log("\"}"); 359 357 break; 360 358 } 361 359 case AF_INET: { 362 360 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; 363 361 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; 364 - gemu_log("{sin_family=AF_INET,sin_port=htons(%d),", 362 + qemu_log("{sin_family=AF_INET,sin_port=htons(%d),", 365 363 ntohs(in->sin_port)); 366 - gemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", 364 + qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", 367 365 c[0], c[1], c[2], c[3]); 368 - gemu_log("}"); 366 + qemu_log("}"); 369 367 break; 370 368 } 371 369 case AF_PACKET: { 372 370 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; 373 371 uint8_t *c = (uint8_t *)&ll->sll_addr; 374 - gemu_log("{sll_family=AF_PACKET," 372 + qemu_log("{sll_family=AF_PACKET," 375 373 "sll_protocol=htons(0x%04x),if%d,pkttype=", 376 374 ntohs(ll->sll_protocol), ll->sll_ifindex); 377 375 switch (ll->sll_pkttype) { 378 376 case PACKET_HOST: 379 - gemu_log("PACKET_HOST"); 377 + qemu_log("PACKET_HOST"); 380 378 break; 381 379 case PACKET_BROADCAST: 382 - gemu_log("PACKET_BROADCAST"); 380 + qemu_log("PACKET_BROADCAST"); 383 381 break; 384 382 case PACKET_MULTICAST: 385 - gemu_log("PACKET_MULTICAST"); 383 + qemu_log("PACKET_MULTICAST"); 386 384 break; 387 385 case PACKET_OTHERHOST: 388 - gemu_log("PACKET_OTHERHOST"); 386 + qemu_log("PACKET_OTHERHOST"); 389 387 break; 390 388 case PACKET_OUTGOING: 391 - gemu_log("PACKET_OUTGOING"); 389 + qemu_log("PACKET_OUTGOING"); 392 390 break; 393 391 default: 394 - gemu_log("%d", ll->sll_pkttype); 392 + qemu_log("%d", ll->sll_pkttype); 395 393 break; 396 394 } 397 - gemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", 395 + qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", 398 396 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); 399 - gemu_log("}"); 397 + qemu_log("}"); 400 398 break; 401 399 } 402 400 case AF_NETLINK: { 403 401 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; 404 - gemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", 402 + qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", 405 403 tswap32(nl->nl_pid), tswap32(nl->nl_groups)); 406 404 break; 407 405 } 408 406 default: 409 - gemu_log("{sa_family=%d, sa_data={", sa->sa_family); 407 + qemu_log("{sa_family=%d, sa_data={", sa->sa_family); 410 408 for (i = 0; i < 13; i++) { 411 - gemu_log("%02x, ", sa->sa_data[i]); 409 + qemu_log("%02x, ", sa->sa_data[i]); 412 410 } 413 - gemu_log("%02x}", sa->sa_data[i]); 414 - gemu_log("}"); 411 + qemu_log("%02x}", sa->sa_data[i]); 412 + qemu_log("}"); 415 413 break; 416 414 } 417 415 unlock_user(sa, addr, 0); 418 416 } else { 419 417 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); 420 418 } 421 - gemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); 419 + qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); 422 420 } 423 421 424 422 static void ··· 426 424 { 427 425 switch (domain) { 428 426 case PF_UNIX: 429 - gemu_log("PF_UNIX"); 427 + qemu_log("PF_UNIX"); 430 428 break; 431 429 case PF_INET: 432 - gemu_log("PF_INET"); 430 + qemu_log("PF_INET"); 433 431 break; 434 432 case PF_NETLINK: 435 - gemu_log("PF_NETLINK"); 433 + qemu_log("PF_NETLINK"); 436 434 break; 437 435 case PF_PACKET: 438 - gemu_log("PF_PACKET"); 436 + qemu_log("PF_PACKET"); 439 437 break; 440 438 default: 441 - gemu_log("%d", domain); 439 + qemu_log("%d", domain); 442 440 break; 443 441 } 444 442 } ··· 448 446 { 449 447 switch (type) { 450 448 case TARGET_SOCK_DGRAM: 451 - gemu_log("SOCK_DGRAM"); 449 + qemu_log("SOCK_DGRAM"); 452 450 break; 453 451 case TARGET_SOCK_STREAM: 454 - gemu_log("SOCK_STREAM"); 452 + qemu_log("SOCK_STREAM"); 455 453 break; 456 454 case TARGET_SOCK_RAW: 457 - gemu_log("SOCK_RAW"); 455 + qemu_log("SOCK_RAW"); 458 456 break; 459 457 case TARGET_SOCK_RDM: 460 - gemu_log("SOCK_RDM"); 458 + qemu_log("SOCK_RDM"); 461 459 break; 462 460 case TARGET_SOCK_SEQPACKET: 463 - gemu_log("SOCK_SEQPACKET"); 461 + qemu_log("SOCK_SEQPACKET"); 464 462 break; 465 463 case TARGET_SOCK_PACKET: 466 - gemu_log("SOCK_PACKET"); 464 + qemu_log("SOCK_PACKET"); 467 465 break; 468 466 } 469 467 } ··· 475 473 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 476 474 switch (protocol) { 477 475 case 0x0003: 478 - gemu_log("ETH_P_ALL"); 476 + qemu_log("ETH_P_ALL"); 479 477 break; 480 478 default: 481 - gemu_log("%d", protocol); 479 + qemu_log("%d", protocol); 482 480 } 483 481 return; 484 482 } ··· 486 484 if (domain == PF_NETLINK) { 487 485 switch (protocol) { 488 486 case NETLINK_ROUTE: 489 - gemu_log("NETLINK_ROUTE"); 487 + qemu_log("NETLINK_ROUTE"); 490 488 break; 491 489 case NETLINK_AUDIT: 492 - gemu_log("NETLINK_AUDIT"); 490 + qemu_log("NETLINK_AUDIT"); 493 491 break; 494 492 case NETLINK_NETFILTER: 495 - gemu_log("NETLINK_NETFILTER"); 493 + qemu_log("NETLINK_NETFILTER"); 496 494 break; 497 495 case NETLINK_KOBJECT_UEVENT: 498 - gemu_log("NETLINK_KOBJECT_UEVENT"); 496 + qemu_log("NETLINK_KOBJECT_UEVENT"); 499 497 break; 500 498 case NETLINK_RDMA: 501 - gemu_log("NETLINK_RDMA"); 499 + qemu_log("NETLINK_RDMA"); 502 500 break; 503 501 case NETLINK_CRYPTO: 504 - gemu_log("NETLINK_CRYPTO"); 502 + qemu_log("NETLINK_CRYPTO"); 505 503 break; 506 504 default: 507 - gemu_log("%d", protocol); 505 + qemu_log("%d", protocol); 508 506 break; 509 507 } 510 508 return; ··· 512 510 513 511 switch (protocol) { 514 512 case IPPROTO_IP: 515 - gemu_log("IPPROTO_IP"); 513 + qemu_log("IPPROTO_IP"); 516 514 break; 517 515 case IPPROTO_TCP: 518 - gemu_log("IPPROTO_TCP"); 516 + qemu_log("IPPROTO_TCP"); 519 517 break; 520 518 case IPPROTO_UDP: 521 - gemu_log("IPPROTO_UDP"); 519 + qemu_log("IPPROTO_UDP"); 522 520 break; 523 521 case IPPROTO_RAW: 524 - gemu_log("IPPROTO_RAW"); 522 + qemu_log("IPPROTO_RAW"); 525 523 break; 526 524 default: 527 - gemu_log("%d", protocol); 525 + qemu_log("%d", protocol); 528 526 break; 529 527 } 530 528 } ··· 536 534 { 537 535 int i; 538 536 539 - gemu_log("["); 537 + qemu_log("["); 540 538 if( target_fds_addr ) { 541 539 abi_long *target_fds; 542 540 ··· 550 548 551 549 for (i=n; i>=0; i--) { 552 550 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) 553 - gemu_log("%d,", i ); 551 + qemu_log("%d,", i); 554 552 } 555 553 unlock_user(target_fds, target_fds_addr, 0); 556 554 } 557 - gemu_log("]"); 555 + qemu_log("]"); 558 556 } 559 557 #endif 560 558 ··· 578 576 { 579 577 switch (clockid) { 580 578 case TARGET_CLOCK_REALTIME: 581 - gemu_log("CLOCK_REALTIME"); 579 + qemu_log("CLOCK_REALTIME"); 582 580 break; 583 581 case TARGET_CLOCK_MONOTONIC: 584 - gemu_log("CLOCK_MONOTONIC"); 582 + qemu_log("CLOCK_MONOTONIC"); 585 583 break; 586 584 case TARGET_CLOCK_PROCESS_CPUTIME_ID: 587 - gemu_log("CLOCK_PROCESS_CPUTIME_ID"); 585 + qemu_log("CLOCK_PROCESS_CPUTIME_ID"); 588 586 break; 589 587 case TARGET_CLOCK_THREAD_CPUTIME_ID: 590 - gemu_log("CLOCK_THREAD_CPUTIME_ID"); 588 + qemu_log("CLOCK_THREAD_CPUTIME_ID"); 591 589 break; 592 590 case TARGET_CLOCK_MONOTONIC_RAW: 593 - gemu_log("CLOCK_MONOTONIC_RAW"); 591 + qemu_log("CLOCK_MONOTONIC_RAW"); 594 592 break; 595 593 case TARGET_CLOCK_REALTIME_COARSE: 596 - gemu_log("CLOCK_REALTIME_COARSE"); 594 + qemu_log("CLOCK_REALTIME_COARSE"); 597 595 break; 598 596 case TARGET_CLOCK_MONOTONIC_COARSE: 599 - gemu_log("CLOCK_MONOTONIC_COARSE"); 597 + qemu_log("CLOCK_MONOTONIC_COARSE"); 600 598 break; 601 599 case TARGET_CLOCK_BOOTTIME: 602 - gemu_log("CLOCK_BOOTTIME"); 600 + qemu_log("CLOCK_BOOTTIME"); 603 601 break; 604 602 case TARGET_CLOCK_REALTIME_ALARM: 605 - gemu_log("CLOCK_REALTIME_ALARM"); 603 + qemu_log("CLOCK_REALTIME_ALARM"); 606 604 break; 607 605 case TARGET_CLOCK_BOOTTIME_ALARM: 608 - gemu_log("CLOCK_BOOTTIME_ALARM"); 606 + qemu_log("CLOCK_BOOTTIME_ALARM"); 609 607 break; 610 608 case TARGET_CLOCK_SGI_CYCLE: 611 - gemu_log("CLOCK_SGI_CYCLE"); 609 + qemu_log("CLOCK_SGI_CYCLE"); 612 610 break; 613 611 case TARGET_CLOCK_TAI: 614 - gemu_log("CLOCK_TAI"); 612 + qemu_log("CLOCK_TAI"); 615 613 break; 616 614 default: 617 - gemu_log("%d", clockid); 615 + qemu_log("%d", clockid); 618 616 break; 619 617 } 620 - gemu_log("%s", get_comma(last)); 618 + qemu_log("%s", get_comma(last)); 621 619 } 622 620 #endif 623 621 ··· 638 636 abi_long arg1, abi_long arg2, abi_long arg3, 639 637 abi_long arg4, abi_long arg5, abi_long arg6) 640 638 { 641 - gemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); 639 + qemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); 642 640 print_fdset(arg1, arg2); 643 - gemu_log(","); 641 + qemu_log(","); 644 642 print_fdset(arg1, arg3); 645 - gemu_log(","); 643 + qemu_log(","); 646 644 print_fdset(arg1, arg4); 647 - gemu_log(","); 645 + qemu_log(","); 648 646 print_timeval(arg5, 1); 649 - gemu_log(")"); 647 + qemu_log(")"); 650 648 651 649 /* save for use in the return output function below */ 652 650 newselect_arg1=arg1; ··· 663 661 abi_long arg1, abi_long arg2, abi_long arg3, 664 662 abi_long arg4, abi_long arg5, abi_long arg6) 665 663 { 666 - gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", name->name, arg1, arg2); 664 + qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", 665 + name->name, arg1, arg2); 667 666 print_ipc_cmd(arg3); 668 - gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 667 + qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 669 668 } 670 669 #endif 671 670 ··· 679 678 680 679 if (!(s = lock_user_string(arg1))) 681 680 return; 682 - gemu_log("%s(\"%s\",{", name->name, s); 681 + qemu_log("%s(\"%s\",{", name->name, s); 683 682 unlock_user(s, arg1, 0); 684 683 685 684 for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { ··· 693 692 if (!arg_addr) 694 693 break; 695 694 if ((s = lock_user_string(arg_addr))) { 696 - gemu_log("\"%s\",", s); 695 + qemu_log("\"%s\",", s); 697 696 unlock_user(s, arg_addr, 0); 698 697 } 699 698 } 700 699 701 - gemu_log("NULL})"); 700 + qemu_log("NULL})"); 702 701 } 703 702 704 703 #ifdef TARGET_NR_ipc ··· 709 708 { 710 709 switch(arg1) { 711 710 case IPCOP_semctl: 712 - gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2); 711 + qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", 712 + arg1, arg2); 713 713 print_ipc_cmd(arg3); 714 - gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 714 + qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 715 715 break; 716 716 default: 717 - gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")", 717 + qemu_log(("%s(" 718 + TARGET_ABI_FMT_ld "," 719 + TARGET_ABI_FMT_ld "," 720 + TARGET_ABI_FMT_ld "," 721 + TARGET_ABI_FMT_ld 722 + ")"), 718 723 name->name, arg1, arg2, arg3, arg4); 719 724 } 720 725 } ··· 733 738 errstr = target_strerror(-ret); 734 739 } 735 740 if (errstr) { 736 - gemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); 741 + qemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); 737 742 } else { 738 - gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 743 + qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 739 744 } 740 745 } 741 746 ··· 743 748 static void 744 749 print_syscall_ret_raw(struct syscallname *name, abi_long ret) 745 750 { 746 - gemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 751 + qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 747 752 } 748 753 #endif 749 754 ··· 751 756 static void 752 757 print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) 753 758 { 754 - gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); 759 + qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); 755 760 print_fdset(newselect_arg1,newselect_arg2); 756 - gemu_log(","); 761 + qemu_log(","); 757 762 print_fdset(newselect_arg1,newselect_arg3); 758 - gemu_log(","); 763 + qemu_log(","); 759 764 print_fdset(newselect_arg1,newselect_arg4); 760 - gemu_log(","); 765 + qemu_log(","); 761 766 print_timeval(newselect_arg5, 1); 762 - gemu_log(")\n"); 767 + qemu_log(")\n"); 763 768 } 764 769 #endif 765 770 ··· 775 780 { 776 781 const char *errstr = NULL; 777 782 778 - gemu_log(" = "); 783 + qemu_log(" = "); 779 784 if (ret < 0) { 780 - gemu_log("-1 errno=%d", errno); 785 + qemu_log("-1 errno=%d", errno); 781 786 errstr = target_strerror(-ret); 782 787 if (errstr) { 783 - gemu_log(" (%s)", errstr); 788 + qemu_log(" (%s)", errstr); 784 789 } 785 790 } else { 786 - gemu_log(TARGET_ABI_FMT_ld, ret); 791 + qemu_log(TARGET_ABI_FMT_ld, ret); 787 792 switch (ret) { 788 793 case TARGET_TIME_OK: 789 - gemu_log(" TIME_OK (clock synchronized, no leap second)"); 794 + qemu_log(" TIME_OK (clock synchronized, no leap second)"); 790 795 break; 791 796 case TARGET_TIME_INS: 792 - gemu_log(" TIME_INS (insert leap second)"); 797 + qemu_log(" TIME_INS (insert leap second)"); 793 798 break; 794 799 case TARGET_TIME_DEL: 795 - gemu_log(" TIME_DEL (delete leap second)"); 800 + qemu_log(" TIME_DEL (delete leap second)"); 796 801 break; 797 802 case TARGET_TIME_OOP: 798 - gemu_log(" TIME_OOP (leap second in progress)"); 803 + qemu_log(" TIME_OOP (leap second in progress)"); 799 804 break; 800 805 case TARGET_TIME_WAIT: 801 - gemu_log(" TIME_WAIT (leap second has occurred)"); 806 + qemu_log(" TIME_WAIT (leap second has occurred)"); 802 807 break; 803 808 case TARGET_TIME_ERROR: 804 - gemu_log(" TIME_ERROR (clock not synchronized)"); 809 + qemu_log(" TIME_ERROR (clock not synchronized)"); 805 810 break; 806 811 } 807 812 } 808 813 809 - gemu_log("\n"); 814 + qemu_log("\n"); 810 815 } 811 816 812 817 UNUSED static struct flags access_flags[] = { ··· 1104 1109 int n; 1105 1110 1106 1111 if ((flags == 0) && (f->f_value == 0)) { 1107 - gemu_log("%s%s", f->f_string, get_comma(last)); 1112 + qemu_log("%s%s", f->f_string, get_comma(last)); 1108 1113 return; 1109 1114 } 1110 1115 for (n = 0; f->f_string != NULL; f++) { 1111 1116 if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { 1112 - gemu_log("%s%s", sep, f->f_string); 1117 + qemu_log("%s%s", sep, f->f_string); 1113 1118 flags &= ~f->f_value; 1114 1119 sep = "|"; 1115 1120 n++; ··· 1119 1124 if (n > 0) { 1120 1125 /* print rest of the flags as numeric */ 1121 1126 if (flags != 0) { 1122 - gemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); 1127 + qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); 1123 1128 } else { 1124 - gemu_log("%s", get_comma(last)); 1129 + qemu_log("%s", get_comma(last)); 1125 1130 } 1126 1131 } else { 1127 1132 /* no string version of flags found, print them in hex then */ 1128 - gemu_log("%#x%s", (unsigned int)flags, get_comma(last)); 1133 + qemu_log("%#x%s", (unsigned int)flags, get_comma(last)); 1129 1134 } 1130 1135 } 1131 1136 ··· 1134 1139 { 1135 1140 #ifdef AT_FDCWD 1136 1141 if (dirfd == AT_FDCWD) { 1137 - gemu_log("AT_FDCWD%s", get_comma(last)); 1142 + qemu_log("AT_FDCWD%s", get_comma(last)); 1138 1143 return; 1139 1144 } 1140 1145 #endif 1141 - gemu_log("%d%s", (int)dirfd, get_comma(last)); 1146 + qemu_log("%d%s", (int)dirfd, get_comma(last)); 1142 1147 } 1143 1148 1144 1149 static void ··· 1149 1154 1150 1155 for (m = &mode_flags[0]; m->f_string != NULL; m++) { 1151 1156 if ((m->f_value & mode) == m->f_value) { 1152 - gemu_log("%s%s", m->f_string, sep); 1157 + qemu_log("%s%s", m->f_string, sep); 1153 1158 sep = "|"; 1154 1159 mode &= ~m->f_value; 1155 1160 break; ··· 1159 1164 mode &= ~S_IFMT; 1160 1165 /* print rest of the mode as octal */ 1161 1166 if (mode != 0) 1162 - gemu_log("%s%#o", sep, (unsigned int)mode); 1167 + qemu_log("%s%#o", sep, (unsigned int)mode); 1163 1168 1164 - gemu_log("%s", get_comma(last)); 1169 + qemu_log("%s", get_comma(last)); 1165 1170 } 1166 1171 1167 1172 static void ··· 1170 1175 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); 1171 1176 flags &= ~TARGET_O_ACCMODE; 1172 1177 if (flags == 0) { 1173 - gemu_log("%s", get_comma(last)); 1178 + qemu_log("%s", get_comma(last)); 1174 1179 return; 1175 1180 } 1176 - gemu_log("|"); 1181 + qemu_log("|"); 1177 1182 print_flags(open_flags, flags, last); 1178 1183 } 1179 1184 1180 1185 static void 1181 1186 print_syscall_prologue(const struct syscallname *sc) 1182 1187 { 1183 - gemu_log("%s(", sc->name); 1188 + qemu_log("%s(", sc->name); 1184 1189 } 1185 1190 1186 1191 /*ARGSUSED*/ ··· 1188 1193 print_syscall_epilogue(const struct syscallname *sc) 1189 1194 { 1190 1195 (void)sc; 1191 - gemu_log(")"); 1196 + qemu_log(")"); 1192 1197 } 1193 1198 1194 1199 static void ··· 1197 1202 char *s; 1198 1203 1199 1204 if ((s = lock_user_string(addr)) != NULL) { 1200 - gemu_log("\"%s\"%s", s, get_comma(last)); 1205 + qemu_log("\"%s\"%s", s, get_comma(last)); 1201 1206 unlock_user(s, addr, 0); 1202 1207 } else { 1203 1208 /* can't get string out of it, so print it as pointer */ ··· 1214 1219 1215 1220 s = lock_user(VERIFY_READ, addr, len, 1); 1216 1221 if (s) { 1217 - gemu_log("\""); 1222 + qemu_log("\""); 1218 1223 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { 1219 1224 if (isprint(s[i])) { 1220 - gemu_log("%c", s[i]); 1225 + qemu_log("%c", s[i]); 1221 1226 } else { 1222 - gemu_log("\\%o", s[i]); 1227 + qemu_log("\\%o", s[i]); 1223 1228 } 1224 1229 } 1225 - gemu_log("\""); 1230 + qemu_log("\""); 1226 1231 if (i != len) { 1227 - gemu_log("..."); 1232 + qemu_log("..."); 1228 1233 } 1229 1234 if (!last) { 1230 - gemu_log(","); 1235 + qemu_log(","); 1231 1236 } 1232 1237 unlock_user(s, addr, 0); 1233 1238 } else { ··· 1245 1250 char format[64]; 1246 1251 1247 1252 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); 1248 - gemu_log(format, param); 1253 + qemu_log(format, param); 1249 1254 } 1250 1255 1251 1256 static void 1252 1257 print_pointer(abi_long p, int last) 1253 1258 { 1254 1259 if (p == 0) 1255 - gemu_log("NULL%s", get_comma(last)); 1260 + qemu_log("NULL%s", get_comma(last)); 1256 1261 else 1257 - gemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); 1262 + qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); 1258 1263 } 1259 1264 1260 1265 /* ··· 1265 1270 print_number(abi_long addr, int last) 1266 1271 { 1267 1272 if (addr == 0) { 1268 - gemu_log("NULL%s", get_comma(last)); 1273 + qemu_log("NULL%s", get_comma(last)); 1269 1274 } else { 1270 1275 int num; 1271 1276 1272 1277 get_user_s32(num, addr); 1273 - gemu_log("[%d]%s", num, get_comma(last)); 1278 + qemu_log("[%d]%s", num, get_comma(last)); 1274 1279 } 1275 1280 } 1276 1281 ··· 1285 1290 print_pointer(tv_addr, last); 1286 1291 return; 1287 1292 } 1288 - gemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", 1293 + qemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", 1289 1294 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); 1290 1295 unlock_user(tv, tv_addr, 0); 1291 1296 } else 1292 - gemu_log("NULL%s", get_comma(last)); 1297 + qemu_log("NULL%s", get_comma(last)); 1293 1298 } 1294 1299 1295 1300 static void ··· 1303 1308 print_pointer(tz_addr, last); 1304 1309 return; 1305 1310 } 1306 - gemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), 1311 + qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), 1307 1312 tswap32(tz->tz_dsttime), get_comma(last)); 1308 1313 unlock_user(tz, tz_addr, 0); 1309 1314 } else { 1310 - gemu_log("NULL%s", get_comma(last)); 1315 + qemu_log("NULL%s", get_comma(last)); 1311 1316 } 1312 1317 } 1313 1318 ··· 1515 1520 print_raw_param("%d", arg0, 0); 1516 1521 switch(arg1) { 1517 1522 case TARGET_F_DUPFD: 1518 - gemu_log("F_DUPFD,"); 1523 + qemu_log("F_DUPFD,"); 1519 1524 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 1520 1525 break; 1521 1526 case TARGET_F_GETFD: 1522 - gemu_log("F_GETFD"); 1527 + qemu_log("F_GETFD"); 1523 1528 break; 1524 1529 case TARGET_F_SETFD: 1525 - gemu_log("F_SETFD,"); 1530 + qemu_log("F_SETFD,"); 1526 1531 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 1527 1532 break; 1528 1533 case TARGET_F_GETFL: 1529 - gemu_log("F_GETFL"); 1534 + qemu_log("F_GETFL"); 1530 1535 break; 1531 1536 case TARGET_F_SETFL: 1532 - gemu_log("F_SETFL,"); 1537 + qemu_log("F_SETFL,"); 1533 1538 print_open_flags(arg2, 1); 1534 1539 break; 1535 1540 case TARGET_F_GETLK: 1536 - gemu_log("F_GETLK,"); 1541 + qemu_log("F_GETLK,"); 1537 1542 print_pointer(arg2, 1); 1538 1543 break; 1539 1544 case TARGET_F_SETLK: 1540 - gemu_log("F_SETLK,"); 1545 + qemu_log("F_SETLK,"); 1541 1546 print_pointer(arg2, 1); 1542 1547 break; 1543 1548 case TARGET_F_SETLKW: 1544 - gemu_log("F_SETLKW,"); 1549 + qemu_log("F_SETLKW,"); 1545 1550 print_pointer(arg2, 1); 1546 1551 break; 1547 1552 case TARGET_F_GETOWN: 1548 - gemu_log("F_GETOWN"); 1553 + qemu_log("F_GETOWN"); 1549 1554 break; 1550 1555 case TARGET_F_SETOWN: 1551 - gemu_log("F_SETOWN,"); 1556 + qemu_log("F_SETOWN,"); 1552 1557 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 1553 1558 break; 1554 1559 case TARGET_F_GETSIG: 1555 - gemu_log("F_GETSIG"); 1560 + qemu_log("F_GETSIG"); 1556 1561 break; 1557 1562 case TARGET_F_SETSIG: 1558 - gemu_log("F_SETSIG,"); 1563 + qemu_log("F_SETSIG,"); 1559 1564 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 1560 1565 break; 1561 1566 #if TARGET_ABI_BITS == 32 1562 1567 case TARGET_F_GETLK64: 1563 - gemu_log("F_GETLK64,"); 1568 + qemu_log("F_GETLK64,"); 1564 1569 print_pointer(arg2, 1); 1565 1570 break; 1566 1571 case TARGET_F_SETLK64: 1567 - gemu_log("F_SETLK64,"); 1572 + qemu_log("F_SETLK64,"); 1568 1573 print_pointer(arg2, 1); 1569 1574 break; 1570 1575 case TARGET_F_SETLKW64: 1571 - gemu_log("F_SETLKW64,"); 1576 + qemu_log("F_SETLKW64,"); 1572 1577 print_pointer(arg2, 1); 1573 1578 break; 1574 1579 #endif 1575 1580 case TARGET_F_SETLEASE: 1576 - gemu_log("F_SETLEASE,"); 1581 + qemu_log("F_SETLEASE,"); 1577 1582 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 1578 1583 break; 1579 1584 case TARGET_F_GETLEASE: 1580 - gemu_log("F_GETLEASE"); 1585 + qemu_log("F_GETLEASE"); 1581 1586 break; 1582 1587 case TARGET_F_SETPIPE_SZ: 1583 - gemu_log("F_SETPIPE_SZ,"); 1588 + qemu_log("F_SETPIPE_SZ,"); 1584 1589 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 1585 1590 break; 1586 1591 case TARGET_F_GETPIPE_SZ: 1587 - gemu_log("F_GETPIPE_SZ"); 1592 + qemu_log("F_GETPIPE_SZ"); 1588 1593 break; 1589 1594 case TARGET_F_DUPFD_CLOEXEC: 1590 - gemu_log("F_DUPFD_CLOEXEC,"); 1595 + qemu_log("F_DUPFD_CLOEXEC,"); 1591 1596 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 1592 1597 break; 1593 1598 case TARGET_F_NOTIFY: 1594 - gemu_log("F_NOTIFY,"); 1599 + qemu_log("F_NOTIFY,"); 1595 1600 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 1596 1601 break; 1597 1602 default: ··· 1679 1684 case SEEK_CUR: whence = "SEEK_CUR"; break; 1680 1685 case SEEK_END: whence = "SEEK_END"; break; 1681 1686 } 1682 - gemu_log("%s",whence); 1687 + qemu_log("%s", whence); 1683 1688 print_syscall_epilogue(name); 1684 1689 } 1685 1690 #endif ··· 1694 1699 1695 1700 print_syscall_prologue(name); 1696 1701 print_socket_domain(domain); 1697 - gemu_log(","); 1702 + qemu_log(","); 1698 1703 print_socket_type(type); 1699 - gemu_log(","); 1704 + qemu_log(","); 1700 1705 if (domain == AF_PACKET || 1701 1706 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 1702 1707 protocol = tswap16(protocol); ··· 1728 1733 get_user_ualx(domain, arg1, 0); 1729 1734 get_user_ualx(type, arg1, 1); 1730 1735 get_user_ualx(protocol, arg1, 2); 1731 - gemu_log("%s(", name); 1736 + qemu_log("%s(", name); 1732 1737 print_socket_domain(domain); 1733 - gemu_log(","); 1738 + qemu_log(","); 1734 1739 print_socket_type(type); 1735 - gemu_log(","); 1740 + qemu_log(","); 1736 1741 if (domain == AF_PACKET || 1737 1742 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 1738 1743 protocol = tswap16(protocol); 1739 1744 } 1740 1745 print_socket_protocol(domain, type, protocol); 1741 - gemu_log(")"); 1746 + qemu_log(")"); 1742 1747 } 1743 1748 1744 1749 static void do_print_sockaddr(const char *name, abi_long arg1) ··· 1749 1754 get_user_ualx(addr, arg1, 1); 1750 1755 get_user_ualx(addrlen, arg1, 2); 1751 1756 1752 - gemu_log("%s(", name); 1757 + qemu_log("%s(", name); 1753 1758 print_sockfd(sockfd, 0); 1754 1759 print_sockaddr(addr, addrlen, 0); 1755 - gemu_log(")"); 1760 + qemu_log(")"); 1756 1761 } 1757 1762 1758 1763 static void do_print_listen(const char *name, abi_long arg1) ··· 1762 1767 get_user_ualx(sockfd, arg1, 0); 1763 1768 get_user_ualx(backlog, arg1, 1); 1764 1769 1765 - gemu_log("%s(", name); 1770 + qemu_log("%s(", name); 1766 1771 print_sockfd(sockfd, 0); 1767 1772 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); 1768 - gemu_log(")"); 1773 + qemu_log(")"); 1769 1774 } 1770 1775 1771 1776 static void do_print_socketpair(const char *name, abi_long arg1) ··· 1777 1782 get_user_ualx(protocol, arg1, 2); 1778 1783 get_user_ualx(tab, arg1, 3); 1779 1784 1780 - gemu_log("%s(", name); 1785 + qemu_log("%s(", name); 1781 1786 print_socket_domain(domain); 1782 - gemu_log(","); 1787 + qemu_log(","); 1783 1788 print_socket_type(type); 1784 - gemu_log(","); 1789 + qemu_log(","); 1785 1790 print_socket_protocol(domain, type, protocol); 1786 - gemu_log(","); 1791 + qemu_log(","); 1787 1792 print_raw_param(TARGET_ABI_FMT_lx, tab, 1); 1788 - gemu_log(")"); 1793 + qemu_log(")"); 1789 1794 } 1790 1795 1791 1796 static void do_print_sendrecv(const char *name, abi_long arg1) ··· 1797 1802 get_user_ualx(len, arg1, 2); 1798 1803 get_user_ualx(flags, arg1, 3); 1799 1804 1800 - gemu_log("%s(", name); 1805 + qemu_log("%s(", name); 1801 1806 print_sockfd(sockfd, 0); 1802 1807 print_buf(msg, len, 0); 1803 1808 print_raw_param(TARGET_ABI_FMT_ld, len, 0); 1804 1809 print_flags(msg_flags, flags, 1); 1805 - gemu_log(")"); 1810 + qemu_log(")"); 1806 1811 } 1807 1812 1808 1813 static void do_print_msgaddr(const char *name, abi_long arg1) ··· 1816 1821 get_user_ualx(addr, arg1, 4); 1817 1822 get_user_ualx(addrlen, arg1, 5); 1818 1823 1819 - gemu_log("%s(", name); 1824 + qemu_log("%s(", name); 1820 1825 print_sockfd(sockfd, 0); 1821 1826 print_buf(msg, len, 0); 1822 1827 print_raw_param(TARGET_ABI_FMT_ld, len, 0); 1823 1828 print_flags(msg_flags, flags, 0); 1824 1829 print_sockaddr(addr, addrlen, 0); 1825 - gemu_log(")"); 1830 + qemu_log(")"); 1826 1831 } 1827 1832 1828 1833 static void do_print_shutdown(const char *name, abi_long arg1) ··· 1832 1837 get_user_ualx(sockfd, arg1, 0); 1833 1838 get_user_ualx(how, arg1, 1); 1834 1839 1835 - gemu_log("shutdown("); 1840 + qemu_log("shutdown("); 1836 1841 print_sockfd(sockfd, 0); 1837 1842 switch (how) { 1838 1843 case SHUT_RD: 1839 - gemu_log("SHUT_RD"); 1844 + qemu_log("SHUT_RD"); 1840 1845 break; 1841 1846 case SHUT_WR: 1842 - gemu_log("SHUT_WR"); 1847 + qemu_log("SHUT_WR"); 1843 1848 break; 1844 1849 case SHUT_RDWR: 1845 - gemu_log("SHUT_RDWR"); 1850 + qemu_log("SHUT_RDWR"); 1846 1851 break; 1847 1852 default: 1848 1853 print_raw_param(TARGET_ABI_FMT_ld, how, 1); 1849 1854 break; 1850 1855 } 1851 - gemu_log(")"); 1856 + qemu_log(")"); 1852 1857 } 1853 1858 1854 1859 static void do_print_msg(const char *name, abi_long arg1) ··· 1859 1864 get_user_ualx(msg, arg1, 1); 1860 1865 get_user_ualx(flags, arg1, 2); 1861 1866 1862 - gemu_log("%s(", name); 1867 + qemu_log("%s(", name); 1863 1868 print_sockfd(sockfd, 0); 1864 1869 print_pointer(msg, 0); 1865 1870 print_flags(msg_flags, flags, 1); 1866 - gemu_log(")"); 1871 + qemu_log(")"); 1867 1872 } 1868 1873 1869 1874 static void do_print_sockopt(const char *name, abi_long arg1) ··· 1876 1881 get_user_ualx(optval, arg1, 3); 1877 1882 get_user_ualx(optlen, arg1, 4); 1878 1883 1879 - gemu_log("%s(", name); 1884 + qemu_log("%s(", name); 1880 1885 print_sockfd(sockfd, 0); 1881 1886 switch (level) { 1882 1887 case SOL_TCP: 1883 - gemu_log("SOL_TCP,"); 1888 + qemu_log("SOL_TCP,"); 1884 1889 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 1885 1890 print_pointer(optval, 0); 1886 1891 break; 1887 1892 case SOL_IP: 1888 - gemu_log("SOL_IP,"); 1893 + qemu_log("SOL_IP,"); 1889 1894 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 1890 1895 print_pointer(optval, 0); 1891 1896 break; 1892 1897 case SOL_RAW: 1893 - gemu_log("SOL_RAW,"); 1898 + qemu_log("SOL_RAW,"); 1894 1899 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 1895 1900 print_pointer(optval, 0); 1896 1901 break; 1897 1902 case TARGET_SOL_SOCKET: 1898 - gemu_log("SOL_SOCKET,"); 1903 + qemu_log("SOL_SOCKET,"); 1899 1904 switch (optname) { 1900 1905 case TARGET_SO_DEBUG: 1901 - gemu_log("SO_DEBUG,"); 1906 + qemu_log("SO_DEBUG,"); 1902 1907 print_optint: 1903 1908 print_number(optval, 0); 1904 1909 break; 1905 1910 case TARGET_SO_REUSEADDR: 1906 - gemu_log("SO_REUSEADDR,"); 1911 + qemu_log("SO_REUSEADDR,"); 1907 1912 goto print_optint; 1908 1913 case TARGET_SO_REUSEPORT: 1909 - gemu_log("SO_REUSEPORT,"); 1914 + qemu_log("SO_REUSEPORT,"); 1910 1915 goto print_optint; 1911 1916 case TARGET_SO_TYPE: 1912 - gemu_log("SO_TYPE,"); 1917 + qemu_log("SO_TYPE,"); 1913 1918 goto print_optint; 1914 1919 case TARGET_SO_ERROR: 1915 - gemu_log("SO_ERROR,"); 1920 + qemu_log("SO_ERROR,"); 1916 1921 goto print_optint; 1917 1922 case TARGET_SO_DONTROUTE: 1918 - gemu_log("SO_DONTROUTE,"); 1923 + qemu_log("SO_DONTROUTE,"); 1919 1924 goto print_optint; 1920 1925 case TARGET_SO_BROADCAST: 1921 - gemu_log("SO_BROADCAST,"); 1926 + qemu_log("SO_BROADCAST,"); 1922 1927 goto print_optint; 1923 1928 case TARGET_SO_SNDBUF: 1924 - gemu_log("SO_SNDBUF,"); 1929 + qemu_log("SO_SNDBUF,"); 1925 1930 goto print_optint; 1926 1931 case TARGET_SO_RCVBUF: 1927 - gemu_log("SO_RCVBUF,"); 1932 + qemu_log("SO_RCVBUF,"); 1928 1933 goto print_optint; 1929 1934 case TARGET_SO_KEEPALIVE: 1930 - gemu_log("SO_KEEPALIVE,"); 1935 + qemu_log("SO_KEEPALIVE,"); 1931 1936 goto print_optint; 1932 1937 case TARGET_SO_OOBINLINE: 1933 - gemu_log("SO_OOBINLINE,"); 1938 + qemu_log("SO_OOBINLINE,"); 1934 1939 goto print_optint; 1935 1940 case TARGET_SO_NO_CHECK: 1936 - gemu_log("SO_NO_CHECK,"); 1941 + qemu_log("SO_NO_CHECK,"); 1937 1942 goto print_optint; 1938 1943 case TARGET_SO_PRIORITY: 1939 - gemu_log("SO_PRIORITY,"); 1944 + qemu_log("SO_PRIORITY,"); 1940 1945 goto print_optint; 1941 1946 case TARGET_SO_BSDCOMPAT: 1942 - gemu_log("SO_BSDCOMPAT,"); 1947 + qemu_log("SO_BSDCOMPAT,"); 1943 1948 goto print_optint; 1944 1949 case TARGET_SO_PASSCRED: 1945 - gemu_log("SO_PASSCRED,"); 1950 + qemu_log("SO_PASSCRED,"); 1946 1951 goto print_optint; 1947 1952 case TARGET_SO_TIMESTAMP: 1948 - gemu_log("SO_TIMESTAMP,"); 1953 + qemu_log("SO_TIMESTAMP,"); 1949 1954 goto print_optint; 1950 1955 case TARGET_SO_RCVLOWAT: 1951 - gemu_log("SO_RCVLOWAT,"); 1956 + qemu_log("SO_RCVLOWAT,"); 1952 1957 goto print_optint; 1953 1958 case TARGET_SO_RCVTIMEO: 1954 - gemu_log("SO_RCVTIMEO,"); 1959 + qemu_log("SO_RCVTIMEO,"); 1955 1960 print_timeval(optval, 0); 1956 1961 break; 1957 1962 case TARGET_SO_SNDTIMEO: 1958 - gemu_log("SO_SNDTIMEO,"); 1963 + qemu_log("SO_SNDTIMEO,"); 1959 1964 print_timeval(optval, 0); 1960 1965 break; 1961 1966 case TARGET_SO_ATTACH_FILTER: { 1962 1967 struct target_sock_fprog *fprog; 1963 1968 1964 - gemu_log("SO_ATTACH_FILTER,"); 1969 + qemu_log("SO_ATTACH_FILTER,"); 1965 1970 1966 1971 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { 1967 1972 struct target_sock_filter *filter; 1968 - gemu_log("{"); 1973 + qemu_log("{"); 1969 1974 if (lock_user_struct(VERIFY_READ, filter, 1970 1975 tswapal(fprog->filter), 0)) { 1971 1976 int i; 1972 1977 for (i = 0; i < tswap16(fprog->len) - 1; i++) { 1973 - gemu_log("[%d]{0x%x,%d,%d,0x%x},", 1978 + qemu_log("[%d]{0x%x,%d,%d,0x%x},", 1974 1979 i, tswap16(filter[i].code), 1975 1980 filter[i].jt, filter[i].jf, 1976 1981 tswap32(filter[i].k)); 1977 1982 } 1978 - gemu_log("[%d]{0x%x,%d,%d,0x%x}", 1983 + qemu_log("[%d]{0x%x,%d,%d,0x%x}", 1979 1984 i, tswap16(filter[i].code), 1980 1985 filter[i].jt, filter[i].jf, 1981 1986 tswap32(filter[i].k)); 1982 1987 } else { 1983 - gemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); 1988 + qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); 1984 1989 } 1985 - gemu_log(",%d},", tswap16(fprog->len)); 1990 + qemu_log(",%d},", tswap16(fprog->len)); 1986 1991 unlock_user(fprog, optval, 0); 1987 1992 } else { 1988 1993 print_pointer(optval, 0); ··· 2002 2007 break; 2003 2008 } 2004 2009 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); 2005 - gemu_log(")"); 2010 + qemu_log(")"); 2006 2011 } 2007 2012 2008 2013 #define PRINT_SOCKOP(name, func) \ ··· 2164 2169 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; 2165 2170 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; 2166 2171 } 2167 - gemu_log("%s,",how); 2172 + qemu_log("%s,", how); 2168 2173 print_pointer(arg1, 0); 2169 2174 print_pointer(arg2, 1); 2170 2175 print_syscall_epilogue(name); ··· 2278 2283 return; 2279 2284 } 2280 2285 } 2281 - gemu_log("%s%s", type, get_comma(last)); 2286 + qemu_log("%s%s", type, get_comma(last)); 2282 2287 } 2283 2288 2284 2289 static void ··· 2683 2688 { 2684 2689 #define print_op(val) \ 2685 2690 if( cmd == val ) { \ 2686 - gemu_log(#val); \ 2691 + qemu_log(#val); \ 2687 2692 return; \ 2688 2693 } 2689 2694 2690 2695 int cmd = (int)tflag; 2691 2696 #ifdef FUTEX_PRIVATE_FLAG 2692 2697 if (cmd & FUTEX_PRIVATE_FLAG) { 2693 - gemu_log("FUTEX_PRIVATE_FLAG|"); 2698 + qemu_log("FUTEX_PRIVATE_FLAG|"); 2694 2699 cmd &= ~FUTEX_PRIVATE_FLAG; 2695 2700 } 2696 2701 #endif 2697 2702 #ifdef FUTEX_CLOCK_REALTIME 2698 2703 if (cmd & FUTEX_CLOCK_REALTIME) { 2699 - gemu_log("FUTEX_CLOCK_REALTIME|"); 2704 + qemu_log("FUTEX_CLOCK_REALTIME|"); 2700 2705 cmd &= ~FUTEX_CLOCK_REALTIME; 2701 2706 } 2702 2707 #endif ··· 2716 2721 print_op(FUTEX_WAKE_BITSET) 2717 2722 #endif 2718 2723 /* unknown values */ 2719 - gemu_log("%d",cmd); 2724 + qemu_log("%d", cmd); 2720 2725 } 2721 2726 2722 2727 static void ··· 2812 2817 int i; 2813 2818 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 ")"; 2814 2819 2815 - gemu_log("%d ", getpid() ); 2820 + qemu_log("%d ", getpid()); 2816 2821 2817 2822 for(i=0;i<nsyscalls;i++) 2818 2823 if( scnames[i].nr == num ) { 2819 2824 if( scnames[i].call != NULL ) { 2820 - scnames[i].call(&scnames[i],arg1,arg2,arg3,arg4,arg5,arg6); 2825 + scnames[i].call( 2826 + &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6); 2821 2827 } else { 2822 2828 /* XXX: this format system is broken because it uses 2823 2829 host types and host pointers for strings */ 2824 2830 if( scnames[i].format != NULL ) 2825 2831 format = scnames[i].format; 2826 - gemu_log(format,scnames[i].name, arg1,arg2,arg3,arg4,arg5,arg6); 2832 + qemu_log(format, 2833 + scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6); 2827 2834 } 2828 2835 return; 2829 2836 } 2830 - gemu_log("Unknown syscall %d\n", num); 2837 + qemu_log("Unknown syscall %d\n", num); 2831 2838 } 2832 2839 2833 2840 ··· 2840 2847 for(i=0;i<nsyscalls;i++) 2841 2848 if( scnames[i].nr == num ) { 2842 2849 if( scnames[i].result != NULL ) { 2843 - scnames[i].result(&scnames[i],ret); 2850 + scnames[i].result(&scnames[i], ret); 2844 2851 } else { 2845 2852 if (ret < 0) { 2846 2853 errstr = target_strerror(-ret); 2847 2854 } 2848 2855 if (errstr) { 2849 - gemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", 2856 + qemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", 2850 2857 -ret, errstr); 2851 2858 } else { 2852 - gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); 2859 + qemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); 2853 2860 } 2854 2861 } 2855 2862 break; ··· 2861 2868 /* Print the strace output for a signal being taken: 2862 2869 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- 2863 2870 */ 2864 - gemu_log("--- "); 2871 + qemu_log("--- "); 2865 2872 print_signal(target_signum, 1); 2866 - gemu_log(" "); 2873 + qemu_log(" "); 2867 2874 print_siginfo(tinfo); 2868 - gemu_log(" ---\n"); 2875 + qemu_log(" ---\n"); 2869 2876 }
+7 -6
linux-user/syscall.c
··· 12171 12171 record_syscall_start(cpu, num, arg1, 12172 12172 arg2, arg3, arg4, arg5, arg6, arg7, arg8); 12173 12173 12174 - if (unlikely(do_strace)) { 12174 + if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { 12175 12175 print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); 12176 - ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, 12177 - arg5, arg6, arg7, arg8); 12176 + } 12177 + 12178 + ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, 12179 + arg5, arg6, arg7, arg8); 12180 + 12181 + if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { 12178 12182 print_syscall_ret(num, ret); 12179 - } else { 12180 - ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, 12181 - arg5, arg6, arg7, arg8); 12182 12183 } 12183 12184 12184 12185 record_syscall_return(cpu, num, ret);
+2
util/log.c
··· 332 332 #ifdef CONFIG_PLUGIN 333 333 { CPU_LOG_PLUGIN, "plugin", "output from TCG plugins\n"}, 334 334 #endif 335 + { LOG_STRACE, "strace", 336 + "log every user-mode syscall, its input, and its result" }, 335 337 { 0, NULL, NULL }, 336 338 }; 337 339