From 4e3f712dafe2d6bf48b576483fe4d3645fc4a5c9 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Sun, 30 Nov 1997 00:00:43 +0000 Subject: [PATCH] add cbdata __FILE__,__LINE__ debugging --- src/cbdata.cc | 22 +++++++++++++++++++++- src/protos.h | 4 ++++ src/squid.h | 6 +++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/cbdata.cc b/src/cbdata.cc index 3b81dc0498..99c5a27841 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.9 1997/11/28 08:01:03 wessels Exp $ + * $Id: cbdata.cc,v 1.10 1997/11/29 17:00:43 wessels Exp $ * * DEBUG: section 45 Callback Data Registry * AUTHOR: Duane Wessels @@ -71,6 +71,10 @@ typedef struct _cbdata { struct _cbdata *next; int valid; int locks; +#if CBDATA_DEBUG + const char *file; + int line; +#endif } cbdata; static HASHCMP cbdata_cmp; @@ -97,7 +101,11 @@ cbdataInit(void) } void +#if CBDATA_DEBUG +cbdataAddDbg(void *p, const char *file, int line) +#else cbdataAdd(void *p) +#endif { cbdata *c; assert(p); @@ -107,6 +115,10 @@ cbdataAdd(void *p) c = xcalloc(1, sizeof(cbdata)); c->key = p; c->valid = 1; +#if CBDATA_DEBUG + c->file = file; + c->line = line; +#endif hash_join(htable, (hash_link *) c); cbdataCount++; } @@ -185,9 +197,17 @@ cbdataDump(StoreEntry * sentry) storeAppendPrintf(sentry, "%d cbdata entries\n", cbdataCount); for (hptr = hash_first(htable); hptr; hptr = hash_next(htable)) { c = (cbdata *) hptr; +#if CBDATA_DEBUG + storeAppendPrintf(sentry, "%20p %10s %d locks %s:%d\n", + c->key, + c->valid ? "VALID" : "NOT VALID", + c->locks, + c->file, c->line); +#else storeAppendPrintf(sentry, "%20p %10s %d locks\n", c->key, c->valid ? "VALID" : "NOT VALID", c->locks); +#endif } } diff --git a/src/protos.h b/src/protos.h index cba31b2f48..8b3faf4521 100644 --- a/src/protos.h +++ b/src/protos.h @@ -55,7 +55,11 @@ extern void wordlistDestroy(wordlist **); extern void configFreeMemory(void); extern void cbdataInit(void); +#if CBDATA_DEBUG +extern void cbdataAddDbg(void *p, const char *, int); +#else extern void cbdataAdd(void *p); +#endif extern void cbdataFree(void *p); extern void cbdataLock(void *p); extern void cbdataUnlock(void *p); diff --git a/src/squid.h b/src/squid.h index ccf3f94596..ff98c07997 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.135 1997/11/14 04:55:08 wessels Exp $ + * $Id: squid.h,v 1.136 1997/11/29 17:00:45 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -245,6 +245,10 @@ #define LOCAL_ARRAY(type,name,size) static type name[size] #endif +#if CBDATA_DEBUG +#define cbdataAdd(a) cbdataAddDbg(a,__FILE__,__LINE__) +#endif + #ifdef USE_GNUREGEX #include "GNUregex.h" #elif HAVE_REGEX_H -- 2.47.3