Index: /trunk/include/iprt/lockvalidator.h
===================================================================
--- /trunk/include/iprt/lockvalidator.h	(revision 28266)
+++ /trunk/include/iprt/lockvalidator.h	(revision 28267)
@@ -834,4 +834,29 @@
 RTDECL(bool) RTLockValidatorIsBlockedThreadInValidator(RTTHREAD hThread);
 
+/**
+ * Checks if the calling thread is holding a lock in the specified class.
+ *
+ * @returns true if it holds a lock in the specific class, false if it
+ *          doesn't.
+ *
+ * @param   hCurrentThread      The current thread.  Pass NIL_RTTHREAD if you're
+ *                              lazy.
+ * @param   hClass              The class.
+ */
+RTDECL(bool) RTLockValidatorHoldsLocksInClass(RTTHREAD hCurrentThread, RTLOCKVALCLASS hClass);
+
+/**
+ * Checks if the calling thread is holding a lock in the specified sub-class.
+ *
+ * @returns true if it holds a lock in the specific sub-class, false if it
+ *          doesn't.
+ *
+ * @param   hCurrentThread      The current thread.  Pass NIL_RTTHREAD if you're
+ *                              lazy.
+ * @param   hClass              The class.
+ * @param   uSubClass           The new sub-class value.
+ */
+RTDECL(bool) RTLockValidatorHoldsLocksInSubClass(RTTHREAD hCurrentThread, RTLOCKVALCLASS hClass, uint32_t uSubClass);
+
 
 
Index: /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 28266)
+++ /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 28267)
@@ -4281,4 +4281,114 @@
 
 
+RTDECL(bool) RTLockValidatorHoldsLocksInClass(RTTHREAD hCurrentThread, RTLOCKVALCLASS hClass)
+{
+    bool            fRet    = false;
+    if (hCurrentThread == NIL_RTTHREAD)
+        hCurrentThread = RTThreadSelf();
+    else
+        Assert(hCurrentThread == RTThreadSelf());
+    PRTTHREADINT    pThread = rtThreadGet(hCurrentThread);
+    if (pThread)
+    {
+        if (hClass != NIL_RTLOCKVALCLASS)
+        {
+            PRTLOCKVALRECUNION pCur = rtLockValidatorReadRecUnionPtr(&pThread->LockValidator.pStackTop);
+            while (VALID_PTR(pCur) && !fRet)
+            {
+                switch (pCur->Core.u32Magic)
+                {
+                    case RTLOCKVALRECEXCL_MAGIC:
+                        fRet = pCur->Excl.hClass == hClass;
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->Excl.pDown);
+                        break;
+                    case RTLOCKVALRECSHRDOWN_MAGIC:
+                        fRet = VALID_PTR(pCur->ShrdOwner.pSharedRec)
+                            && pCur->ShrdOwner.pSharedRec->hClass == hClass;
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->ShrdOwner.pDown);
+                        break;
+                    case RTLOCKVALRECNEST_MAGIC:
+                        switch (pCur->Nest.pRec->Core.u32Magic)
+                        {
+                            case RTLOCKVALRECEXCL_MAGIC:
+                                fRet = pCur->Nest.pRec->Excl.hClass == hClass;
+                                break;
+                            case RTLOCKVALRECSHRDOWN_MAGIC:
+                                fRet = VALID_PTR(pCur->ShrdOwner.pSharedRec)
+                                    && pCur->Nest.pRec->ShrdOwner.pSharedRec->hClass == hClass;
+                                break;
+                        }
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->Nest.pDown);
+                        break;
+                    default:
+                        pCur = NULL;
+                        break;
+                }
+            }
+        }
+
+        rtThreadRelease(pThread);
+    }
+    return fRet;
+}
+RT_EXPORT_SYMBOL(RTLockValidatorHoldsLocksInClass);
+
+
+RTDECL(bool) RTLockValidatorHoldsLocksInSubClass(RTTHREAD hCurrentThread, RTLOCKVALCLASS hClass, uint32_t uSubClass)
+{
+    bool            fRet    = false;
+    if (hCurrentThread == NIL_RTTHREAD)
+        hCurrentThread = RTThreadSelf();
+    else
+        Assert(hCurrentThread == RTThreadSelf());
+    PRTTHREADINT    pThread = rtThreadGet(hCurrentThread);
+    if (pThread)
+    {
+        if (hClass != NIL_RTLOCKVALCLASS)
+        {
+            PRTLOCKVALRECUNION pCur = rtLockValidatorReadRecUnionPtr(&pThread->LockValidator.pStackTop);
+            while (VALID_PTR(pCur) && !fRet)
+            {
+                switch (pCur->Core.u32Magic)
+                {
+                    case RTLOCKVALRECEXCL_MAGIC:
+                        fRet = pCur->Excl.hClass == hClass
+                            && pCur->Excl.uSubClass == uSubClass;
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->Excl.pDown);
+                        break;
+                    case RTLOCKVALRECSHRDOWN_MAGIC:
+                        fRet = VALID_PTR(pCur->ShrdOwner.pSharedRec)
+                            && pCur->ShrdOwner.pSharedRec->hClass == hClass
+                            && pCur->ShrdOwner.pSharedRec->uSubClass == uSubClass;
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->ShrdOwner.pDown);
+                        break;
+                    case RTLOCKVALRECNEST_MAGIC:
+                        switch (pCur->Nest.pRec->Core.u32Magic)
+                        {
+                            case RTLOCKVALRECEXCL_MAGIC:
+                                fRet = pCur->Nest.pRec->Excl.hClass == hClass
+                                    && pCur->Nest.pRec->Excl.uSubClass == uSubClass;
+                                break;
+                            case RTLOCKVALRECSHRDOWN_MAGIC:
+                                fRet = VALID_PTR(pCur->ShrdOwner.pSharedRec)
+                                    && pCur->Nest.pRec->ShrdOwner.pSharedRec->hClass == hClass
+                                    && pCur->Nest.pRec->ShrdOwner.pSharedRec->uSubClass == uSubClass;
+                                break;
+                        }
+                        pCur = rtLockValidatorReadRecUnionPtr(&pCur->Nest.pDown);
+                        break;
+                    default:
+                        pCur = NULL;
+                        break;
+                }
+            }
+        }
+
+        rtThreadRelease(pThread);
+    }
+    return fRet;
+}
+RT_EXPORT_SYMBOL(RTLockValidatorHoldsLocksInClass);
+
+
 RTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled)
 {
