mirror of
https://github.com/reactos/reactos.git
synced 2025-05-23 11:04:52 +00:00
[WIN32K]
- add tracing of exclusive gdi locks - add some asserts svn path=/trunk/; revision=50825
This commit is contained in:
parent
dc29559c25
commit
ebf22c9469
3 changed files with 44 additions and 7 deletions
|
@ -9,6 +9,9 @@
|
||||||
#include <win32k/ntgdihdl.h>
|
#include <win32k/ntgdihdl.h>
|
||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
|
|
||||||
|
/* apparently the first 10 entries are never used in windows as they are empty */
|
||||||
|
#define RESERVE_ENTRIES_COUNT 10
|
||||||
|
|
||||||
typedef struct _GDI_HANDLE_TABLE
|
typedef struct _GDI_HANDLE_TABLE
|
||||||
{
|
{
|
||||||
/* The table must be located at the beginning of this structure so it can be
|
/* The table must be located at the beginning of this structure so it can be
|
||||||
|
@ -105,6 +108,19 @@ ULONG
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
GDIOBJ_UnlockObjByPtr(POBJ Object)
|
GDIOBJ_UnlockObjByPtr(POBJ Object)
|
||||||
{
|
{
|
||||||
|
#if DBG
|
||||||
|
PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
|
||||||
|
if (pti)
|
||||||
|
{
|
||||||
|
if (pti->cExclusiveLocks < 1)
|
||||||
|
{
|
||||||
|
DbgPrint("cExclusiveLocks = %ld, object: %ld\n",
|
||||||
|
pti->cExclusiveLocks, Object->cExclusiveLock);
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
pti->cExclusiveLocks--;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
INT cLocks = InterlockedDecrement((PLONG)&Object->cExclusiveLock);
|
INT cLocks = InterlockedDecrement((PLONG)&Object->cExclusiveLock);
|
||||||
ASSERT(cLocks >= 0);
|
ASSERT(cLocks >= 0);
|
||||||
return cLocks;
|
return cLocks;
|
||||||
|
@ -120,6 +136,7 @@ GDIOBJ_ShareUnlockObjByPtr(POBJ Object)
|
||||||
ASSERT(cLocks >= 0);
|
ASSERT(cLocks >= 0);
|
||||||
if ((flags & BASEFLAG_READY_TO_DIE) && (cLocks == 0))
|
if ((flags & BASEFLAG_READY_TO_DIE) && (cLocks == 0))
|
||||||
{
|
{
|
||||||
|
ASSERT(Object->cExclusiveLock == 0);
|
||||||
GDIOBJ_SetOwnership(hobj, PsGetCurrentProcess());
|
GDIOBJ_SetOwnership(hobj, PsGetCurrentProcess());
|
||||||
GDIOBJ_FreeObjByHandle(hobj, GDI_OBJECT_TYPE_DONTCARE);
|
GDIOBJ_FreeObjByHandle(hobj, GDI_OBJECT_TYPE_DONTCARE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,12 +208,14 @@ VOID FASTCALL UserEnterShared(VOID)
|
||||||
|
|
||||||
VOID FASTCALL UserEnterExclusive(VOID)
|
VOID FASTCALL UserEnterExclusive(VOID)
|
||||||
{
|
{
|
||||||
|
ASSERT_NOGDILOCKS();
|
||||||
KeEnterCriticalRegion();
|
KeEnterCriticalRegion();
|
||||||
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
|
ExAcquireResourceExclusiveLite(&UserLock, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FASTCALL UserLeave(VOID)
|
VOID FASTCALL UserLeave(VOID)
|
||||||
{
|
{
|
||||||
|
ASSERT_NOGDILOCKS();
|
||||||
ExReleaseResourceLite(&UserLock);
|
ExReleaseResourceLite(&UserLock);
|
||||||
KeLeaveCriticalRegion();
|
KeLeaveCriticalRegion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#define GDI_HANDLE_GET_ENTRY(HandleTable, h) \
|
#define GDI_HANDLE_GET_ENTRY(HandleTable, h) \
|
||||||
(&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
|
(&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
|
||||||
|
|
||||||
/* apparently the first 10 entries are never used in windows as they are empty */
|
|
||||||
#define RESERVE_ENTRIES_COUNT 10
|
|
||||||
|
|
||||||
#define BASE_OBJTYPE_COUNT 32
|
#define BASE_OBJTYPE_COUNT 32
|
||||||
|
|
||||||
#define DelayExecution() \
|
#define DelayExecution() \
|
||||||
|
@ -483,6 +480,9 @@ LockHandle:
|
||||||
newObject->ulShareCount = 0;
|
newObject->ulShareCount = 0;
|
||||||
newObject->cExclusiveLock = 1;
|
newObject->cExclusiveLock = 1;
|
||||||
newObject->Tid = Thread;
|
newObject->Tid = Thread;
|
||||||
|
#if DBG
|
||||||
|
if (Thread) Thread->cExclusiveLocks++;
|
||||||
|
#endif
|
||||||
|
|
||||||
AllocTypeDataDump(TypeInfo);
|
AllocTypeDataDump(TypeInfo);
|
||||||
|
|
||||||
|
@ -603,11 +603,11 @@ LockHandle:
|
||||||
((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == (HandleUpper & GDI_ENTRY_BASETYPE_MASK)) )
|
((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == (HandleUpper & GDI_ENTRY_BASETYPE_MASK)) )
|
||||||
{
|
{
|
||||||
POBJ Object;
|
POBJ Object;
|
||||||
|
PTHREADINFO Thread = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
|
||||||
|
|
||||||
Object = Entry->KernelData;
|
Object = Entry->KernelData;
|
||||||
|
|
||||||
if ((Object->cExclusiveLock == 0 ||
|
if ((Object->cExclusiveLock == 0 || Object->Tid == Thread) &&
|
||||||
Object->Tid == (PTHREADINFO)PsGetCurrentThreadWin32Thread()) &&
|
|
||||||
Object->ulShareCount == 0)
|
Object->ulShareCount == 0)
|
||||||
{
|
{
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
@ -623,6 +623,18 @@ LockHandle:
|
||||||
InterlockedPushFreeEntry(GDI_ENTRY_TO_INDEX(GdiHandleTable, Entry));
|
InterlockedPushFreeEntry(GDI_ENTRY_TO_INDEX(GdiHandleTable, Entry));
|
||||||
|
|
||||||
Object->hHmgr = NULL;
|
Object->hHmgr = NULL;
|
||||||
|
#if DBG
|
||||||
|
if (Thread)
|
||||||
|
{
|
||||||
|
if (Thread->cExclusiveLocks < Object->cExclusiveLock)
|
||||||
|
{
|
||||||
|
DPRINT1("cExclusiveLocks = %ld, object: %ld\n",
|
||||||
|
Thread->cExclusiveLocks, Object->cExclusiveLock);
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
Thread->cExclusiveLocks -= Object->cExclusiveLock;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (W32Process != NULL)
|
if (W32Process != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1056,6 +1068,9 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
|
||||||
Object->Tid = Thread;
|
Object->Tid = Thread;
|
||||||
Object->cExclusiveLock = 1;
|
Object->cExclusiveLock = 1;
|
||||||
GDIDBG_CAPTURELOCKER(GDI_HANDLE_GET_INDEX(hObj))
|
GDIDBG_CAPTURELOCKER(GDI_HANDLE_GET_INDEX(hObj))
|
||||||
|
#if DBG
|
||||||
|
if (Thread) Thread->cExclusiveLocks++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1068,6 +1083,9 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
InterlockedIncrement((PLONG)&Object->cExclusiveLock);
|
InterlockedIncrement((PLONG)&Object->cExclusiveLock);
|
||||||
|
#if DBG
|
||||||
|
if (Thread) Thread->cExclusiveLocks++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue