aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2016-05-12 02:57:52 -0400
committerIngo Molnar <mingo@kernel.org>2016-05-12 02:57:52 -0400
commit9ab975a029ec96b47c2f830aef6efd0e24f5c304 (patch)
tree9f72227d5a3282e19994cf8ee0ad81c4d66abdd7 /tools
parent38f5d8b32f36bcac1f54d4511a81e02ed8771a29 (diff)
parentd65444d2fba98dcd4fa028ffada39c36a46f0038 (diff)
Merge tag 'perf-core-for-mingo-20160511' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: - Fix symbol insertion and callchain behavior in db-export (Chris Phlipot) Infrastructure changes: - Add libunwind build test (feature query), working towards supporting cross-platform DWARF callchains, starting with arm/arm64 (He Kuang) - Use lsdir() more extensively (Masami Hiramatsu) - Use SBUILD_ID_SIZE in places where the equivalent expression was being used (Masami Hiramatsu) - Split some more 'perf trace' syscall arg beautifiers (Arnaldo Carvalho de Melo) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/build/Makefile.feature8
-rw-r--r--tools/build/feature/Makefile23
-rw-r--r--tools/build/feature/test-libunwind-aarch64.c26
-rw-r--r--tools/build/feature/test-libunwind-arm.c27
-rw-r--r--tools/build/feature/test-libunwind-debug-frame-aarch64.c16
-rw-r--r--tools/build/feature/test-libunwind-debug-frame-arm.c16
-rw-r--r--tools/build/feature/test-libunwind-x86.c27
-rw-r--r--tools/build/feature/test-libunwind-x86_64.c27
-rw-r--r--tools/perf/builtin-trace.c85
-rw-r--r--tools/perf/trace/beauty/flock.c31
-rw-r--r--tools/perf/trace/beauty/seccomp.c52
-rw-r--r--tools/perf/util/annotate.c2
-rw-r--r--tools/perf/util/build-id.c30
-rw-r--r--tools/perf/util/db-export.c12
-rw-r--r--tools/perf/util/dso.c4
-rw-r--r--tools/perf/util/header.c2
-rw-r--r--tools/perf/util/map.c2
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c9
-rw-r--r--tools/perf/util/symbol.c40
-rw-r--r--tools/perf/util/symbol.h3
-rw-r--r--tools/perf/util/util.c2
21 files changed, 306 insertions, 138 deletions
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 9f878619077a..57c8f98874e8 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -49,6 +49,10 @@ FEATURE_TESTS_BASIC := \
49 libslang \ 49 libslang \
50 libcrypto \ 50 libcrypto \
51 libunwind \ 51 libunwind \
52 libunwind-x86 \
53 libunwind-x86_64 \
54 libunwind-arm \
55 libunwind-aarch64 \
52 pthread-attr-setaffinity-np \ 56 pthread-attr-setaffinity-np \
53 stackprotector-all \ 57 stackprotector-all \
54 timerfd \ 58 timerfd \
@@ -69,7 +73,9 @@ FEATURE_TESTS_EXTRA := \
69 libbabeltrace \ 73 libbabeltrace \
70 liberty \ 74 liberty \
71 liberty-z \ 75 liberty-z \
72 libunwind-debug-frame 76 libunwind-debug-frame \
77 libunwind-debug-frame-arm \
78 libunwind-debug-frame-aarch64
73 79
74FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC) 80FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)
75 81
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 4ae94dbfdab9..3d88f09e188b 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -27,6 +27,12 @@ FILES= \
27 test-libcrypto.bin \ 27 test-libcrypto.bin \
28 test-libunwind.bin \ 28 test-libunwind.bin \
29 test-libunwind-debug-frame.bin \ 29 test-libunwind-debug-frame.bin \
30 test-libunwind-x86.bin \
31 test-libunwind-x86_64.bin \
32 test-libunwind-arm.bin \
33 test-libunwind-aarch64.bin \
34 test-libunwind-debug-frame-arm.bin \
35 test-libunwind-debug-frame-aarch64.bin \
30 test-pthread-attr-setaffinity-np.bin \ 36 test-pthread-attr-setaffinity-np.bin \
31 test-stackprotector-all.bin \ 37 test-stackprotector-all.bin \
32 test-timerfd.bin \ 38 test-timerfd.bin \
@@ -103,6 +109,23 @@ $(OUTPUT)test-libunwind.bin:
103 109
104$(OUTPUT)test-libunwind-debug-frame.bin: 110$(OUTPUT)test-libunwind-debug-frame.bin:
105 $(BUILD) -lelf 111 $(BUILD) -lelf
112$(OUTPUT)test-libunwind-x86.bin:
113 $(BUILD) -lelf -lunwind-x86
114
115$(OUTPUT)test-libunwind-x86_64.bin:
116 $(BUILD) -lelf -lunwind-x86_64
117
118$(OUTPUT)test-libunwind-arm.bin:
119 $(BUILD) -lelf -lunwind-arm
120
121$(OUTPUT)test-libunwind-aarch64.bin:
122 $(BUILD) -lelf -lunwind-aarch64
123
124$(OUTPUT)test-libunwind-debug-frame-arm.bin:
125 $(BUILD) -lelf -lunwind-arm
126
127$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
128 $(BUILD) -lelf -lunwind-aarch64
106 129
107$(OUTPUT)test-libaudit.bin: 130$(OUTPUT)test-libaudit.bin:
108 $(BUILD) -laudit 131 $(BUILD) -laudit
diff --git a/tools/build/feature/test-libunwind-aarch64.c b/tools/build/feature/test-libunwind-aarch64.c
new file mode 100644
index 000000000000..fc03fb64e8c1
--- /dev/null
+++ b/tools/build/feature/test-libunwind-aarch64.c
@@ -0,0 +1,26 @@
1#include <libunwind-aarch64.h>
2#include <stdlib.h>
3
4extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
5 unw_word_t ip,
6 unw_dyn_info_t *di,
7 unw_proc_info_t *pi,
8 int need_unwind_info, void *arg);
9
10#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
11
12static unw_accessors_t accessors;
13
14int main(void)
15{
16 unw_addr_space_t addr_space;
17
18 addr_space = unw_create_addr_space(&accessors, 0);
19 if (addr_space)
20 return 0;
21
22 unw_init_remote(NULL, addr_space, NULL);
23 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
24
25 return 0;
26}
diff --git a/tools/build/feature/test-libunwind-arm.c b/tools/build/feature/test-libunwind-arm.c
new file mode 100644
index 000000000000..632d95ec641f
--- /dev/null
+++ b/tools/build/feature/test-libunwind-arm.c
@@ -0,0 +1,27 @@
1#include <libunwind-arm.h>
2#include <stdlib.h>
3
4extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
5 unw_word_t ip,
6 unw_dyn_info_t *di,
7 unw_proc_info_t *pi,
8 int need_unwind_info, void *arg);
9
10
11#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
12
13static unw_accessors_t accessors;
14
15int main(void)
16{
17 unw_addr_space_t addr_space;
18
19 addr_space = unw_create_addr_space(&accessors, 0);
20 if (addr_space)
21 return 0;
22
23 unw_init_remote(NULL, addr_space, NULL);
24 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
25
26 return 0;
27}
diff --git a/tools/build/feature/test-libunwind-debug-frame-aarch64.c b/tools/build/feature/test-libunwind-debug-frame-aarch64.c
new file mode 100644
index 000000000000..22844673fc26
--- /dev/null
+++ b/tools/build/feature/test-libunwind-debug-frame-aarch64.c
@@ -0,0 +1,16 @@
1#include <libunwind-aarch64.h>
2#include <stdlib.h>
3
4extern int
5UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
6 unw_word_t ip, unw_word_t segbase,
7 const char *obj_name, unw_word_t start,
8 unw_word_t end);
9
10#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
11
12int main(void)
13{
14 dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
15 return 0;
16}
diff --git a/tools/build/feature/test-libunwind-debug-frame-arm.c b/tools/build/feature/test-libunwind-debug-frame-arm.c
new file mode 100644
index 000000000000..f98859684fee
--- /dev/null
+++ b/tools/build/feature/test-libunwind-debug-frame-arm.c
@@ -0,0 +1,16 @@
1#include <libunwind-arm.h>
2#include <stdlib.h>
3
4extern int
5UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
6 unw_word_t ip, unw_word_t segbase,
7 const char *obj_name, unw_word_t start,
8 unw_word_t end);
9
10#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
11
12int main(void)
13{
14 dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
15 return 0;
16}
diff --git a/tools/build/feature/test-libunwind-x86.c b/tools/build/feature/test-libunwind-x86.c
new file mode 100644
index 000000000000..3561edce305e
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86.c
@@ -0,0 +1,27 @@
1#include <libunwind-x86.h>
2#include <stdlib.h>
3
4extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
5 unw_word_t ip,
6 unw_dyn_info_t *di,
7 unw_proc_info_t *pi,
8 int need_unwind_info, void *arg);
9
10
11#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
12
13static unw_accessors_t accessors;
14
15int main(void)
16{
17 unw_addr_space_t addr_space;
18
19 addr_space = unw_create_addr_space(&accessors, 0);
20 if (addr_space)
21 return 0;
22
23 unw_init_remote(NULL, addr_space, NULL);
24 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
25
26 return 0;
27}
diff --git a/tools/build/feature/test-libunwind-x86_64.c b/tools/build/feature/test-libunwind-x86_64.c
new file mode 100644
index 000000000000..5add2517b2a1
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86_64.c
@@ -0,0 +1,27 @@
1#include <libunwind-x86_64.h>
2#include <stdlib.h>
3
4extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
5 unw_word_t ip,
6 unw_dyn_info_t *di,
7 unw_proc_info_t *pi,
8 int need_unwind_info, void *arg);
9
10
11#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
12
13static unw_accessors_t accessors;
14
15int main(void)
16{
17 unw_addr_space_t addr_space;
18
19 addr_space = unw_create_addr_space(&accessors, 0);
20 if (addr_space)
21 return 0;
22
23 unw_init_remote(NULL, addr_space, NULL);
24 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
25
26 return 0;
27}
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 709963740f9a..6e5c325148e4 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -41,7 +41,6 @@
41#include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */ 41#include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */
42#include <stdlib.h> 42#include <stdlib.h>
43#include <linux/err.h> 43#include <linux/err.h>
44#include <linux/seccomp.h>
45#include <linux/filter.h> 44#include <linux/filter.h>
46#include <linux/audit.h> 45#include <linux/audit.h>
47#include <sys/ptrace.h> 46#include <sys/ptrace.h>
@@ -369,37 +368,6 @@ static size_t syscall_arg__scnprintf_int(char *bf, size_t size,
369 368
370#define SCA_INT syscall_arg__scnprintf_int 369#define SCA_INT syscall_arg__scnprintf_int
371 370
372static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
373 struct syscall_arg *arg)
374{
375 int printed = 0, op = arg->val;
376
377 if (op == 0)
378 return scnprintf(bf, size, "NONE");
379#define P_CMD(cmd) \
380 if ((op & LOCK_##cmd) == LOCK_##cmd) { \
381 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
382 op &= ~LOCK_##cmd; \
383 }
384
385 P_CMD(SH);
386 P_CMD(EX);
387 P_CMD(NB);
388 P_CMD(UN);
389 P_CMD(MAND);
390 P_CMD(RW);
391 P_CMD(READ);
392 P_CMD(WRITE);
393#undef P_OP
394
395 if (op)
396 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
397
398 return printed;
399}
400
401#define SCA_FLOCK syscall_arg__scnprintf_flock
402
403static const char *bpf_cmd[] = { 371static const char *bpf_cmd[] = {
404 "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM", 372 "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM",
405 "MAP_GET_NEXT_KEY", "PROG_LOAD", 373 "MAP_GET_NEXT_KEY", "PROG_LOAD",
@@ -548,57 +516,6 @@ static const char *tioctls[] = {
548static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401); 516static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);
549#endif /* defined(__i386__) || defined(__x86_64__) */ 517#endif /* defined(__i386__) || defined(__x86_64__) */
550 518
551#ifndef SECCOMP_SET_MODE_STRICT
552#define SECCOMP_SET_MODE_STRICT 0
553#endif
554#ifndef SECCOMP_SET_MODE_FILTER
555#define SECCOMP_SET_MODE_FILTER 1
556#endif
557
558static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
559{
560 int op = arg->val;
561 size_t printed = 0;
562
563 switch (op) {
564#define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break
565 P_SECCOMP_SET_MODE_OP(STRICT);
566 P_SECCOMP_SET_MODE_OP(FILTER);
567#undef P_SECCOMP_SET_MODE_OP
568 default: printed = scnprintf(bf, size, "%#x", op); break;
569 }
570
571 return printed;
572}
573
574#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op
575
576#ifndef SECCOMP_FILTER_FLAG_TSYNC
577#define SECCOMP_FILTER_FLAG_TSYNC 1
578#endif
579
580static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
581 struct syscall_arg *arg)
582{
583 int printed = 0, flags = arg->val;
584
585#define P_FLAG(n) \
586 if (flags & SECCOMP_FILTER_FLAG_##n) { \
587 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
588 flags &= ~SECCOMP_FILTER_FLAG_##n; \
589 }
590
591 P_FLAG(TSYNC);
592#undef P_FLAG
593
594 if (flags)
595 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
596
597 return printed;
598}
599
600#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags
601
602#ifndef GRND_NONBLOCK 519#ifndef GRND_NONBLOCK
603#define GRND_NONBLOCK 0x0001 520#define GRND_NONBLOCK 0x0001
604#endif 521#endif
@@ -634,6 +551,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
634 .arg_parm = { [arg] = &strarray__##array, } 551 .arg_parm = { [arg] = &strarray__##array, }
635 552
636#include "trace/beauty/eventfd.c" 553#include "trace/beauty/eventfd.c"
554#include "trace/beauty/flock.c"
637#include "trace/beauty/futex_op.c" 555#include "trace/beauty/futex_op.c"
638#include "trace/beauty/mmap.c" 556#include "trace/beauty/mmap.c"
639#include "trace/beauty/mode_t.c" 557#include "trace/beauty/mode_t.c"
@@ -642,6 +560,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
642#include "trace/beauty/perf_event_open.c" 560#include "trace/beauty/perf_event_open.c"
643#include "trace/beauty/pid.c" 561#include "trace/beauty/pid.c"
644#include "trace/beauty/sched_policy.c" 562#include "trace/beauty/sched_policy.c"
563#include "trace/beauty/seccomp.c"
645#include "trace/beauty/signum.c" 564#include "trace/beauty/signum.c"
646#include "trace/beauty/socket_type.c" 565#include "trace/beauty/socket_type.c"
647#include "trace/beauty/waitid_options.c" 566#include "trace/beauty/waitid_options.c"
diff --git a/tools/perf/trace/beauty/flock.c b/tools/perf/trace/beauty/flock.c
new file mode 100644
index 000000000000..021bb48c6336
--- /dev/null
+++ b/tools/perf/trace/beauty/flock.c
@@ -0,0 +1,31 @@
1
2static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
3 struct syscall_arg *arg)
4{
5 int printed = 0, op = arg->val;
6
7 if (op == 0)
8 return scnprintf(bf, size, "NONE");
9#define P_CMD(cmd) \
10 if ((op & LOCK_##cmd) == LOCK_##cmd) { \
11 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
12 op &= ~LOCK_##cmd; \
13 }
14
15 P_CMD(SH);
16 P_CMD(EX);
17 P_CMD(NB);
18 P_CMD(UN);
19 P_CMD(MAND);
20 P_CMD(RW);
21 P_CMD(READ);
22 P_CMD(WRITE);
23#undef P_OP
24
25 if (op)
26 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
27
28 return printed;
29}
30
31#define SCA_FLOCK syscall_arg__scnprintf_flock
diff --git a/tools/perf/trace/beauty/seccomp.c b/tools/perf/trace/beauty/seccomp.c
new file mode 100644
index 000000000000..213c5a7e3e92
--- /dev/null
+++ b/tools/perf/trace/beauty/seccomp.c
@@ -0,0 +1,52 @@
1#include <linux/seccomp.h>
2
3#ifndef SECCOMP_SET_MODE_STRICT
4#define SECCOMP_SET_MODE_STRICT 0
5#endif
6#ifndef SECCOMP_SET_MODE_FILTER
7#define SECCOMP_SET_MODE_FILTER 1
8#endif
9
10static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
11{
12 int op = arg->val;
13 size_t printed = 0;
14
15 switch (op) {
16#define P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break
17 P_SECCOMP_SET_MODE_OP(STRICT);
18 P_SECCOMP_SET_MODE_OP(FILTER);
19#undef P_SECCOMP_SET_MODE_OP
20 default: printed = scnprintf(bf, size, "%#x", op); break;
21 }
22
23 return printed;
24}
25
26#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op
27
28#ifndef SECCOMP_FILTER_FLAG_TSYNC
29#define SECCOMP_FILTER_FLAG_TSYNC 1
30#endif
31
32static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
33 struct syscall_arg *arg)
34{
35 int printed = 0, flags = arg->val;
36
37#define P_FLAG(n) \
38 if (flags & SECCOMP_FILTER_FLAG_##n) { \
39 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
40 flags &= ~SECCOMP_FILTER_FLAG_##n; \
41 }
42
43 P_FLAG(TSYNC);
44#undef P_FLAG
45
46 if (flags)
47 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
48
49 return printed;
50}
51
52#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index d4b3d034c503..4db73d5a0dbc 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1138,7 +1138,7 @@ fallback:
1138 1138
1139 if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && 1139 if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS &&
1140 !dso__is_kcore(dso)) { 1140 !dso__is_kcore(dso)) {
1141 char bf[BUILD_ID_SIZE * 2 + 16] = " with build id "; 1141 char bf[SBUILD_ID_SIZE + 15] = " with build id ";
1142 char *build_id_msg = NULL; 1142 char *build_id_msg = NULL;
1143 1143
1144 if (dso->annotate_warned) 1144 if (dso->annotate_warned)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index b6ecf87bc3e3..bff425e1232c 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -365,39 +365,17 @@ static char *build_id_cache__dirname_from_path(const char *name,
365int build_id_cache__list_build_ids(const char *pathname, 365int build_id_cache__list_build_ids(const char *pathname,
366 struct strlist **result) 366 struct strlist **result)
367{ 367{
368 struct strlist *list;
369 char *dir_name; 368 char *dir_name;
370 DIR *dir;
371 struct dirent *d;
372 int ret = 0; 369 int ret = 0;
373 370
374 list = strlist__new(NULL, NULL);
375 dir_name = build_id_cache__dirname_from_path(pathname, false, false); 371 dir_name = build_id_cache__dirname_from_path(pathname, false, false);
376 if (!list || !dir_name) { 372 if (!dir_name)
377 ret = -ENOMEM; 373 return -ENOMEM;
378 goto out;
379 }
380 374
381 /* List up all dirents */ 375 *result = lsdir(dir_name, lsdir_no_dot_filter);
382 dir = opendir(dir_name); 376 if (!*result)
383 if (!dir) {
384 ret = -errno; 377 ret = -errno;
385 goto out;
386 }
387
388 while ((d = readdir(dir)) != NULL) {
389 if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
390 continue;
391 strlist__add(list, d->d_name);
392 }
393 closedir(dir);
394
395out:
396 free(dir_name); 378 free(dir_name);
397 if (ret)
398 strlist__delete(list);
399 else
400 *result = list;
401 379
402 return ret; 380 return ret;
403} 381}
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c
index f8e3057ae3b1..8d96c80cc67e 100644
--- a/tools/perf/util/db-export.c
+++ b/tools/perf/util/db-export.c
@@ -260,8 +260,7 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
260 if (!al->sym) { 260 if (!al->sym) {
261 al->sym = symbol__new(al->addr, 0, 0, "unknown"); 261 al->sym = symbol__new(al->addr, 0, 0, "unknown");
262 if (al->sym) 262 if (al->sym)
263 symbols__insert(&dso->symbols[al->map->type], 263 dso__insert_symbol(dso, al->map->type, al->sym);
264 al->sym);
265 } 264 }
266 265
267 if (al->sym) { 266 if (al->sym) {
@@ -325,10 +324,11 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
325 al.sym = node->sym; 324 al.sym = node->sym;
326 al.map = node->map; 325 al.map = node->map;
327 al.machine = machine; 326 al.machine = machine;
328 if (al.map) 327 al.addr = node->ip;
329 al.addr = al.map->map_ip(al.map, node->ip); 328
330 else 329 if (al.map && !al.sym)
331 al.addr = node->ip; 330 al.sym = dso__find_symbol(al.map->dso, MAP__FUNCTION,
331 al.addr);
332 332
333 db_ids_from_al(dbe, &al, &dso_db_id, &sym_db_id, &offset); 333 db_ids_from_al(dbe, &al, &dso_db_id, &sym_db_id, &offset);
334 334
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 8e6395439ca0..3357479082ca 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -38,7 +38,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
38 enum dso_binary_type type, 38 enum dso_binary_type type,
39 char *root_dir, char *filename, size_t size) 39 char *root_dir, char *filename, size_t size)
40{ 40{
41 char build_id_hex[BUILD_ID_SIZE * 2 + 1]; 41 char build_id_hex[SBUILD_ID_SIZE];
42 int ret = 0; 42 int ret = 0;
43 size_t len; 43 size_t len;
44 44
@@ -1301,7 +1301,7 @@ size_t __dsos__fprintf(struct list_head *head, FILE *fp)
1301 1301
1302size_t dso__fprintf_buildid(struct dso *dso, FILE *fp) 1302size_t dso__fprintf_buildid(struct dso *dso, FILE *fp)
1303{ 1303{
1304 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 1304 char sbuild_id[SBUILD_ID_SIZE];
1305 1305
1306 build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id); 1306 build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
1307 return fprintf(fp, "%s", sbuild_id); 1307 return fprintf(fp, "%s", sbuild_id);
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c6000d44f98c..08852dde1378 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1474,7 +1474,7 @@ static int __event_process_build_id(struct build_id_event *bev,
1474 1474
1475 dso = machine__findnew_dso(machine, filename); 1475 dso = machine__findnew_dso(machine, filename);
1476 if (dso != NULL) { 1476 if (dso != NULL) {
1477 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 1477 char sbuild_id[SBUILD_ID_SIZE];
1478 1478
1479 dso__set_build_id(dso, &bev->build_id); 1479 dso__set_build_id(dso, &bev->build_id);
1480 1480
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 02c31865648b..b19bcd3b7128 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -289,7 +289,7 @@ int map__load(struct map *map, symbol_filter_t filter)
289 nr = dso__load(map->dso, map, filter); 289 nr = dso__load(map->dso, map, filter);
290 if (nr < 0) { 290 if (nr < 0) {
291 if (map->dso->has_build_id) { 291 if (map->dso->has_build_id) {
292 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 292 char sbuild_id[SBUILD_ID_SIZE];
293 293
294 build_id__sprintf(map->dso->build_id, 294 build_id__sprintf(map->dso->build_id,
295 sizeof(map->dso->build_id), 295 sizeof(map->dso->build_id),
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 1546b749a3a3..ff134700bf30 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -408,8 +408,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
408 if (!t) 408 if (!t)
409 Py_FatalError("couldn't create Python tuple"); 409 Py_FatalError("couldn't create Python tuple");
410 410
411 if (!event) 411 if (!event) {
412 die("ug! no event found for type %d", (int)evsel->attr.config); 412 snprintf(handler_name, sizeof(handler_name),
413 "ug! no event found for type %" PRIu64, (u64)evsel->attr.config);
414 Py_FatalError(handler_name);
415 }
413 416
414 pid = raw_field_value(event, "common_pid", data); 417 pid = raw_field_value(event, "common_pid", data);
415 418
@@ -615,7 +618,7 @@ static int python_export_dso(struct db_export *dbe, struct dso *dso,
615 struct machine *machine) 618 struct machine *machine)
616{ 619{
617 struct tables *tables = container_of(dbe, struct tables, dbe); 620 struct tables *tables = container_of(dbe, struct tables, dbe);
618 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 621 char sbuild_id[SBUILD_ID_SIZE];
619 PyObject *t; 622 PyObject *t;
620 623
621 build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id); 624 build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 2946295ca502..7fb33304fb4e 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -413,6 +413,18 @@ void dso__reset_find_symbol_cache(struct dso *dso)
413 } 413 }
414} 414}
415 415
416void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym)
417{
418 symbols__insert(&dso->symbols[type], sym);
419
420 /* update the symbol cache if necessary */
421 if (dso->last_find_result[type].addr >= sym->start &&
422 (dso->last_find_result[type].addr < sym->end ||
423 sym->start == sym->end)) {
424 dso->last_find_result[type].symbol = sym;
425 }
426}
427
416struct symbol *dso__find_symbol(struct dso *dso, 428struct symbol *dso__find_symbol(struct dso *dso,
417 enum map_type type, u64 addr) 429 enum map_type type, u64 addr)
418{ 430{
@@ -1596,25 +1608,27 @@ out:
1596 return err; 1608 return err;
1597} 1609}
1598 1610
1611static bool visible_dir_filter(const char *name, struct dirent *d)
1612{
1613 if (d->d_type != DT_DIR)
1614 return false;
1615 return lsdir_no_dot_filter(name, d);
1616}
1617
1599static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz) 1618static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
1600{ 1619{
1601 char kallsyms_filename[PATH_MAX]; 1620 char kallsyms_filename[PATH_MAX];
1602 struct dirent *dent;
1603 int ret = -1; 1621 int ret = -1;
1604 DIR *d; 1622 struct strlist *dirs;
1623 struct str_node *nd;
1605 1624
1606 d = opendir(dir); 1625 dirs = lsdir(dir, visible_dir_filter);
1607 if (!d) 1626 if (!dirs)
1608 return -1; 1627 return -1;
1609 1628
1610 while (1) { 1629 strlist__for_each(nd, dirs) {
1611 dent = readdir(d);
1612 if (!dent)
1613 break;
1614 if (dent->d_type != DT_DIR)
1615 continue;
1616 scnprintf(kallsyms_filename, sizeof(kallsyms_filename), 1630 scnprintf(kallsyms_filename, sizeof(kallsyms_filename),
1617 "%s/%s/kallsyms", dir, dent->d_name); 1631 "%s/%s/kallsyms", dir, nd->s);
1618 if (!validate_kcore_addresses(kallsyms_filename, map)) { 1632 if (!validate_kcore_addresses(kallsyms_filename, map)) {
1619 strlcpy(dir, kallsyms_filename, dir_sz); 1633 strlcpy(dir, kallsyms_filename, dir_sz);
1620 ret = 0; 1634 ret = 0;
@@ -1622,7 +1636,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
1622 } 1636 }
1623 } 1637 }
1624 1638
1625 closedir(d); 1639 strlist__delete(dirs);
1626 1640
1627 return ret; 1641 return ret;
1628} 1642}
@@ -1630,7 +1644,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
1630static char *dso__find_kallsyms(struct dso *dso, struct map *map) 1644static char *dso__find_kallsyms(struct dso *dso, struct map *map)
1631{ 1645{
1632 u8 host_build_id[BUILD_ID_SIZE]; 1646 u8 host_build_id[BUILD_ID_SIZE];
1633 char sbuild_id[BUILD_ID_SIZE * 2 + 1]; 1647 char sbuild_id[SBUILD_ID_SIZE];
1634 bool is_host = false; 1648 bool is_host = false;
1635 char path[PATH_MAX]; 1649 char path[PATH_MAX];
1636 1650
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 07211c2f8456..2b5e4ed76fcb 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -246,6 +246,9 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
246int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map, 246int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
247 symbol_filter_t filter); 247 symbol_filter_t filter);
248 248
249void dso__insert_symbol(struct dso *dso, enum map_type type,
250 struct symbol *sym);
251
249struct symbol *dso__find_symbol(struct dso *dso, enum map_type type, 252struct symbol *dso__find_symbol(struct dso *dso, enum map_type type,
250 u64 addr); 253 u64 addr);
251struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, 254struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 01c9433de7ef..eab077ad6ca9 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -139,7 +139,7 @@ struct strlist *lsdir(const char *name,
139 139
140 list = strlist__new(NULL, NULL); 140 list = strlist__new(NULL, NULL);
141 if (!list) { 141 if (!list) {
142 errno = -ENOMEM; 142 errno = ENOMEM;
143 goto out; 143 goto out;
144 } 144 }
145 145