- Timestamp:
- Apr 22, 2014 11:33:47 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxUSB/darwin/VBoxUSB.cpp
r51107 r51116 66 66 RT_C_DECLS_END 67 67 68 /* Temporary: Extra logging */ 69 #ifdef Log 70 # undef Log 71 #endif 72 #define Log LogRel 73 #ifdef Log2 74 # undef Log2 75 #endif 76 #define Log2 LogRel 77 /* Temporary: needed for extra debug info */ 78 #define VBOX_PROC_SELFNAME_LEN (20) 79 68 80 69 81 /******************************************************************************* … … 133 145 virtual void stop(IOService *pProvider); 134 146 virtual void free(); 147 virtual void retain() const; 148 virtual void release(int freeWhen) const; 149 virtual void taggedRetain(const void *pTag=0) const; 150 virtual void taggedRelease(const void *pTag, const int freeWhen) const; 135 151 virtual IOExternalMethod *getTargetAndMethodForIndex(IOService **ppService, UInt32 iMethod); 136 152 /** @} */ … … 446 462 { 447 463 uint32_t cInstances = ASMAtomicIncU32(&g_cInstances); 448 Log(("VBoxUSB::init([%p], %p) new g_cInstances=%d \n", this, pDictionary, cInstances));464 Log(("VBoxUSB::init([%p], %p) new g_cInstances=%d [retain count: %d]\n", this, pDictionary, cInstances, getRetainCount())); 449 465 if (IOService::init(pDictionary)) 450 466 { 451 467 /* init members. */ 468 Log(("VBoxUSB::init([%p], %p) returns true [retain count: %d]\n", this, pDictionary, getRetainCount())); 452 469 return true; 453 470 } 454 471 ASMAtomicDecU32(&g_cInstances); 472 Log(("VBoxUSB::init([%p], %p) returns false [retain count: %d]\n", this, pDictionary, getRetainCount())); 455 473 return false; 456 474 } … … 465 483 { 466 484 uint32_t cInstances = ASMAtomicDecU32(&g_cInstances); NOREF(cInstances); 467 Log(("VBoxUSB::free([%p]) new g_cInstances=%d \n", this, cInstances));485 Log(("VBoxUSB::free([%p]) new g_cInstances=%d [retain count: %d]\n", this, cInstances, getRetainCount())); 468 486 IOService::free(); 469 487 } … … 476 494 org_virtualbox_VBoxUSB::start(IOService *pProvider) 477 495 { 478 Log(("VBoxUSB::start([%p], %p {%s}) \n", this, pProvider, pProvider->getName()));496 Log(("VBoxUSB::start([%p], %p {%s}) [retain count: %d]\n", this, pProvider, pProvider->getName(), getRetainCount())); 479 497 480 498 if (IOService::start(pProvider)) … … 482 500 /* register the service. */ 483 501 registerService(); 502 Log(("VBoxUSB::start([%p], %p {%s}) returns true [retain count: %d]\n", this, pProvider, pProvider->getName(), getRetainCount())); 484 503 return true; 485 504 } 505 506 Log(("VBoxUSB::start([%p], %p {%s}) returns false [retain count: %d]\n", this, pProvider, pProvider->getName(), getRetainCount())); 486 507 return false; 487 508 } … … 495 516 org_virtualbox_VBoxUSB::stop(IOService *pProvider) 496 517 { 497 Log(("VBoxUSB::stop([%p], %p (%s)) \n", this, pProvider, pProvider->getName()));518 Log(("VBoxUSB::stop([%p], %p (%s)) (1) [retain count: %d]\n", this, pProvider, pProvider->getName(), getRetainCount())); 498 519 IOService::stop(pProvider); 520 Log(("VBoxUSB::stop([%p], %p (%s)) (2) [retain count: %d]\n", this, pProvider, pProvider->getName(), getRetainCount())); 499 521 } 500 522 … … 507 529 org_virtualbox_VBoxUSB::open(IOService *pForClient, IOOptionBits fOptions/* = 0*/, void *pvArg/* = 0*/) 508 530 { 509 Log(("VBoxUSB::open([%p], %p, %#x, %p) \n", this, pForClient, fOptions, pvArg));531 Log(("VBoxUSB::open([%p], %p, %#x, %p) [retain count: %d]\n", this, pForClient, fOptions, pvArg, getRetainCount())); 510 532 bool fRc = IOService::open(pForClient, fOptions, pvArg); 511 Log(("VBoxUSB::open([%p], %p, %#x, %p) -> %d \n", this, pForClient, fOptions, pvArg, fRc));533 Log(("VBoxUSB::open([%p], %p, %#x, %p) -> %d [retain count: %d]\n", this, pForClient, fOptions, pvArg, fRc, getRetainCount())); 512 534 return fRc; 513 535 } … … 521 543 org_virtualbox_VBoxUSB::close(IOService *pForClient, IOOptionBits fOptions/* = 0*/) 522 544 { 523 Log(("VBoxUSB::close([%p], %p, %#x)\n", this, pForClient, fOptions));524 545 IOService::close(pForClient, fOptions); 546 Log(("VBoxUSB::close([%p], %p, %#x) [retain count: %d]\n", this, pForClient, fOptions, getRetainCount())); 525 547 } 526 548 … … 533 555 org_virtualbox_VBoxUSB::terminate(IOOptionBits fOptions) 534 556 { 535 Log(("VBoxUSB::terminate([%p], %#x): g_cInstances=%d \n", this, fOptions, g_cInstances));557 Log(("VBoxUSB::terminate([%p], %#x): g_cInstances=%d [retain count: %d]\n", this, fOptions, g_cInstances, getRetainCount())); 536 558 bool fRc = IOService::terminate(fOptions); 537 Log(("VBoxUSB::terminate([%p], %#x): returns %d \n", this, fOptions, fRc));559 Log(("VBoxUSB::terminate([%p], %#x): returns %d [retain count: %d]\n", this, fOptions, fRc, getRetainCount())); 538 560 return fRc; 539 561 } … … 564 586 if (!OwningTask) 565 587 { 566 Log(("VBoxUSBClient::initWithTask([%p], %p, %p, %#x) -> false (no task) \n", this, OwningTask, pvSecurityId, u32Type));588 Log(("VBoxUSBClient::initWithTask([%p], %p, %p, %#x) -> false (no task) [retain count: %d]\n", this, OwningTask, pvSecurityId, u32Type, getRetainCount())); 567 589 return false; 568 590 } 591 592 char pszProcName[VBOX_PROC_SELFNAME_LEN]; 593 proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN); 594 569 595 proc_t pProc = (proc_t)get_bsdtask_info(OwningTask); /* we need the pid */ 570 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d }, %p, %#x)\n",571 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, p vSecurityId, u32Type));596 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d (%s)}, %p, %#x) [retain count: %d]\n", 597 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, pszProcName, pvSecurityId, u32Type, getRetainCount())); 572 598 573 599 if (IOUserClient::initWithTask(OwningTask, pvSecurityId , u32Type)) … … 579 605 580 606 uint32_t cInstances = ASMAtomicIncU32(&g_cInstances); 581 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d }, %p, %#x) -> true; new g_cInstances=%d\n",582 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, p vSecurityId, u32Type, cInstances));607 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d (%s)}, %p, %#x) -> true; new g_cInstances=%d [retain count: %d]\n", 608 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, pszProcName, pvSecurityId, u32Type, cInstances, getRetainCount())); 583 609 return true; 584 610 } 585 611 586 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d }, %p, %#x) -> false\n",587 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, p vSecurityId, u32Type));612 Log(("VBoxUSBClient::initWithTask([%p], %p(->%p:{.pid=%d (%s)}, %p, %#x) -> false [retain count: %d]\n", 613 this, OwningTask, pProc, pProc ? proc_pid(pProc) : -1, pszProcName, pvSecurityId, u32Type, getRetainCount())); 588 614 return false; 589 615 } … … 598 624 { 599 625 uint32_t cInstances = ASMAtomicDecU32(&g_cInstances); NOREF(cInstances); 600 Log(("VBoxUSBClient::free([%p]) new g_cInstances=%d \n", this, cInstances));626 Log(("VBoxUSBClient::free([%p]) new g_cInstances=%d [retain count: %d]\n", this, cInstances, getRetainCount())); 601 627 IOUserClient::free(); 628 } 629 630 631 /** 632 * Retain the object. 633 * @remark Only for logging. 634 */ 635 void 636 org_virtualbox_VBoxUSBClient::retain() const 637 { 638 char pszProcName[VBOX_PROC_SELFNAME_LEN]; 639 proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN); 640 641 Log(("VBoxUSBClient::retain([%p]) (1) pszProcName=[%s] [retain count: %d]\n", this, pszProcName, getRetainCount())); 642 IOUserClient::retain(); 643 Log(("VBoxUSBClient::retain([%p]) (2) pszProcName=[%s] [retain count: %d]\n", this, pszProcName, getRetainCount())); 644 } 645 646 647 /** 648 * Release the object. 649 * @remark Only for logging. 650 */ 651 void 652 org_virtualbox_VBoxUSBClient::release(int freeWhen) const 653 { 654 char pszProcName[VBOX_PROC_SELFNAME_LEN]; 655 proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN); 656 657 Log(("VBoxUSBClient::release([%p], freeWhen=%d) pszProcName=[%s] [retain count: %d]\n", this, freeWhen, pszProcName, getRetainCount())); 658 IOUserClient::release(freeWhen); 659 } 660 661 662 /** 663 * Tagged retain the object. 664 * @remark Only for logging. 665 */ 666 void 667 org_virtualbox_VBoxUSBClient::taggedRetain(const void *pTag) const 668 { 669 char pszProcName[VBOX_PROC_SELFNAME_LEN]; 670 proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN); 671 672 Log(("VBoxUSBClient::taggedRetain([%p], [pTag=%p]) (1) pszProcName=[%s] [retain count: %d]\n", this, pTag, pszProcName, getRetainCount())); 673 IOUserClient::taggedRetain(pTag); 674 Log(("VBoxUSBClient::taggedRetain([%p], [pTag=%p]) (2) pszProcName=[%s] [retain count: %d]\n", this, pTag, pszProcName, getRetainCount())); 675 } 676 677 678 /** 679 * Tagged release the object. 680 * @remark Only for logging. 681 */ 682 void 683 org_virtualbox_VBoxUSBClient::taggedRelease(const void *pTag, const int freeWhen) const 684 { 685 char pszProcName[VBOX_PROC_SELFNAME_LEN]; 686 proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN); 687 688 Log(("VBoxUSBClient::taggedRelease([%p], [pTag=%p], [freeWhen=%d]) pszProcName=[%s] [retain count: %d]\n", this, pTag, freeWhen, pszProcName, getRetainCount())); 689 IOUserClient::taggedRelease(pTag, freeWhen); 602 690 } 603 691 … … 609 697 org_virtualbox_VBoxUSBClient::start(IOService *pProvider) 610 698 { 611 Log(("VBoxUSBClient::start([%p], %p) \n", this, pProvider));699 Log(("VBoxUSBClient::start([%p], %p) [retain count: %d]\n", this, pProvider, getRetainCount())); 612 700 if (IOUserClient::start(pProvider)) 613 701 { … … 625 713 VBOXUSB_UNLOCK(); 626 714 715 Log(("VBoxUSBClient::start([%p]): returns true [retain count: %d]\n", this, getRetainCount())); 627 716 return true; 628 717 } 629 Log(("VBoxUSBClient::start: %p isn't org_virtualbox_VBoxUSB\n", pProvider)); 630 } 718 Log(("VBoxUSBClient::start: %p isn't org_virtualbox_VBoxUSB [retain count: %d]\n", pProvider, getRetainCount())); 719 } 720 721 Log(("VBoxUSBClient::start([%p]): returns false [retain count: %d]\n", this, getRetainCount())); 631 722 return false; 632 723 } … … 639 730 org_virtualbox_VBoxUSBClient::clientClose(void) 640 731 { 641 Log(("VBoxUSBClient::clientClose([%p:{.m_Process=%d}]) \n", this, (int)m_Process));732 Log(("VBoxUSBClient::clientClose([%p:{.m_Process=%d}]) [retain count: %d]\n", this, (int)m_Process, getRetainCount())); 642 733 643 734 /* … … 682 773 terminate(); 683 774 775 Log(("VBoxUSBClient::clientClose([%p:{.m_Process=%d}]) return kIOReturnSuccess [retain count: %d]\n", this, (int)m_Process, getRetainCount())); 776 684 777 return kIOReturnSuccess; 685 778 } … … 693 786 org_virtualbox_VBoxUSBClient::clientDied(void) 694 787 { 695 Log(("VBoxUSBClient::clientDied([%p]) m_Task=%p R0Process=%p Process=%d\n", 696 this, m_Task, RTR0ProcHandleSelf(), RTProcSelf())); 697 788 Log(("VBoxUSBClient::clientDied([%p]) m_Task=%p R0Process=%p Process=%d\n [retain count: %d]", 789 this, m_Task, RTR0ProcHandleSelf(), RTProcSelf(), getRetainCount())); 698 790 /* IOUserClient::clientDied() calls clientClose... */ 699 return IOUserClient::clientDied(); 791 bool fRc = IOUserClient::clientDied(); 792 Log(("VBoxUSBClient::clientDied([%p]): returns %d [retain count: %d]\n", this, fRc, getRetainCount())); 793 return fRc; 700 794 } 701 795 … … 709 803 { 710 804 /* kIOServiceRecursing, kIOServiceRequired, kIOServiceTerminate, kIOServiceSynchronous - interesting option bits */ 711 Log(("VBoxUSBClient::terminate([%p], %#x)\n", this, fOptions)); 712 return IOUserClient::terminate(fOptions); 805 Log(("VBoxUSBClient::terminate([%p], %#x) [retain count: %d]\n", this, fOptions, getRetainCount())); 806 bool fRc = IOUserClient::terminate(fOptions); 807 Log(("VBoxUSBClient::terminate([%p]): returns %d [retain count: %d]\n", this, fRc, getRetainCount())); 808 return fRc; 713 809 } 714 810 … … 721 817 org_virtualbox_VBoxUSBClient::finalize(IOOptionBits fOptions) 722 818 { 723 Log(("VBoxUSBClient::finalize([%p], %#x)\n", this, fOptions)); 724 return IOUserClient::finalize(fOptions); 819 Log(("VBoxUSBClient::finalize([%p], %#x) [retain count: %d]\n", this, fOptions, getRetainCount())); 820 bool fRc = IOUserClient::finalize(fOptions); 821 Log(("VBoxUSBClient::finalize([%p]): returns %d [retain count: %d]\n", this, fRc, getRetainCount())); 822 return fRc; 725 823 } 726 824 … … 732 830 org_virtualbox_VBoxUSBClient::stop(IOService *pProvider) 733 831 { 734 Log(("VBoxUSBClient::stop([%p]) \n", this));832 Log(("VBoxUSBClient::stop([%p]) (1) [retain count: %d]\n", this, getRetainCount())); 735 833 IOUserClient::stop(pProvider); 834 Log(("VBoxUSBClient::stop([%p]) (2) [retain count: %d]\n", this, getRetainCount())); 736 835 737 836 /* … … 1295 1394 m_fBeingUnloaded = true; 1296 1395 1297 return IOUSBUserClientInit::terminate(fOptions); 1396 bool fRc = IOUSBUserClientInit::terminate(fOptions); 1397 Log(("VBoxUSBDevice::terminate([%p]): returns %d\n", this, fRc)); 1398 return fRc; 1298 1399 } 1299 1400 … … 1743 1844 /* kIOServiceRecursing, kIOServiceRequired, kIOServiceTerminate, kIOServiceSynchronous - interesting option bits */ 1744 1845 Log(("VBoxUSBInterface::terminate([%p], %#x)\n", this, fOptions)); 1745 return IOUSBUserClientInit::terminate(fOptions); 1846 bool fRc = IOUSBUserClientInit::terminate(fOptions); 1847 Log(("VBoxUSBInterface::terminate([%p]): returns %d\n", this, fRc)); 1848 return fRc; 1746 1849 } 1747 1850
Note:
See TracChangeset
for help on using the changeset viewer.