Commit f75b7e87 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Improve tracing of GDI objects to make leaks easier to spot.

parent 50195920
...@@ -635,6 +635,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) ...@@ -635,6 +635,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
#define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE) #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES]; static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
static int next_large_handle; static int next_large_handle;
static LONG debug_count;
static const char *gdi_obj_type( unsigned type ) static const char *gdi_obj_type( unsigned type )
{ {
...@@ -712,6 +713,9 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs ...@@ -712,6 +713,9 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
large_handles[i] = obj; large_handles[i] = obj;
next_large_handle = i; next_large_handle = i;
LeaveCriticalSection( &gdi_section ); LeaveCriticalSection( &gdi_section );
TRACE( "allocated %s %p %u/%u\n",
gdi_obj_type(type), (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2),
InterlockedIncrement( &debug_count ), MAX_LARGE_HANDLES );
return (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2); return (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
} }
...@@ -736,6 +740,8 @@ void *free_gdi_handle( HGDIOBJ handle ) ...@@ -736,6 +740,8 @@ void *free_gdi_handle( HGDIOBJ handle )
} }
if (object) if (object)
{ {
TRACE( "freed %s %p %u/%u\n", gdi_obj_type( object->type ), handle,
InterlockedDecrement( &debug_count ) + 1, MAX_LARGE_HANDLES );
object->type = 0; /* mark it as invalid */ object->type = 0; /* mark it as invalid */
object->funcs = NULL; object->funcs = NULL;
} }
...@@ -769,7 +775,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type ) ...@@ -769,7 +775,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
LeaveCriticalSection( &gdi_section ); LeaveCriticalSection( &gdi_section );
WARN( "Invalid handle %p\n", handle ); WARN( "Invalid handle %p\n", handle );
} }
else TRACE("(%p): enter %d\n", handle, gdi_section.RecursionCount);
return ptr; return ptr;
} }
...@@ -781,7 +786,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type ) ...@@ -781,7 +786,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
*/ */
void GDI_ReleaseObj( HGDIOBJ handle ) void GDI_ReleaseObj( HGDIOBJ handle )
{ {
TRACE("(%p): leave %d\n", handle, gdi_section.RecursionCount);
LeaveCriticalSection( &gdi_section ); LeaveCriticalSection( &gdi_section );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment