Skip to contentSkip to conversation

improve XENO_ASSERT verbosity

PATCH In review Jan Kiszka 2 participants 2 messages Apr 9, 2006

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 improve XENO_ASSERT verbosity

Hi,

this patch adds xnlogerr to the XENO_ASSERT macro, making the failure visible so that the user does not have to bother. Furthermore, it adds panic tracing.

Tested and found useful with latest RTDM debugging, ok to apply?

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(group,cond,action)  do { \
+if (unlikely(CONFIG_XENO_OPT_DEBUG_##group > 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(group,cond)  \
+    XENO_ASSERT(group,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
#1 lore raw
Quoted 7 lines · Jan Kiszka

Hi,

this patch adds xnlogerr to the XENO_ASSERT macro, making the failure visible so that the user does not have to bother. Furthermore, it adds panic tracing.

Tested and found useful with latest RTDM debugging, ok to apply?

Ok.

Signature · 1 line
Philippe.