You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Ian Holsman <ia...@apache.org> on 2001/12/14 08:03:27 UTC

[PATCH] APR_DEBUG_BUCKET option

This is a patch to help debugging bucket operations.
it adds a file/line to each bucket so that you can tell where it is
created.

Index: include/http_protocol.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_protocol.h,v
retrieving revision 1.67
diff -u -r1.67 http_protocol.h
--- include/http_protocol.h	2001/12/02 23:13:32	1.67
+++ include/http_protocol.h	2001/12/14 06:58:46
@@ -652,8 +652,19 @@
   * @return The new bucket, or NULL if allocation failed
   * @deffunc apr_bucket *ap_bucket_error_create(int error, const char 
*buf, apr_pool_t *p)
   */
+
+#ifdef APR_DEBUG_BUCKET
+#define ap_bucket_error_create(error,buf,p) \
+ 
ap_bucket_error_create_debug(error,buf,p,__FILE__,__LINE__)
+
+AP_DECLARE(apr_bucket *) ap_bucket_error_create_debug(int error,
+                const char *buf, apr_pool_t *p,
+ 
			const char*file,int line);
+#else
  AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error,
                  const char *buf, apr_pool_t *p);
+#endif
+

  AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, 
apr_bucket_brigade *b);
  AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, 
apr_bucket_brigade *b);
Index: server/error_bucket.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/error_bucket.c,v
retrieving revision 1.9
diff -u -r1.9 error_bucket.c
--- server/error_bucket.c	2001/09/22 22:37:04	1.9
+++ server/error_bucket.c	2001/12/14 06:59:01
@@ -87,8 +87,14 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+AP_DECLARE(apr_bucket *) ap_bucket_error_create_debug(int error,
+ 
	const char *buf, apr_pool_t *p,
+ 
	const char *file, int line)
+#else
  AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error,
  		const char *buf, apr_pool_t *p)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_eos.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_eos.c,v
retrieving revision 1.30
diff -u -r1.30 apr_buckets_eos.c
--- srclib/apr-util/buckets/apr_buckets_eos.c	2001/09/22 22:36:07	1.30
+++ srclib/apr-util/buckets/apr_buckets_eos.c	2001/12/14 06:59:05
@@ -79,12 +79,17 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_eos_create_debug(const 
char*file,int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_eos_create(void)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

      APR_BUCKET_INIT(b);
      b->free = free;
+
      return apr_bucket_eos_make(b);
  }

Index: srclib/apr-util/buckets/apr_buckets_file.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_file.c,v
retrieving revision 1.63
diff -u -r1.63 apr_buckets_file.c
--- srclib/apr-util/buckets/apr_buckets_file.c	2001/12/02 00:28:11	1.63
+++ srclib/apr-util/buckets/apr_buckets_file.c	2001/12/14 06:59:06
@@ -205,9 +205,16 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_file_create_debug(apr_file_t *fd,
+                                                 apr_off_t offset,
+ 
											 apr_size_t len, apr_pool_t *p,
+ 
											 const char*file,int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
-                                                 apr_off_t offset,
-                                                 apr_size_t len, 
apr_pool_t *p)
+                                                 apr_off_t offset,
+ 
											 apr_size_t len, apr_pool_t *p)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_flush.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_flush.c,v
retrieving revision 1.22
diff -u -r1.22 apr_buckets_flush.c
--- srclib/apr-util/buckets/apr_buckets_flush.c	2001/09/22 22:36:07	1.22
+++ srclib/apr-util/buckets/apr_buckets_flush.c	2001/12/14 06:59:06
@@ -78,8 +78,11 @@

      return b;
  }
-
+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_flush_create_debug(const 
char*file,int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_flush_create(void)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_heap.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_heap.c,v
retrieving revision 1.39
diff -u -r1.39 apr_buckets_heap.c
--- srclib/apr-util/buckets/apr_buckets_heap.c	2001/11/12 03:22:25	1.39
+++ srclib/apr-util/buckets/apr_buckets_heap.c	2001/12/14 06:59:06
@@ -111,8 +111,14 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_heap_create_debug(const char *buf,
+                                                 apr_size_t length, int 
copy,
+ 
											 const char*file, int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf,
                                                   apr_size_t length, 
int copy)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_mmap.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_mmap.c,v
retrieving revision 1.46
diff -u -r1.46 apr_buckets_mmap.c
--- srclib/apr-util/buckets/apr_buckets_mmap.c	2001/11/29 21:14:25	1.46
+++ srclib/apr-util/buckets/apr_buckets_mmap.c	2001/12/14 06:59:07
@@ -108,10 +108,16 @@
      return b;
  }

