From: g0dil Date: Mon, 15 Jun 2009 09:27:18 +0000 (+0000) Subject: Added error messages to PPI and Utils SENF_ASSERTs X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=9e9679b333e3e6c2face5c16d1f98e4236a890ae;p=senf.git Added error messages to PPI and Utils SENF_ASSERTs git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1230 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/Connectors.cc b/PPI/Connectors.cc index 22f3929..4c5a3ea 100644 --- a/PPI/Connectors.cc +++ b/PPI/Connectors.cc @@ -41,13 +41,21 @@ prefix_ void senf::ppi::connector::Connector::connect(Connector & target) { // The connector is not registered -> route() or noroute() statement missing - SENF_ASSERT( module_ ); + SENF_ASSERT( module_ && + "senf::ppi::connector::Connector::connect(): (source) " + "Missing route() or noroute()" ); // The connector is already connected - SENF_ASSERT( ! peer_ ); + SENF_ASSERT( ! peer_ && + "senf::ppi::connector::Connector::connect(): (source) " + "duplicate connection" ); // The target connector is not registered -> route() or noroute() statement missing - SENF_ASSERT( target.module_ ); + SENF_ASSERT( target.module_ && + "senf::ppi::connector::Connector::connect(): (target) " + "Missing route() or noroute()" ); // The target connector is already connected - SENF_ASSERT( ! target.peer_ ); + SENF_ASSERT( ! target.peer_ && + "senf::ppi::connector::Connector::connect(): (target) " + "duplicate connection" ); if (! (packetTypeID() == typeid(void) || target.packetTypeID() == typeid(void) || packetTypeID() == target.packetTypeID()) ) @@ -69,7 +77,8 @@ prefix_ void senf::ppi::connector::Connector::connect(Connector & target) prefix_ void senf::ppi::connector::Connector::disconnect() { // Cannot disconnected a non-connected connector - SENF_ASSERT( peer_ ); + SENF_ASSERT( peer_ && + "senf::ppi::connector::Connector::disconnect(): Not connected" ); Connector & peer (*peer_); peer_ = 0; peer.peer_ = 0; diff --git a/PPI/Connectors.cci b/PPI/Connectors.cci index 3f24b5d..e6a7391 100644 --- a/PPI/Connectors.cci +++ b/PPI/Connectors.cci @@ -37,7 +37,7 @@ prefix_ senf::ppi::connector::Connector & senf::ppi::connector::Connector::peer( const { // The connector is not connected - SENF_ASSERT(peer_); + SENF_ASSERT(peer_ && "senf::ppi::connect() call missing"); return *peer_; } @@ -46,7 +46,7 @@ prefix_ senf::ppi::module::Module & senf::ppi::connector::Connector::module() { // The connector is not registered in the module -> probably a route() or noroute() statement is // missing. - SENF_ASSERT(module_); + SENF_ASSERT(module_ && "Connector not registered: Missing route() or noroute()"); return *module_; } @@ -162,8 +162,8 @@ prefix_ senf::ppi::connector::PassiveConnector::PassiveConnector() prefix_ void senf::ppi::connector::PassiveConnector::emit() { - // No event callback has been registered (onEvent() call missing) - SENF_ASSERT(callback_); + // No event callback has been registered (onRequest() call missing) + SENF_ASSERT(callback_ && "senf::ppi::connector::PassiveConnector: missing onRequest()"); if (!throttled()) callback_(); } @@ -232,7 +232,8 @@ prefix_ senf::Packet senf::ppi::connector::InputConnector::peek() const { // Cannot peek() head of empty queue - SENF_ASSERT( ! queue_.empty() ); + SENF_ASSERT( ! queue_.empty() && + "senf::ppi::connector::InputConnector: cannot call peek() on empty queue" ); return queue_.back(); } diff --git a/PPI/DebugModules.cc b/PPI/DebugModules.cc index 409c5ce..2826166 100644 --- a/PPI/DebugModules.cc +++ b/PPI/DebugModules.cc @@ -37,7 +37,9 @@ prefix_ void senf::ppi::module::debug::PassiveSource::request() { - SENF_ASSERT( ! packets_.empty() ); + SENF_ASSERT( ! packets_.empty() && + "senf::ppi::module::debug::PassiveSource::request(): " + "Requesting packet from empty source." ); output(packets_.front()); packets_.pop_front(); if (packets_.empty()) diff --git a/PPI/Events.cti b/PPI/Events.cti index 1dca3da..435fe3a 100644 --- a/PPI/Events.cti +++ b/PPI/Events.cti @@ -59,7 +59,8 @@ template prefix_ senf::ppi::detail::EventBinding & senf::ppi::EventImplementationHelper::binding() { - SENF_ASSERT( static_cast(this)->binding_ ); + SENF_ASSERT( static_cast(this)->binding_ && + "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" ); return * static_cast(this)->binding_; } @@ -89,7 +90,8 @@ template prefix_ senf::ppi::detail::EventBinding & senf::ppi::EventImplementationHelper::binding() { - SENF_ASSERT( static_cast(this)->binding_ ); + SENF_ASSERT( static_cast(this)->binding_ && + "senf::ppi::EventImplementationHelper::binding(): Missing registerEvent()" ); return * static_cast(this)->binding_; } diff --git a/PPI/IOEvent.cc b/PPI/IOEvent.cc index ea70efc..7517e41 100644 --- a/PPI/IOEvent.cc +++ b/PPI/IOEvent.cc @@ -59,8 +59,7 @@ prefix_ void senf::ppi::IOEvent::cb(int event) else if (event & Hup) throw HangupException(); else - // This cannot happen. - SENF_ASSERT(false); + SENF_ASSERT(false && "Internal failure in senf::ppi::IOEvent::cb(int)"); } else { IOEventInfo info = { event }; callback(info); diff --git a/Utils/intrusive_refcount.cci b/Utils/intrusive_refcount.cci index 7ac3df2..99b23bc 100644 --- a/Utils/intrusive_refcount.cci +++ b/Utils/intrusive_refcount.cci @@ -52,7 +52,9 @@ prefix_ void senf::intrusive_refcount_base::add_ref() prefix_ bool senf::intrusive_refcount_base::release() { - SENF_ASSERT(refcount_>0); + SENF_ASSERT(refcount_>0 && + "senf::intrusive_refcount_base: Internal inconsistency: " + "Calling release on dead object."); return --refcount_ == 0; } diff --git a/Utils/pool_alloc_mixin.cti b/Utils/pool_alloc_mixin.cti index e2a80ab..93b062f 100644 --- a/Utils/pool_alloc_mixin.cti +++ b/Utils/pool_alloc_mixin.cti @@ -36,7 +36,9 @@ prefix_ void * senf::pool_alloc_mixin::operator new(size_t size) { // When deriving from Self you may not change the class's size without // inheriting from pool_alloc_mixin again. See pool_alloc_mixin documentation. - SENF_ASSERT( size <= sizeof(Self) ); + SENF_ASSERT( size <= sizeof(Self) && + "senf::pool_alloc_mixin::operator new(): " + "Bad object size. Missing pool_alloc_mixin base in derived class?" ); #ifdef SENF_DEBUG allocCounter(1); #endif