Module: xenomai-3
Branch: next
Commit: 2a7dcee23f32c01bd20dd9ecf1a2553f18abe78c
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2a7dcee23f32c01bd20dd9ecf1a2553f18abe78c

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jun  2 09:55:36 2015 +0200

copperplate/traceobj: add helpers for checking a status

---

 include/copperplate/traceobj.h |   22 ++++++++++++++++++++++
 lib/boilerplate/ancillaries.c  |    1 +
 lib/copperplate/traceobj.c     |   30 +++++++++++++++++++++++++++---
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/include/copperplate/traceobj.h b/include/copperplate/traceobj.h
index 613b043..be660aa 100644
--- a/include/copperplate/traceobj.h
+++ b/include/copperplate/traceobj.h
@@ -40,6 +40,20 @@ do {                                                         
        \
                __traceobj_assert_failed(trobj, __FILE__, __LINE__, 
__STRING(cond)); \
 } while(0)
 
+#define traceobj_check(__trobj, __status, __expected)                  \
+do {                                                                   \
+       if (__status != __expected)                                     \
+               __traceobj_check_abort(__trobj, __FILE__, __LINE__,     \
+                                      __status, __expected);           \
+} while(0)
+
+#define traceobj_check_warn(__trobj, __status, __expected)             \
+do {                                                                   \
+       if (__status != __expected)                                     \
+               __traceobj_check_warn(__trobj, __FILE__, __LINE__,      \
+                                     __status, __expected);            \
+} while(0)
+
 #define traceobj_mark(trobj, mark)     \
        __traceobj_mark(trobj, __FILE__, __LINE__, mark)
 
@@ -65,6 +79,14 @@ void traceobj_join(struct traceobj *trobj);
 void __traceobj_assert_failed(struct traceobj *trobj,
                              const char *file, int line, const char *cond);
 
+void __traceobj_check_abort(struct traceobj *trobj,
+                           const char *file, int line,
+                           int received, int expected);
+
+void __traceobj_check_warn(struct traceobj *trobj,
+                          const char *file, int line,
+                          int received, int expected);
+       
 void __traceobj_mark(struct traceobj *trobj,
                     const char *file, int line, int mark);
 
diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index 244e6f6..21aa667 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -152,6 +152,7 @@ static const char *__esym_map[] = {
        __esym_def(ENOSYS),
        __esym_def(ETIMEDOUT),
        __esym_def(ENOMSG),
+       __esym_def(EIDRM),
        __esym_def(EADDRINUSE),
 };
 
diff --git a/lib/copperplate/traceobj.c b/lib/copperplate/traceobj.c
index a06cfd9..8d4ee9b 100644
--- a/lib/copperplate/traceobj.c
+++ b/lib/copperplate/traceobj.c
@@ -194,8 +194,7 @@ static void dump_marks(struct traceobj *trobj) /* lock held 
*/
        fflush(stderr);
 }
 
-void __traceobj_assert_failed(struct traceobj *trobj,
-                             const char *file, int line, const char *cond)
+static void dump_marks_on_error(struct traceobj *trobj)
 {
        struct service svc;
 
@@ -208,8 +207,33 @@ void __traceobj_assert_failed(struct traceobj *trobj,
        pop_cleanup_lock(&trobj->lock);
 
        CANCEL_RESTORE(svc);
+}
+
+void __traceobj_assert_failed(struct traceobj *trobj,
+                             const char *file, int line, const char *cond)
+{
+       dump_marks_on_error(trobj);
+       panic("trace assertion failed:\n              %s:%d => \"%s\"", file, 
line, cond);
+}
+
+void __traceobj_check_abort(struct traceobj *trobj,
+                           const char *file, int line,
+                           int received, int expected)
+{
+       dump_marks_on_error(trobj);
+       panic("wrong return status:\n              %s:%d => %s (want %s)", 
file, line,
+             symerror(received > 0 ? -received : received),
+             symerror(expected > 0 ? -expected : expected));
+}
 
-       panic("trace assertion failed:\n%s:%d => \"%s\"", file, line, cond);
+void __traceobj_check_warn(struct traceobj *trobj,
+                          const char *file, int line,
+                          int received, int expected)
+{
+       dump_marks_on_error(trobj);
+       warning("wrong return status:\n              %s:%d => %s (want %s)", 
file, line,
+               symerror(received > 0 ? -received : received),
+               symerror(expected > 0 ? -expected : expected));
 }
 
 void __traceobj_mark(struct traceobj *trobj,


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to