-
+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_mmap_create_debug(apr_mmap_t *mm,
+                                                 apr_off_t start,
+                                                 apr_size_t length,
+ 
											 const char*file, int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm,
                                                   apr_off_t start,
                                                   apr_size_t length)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_pipe.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_pipe.c,v
retrieving revision 1.43
diff -u -r1.43 apr_buckets_pipe.c
--- srclib/apr-util/buckets/apr_buckets_pipe.c	2001/11/12 03:22:25	1.43
+++ srclib/apr-util/buckets/apr_buckets_pipe.c	2001/12/14 06:59:07
@@ -136,8 +136,13 @@

      return b;
  }
-
+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_pipe_create_debug(apr_file_t *p,
+ 
												   const char*file,
+ 
												   int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *p)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_pool.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_pool.c,v
retrieving revision 1.25
diff -u -r1.25 apr_buckets_pool.c
--- srclib/apr-util/buckets/apr_buckets_pool.c	2001/09/29 03:29:41	1.25
+++ srclib/apr-util/buckets/apr_buckets_pool.c	2001/12/14 06:59:09
@@ -159,8 +159,14 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_pool_create_debug(
+ 
	const char *buf, apr_size_t length, apr_pool_t *pool,
+ 
	const char*file, int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_pool_create(
  		const char *buf, apr_size_t length, apr_pool_t *pool)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_simple.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_simple.c,v
retrieving revision 1.36
diff -u -r1.36 apr_buckets_simple.c
--- srclib/apr-util/buckets/apr_buckets_simple.c	2001/11/12 03:22:25	1.36
+++ srclib/apr-util/buckets/apr_buckets_simple.c	2001/12/14 06:59:10
@@ -104,9 +104,14 @@

      return b;
  }
-
+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_immortal_create_debug(
+ 
	const char *buf, apr_size_t length,
+ 
	const char *file, int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(
  		const char *buf, apr_size_t length)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

@@ -143,8 +148,14 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_transient_create_debug(
+ 
	const char *buf, apr_size_t length,
+ 
	const char *file, int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_transient_create(
  		const char *buf, apr_size_t length)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/buckets/apr_buckets_socket.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_socket.c,v
retrieving revision 1.34
diff -u -r1.34 apr_buckets_socket.c
--- srclib/apr-util/buckets/apr_buckets_socket.c	2001/11/12 03:22:25	1.34
+++ srclib/apr-util/buckets/apr_buckets_socket.c	2001/12/14 06:59:11
@@ -132,7 +132,13 @@
      return b;
  }

+#ifdef APR_DEBUG_BUCKET
+APU_DECLARE(apr_bucket *) apr_bucket_socket_create_debug(apr_socket_t *p,
+ 
													 const char* file,
+ 
													 int line)
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *p)
+#endif
  {
      apr_bucket *b = (apr_bucket *)malloc(sizeof(*b));

Index: srclib/apr-util/include/apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.121
diff -u -r1.121 apr_buckets.h
--- srclib/apr-util/include/apr_buckets.h	2001/11/12 03:22:25	1.121
+++ srclib/apr-util/include/apr_buckets.h	2001/12/14 06:59:15
@@ -59,6 +59,7 @@
  #ifndef APR_BUCKETS_H
  #define APR_BUCKETS_H

+#define APR_DEBUG_BUCKET 1
  #include "apu.h"
  #include "apr_network_io.h"
  #include "apr_file_io.h"
@@ -242,6 +243,16 @@
       *  the value of this field will be (apr_size_t)(-1).
       */
      apr_size_t length;
+#ifdef APR_DEBUG_BUCKET
+ 
/**
+ 
  * the File where this bucket was created
+ 
  */
+ 
const char*file;
+ 
/**
+ 
  * the line number in the file
+ 
  */
+ 
int line;
+#endif
      /** The start of the data in the bucket relative to the private base
       *  pointer.  The vast majority of bucket types allow a fixed block of
       *  data to be referenced by multiple buckets, each bucket pointing to
@@ -432,8 +443,11 @@
   * Initialize a new bucket's prev/next pointers
   * @param e The bucket to initialize
   */
+#ifdef APR_DEBUG_BUCKET
+#define APR_BUCKET_INIT(e) {APR_RING_ELEM_INIT((e), 
link);e->file=file;e->line=line;}
+#else
  #define APR_BUCKET_INIT(e)	APR_RING_ELEM_INIT((e), link)
