提交 c9f08bee 编写于 作者: I Irina Tirdea 提交者: Arnaldo Carvalho de Melo

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: NIrina 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.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 9612ef67
...@@ -755,6 +755,14 @@ else ...@@ -755,6 +755,14 @@ else
endif endif
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 ifdef ASCIIDOC8
export ASCIIDOC8 export ASCIIDOC8
endif endif
......
...@@ -179,3 +179,17 @@ int main(void) ...@@ -179,3 +179,17 @@ int main(void)
} }
endef endef
endif endif
ifndef NO_BACKTRACE
define SOURCE_BACKTRACE
#include <execinfo.h>
#include <stdio.h>
int main(void)
{
backtrace(NULL, 0);
backtrace_symbols(NULL, 0);
return 0;
}
endef
endif
#include "../perf.h" #include "../perf.h"
#include "util.h" #include "util.h"
#include <sys/mman.h> #include <sys/mman.h>
#ifndef NO_BACKTRACE
#include <execinfo.h> #include <execinfo.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -163,6 +165,7 @@ size_t hex_width(u64 v) ...@@ -163,6 +165,7 @@ size_t hex_width(u64 v)
} }
/* Obtain a backtrace and print it to stdout. */ /* Obtain a backtrace and print it to stdout. */
#ifndef NO_BACKTRACE
void dump_stack(void) void dump_stack(void)
{ {
void *array[16]; void *array[16];
...@@ -177,3 +180,6 @@ void dump_stack(void) ...@@ -177,3 +180,6 @@ void dump_stack(void)
free(strings); free(strings);
} }
#else
void dump_stack(void) {}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册