From: Amos Jeffries Date: Fri, 28 Aug 2009 01:44:26 +0000 (+1200) Subject: Cleanup: Remove more traces of old squid debug()() macro X-Git-Tag: SQUID_3_2_0_1~756 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96e03dd843bf82abfefbb46b3275154853ada1d4;p=thirdparty%2Fsquid.git Cleanup: Remove more traces of old squid debug()() macro There is now no reason for any of the Squid internal code to contain 'debug()' TODO: Just the ESI code remaining on the old system. It's debug seems to be incrementally building a single line to display objects parsed. But using multiple nested calls to dump it. VERY nasty. They need to be made writing to a buffer instead. --- diff --git a/include/RefCount.h b/include/RefCount.h index 527ae4ff6b..d1ef4d6270 100644 --- a/include/RefCount.h +++ b/include/RefCount.h @@ -119,7 +119,7 @@ struct RefCountable_ { /* Not private, to allow class hierarchies */ void RefCountReference() const { #if REFCOUNT_DEBUG - debug (0,1)("Incrementing this %p from count %u\n",this,count_); + old_debug(0,1)("Incrementing this %p from count %u\n",this,count_); #endif ++count_; @@ -127,7 +127,7 @@ struct RefCountable_ { unsigned RefCountDereference() const { #if REFCOUNT_DEBUG - debug (0,1)("Decrementing this %p from count %u\n",this,count_); + old_debug(0,1)("Decrementing this %p from count %u\n",this,count_); #endif return --count_; diff --git a/src/Debug.h b/src/Debug.h index 6e4c13c64d..b2134c1bc3 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -103,7 +103,6 @@ extern FILE *debug_log; const size_t BuildPrefixInit(); const char * SkipBuildPrefix(const char* path); - /* Debug stream */ #define debugs(SECTION, LEVEL, CONTENT) \ do { \ @@ -137,4 +136,10 @@ inline std::ostream& operator <<(std::ostream &os, const uint8_t d) return (os << (int)d); } +/* Legacy debug style. Still used in some places. needs to die... */ +#define do_debug(SECTION, LEVEL) ((Debug::level = (LEVEL)) > Debug::Levels[SECTION]) +#define old_debug(SECTION, LEVEL) \ + do_debug(SECTION, LEVEL) ? (void) 0 : _db_print + + #endif /* SQUID_DEBUG_H */ diff --git a/src/HttpStatusLine.cc b/src/HttpStatusLine.cc index 1e5aeb738e..eb797c5a17 100644 --- a/src/HttpStatusLine.cc +++ b/src/HttpStatusLine.cc @@ -71,9 +71,9 @@ httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p) { assert(sline && p); debugs(57, 9, "packing sline " << sline << " using " << p << ":"); - debug(57, 9) (HttpStatusLineFormat, sline->version.major, - sline->version.minor, sline->status, - sline->reason ? sline->reason : httpStatusString(sline->status)); + debugs(57, 9, "FORMAT=" << HttpStatusLineFormat ); + debugs(57, 9, "HTTP/" << sline->version.major << "." << sline->version.minor << + " " << sline->status << " " << (sline->reason ? sline->reason : httpStatusString(sline->status)) ); packerPrintf(p, HttpStatusLineFormat, sline->version.major, sline->version.minor, sline->status, httpStatusLineReason(sline)); } diff --git a/src/client_side.h b/src/client_side.h index 1a62846f16..d3761a6125 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -81,8 +81,7 @@ public: void mayUseConnection(bool aBool) { mayUseConnection_ = aBool; - debug (33,3)("ClientSocketContext::mayUseConnection: This %p marked %d\n", - this, aBool); + debugs(33,3, HERE << "This " << this << " marked " << aBool); } class DeferredParams diff --git a/src/defines.h b/src/defines.h index ac6ace1e58..c54093d3be 100644 --- a/src/defines.h +++ b/src/defines.h @@ -67,11 +67,6 @@ #define COMM_REUSEADDR 0x04 #define COMM_TRANSPARENT 0x08 -#include "Debug.h" -#define do_debug(SECTION, LEVEL) ((Debug::level = (LEVEL)) > Debug::Levels[SECTION]) -#define debug(SECTION, LEVEL) \ - do_debug(SECTION, LEVEL) ? (void) 0 : _db_print - #define safe_free(x) if (x) { xxfree(x); x = NULL; } #define DISK_OK (0) diff --git a/src/esi/Expression.cc b/src/esi/Expression.cc index 759171842d..aaace55c3a 100644 --- a/src/esi/Expression.cc +++ b/src/esi/Expression.cc @@ -881,23 +881,23 @@ printliteral (stackmember s) switch (s.valuestored) { case ESI_LITERAL_INVALID: - debug(86, 1) ( " Invalid " ); + old_debug(86, 1) ( " Invalid " ); break; case ESI_LITERAL_FLOAT: - debug (86,1) ("%f", s.value.floating); + old_debug(86,1) ("%f", s.value.floating); break; case ESI_LITERAL_STRING: - debug (86,1) ("'%s'", s.value.string); + old_debug(86,1) ("'%s'", s.value.string); break; case ESI_LITERAL_INT: - debug (86,1) ("%d", s.value.integral); + old_debug(86,1) ("%d", s.value.integral); break; case ESI_LITERAL_BOOL: - debug (86,1)("%s",s.value.integral ? "true" : "false"); + old_debug(86,1)("%s",s.value.integral ? "true" : "false"); } } @@ -907,7 +907,7 @@ printmember (stackmember s) switch (s.valuetype) { case ESI_EXPR_INVALID: - debug (86,1) (" Invalid "); + old_debug(86,1) (" Invalid "); break; case ESI_EXPR_LITERAL: @@ -915,51 +915,51 @@ printmember (stackmember s) break; case ESI_EXPR_EXPR: - debug (86,1) ("%s", s.value.integral ? "true" : "false"); + old_debug(86,1) ("%s", s.value.integral ? "true" : "false"); break; case ESI_EXPR_OR: - debug (86,1) ("|"); + old_debug(86,1) ("|"); break; case ESI_EXPR_AND: - debug (86,1) ("&"); + old_debug(86,1) ("&"); break; case ESI_EXPR_NOT: - debug (86,1) ("!"); + old_debug(86,1) ("!"); break; case ESI_EXPR_START: - debug (86,1) ("("); + old_debug(86,1) ("("); break; case ESI_EXPR_END: - debug (86,1) (")"); + old_debug(86,1) (")"); break; case ESI_EXPR_EQ: - debug (86,1) ("=="); + old_debug(86,1) ("=="); break; case ESI_EXPR_NOTEQ: - debug (86,1) ("!="); + old_debug(86,1) ("!="); break; case ESI_EXPR_LESS: - debug (86,1) ("<"); + old_debug(86,1) ("<"); break; case ESI_EXPR_LESSEQ: - debug (86,1) ("<="); + old_debug(86,1) ("<="); break; case ESI_EXPR_MORE: - debug (86,1) (">"); + old_debug(86,1) (">"); break; case ESI_EXPR_MOREEQ: - debug (86,1) (">="); + old_debug(86,1) (">="); break; } } @@ -973,7 +973,7 @@ dumpstack (stackmember * stack, int depth) printmember (stack[i]); if (depth) - debug (86,1) ("\n"); + old_debug(86,1) ("\n"); } int diff --git a/src/protos.h b/src/protos.h index 820ae35536..459820d3bc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -97,6 +97,7 @@ SQUIDCEXTERN void httpRequestFree(void *); extern void clientAccessCheck(void *); +#include "Debug.h" /* see debug.c for info on context-based debugging */ SQUIDCEXTERN Ctx ctx_enter(const char *descr); SQUIDCEXTERN void ctx_exit(Ctx ctx); @@ -107,7 +108,7 @@ SQUIDCEXTERN void _db_rotate_log(void); SQUIDCEXTERN void _db_print(const char *,...) PRINTF_FORMAT_ARG1; -/* packs, then prints an object using debug() */ +/* packs, then prints an object using debugs() */ SQUIDCEXTERN void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm); /* disk.c */ diff --git a/src/snmp_core.cc b/src/snmp_core.cc index d545548de0..7bbdf893df 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -1051,7 +1051,7 @@ snmpDebugOid(int lvl, oid * Name, snint Len) static void snmpSnmplibDebug(int lvl, char *buf) { - debug(49, lvl) ("%s", buf); + debugs(49, lvl, buf); } diff --git a/src/tools.cc b/src/tools.cc index 311f007fc3..e3e2323ee1 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -395,7 +395,7 @@ void sigusr2_handle(int sig) { static int state = 0; - /* no debug() here; bad things happen if the signal is delivered during _db_print() */ + /* no debugs() here; bad things happen if the signal is delivered during _db_print() */ if (state == 0) { #ifndef MEM_GEN_TRACE @@ -555,7 +555,7 @@ sig_child(int sig) pid = waitpid(-1, &status, WNOHANG); #endif - /* no debug() here; bad things happen if the signal is delivered during _db_print() */ + /* no debugs() here; bad things happen if the signal is delivered during _db_print() */ #if HAVE_SIGACTION } while (pid > 0); diff --git a/test-suite/test_tools.cc b/test-suite/test_tools.cc index 4ebcf4b94d..8e95c2c7fb 100644 --- a/test-suite/test_tools.cc +++ b/test-suite/test_tools.cc @@ -67,14 +67,14 @@ _db_print_stderr(const char *format, va_list args) void fatal_dump(const char *message) { - debug (0,0) ("Fatal: %s",message); + fprintf(stderr, "Fatal: %s",message); exit (1); } void fatal(const char *message) { - debug (0,0) ("Fatal: %s",message); + fprintf(stderr, "Fatal: %s", message); exit (1); } @@ -150,7 +150,7 @@ Debug::xassert(const char *msg, const char *file, int line) abort(); } -std::ostringstream *Debug::CurrentDebug (NULL); +std::ostringstream *Debug::CurrentDebug(NULL); MemAllocator *dlink_node_pool = NULL;