-
+#endif
  /**
   * Determine if a bucket is a FLUSH bucket
   * @param e The bucket to inspect
@@ -1061,7 +1075,13 @@
   * coming from down the filter stack.  All filters should flush at 
this point.
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_eos_create() 
apr_bucket_eos_create_debug(__FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_eos_create_debug(const 
char*file,int line);
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_eos_create(void);
+#endif

  /**
   * Make the bucket passed in an EOS bucket.  This indicates that there 
is no
@@ -1078,7 +1098,13 @@
   * best we can do.
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_flush_create() 
apr_bucket_flush_create_debug(__FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_flush_create_debug(const 
char*file,int line);
+#else
  APU_DECLARE(apr_bucket *) apr_bucket_flush_create(void);
+#endif

  /**
   * Make the bucket passed in a FLUSH  bucket.  This indicates that 
filters
@@ -1095,8 +1121,19 @@
   * @param nbyte The size of the data to insert.
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_immortal_create(buf,nbyte)  \
+ 
apr_bucket_immortal_create_debug(buf,nbyte, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_immortal_create_debug(const char*buf,
+ 
													   apr_size_t nbyte,
+ 
													   const char*file,
+ 
													   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf,
                                                       apr_size_t nbyte);
+#endif

  /**
   * Make the bucket passed in a bucket refer to long-lived data
@@ -1115,8 +1152,20 @@
   * @param nbyte The size of the data to insert.
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_transient_create(buf,nbyte)  \
+ 
apr_bucket_transient_create_debug(buf,nbyte, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_transient_create_debug(const char*buf,
+ 
													   apr_size_t nbyte,
+ 
													   const char*file,
+ 
													   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf,
-                                                      apr_size_t nbyte);
+                                                     apr_size_t nbyte);
+#endif
+

  /**
   * Make the bucket passed in a bucket refer to stack data
@@ -1141,8 +1190,22 @@
   * @param copy Whether to copy the data into newly-allocated memory or not
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_heap_create(buf,nbyte,copy)  \
+ 
apr_bucket_heap_create_debug(buf,nbyte,copy, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_heap_create_debug(const char*buf,
+ 
												   apr_size_t nbyte,
+ 
												   int copy,
+ 
												   const char*file,
+ 
												   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf,
-                                                 apr_size_t nbyte, int 
copy);
+                                                 apr_size_t nbyte,
+ 
											 int copy);
+#endif
+
  /**
   * Make the bucket passed in a bucket refer to heap data
   * @param b The bucket to make into a HEAP bucket
@@ -1162,9 +1225,22 @@
   * @param pool The pool the memory was allocated from
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_pool_create(buf,length,pool)  \
+ 
apr_bucket_pool_create_debug(buf,length,pool, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_pool_create_debug(const char*buf,
+ 
												   apr_size_t length,
+ 
												   apr_pool_t *pool,
+ 
												   const char*file,
+ 
												   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf,
                                                   apr_size_t length,
-                                                 apr_pool_t *pool);
+ 
											 apr_pool_t *pool);
+#endif
+

  /**
   * Make the bucket passed in a bucket refer to pool data
@@ -1187,10 +1263,23 @@
   * @param length The number of bytes referred to by this bucket
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_mmap_create(mm,start,length)  \
+ 
apr_bucket_mmap_create_debug(mm,start,length, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_mmap_create_debug(apr_mmap_t *mm,
+ 
												   apr_off_t start,
+ 
												   apr_size_t length,
+ 
												   const char*file,
+ 
												   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm,
                                                   apr_off_t start,
                                                   apr_size_t length);
+#endif

+
  /**
   * Make the bucket passed in a bucket refer to an MMAP'ed file
   * @param b The bucket to make into a MMAP bucket
@@ -1210,7 +1299,18 @@
   * @param thissocket The socket to put in the bucket
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_socket_create(thissock)  \
+ 
apr_bucket_socket_create_debug(thissock, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_socket_create_debug(apr_socket_t 
*thissock,
+ 
												   const char*file,
+ 
												   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t 
*thissock);
+#endif
+
  /**
   * Make the bucket passed in a bucket refer to a socket
   * @param b The bucket to make into a SOCKET bucket
@@ -1225,7 +1325,17 @@
   * @param thispipe The pipe to put in the bucket
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_pipe_create(thispipe)  \
+ 
apr_bucket_pipe_create_debug(thispipe, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_pipe_create_debug(apr_file_t 
*thispipe,
+ 
												   const char*file,
+ 
												   int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe);
+#endif

  /**
   * Make the bucket passed in a bucket refer to a pipe
@@ -1245,11 +1355,23 @@
   *          while reading from this file bucket
   * @return The new bucket, or NULL if allocation failed
   */
