From: Amos Jeffries Date: Mon, 6 Oct 2014 19:38:03 +0000 (-0700) Subject: Cleanup CBDATA debugging messages X-Git-Tag: SQUID_3_5_0_1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0796f998e4085aa9261a21ac33aa1607eee12b2d;p=thirdparty%2Fsquid.git Cleanup CBDATA debugging messages * Remove duplicate labels from debug messages. function names are now automatically added. * Add debug messages to display method used for freeing CBDATA. Whether the object was deleted, or placement destructor called. --- diff --git a/src/base/CbcPointer.h b/src/base/CbcPointer.h index 53eeb3ac93..925fa86378 100644 --- a/src/base/CbcPointer.h +++ b/src/base/CbcPointer.h @@ -11,6 +11,7 @@ #include "base/TextException.h" #include "cbdata.h" +#include "Debug.h" /** \ingroup CBDATAAPI @@ -120,6 +121,9 @@ template void CbcPointer::clear() { +#if USE_CBDATA_DEBUG + debugs(45, 3, "cbc=" << (void*)cbc << ", lock=" << (void*)lock); +#endif cbdataReferenceDone(lock); // lock may be nil before and will be nil after cbc = NULL; } diff --git a/src/cbdata.cc b/src/cbdata.cc index bc93dca3c0..e8b1a4fee9 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -294,9 +294,9 @@ cbdataInternalAlloc(cbdata_type type) c->calls = std::vector (); c->addHistory("Alloc", file, line); dlinkAdd(c, &c->link, &cbdataEntries); - debugs(45, 3, "cbdataAlloc: " << p << " " << file << ":" << line); + debugs(45, 3, "Allocating " << p << " " << file << ":" << line); #else - debugs(45, 9, "cbdataAlloc: " << p); + debugs(45, 9, "Allocating " << p); #endif return p; @@ -316,11 +316,9 @@ cbdataInternalFree(void *p) c = (cbdata *) (((char *) p) - cbdata::Offset); #endif #if USE_CBDATA_DEBUG - - debugs(45, 3, "cbdataFree: " << p << " " << file << ":" << line); + debugs(45, 3, p << " " << file << ":" << line); #else - - debugs(45, 9, "cbdataFree: " << p); + debugs(45, 9, p); #endif c->check(__LINE__); @@ -332,12 +330,12 @@ cbdataInternalFree(void *p) #endif if (c->locks) { - debugs(45, 9, "cbdataFree: " << p << " has " << c->locks << " locks, not freeing"); + debugs(45, 9, p << " has " << c->locks << " locks, not freeing"); return NULL; } --cbdataCount; - debugs(45, 9, "cbdataFree: Freeing " << p); + debugs(45, 9, "Freeing " << p); #if USE_CBDATA_DEBUG dlinkDelete(&c->link, &cbdataEntries); @@ -356,9 +354,15 @@ cbdataInternalFree(void *p) cbdata_type theType = c->type; #if HASHED_CBDATA hash_remove_link(cbdata_htable, &c->hash); +#if USE_CBDATA_DEBUG + debugs(45, 3, "Call delete " << (void*)c << " " << file << ":" << line); +#endif delete c; cbdata_index[theType].pool->freeOne((void *)p); #else +#if USE_CBDATA_DEBUG + debugs(45, 3, "Call cbdata::~cbdata() " << (void*)c << " " << file << ":" << line); +#endif c->cbdata::~cbdata(); cbdata_index[theType].pool->freeOne(c); #endif @@ -384,15 +388,10 @@ cbdataInternalLock(const void *p) #endif #if USE_CBDATA_DEBUG - - debugs(45, 3, "cbdataLock: " << p << "=" << (c ? c->locks + 1 : -1) << " " << file << ":" << line); - + debugs(45, 3, p << "=" << (c ? c->locks + 1 : -1) << " " << file << ":" << line); c->addHistory("Reference", file, line); - #else - - debugs(45, 9, "cbdataLock: " << p << "=" << (c ? c->locks + 1 : -1)); - + debugs(45, 9, p << "=" << (c ? c->locks + 1 : -1)); #endif c->check(__LINE__); @@ -421,15 +420,10 @@ cbdataInternalUnlock(const void *p) #endif #if USE_CBDATA_DEBUG - - debugs(45, 3, "cbdataUnlock: " << p << "=" << (c ? c->locks - 1 : -1) << " " << file << ":" << line); - + debugs(45, 3, p << "=" << (c ? c->locks - 1 : -1) << " " << file << ":" << line); c->addHistory("Dereference", file, line); - #else - - debugs(45, 9, "cbdataUnlock: " << p << "=" << (c ? c->locks - 1 : -1)); - + debugs(45, 9, p << "=" << (c ? c->locks - 1 : -1)); #endif c->check(__LINE__); @@ -445,7 +439,7 @@ cbdataInternalUnlock(const void *p) --cbdataCount; - debugs(45, 9, "cbdataUnlock: Freeing " << p); + debugs(45, 9, "Freeing " << p); #if USE_CBDATA_DEBUG @@ -466,9 +460,15 @@ cbdataInternalUnlock(const void *p) cbdata_type theType = c->type; #if HASHED_CBDATA hash_remove_link(cbdata_htable, &c->hash); +#if USE_CBDATA_DEBUG + debugs(45, 3, "Call delete " << (void*)c << " " << file << ":" << line); +#endif delete c; cbdata_index[theType].pool->freeOne((void *)p); #else +#if USE_CBDATA_DEBUG + debugs(45, 3, "Call cbdata::~cbdata() " << (void*)c << " " << file << ":" << line); +#endif c->cbdata::~cbdata(); cbdata_index[theType].pool->freeOne(c); #endif @@ -482,7 +482,7 @@ cbdataReferenceValid(const void *p) if (p == NULL) return 1; /* A NULL pointer cannot become invalid */ - debugs(45, 9, "cbdataReferenceValid: " << p); + debugs(45, 9, p); #if HASHED_CBDATA c = (cbdata *) hash_lookup(cbdata_htable, p);