From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Gorcunov Subject: [PATCH] kvm tool: Introduce own BUG_ON handler Date: Tue, 20 Dec 2011 20:58:35 +0400 Message-ID: <20111220165835.GD12782@moon> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sasha Levin , Asias He , KVM-ML To: Pekka Enberg , Ingo Molnar Return-path: Received: from mail-ee0-f46.google.com ([74.125.83.46]:39269 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407Ab1LTQ6j (ORCPT ); Tue, 20 Dec 2011 11:58:39 -0500 Received: by eekc4 with SMTP id c4so6726184eek.19 for ; Tue, 20 Dec 2011 08:58:38 -0800 (PST) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Raise SIGABRT in case if run-time crtitical problem found. Proposed-by: Ingo Molnar Signed-off-by: Cyrill Gorcunov --- 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 #include #include #include @@ -17,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -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 { \