diff --git a/src/db/dbCAC.h b/src/db/dbCAC.h index cb8b9a3d7..23feb9c9d 100644 --- a/src/db/dbCAC.h +++ b/src/db/dbCAC.h @@ -55,6 +55,7 @@ public: dbSubscriptionIO ( dbChannelIO &chanIO, cacNotify &, unsigned type, unsigned long count ); int begin ( struct dbAddr &addr, unsigned mask ); void destroy (); + void show ( unsigned level ) const; static void * operator new ( size_t size ); static void operator delete ( void *pCadaver, size_t size ); private: @@ -77,6 +78,7 @@ public: int initiatePutNotify (cacNotify ¬ify, struct dbAddr &addr, unsigned type, unsigned long count, const void *pValue); void putNotifyDestroyNotify (); + void show ( unsigned level ) const; static void * operator new ( size_t size ); static void operator delete ( void *pCadaver, size_t size ); private: @@ -98,7 +100,7 @@ public: void subscriptionUpdate ( unsigned type, unsigned long count, const struct db_field_log *pfl, cacNotifyIO ¬ify ); dbEventSubscription subscribe ( dbSubscriptionIO &subscr, unsigned mask ); - + void show ( unsigned level ) const; static void * operator new ( size_t size); static void operator delete ( void *pCadaver, size_t size ); @@ -107,7 +109,7 @@ private: char *pGetCallbackCache; dbPutNotifyBlocker *pBlocker; unsigned long getCallbackCacheSize; - tsDLList eventq; + tsDLList < dbSubscriptionIO > eventq; dbAddr addr; static tsFreeList < dbChannelIO > freeList; @@ -143,6 +145,7 @@ public: void subscriptionUpdate ( struct dbAddr &addr, unsigned type, unsigned long count, const struct db_field_log *pfl, cacNotifyIO ¬ify ); dbEventSubscription subscribe ( struct dbAddr &addr, dbSubscriptionIO &subscr, unsigned mask ); + void show ( unsigned level ) const; private: dbEventCtx ctx; char *pEventCallbackCache; diff --git a/src/db/dbChannelIO.cpp b/src/db/dbChannelIO.cpp index 4aec3a37c..006bf24df 100644 --- a/src/db/dbChannelIO.cpp +++ b/src/db/dbChannelIO.cpp @@ -186,3 +186,29 @@ void dbChannelIO::unlockOutstandingIO () const { } +void dbChannelIO::show ( unsigned level ) const +{ + this->lock (); + printf ("channel at %p attached to local database record %s\n", + this, this->addr.precord->name ); + + if ( level > 0u ) { + printf ( "\ttype %s, element count %li, field at %p\n", + dbf_type_to_text ( this->addr.dbr_field_type ), this->addr.no_elements, + this->addr.pfield ); + } + if ( level > 1u ) { + this->serviceIO.show ( level - 2u ); + printf ( "\tget callback cache at %p, with size %lu\n", + this->pGetCallbackCache, this->getCallbackCacheSize ); + tsDLIterConstBD < dbSubscriptionIO > pItem = this->eventq.first (); + while ( pItem.valid () ) { + pItem->show ( level - 2u ); + pItem++; + } + if ( this->pBlocker ) { + this->pBlocker->show ( level - 2u ); + } + } + this->unlock (); +} diff --git a/src/db/dbPutNotifyBlocker.cpp b/src/db/dbPutNotifyBlocker.cpp index 6c05ceb1f..53bc4a876 100644 --- a/src/db/dbPutNotifyBlocker.cpp +++ b/src/db/dbPutNotifyBlocker.cpp @@ -104,5 +104,17 @@ extern "C" void putNotifyCompletion ( putNotify *ppn ) pBlocker->block.signal (); } +void dbPutNotifyBlocker::show ( unsigned level ) const +{ + printf ( "put notify blocker at %p\n", this ); + if ( level > 0u ) { + printf ( "\tdbPutNotifyIO at %p\n", this->pPN ); + printf ( "\tdbChannelIO at %p\n", &this->chan ); + } + if ( level > 1u ) { + this->block.show ( level - 2u ); + } +} + diff --git a/src/db/dbServiceIO.cpp b/src/db/dbServiceIO.cpp index b6bff6a29..d20cf7078 100644 --- a/src/db/dbServiceIO.cpp +++ b/src/db/dbServiceIO.cpp @@ -156,3 +156,18 @@ dbEventSubscription dbServiceIO::subscribe ( struct dbAddr &addr, dbSubscription return es; } + +void dbServiceIO::show ( unsigned level ) const +{ + this->mutex.lock (); + printf ( "dbServiceIO at %p\n", this ); + if (level > 0u ) { + printf ( "\tevent call back cache location %p, and its size %lu\n", + this->pEventCallbackCache, this->eventCallbackCacheSize ); + } + if ( level > 1u ) { + this->mutex.show ( level - 2u ); + } + this->mutex.unlock (); +} + diff --git a/src/db/dbSubscriptionIO.cpp b/src/db/dbSubscriptionIO.cpp index 1225995ed..940e8c6a1 100644 --- a/src/db/dbSubscriptionIO.cpp +++ b/src/db/dbSubscriptionIO.cpp @@ -89,3 +89,19 @@ int dbSubscriptionIO::begin ( struct dbAddr &addr, unsigned mask ) } } +void dbSubscriptionIO::show ( unsigned level ) const +{ + printf ( "Data base subscription IO at %p\n", this ); + if ( level > 0u ) { + short tmpType; + if ( this->type < SHRT_MAX ) { + tmpType = static_cast < short > ( this->type ); + printf ( "\ttype %s, count %lu, channel at %p\n", + dbf_type_to_text ( tmpType ), this->count, &this->chan ); + } + else { + printf ("strange type !, count %lu, channel at %p\n", + this->count, &this->chan ); + } + } +} diff --git a/src/libCom/cxxTemplates/tsFreeList.h b/src/libCom/cxxTemplates/tsFreeList.h index 952a8861c..8e12d9940 100644 --- a/src/libCom/cxxTemplates/tsFreeList.h +++ b/src/libCom/cxxTemplates/tsFreeList.h @@ -75,7 +75,7 @@ void * tsFreeList < T, N, DEBUG_LEVEL >::allocate (size_t size) { tsFreeListItem < T, DEBUG_LEVEL > *p; - if ( size != sizeof ( T ) ) { + if ( size != sizeof ( T ) || N == 0u ) { return ::operator new (size); } @@ -115,14 +115,12 @@ void tsFreeList < T, N, DEBUG_LEVEL >::release (void *pCadaver, size_t size) if ( size != sizeof ( T ) ) { ::operator delete ( pCadaver ); } - else { - if ( pCadaver ) { - this->lock (); - tsFreeListItem < T, DEBUG_LEVEL > *p = - static_cast < tsFreeListItem < T, DEBUG_LEVEL > *> ( pCadaver ); - p->pNext = this->pFreeList; - this->pFreeList = p; - this->unlock (); - } + else if ( pCadaver ) { + this->lock (); + tsFreeListItem < T, DEBUG_LEVEL > *p = + static_cast < tsFreeListItem < T, DEBUG_LEVEL > *> ( pCadaver ); + p->pNext = this->pFreeList; + this->pFreeList = p; + this->unlock (); } } diff --git a/src/libCom/misc/ipAddrToAsciiAsynchronous.cpp b/src/libCom/misc/ipAddrToAsciiAsynchronous.cpp index 347dbbee3..e9176eba9 100644 --- a/src/libCom/misc/ipAddrToAsciiAsynchronous.cpp +++ b/src/libCom/misc/ipAddrToAsciiAsynchronous.cpp @@ -90,6 +90,30 @@ void ipAddrToAsciiEngine::entryPoint () this->threadExit.signal (); } +void ipAddrToAsciiEngine::show ( unsigned level ) const +{ + this->mutex.lock (); + printf ( "ipAddrToAsciiEngine at %p with %u requests pendingh\n", + this, this->labor.count () ); + if ( level > 0u ) { + tsDLIterConstBD < ipAddrToAsciiAsynchronous > pItem = this->labor.first (); + while ( pItem.valid () ) { + pItem->show ( level - 1u ); + } + printf ( "nextId = %u\n", this->nextId ); + } + if ( level > 1u ) { + printf ( "mutex:\n" ); + this->mutex.show ( level - 2u ); + printf ( "event:\n" ); + this->event.show ( level - 2u ); + printf ( "exitFlag boolean = %u\n", this->exitFlag ); + printf ( "exit event:\n" ); + this->threadExit.show ( level - 2u ); + } + this->mutex.unlock (); +} + ipAddrToAsciiAsynchronous::ipAddrToAsciiAsynchronous ( const osiSockAddr &addrIn ) : addr ( addrIn ), pEngine ( 0u ) @@ -128,3 +152,16 @@ epicsShareFunc bool ipAddrToAsciiAsynchronous::ioInitiate ( ipAddrToAsciiEngine return success; } + +void ipAddrToAsciiAsynchronous::show ( unsigned level ) const +{ + char ipAddr [64]; + + ipAddrToAsciiEngine::mutex.lock (); + sockAddrToA ( &this->addr.sa, ipAddr, sizeof ( ipAddr ) ); + printf ( "ipAddrToAsciiAsynchronous for address %s\n", ipAddr ); + if ( level > 0u ) { + printf ( "\tidentifier %u, engine %p\n", this->id, this->pEngine ); + } + ipAddrToAsciiEngine::mutex.unlock (); +} diff --git a/src/libCom/misc/ipAddrToAsciiAsynchronous.h b/src/libCom/misc/ipAddrToAsciiAsynchronous.h index 786120117..f05fabab8 100644 --- a/src/libCom/misc/ipAddrToAsciiAsynchronous.h +++ b/src/libCom/misc/ipAddrToAsciiAsynchronous.h @@ -30,6 +30,7 @@ class ipAddrToAsciiEngine : public osiThread { public: epicsShareFunc ipAddrToAsciiEngine ( const char *pName ); epicsShareFunc ~ipAddrToAsciiEngine (); + epicsShareFunc void show ( unsigned level ) const; private: tsDLList < ipAddrToAsciiAsynchronous > labor; osiEvent event; @@ -56,6 +57,7 @@ public: epicsShareFunc bool ioInitiate ( ipAddrToAsciiEngine &engine ); epicsShareFunc bool identicalAddress ( const osiSockAddr &addr ) const; epicsShareFunc osiSockAddr address () const; + epicsShareFunc void show ( unsigned level ) const; virtual void ioCompletionNotify ( const char *pHostName ) = 0; private: osiSockAddr addr; diff --git a/src/libCom/osi/osiEvent.h b/src/libCom/osi/osiEvent.h index e28649420..bfd8eedba 100644 --- a/src/libCom/osi/osiEvent.h +++ b/src/libCom/osi/osiEvent.h @@ -20,9 +20,9 @@ public: ~osiEvent (); void signal (); void wait (); /* blocks until full */ - bool wait (double timeOut); /* false if empty at time out */ + bool wait ( double timeOut ); /* false if empty at time out */ bool tryWait (); /* false if empty */ - void show (unsigned level); + void show ( unsigned level ) const; class invalidSemaphore {}; /* exception */ class noMemory {}; /* exception */ @@ -89,9 +89,9 @@ inline bool osiEvent::tryWait () } } -inline void osiEvent::show (unsigned level) +inline void osiEvent::show ( unsigned level ) const { - semBinaryShow (this->id, level); + semBinaryShow ( this->id, level ); } #endif /* osiEventh */ diff --git a/src/libCom/osi/osiMutex.h b/src/libCom/osi/osiMutex.h index 737b9e4fb..7eda60ed3 100644 --- a/src/libCom/osi/osiMutex.h +++ b/src/libCom/osi/osiMutex.h @@ -19,10 +19,10 @@ public: osiMutex (); ~osiMutex (); void lock () const; /* blocks until success */ - bool lock (double timeOut) const; /* true if successful */ + bool lock ( double timeOut ) const; /* true if successful */ bool tryLock () const; /* true if successful */ void unlock () const; - void show (unsigned level) const; + void show ( unsigned level ) const; class invalidSemaphore {}; /* exception */ class noMemory {}; /* exception */