[PATCH] kvm tool: Introduce own BUG_ON handler

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

 



Raise SIGABRT in case if run-time crtitical
problem found.

Proposed-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxx>
---

Ingo, you meant something like below?

 tools/kvm/include/kvm/util.h |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Index: linux-2.6.git/tools/kvm/include/kvm/util.h
===================================================================
--- linux-2.6.git.orig/tools/kvm/include/kvm/util.h
+++ linux-2.6.git/tools/kvm/include/kvm/util.h
@@ -9,7 +9,6 @@
  * Some bits are stolen from perf tool :)
  */
 
-#include <assert.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stddef.h>
@@ -17,6 +16,7 @@
 #include <stdarg.h>
 #include <string.h>
 #include <stdbool.h>
+#include <signal.h>
 #include <errno.h>
 #include <limits.h>
 #include <sys/param.h>
@@ -51,9 +51,20 @@ extern void set_die_routine(void (*routi
 				__func__, __LINE__, ##__VA_ARGS__);	\
 	} while (0)
 
-#
+
 #define BUILD_BUG_ON(condition)	((void)sizeof(char[1 - 2*!!(condition)]))
-#define BUG_ON(condition)	assert(!(condition))
+
+#ifndef BUG_ON_HANDLER
+# define BUG_ON_HANDLER(condition)					\
+	do {								\
+		if ((condition)) {					\
+			pr_err("BUG at %s:%d", __FILE__, __LINE__);	\
+			raise(SIGABRT);					\
+		}							\
+	} while (0)
+#endif
+
+#define BUG_ON(condition)	BUG_ON_HANDLER((condition))
 
 #define DIE_IF(cnd)						\
 do {								\
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux