Changeset 25834 in vbox
- Timestamp:
- Jan 14, 2010 4:21:05 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/AutoLock.h
r25813 r25834 27 27 // macros for automatic lock validation; these will amount to nothing 28 28 // unless lock validation is enabled for the runtime 29 #if defined(RT_LOCK_STRICT) 29 #if defined(RT_LOCK_STRICT) && defined (DEBUG) 30 #define VBOX_WITH_MAIN_LOCK_VALIDATION 30 31 # define COMMA_LOCKVAL_SRC_POS , RT_SRC_POS 31 32 # define LOCKVAL_SRC_POS_DECL RT_SRC_POS_DECL … … 57 58 * LockHandle classes. 58 59 */ 59 enum MainLockValidationClasses60 enum VBoxLockingClass 60 61 { 61 62 LOCKCLASS_NONE = 0, … … 63 64 LOCKCLASS_VIRTUALBOXLIST = 2, // lock protecting a list in VirtualBox object 64 65 // (machines list, hard disk tree, shared folders list, ...) 65 LOCKCLASS_OTHERLIST = 3, // lock protecting a list that's elsewhere 66 LOCKCLASS_USBPROXYSERVICE = 3, // USB proxy service object lock 67 LOCKCLASS_HOSTOBJECT = 4, // Host object lock 68 LOCKCLASS_HOSTLIST = 5, // lock protecting a list in Host object 69 LOCKCLASS_OTHEROBJECT = 6, // any regular object member variable lock 70 LOCKCLASS_OTHERLIST = 7, // lock protecting a list that's elsewhere 66 71 // (e.g. snapshots list in machine object) 67 LOCKCLASS_OBJECT = 4, // any regular object member variable lock 68 LOCKCLASS_OBJECTSTATE = 5 // object state lock (handled by AutoCaller classes) 72 LOCKCLASS_OBJECTSTATE = 8 // object state lock (handled by AutoCaller classes) 69 73 }; 70 74 … … 111 115 virtual void unlockRead() = 0; 112 116 113 #ifdef RT_LOCK_STRICT117 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 114 118 virtual const char* describe() const = 0; 115 119 #endif … … 132 136 { 133 137 public: 134 RWLockHandle( MainLockValidationClasses lockClass);138 RWLockHandle(VBoxLockingClass lockClass); 135 139 virtual ~RWLockHandle(); 136 140 … … 144 148 virtual uint32_t writeLockLevel() const; 145 149 146 #ifdef RT_LOCK_STRICT150 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 147 151 virtual const char* describe() const; 148 152 #endif … … 169 173 { 170 174 public: 171 WriteLockHandle( MainLockValidationClasses lockClass);175 WriteLockHandle(VBoxLockingClass lockClass); 172 176 virtual ~WriteLockHandle(); 173 177 virtual bool isWriteLockOnCurrentThread() const; … … 179 183 virtual uint32_t writeLockLevel() const; 180 184 181 #ifdef RT_LOCK_STRICT185 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 182 186 virtual const char* describe() const; 183 187 #endif -
trunk/src/VBox/Main/HostImpl.cpp
r25810 r25834 152 152 Data() 153 153 #ifdef VBOX_WITH_USB 154 : treeLock(LOCKCLASS_OTHERLIST)154 : usbListsLock(LOCKCLASS_HOSTLIST) 155 155 #endif 156 156 {}; … … 160 160 161 161 #ifdef VBOX_WITH_USB 162 WriteLockHandle treeLock;// protects the below two lists162 WriteLockHandle usbListsLock; // protects the below two lists 163 163 164 164 USBDeviceFilterList llChildren; // all USB device filters … … 947 947 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 948 948 949 AutoMultiWriteLock2 alock(this->lockHandle(), &m-> treeLock COMMA_LOCKVAL_SRC_POS);949 AutoMultiWriteLock2 alock(this->lockHandle(), &m->usbListsLock COMMA_LOCKVAL_SRC_POS); 950 950 951 951 MultiResult rc = checkUSBProxyService(); … … 1324 1324 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1325 1325 1326 AutoMultiWriteLock2 alock(this->lockHandle(), &m-> treeLock COMMA_LOCKVAL_SRC_POS);1326 AutoMultiWriteLock2 alock(this->lockHandle(), &m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1327 1327 1328 1328 MultiResult rc = checkUSBProxyService(); … … 1384 1384 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1385 1385 1386 AutoMultiWriteLock2 alock(this->lockHandle(), &m-> treeLock COMMA_LOCKVAL_SRC_POS);1386 AutoMultiWriteLock2 alock(this->lockHandle(), &m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1387 1387 1388 1388 MultiResult rc = checkUSBProxyService(); … … 1669 1669 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1670 1670 1671 AutoMultiWriteLock2 alock(this->lockHandle(), &m-> treeLock COMMA_LOCKVAL_SRC_POS);1671 AutoMultiWriteLock2 alock(this->lockHandle(), &m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1672 1672 1673 1673 … … 1704 1704 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1705 1705 1706 AutoReadLock alock(&m-> treeLock COMMA_LOCKVAL_SRC_POS);1706 AutoReadLock alock(&m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1707 1707 1708 1708 data.llUSBDeviceFilters.clear(); … … 1735 1735 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1736 1736 1737 AutoWriteLock alock(&m-> treeLock COMMA_LOCKVAL_SRC_POS);1737 AutoWriteLock alock(&m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1738 1738 1739 1739 m->llChildren.push_back(pChild); … … 1747 1747 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1748 1748 1749 AutoWriteLock alock(&m-> treeLock COMMA_LOCKVAL_SRC_POS);1749 AutoWriteLock alock(&m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1750 1750 1751 1751 for (USBDeviceFilterList::iterator it = m->llChildren.begin(); … … 1825 1825 void Host::getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters) 1826 1826 { 1827 AutoReadLock alock(&m-> treeLock COMMA_LOCKVAL_SRC_POS);1827 AutoReadLock alock(&m->usbListsLock COMMA_LOCKVAL_SRC_POS); 1828 1828 1829 1829 *aGlobalFilters = m->llUSBDeviceFilters; -
trunk/src/VBox/Main/MachineImpl.cpp
r25809 r25834 329 329 ///////////////////////////////////////////////////////////////////////////// 330 330 331 Machine::Machine() : mType (IsMachine) {} 332 333 Machine::~Machine() {} 331 Machine::Machine() 332 {} 333 334 Machine::~Machine() 335 {} 334 336 335 337 HRESULT Machine::FinalConstruct() … … 547 549 HRESULT Machine::registeredInit() 548 550 { 549 AssertReturn( mType == IsMachine, E_FAIL);551 AssertReturn(getClassID() == clsidMachine, E_FAIL); 550 552 AssertReturn(!mData->mUuid.isEmpty(), E_FAIL); 551 553 AssertReturn(!mData->mAccessible, E_FAIL); … … 623 625 return; 624 626 625 Assert (mType == IsMachine);626 Assert 627 Assert(getClassID() == clsidMachine); 628 Assert(!!mData); 627 629 628 630 LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed())); … … 2115 2117 if ( aEnabled 2116 2118 && mData->mRegistered 2117 && ( mType != IsSessionMachine2119 && ( getClassID() != clsidSessionMachine 2118 2120 || ( mData->mMachineState != MachineState_PoweredOff 2119 2121 && mData->mMachineState != MachineState_Teleported … … 2258 2260 if ( aEnabled 2259 2261 && mData->mRegistered 2260 && ( mType != IsSessionMachine2262 && ( getClassID() != clsidSessionMachine 2261 2263 || ( mData->mMachineState != MachineState_PoweredOff 2262 2264 && mData->mMachineState != MachineState_Teleported … … 3188 3190 AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS); 3189 3191 3190 if ( mType == IsSnapshotMachine)3192 if (getClassID() == clsidSnapshotMachine) 3191 3193 { 3192 3194 HRESULT rc = checkStateDependency(MutableStateDep); … … 5370 5372 { 5371 5373 if ( mData->mRegistered 5372 && ( mType != IsSessionMachine /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */5374 && ( getClassID() != clsidSessionMachine /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */ 5373 5375 || ( mData->mMachineState != MachineState_Paused 5374 5376 && mData->mMachineState != MachineState_Running … … 5387 5389 { 5388 5390 if ( mData->mRegistered 5389 && ( mType != IsSessionMachine /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */5391 && ( getClassID() != clsidSessionMachine /** @todo This was just convered raw; Check if Running and Paused should actually be included here... (Live Migration) */ 5390 5392 || ( mData->mMachineState != MachineState_Paused 5391 5393 && mData->mMachineState != MachineState_Running … … 5560 5562 * disk attachments will already be uninitialized and deleted, so this 5561 5563 * code will not affect them. */ 5562 if (!!mMediaData && ( mType == IsMachine || mType == IsSnapshotMachine))5564 if (!!mMediaData && (getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine)) 5563 5565 { 5564 5566 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); … … 5574 5576 } 5575 5577 5576 if ( mType == IsMachine)5578 if (getClassID() == clsidMachine) 5577 5579 { 5578 5580 /* reset some important fields of mData */ … … 5720 5722 { 5721 5723 LogFlowThisFuncEnter(); 5722 AssertReturn( mType == IsMachine, E_FAIL);5724 AssertReturn(getClassID() == clsidMachine, E_FAIL); 5723 5725 5724 5726 AutoCaller autoCaller(this); … … 5877 5879 Snapshot *aParentSnapshot) 5878 5880 { 5879 AssertReturn (mType == IsMachine, E_FAIL);5881 AssertReturn(getClassID() == clsidMachine, E_FAIL); 5880 5882 5881 5883 HRESULT rc = S_OK; … … 5948 5950 HRESULT Machine::loadHardware(const settings::Hardware &data) 5949 5951 { 5950 AssertReturn( mType == IsMachine || mType == IsSnapshotMachine, E_FAIL);5952 AssertReturn(getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL); 5951 5953 5952 5954 HRESULT rc = S_OK; … … 6134 6136 const Guid *aSnapshotId /* = NULL */) 6135 6137 { 6136 AssertReturn (mType == IsMachine || mType == IsSnapshotMachine, E_FAIL);6138 AssertReturn(getClassID() == clsidMachine || getClassID() == clsidSnapshotMachine, E_FAIL); 6137 6139 6138 6140 HRESULT rc = S_OK; … … 6208 6210 const Guid *aSnapshotId /*= NULL*/) 6209 6211 { 6210 AssertReturn ((mType == IsMachine && aSnapshotId == NULL) || 6211 (mType == IsSnapshotMachine && aSnapshotId != NULL), E_FAIL); 6212 AssertReturn( (getClassID() == clsidMachine && aSnapshotId == NULL) 6213 || (getClassID() == clsidSnapshotMachine && aSnapshotId != NULL), 6214 E_FAIL); 6212 6215 6213 6216 HRESULT rc = S_OK; … … 6313 6316 if (FAILED(rc)) 6314 6317 { 6315 if ( mType == IsSnapshotMachine)6318 if (getClassID() == clsidSnapshotMachine) 6316 6319 { 6317 6320 // wrap another error message around the "cannot find hard disk" set by findHardDisk … … 6331 6334 if (medium->getType() == MediumType_Immutable) 6332 6335 { 6333 if ( mType == IsSnapshotMachine)6336 if (getClassID() == clsidSnapshotMachine) 6334 6337 return setError(E_FAIL, 6335 6338 tr("Immutable hard disk '%s' with UUID {%RTuuid} cannot be directly attached to snapshot with UUID {%RTuuid} " … … 6349 6352 } 6350 6353 6351 if ( mType != IsSnapshotMachine6354 if ( getClassID() != clsidSnapshotMachine 6352 6355 && medium->getChildren().size() != 0 6353 6356 ) … … 6399 6402 if (!medium.isNull()) 6400 6403 { 6401 if ( mType == IsSnapshotMachine)6404 if (getClassID() == clsidSnapshotMachine) 6402 6405 rc = medium->attachTo(mData->mUuid, *aSnapshotId); 6403 6406 else … … 6786 6789 ensureNoStateDependencies(); 6787 6790 6788 AssertReturn( mType == IsMachine || mType == IsSessionMachine, E_FAIL);6791 AssertReturn(getClassID() == clsidMachine || getClassID() == clsidSessionMachine, E_FAIL); 6789 6792 6790 6793 BOOL currentStateModified = mData->mCurrentStateModified; … … 6900 6903 * to the client process that creates them) and thus don't need to 6901 6904 * inform callbacks. */ 6902 if ( mType == IsSessionMachine)6905 if (getClassID() == clsidSessionMachine) 6903 6906 mParent->onMachineDataChange(mData->mUuid); 6904 6907 } … … 7823 7826 mMediaData.commit(); 7824 7827 7825 if ( mType == IsSessionMachine)7828 if (getClassID() == clsidSessionMachine) 7826 7829 { 7827 7830 /* attach new data to the primary machine and reshare it */ … … 8274 8277 } 8275 8278 8276 if ( mType == IsSessionMachine)8279 if (getClassID() == clsidSessionMachine) 8277 8280 { 8278 8281 /* attach new data to the primary machine and reshare it */ … … 8299 8302 void Machine::copyFrom(Machine *aThat) 8300 8303 { 8301 AssertReturnVoid (mType == IsMachine || mType == IsSessionMachine);8302 AssertReturnVoid (aThat->mType == IsSnapshotMachine);8303 8304 AssertReturnVoid 8305 8306 mHWData.assignCopy 8304 AssertReturnVoid(getClassID() == clsidMachine || getClassID() == clsidSessionMachine); 8305 AssertReturnVoid(aThat->getClassID() == clsidSnapshotMachine); 8306 8307 AssertReturnVoid(!Global::IsOnline (mData->mMachineState)); 8308 8309 mHWData.assignCopy(aThat->mHWData); 8307 8310 8308 8311 // create copies of all shared folders (mHWData after attiching a copy … … 8405 8408 { 8406 8409 LogFlowThisFunc(("\n")); 8407 8408 /* set the proper type to indicate we're the SessionMachine instance */8409 unconst(mType) = IsSessionMachine;8410 8410 8411 8411 #if defined(RT_OS_WINDOWS) -
trunk/src/VBox/Main/SnapshotImpl.cpp
r25696 r25834 767 767 { 768 768 LogFlowThisFunc(("\n")); 769 770 /* set the proper type to indicate we're the SnapshotMachine instance */771 unconst(mType) = IsSnapshotMachine;772 769 773 770 return S_OK; -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r25809 r25834 79 79 { 80 80 AssertCompile (sizeof (RWLockHandle *) == sizeof (void *)); 81 RWLockHandle *objLock = new RWLockHandle(LOCKCLASS_OBJECT); 81 82 // locking class is LOCKCLASS_VIRTUALBOXOBJECT for the VirtualBox singleton, 83 // LOCKCLASS_HOSTOBJECT for the Host object and LOCKCLASS_OBJECT for any other object 84 RWLockHandle *objLock = new RWLockHandle(getLockingClass()); 82 85 if (!ASMAtomicCmpXchgPtr ((void * volatile *) &mObjectLock, objLock, NULL)) 83 86 { -
trunk/src/VBox/Main/glue/AutoLock.cpp
r25813 r25834 41 41 #include <vector> 42 42 #include <list> 43 #include <map> 43 44 44 45 namespace util … … 51 52 //////////////////////////////////////////////////////////////////////////////// 52 53 53 class RuntimeLockClass 54 { 55 }; 54 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 55 typedef std::map<VBoxLockingClass, RTLOCKVALCLASS> LockValidationClassesMap; 56 LockValidationClassesMap g_mapLockValidationClasses; 57 #endif 56 58 57 59 /** … … 61 63 void InitAutoLockSystem() 62 64 { 63 RTPrintf("InitAutoLockSystem\n"); 65 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 66 struct 67 { 68 VBoxLockingClass cls; 69 const char *pcszDescription; 70 } aClasses[] = 71 { 72 { LOCKCLASS_VIRTUALBOXOBJECT, "1-VIRTUALBOXOBJECT" }, 73 { LOCKCLASS_VIRTUALBOXLIST, "2-VIRTUALBOXLIST" }, 74 { LOCKCLASS_USBPROXYSERVICE, "3-USBPROXYSERVICE" }, 75 { LOCKCLASS_HOSTOBJECT, "4-HOSTOBJECT" }, 76 { LOCKCLASS_HOSTLIST, "5-HOSTLIST" }, 77 { LOCKCLASS_OTHEROBJECT, "6-OTHEROBJECT" }, 78 { LOCKCLASS_OTHERLIST, "7-OTHERLIST" }, 79 { LOCKCLASS_OBJECTSTATE, "8-OBJECTSTATE" } 80 }; 81 82 RTLOCKVALCLASS hClass; 83 int vrc; 84 for (unsigned i = 0; i < RT_ELEMENTS(aClasses); ++i) 85 { 86 vrc = RTLockValidatorClassCreate(&hClass, 87 true, /*fAutodidact*/ 88 RT_SRC_POS, 89 aClasses[i].pcszDescription); 90 AssertRC(vrc); 91 92 // teach the new class that the classes created previously can be held 93 // while the new class is being acquired 94 for (LockValidationClassesMap::iterator it = g_mapLockValidationClasses.begin(); 95 it != g_mapLockValidationClasses.end(); 96 ++it) 97 { 98 RTLOCKVALCLASS &canBeHeld = it->second; 99 vrc = RTLockValidatorClassAddPriorClass(hClass, 100 canBeHeld); 101 AssertRC(vrc); 102 } 103 104 // and store the new class 105 g_mapLockValidationClasses[aClasses[i].cls] = hClass; 106 } 107 108 /* WriteLockHandle critsect1(LOCKCLASS_VIRTUALBOXOBJECT); 109 WriteLockHandle critsect2(LOCKCLASS_VIRTUALBOXLIST); 110 111 AutoWriteLock lock1(critsect1 COMMA_LOCKVAL_SRC_POS); 112 AutoWriteLock lock2(critsect2 COMMA_LOCKVAL_SRC_POS);*/ 113 #endif 64 114 } 65 115 … … 76 126 77 127 RTSEMRW sem; 78 MainLockValidationClasses lockClass;79 80 #ifdef RT_LOCK_STRICT128 VBoxLockingClass lockClass; 129 130 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 81 131 com::Utf8Str strDescription; 82 132 #endif 83 133 }; 84 134 85 RWLockHandle::RWLockHandle( MainLockValidationClasses lockClass)135 RWLockHandle::RWLockHandle(VBoxLockingClass lockClass) 86 136 { 87 137 m = new Data(); … … 89 139 m->lockClass = lockClass; 90 140 91 int vrc = RTSemRWCreateEx(&m->sem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL); 141 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 142 m->strDescription = com::Utf8StrFmt("r/w %RCv", this); 143 int vrc = RTSemRWCreateEx(&m->sem, 0 /*fFlags*/, g_mapLockValidationClasses[lockClass], RTLOCKVAL_SUB_CLASS_ANY, NULL); 144 #else 145 int vrc = RTSemRWCreateEx(&m->sem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY, NULL); 146 #endif 92 147 AssertRC(vrc); 93 94 #ifdef RT_LOCK_STRICT95 m->strDescription = com::Utf8StrFmt("r/w %RCv", this);96 #endif97 148 } 98 149 … … 110 161 /*virtual*/ void RWLockHandle::lockWrite(LOCKVAL_SRC_POS_DECL) 111 162 { 112 #if defined(RT_LOCK_STRICT)163 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 113 164 int vrc = RTSemRWRequestWriteDebug(m->sem, RT_INDEFINITE_WAIT, (uintptr_t)ASMReturnAddress(), RT_SRC_POS_ARGS); 114 165 #else … … 127 178 /*virtual*/ void RWLockHandle::lockRead(LOCKVAL_SRC_POS_DECL) 128 179 { 129 #if defined(RT_LOCK_STRICT)180 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 130 181 int vrc = RTSemRWRequestReadDebug(m->sem, RT_INDEFINITE_WAIT, (uintptr_t)ASMReturnAddress(), RT_SRC_POS_ARGS); 131 182 #else … … 147 198 } 148 199 149 #ifdef RT_LOCK_STRICT200 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 150 201 /*virtual*/ const char* RWLockHandle::describe() const 151 202 { … … 166 217 167 218 mutable RTCRITSECT sem; 168 MainLockValidationClasses lockClass;169 170 #ifdef RT_LOCK_STRICT219 VBoxLockingClass lockClass; 220 221 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 171 222 com::Utf8Str strDescription; 172 223 #endif 173 224 }; 174 225 175 WriteLockHandle::WriteLockHandle( MainLockValidationClasses lockClass)226 WriteLockHandle::WriteLockHandle(VBoxLockingClass lockClass) 176 227 { 177 228 m = new Data; … … 179 230 m->lockClass = lockClass; 180 231 181 int vrc = RTCritSectInitEx(&m->sem, 0/*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL); 232 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 233 m->strDescription = com::Utf8StrFmt("crit %RCv", this); 234 int vrc = RTCritSectInitEx(&m->sem, 0/*fFlags*/, g_mapLockValidationClasses[lockClass], RTLOCKVAL_SUB_CLASS_ANY, NULL); 235 #else 236 int vrc = RTCritSectInitEx(&m->sem, 0/*fFlags*/, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY, NULL); 237 #endif 182 238 AssertRC(vrc); 183 184 #ifdef RT_LOCK_STRICT185 m->strDescription = com::Utf8StrFmt("crit %RCv", this);186 #endif187 239 } 188 240 … … 200 252 /*virtual*/ void WriteLockHandle::lockWrite(LOCKVAL_SRC_POS_DECL) 201 253 { 202 #if defined(RT_LOCK_STRICT)254 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 203 255 RTCritSectEnterDebug(&m->sem, (uintptr_t)ASMReturnAddress(), RT_SRC_POS_ARGS); 204 256 #else … … 227 279 } 228 280 229 #ifdef RT_LOCK_STRICT281 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 230 282 /*virtual*/ const char* WriteLockHandle::describe() const 231 283 { … … 246 298 { 247 299 Data(size_t cHandles 248 #ifdef RT_LOCK_STRICT300 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 249 301 , const char *pcszFile_, 250 302 unsigned uLine_, … … 255 307 aHandles(cHandles), // size of array 256 308 acUnlockedInLeave(cHandles) 257 #ifdef RT_LOCK_STRICT309 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 258 310 , pcszFile(pcszFile_), 259 311 uLine(uLine_), … … 275 327 CountsVector acUnlockedInLeave; // for each lock handle, how many times the handle was unlocked in leave(); otherwise 0 276 328 277 #ifdef RT_LOCK_STRICT329 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 278 330 // information about where the lock occured (passed down from the AutoLock classes) 279 331 const char *pcszFile; … … 443 495 /*virtual*/ void AutoReadLock::callLockImpl(LockHandle &l) 444 496 { 445 #ifdef RT_LOCK_STRICT497 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 446 498 l.lockRead(m->pcszFile, m->uLine, m->pcszFunction); 447 499 #else … … 475 527 /*virtual*/ void AutoWriteLockBase::callLockImpl(LockHandle &l) 476 528 { 477 #ifdef RT_LOCK_STRICT529 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION 478 530 l.lockWrite(m->pcszFile, m->uLine, m->pcszFunction); 479 531 #else -
trunk/src/VBox/Main/include/HostImpl.h
r24403 r25834 101 101 102 102 // public methods only for internal purposes 103 104 /** 105 * Simple run-time type identification without having to enable C++ RTTI. 106 * The class IDs are defined in VirtualBoxBase.h. 107 * @return 108 */ 109 virtual VBoxClsID getClassID() const 110 { 111 return clsidHost; 112 } 113 114 /** 115 * Override of the default locking class to be used for validating lock 116 * order with the standard member lock handle. 117 */ 118 virtual VBoxLockingClass getLockingClass() const 119 { 120 return LOCKCLASS_HOSTOBJECT; 121 } 122 103 123 HRESULT loadSettings(const settings::Host &data); 104 124 HRESULT saveSettings(settings::Host &data); -
trunk/src/VBox/Main/include/MachineImpl.h
r25672 r25834 94 94 95 95 public: 96 97 enum InstanceType { IsMachine, IsSessionMachine, IsSnapshotMachine };98 96 99 97 enum InitMode { Init_New, Init_Import, Init_Registered }; … … 640 638 // public methods only for internal purposes 641 639 642 InstanceType getType() const { return mType; } 640 /** 641 * Simple run-time type identification without having to enable C++ RTTI. 642 * The class IDs are defined in VirtualBoxBase.h. 643 * @return 644 */ 645 virtual VBoxClsID getClassID() const 646 { 647 return clsidMachine; 648 } 643 649 644 650 /// @todo (dmik) add lock and make non-inlined after revising classes … … 892 898 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine); 893 899 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 894 895 const InstanceType mType;896 900 897 901 const ComObjPtr<Machine, ComWeakRef> mPeer; … … 1007 1011 // public methods only for internal purposes 1008 1012 1013 /** 1014 * Simple run-time type identification without having to enable C++ RTTI. 1015 * The class IDs are defined in VirtualBoxBase.h. 1016 * @return 1017 */ 1018 virtual VBoxClsID getClassID() const 1019 { 1020 return clsidSessionMachine; 1021 } 1022 1009 1023 bool checkForDeath(); 1010 1024 … … 1148 1162 // public methods only for internal purposes 1149 1163 1164 /** 1165 * Simple run-time type identification without having to enable C++ RTTI. 1166 * The class IDs are defined in VirtualBoxBase.h. 1167 * @return 1168 */ 1169 virtual VBoxClsID getClassID() const 1170 { 1171 return clsidSnapshotMachine; 1172 } 1173 1150 1174 HRESULT onSnapshotChange(Snapshot *aSnapshot); 1151 1175 … … 1166 1190 inline const Guid &Machine::getSnapshotId() const 1167 1191 { 1168 return mType != IsSnapshotMachine ? Guid::Empty : 1169 static_cast<const SnapshotMachine *>(this)->getSnapshotId(); 1192 return getClassID() != clsidSnapshotMachine 1193 ? Guid::Empty 1194 : static_cast<const SnapshotMachine*>(this)->getSnapshotId(); 1170 1195 } 1171 1196 … … 1182 1207 inline Machine *Machine::getMachine() 1183 1208 { 1184 if ( mType == IsSessionMachine)1209 if (getClassID() == clsidSessionMachine) 1185 1210 return mPeer; 1186 1211 return this; -
trunk/src/VBox/Main/include/SnapshotImpl.h
r25152 r25834 90 90 91 91 // public methods only for internal purposes 92 93 94 /** 95 * Simple run-time type identification without having to enable C++ RTTI. 96 * The class IDs are defined in VirtualBoxBase.h. 97 * @return 98 */ 99 virtual VBoxClsID getClassID() const 100 { 101 return clsidSnapshot; 102 } 103 92 104 const ComObjPtr<Snapshot>& getParent() const; 93 105 -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r25813 r25834 419 419 //////////////////////////////////////////////////////////////////////////////// 420 420 421 enum VBoxClsID 422 { 423 clsidVirtualBox, 424 clsidHost, 425 clsidMachine, 426 clsidSessionMachine, 427 clsidSnapshotMachine, 428 clsidSnapshot, 429 clsidOther 430 }; 431 421 432 /** 422 433 * Abstract base class for all component classes implementing COM … … 503 514 // util::Lockable interface 504 515 virtual RWLockHandle *lockHandle() const; 516 517 /** 518 * Simple run-time type identification without having to enable C++ RTTI. 519 * The class IDs are defined in VirtualBoxBase.h. 520 * @return 521 */ 522 virtual VBoxClsID getClassID() const 523 { 524 return clsidOther; 525 } 526 527 /** 528 * Override of the default locking class to be used for validating lock 529 * order with the standard member lock handle. 530 */ 531 virtual VBoxLockingClass getLockingClass() const 532 { 533 return LOCKCLASS_OTHEROBJECT; 534 } 505 535 506 536 /** … … 1117 1147 1118 1148 class ATL_NO_VTABLE VirtualBoxBase 1119 : virtual public VirtualBoxBaseProto 1120 ,public CComObjectRootEx<CComMultiThreadModel>1149 : virtual public VirtualBoxBaseProto, 1150 public CComObjectRootEx<CComMultiThreadModel> 1121 1151 { 1122 1152 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r25184 r25834 181 181 182 182 /* public methods only for internal purposes */ 183 184 /** 185 * Simple run-time type identification without having to enable C++ RTTI. 186 * The class IDs are defined in VirtualBoxBase.h. 187 * @return 188 */ 189 virtual VBoxClsID getClassID() const 190 { 191 return clsidVirtualBox; 192 } 193 194 /** 195 * Override of the default locking class to be used for validating lock 196 * order with the standard member lock handle. 197 */ 198 virtual VBoxLockingClass getLockingClass() const 199 { 200 return LOCKCLASS_VIRTUALBOXOBJECT; 201 } 202 183 203 #ifdef DEBUG 184 204 void dumpAllBackRefs(); -
trunk/src/VBox/Main/include/objectslist.h
r25809 r25834 59 59 // http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18 60 60 61 ObjectsList( MainLockValidationClasses lockClass)61 ObjectsList(VBoxLockingClass lockClass) 62 62 : m_lock(lockClass) 63 63 { }
Note:
See TracChangeset
for help on using the changeset viewer.