+#ifdef APR_DEBUG_BUCKET
+#define apr_bucket_file_create(fd,offset,len,p)  \
+ 
apr_bucket_file_create_debug(fd,offset,len,p, __FILE__,__LINE__)
+
+APU_DECLARE(apr_bucket *) apr_bucket_file_create_debug(apr_file_t *fd,
+                                                 apr_off_t offset,
+                                                 apr_size_t len,
+                                                 apr_pool_t *p,
+ 
										     const char*file,
+ 
											 int line);
+#else
+
  APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
                                                   apr_off_t offset,
                                                   apr_size_t len,
                                                   apr_pool_t *p);
-
+#endif
  /**
   * Make the bucket passed in a bucket refer to a file
   * @param b The bucket to make into a FILE bucket

Re: [PATCH] APR_DEBUG_BUCKET option

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Thu, Dec 13, 2001 at 11:03:27PM -0800, Ian Holsman wrote:
> This is a patch to help debugging bucket operations.
> it adds a file/line to each bucket so that you can tell where it is
> created.

If you lose all of the extra formatting changes, you might
have something here.  =)  

BTW, did this help track down your problem?  -- justin


Re: [PATCH] APR_DEBUG_BUCKET option

Posted by Ian Holsman <ia...@apache.org>.
Cliff Woolley wrote:

>    Hmmm... it's too bad that this adds so many #ifdefs to code that's
> largely #ifdef free...  I guess I can see some instances where this would
> be helpful, but I'm not sure it's worth cluttering up all the buckets code
> for.  I'm trying to think of another way to get roughly the same
> information without all the mess.  What if we did it at bucket-insertion
> time?  That way you'd only have to change the brigade insert macros.  A
> bucket that never got inserted into a brigade can't hurt you (except to
> leak memory ;) anyway.  And actually, knowing when a particular bucket got
> stuck in the brigade it's currently in is also valuable information...
> 

Thats a probably a better way.
and will be much more helpful.

(and justin.. I haven't tried it yet)
so far it is looking like it is somewhere in mod-include and
a bucket not on a brigade or something. (brian and jin were debugging 
this late last night)


> --Cliff
> 
> --------------------------------------------------------------
>    Cliff Woolley
>    cliffwoolley@yahoo.com
>    Charlottesville, VA
> 
> 
> 
> 
> 



Re: [PATCH] APR_DEBUG_BUCKET option

Posted by Cliff Woolley <cl...@yahoo.com>.

   Hmmm... it's too bad that this adds so many #ifdefs to code that's
largely #ifdef free...  I guess I can see some instances where this would
be helpful, but I'm not sure it's worth cluttering up all the buckets code
for.  I'm trying to think of another way to get roughly the same
information without all the mess.  What if we did it at bucket-insertion
time?  That way you'd only have to change the brigade insert macros.  A
bucket that never got inserted into a brigade can't hurt you (except to
leak memory ;) anyway.  And actually, knowing when a particular bucket got
stuck in the brigade it's currently in is also valuable information...

--Cliff

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA