On 11/08/11 21:14, Peter Hutterer wrote:
There are plenty of cases that can only be triggered by a real bug in the
server and doing the ErrorF dance manually everywhere is a tad painful and
the error message is usually used only to find the spot in the file anyway.

Plus, reading BUG_WARN somewhere is a good indicator to the casual reader
that this isn't intended behaviour.

Note that this is intentionally different to the BUG_ON behaviour on the
kernel, we do not FatalError the server. It's just a warning + stacktrace.
If the bug is really fatal, call FatalError.

Signed-off-by: Peter Hutterer<[email protected]>
---
  include/misc.h |    7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/misc.h b/include/misc.h
index dc03911..0584f08 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -359,4 +359,11 @@ typedef struct _CharInfo *CharInfoPtr; /* also in 
fonts/include/font.h */
  extern _X_EXPORT unsigned long globalSerialNumber;
  extern _X_EXPORT unsigned long serverGeneration;

+#define BUG_WARN(cond)                                                    \
+          do { if (cond) {                                                \
+              ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n",  
   \
+                      __FILE__, __LINE__, __func__);                      \
+              xorg_backtrace();                                           \
+          } } while(0)
+
  #endif /* MISC_H */

Reviewed-by: Alan Coopersmith <[email protected]>

--
        -Alan Coopersmith-        [email protected]
         Oracle Solaris Platform Engineering: X Window System

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to