Menu

debug.h File Reference

#include "logging/logging.h"
#include <stdlib.h>

Go to the source code of this file.

Defines

#define FUNCTION_SIGNATURE   __FUNCSIG__
#define TRACE_FUNCTION
#define FAMOUSO_ASSERT_FAILED_HANDLER   ::__famouso_assert_failed_handler
 Name of the assert handler function.
#define FAMOUSO_ASSERT(expr)
 Print diagnostic message and abort program if expr evaluates to false.
#define FOR_FAMOUSO_ASSERT_ONLY(code)   code
 Declare code to be needed only for FAMOUSO_ASSERT.

Define Documentation

#define FAMOUSO_ASSERT ( expr   ) 
Value:
((expr) ? ((void)0) :                             \
            FAMOUSO_ASSERT_FAILED_HANDLER(PROGMEMSTRING(#expr),                \
                                          PROGMEMSTRING(__FILE__),             \
                                          PROGMEMSTRING(__TOSTR__(__LINE__))))

Print diagnostic message and abort program if expr evaluates to false.

Parameters:
expr Expression to test for

Useful to find bugs and spot wrong usage of interfaces by checking assumptions that should be always true. Do not use this macro to check for errors that may happen in NDEBUG case, e.g. invalid user input.

Evaluates to nothing if preprocessor symbol NDEBUG is defined.

Overwrite handler function:
An assert handler function has the following signature:
 void foobar(const char * expr, const char * file, int line); 
It should never return if you are not interested in undefined behaviour. To get your handler called on assertion failure define the preprocessor symbol FAMOUSO_ASSERT_FAILED_HANDLER before including debug.h:
 #define FAMOUSO_ASSERT_FAILED_HANDLER foobar 

Referenced by Chain::detach(), famouso::mw::afp::DefragmentationProcessor< AFP_DefragConfig >::event_processed(), object::RawStorage< size >::find_allocated_block(), object::RawStorage< size >::find_first_fit(), object::RawStorage< size >::free(), object::RingBuffer< Event< KeyType > *, N >::front(), famouso::mw::afp::defrag::OutOfOrderEventDataReconstructor< DCP >::get_data(), famouso::mw::afp::defrag::FECEventDataReconstructor< DCP >::get_data(), famouso::mw::afp::defrag::SingleEventDemux< DCP >::get_defragmenter_handle(), famouso::mw::afp::defrag::MultiSourceDemux< DCP >::get_defragmenter_handle(), famouso::mw::afp::defrag::EventSeqDemux< DCP >::get_defragmenter_handle(), famouso::mw::afp::frag::NoFECFragmenter< FCP >::get_fragment(), famouso::mw::afp::frag::FECFragmenter< FCP >::get_fragment(), famouso::mw::afp::frag::NoFECFragmenter< FCP >::get_header(), object::RingBuffer< Event< KeyType > *, N >::get_idx(), object::RingBuffer< Event< KeyType > *, N >::get_last(), famouso::mw::afp::defrag::OutOfOrderEventDataReconstructor< DCP >::get_length(), famouso::mw::afp::defrag::InOrderEventDataReconstructor< DCP >::get_length(), famouso::mw::afp::defrag::FECEventDataReconstructor< DCP >::get_length(), famouso::mw::afp::defrag::detail::VarHeaderLength< DCP >::get_payload(), famouso::mw::afp::frag::UseFEC< FCP >::get_red_fragment(), famouso::mw::afp::frag::UseFEC< FCP >::init(), famouso::mw::afp::frag::NoFECFragmenter< FCP >::init(), famouso::mw::afp::frag::FECFragmenter< FCP >::init(), famouso::mw::afp::defrag::EventSeqDemux< DCP >::keep_defragmenter(), famouso::mw::afp::defrag::detail::BitArray< afp::dynamic, Allocator >::operator[](), famouso::mw::afp::defrag::detail::BitArray< DCP::max_fragments, typename DCP::Allocator >::operator[](), object::RingBuffer< Event< KeyType > *, N >::pop_back(), object::RingBuffer< Event< KeyType > *, N >::pop_front(), object::RingBuffer< Event< KeyType > *, N >::push_back(), object::RingBuffer< Event< KeyType > *, N >::push_front(), famouso::mw::afp::defrag::OutOfOrderEventDataReconstructor< DCP >::put_fragment(), famouso::mw::afp::defrag::InOrderEventDataReconstructor< DCP >::put_fragment(), famouso::mw::afp::defrag::FECEventDataReconstructor< DCP >::put_fragment(), famouso::mw::afp::frag::UseFEC< FCP >::put_nonred_fragment(), and famouso::mw::afp::frag::UseFEC< FCP >::put_smaller_nonred_fragment().

#define FAMOUSO_ASSERT_FAILED_HANDLER   ::__famouso_assert_failed_handler

Name of the assert handler function.

This preprocessor symbol may be defined before including debug.h to overwrite the default assert handler function.

#define FOR_FAMOUSO_ASSERT_ONLY ( code   )     code

Declare code to be needed only for FAMOUSO_ASSERT.

Parameters:
code Definition or assignment of a variable (or something else), only used by assert test.

Use this to define variables with meaningful names to to get better assert messages while avoiding the 'unused variable' warning in NDEBUG case.

Evaluates to code if NDEBUG is not defined. Evaluates to nothing if NDEBUG is defined.

Referenced by object::RawStorage< size >::free(), famouso::mw::afp::defrag::OutOfOrderEventDataReconstructor< DCP >::put_fragment(), famouso::mw::afp::defrag::InOrderEventDataReconstructor< DCP >::put_fragment(), and famouso::mw::afp::defrag::FECEventDataReconstructor< DCP >::put_fragment().

#define FUNCTION_SIGNATURE   __FUNCSIG__
#define TRACE_FUNCTION
Value:
do {                                         \
    ::logging::log::emit< ::logging::Trace>()                       \
       << '"' << FUNCTION_SIGNATURE << '"'                          \
       << PROGMEMSTRING(" -> "__FILE__":" __TOSTR__(__LINE__)" ")    \
       << ::logging::log::endl;                                     \
} while(0)

Referenced by famouso::mw::el::EventLayerClientStub::announce(), famouso::mw::el::EventLayer< LL >::announce(), famouso::mw::api::PublisherEventChannel< ECH >::announce(), famouso::mw::anl::AbstractNetworkLayer< NL, AFP_FragConfig, AFP_DefragConfig >::announce(), famouso::mw::nl::voidNL::bind(), famouso::mw::nl::UDPBroadCastNL::bind(), famouso::mw::nl::SerialNL< DRV >::bind(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::bind(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::bind(), famouso::mw::nl::voidNL::deliver(), famouso::mw::nl::UDPBroadCastNL::deliver(), famouso::mw::nl::SerialNL< DRV >::deliver(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::deliver(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::deliver(), famouso::mw::nl::voidNL::fetch(), famouso::mw::nl::UDPBroadCastNL::fetch(), famouso::mw::nl::SerialNL< DRV >::fetch(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::fetch(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::fetch(), famouso::mw::el::EventLayer< LL >::fetch(), famouso::mw::anl::AbstractNetworkLayer< NL, AFP_FragConfig, AFP_DefragConfig >::fetch(), famouso::mw::gwl::GatewayEventChannel< ECH >::GatewayEventChannel(), famouso::mw::nl::voidNL::init(), famouso::mw::nl::UDPBroadCastNL::init(), famouso::mw::nl::SerialNL< DRV >::init(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::init(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::init(), device::nic::serial::AtmelSerialDriver< DEV, PL, BR, SFD >::init(), device::nic::serial::AsioSerialDriver< PL, SFD >::init(), famouso::mw::nl::voidNL::interrupt(), famouso::mw::nl::UDPBroadCastNL::interrupt(), ThenPolicyExample::process(), ElsePolicyExample::process(), famouso::mw::el::EventLayerClientStub::publish(), famouso::mw::el::EventLayer< LL >::publish(), famouso::mw::api::PublisherEventChannel< ECH >::publish(), famouso::mw::anl::AbstractNetworkLayer< NL, AFP_FragConfig, AFP_DefragConfig >::publish(), famouso::mw::api::ReflectionPublisherEventChannel< ECH >::publish(), famouso::mw::el::EventLayer< LL >::publish_local(), device::nic::serial::AtmelSerialDriver< DEV, PL, BR, SFD >::recv(), device::nic::serial::AsioSerialDriver< PL, SFD >::recv(), famouso::mw::nl::SerialNL< DRV >::rx_interrupt(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::rx_interrupt(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::rx_interrupt(), device::nic::serial::AtmelSerialDriver< DEV, PL, BR, SFD >::send(), device::nic::serial::AsioSerialDriver< PL, SFD >::send(), device::nic::ieee802_15_4::DRV802_15_4< RFLayer >::send(), famouso::mw::el::EventLayerClientStub::subscribe(), famouso::mw::el::EventLayer< LL >::subscribe(), famouso::mw::api::SubscriberEventChannel< ECH >::subscribe(), famouso::mw::anl::AbstractNetworkLayer< NL, AFP_FragConfig, AFP_DefragConfig >::subscribe(), famouso::mw::nl::SerialNL< DRV >::tx_interrupt(), famouso::mw::nl::IEEE_802_15_4_NL< driver_t >::tx_interrupt(), famouso::mw::nl::CANNL< CAN_Driver, CCP, BP >::tx_interrupt(), famouso::mw::el::EventLayerClientStub::unannounce(), famouso::mw::el::EventLayer< LL >::unannounce(), famouso::mw::el::EventLayerClientStub::unsubscribe(), famouso::mw::el::EventLayer< LL >::unsubscribe(), and famouso::mw::api::SubscriberEventChannel< ECH >::unsubscribe().