ac_help="$ac_help
--enable-xmalloc-statistics
Show malloc statistics in status page"
+ac_help="$ac_help
+ --enable-mem-gen-trace
+ Trace memory alloc/free to /tmp/squid.alloc"
ac_help="$ac_help
--enable-async-io Do ASYNC disk I/O using threads"
ac_help="$ac_help
fi
+# Check whether --enable-mem-gen-trace or --disable-mem-gen-trace was given.
+if test "${enable_mem_gen_trace+set}" = set; then
+ enableval="$enable_mem_gen_trace"
+ if test "$enableval" = "yes" ; then
+ echo "Alloc trace to file enabled"
+ cat >> confdefs.h <<\EOF
+#define MEM_GEN_TRACE 1
+EOF
+
+ fi
+
+fi
# Check whether --enable-async_io or --disable-async_io was given.
if test "${enable_async_io+set}" = set; then
dnl
dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9)
dnl
-dnl $Id: configure.in,v 1.101 1998/02/21 18:46:31 rousskov Exp $
+dnl $Id: configure.in,v 1.102 1998/02/27 05:51:14 kostas Exp $
dnl
dnl
dnl
AC_INIT(src/main.c)
AC_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.101 $)dnl
+AC_REVISION($Revision: 1.102 $)dnl
AC_PREFIX_DEFAULT(/usr/local/squid)
AC_CONFIG_AUX_DIR(aux)
esac
])
+
AC_ARG_ENABLE(xmalloc_debug,
[ --enable-xmalloc-debug Do some simple malloc debugging],
[ if test "$enableval" = "yes" ; then
fi
])
+AC_ARG_ENABLE(mem-gen-trace,
+[ --enable-mem-gen-trace Do trace of memory stuff],
+[ if test "$enableval" = "yes" ; then
+ echo "Memory trace (to file) enabled"
+ AC_DEFINE(MEM_GEN_TRACE)
+ fi
+])
+
AC_ARG_ENABLE(useragent_log,
[ --enable-useragent-log Enable logging of User-Agent header],
[ if test "$enableval" = "yes" ; then
/* Define to have a detailed trace of memory allocations */
#undef XMALLOC_TRACE
+/* Define to have mem trace to file */
+#undef MEM_GEN_TRACE
+
/* Define to use async disk I/O operations */
#undef USE_ASYNC_IO
/*
- * $Id: util.c,v 1.46 1998/02/26 22:16:26 kostas Exp $
+ * $Id: util.c,v 1.47 1998/02/27 05:51:15 kostas Exp $
*
* DEBUG:
* AUTHOR: Harvest Derived
extern int sys_nerr;
+#if MEM_GEN_TRACE
+
+static FILE *tracefp;
+
+void
+log_trace_init(char *fn)
+{
+ tracefp=fopen(fn,"w+");
+ if (!tracefp) {
+ perror("log_trace_init");
+ exit(1);
+ }
+}
+
+void
+log_trace_done()
+{
+ fclose(tracefp);
+}
+
+#endif
+
#if XMALLOC_STATISTICS
#define DBG_MAXSIZE (1024*1024)
#define DBG_GRAIN (16)
static int malloc_sizes[DBG_MAXINDEX + 1];
static int dbg_stat_init = 0;
+
static void
stat_init(void)
{
if (sz < 1)
sz = 1;
+
if ((p = malloc(sz)) == NULL) {
if (failure_notify) {
snprintf(msg, 128, "xmalloc: Unable to allocate %d bytes!\n",
#endif
#if XMALLOC_TRACE
xmalloc_show_trace(p, 1);
+#endif
+#if MEM_GEN_TRACE
+ fprintf(tracefp, "m:%d:%x\n",sz,p);
#endif
return (p);
}
#if XMALLOC_TRACE
xmalloc_show_trace(s, -1);
#endif
+
#if XMALLOC_DEBUG
check_free(s);
#endif
if (s != NULL)
free(s);
+#if MEM_GEN_TRACE
+ fprintf(tracefp,"f:%x\n",s);
+#endif
}
/* xxfree() - like xfree(), but we already know s != NULL */
check_free(s);
#endif
free(s);
+#if MEM_GEN_TRACE
+ fprintf(tracefp,"f:%x\n",s);
+#endif
}
/*
#endif
#if XMALLOC_TRACE
xmalloc_show_trace(p, 1);
+#endif
+#if MEM_GEN_TRACE
+ fprintf(tracefp,"c:%d:%d:%x\n", n, sz,p);
#endif
return (p);
}
/*
- * $Id: main.cc,v 1.227 1998/02/26 18:00:45 wessels Exp $
+ * $Id: main.cc,v 1.228 1998/02/27 05:51:15 kostas Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
static void watch_child(char **);
static void setEffectiveUser(void);
static void normal_shutdown(void);
+#if MEM_GEN_TRACE
+extern void log_trace_done();
+extern void log_trace_init(char *);
+#endif
static void
usage(void)
int errcount = 0;
int n; /* # of GC'd objects */
time_t loop_delay;
+#if MEM_GEN_TRACE
+ log_trace_init("/tmp/squid.alloc");
+#endif
debug_log = stderr;
if (FD_SETSIZE < Squid_MaxFD)
Squid_MaxFD = FD_SETSIZE;
-
+
/* call mallopt() before anything else */
#if HAVE_MALLOPT
#ifdef M_GRAIN
debug(1, 0) ("Memory used after shutdown: %d\n", xmalloc_total);
}
#endif
+#if MEM_GEN_TRACE
+ log_trace_done();
+#endif
+
debug(1, 0) ("Squid Cache (Version %s): Exiting normally.\n",
version_string);
fclose(debug_log);