Skip to contentSkip to conversation

CONFIG_XENO_OPT_DEBUG_LEVEL

Xenomai-core Jan Kiszka 2 participants 6 messages Mar 20, 2006 – Mar 27, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi,

as I started to actually use XENO_ASSERT, I noticed that there is no infrastructure yet to enable it. CONFIG_XENO_OPT_DEBUG_LEVEL is nowhere defined. Add this as integer to Kconfig? Or better convert nucleus/assert.h to CONFIG_OPT_DEBUG for now until we really feel like we need more than on/off for this? I would vote for the latter ATM.

Jan

#1 lore raw
Quoted 7 lines · Jan Kiszka

Hi,

as I started to actually use XENO_ASSERT, I noticed that there is no infrastructure yet to enable it. CONFIG_XENO_OPT_DEBUG_LEVEL is nowhere defined. Add this as integer to Kconfig? Or better convert nucleus/assert.h to CONFIG_OPT_DEBUG for now until we really feel like we need more than on/off for this? I would vote for the latter ATM.

Actually, we already need more than a simple switch: I'd really like the queue debugging option to become a level on its own (say, 4294967295?). I'll add this tomorrow.

Quoted 11 lines

Jan

------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.
author
#2 lore raw
Quoted 9 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka

Hi,

as I started to actually use XENO_ASSERT, I noticed that there is no infrastructure yet to enable it. CONFIG_XENO_OPT_DEBUG_LEVEL is nowhere defined. Add this as integer to Kconfig? Or better convert nucleus/assert.h to CONFIG_OPT_DEBUG for now until we really feel like we need more than on/off for this? I would vote for the latter ATM.

Quoted 3 lines

Actually, we already need more than a simple switch: I'd really like the queue debugging option to become a level on its own (say, 4294967295?). I'll add this tomorrow.

Hmm, raises my old concern again: this "vertical" debugging implies to switch everything on when you only want queue debugging. I still think we rather need "horizontal" control: switch on queues, asserts, ...

This level "4294967295" indicates for me where we may end with: dozens of debug levels no one can tell apart, and you have to switch them all on to gain the relevant pieces or to be sure that you didn't missed anything. I always have the mess in mind we once had in ndiswrapper: for serious debugging of the USB layer you had to raise the debug level which dragged in bulks of (in this case) useless reports from other subsystems.

A student (Marc Kleine-Budde) once ported some nice debug subsystem into an internal project that requested a subsystem ID for every debug statement (I think it came from kaffe). At compilation time or even later during runtime you could easily select which subsystem should start babbling and checking and which one is not that interesting for a specific test. I think this is far more useful than debug levels. Queues could become such a subsystem, RTDM (with its asserts) another, and so forth. Of course, this means maintaining those subsystem IDs at a central place, but it's clearer than deciding which level to pick for a new debug code.

Jan

#3 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 10 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka

Hi,

as I started to actually use XENO_ASSERT, I noticed that there is no infrastructure yet to enable it. CONFIG_XENO_OPT_DEBUG_LEVEL is nowhere defined. Add this as integer to Kconfig? Or better convert nucleus/assert.h to CONFIG_OPT_DEBUG for now until we really feel like we need more than on/off for this? I would vote for the latter ATM.

Quoted 8 lines
Quoted 3 lines

Actually, we already need more than a simple switch: I'd really like the queue debugging option to become a level on its own (say, 4294967295?). I'll add this tomorrow.

Hmm, raises my old concern again: this "vertical" debugging implies to switch everything on when you only want queue debugging. I still think we rather need "horizontal" control: switch on queues, asserts, ...

It just depends whether we want to make the assertion mechanism a formalized exported feature or not. If there is a limited number of "clients", the simpler the better. This said, implementing sub-system debug switches instead of global debug levels would still be pretty trivial, provided we keep the number of sub-systems within reasonable limits (e.g. <= 64).

Quoted 22 lines

