All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
@ 2006-11-20 23:14 Jan Kiszka
  2006-11-21  9:59 ` Gilles Chanteperdrix
  2006-11-22  7:21 ` Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Kiszka @ 2006-11-20 23:14 UTC (permalink / raw)
  To: xenomai-core


[-- Attachment #1.1: Type: text/plain, Size: 186 bytes --]

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





[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: split-posix-debug.patch --]
[-- Type: text/x-patch; name="split-posix-debug.patch", Size: 12296 bytes --]

---
 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(-)

Index: xenomai/ksrc/skins/posix/cond.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/cond.c
+++ xenomai/ksrc/skins/posix/cond.c
@@ -561,11 +561,11 @@ void pse51_condq_cleanup(pse51_kqueues_t
 	while ((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);
 	}
 
Index: xenomai/ksrc/skins/posix/internal.h
===================================================================
--- xenomai.orig/ksrc/skins/posix/internal.h
+++ xenomai/ksrc/skins/posix/internal.h
@@ -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)
Index: xenomai/ksrc/skins/posix/mq.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/mq.c
+++ xenomai/ksrc/skins/posix/mq.c
@@ -1127,10 +1127,9 @@ int mq_notify(mqd_t fd, const struct sig
 static 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);
Index: xenomai/ksrc/skins/posix/mutex.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/mutex.c
+++ xenomai/ksrc/skins/posix/mutex.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/registry.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/registry.c
+++ xenomai/ksrc/skins/posix/registry.c
@@ -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
Index: xenomai/ksrc/skins/posix/sem.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/sem.c
+++ xenomai/ksrc/skins/posix/sem.c
@@ -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_t 
 		pse51_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,
Index: xenomai/ksrc/skins/posix/shm.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/shm.c
+++ xenomai/ksrc/skins/posix/shm.c
@@ -880,10 +880,9 @@ int pse51_xnheap_get(xnheap_t **pheap, v
 static 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 *a
 static 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);
 	}
