From patchwork Tue Oct 7 14:09:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Zacarias X-Patchwork-Id: 5046291 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3ED2BC11AB for ; Tue, 7 Oct 2014 14:19:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 518B420117 for ; Tue, 7 Oct 2014 14:19:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 022D9200E9 for ; Tue, 7 Oct 2014 14:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753795AbaJGOSt (ORCPT ); Tue, 7 Oct 2014 10:18:49 -0400 Received: from www.zacarias.com.ar ([62.210.192.172]:42427 "EHLO www.zacarias.com.ar" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbaJGOSt (ORCPT ); Tue, 7 Oct 2014 10:18:49 -0400 X-Greylist: delayed 572 seconds by postgrey-1.27 at vger.kernel.org; Tue, 07 Oct 2014 10:18:48 EDT Received: from asgard (cpe-186-18-128-65.telecentro-reversos.com.ar [186.18.128.65] (may be forged)) (authenticated bits=0) by www.zacarias.com.ar (8.14.9/8.14.9) with ESMTP id s97E9ACd030461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 7 Oct 2014 14:09:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=zacarias.com.ar; s=dkey; t=1412690954; bh=Jt++tDlW8T019E4y4NbxYPWINs60HQMMGDo40hWhmVk=; h=From:To:Cc:Subject:Date; b=Tde7bZUjXfu+bRgKBNvmMLwERojwFfLf6pgRGVXcmV5idEwCGFQzurKUPWJtxnp2P 5cIWT5d0GswFvos3gbzSlh3ef+MRCSbaIn/sHc6EF0tLtUGzgKsqZiOy3gsnjdmIC7 odhmn7CUyHxfTbeTNy+S7gpiPLNc40jjnuwNq0pg= Received: by asgard (sSMTP sendmail emulation); Tue, 07 Oct 2014 11:09:04 -0300 From: Gustavo Zacarias To: linux-btrfs@vger.kernel.org Cc: Gustavo Zacarias Subject: [PATCH] btrfs-progs: add option to disable backtrace usage Date: Tue, 7 Oct 2014 11:09:04 -0300 Message-Id: <1412690944-5513-1-git-send-email-gustavo@zacarias.com.ar> X-Mailer: git-send-email 2.0.4 X-Virus-Scanned: clamav-milter 0.98.4 at www X-Virus-Status: Clean Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds the support for a make variable named "DISABLE_BACKTRACE" which allows to disable the support for backtrace() usage on ASSERT(), BUG() and BUG_ON() calls. This is useful because some alternative C libraries like uClibc have optional support for backtrace() which is rarely built when debugging isn't taking place. Signed-off-by: Gustavo Zacarias --- Makefile | 4 ++++ kerncompat.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Makefile b/Makefile index 7cc7783..342545c 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,10 @@ BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS)) CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS)) +ifeq ($(DISABLE_BACKTRACE),1) +AM_CFLAGS += -DBTRFS_DISABLE_BACKTRACE +endif + ifneq ($(DISABLE_DOCUMENTATION),1) BUILDDIRS += build-Documentation INSTALLDIRS += install-Documentation diff --git a/kerncompat.h b/kerncompat.h index 19c7fa5..889d94c 100644 --- a/kerncompat.h +++ b/kerncompat.h @@ -29,7 +29,9 @@ #include #include #include +#ifndef BTRFS_DISABLE_BACKTRACE #include +#endif #define ptr_to_u64(x) ((u64)(uintptr_t)x) #define u64_to_ptr(x) ((void *)(uintptr_t)x) @@ -55,6 +57,7 @@ #define ULONG_MAX (~0UL) #endif +#ifndef BTRFS_DISABLE_BACKTRACE #define MAX_BACKTRACE 16 static inline void print_trace(void) { @@ -81,6 +84,9 @@ static inline void assert_trace(const char *assertion, const char *filename, } #define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 0) +#else +#define BUG() assert(0) +#endif #ifdef __CHECKER__ #define __force __attribute__((force)) @@ -264,10 +270,19 @@ static inline long IS_ERR(const void *ptr) #define kstrdup(x, y) strdup(x) #define kfree(x) free(x) +#ifndef BTRFS_DISABLE_BACKTRACE #define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, !(c)) +#else +#define BUG_ON(c) assert(!(c)) +#endif #define WARN_ON(c) BUG_ON(c) + +#ifndef BTRFS_DISABLE_BACKTRACE #define ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c)) +#else +#define ASSERT(c) assert(c) +#endif #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \