summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-09-13 22:05:29 -0700
committerJosh Blum2012-09-13 22:05:29 -0700
commit85b29ab7235d85ff17062cf8521f522b5a84fe3d (patch)
tree765679f2f9104c5e5cd28c07d2720d6562df9284 /lib
parent714aca847ac7f2e66c79933a3b7cb26b081d304a (diff)
downloadsandhi-85b29ab7235d85ff17062cf8521f522b5a84fe3d.tar.gz
sandhi-85b29ab7235d85ff17062cf8521f522b5a84fe3d.tar.bz2
sandhi-85b29ab7235d85ff17062cf8521f522b5a84fe3d.zip
work on debugger helpers/tools
Diffstat (limited to 'lib')
-rw-r--r--lib/block_task.cpp5
-rw-r--r--lib/gras_impl/debug.hpp46
2 files changed, 48 insertions, 3 deletions
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index c3ab0d4..a9b88bd 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -73,6 +73,10 @@ void ElementImpl::mark_done(const tsbe::TaskInterface &task_iface)
void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
{
+ #ifdef WORK_DEBUG
+ WorkDebugPrinter(this->name);
+ #endif
+
//------------------------------------------------------------------
//-- Decide if its possible to continue any processing:
//-- Handle task may get called for incoming buffers,
@@ -83,7 +87,6 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
this->input_queues.all_ready() and
this->output_queues.all_ready()
)) return;
- if (WORK) std::cout << "=== calling work on " << name << " ===" << std::endl;
const size_t num_inputs = task_iface.get_num_inputs();
const size_t num_outputs = task_iface.get_num_outputs();
diff --git a/lib/gras_impl/debug.hpp b/lib/gras_impl/debug.hpp
index e5f334e..69f7b4a 100644
--- a/lib/gras_impl/debug.hpp
+++ b/lib/gras_impl/debug.hpp
@@ -20,14 +20,28 @@
#include <iostream>
#include <stdexcept>
+//----------------------------------------------------------------------
+//-- set to 1 to enable these debugs:
+//----------------------------------------------------------------------
#define GENESIS 0
#define ARMAGEDDON 0
#define MESSAGE 0
-#define WORK 0
-#define ASSERTING 1
+//----------------------------------------------------------------------
+//-- define to enable these debugs:
+//----------------------------------------------------------------------
+//#define WORK_DEBUG
+#define ASSERTING
+
+//----------------------------------------------------------------------
+//-- various debug prints
+//----------------------------------------------------------------------
#define HERE() std::cerr << __FILE__ << ":" << __LINE__ << std::endl << std::flush;
#define VAR(x) std::cerr << #x << " = " << (x) << std::endl << std::flush;
+
+//----------------------------------------------------------------------
+//-- implementation for assert debug
+//----------------------------------------------------------------------
#ifdef ASSERTING
#define ASSERT(x) {if(not (x)) \
{ \
@@ -38,4 +52,32 @@
#define ASSERT(x)
#endif
+//----------------------------------------------------------------------
+//-- implementation for work debug
+//----------------------------------------------------------------------
+#ifdef WORK_DEBUG
+
+#include <boost/thread/mutex.hpp>
+
+static boost::mutex work_debug_mutex;
+
+struct WorkDebugPrinter
+{
+ WorkDebugPrinter(const std::string &name):
+ lock(work_debug_mutex), name(name)
+ {
+ std::cout << "-----> begin work on " << name << std::endl;
+ }
+
+ ~WorkDebugPrinter(void)
+ {
+ std::cout << "<----- end work on " << name << std::endl;
+ }
+
+ boost::mutex::scoped_lock lock;
+ std::string name;
+};
+
+#endif
+
#endif /*INCLUDED_LIBGRAS_IMPL_DEBUG_HPP*/