control POSIX skin debugging independently
PATCH 3/3 control POSIX skin debugging independently
Following the logic of per-subsystem debug feature control, this patch introduces a separate kconfig switch XENO_OPT_POSIX_DEBUG and updates the involved source files.
Jan
--- ksrc/skins/posix/Config.in | 1 + ksrc/skins/posix/Kconfig | 7 +++++++ ksrc/skins/posix/cond.c | 10 +++++----- ksrc/skins/posix/internal.h | 7 +++++++ ksrc/skins/posix/intr.c | 11 ++++++----- ksrc/skins/posix/mq.c | 16 ++++++++-------- ksrc/skins/posix/mutex.c | 8 +++++--- ksrc/skins/posix/registry.c | 22 ++++++++++++---------- ksrc/skins/posix/sem.c | 24 ++++++++++++++---------- ksrc/skins/posix/shm.c | 23 +++++++++++------------ ksrc/skins/posix/signal.c | 16 ++++++++-------- ksrc/skins/posix/thread.c | 7 ++++--- ksrc/skins/posix/timer.c | 7 ++++--- 13 files changed, 92 insertions(+), 67 deletions(-)
ksrc/skins/posix/cond.c +5 -5
@@ -561,11 +561,11 @@ void pse51_condq_cleanup(pse51_kqueues_twhile ((holder =getheadq (&q->condq)) !=NULL ) {cond_destroy_internal (link2cond (holder), q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf - ("Posix: destroying condition variable %p.\n" , -link2cond (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: destroying condition variable %p.\n" , +link2cond (holder)); +xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/internal.h +7 -0
@@ -25,6 +25,13 @@#include <posix/posix.h> #include <posix/registry.h> +/* debug support */ +#include <nucleus/assert.h> + +#ifndef CONFIG_XENO_OPT_DEBUG_POSIX +#define CONFIG_XENO_OPT_DEBUG_POSIX 0 +#endif +#define PSE51_MAGIC (n) (0x8686##n##n)#define PSE51_ANY_MAGIC PSE51_MAGIC(00)#define PSE51_THREAD_MAGIC PSE51_MAGIC(01)
ksrc/skins/posix/mq.c +8 -8
@@ -1127,10 +1127,9 @@ int mq_notify(mqd_t fd, const struct sigstatic void uqd_cleanup (pse51_assoc_t *assoc) {pse51_ufd_t *ufd =assoc2ufd (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: closing message queue descriptor %lu.\n" , -pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: closing message queue descriptor %lu.\n" , +pse51_assoc_key (assoc));mq_close (ufd->kfd);xnfree (ufd); }
@@ -1159,12 +1158,13 @@ void pse51_mq_pkg_cleanup(void)pse51_node_t *node;pse51_node_remove (&node, mq->nodebase.name,PSE51_MQ_MAGIC );xnlock_put_irqrestore (&nklock, s); +pse51_mq_destroy (mq); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: unlinking message queue \"%s\".\n" , - mq->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: unlinking message queue \"%s\".\n" , + mq->nodebase.name);xnfree (mq); +xnlock_get_irqsave (&nklock, s); }xnlock_put_irqrestore (&nklock, s);
ksrc/skins/posix/mutex.c +5 -3
@@ -504,9 +504,11 @@ void pse51_mutexq_cleanup(pse51_kqueues_while ((holder =getheadq (&q->mutexq)) !=NULL ) {pse51_mutex_destroy_internal (link2mutex (holder), q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: destroying mutex %p.\n" ,link2mutex (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: destroying mutex %p.\n" , +link2mutex (holder)); +xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/registry.c +12 -10
@@ -488,18 +488,20 @@ void pse51_reg_pkg_cleanup(void)unsigned i;for (i =0 ; i < pse51_reg.maxfds; i++)if (pse51_reg.descs[i]) { -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: destroying descriptor %d.\n" ,i); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: destroying descriptor %d.\n" , + i);pse51_desc_destroy (pse51_reg.descs[i]); } -#ifdef CONFIG_XENO_OPT_DEBUG -for (i =0 ; i < pse51_reg.buckets_count; i++) { -pse51_node_t *node; -for (node = pse51_reg.node_buckets[i]; node; node = node->next) -xnprintf ("Posix: node \"%s\" left aside.\n" , node->name); - } -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +for (i =0 ; i < pse51_reg.buckets_count; i++) { +pse51_node_t *node; +for (node = pse51_reg.node_buckets[i]; + node; + node = node->next) +xnprintf ("Posix: node \"%s\" left aside.\n" , + node->name); + } size =sizeof (pse51_node_t) * pse51_reg.buckets_count +sizeof (pse51_desc_t) * pse51_reg.maxfds
ksrc/skins/posix/sem.c +14 -10
@@ -760,9 +760,9 @@ static void usem_cleanup(pse51_assoc_t *pse51_usem_t *usem =assoc2usem (assoc);nsem_t *nsem =sem2named_sem (sem); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: closing semaphore \"%s\".\n" , nsem->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: closing semaphore \"%s\".\n" , + nsem->nodebase.name);sem_close (&nsem->descriptor.native_sem);xnfree (usem); }
@@ -784,13 +784,17 @@ void pse51_semq_cleanup(pse51_kqueues_tpse51_sem_t *sem =link2sem (holder);pse51_node_t *node;xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -if (sem->is_named) -xnprintf ("Posix: unlinking semaphore \"%s\".\n" , -sem2named_sem (sem)->nodebase.name); -else -xnprintf ("Posix: destroying semaphore %p.\n" ,sem); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) { +if (sem->is_named) +xnprintf ("Posix: unlinking semaphore " +"\"%s\".\n" , +sem2named_sem (sem)->nodebase.name); +else +xnprintf ("Posix: destroying semaphore %p.\n" , + sem); + } +xnlock_get_irqsave (&nklock, s);if (sem->is_named) pse51_node_remove(&node,
ksrc/skins/posix/shm.c +11 -12
@@ -880,10 +880,9 @@ int pse51_xnheap_get(xnheap_t **pheap, vstatic void ufd_cleanup (pse51_assoc_t *assoc) {pse51_ufd_t *ufd =assoc2ufd (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: closing shared memory descriptor %lu.\n" , -pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: closing shared memory descriptor %lu.\n" , +pse51_assoc_key (assoc));pse51_shm_close (ufd->kfd);xnfree (ufd); }
@@ -891,10 +890,9 @@ static void ufd_cleanup(pse51_assoc_t *astatic void umap_cleanup (pse51_assoc_t *assoc) {pse51_umap_t *umap =assoc2umap (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: unmapping shared memory 0x%08lx.\n" , -pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: unmapping shared memory 0x%08lx.\n" , +pse51_assoc_key (assoc));munmap (umap->kaddr, umap->len);xnfree (umap); }
@@ -931,10 +929,11 @@ void pse51_shm_pkg_cleanup(void)pse51_node_remove (&node, shm->nodebase.name,PSE51_SHM_MAGIC );xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: unlinking shared memory \"%s\".\n" , - shm->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix: unlinking shared memory \"%s\".\n" , + shm->nodebase.name); +xnlock_get_irqsave (&nklock, s);pse51_shm_destroy (shm,1 ); }
ksrc/skins/posix/signal.c +8 -8
@@ -1211,15 +1211,15 @@ void pse51_signal_pkg_init(void)void pse51_signal_pkg_cleanup (void ) { -#ifdef CONFIG_XENO_OPT_DEBUG -int i; +if (XENO_DEBUG (POSIX )) { +int i; -for (i =0 ; i <PSE51_SIGQUEUE_MAX ; i++) -if (pse51_infos_pool[i].info.si_signo) -xnprintf - ("Posix siginfo structure %p was not freed, freeing now.\n" , - &pse51_infos_pool[i].info); -#endif /* CONFIG_XENO_OPT_DEBUG */ +for (i =0 ; i <PSE51_SIGQUEUE_MAX ; i++) +if (pse51_infos_pool[i].info.si_signo) +xnprintf ("Posix siginfo structure %p was not " +"freed, freeing now.\n" , + &pse51_infos_pool[i].info); + }#if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE )rthal_apc_free (pse51_signals_apc);
ksrc/skins/posix/thread.c +4 -3
@@ -712,9 +712,10 @@ void pse51_threadq_cleanup(pse51_kqueues/* Remaining TCB (joinable thread, which was never joined). */ thread_destroy (thread);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("POSIX: destroyed thread %p\n" , thread); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("POSIX: destroyed thread %p\n" , thread); +xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/timer.c +4 -3
@@ -520,9 +520,10 @@ void pse51_timerq_cleanup(pse51_kqueues_timer_t tm = (timer_t) (link2tm (holder, link) - timer_pool);pse51_timer_delete_inner (tm, q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix timer %u deleted\n" , (unsigned ) tm); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix timer %u deleted\n" , (unsigned ) tm); +xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/intr.c +6 -5
@@ -261,11 +261,12 @@ void pse51_intrq_cleanup(pse51_kqueues_twhile ((holder =getheadq (&q->intrq)) !=NULL ) {pthread_intr_detach_np (link2intr (holder));xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf - ("Posix interruption handler %p was not destroyed," -" destroying now.\n" ,link2intr (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ + +if (XENO_DEBUG (POSIX )) +xnprintf ("Posix interruption handler %p was not " +"destroyed, destroying now.\n" , +link2intr (holder)); +xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/Config.in +1 -0
@@ -9,5 +9,6 @@ if [ "$CONFIG_XENO_SKIN_POSIX" != "n" ]; comment 'POSIX interface options' bool 'Shared memory' CONFIG_XENO_OPT_POSIX_SHM bool 'Interrupts' CONFIG_XENO_OPT_POSIX_INTR + bool 'Debugging support' CONFIG_XENO_OPT_DEBUG_POSIX endmenu fi
ksrc/skins/posix/Kconfig +7 -0
@@ -32,4 +32,11 @@ config XENO_OPT_POSIX_INTR RTDM skin is the preferred way of implementing drivers), leave this option unselected. +config XENO_OPT_DEBUG_POSIX + bool "Debugging support" + help + + When enabled, this option makes the skin warn about not properly + cleaned up POSIX objects it detects on process termination. + endif
Quoted 3 lines · Jan Kiszka
Following the logic of per-subsystem debug feature control, this patch introduces a separate kconfig switch
XENO_OPT_POSIX_DEBUGand updates the involved source files.
I find the "if(XENO_DEBUG(FOO))" notation make it hard to understand that the piece of code that follows is disabled at compilation time, #ifdef CONFIG_XENO_OPT_FOO_DEBUG is easier to read. This also avoid the rather inelegant
#ifndef CONFIG_XENO_OPT_POSIX_DEBUG
#define CONFIG_XENO_OPT_POSIX_DEBUG 0
#endif
Now about the Posix skin patch, in my opinion the Posix skin debug should be enabled by default, because these printks are the indication that there is something wrong in the user code: some objects were created but not destroyed.
Signature · 1 line
Gilles Chanteperdrix
Quoted 5 lines · Gilles Chanteperdrix
Quoted 3 lines · Jan Kiszka
Following the logic of per-subsystem debug feature control, this patch introduces a separate kconfig switch
XENO_OPT_POSIX_DEBUGand updates the involved source files.
Quoted 8 lines
I find the "if(XENO_DEBUG(FOO))" notation make it hard to understand that the piece of code that follows is disabled at compilation time, #ifdef
CONFIG_XENO_OPT_FOO_DEBUGis easier to read. This also avoid the rather inelegant#ifndef
CONFIG_XENO_OPT_POSIX_DEBUG
#defineCONFIG_XENO_OPT_POSIX_DEBUG0
#endif
For now that's just for the sake of consistency with other debugging parts in Xenomai. But once you may want to use XENO_ASSERT or XENO_BUGON also in the POSIX skin, the above becomes necessary anyway.
I thought a lot about how to encapsulate the #ifndef more gracefully, but unfortunately you cannot build preprocessor statements from a preprocessor macro. If anyone has an idea how to obtain the XENO_ASSERT&friends semantics without any #ifndef-#define constructions, please let me know.
About the "if (XENO_DEBUG(POSIX))": I'm OK with converting them back to "#if XENO_DEBUG(POSIX)" if this is preferred.
Quoted 5 lines
Now about the Posix skin patch, in my opinion the Posix skin debug should be enabled by default, because these printks are the indication that there is something wrong in the user code: some objects were created but not destroyed.
Ok, will make it "default y" in the next patch revision.
Jan
Quoted 2 lines
About the "if (
XENO_DEBUG(POSIX))": I'm OK with converting them back to "#ifXENO_DEBUG(POSIX)" if this is preferred.
If the construct is *only* used at compile time, then the second form is certainly more explicit in that regard. However, it precludes alternate implementations which allow conditional debugging at run time. Would that not be the point of the first form? So in that sense they are not equivalent source code constructs.
- Tom
Signature · 4 lines
Thomas Lockhart Supervisor, Realtime Software Group Interferometry and Large Optical Systems Caltech/JPL
Quoted 9 lines · Thomas Lockhart
Quoted 2 lines
About the "if (
XENO_DEBUG(POSIX))": I'm OK with converting them back to "#ifXENO_DEBUG(POSIX)" if this is preferred.If the construct is *only* used at compile time, then the second form is certainly more explicit in that regard. However, it precludes alternate implementations which allow conditional debugging at run time. Would that not be the point of the first form? So in that sense they are not equivalent source code constructs.
True, but we do not have concrete plains to make this runtime switchable. And at least for the debugging features of the POSIX skin, runtime switching would be of no real use.
Jan
Version 2 of this patch with the following changes:
- switch to #if XENO_DEBUG(POSIX) (instead of "if (XENO_DEBUG(POSIX))")
- make XENO_OPT_DEBUG_POSIX default y (if debugging is enabled)
Jan
PS: Changelog for the whole series can be provided once it is considered mergeable.
--- ksrc/skins/posix/Config.in | 1 + ksrc/skins/posix/Kconfig | 10 ++++++++-- ksrc/skins/posix/cond.c | 9 ++++----- ksrc/skins/posix/internal.h | 7 +++++++ ksrc/skins/posix/intr.c | 9 ++++----- ksrc/skins/posix/mq.c | 8 ++++---- ksrc/skins/posix/mutex.c | 4 ++-- ksrc/skins/posix/registry.c | 17 ++++++++++------- ksrc/skins/posix/sem.c | 12 ++++++------ ksrc/skins/posix/shm.c | 12 ++++++------ ksrc/skins/posix/signal.c | 9 ++++----- ksrc/skins/posix/thread.c | 4 ++-- ksrc/skins/posix/timer.c | 4 ++-- 13 files changed, 60 insertions(+), 46 deletions(-)
ksrc/skins/posix/cond.c +4 -5
@@ -561,11 +561,10 @@ void pse51_condq_cleanup(pse51_kqueues_twhile ((holder =getheadq (&q->condq)) !=NULL ) {cond_destroy_internal (link2cond (holder), q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf - ("Posix: destroying condition variable %p.\n" , -link2cond (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#if XENO_DEBUG (POSIX ) +xnprintf ("Posix: destroying condition variable %p.\n" , +link2cond (holder)); +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/internal.h +7 -0
@@ -25,6 +25,13 @@#include <posix/posix.h> #include <posix/registry.h> +/* debug support */ +#include <nucleus/assert.h> + +#ifndef CONFIG_XENO_OPT_DEBUG_POSIX +#define CONFIG_XENO_OPT_DEBUG_POSIX 0 +#endif +#define PSE51_MAGIC (n) (0x8686##n##n)#define PSE51_ANY_MAGIC PSE51_MAGIC(00)#define PSE51_THREAD_MAGIC PSE51_MAGIC(01)
ksrc/skins/posix/mq.c +4 -4
@@ -1127,10 +1127,10 @@ int mq_notify(mqd_t fd, const struct sigstatic void uqd_cleanup (pse51_assoc_t *assoc) {pse51_ufd_t *ufd =assoc2ufd (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: closing message queue descriptor %lu.\n" ,pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ mq_close (ufd->kfd);xnfree (ufd); }
@@ -1160,10 +1160,10 @@ void pse51_mq_pkg_cleanup(void)pse51_node_remove (&node, mq->nodebase.name,PSE51_MQ_MAGIC );xnlock_put_irqrestore (&nklock, s);pse51_mq_destroy (mq); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: unlinking message queue \"%s\".\n" , mq->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ xnfree (mq);xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/mutex.c +2 -2
@@ -504,9 +504,9 @@ void pse51_mutexq_cleanup(pse51_kqueues_while ((holder =getheadq (&q->mutexq)) !=NULL ) {pse51_mutex_destroy_internal (link2mutex (holder), q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: destroying mutex %p.\n" ,link2mutex (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/registry.c +10 -7
@@ -488,18 +488,21 @@ void pse51_reg_pkg_cleanup(void)unsigned i;for (i =0 ; i < pse51_reg.maxfds; i++)if (pse51_reg.descs[i]) { -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf ("Posix: destroying descriptor %d.\n" ,i); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#if XENO_DEBUG (POSIX ) +xnprintf ("Posix: destroying descriptor %d.\n" , i); +#endif /* XENO_DEBUG(POSIX) */ pse51_desc_destroy (pse51_reg.descs[i]); } -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )for (i =0 ; i < pse51_reg.buckets_count; i++) {pse51_node_t *node; -for (node = pse51_reg.node_buckets[i]; node; node = node->next) -xnprintf ("Posix: node \"%s\" left aside.\n" , node->name); +for (node = pse51_reg.node_buckets[i]; + node; + node = node->next) +xnprintf ("Posix: node \"%s\" left aside.\n" , + node->name); } -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ size =sizeof (pse51_node_t) * pse51_reg.buckets_count +sizeof (pse51_desc_t) * pse51_reg.maxfds
ksrc/skins/posix/sem.c +6 -6
@@ -760,9 +760,9 @@ static void usem_cleanup(pse51_assoc_t *pse51_usem_t *usem =assoc2usem (assoc);nsem_t *nsem =sem2named_sem (sem); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: closing semaphore \"%s\".\n" , nsem->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ sem_close (&nsem->descriptor.native_sem);xnfree (usem); }
@@ -784,13 +784,13 @@ void pse51_semq_cleanup(pse51_kqueues_tpse51_sem_t *sem =link2sem (holder);pse51_node_t *node;xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -if (sem->is_named) +#if XENO_DEBUG (POSIX ) +if (sem->is_named)xnprintf ("Posix: unlinking semaphore \"%s\".\n" ,sem2named_sem (sem)->nodebase.name);else -xnprintf ("Posix: destroying semaphore %p.\n" ,sem); -#endif /* CONFIG_XENO_OPT_DEBUG */ +xnprintf ("Posix: destroying semaphore %p.\n" , sem); +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s);if (sem->is_named) pse51_node_remove(&node,
ksrc/skins/posix/shm.c +6 -6
@@ -880,10 +880,10 @@ int pse51_xnheap_get(xnheap_t **pheap, vstatic void ufd_cleanup (pse51_assoc_t *assoc) {pse51_ufd_t *ufd =assoc2ufd (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: closing shared memory descriptor %lu.\n" ,pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ pse51_shm_close (ufd->kfd);xnfree (ufd); }
@@ -891,10 +891,10 @@ static void ufd_cleanup(pse51_assoc_t *astatic void umap_cleanup (pse51_assoc_t *assoc) {pse51_umap_t *umap =assoc2umap (assoc); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: unmapping shared memory 0x%08lx.\n" ,pse51_assoc_key (assoc)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ munmap (umap->kaddr, umap->len);xnfree (umap); }
@@ -931,10 +931,10 @@ void pse51_shm_pkg_cleanup(void)pse51_node_remove (&node, shm->nodebase.name,PSE51_SHM_MAGIC );xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix: unlinking shared memory \"%s\".\n" , shm->nodebase.name); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s);pse51_shm_destroy (shm,1 ); }
ksrc/skins/posix/signal.c +4 -5
@@ -1211,15 +1211,14 @@ void pse51_signal_pkg_init(void)void pse51_signal_pkg_cleanup (void ) { -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )int i;for (i =0 ; i <PSE51_SIGQUEUE_MAX ; i++)if (pse51_infos_pool[i].info.si_signo) -xnprintf - ("Posix siginfo structure %p was not freed, freeing now.\n" , - &pse51_infos_pool[i].info); -#endif /* CONFIG_XENO_OPT_DEBUG */ +xnprintf ("Posix siginfo structure %p was not freed, " +"freeing now.\n" , &pse51_infos_pool[i].info); +#endif /* XENO_DEBUG(POSIX) */ #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE )rthal_apc_free (pse51_signals_apc);
ksrc/skins/posix/thread.c +2 -2
@@ -712,9 +712,9 @@ void pse51_threadq_cleanup(pse51_kqueues/* Remaining TCB (joinable thread, which was never joined). */ thread_destroy (thread);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("POSIX: destroyed thread %p\n" , thread); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/timer.c +2 -2
@@ -520,9 +520,9 @@ void pse51_timerq_cleanup(pse51_kqueues_timer_t tm = (timer_t) (link2tm (holder, link) - timer_pool);pse51_timer_delete_inner (tm, q);xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG +#if XENO_DEBUG (POSIX )xnprintf ("Posix timer %u deleted\n" , (unsigned ) tm); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/intr.c +4 -5
@@ -261,11 +261,10 @@ void pse51_intrq_cleanup(pse51_kqueues_twhile ((holder =getheadq (&q->intrq)) !=NULL ) {pthread_intr_detach_np (link2intr (holder));xnlock_put_irqrestore (&nklock, s); -#ifdef CONFIG_XENO_OPT_DEBUG -xnprintf - ("Posix interruption handler %p was not destroyed," -" destroying now.\n" ,link2intr (holder)); -#endif /* CONFIG_XENO_OPT_DEBUG */ +#if XENO_DEBUG (POSIX ) +xnprintf ("Posix interruption handler %p was not destroyed, " +"destroying now.\n" ,link2intr (holder)); +#endif /* XENO_DEBUG(POSIX) */ xnlock_get_irqsave (&nklock, s); }
ksrc/skins/posix/Config.in +1 -0
@@ -9,5 +9,6 @@ if [ "$CONFIG_XENO_SKIN_POSIX" != "n" ]; comment 'POSIX interface options' bool 'Shared memory' CONFIG_XENO_OPT_POSIX_SHM bool 'Interrupts' CONFIG_XENO_OPT_POSIX_INTR + bool 'Debugging support' CONFIG_XENO_OPT_DEBUG_POSIX endmenu fi
ksrc/skins/posix/Kconfig +8 -2
@@ -10,7 +10,6 @@ if XENO_SKIN_POSIX != n config XENO_OPT_POSIX_SHM bool "Shared memory" - default n help POSIX skin shared memory areas are regions of memory which can be shared
@@ -23,7 +22,6 @@ config XENO_OPT_POSIX_SHM config XENO_OPT_POSIX_INTR bool "Interrupts" - default n help This option provides an ad-hoc API to deal with interrupts in programs
@@ -32,4 +30,12 @@ config XENO_OPT_POSIX_INTR RTDM skin is the preferred way of implementing drivers), leave this option unselected. +config XENO_OPT_DEBUG_POSIX + bool "Debugging support" + default y + help + + When enabled, this option makes the skin warn about not properly + cleaned up POSIX objects it detects on process termination. + endif