dgaudet 98/01/30 16:24:33
Modified: src CHANGES
src/main alloc.c
Log:
People are challenging me to write something in assembly... well gcc is so
nice that I don't have to do this one in assembly. MAKE_TABLE_PROFILE is
a debugging mode that makes it easier to find tables which are created
with too small an initial guess. It uses __builtin_return_address()
which is a gcc directive that avoids the need for arch specific assembly
to find the return address of the function you're in... super ultra cool
for debugging.
Revision Changes Path
1.608 +6 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.607
retrieving revision 1.608
diff -u -r1.607 -r1.608
--- CHANGES 1998/01/30 19:30:31 1.607
+++ CHANGES 1998/01/31 00:24:29 1.608
@@ -1,5 +1,11 @@
Changes with Apache 1.3b4
+ *) Tweaked the headers_out table size, and the subprocess_env
+ table size guess in rename_original_environment(). Added
+ MAKE_TABLE_PROFILE which can help discover make_table()
+ calls that use too small an initial guess, see alloc.c.
+ [Dean Gaudet]
+
*) Options and AllowOverrides weren't properly merging in the main
server setting inside vhosts (only an issue when you have no
<Directory> or other section containing an Options that affects
1.73 +37 -7 apache-1.3/src/main/alloc.c
Index: alloc.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/alloc.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- alloc.c 1998/01/27 10:04:35 1.72
+++ alloc.c 1998/01/31 00:24:32 1.73
@@ -97,6 +97,17 @@
*/
/* #define POOL_DEBUG */
+/* Provide diagnostic information about make_table() calls which are
+ * possibly too small. This requires a recent gcc which supports
+ * __builtin_return_address(). The error_log output will be a
+ * message such as:
+ * table_push: table created by 0x804d874 hit limit of 10
+ * Use "l *0x804d874" to find the source that corresponds to. It
+ * indicates that a table allocated by a call at that address has
+ * possibly too small an initial table size guess.
+ */
+/* #define MAKE_TABLE_PROFILE */
+
#ifdef POOL_DEBUG
#ifdef ALLOC_USE_MALLOC
# error "sorry, no support for ALLOC_USE_MALLOC and POOL_DEBUG at the same
time"
@@ -113,7 +124,6 @@
#define BLOCK_MINALLOC 0
#endif
-
/*****************************************************************
*
* Managing free storage blocks...
@@ -890,14 +900,34 @@
* cases they do this for.
*/
array_header a;
+#ifdef MAKE_TABLE_PROFILE
+ void *creator;
+#endif
};
+#ifdef MAKE_TABLE_PROFILE
+static table_entry *table_push(table *t)
+{
+ if (t->a.nelts == t->a.nalloc) {
+ fprintf(stderr,
+ "table_push: table created by %p hit limit of %u\n",
+ t->creator, t->a.nalloc);
+ }
+ return (table_entry *) push_array(&t->a);
+}
+#else
+#define table_push(t) ((table_entry *) push_array(&(t)->a))
+#endif
+
API_EXPORT(table *) make_table(pool *p, int nelts)
{
table *t = palloc(p, sizeof(table));
make_array_core(&t->a, p, nelts, sizeof(table_entry));
+#ifdef MAKE_TABLE_PROFILE
+ t->creator = __builtin_return_address(0);
+#endif
return t;
}
@@ -967,7 +997,7 @@
}
if (!done) {
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = pstrdup(t->a.pool, key);
elts->val = pstrdup(t->a.pool, val);
}
@@ -1013,7 +1043,7 @@
}
if (!done) {
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = key;
elts->val = val;
}
@@ -1055,7 +1085,7 @@
return;
}
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = pstrdup(t->a.pool, key);
elts->val = pstrdup(t->a.pool, val);
}
@@ -1085,7 +1115,7 @@
}
}
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = key;
elts->val = val;
}
@@ -1094,7 +1124,7 @@
{
table_entry *elts = (table_entry *) t->a.elts;
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = pstrdup(t->a.pool, key);
elts->val = pstrdup(t->a.pool, val);
}
@@ -1116,7 +1146,7 @@
}
#endif
- elts = (table_entry *) push_array(&t->a);
+ elts = (table_entry *) table_push(t);
elts->key = key;
elts->val = val;
}