This level "4294967295" indicates for me where we may end with: dozens of debug levels no one can tell apart, and you have to switch them all on to gain the relevant pieces or to be sure that you didn't missed anything. I always have the mess in mind we once had in ndiswrapper: for serious debugging of the USB layer you had to raise the debug level which dragged in bulks of (in this case) useless reports from other subsystems.

A student (Marc Kleine-Budde) once ported some nice debug subsystem into an internal project that requested a subsystem ID for every debug statement (I think it came from kaffe). At compilation time or even later during runtime you could easily select which subsystem should start babbling and checking and which one is not that interesting for a specific test. I think this is far more useful than debug levels. Queues could become such a subsystem, RTDM (with its asserts) another, and so forth. Of course, this means maintaining those subsystem IDs at a central place, but it's clearer than deciding which level to pick for a new debug code.

Jan

Signature · 1 line
Philippe.
author
#4 lore raw
Quoted 22 lines · Philippe Gerum
Quoted 12 lines · Jan Kiszka
Quoted 10 lines · Philippe Gerum
Quoted 7 lines · Jan Kiszka

Hi,

as I started to actually use XENO_ASSERT, I noticed that there is no infrastructure yet to enable it. CONFIG_XENO_OPT_DEBUG_LEVEL is nowhere defined. Add this as integer to Kconfig? Or better convert nucleus/assert.h to CONFIG_OPT_DEBUG for now until we really feel like we need more than on/off for this? I would vote for the latter ATM.

Quoted 8 lines
Quoted 3 lines

Actually, we already need more than a simple switch: I'd really like the queue debugging option to become a level on its own (say, 4294967295?). I'll add this tomorrow.

Hmm, raises my old concern again: this "vertical" debugging implies to switch everything on when you only want queue debugging. I still think we rather need "horizontal" control: switch on queues, asserts, ...

Quoted 7 lines

It just depends whether we want to make the assertion mechanism a formalized exported feature or not. If there is a limited number of "clients", the simpler the better. This said, implementing sub-system debug switches instead of global debug levels would still be pretty trivial, provided we keep the number of sub-systems within reasonable limits (e.g. <= 64).

Here is an attempt to base the activation of XENO_ASSERT on a subsystem debug switch at compile time, applied on RTDM.

The procedure of adding a new system for XENO_ASSERT usage would be to define the required kbuild switch according to the naming scheme CONFIG_XENO_OPT_DEBUG_subsystem, include nucleus/assert.h, and add "#define CONFIG_XENO_OPT_DEBUG_subsystem 0" for the unset case. XENO_ASSERT is new called with (subsystem, condition, action). If we invent further debugging macros, they could be controlled in a similar way.

What do you think?

Jan

rtdm/rtdm_driver.h +8 -0
Index: include/rtdm/rtdm_driver.h
===================================================================
@@ -40,6 +40,13 @@
 #include <nucleus/synch.h>
 #include <rtdm/rtdm.h>
 
+/* debug support */
+#include <nucleus/assert.h>
+
+#ifndef CONFIG_XENO_OPT_DEBUG_RTDM
+#define CONFIG_XENO_OPT_DEBUG_RTDM  0
+#endif
+
 
 struct rtdm_dev_context;
 
@@ -891,6 +898,7 @@ static inline rtdm_task_t *rtdm_task_cur
 
 static inline int rtdm_task_wait_period(void)
 {
+    XENO_ASSERT(RTDM, !xnpod_unblockable_p(), return -EPERM;);
     return xnpod_wait_thread_period(NULL);
 }
 
nucleus/assert.h +4 -12
Index: include/nucleus/assert.h
===================================================================
@@ -22,20 +22,12 @@
 
 #include <nucleus/compiler.h>
 
