From patchwork Thu Jan 9 13:48:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11325715 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFE9B921 for ; Thu, 9 Jan 2020 13:50:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A541420661 for ; Thu, 9 Jan 2020 13:50:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A541420661 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipYBU-0003J8-56; Thu, 09 Jan 2020 13:49:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipYBT-0003Ix-8i for xen-devel@lists.xenproject.org; Thu, 09 Jan 2020 13:49:11 +0000 X-Inumbo-ID: cb123d62-32e6-11ea-b89f-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cb123d62-32e6-11ea-b89f-bc764e2007e4; Thu, 09 Jan 2020 13:49:02 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 55D8FAD78; Thu, 9 Jan 2020 13:48:28 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Thu, 9 Jan 2020 14:48:24 +0100 Message-Id: <20200109134825.31482-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200109134825.31482-1-jgross@suse.com> References: <20200109134825.31482-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v2 1/2] xen: add config option to include failing condition in BUG_ON() message X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Today a triggering BUG_ON() will only print source file and line information. Add the possibility to print the triggering condition like ASSERT(). Do that by introducing BUG_ON_VERBOSE() and add a Kconfig option to make BUG_ON use BUG_ON_VERBOSE(). Signed-off-by: Juergen Gross --- xen/Kconfig.debug | 6 ++++++ xen/include/asm-x86/bug.h | 5 +++-- xen/include/xen/lib.h | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index b3511e81a2..dfbcac575a 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -81,6 +81,12 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. +config DEBUG_BUGVERBOSE + bool "Verbose BUG_ON messages" + default DEBUG + ---help--- + In case a BUG_ON triggers additionally print the triggering + condition on the console. config VERBOSE_DEBUG bool "Verbose debug messages" diff --git a/xen/include/asm-x86/bug.h b/xen/include/asm-x86/bug.h index 9bb4a19420..46d282777f 100644 --- a/xen/include/asm-x86/bug.h +++ b/xen/include/asm-x86/bug.h @@ -60,10 +60,11 @@ struct bug_frame { #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, NULL) -#define BUG() do { \ - BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, NULL); \ +#define BUG_VERBOSE(msg) do { \ + BUG_FRAME(BUGFRAME_bug, __LINE__, __FILE__, 0, msg); \ unreachable(); \ } while (0) +#define BUG() BUG_VERBOSE(NULL) #define run_in_exception_handler(fn) BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL) diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 8fbe84032d..e7770b0d24 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -8,7 +8,12 @@ #include #include +#define BUG_ON_VERBOSE(p) do { if (unlikely(p)) BUG_VERBOSE(#p); } while (0) +#ifdef CONFIG_DEBUG_BUGVERBOSE +#define BUG_ON(p) BUG_ON_VERBOSE(p) +#else #define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) +#endif #define WARN_ON(p) do { if (unlikely(p)) WARN(); } while (0) #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)