From 37d95daaee0ab1c5e5cecf8fded0aeb292e589ea Mon Sep 17 00:00:00 2001 From: root Date: Mon, 19 Oct 2009 12:38:49 -0500 Subject: [PATCH] fprintf() debugging statements: * report all resources being freed * report all resources being added * show calls to DeleteWindow * show calls to CrushTree * show calls to xfree by: FreeClientResources() -> DeleteWindow() -> CrushTree() * FreePicture() - report address of each pPicture->pDrawable access * CrushTree() - clearly indicate which return was used --- dix/main.c | 2 ++ dix/resource.c | 26 ++++++++++++++++++++++++++ dix/window.c | 22 ++++++++++++++++++---- include/os.h | 2 ++ os/utils.c | 8 ++++++-- render/picture.c | 7 +++++++ 6 files changed, 61 insertions(+), 6 deletions(-) diff --git a/dix/main.c b/dix/main.c index f96245a..5250af2 100644 --- a/dix/main.c +++ b/dix/main.c @@ -135,6 +135,8 @@ int main(int argc, char *argv[], char *envp[]) int i; HWEventQueueType alwaysCheckForInput[2]; + Xfree_show_debug = 0; + display = "0"; InitRegions(); diff --git a/dix/resource.c b/dix/resource.c index d3641df..da756f4 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -475,6 +475,20 @@ AddResource(XID id, RESTYPE type, pointer value) rrec->elements++; if (!(id & SERVER_BIT) && (id >= rrec->expectID)) rrec->expectID = id + 1; + + fprintf(stderr, + "++ AddResource - " + "resource base: 0x%x, " + "bucket: %i, " + "this: 0x%x, " + "resource type: %i" + "\n", + rrec->resources, + Hash(client, id), + res, + res->type + ); + CallResourceStateCallback(ResourceStateAdding, res); return TRUE; } @@ -809,6 +823,18 @@ FreeClientResources(ClientPtr client) CallResourceStateCallback(ResourceStateFreeing, this); + fprintf(stderr, "++ FreeClientResources - " + "resource base: 0x%x, " + "bucket: %i, " + "this: 0x%x, " + "resource type: %i" + "\n", + resources, + j, + this, + this->type + ); + (*DeleteFuncs[rtype & TypeMask])(this->value, this->id); xfree(this); } diff --git a/dix/window.c b/dix/window.c index caff1cb..afa9642 100644 --- a/dix/window.c +++ b/dix/window.c @@ -854,8 +854,11 @@ CrushTree(WindowPtr pWin) UnrealizeWindowProcPtr UnrealizeWindow; xEvent event; - if (!(pChild = pWin->firstChild)) - return; + fprintf(stderr, "++++ CrushTree Started\n"); + if (!(pChild = pWin->firstChild)) { + fprintf(stderr, "++++ CrushTree Finished (!(pChild = pWin->firstChild))\n"); + return; + } UnrealizeWindow = pWin->drawable.pScreen->UnrealizeWindow; while (1) { @@ -884,16 +887,22 @@ CrushTree(WindowPtr pWin) } FreeWindowResources(pChild); dixFreePrivates(pChild->devPrivates); + Xfree_show_debug = 1; xfree(pChild); + Xfree_show_debug = 0; if ( (pChild = pSib) ) break; pChild = pParent; pChild->firstChild = NullWindow; pChild->lastChild = NullWindow; - if (pChild == pWin) - return; + if (pChild == pWin) { + fprintf(stderr, "++++ CrushTree Finished (pChild == pWin)\n"); + return; + } } } + + fprintf(stderr, "++++ CrushTree Finished (Normally)\n"); } /***** @@ -909,6 +918,8 @@ DeleteWindow(pointer value, XID wid) WindowPtr pWin = (WindowPtr)value; xEvent event; + fprintf(stderr, "++++ DeleteWindow Started \n"); + UnmapWindow(pWin, FALSE); CrushTree(pWin); @@ -937,6 +948,9 @@ DeleteWindow(pointer value, XID wid) xfree(dixLookupPrivate(&pWin->devPrivates, FocusPrivatesKey)); dixFreePrivates(pWin->devPrivates); xfree(pWin); + + fprintf(stderr, "++++ DeleteWindow Ended \n"); + return Success; } diff --git a/include/os.h b/include/os.h index 2f6b0c0..4fec9a6 100644 --- a/include/os.h +++ b/include/os.h @@ -52,6 +52,8 @@ SOFTWARE. #include "misc.h" #include +int Xfree_show_debug; + #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1 #define SCREEN_SAVER_FORCER 2 diff --git a/os/utils.c b/os/utils.c index 3718b17..8b55279 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1150,8 +1150,12 @@ XNFrealloc(pointer ptr, unsigned long amount) void Xfree(pointer ptr) { - if (ptr) - free(ptr); + if (ptr) { + if (Xfree_show_debug) + fprintf(stderr, "++++ Xfree called, free memory at 0x%x\n", + ptr); + free(ptr); + } } #endif /* !INTERNAL_MALLOC */ diff --git a/render/picture.c b/render/picture.c index e1a2972..2faa88b 100644 --- a/render/picture.c +++ b/render/picture.c @@ -1543,6 +1543,13 @@ FreePicture (pointer value, if (pPicture->pDrawable) { + fprintf(stderr, "++++ FreePicture - " + "Address of pPicture data: 0x%x, " + "Address of pPicture->pDrawable data: 0x%x\n", + pPicture, + pPicture->pDrawable + ); + ScreenPtr pScreen = pPicture->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); -- 1.6.4.4