/*
- * $Id: Debug.h,v 1.10 2007/08/24 01:02:09 amosjeffries Exp $
+ * $Id: Debug.h,v 1.13 2008/02/26 18:43:30 rousskov Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
static void parseOptions(char const *);
private:
+ // Hack: replaces global ::xassert() to debug debugging assertions
+ static void xassert(const char *msg, const char *file, int line);
+
static std::ostringstream *CurrentDebug;
+ static int TheDepth; // level of nested debugging calls
};
/* Debug stream */
/*
- * $Id: client_side.cc,v 1.770 2007/12/04 03:35:52 hno Exp $
+ * $Id: client_side.cc,v 1.778 2008/02/26 18:43:58 rousskov Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
/* first update "i" if needed */
if (!http->range_iter.debt()) {
- debugs(33, 5, "ClientSocketContext::canPackMoreRanges: At end of current range spec for FD " <<
- fd());
+ debugs(33, 5, "ClientSocketContext::canPackMoreRanges: At end of current range spec for FD " << fd());
if (http->range_iter.pos.incrementable())
++http->range_iter.pos;
void
ClientSocketContext::pullData()
{
- debugs(33, 5, "ClientSocketContext::pullData: FD " << fd() << " attempting to pull upstream data");
+ debugs(33, 5, "ClientSocketContext::pullData: FD " << fd() );
/* More data will be coming from the stream. */
StoreIOBuffer readBuffer;
/* filter out data according to range specs */
if (!canPackMoreRanges()) {
- debugs(33, 5, "ClientSocketContext::socketState: Range request has hit end of returnable range sequence on FD " <<
- fd());
+ debugs(33, 5, "ClientSocketContext::socketState: Range request has hit end of returnable range sequence on FD " << fd() );
if (http->request->flags.proxy_keepalive)
return STREAM_COMPLETE;
/*
- * $Id: debug.cc,v 1.106.2.1 2008/02/25 03:01:01 amosjeffries Exp $
+ * $Id: debug.cc,v 1.109 2008/02/26 18:43:30 rousskov Exp $
*
* DEBUG: section 0 Debug Routines
* AUTHOR: Harvest Derived
return Ctx_Descrs[ctx] ? Ctx_Descrs[ctx] : "<null>";
}
+int Debug::TheDepth = 0;
+
std::ostream &
Debug::getDebugOut() {
- assert (CurrentDebug == NULL);
- CurrentDebug = new std::ostringstream();
- // set default formatting flags
- CurrentDebug->setf(std::ios::fixed);
- CurrentDebug->precision(2);
+ assert(TheDepth >= 0);
+ ++TheDepth;
+ if (TheDepth > 1) {
+ assert(CurrentDebug);
+ *CurrentDebug << std::endl << "reentrant debuging " << TheDepth << "-{";
+ } else {
+ assert(!CurrentDebug);
+ CurrentDebug = new std::ostringstream();
+ // set default formatting flags
+ CurrentDebug->setf(std::ios::fixed);
+ CurrentDebug->precision(2);
+ }
return *CurrentDebug;
}
void
Debug::finishDebug() {
- _db_print("%s\n", CurrentDebug->str().c_str());
- delete CurrentDebug;
- CurrentDebug = NULL;
+ assert(TheDepth >= 0);
+ assert(CurrentDebug);
+ if (TheDepth > 1) {
+ *CurrentDebug << "}-" << TheDepth << std::endl;
+ } else {
+ assert(TheDepth == 1);
+ _db_print("%s\n", CurrentDebug->str().c_str());
+ delete CurrentDebug;
+ CurrentDebug = NULL;
+ }
+ --TheDepth;
+}
+
+// Hack: replaces global ::xassert() to debug debugging assertions
+// Relies on assert macro calling xassert() without a specific scope.
+void
+Debug::xassert(const char *msg, const char *file, int line) {
+
+ if (CurrentDebug) {
+ *CurrentDebug << "assertion failed: " << file << ":" << line <<
+ ": \"" << msg << "\"";
+ }
+ abort();
}
std::ostringstream (*Debug::CurrentDebug)(NULL);
/*
- * $Id: test_tools.cc,v 1.9 2006/09/03 21:05:22 hno Exp $
+ * $Id: test_tools.cc,v 1.10 2008/02/26 18:44:16 rousskov Exp $
*
* AUTHOR: Robert Collins
*
fatal(message);
}
+int Debug::TheDepth = 0;
+
std::ostream &
Debug::getDebugOut() {
- assert (CurrentDebug == NULL);
- CurrentDebug = new std::ostringstream();
+ assert(TheDepth >= 0);
+ ++TheDepth;
+ if (TheDepth > 1) {
+ assert(CurrentDebug);
+ *CurrentDebug << std::endl << "reentrant debuging " << TheDepth << "-{";
+ } else {
+ assert(!CurrentDebug);
+ CurrentDebug = new std::ostringstream();
+ // set default formatting flags
+ CurrentDebug->setf(std::ios::fixed);
+ CurrentDebug->precision(2);
+ }
return *CurrentDebug;
}
void
Debug::finishDebug() {
- _db_print("%s\n", CurrentDebug->str().c_str());
- delete CurrentDebug;
- CurrentDebug = NULL;
+ assert(TheDepth >= 0);
+ assert(CurrentDebug);
+ if (TheDepth > 1) {
+ *CurrentDebug << "}-" << TheDepth << std::endl;
+ } else {
+ assert(TheDepth == 1);
+ _db_print("%s\n", CurrentDebug->str().c_str());
+ delete CurrentDebug;
+ CurrentDebug = NULL;
+ }
+ --TheDepth;
+}
+
+void
+Debug::xassert(const char *msg, const char *file, int line) {
+
+ if (CurrentDebug) {
+ *CurrentDebug << "assertion failed: " << file << ":" << line <<
+ ": \"" << msg << "\"";
+ }
+ abort();
}
std::ostringstream *Debug::CurrentDebug (NULL);