From 82c436587c31cd760aef4db3661d54553ab88b87 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 3 Feb 2018 15:04:39 +0100 Subject: [PATCH] Do not create deep backtraces unless in ENABLE_DEBUG mode Signed-off-by: Clifford Wolf --- Makefile | 4 ++-- kernel/log.cc | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index dcc8be3eb..39e173a26 100644 --- a/Makefile +++ b/Makefile @@ -264,9 +264,9 @@ endif ifeq ($(ENABLE_DEBUG),1) ifeq ($(CONFIG),clang) -CXXFLAGS := -O0 $(filter-out -Os,$(CXXFLAGS)) +CXXFLAGS := -O0 -DDEBUG $(filter-out -Os,$(CXXFLAGS)) else -CXXFLAGS := -Og $(filter-out -Os,$(CXXFLAGS)) +CXXFLAGS := -Og -DDEBUG $(filter-out -Os,$(CXXFLAGS)) endif endif diff --git a/kernel/log.cc b/kernel/log.cc index 7be95204b..8b12008bc 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -375,6 +375,9 @@ void log_backtrace(const char *prefix, int levels) if (levels <= 1) return; +#ifndef DEBUG + log("%sframe #2: [build Yosys with ENABLE_DEBUG for deeper backtraces]\n", prefix); +#else if ((p = __builtin_extract_return_addr(__builtin_return_address(1))) && dladdr(p, &dli)) { log("%sframe #2: %p %s(%p) %s(%p)\n", prefix, p, dli.dli_fname, dli.dli_fbase, dli.dli_sname, dli.dli_saddr); } else { @@ -446,6 +449,7 @@ void log_backtrace(const char *prefix, int levels) } if (levels <= 9) return; +#endif } #else void log_backtrace(const char*, int) { } -- 2.30.2