diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-05 10:33:41 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-12 10:26:59 -0400 |
commit | 4924734570a073049450b11f7c59ce5992b03343 (patch) | |
tree | 7fbf3af95e3702b0dca4a0cb213f2ebbba44671f | |
parent | 62aa0e177d278462145a29c30d3c8501ae57e200 (diff) |
perf probe: Check if dwarf_getlocations() is available
If not, tell the user that:
config/Makefile:273: Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157
And return -ENOTSUPP in die_get_var_range(), failing features that
need it, like the one pointed out above.
This fixes the build on older systems, such as Ubuntu 12.04.5.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Vinson Lee <vlee@freedesktop.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-9l7luqkq4gfnx7vrklkq4obs@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/build/Makefile.feature | 2 | ||||
-rw-r--r-- | tools/build/feature/Makefile | 4 | ||||
-rw-r--r-- | tools/build/feature/test-all.c | 5 | ||||
-rw-r--r-- | tools/build/feature/test-dwarf_getlocations.c | 12 | ||||
-rw-r--r-- | tools/perf/config/Makefile | 6 | ||||
-rw-r--r-- | tools/perf/util/dwarf-aux.c | 9 |
6 files changed, 38 insertions, 0 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 6b7707270aa3..9f878619077a 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature | |||
@@ -30,6 +30,7 @@ endef | |||
30 | FEATURE_TESTS_BASIC := \ | 30 | FEATURE_TESTS_BASIC := \ |
31 | backtrace \ | 31 | backtrace \ |
32 | dwarf \ | 32 | dwarf \ |
33 | dwarf_getlocations \ | ||
33 | fortify-source \ | 34 | fortify-source \ |
34 | sync-compare-and-swap \ | 35 | sync-compare-and-swap \ |
35 | glibc \ | 36 | glibc \ |
@@ -78,6 +79,7 @@ endif | |||
78 | 79 | ||
79 | FEATURE_DISPLAY ?= \ | 80 | FEATURE_DISPLAY ?= \ |
80 | dwarf \ | 81 | dwarf \ |
82 | dwarf_getlocations \ | ||
81 | glibc \ | 83 | glibc \ |
82 | gtk2 \ | 84 | gtk2 \ |
83 | libaudit \ | 85 | libaudit \ |
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index c5f4c417428d..4ae94dbfdab9 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile | |||
@@ -3,6 +3,7 @@ FILES= \ | |||
3 | test-backtrace.bin \ | 3 | test-backtrace.bin \ |
4 | test-bionic.bin \ | 4 | test-bionic.bin \ |
5 | test-dwarf.bin \ | 5 | test-dwarf.bin \ |
6 | test-dwarf_getlocations.bin \ | ||
6 | test-fortify-source.bin \ | 7 | test-fortify-source.bin \ |
7 | test-sync-compare-and-swap.bin \ | 8 | test-sync-compare-and-swap.bin \ |
8 | test-glibc.bin \ | 9 | test-glibc.bin \ |
@@ -82,6 +83,9 @@ endif | |||
82 | $(OUTPUT)test-dwarf.bin: | 83 | $(OUTPUT)test-dwarf.bin: |
83 | $(BUILD) $(DWARFLIBS) | 84 | $(BUILD) $(DWARFLIBS) |
84 | 85 | ||
86 | $(OUTPUT)test-dwarf_getlocations.bin: | ||
87 | $(BUILD) $(DWARFLIBS) | ||
88 | |||
85 | $(OUTPUT)test-libelf-mmap.bin: | 89 | $(OUTPUT)test-libelf-mmap.bin: |
86 | $(BUILD) -lelf | 90 | $(BUILD) -lelf |
87 | 91 | ||
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index e499a36c1e4a..a282e8cb84f3 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c | |||
@@ -41,6 +41,10 @@ | |||
41 | # include "test-dwarf.c" | 41 | # include "test-dwarf.c" |
42 | #undef main | 42 | #undef main |
43 | 43 | ||
44 | #define main main_test_dwarf_getlocations | ||
45 | # include "test-dwarf_getlocations.c" | ||
46 | #undef main | ||
47 | |||
44 | #define main main_test_libelf_getphdrnum | 48 | #define main main_test_libelf_getphdrnum |
45 | # include "test-libelf-getphdrnum.c" | 49 | # include "test-libelf-getphdrnum.c" |
46 | #undef main | 50 | #undef main |
@@ -143,6 +147,7 @@ int main(int argc, char *argv[]) | |||
143 | main_test_libelf_mmap(); | 147 | main_test_libelf_mmap(); |
144 | main_test_glibc(); | 148 | main_test_glibc(); |
145 | main_test_dwarf(); | 149 | main_test_dwarf(); |
150 | main_test_dwarf_getlocations(); | ||
146 | main_test_libelf_getphdrnum(); | 151 | main_test_libelf_getphdrnum(); |
147 | main_test_libunwind(); | 152 | main_test_libunwind(); |
148 | main_test_libaudit(); | 153 | main_test_libaudit(); |
diff --git a/tools/build/feature/test-dwarf_getlocations.c b/tools/build/feature/test-dwarf_getlocations.c new file mode 100644 index 000000000000..70162699dd43 --- /dev/null +++ b/tools/build/feature/test-dwarf_getlocations.c | |||
@@ -0,0 +1,12 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <elfutils/libdw.h> | ||
3 | |||
4 | int main(void) | ||
5 | { | ||
6 | Dwarf_Addr base, start, end; | ||
7 | Dwarf_Attribute attr; | ||
8 | Dwarf_Op *op; | ||
9 | size_t nops; | ||
10 | ptrdiff_t offset = 0; | ||
11 | return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops); | ||
12 | } | ||
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index f7d7f5a1cad5..6f8f6430f2bf 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -268,6 +268,12 @@ else | |||
268 | ifneq ($(feature-dwarf), 1) | 268 | ifneq ($(feature-dwarf), 1) |
269 | msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); | 269 | msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); |
270 | NO_DWARF := 1 | 270 | NO_DWARF := 1 |
271 | else | ||
272 | ifneq ($(feature-dwarf_getlocations), 1) | ||
273 | msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157); | ||
274 | else | ||
275 | CFLAGS += -DHAVE_DWARF_GETLOCATIONS | ||
276 | endif # dwarf_getlocations | ||
271 | endif # Dwarf support | 277 | endif # Dwarf support |
272 | endif # libelf support | 278 | endif # libelf support |
273 | endif # NO_LIBELF | 279 | endif # NO_LIBELF |
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 577e600c8eb1..aea189b41cc8 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c | |||
@@ -959,6 +959,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf) | |||
959 | return 0; | 959 | return 0; |
960 | } | 960 | } |
961 | 961 | ||
962 | #ifdef HAVE_DWARF_GETLOCATIONS | ||
962 | /** | 963 | /** |
963 | * die_get_var_innermost_scope - Get innermost scope range of given variable DIE | 964 | * die_get_var_innermost_scope - Get innermost scope range of given variable DIE |
964 | * @sp_die: a subprogram DIE | 965 | * @sp_die: a subprogram DIE |
@@ -1080,3 +1081,11 @@ int die_get_var_range(Dwarf_Die *sp_die, Dwarf_Die *vr_die, struct strbuf *buf) | |||
1080 | 1081 | ||
1081 | return ret; | 1082 | return ret; |
1082 | } | 1083 | } |
1084 | #else | ||
1085 | int die_get_var_range(Dwarf_Die *sp_die __maybe_unused, | ||
1086 | Dwarf_Die *vr_die __maybe_unused, | ||
1087 | struct strbuf *buf __maybe_unused) | ||
1088 | { | ||
1089 | return -ENOTSUP; | ||
1090 | } | ||
1091 | #endif | ||