diff options
author | Irina Tirdea <irina.tirdea@intel.com> | 2012-09-07 20:43:23 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-07 21:12:30 -0400 |
commit | c9f08bee50c71b06685ccff8110e56a7c05662b7 (patch) | |
tree | 5a4fd1448bef4204e0dc0e99f8bf925a18fb6f61 | |
parent | 9612ef6716efc20fac0f57d59452cda4e6846bda (diff) |
perf tools: add NO_BACKTRACE for application self-debugging
perf has support for self-debugging by defining dump_stack function.
This function uses backtrace and backtrace_symbols functions defined as
GNU extensions.
In Android, bionic does not offer support for these functions and
compilation will fail with the following error:
target C: libperf <= tools/perf/util/util.c
tools/perf/util/util.c:4:22: fatal error: execinfo.h: No such file or directory
compilation terminated.
Add a compile-time option (NO_BACKTRACE) to enable or disable
self-debugging functionality in perf. This can also help in debugging
since it offers the possibility to turn on/off printing the backtrace.
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1347065004-15306-12-git-send-email-irina.tirdea@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/Makefile | 8 | ||||
-rw-r--r-- | tools/perf/config/feature-tests.mak | 14 | ||||
-rw-r--r-- | tools/perf/util/util.c | 6 |
3 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index afd507574902..3eda49215730 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -755,6 +755,14 @@ else | |||
755 | endif | 755 | endif |
756 | endif | 756 | endif |
757 | 757 | ||
758 | ifdef NO_BACKTRACE | ||
759 | BASIC_CFLAGS += -DNO_BACKTRACE | ||
760 | else | ||
761 | ifneq ($(call try-cc,$(SOURCE_BACKTRACE),),y) | ||
762 | BASIC_CFLAGS += -DNO_BACKTRACE | ||
763 | endif | ||
764 | endif | ||
765 | |||
758 | ifdef ASCIIDOC8 | 766 | ifdef ASCIIDOC8 |
759 | export ASCIIDOC8 | 767 | export ASCIIDOC8 |
760 | endif | 768 | endif |
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 2f1156a62ab7..116690a669d2 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak | |||
@@ -179,3 +179,17 @@ int main(void) | |||
179 | } | 179 | } |
180 | endef | 180 | endef |
181 | endif | 181 | endif |
182 | |||
183 | ifndef NO_BACKTRACE | ||
184 | define SOURCE_BACKTRACE | ||
185 | #include <execinfo.h> | ||
186 | #include <stdio.h> | ||
187 | |||
188 | int main(void) | ||
189 | { | ||
190 | backtrace(NULL, 0); | ||
191 | backtrace_symbols(NULL, 0); | ||
192 | return 0; | ||
193 | } | ||
194 | endef | ||
195 | endif | ||
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 1b8775c3707d..2055cf38041c 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -1,7 +1,9 @@ | |||
1 | #include "../perf.h" | 1 | #include "../perf.h" |
2 | #include "util.h" | 2 | #include "util.h" |
3 | #include <sys/mman.h> | 3 | #include <sys/mman.h> |
4 | #ifndef NO_BACKTRACE | ||
4 | #include <execinfo.h> | 5 | #include <execinfo.h> |
6 | #endif | ||
5 | #include <stdio.h> | 7 | #include <stdio.h> |
6 | #include <stdlib.h> | 8 | #include <stdlib.h> |
7 | 9 | ||
@@ -163,6 +165,7 @@ size_t hex_width(u64 v) | |||
163 | } | 165 | } |
164 | 166 | ||
165 | /* Obtain a backtrace and print it to stdout. */ | 167 | /* Obtain a backtrace and print it to stdout. */ |
168 | #ifndef NO_BACKTRACE | ||
166 | void dump_stack(void) | 169 | void dump_stack(void) |
167 | { | 170 | { |
168 | void *array[16]; | 171 | void *array[16]; |
@@ -177,3 +180,6 @@ void dump_stack(void) | |||
177 | 180 | ||
178 | free(strings); | 181 | free(strings); |
179 | } | 182 | } |
183 | #else | ||
184 | void dump_stack(void) {} | ||
185 | #endif | ||