btrfs-progs: add option to disable backtrace usage
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 <gustavo@zacarias.com.ar> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
cb37bf83cc
commit
05499d865f
4
Makefile
4
Makefile
|
@ -63,6 +63,10 @@ BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
|
||||||
INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
|
INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
|
||||||
CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
|
CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
|
||||||
|
|
||||||
|
ifeq ($(DISABLE_BACKTRACE),1)
|
||||||
|
AM_CFLAGS += -DBTRFS_DISABLE_BACKTRACE
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(DISABLE_DOCUMENTATION),1)
|
ifneq ($(DISABLE_DOCUMENTATION),1)
|
||||||
BUILDDIRS += build-Documentation
|
BUILDDIRS += build-Documentation
|
||||||
INSTALLDIRS += install-Documentation
|
INSTALLDIRS += install-Documentation
|
||||||
|
|
15
kerncompat.h
15
kerncompat.h
|
@ -29,7 +29,9 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#ifndef BTRFS_DISABLE_BACKTRACE
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define ptr_to_u64(x) ((u64)(uintptr_t)x)
|
#define ptr_to_u64(x) ((u64)(uintptr_t)x)
|
||||||
#define u64_to_ptr(x) ((void *)(uintptr_t)x)
|
#define u64_to_ptr(x) ((void *)(uintptr_t)x)
|
||||||
|
@ -55,6 +57,7 @@
|
||||||
#define ULONG_MAX (~0UL)
|
#define ULONG_MAX (~0UL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BTRFS_DISABLE_BACKTRACE
|
||||||
#define MAX_BACKTRACE 16
|
#define MAX_BACKTRACE 16
|
||||||
static inline void print_trace(void)
|
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)
|
#define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 0)
|
||||||
|
#else
|
||||||
|
#define BUG() assert(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __CHECKER__
|
#ifdef __CHECKER__
|
||||||
#define __force __attribute__((force))
|
#define __force __attribute__((force))
|
||||||
|
@ -264,10 +270,19 @@ static inline long IS_ERR(const void *ptr)
|
||||||
#define kstrdup(x, y) strdup(x)
|
#define kstrdup(x, y) strdup(x)
|
||||||
#define kfree(x) free(x)
|
#define kfree(x) free(x)
|
||||||
|
|
||||||
|
#ifndef BTRFS_DISABLE_BACKTRACE
|
||||||
#define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, !(c))
|
#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)
|
#define WARN_ON(c) BUG_ON(c)
|
||||||
|
|
||||||
|
#ifndef BTRFS_DISABLE_BACKTRACE
|
||||||
#define ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c))
|
#define ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c))
|
||||||
|
#else
|
||||||
|
#define ASSERT(c) assert(c)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define container_of(ptr, type, member) ({ \
|
#define container_of(ptr, type, member) ({ \
|
||||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||||
|
|
Loading…
Reference in New Issue