Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Allow QUEUEDEBUG to be used from userland.



details:   https://anonhg.NetBSD.org/src/rev/640d6bd64c92
branches:  trunk
changeset: 325454:640d6bd64c92
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 25 17:19:34 2013 +0000

description:
Allow QUEUEDEBUG to be used from userland.

diffstat:

 sys/sys/queue.h |  62 +++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 39 insertions(+), 23 deletions(-)

diffs (135 lines):

diff -r 4276e4327e52 -r 640d6bd64c92 sys/sys/queue.h
--- a/sys/sys/queue.h   Wed Dec 25 17:18:39 2013 +0000
+++ b/sys/sys/queue.h   Wed Dec 25 17:19:34 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: queue.h,v 1.64 2013/11/27 12:24:56 joerg Exp $ */
+/*     $NetBSD: queue.h,v 1.65 2013/12/25 17:19:34 christos Exp $      */
 
 /*
  * Copyright (c) 1991, 1993
@@ -91,6 +91,15 @@
 #include <sys/null.h>
 #endif
 
+#if defined(QUEUEDEBUG)
+# if defined(_KERNEL)
+#  define QUEUEDEBUG_ABORT(...) panic(__VA_ARGS__)
+# else
+#  include <err.h>
+#  define QUEUEDEBUG_ABORT(...) err(1, __VA_ARGS__)
+# endif
+#endif
+
 /*
  * Singly-linked List definitions.
  */
@@ -205,18 +214,21 @@
 /*
  * List functions.
  */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
+#if defined(QUEUEDEBUG)
 #define        QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field)                   \
        if ((head)->lh_first &&                                         \
            (head)->lh_first->field.le_prev != &(head)->lh_first)       \
-               panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("LIST_INSERT_HEAD %p %s:%d", (head),   \
+                   __FILE__, __LINE__);
 #define        QUEUEDEBUG_LIST_OP(elm, field)                                  \
        if ((elm)->field.le_next &&                                     \
            (elm)->field.le_next->field.le_prev !=                      \
            &(elm)->field.le_next)                                      \
-               panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
+               QUEUEDEBUG_ABORT("LIST_* forw %p %s:%d", (elm),         \
+                   __FILE__, __LINE__);                                \
        if (*(elm)->field.le_prev != (elm))                             \
-               panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("LIST_* back %p %s:%d", (elm),         \
+                   __FILE__, __LINE__);
 #define        QUEUEDEBUG_LIST_POSTREMOVE(elm, field)                          \
        (elm)->field.le_next = (void *)1L;                              \
        (elm)->field.le_prev = (void *)1L;
@@ -430,26 +442,30 @@
 /*
  * Tail queue functions.
  */
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
+#if defined(QUEUEDEBUG)
 #define        QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field)                  \
        if ((head)->tqh_first &&                                        \
            (head)->tqh_first->field.tqe_prev != &(head)->tqh_first)    \
-               panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("TAILQ_INSERT_HEAD %p %s:%d", (head),  \
+                   __FILE__, __LINE__);
 #define        QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field)                  \
        if (*(head)->tqh_last != NULL)                                  \
-               panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("TAILQ_INSERT_TAIL %p %s:%d", (head),  \
+                   __FILE__, __LINE__);
 #define        QUEUEDEBUG_TAILQ_OP(elm, field)                                 \
        if ((elm)->field.tqe_next &&                                    \
            (elm)->field.tqe_next->field.tqe_prev !=                    \
            &(elm)->field.tqe_next)                                     \
-               panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\
+               QUEUEDEBUG_ABORT("TAILQ_* forw %p %s:%d", (elm),        \
+                   __FILE__, __LINE__);                                \
        if (*(elm)->field.tqe_prev != (elm))                            \
-               panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("TAILQ_* back %p %s:%d", (elm),        \
+                   __FILE__, __LINE__);
 #define        QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field)                    \
        if ((elm)->field.tqe_next == NULL &&                            \
            (head)->tqh_last != &(elm)->field.tqe_next)                 \
-               panic("TAILQ_PREREMOVE head %p elm %p %s:%d",           \
-                     (head), (elm), __FILE__, __LINE__);
+               QUEUEDEBUG_ABORT("TAILQ_PREREMOVE head %p elm %p %s:%d",\
+                   (head), (elm), __FILE__, __LINE__);
 #define        QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field)                         \
        (elm)->field.tqe_next = (void *)1L;                             \
        (elm)->field.tqe_prev = (void *)1L;
@@ -662,34 +678,34 @@
        return __x;
 }
 
-#if defined(_KERNEL) && defined(QUEUEDEBUG)
+#if defined(QUEUEDEBUG)
 #define QUEUEDEBUG_CIRCLEQ_HEAD(head, field)                           \
        if ((head)->cqh_first != CIRCLEQ_ENDC(head) &&                  \
            (head)->cqh_first->field.cqe_prev != CIRCLEQ_ENDC(head))    \
-               panic("CIRCLEQ head forw %p %s:%d", (head),             \
+               QUEUEDEBUG_ABORT("CIRCLEQ head forw %p %s:%d", (head),  \
                      __FILE__, __LINE__);                              \
        if ((head)->cqh_last != CIRCLEQ_ENDC(head) &&                   \
            (head)->cqh_last->field.cqe_next != CIRCLEQ_ENDC(head))     \
-               panic("CIRCLEQ head back %p %s:%d", (head),             \
+               QUEUEDEBUG_ABORT("CIRCLEQ head back %p %s:%d", (head),  \
                      __FILE__, __LINE__);
 #define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field)                       \
        if ((elm)->field.cqe_next == CIRCLEQ_ENDC(head)) {              \
                if ((head)->cqh_last != (elm))                          \
-                       panic("CIRCLEQ elm last %p %s:%d", (elm),       \
-                             __FILE__, __LINE__);                      \
+                       QUEUEDEBUG_ABORT("CIRCLEQ elm last %p %s:%d",   \
+                           (elm), __FILE__, __LINE__);                 \
        } else {                                                        \
                if ((elm)->field.cqe_next->field.cqe_prev != (elm))     \
-                       panic("CIRCLEQ elm forw %p %s:%d", (elm),       \
-                             __FILE__, __LINE__);                      \
+                       QUEUEDEBUG_ABORT("CIRCLEQ elm forw %p %s:%d",   \
+                           (elm), __FILE__, __LINE__);                 \
        }                                                               \
        if ((elm)->field.cqe_prev == CIRCLEQ_ENDC(head)) {              \
                if ((head)->cqh_first != (elm))                         \
-                       panic("CIRCLEQ elm first %p %s:%d", (elm),      \
-                             __FILE__, __LINE__);                      \
+                       QUEUEDEBUG_ABORT("CIRCLEQ elm first %p %s:%d",  \
+                           (elm), __FILE__, __LINE__);                 \
        } else {                                                        \
                if ((elm)->field.cqe_prev->field.cqe_next != (elm))     \
-                       panic("CIRCLEQ elm prev %p %s:%d", (elm),       \
-                             __FILE__, __LINE__);                      \
+                       QUEUEDEBUG_ABORT("CIRCLEQ elm prev %p %s:%d",   \
+                           (elm), __FILE__, __LINE__);                 \
        }
 #define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field)                      \
        (elm)->field.cqe_next = (void *)1L;                             \



Home | Main Index | Thread Index | Old Index