diff --git a/tools/perf/Makefile b/tools/perf/Makefile index afd507574902a786447bd26ed368506177f290b1..3eda49215730b009c4ad1473d0c5f744a87a38d5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -755,6 +755,14 @@ else endif endif +ifdef NO_BACKTRACE + BASIC_CFLAGS += -DNO_BACKTRACE +else + ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) + BASIC_CFLAGS += -DNO_BACKTRACE + endif +endif + ifdef ASCIIDOC8 export ASCIIDOC8 endif diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 2f1156a62ab7c1cf97aadc8631257ba88032e916..116690a669d271c98f4c308ad72e7e9eb9b0512b 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -179,3 +179,17 @@ int main(void) } endef endif + +ifndef NO_BACKTRACE +define SOURCE_BACKTRACE +#include +#include + +int main(void) +{ + backtrace(NULL, 0); + backtrace_symbols(NULL, 0); + return 0; +} +endef +endif diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 1b8775c3707d483676c170bbf67d220d8ef1c14a..2055cf38041ce24e071c4f5b95af42f6237bc8d7 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -1,7 +1,9 @@ #include "../perf.h" #include "util.h" #include +#ifndef NO_BACKTRACE #include +#endif #include #include @@ -163,6 +165,7 @@ size_t hex_width(u64 v) } /* Obtain a backtrace and print it to stdout. */ +#ifndef NO_BACKTRACE void dump_stack(void) { void *array[16]; @@ -177,3 +180,6 @@ void dump_stack(void) free(strings); } +#else +void dump_stack(void) {} +#endif