From c2076ed0dc0d1c4c6eac37cdf31b3c4d580d751f Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Tue, 28 Oct 2014 09:19:13 -0600 Subject: layers: Update object tracker to account for Memory alloc/free --- layers/object_track.c | 20 +++++--------------- xgl-layer-generate.py | 10 +++++++--- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/layers/object_track.c b/layers/object_track.c index 697c8e5d..a8d96e4b 100644 --- a/layers/object_track.c +++ b/layers/object_track.c @@ -64,7 +64,7 @@ static void ll_increment_use_count(XGL_VOID* pObj) { pTrav = pTrav->pNext; } // If we do not find obj, insert it and then intrement count - printf("INFO : Unable to increment count for obj %p, will add to list as UNKNOWN type and increment count\n", pObj); + printf("OBJ WARN : Unable to increment count for obj %p, will add to list as UNKNOWN type and increment count\n", pObj); ll_insert_obj(pObj, "UNKNOWN"); ll_increment_use_count(pObj); } @@ -350,11 +350,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSI XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; ll_increment_use_count((XGL_VOID*)gpu); printf("OBJ[%llu] : USING gpu object %p (%lu total uses)\n", object_track_index++, (void*)gpu, ll_get_obj_uses((XGL_VOID*)gpu)); - //printf("At start of layered GetGpuInfo\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData); - //printf("Completed layered GetGpuInfo\n"); return result; } @@ -363,13 +361,11 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const X XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; ll_increment_use_count((XGL_VOID*)gpu); printf("OBJ[%llu] : USING gpu object %p (%lu total uses)\n", object_track_index++, (void*)gpu, ll_get_obj_uses((XGL_VOID*)gpu)); - //printf("At start of layered CreateDevice\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); printf("OBJ[%llu] : CREATE XGL_DEVICE object %p\n", object_track_index++, (void*)*pDevice); ll_insert_obj((XGL_VOID*)*pDevice, "XGL_DEVICE"); - //printf("Completed layered CreateDevice\n"); return result; } @@ -392,11 +388,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; ll_increment_use_count((XGL_VOID*)gpu); printf("OBJ[%llu] : USING gpu object %p (%lu total uses)\n", object_track_index++, (void*)gpu, ll_get_obj_uses((XGL_VOID*)gpu)); - //printf("At start of layered GetExtensionSupport\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); - //printf("Completed layered GetExtensionSupport\n"); return result; } @@ -405,11 +399,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_ XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; ll_increment_use_count((XGL_VOID*)gpu); printf("OBJ[%llu] : USING gpu object %p (%lu total uses)\n", object_track_index++, (void*)gpu, ll_get_obj_uses((XGL_VOID*)gpu)); - //printf("At start of layered EnumerateLayers\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount); - //printf("Completed layered EnumerateLayers\n"); return result; } @@ -474,14 +466,16 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_M ll_increment_use_count((XGL_VOID*)device); printf("OBJ[%llu] : USING device object %p (%lu total uses)\n", object_track_index++, (void*)device, ll_get_obj_uses((XGL_VOID*)device)); XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem); + printf("OBJ[%llu] : CREATE XGL_GPU_MEMORY object %p\n", object_track_index++, (void*)*pMem); + ll_insert_obj((XGL_VOID*)*pMem, "XGL_GPU_MEMORY"); return result; } XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem) { - ll_increment_use_count((XGL_VOID*)mem); - printf("OBJ[%llu] : USING mem object %p (%lu total uses)\n", object_track_index++, (void*)mem, ll_get_obj_uses((XGL_VOID*)mem)); XGL_RESULT result = nextTable.FreeMemory(mem); + printf("OBJ[%llu] : DESTROY mem object %p\n", object_track_index++, (void*)mem); + ll_remove_obj((XGL_VOID*)mem); return result; } @@ -530,11 +524,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0; ll_increment_use_count((XGL_VOID*)gpu0); printf("OBJ[%llu] : USING gpu0 object %p (%lu total uses)\n", object_track_index++, (void*)gpu0, ll_get_obj_uses((XGL_VOID*)gpu0)); - //printf("At start of layered GetMultiGpuCompatibility\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo); - //printf("Completed layered GetMultiGpuCompatibility\n"); return result; } @@ -1290,11 +1282,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; ll_increment_use_count((XGL_VOID*)gpu); printf("OBJ[%llu] : USING gpu object %p (%lu total uses)\n", object_track_index++, (void*)gpu, ll_get_obj_uses((XGL_VOID*)gpu)); - //printf("At start of layered WsiX11AssociateConnection\n"); pCurObj = gpuw; pthread_once(&tabOnce, initLayerTable); XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo); - //printf("Completed layered WsiX11AssociateConnection\n"); return result; } diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py index bcedd8d7..b2119839 100755 --- a/xgl-layer-generate.py +++ b/xgl-layer-generate.py @@ -233,11 +233,15 @@ class Subcommand(object): create_line = '' destroy_line = '' using_line = ' ll_increment_use_count((XGL_VOID*)%s);\n printf("OBJ[%%llu] : USING %s object %%p (%%lu total uses)\\n", object_track_index++, (void*)%s, ll_get_obj_uses((XGL_VOID*)%s));\n' % (param0_name, param0_name, param0_name, param0_name) - if 'Create' in proto.name: + if 'Create' in proto.name or 'Alloc' in proto.name: create_line = ' printf("OBJ[%%llu] : CREATE %s object %%p\\n", object_track_index++, (void*)*%s);\n ll_insert_obj((XGL_VOID*)*%s, "%s");\n' % (proto.params[-1].ty.strip('*'), proto.params[-1].name, proto.params[-1].name, proto.params[-1].ty.strip('*')) - if 'Destroy' in proto.name: + if 'Destroy' in proto.name or 'Free' in proto.name: destroy_line = ' printf("OBJ[%%llu] : DESTROY %s object %%p\\n", object_track_index++, (void*)%s);\n ll_remove_obj((XGL_VOID*)%s);\n' % (param0_name, param0_name, param0_name) using_line = '' + if 'DestroyDevice' in proto.name: + destroy_line += ' // Report any remaining objects in LL\n objNode *pTrav = pObjLLHead;\n while (pTrav) {\n' + destroy_line += ' printf("OBJ ERROR : %s object %p has not been destroyed (was used %lu times).\\n", pTrav->objType, pTrav->pObj, pTrav->numUses);\n' + destroy_line += ' pTrav = pTrav->pNext;\n }\n' ret_val = '' stmt = '' if proto.ret != "XGL_VOID": @@ -385,7 +389,7 @@ class ObjectTrackerSubcommand(Subcommand): header_txt.append(' pTrav = pTrav->pNext;') header_txt.append(' }') header_txt.append(' // If we do not find obj, insert it and then intrement count') - header_txt.append(' printf("INFO : Unable to increment count for obj %p, will add to list as UNKNOWN type and increment count\\n", pObj);') + header_txt.append(' printf("OBJ WARN : Unable to increment count for obj %p, will add to list as UNKNOWN type and increment count\\n", pObj);') header_txt.append(' ll_insert_obj(pObj, "UNKNOWN");') header_txt.append(' ll_increment_use_count(pObj);') header_txt.append('}') -- cgit v1.2.3