[Skiboot] [PATCH 05/34] Add global DEBUG make flag
Benjamin Herrenschmidt
benh at kernel.crashing.org
Sun Jul 24 09:26:59 AEST 2016
And use it to control the stack checker, memory poisoning and
CCAN's list debugging.
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
Makefile | 7 ++++++-
Makefile.main | 4 ++++
core/mem_region.c | 4 ++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 758bbb9..f13bf50 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,11 @@ else
endif
#
+# Main debug switch
+#
+DEBUG ?= 0
+
+#
# Set to enable SLW bits
#
PORE ?= 1
@@ -30,7 +35,7 @@ KERNEL ?=
#
# Optional build with advanced stack checking
#
-STACK_CHECK ?= 0
+STACK_CHECK ?= $(DEBUG)
#
# Where is the source directory, must be a full path (no ~)
diff --git a/Makefile.main b/Makefile.main
index 159ce26..03ae972 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -60,6 +60,10 @@ CPPFLAGS += -DBITS_PER_LONG=64 -DHAVE_BIG_ENDIAN
# causing all our printf's to warn
CPPFLAGS += -ffreestanding
+ifeq ($(DEBUG),1)
+CPPFLAGS += -DDEBUG -DCCAN_LIST_DEBUG
+endif
+
CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie -mbig-endian -m64
CFLAGS += -Wl,--oformat,elf64-powerpc
CFLAGS += $(call try-cflag,$(CC),-mabi=elfv1)
diff --git a/core/mem_region.c b/core/mem_region.c
index 0c482b0..576deae 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -30,7 +30,11 @@ int64_t mem_dump_free(void);
void mem_dump_allocs(void);
/* Memory poisoning on free (if POISON_MEM_REGION set to 1) */
+#ifdef DEBUG
+#define POISON_MEM_REGION 1
+#else
#define POISON_MEM_REGION 0
+#endif
#define POISON_MEM_REGION_WITH 0x99
#define POISON_MEM_REGION_LIMIT 1*1024*1024*1024
--
2.7.4
More information about the Skiboot
mailing list