--- /dev/null
+/*
+ * $Id: SquidNew.h,v 1.1 2003/07/07 22:44:28 robertc Exp $
+ *
+ * AUTHOR: Harvest Derived
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_NEW_H
+#define SQUID_NEW_H
+
+/* Any code using libstdc++ must have externally resolvable overloads
+ * for void * operator new - which means in the .o for the binary,
+ * or in a shared library. static libs don't propogate the symbol
+ * so, look in the translation unit containing main() in squid
+ * for the extern version in squid
+ */
+#include <new>
+_SQUID_EXTERNNEW_ void *operator new(size_t size) throw (std::bad_alloc)
+{
+ return xmalloc(size);
+}
+_SQUID_EXTERNNEW_ void operator delete (void *address) throw()
+{
+ xfree (address);
+}
+_SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
+{
+ return xmalloc(size);
+}
+_SQUID_EXTERNNEW_ void operator delete[] (void *address) throw()
+{
+ xfree (address);
+}
+#endif /* SQUID_NEW_H */
/*
- * $Id: util.h,v 1.70 2003/03/02 22:20:31 hno Exp $
+ * $Id: util.h,v 1.71 2003/07/07 22:44:28 robertc Exp $
*
* AUTHOR: Harvest Derived
*
SQUIDCEXTERN void xfree(void *);
SQUIDCEXTERN void xxfree(const void *);
#ifdef __cplusplus
-#include <new>
-inline void *operator new(size_t size) throw (std::bad_alloc)
-{
- return xmalloc(size);
-}
-inline void operator delete (void *address) throw()
-{
- xfree (address);
-}
-inline void *operator new[] (size_t size) throw (std::bad_alloc)
-{
- return xmalloc(size);
-}
-inline void operator delete[] (void *address) throw()
-{
- xfree (address);
-}
+/* Any code using libstdc++ must have externally resolvable overloads
+ * for void * operator new - which means in the .o for the binary,
+ * or in a shared library. static libs don't propogate the symbol
+ * so, look in the translation unit containing main() in squid
+ * for the extern version in squid
+ */
+#ifndef _SQUID_EXTERNNEW_
+#define _SQUID_EXTERNNEW_ extern inline
+#endif
+#include "SquidNew.h"
#endif
/* rfc1738.c */
/*
- * $Id: CacheDigest.cc,v 1.36 2003/02/21 22:50:04 robertc Exp $
+ * $Id: CacheDigest.cc,v 1.37 2003/07/07 22:44:28 robertc Exp $
*
* DEBUG: section 70 Cache Digest
* AUTHOR: Alex Rousskov
cd->bits_per_entry = bpe;
cd->mask_size = mask_size;
cd->mask = (char *)xcalloc(cd->mask_size, 1);
- debug(70, 2) ("cacheDigestInit: capacity: %d entries, bpe: %d; size: %d bytes\n",
- cd->capacity, cd->bits_per_entry, cd->mask_size);
+ debugs(70, 2) ("cacheDigestInit: capacity: " << cd->capacity << " entries, bpe: " << cd->bits_per_entry << "; size: "
+ << cd->mask_size << " bytes");
}
CacheDigest *
/*
- * $Id: Debug.h,v 1.3 2003/02/21 22:50:05 robertc Exp $
+ * $Id: Debug.h,v 1.4 2003/07/07 22:44:28 robertc Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
#ifndef SQUID_DEBUG
#define SQUID_DEBUG
+#include <iostream>
+#include <sstream>
+
class Debug
{
public:
static int Levels[MAX_DEBUG_SECTIONS];
static int level;
+ static std::ostream &getDebugOut();
+ static void finishDebug();
+
+private:
+ static std::ostringstream *currentDebug;
};
+/* Debug stream */
+#define debugs(SECTION, LEVEL, CONTENT) \
+ do { \
+ if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
+ Debug::getDebugOut() << CONTENT; \
+ Debug::finishDebug(); \
+ } \
+ } while (/*CONSTCOND*/ 0)
+
#endif /* SQUID_DEBUG */
#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.am,v 1.80 2003/06/27 22:32:30 hno Exp $
+# $Id: Makefile.am,v 1.81 2003/07/07 22:44:28 robertc Exp $
#
# Uncomment and customize the following to suit your needs:
#
send-announce.cc \
$(SNMPSOURCE) \
squid.h \
+ SquidNew.cc \
tunnel.cc \
$(SSL_SOURCE) \
stat.cc \
@EPOLL_LIBS@
squid_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a @STORE_OBJS@
-unlinkd_SOURCES = unlinkd.cc
+unlinkd_SOURCES = unlinkd.cc SquidNew.cc
unlinkd_CXXFLAGS = -DUNLINK_DAEMON
pinger_SOURCES = \
pinger.cc \
- debug.cc
+ debug.cc \
+ SquidNew.cc
-dnsserver_SOURCES = dnsserver.cc
-recv_announce_SOURCES = recv-announce.cc
+dnsserver_SOURCES = dnsserver.cc SquidNew.cc
+recv_announce_SOURCES = recv-announce.cc SquidNew.cc
ufsdump_SOURCES = debug.cc \
int.cc \
squid.h \
$(SSL_SOURCE) \
tunnel.cc \
+ SquidNew.cc \
stat.cc \
StatHist.cc \
String.cc \
--- /dev/null
+
+/*
+ * $Id: SquidNew.cc,v 1.1 2003/07/07 22:44:28 robertc Exp $
+ *
+ * DEBUG: section ??? Memory Allocation
+ * AUTHOR: Robert Collins
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#define _SQUID_EXTERNNEW_
+#include "squid.h"
/*
- * $Id: debug.cc,v 1.91 2003/07/06 12:12:28 hno Exp $
+ * $Id: debug.cc,v 1.92 2003/07/07 22:44:28 robertc Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
#include "squid.h"
#include "Debug.h"
+#include <sstream>
int Debug::Levels[MAX_DEBUG_SECTIONS];
int Debug::level;
return Ctx_Descrs[ctx] ? Ctx_Descrs[ctx] : "<null>";
}
+
+std::ostream &
+Debug::getDebugOut() {
+ assert (currentDebug == NULL);
+ currentDebug = new std::ostringstream();
+ return *currentDebug;
+}
+
+void
+Debug::finishDebug() {
+ _db_print("%s\n", currentDebug->str().c_str());
+ delete currentDebug;
+ currentDebug = NULL;
+}
+
+std::ostringstream *Debug::currentDebug (NULL);
+#
#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.am,v 1.8 2003/06/24 12:31:00 robertc Exp $
+# $Id: Makefile.am,v 1.9 2003/07/07 22:44:28 robertc Exp $
#
AUTOMAKE_OPTIONS = subdir-objects
EXTRA_PROGRAMS = mem_node_test membanger splay tcp-banger2 rfc1738
## Sort by dependencies - test lowest layers first
-TESTS = rfc1738 \
+TESTS = debug \
+ rfc1738 \
refcount\
splay\
MemPoolTest\
http_range_test
## Sort by alpha - any build failures are significant.
-check_PROGRAMS= http_range_test \
+check_PROGRAMS= debug \
+ http_range_test \
MemPoolTest\
mem_node_test\
mem_hdr_test \
splay
LDADD = -L$(top_builddir)/lib -lmiscutil
+debug_SOURCES = debug.cc test_tools.cc
+debug_LDADD = $(top_builddir)/lib/Array.o $(LDADD)
mem_node_test_SOURCES = mem_node_test.cc
mem_node_test_LDADD = $(top_builddir)/src/mem_node.o $(LDADD)
mem_hdr_test_SOURCES = mem_hdr_test.cc test_tools.cc
--- /dev/null
+
+/*
+ * $Id: debug.cc,v 1.1 2003/07/07 22:44:28 robertc Exp $
+ *
+ * DEBUG: section 19 Store Memory Primitives
+ * AUTHOR: Robert Collins
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ * Copyright (c) 2003 Robert Collins <robertc@squid-cache.org>
+ */
+
+#include "squid.h"
+#include "stmem.h"
+#include "mem_node.h"
+#include <iostream>
+
+class StreamTest {
+ public:
+ std::ostream &serialise(std::ostream &);
+ char const *getAnInt() const;
+ char const *getACString() const;
+};
+
+std::ostream &operator << (std::ostream &aStream, StreamTest &anObject)
+{
+ return anObject.serialise(aStream);
+}
+
+std::ostream&
+StreamTest::serialise(std::ostream &aStream)
+{
+ aStream << "stream test";
+ return aStream;
+}
+
+char const *
+StreamTest::getAnInt() const
+{
+ return "5";
+}
+
+char const *
+StreamTest::getACString() const
+{
+ return "ThisIsAStreamTest";
+}
+
+int
+main (int argc, char *argv)
+{
+ Debug::Levels[1] = 8;
+ debugs (1,1,"test" << "string");
+ debugs (1,9,"dont show this" << "string");
+ debugs (1,1,"test" << "string");
+ debugs (1,1,"test" << "string");
+ if (true)
+ debugs(1,9,"this won't compile if the macro is broken.");
+ else
+ debugs(1,1,"bar");
+ StreamTest aStreamObject;
+ StreamTest *streamPointer (&aStreamObject);
+ debugs(1,1,aStreamObject);
+ debugs(1,1,streamPointer->getAnInt() << " " << aStreamObject.getACString());
+ return 0;
+}
/*
- * $Id: test_tools.cc,v 1.1 2003/06/24 12:31:02 robertc Exp $
+ * $Id: test_tools.cc,v 1.2 2003/07/07 22:44:28 robertc Exp $
*
* AUTHOR: Robert Collins
*
* Copyright (c) 2003 Robert Collins <robertc@squid-cache.org>
*/
+#define _SQUID_EXTERNNEW_
#include "squid.h"
#include <iostream>
+#include <sstream>
void
xassert(const char *msg, const char *file, int line)
debug (0,0) ("Fatal: %s",message);
exit (1);
}
+
+std::ostream &
+Debug::getDebugOut()
+{
+ assert (currentDebug == NULL);
+ currentDebug = new std::ostringstream();
+ return *currentDebug;
+}
+
+void
+Debug::finishDebug()
+{
+ _db_print("%s\n", currentDebug->str().c_str());
+ delete currentDebug;
+ currentDebug = NULL;
+}
+
+std::ostringstream *Debug::currentDebug (NULL);