apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sander Striker" <stri...@apache.org>
Subject RE: [PATCH] Add --enable-pool-debug to configure
Date Wed, 23 Jan 2002 08:45:58 GMT
> Sander Striker wrote:
> > 
> > Ok, that sounds like a plan.
> > One minor nit which would be great if we could agree on:
> > simply defining APR_POOL_DEBUG should enable the basic debug
> > mode.
> > 
> 
> +1...

Working on it... [bit short on time at the moment]
 
> Most likely it would be best to do the mojo in apr_pools.h and adjust
> apr_pools.c accordingly. For example:
> 
>    #ifdef APR_POOL_DEBUG
>     #if APR_POOL_DEBUG == 2
>      #define APR_POOL_DEBUG_LEVEL 2
>     #elif APR_POOL_DEBUG == 1
>      #define APR_POOL_DEBUG_LEVEL 1
>     #else
>      #define APR_POOL_DEBUG_LEVEL 0
>     #endif
>    #endif

Well, I don't really feel like adding all this...
 
> and use APR_POOL_DEBUG_LEVEL in apr_pools.c otherwise you run into lots
> of ugly stuff in apr_pool.c. Recall that compiling with -DAPR_POOLS_DEBUG
> will not result in
> 
> 	#if APR_POOLS_DEBUG == 0
> 
> being true.

This trick will work (at the start of apr_pools.c):

#if defined(APR_POOL_DEBUG) && (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG -
0 == 0)
#undef APR_POOL_DEBUG
#define APR_POOL_DEBUG 1
#endif

> And you can't do stuff like
> 
> 	#if APR_POOLS_DEBUG == 0 || defined(APR_POOLS_DEBUG)
> 
> since that would grab the non 0 ones as well.

This would actually be ok, since there is a common debug codebase
for all the debug modes (a malloc based one).


The approach that looked most appealing to me is the following:

| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---------------------------------
|   |   |   |   |   |   |   | x |  General debug code enabled (good for --with-efence)

|   |   |   |   |   |   | x |   |  Verbose output on stderr (report CREATE, CLEAR, DESTROY)

|   |   |   |   |   | x |   |   |  Lifetime checking. On each use of a pool, check its lifetime.
                                   If the pool is out of scope, abort().  In combination with
                                   the verbose flag above, it will output LIFE in such an
event
                                   prior to aborting.

|   |   |   |   | x |   |   |   |  Pool owner checking.  On each use of a pool, check if the
                                   current thread is the pools owner.  If not, abort().  In
                                   combination with the verbose flag above, it will output
OWNER
                                   in such an event prior to aborting.  Use the debug function
                                   apr_pool_set_owner() to switch a pools ownership.

I haven't thought of more modes, but this seems extentable enough to me.  It also allows
combinations.

At configure time I'd like to be able to do the following:

./configure --enable-pool-debug           ; default debug mode (malloc system)
./configure --enable-pool-debug=yes       ; same

./configure --enable-pool-debug=verbose   ; verbose output
./configure --enable-pool-debug=lifetime  ; lifetime checking
./configure --enable-pool-debug=owner     ; owner checking

./configure --enable-pool-debug=all       ; enable all debug modes

Or even:
./configure --enable-pool-debug="verbose owner"


Thoughts?

Sander

Mime
View raw message