summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-04-02 06:24:05 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2012-04-02 06:24:05 +0000
commita6d8c8ff0c7d48e5e56728e3dc191ccb0a96418a (patch)
tree428cfc3b43089d16f2fb91699471d4a9949496d6 /sca-cpp/trunk/kernel
parent86b27d2bb7203724cf25cd134b2b4e1cefeacb42 (diff)
Add more fine grain debug options and remove overhead in debug log macros when logging is turned off.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1308248 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/kernel')
-rw-r--r--sca-cpp/trunk/kernel/config.hpp28
-rw-r--r--sca-cpp/trunk/kernel/fstream.hpp21
-rw-r--r--sca-cpp/trunk/kernel/function.hpp2
-rw-r--r--sca-cpp/trunk/kernel/gc.hpp2
-rw-r--r--sca-cpp/trunk/kernel/list.hpp10
-rw-r--r--sca-cpp/trunk/kernel/monad.hpp2
-rw-r--r--sca-cpp/trunk/kernel/stream.hpp2
-rw-r--r--sca-cpp/trunk/kernel/string.hpp6
-rw-r--r--sca-cpp/trunk/kernel/value.hpp11
9 files changed, 54 insertions, 30 deletions
diff --git a/sca-cpp/trunk/kernel/config.hpp b/sca-cpp/trunk/kernel/config.hpp
index 5b447e116b..944b9629e7 100644
--- a/sca-cpp/trunk/kernel/config.hpp
+++ b/sca-cpp/trunk/kernel/config.hpp
@@ -67,13 +67,32 @@ namespace tuscany
#ifdef WANT_MAINTAINER_MODE
/**
+ * Strict compile warnings.
+ */
+#define WANT_MAINTAINER_WARNINGS
+
+/**
+ * Fast fail assertion.
+ */
+#define WANT_MAINTAINER_ASSERT
+
+/**
+ * Debug log.
+ */
+#define WANT_MAINTAINER_LOG
+
+/**
* Add string watch members to important classes to help watch them in a debugger.
*/
//#define WANT_MAINTAINER_WATCH
/**
- * Increment/decrement a debug counter.
+ * Maintain counters of important objects to help test garbage collection.
*/
+//#define WANT_MAINTAINER_COUNTERS
+
+#ifdef WANT_MAINTAINER_COUNTERS
+
bool debug_inc(long int& c) {
c++;
return true;
@@ -91,5 +110,12 @@ bool debug_dec(long int& c) {
#endif
+#else
+
+#define debug_inc(c)
+#define debug_dec(c)
+
+#endif
+
}
#endif /* tuscany_config_hpp */
diff --git a/sca-cpp/trunk/kernel/fstream.hpp b/sca-cpp/trunk/kernel/fstream.hpp
index fe95fc02e0..6afec8bd35 100644
--- a/sca-cpp/trunk/kernel/fstream.hpp
+++ b/sca-cpp/trunk/kernel/fstream.hpp
@@ -224,7 +224,7 @@ private:
loghstream cinfo(APLOG_INFO);
loghstream cfailure(APLOG_ERR);
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
/**
* Debug log stream.
@@ -234,9 +234,7 @@ loghstream cdebug(APLOG_DEBUG);
/**
* Return true if debug log is enabled.
*/
-const bool isDebugLog() {
- return APLOG_MODULE_IS_LEVEL(ap_server_conf, APLOG_NO_MODULE, APLOG_DEBUG);
-}
+#define debug_islogging() (bool)(APLOG_MODULE_IS_LEVEL(ap_server_conf, APLOG_NO_MODULE, APLOG_DEBUG))
#endif
@@ -321,7 +319,7 @@ private:
logfstream cinfo(stderr, "info");
logfstream cfailure(stderr, "error");
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
/**
* Debug log stream.
@@ -331,22 +329,18 @@ logfstream cdebug(stderr, "debug");
/**
* Return true if debug log is enabled.
*/
-const bool isDebugLog() {
- return true;
-}
+#define debug_islogging() true
#endif
#endif
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
/**
* Log a debug message.
*/
const bool debugLog(const string& msg) {
- if (!isDebugLog())
- return true;
gc_scoped_pool();
cdebug << msg << endl;
return true;
@@ -356,17 +350,16 @@ const bool debugLog(const string& msg) {
* Log a debug message and a value.
*/
template<typename V> const bool debugLog(const V& v, const string& msg) {
- if (!isDebugLog())
- return true;
gc_scoped_pool();
cdebug << msg << ": " << v << endl;
return true;
}
-#define debug(...) tuscany::debugLog(__VA_ARGS__)
+#define debug(...) if (debug_islogging()) tuscany::debugLog(__VA_ARGS__)
#else
+#define debug_islogging() false
#define debug(...)
#endif
diff --git a/sca-cpp/trunk/kernel/function.hpp b/sca-cpp/trunk/kernel/function.hpp
index 701e0f1fa9..60117dab98 100644
--- a/sca-cpp/trunk/kernel/function.hpp
+++ b/sca-cpp/trunk/kernel/function.hpp
@@ -33,7 +33,7 @@
namespace tuscany {
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_COUNTERS
/**
* Debug counters.
diff --git a/sca-cpp/trunk/kernel/gc.hpp b/sca-cpp/trunk/kernel/gc.hpp
index 59947dd853..ed5482cfff 100644
--- a/sca-cpp/trunk/kernel/gc.hpp
+++ b/sca-cpp/trunk/kernel/gc.hpp
@@ -44,7 +44,7 @@
namespace tuscany
{
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_ASSERT
/**
* Force a core dump on assertion violation.
diff --git a/sca-cpp/trunk/kernel/list.hpp b/sca-cpp/trunk/kernel/list.hpp
index 60dcbb083a..d3736de62c 100644
--- a/sca-cpp/trunk/kernel/list.hpp
+++ b/sca-cpp/trunk/kernel/list.hpp
@@ -33,12 +33,10 @@
namespace tuscany {
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_COUNTERS
/**
- * Debug utilities. Counters used to track instances of lists, and
- * macro used to write the contents of a list in a string, easier to
- * watch in a debugger than the list itself.
+ * Debug utilities. Counters used to track instances of lists.
*/
long countLists = 0;
long countILists = 0;
@@ -72,6 +70,10 @@ bool printListCounters() {
#ifdef WANT_MAINTAINER_WATCH
+/**
+ * Debug utilities. Macro used to write the contents of a list to
+ * a string, easier to watch in a debugger than the list itself.
+ */
#define debug_watchList() do { \
this->watch = watchList(*this); \
} while (0)
diff --git a/sca-cpp/trunk/kernel/monad.hpp b/sca-cpp/trunk/kernel/monad.hpp
index 2ae49308a9..b1bef7996c 100644
--- a/sca-cpp/trunk/kernel/monad.hpp
+++ b/sca-cpp/trunk/kernel/monad.hpp
@@ -277,7 +277,7 @@ template<typename V, typename F> const lambda<failable<V, F>(const V)> success()
* Returns a failable monad with a failure in it.
*/
template<typename V, typename F> const failable<V, F> mkfailure(const F& f, const bool log = true) {
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
if (!log)
debug(f, "failable::mkfailure");
#endif
diff --git a/sca-cpp/trunk/kernel/stream.hpp b/sca-cpp/trunk/kernel/stream.hpp
index 2a27f5a948..8ccfed948f 100644
--- a/sca-cpp/trunk/kernel/stream.hpp
+++ b/sca-cpp/trunk/kernel/stream.hpp
@@ -152,7 +152,7 @@ template<typename T> ostream& operator<<(ostream& out, const gc_ptr<T>& p) {
return out << p.ptr;
}
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
/**
* Debug stream implementation with no dependencies on anything else.
diff --git a/sca-cpp/trunk/kernel/string.hpp b/sca-cpp/trunk/kernel/string.hpp
index cf7b4092d2..e726a61b84 100644
--- a/sca-cpp/trunk/kernel/string.hpp
+++ b/sca-cpp/trunk/kernel/string.hpp
@@ -34,7 +34,7 @@
namespace tuscany {
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_COUNTERS
/**
* Debug utilities. Counters used to track string copies.
@@ -67,7 +67,7 @@ bool printStringCopyCounters() {
* Instrumented memcpy.
*/
void* string_memcpy(void* t, const void* s, const size_t n) {
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_COUNTERS
countStringCopies += 1;
#endif
return memcpy(t, s, n);
@@ -172,7 +172,7 @@ public:
}
private:
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_LOG
friend class odebugstream;
#endif
friend class ostringstream;
diff --git a/sca-cpp/trunk/kernel/value.hpp b/sca-cpp/trunk/kernel/value.hpp
index 886897f20f..3b0e9beb73 100644
--- a/sca-cpp/trunk/kernel/value.hpp
+++ b/sca-cpp/trunk/kernel/value.hpp
@@ -40,12 +40,10 @@
namespace tuscany
{
-#ifdef WANT_MAINTAINER_MODE
+#ifdef WANT_MAINTAINER_COUNTERS
/**
- * Debug utilities. Counters used to track instances of values, and
- * macro used to write the contents of a value in a string, easier to
- * watch in a debugger than the value itself.
+ * Debug utilities. Counters used to track instances of values
*/
long int countValues = 0;
long int countEValues = 0;
@@ -79,6 +77,11 @@ bool printValueCounters() {
#ifdef WANT_MAINTAINER_WATCH
+/**
+ * Debug utilities. Macro used to write the contents of a value to
+ * a string, easier to watch in a debugger than the value itself.
+ */
+
#define debug_watchValue() do { \
this->watch = watchValue(*this); \
} while (0)