Index: xenomai/ksrc/skins/posix/signal.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/signal.c
+++ xenomai/ksrc/skins/posix/signal.c
@@ -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);
Index: xenomai/ksrc/skins/posix/thread.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/thread.c
+++ xenomai/ksrc/skins/posix/thread.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/timer.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/timer.c
+++ xenomai/ksrc/skins/posix/timer.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/intr.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/intr.c
+++ xenomai/ksrc/skins/posix/intr.c
@@ -261,11 +261,12 @@ void pse51_intrq_cleanup(pse51_kqueues_t
 	while ((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);
 	}
 
Index: xenomai/ksrc/skins/posix/Config.in
===================================================================
--- xenomai.orig/ksrc/skins/posix/Config.in
+++ xenomai/ksrc/skins/posix/Config.in
@@ -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
Index: xenomai/ksrc/skins/posix/Kconfig
===================================================================
--- xenomai.orig/ksrc/skins/posix/Kconfig
+++ xenomai/ksrc/skins/posix/Kconfig
@@ -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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
  2006-11-20 23:14 [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently Jan Kiszka
@ 2006-11-21  9:59 ` Gilles Chanteperdrix
  2006-11-21 11:26   ` Jan Kiszka
  2006-11-22  7:21 ` Jan Kiszka
  1 sibling, 1 reply; 6+ messages in thread
From: Gilles Chanteperdrix @ 2006-11-21  9:59 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai-core

Jan Kiszka wrote:
> 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.

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.

-- 
                                                 Gilles Chanteperdrix


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
  2006-11-21  9:59 ` Gilles Chanteperdrix
@ 2006-11-21 11:26   ` Jan Kiszka
  2006-11-21 16:27     ` Thomas Lockhart
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2006-11-21 11:26 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>> 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.
> 
> 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

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.

> 
> 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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
  2006-11-21 11:26   ` Jan Kiszka
@ 2006-11-21 16:27     ` Thomas Lockhart
  2006-11-21 19:13       ` Jan Kiszka
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Lockhart @ 2006-11-21 16:27 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai-core

> About the "if (XENO_DEBUG(POSIX))": I'm OK with converting them back to
> "#if XENO_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

-- 
Thomas Lockhart
Supervisor, Realtime Software Group
Interferometry and Large Optical Systems
Caltech/JPL


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
  2006-11-21 16:27     ` Thomas Lockhart
@ 2006-11-21 19:13       ` Jan Kiszka
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2006-11-21 19:13 UTC (permalink / raw)
  To: Thomas Lockhart; +Cc: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 683 bytes --]

Thomas Lockhart wrote:
>> About the "if (XENO_DEBUG(POSIX))": I'm OK with converting them back to
>> "#if XENO_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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently
  2006-11-20 23:14 [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently Jan Kiszka
  2006-11-21  9:59 ` Gilles Chanteperdrix
@ 2006-11-22  7:21 ` Jan Kiszka
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2006-11-22  7:21 UTC (permalink / raw)
  To: xenomai-core

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

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.

[-- Attachment #2: split-posix-debug-v2.patch --]
[-- Type: text/x-patch, Size: 11585 bytes --]

---
 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(-)

Index: xenomai/ksrc/skins/posix/cond.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/cond.c
+++ xenomai/ksrc/skins/posix/cond.c
@@ -561,11 +561,10 @@ void pse51_condq_cleanup(pse51_kqueues_t
 	while ((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);
 	}
 
Index: xenomai/ksrc/skins/posix/internal.h
===================================================================
--- xenomai.orig/ksrc/skins/posix/internal.h
+++ xenomai/ksrc/skins/posix/internal.h
@@ -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)
Index: xenomai/ksrc/skins/posix/mq.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/mq.c
+++ xenomai/ksrc/skins/posix/mq.c
@@ -1127,10 +1127,10 @@ int mq_notify(mqd_t fd, const struct sig
 static 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);
 	}
Index: xenomai/ksrc/skins/posix/mutex.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/mutex.c
+++ xenomai/ksrc/skins/posix/mutex.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/registry.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/registry.c
+++ xenomai/ksrc/skins/posix/registry.c
@@ -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
Index: xenomai/ksrc/skins/posix/sem.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/sem.c
+++ xenomai/ksrc/skins/posix/sem.c
@@ -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_t 
 		pse51_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,
Index: xenomai/ksrc/skins/posix/shm.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/shm.c
+++ xenomai/ksrc/skins/posix/shm.c
@@ -880,10 +880,10 @@ int pse51_xnheap_get(xnheap_t **pheap, v
 static 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 *a
 static 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);
 	}
Index: xenomai/ksrc/skins/posix/signal.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/signal.c
+++ xenomai/ksrc/skins/posix/signal.c
@@ -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);
Index: xenomai/ksrc/skins/posix/thread.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/thread.c
+++ xenomai/ksrc/skins/posix/thread.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/timer.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/timer.c
+++ xenomai/ksrc/skins/posix/timer.c
@@ -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);
 	}
 
Index: xenomai/ksrc/skins/posix/intr.c
===================================================================
--- xenomai.orig/ksrc/skins/posix/intr.c
+++ xenomai/ksrc/skins/posix/intr.c
@@ -261,11 +261,10 @@ void pse51_intrq_cleanup(pse51_kqueues_t
 	while ((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);
 	}
 
Index: xenomai/ksrc/skins/posix/Config.in
===================================================================
--- xenomai.orig/ksrc/skins/posix/Config.in
+++ xenomai/ksrc/skins/posix/Config.in
@@ -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
Index: xenomai/ksrc/skins/posix/Kconfig
===================================================================
--- xenomai.orig/ksrc/skins/posix/Kconfig
+++ xenomai/ksrc/skins/posix/Kconfig
@@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-11-22  7:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-20 23:14 [Xenomai-core] [PATCH 3/3] control POSIX skin debugging independently Jan Kiszka
2006-11-21  9:59 ` Gilles Chanteperdrix
2006-11-21 11:26   ` Jan Kiszka
2006-11-21 16:27     ` Thomas Lockhart
2006-11-21 19:13       ` Jan Kiszka
2006-11-22  7:21 ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.