-#ifndef CONFIG_XENO_OPT_DEBUG_LEVEL
-#define CONFIG_XENO_OPT_DEBUG_LEVEL  0
-#endif
-
-#if CONFIG_XENO_OPT_DEBUG_LEVEL > 0
-#define XENO_ASSERT(cond,action)  do { \
-if (unlikely((cond) != 0)) \
+#define XENO_ASSERT(subsystem,cond,action)  do { \
+if (unlikely(CONFIG_XENO_OPT_DEBUG_##subsystem > 0 && !(cond))) \
 	do { action; } while(0); \
 } while(0)
-#else  /* CONFIG_XENO_OPT_DEBUG_LEVEL == 0 */
-#define XENO_ASSERT(cond,action) do { } while(0)
-#endif /* CONFIG_XENO_OPT_DEBUG_LEVEL > 0 */
 
-#define XENO_BUGON(cond)  \
-    XENO_ASSERT(cond,xnpod_fatal("assertion failed at %s:%d",__FILE__,__LINE__))
+#define XENO_BUGON(subsystem,cond)  \
+    XENO_ASSERT(subsystem,cond,xnpod_fatal("assertion failed at %s:%d",__FILE__,__LINE__))
 
 #endif /* !_XENO_NUCLEUS_ASSERT_H */
ChangeLog +10 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,13 @@
+2006-03-26  Jan Kiszka  <[email protected]>
+
+	* ksrc/include/nucleus/assert.h: XENO_ASSERT with built-in
+	activation at compile time.
+
+	* ksrc/skins/rtdm/Kconfig, ksrc/skins/rtdm/Config.in,
+	ksrc/skins/rtdm/drvlib.c, include/rtdm/rtdm_driver.h: Use
+	XENO_ASSERT to check for correct RTDM driver API invocation
+	contexts.
+
 2006-03-24  Gilles Chanteperdrix  <[email protected]>
 
 	* ksrc/nucleus/pod.c (xnpod_init): Return immediately with an
skins/rtdm/Kconfig +9 -0
Index: ksrc/skins/rtdm/Kconfig
===================================================================
@@ -7,3 +7,12 @@ config XENO_SKIN_RTDM
 	This API skin allows to write real-time drivers against a common
 	light weight interface in kernel mode, but use them across all other
 	skins in both kernel and user mode.
+
+config XENO_OPT_DEBUG_RTDM
+    bool "RTDM Debugging support"
+    depends on XENO_OPT_DEBUG && XENO_SKIN_RTDM
+    help
+
+    This option activates debugging checks for the RTDM subsystem.
+    It is a recommended option for analysing potential issues in RTDM
+    drivers. A minor runtime overhead is added.
skins/rtdm/drvlib.c +56 -0

188 lines not on this page · raw message

skins/rtdm/Config.in +7 -0
Index: ksrc/skins/rtdm/Config.in
===================================================================
@@ -3,3 +3,10 @@
 #
 
 dep_tristate 'Real-Time Driver Model' CONFIG_XENO_SKIN_RTDM $CONFIG_XENO_OPT_NUCLEUS
+
+if [ "$CONFIG_XENO_SKIN_RTDM" != "n" ]; then
+	mainmenu_option next_comment
+	comment 'RTDM interface options'
+	dep_bool 'Debugging support' CONFIG_XENO_OPT_DEBUG_RTDM $CONFIG_XENO_OPT_DEBUG
+	endmenu
+fi
#5 lore raw
Quoted 5 lines · Jan Kiszka

Here is an attempt to base the activation of XENO_ASSERT on a subsystem debug switch at compile time, applied on RTDM.

Quoted 9 lines

The procedure of adding a new system for XENO_ASSERT usage would be to define the required kbuild switch according to the naming scheme CONFIG_XENO_OPT_DEBUG_subsystem, include nucleus/assert.h, and add "#define CONFIG_XENO_OPT_DEBUG_subsystem 0" for the unset case. XENO_ASSERT is new called with (subsystem, condition, action). If we invent further debugging macros, they could be controlled in a similar way.

What do you think?

I like the flexibity this approach brings (even if I think that the context checking in drvlib.c should be done unconditionally, regardless of the debug mode -- but that's probably a matter of personal taste). I've merged this patch, so that we can further use this debug infrastructure in other sub-systems. Thanks.

Signature · 1 line
Philippe.