]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'perf-core-for-mingo-20160511' of git://git.kernel.org/pub/scm/linux/kernel...
authorIngo Molnar <mingo@kernel.org>
Thu, 12 May 2016 06:57:52 +0000 (08:57 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 12 May 2016 06:57:52 +0000 (08:57 +0200)
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>
21 files changed:
tools/build/Makefile.feature
tools/build/feature/Makefile
tools/build/feature/test-libunwind-aarch64.c [new file with mode: 0644]
tools/build/feature/test-libunwind-arm.c [new file with mode: 0644]
tools/build/feature/test-libunwind-debug-frame-aarch64.c [new file with mode: 0644]
tools/build/feature/test-libunwind-debug-frame-arm.c [new file with mode: 0644]
tools/build/feature/test-libunwind-x86.c [new file with mode: 0644]
tools/build/feature/test-libunwind-x86_64.c [new file with mode: 0644]
tools/perf/builtin-trace.c
tools/perf/trace/beauty/flock.c [new file with mode: 0644]
tools/perf/trace/beauty/seccomp.c [new file with mode: 0644]
tools/perf/util/annotate.c
tools/perf/util/build-id.c
tools/perf/util/db-export.c
tools/perf/util/dso.c
tools/perf/util/header.c
tools/perf/util/map.c
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/symbol.c
tools/perf/util/symbol.h
tools/perf/util/util.c

index 9f878619077aeb9ecbb50f87b381706d083def37..57c8f98874e833b7407c7000fe2fb8ff1253eb16 100644 (file)
@@ -49,6 +49,10 @@ FEATURE_TESTS_BASIC :=                       \
        libslang                        \
        libcrypto                       \
        libunwind                       \
+       libunwind-x86                   \
+       libunwind-x86_64                \
+       libunwind-arm                   \
+       libunwind-aarch64               \
        pthread-attr-setaffinity-np     \
        stackprotector-all              \
        timerfd                         \
@@ -69,7 +73,9 @@ FEATURE_TESTS_EXTRA :=                        \
        libbabeltrace                   \
        liberty                         \
        liberty-z                       \
-       libunwind-debug-frame
+       libunwind-debug-frame           \
+       libunwind-debug-frame-arm       \
+       libunwind-debug-frame-aarch64
 
 FEATURE_TESTS ?= $(FEATURE_TESTS_BASIC)
 
index 4ae94dbfdab98d5181e18d9d8864a24f942bdc53..3d88f09e188bdd3e01f7affc2094aeae2e6b1863 100644 (file)
@@ -27,6 +27,12 @@ FILES=                                       \
        test-libcrypto.bin              \
        test-libunwind.bin              \
        test-libunwind-debug-frame.bin  \
+       test-libunwind-x86.bin          \
+       test-libunwind-x86_64.bin       \
+       test-libunwind-arm.bin          \
+       test-libunwind-aarch64.bin      \
+       test-libunwind-debug-frame-arm.bin      \
+       test-libunwind-debug-frame-aarch64.bin  \
        test-pthread-attr-setaffinity-np.bin    \
        test-stackprotector-all.bin     \
        test-timerfd.bin                \
@@ -103,6 +109,23 @@ $(OUTPUT)test-libunwind.bin:
 
 $(OUTPUT)test-libunwind-debug-frame.bin:
        $(BUILD) -lelf
+$(OUTPUT)test-libunwind-x86.bin:
+       $(BUILD) -lelf -lunwind-x86
+
+$(OUTPUT)test-libunwind-x86_64.bin:
+       $(BUILD) -lelf -lunwind-x86_64
+
+$(OUTPUT)test-libunwind-arm.bin:
+       $(BUILD) -lelf -lunwind-arm
+
+$(OUTPUT)test-libunwind-aarch64.bin:
+       $(BUILD) -lelf -lunwind-aarch64
+
+$(OUTPUT)test-libunwind-debug-frame-arm.bin:
+       $(BUILD) -lelf -lunwind-arm
+
+$(OUTPUT)test-libunwind-debug-frame-aarch64.bin:
+       $(BUILD) -lelf -lunwind-aarch64
 
 $(OUTPUT)test-libaudit.bin:
        $(BUILD) -laudit
diff --git a/tools/build/feature/test-libunwind-aarch64.c b/tools/build/feature/test-libunwind-aarch64.c
new file mode 100644 (file)
index 0000000..fc03fb6
--- /dev/null
@@ -0,0 +1,26 @@
+#include <libunwind-aarch64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                              unw_word_t ip,
+                                              unw_dyn_info_t *di,
+                                              unw_proc_info_t *pi,
+                                              int need_unwind_info, void *arg);
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+       unw_addr_space_t addr_space;
+
+       addr_space = unw_create_addr_space(&accessors, 0);
+       if (addr_space)
+               return 0;
+
+       unw_init_remote(NULL, addr_space, NULL);
+       dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+       return 0;
+}
diff --git a/tools/build/feature/test-libunwind-arm.c b/tools/build/feature/test-libunwind-arm.c
new file mode 100644 (file)
index 0000000..632d95e
--- /dev/null
@@ -0,0 +1,27 @@
+#include <libunwind-arm.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                              unw_word_t ip,
+                                              unw_dyn_info_t *di,
+                                              unw_proc_info_t *pi,
+                                              int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+       unw_addr_space_t addr_space;
+
+       addr_space = unw_create_addr_space(&accessors, 0);
+       if (addr_space)
+               return 0;
+
+       unw_init_remote(NULL, addr_space, NULL);
+       dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+       return 0;
+}
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 (file)
index 0000000..2284467
--- /dev/null
@@ -0,0 +1,16 @@
+#include <libunwind-aarch64.h>
+#include <stdlib.h>
+
+extern int
+UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
+                                unw_word_t ip, unw_word_t segbase,
+                                const char *obj_name, unw_word_t start,
+                                unw_word_t end);
+
+#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
+
+int main(void)
+{
+       dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
+       return 0;
+}
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 (file)
index 0000000..f988596
--- /dev/null
@@ -0,0 +1,16 @@
+#include <libunwind-arm.h>
+#include <stdlib.h>
+
+extern int
+UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
+                                unw_word_t ip, unw_word_t segbase,
+                                const char *obj_name, unw_word_t start,
+                                unw_word_t end);
+
+#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
+
+int main(void)
+{
+       dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
+       return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86.c b/tools/build/feature/test-libunwind-x86.c
new file mode 100644 (file)
index 0000000..3561edc
--- /dev/null
@@ -0,0 +1,27 @@
+#include <libunwind-x86.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                              unw_word_t ip,
+                                              unw_dyn_info_t *di,
+                                              unw_proc_info_t *pi,
+                                              int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+       unw_addr_space_t addr_space;
+
+       addr_space = unw_create_addr_space(&accessors, 0);
+       if (addr_space)
+               return 0;
+
+       unw_init_remote(NULL, addr_space, NULL);
+       dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+       return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86_64.c b/tools/build/feature/test-libunwind-x86_64.c
new file mode 100644 (file)
index 0000000..5add251
--- /dev/null
@@ -0,0 +1,27 @@
+#include <libunwind-x86_64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+                                              unw_word_t ip,
+                                              unw_dyn_info_t *di,
+                                              unw_proc_info_t *pi,
+                                              int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+       unw_addr_space_t addr_space;
+
+       addr_space = unw_create_addr_space(&accessors, 0);
+       if (addr_space)
+               return 0;
+
+       unw_init_remote(NULL, addr_space, NULL);
+       dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+       return 0;
+}
index 709963740f9a52ae98e5096848e6fe351584a87b..6e5c325148e488ec61a880196db9a7294d20156c 100644 (file)
@@ -41,7 +41,6 @@
 #include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */
 #include <stdlib.h>
 #include <linux/err.h>
-#include <linux/seccomp.h>
 #include <linux/filter.h>
 #include <linux/audit.h>
 #include <sys/ptrace.h>
@@ -369,37 +368,6 @@ static size_t syscall_arg__scnprintf_int(char *bf, size_t size,
 
 #define SCA_INT syscall_arg__scnprintf_int
 
-static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
-                                          struct syscall_arg *arg)
-{
-       int printed = 0, op = arg->val;
-
-       if (op == 0)
-               return scnprintf(bf, size, "NONE");
-#define        P_CMD(cmd) \
-       if ((op & LOCK_##cmd) == LOCK_##cmd) { \
-               printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
-               op &= ~LOCK_##cmd; \
-       }
-
-       P_CMD(SH);
-       P_CMD(EX);
-       P_CMD(NB);
-       P_CMD(UN);
-       P_CMD(MAND);
-       P_CMD(RW);
-       P_CMD(READ);
-       P_CMD(WRITE);
-#undef P_OP
-
-       if (op)
-               printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
-
-       return printed;
-}
-
-#define SCA_FLOCK syscall_arg__scnprintf_flock
-
 static const char *bpf_cmd[] = {
        "MAP_CREATE", "MAP_LOOKUP_ELEM", "MAP_UPDATE_ELEM", "MAP_DELETE_ELEM",
        "MAP_GET_NEXT_KEY", "PROG_LOAD",
@@ -548,57 +516,6 @@ static const char *tioctls[] = {
 static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);
 #endif /* defined(__i386__) || defined(__x86_64__) */
 
-#ifndef SECCOMP_SET_MODE_STRICT
-#define SECCOMP_SET_MODE_STRICT 0
-#endif
-#ifndef SECCOMP_SET_MODE_FILTER
-#define SECCOMP_SET_MODE_FILTER 1
-#endif
-
-static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
-{
-       int op = arg->val;
-       size_t printed = 0;
-
-       switch (op) {
-#define        P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break
-       P_SECCOMP_SET_MODE_OP(STRICT);
-       P_SECCOMP_SET_MODE_OP(FILTER);
-#undef P_SECCOMP_SET_MODE_OP
-       default: printed = scnprintf(bf, size, "%#x", op);                        break;
-       }
-
-       return printed;
-}
-
-#define SCA_SECCOMP_OP  syscall_arg__scnprintf_seccomp_op
-
-#ifndef SECCOMP_FILTER_FLAG_TSYNC
-#define SECCOMP_FILTER_FLAG_TSYNC 1
-#endif
-
-static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
-                                                  struct syscall_arg *arg)
-{
-       int printed = 0, flags = arg->val;
-
-#define        P_FLAG(n) \
-       if (flags & SECCOMP_FILTER_FLAG_##n) { \
-               printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
-               flags &= ~SECCOMP_FILTER_FLAG_##n; \
-       }
-
-       P_FLAG(TSYNC);
-#undef P_FLAG
-
-       if (flags)
-               printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
-
-       return printed;
-}
-
-#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags
-
 #ifndef GRND_NONBLOCK
 #define GRND_NONBLOCK  0x0001
 #endif
@@ -634,6 +551,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
          .arg_parm      = { [arg] = &strarray__##array, }
 
 #include "trace/beauty/eventfd.c"
+#include "trace/beauty/flock.c"
 #include "trace/beauty/futex_op.c"
 #include "trace/beauty/mmap.c"
 #include "trace/beauty/mode_t.c"
@@ -642,6 +560,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
 #include "trace/beauty/perf_event_open.c"
 #include "trace/beauty/pid.c"
 #include "trace/beauty/sched_policy.c"
+#include "trace/beauty/seccomp.c"
 #include "trace/beauty/signum.c"
 #include "trace/beauty/socket_type.c"
 #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 (file)
index 0000000..021bb48
--- /dev/null
@@ -0,0 +1,31 @@
+
+static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
+                                          struct syscall_arg *arg)
+{
+       int printed = 0, op = arg->val;
+
+       if (op == 0)
+               return scnprintf(bf, size, "NONE");
+#define        P_CMD(cmd) \
+       if ((op & LOCK_##cmd) == LOCK_##cmd) { \
+               printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
+               op &= ~LOCK_##cmd; \
+       }
+
+       P_CMD(SH);
+       P_CMD(EX);
+       P_CMD(NB);
+       P_CMD(UN);
+       P_CMD(MAND);
+       P_CMD(RW);
+       P_CMD(READ);
+       P_CMD(WRITE);
+#undef P_OP
+
+       if (op)
+               printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
+
+       return printed;
+}
+
+#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 (file)
index 0000000..213c5a7
--- /dev/null
@@ -0,0 +1,52 @@
+#include <linux/seccomp.h>
+
+#ifndef SECCOMP_SET_MODE_STRICT
+#define SECCOMP_SET_MODE_STRICT 0
+#endif
+#ifndef SECCOMP_SET_MODE_FILTER
+#define SECCOMP_SET_MODE_FILTER 1
+#endif
+
+static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
+{
+       int op = arg->val;
+       size_t printed = 0;
+
+       switch (op) {
+#define        P_SECCOMP_SET_MODE_OP(n) case SECCOMP_SET_MODE_##n: printed = scnprintf(bf, size, #n); break
+       P_SECCOMP_SET_MODE_OP(STRICT);
+       P_SECCOMP_SET_MODE_OP(FILTER);
+#undef P_SECCOMP_SET_MODE_OP
+       default: printed = scnprintf(bf, size, "%#x", op);                        break;
+       }
+
+       return printed;
+}
+
+#define SCA_SECCOMP_OP  syscall_arg__scnprintf_seccomp_op
+
+#ifndef SECCOMP_FILTER_FLAG_TSYNC
+#define SECCOMP_FILTER_FLAG_TSYNC 1
+#endif
+
+static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size,
+                                                  struct syscall_arg *arg)
+{
+       int printed = 0, flags = arg->val;
+
+#define        P_FLAG(n) \
+       if (flags & SECCOMP_FILTER_FLAG_##n) { \
+               printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
+               flags &= ~SECCOMP_FILTER_FLAG_##n; \
+       }
+
+       P_FLAG(TSYNC);
+#undef P_FLAG
+
+       if (flags)
+               printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
+
+       return printed;
+}
+
+#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags
index d4b3d034c5031bdbf9a1dcc099812778f4e603c8..4db73d5a0dbc6bf421c57d50ff0db7560caff03f 100644 (file)
@@ -1138,7 +1138,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
 
        if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS &&
            !dso__is_kcore(dso)) {
-               char bf[BUILD_ID_SIZE * 2 + 16] = " with build id ";
+               char bf[SBUILD_ID_SIZE + 15] = " with build id ";
                char *build_id_msg = NULL;
 
                if (dso->annotate_warned)
index b6ecf87bc3e3c32dac43a0b3f521a72ff3e28ecd..bff425e1232cdcb99f362e1b7d5971e5d1121a23 100644 (file)
@@ -365,39 +365,17 @@ static char *build_id_cache__dirname_from_path(const char *name,
 int build_id_cache__list_build_ids(const char *pathname,
                                   struct strlist **result)
 {
-       struct strlist *list;
        char *dir_name;
-       DIR *dir;
-       struct dirent *d;
        int ret = 0;
 
-       list = strlist__new(NULL, NULL);
        dir_name = build_id_cache__dirname_from_path(pathname, false, false);
-       if (!list || !dir_name) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!dir_name)
+               return -ENOMEM;
 
-       /* List up all dirents */
-       dir = opendir(dir_name);
-       if (!dir) {
+       *result = lsdir(dir_name, lsdir_no_dot_filter);
+       if (!*result)
                ret = -errno;
-               goto out;
-       }
-
-       while ((d = readdir(dir)) != NULL) {
-               if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
-                       continue;
-               strlist__add(list, d->d_name);
-       }
-       closedir(dir);
-
-out:
        free(dir_name);
-       if (ret)
-               strlist__delete(list);
-       else
-               *result = list;
 
        return ret;
 }
index f8e3057ae3b1903ff7c15f605d0319486c957b30..8d96c80cc67e629f0ef576ae24c1266e468df91f 100644 (file)
@@ -260,8 +260,7 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
                if (!al->sym) {
                        al->sym = symbol__new(al->addr, 0, 0, "unknown");
                        if (al->sym)
-                               symbols__insert(&dso->symbols[al->map->type],
-                                               al->sym);
+                               dso__insert_symbol(dso, al->map->type, al->sym);
                }
 
                if (al->sym) {
@@ -325,10 +324,11 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
                al.sym = node->sym;
                al.map = node->map;
                al.machine = machine;
-               if (al.map)
-                       al.addr = al.map->map_ip(al.map, node->ip);
-               else
-                       al.addr = node->ip;
+               al.addr = node->ip;
+
+               if (al.map && !al.sym)
+                       al.sym = dso__find_symbol(al.map->dso, MAP__FUNCTION,
+                                                 al.addr);
 
                db_ids_from_al(dbe, &al, &dso_db_id, &sym_db_id, &offset);
 
index 8e6395439ca0830cefaaa5b6dbe905ae2af93011..3357479082ca95b9b6cfd4df5015a30b470214fe 100644 (file)
@@ -38,7 +38,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
                                   enum dso_binary_type type,
                                   char *root_dir, char *filename, size_t size)
 {
-       char build_id_hex[BUILD_ID_SIZE * 2 + 1];
+       char build_id_hex[SBUILD_ID_SIZE];
        int ret = 0;
        size_t len;
 
@@ -1301,7 +1301,7 @@ size_t __dsos__fprintf(struct list_head *head, FILE *fp)
 
 size_t dso__fprintf_buildid(struct dso *dso, FILE *fp)
 {
-       char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+       char sbuild_id[SBUILD_ID_SIZE];
 
        build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
        return fprintf(fp, "%s", sbuild_id);
index c6000d44f98c9848d8e3633dafb46ea3167f0cdd..08852dde1378696d24c47c0b34bded96b9d862e8 100644 (file)
@@ -1474,7 +1474,7 @@ static int __event_process_build_id(struct build_id_event *bev,
 
        dso = machine__findnew_dso(machine, filename);
        if (dso != NULL) {
-               char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+               char sbuild_id[SBUILD_ID_SIZE];
 
                dso__set_build_id(dso, &bev->build_id);
 
index 02c31865648b11aaf6569ce34014ce16f602e9f0..b19bcd3b7128355f67d93232b695966907a5e473 100644 (file)
@@ -289,7 +289,7 @@ int map__load(struct map *map, symbol_filter_t filter)
        nr = dso__load(map->dso, map, filter);
        if (nr < 0) {
                if (map->dso->has_build_id) {
-                       char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+                       char sbuild_id[SBUILD_ID_SIZE];
 
                        build_id__sprintf(map->dso->build_id,
                                          sizeof(map->dso->build_id),
index 1546b749a3a34af6ed4bb89d33a5d6ccbaada4af..ff134700bf30dfa1f3bf772220ebb681daf077b2 100644 (file)
@@ -408,8 +408,11 @@ static void python_process_tracepoint(struct perf_sample *sample,
        if (!t)
                Py_FatalError("couldn't create Python tuple");
 
-       if (!event)
-               die("ug! no event found for type %d", (int)evsel->attr.config);
+       if (!event) {
+               snprintf(handler_name, sizeof(handler_name),
+                        "ug! no event found for type %" PRIu64, (u64)evsel->attr.config);
+               Py_FatalError(handler_name);
+       }
 
        pid = raw_field_value(event, "common_pid", data);
 
@@ -615,7 +618,7 @@ static int python_export_dso(struct db_export *dbe, struct dso *dso,
                             struct machine *machine)
 {
        struct tables *tables = container_of(dbe, struct tables, dbe);
-       char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+       char sbuild_id[SBUILD_ID_SIZE];
        PyObject *t;
 
        build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
index 2946295ca5027d6e4d212df09f125cced2c25f96..7fb33304fb4ea66f1103c351b696a1e2b5e8bae8 100644 (file)
@@ -413,6 +413,18 @@ void dso__reset_find_symbol_cache(struct dso *dso)
        }
 }
 
+void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym)
+{
+       symbols__insert(&dso->symbols[type], sym);
+
+       /* update the symbol cache if necessary */
+       if (dso->last_find_result[type].addr >= sym->start &&
+           (dso->last_find_result[type].addr < sym->end ||
+           sym->start == sym->end)) {
+               dso->last_find_result[type].symbol = sym;
+       }
+}
+
 struct symbol *dso__find_symbol(struct dso *dso,
                                enum map_type type, u64 addr)
 {
@@ -1596,25 +1608,27 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
        return err;
 }
 
+static bool visible_dir_filter(const char *name, struct dirent *d)
+{
+       if (d->d_type != DT_DIR)
+               return false;
+       return lsdir_no_dot_filter(name, d);
+}
+
 static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
 {
        char kallsyms_filename[PATH_MAX];
-       struct dirent *dent;
        int ret = -1;
-       DIR *d;
+       struct strlist *dirs;
+       struct str_node *nd;
 
-       d = opendir(dir);
-       if (!d)
+       dirs = lsdir(dir, visible_dir_filter);
+       if (!dirs)
                return -1;
 
-       while (1) {
-               dent = readdir(d);
-               if (!dent)
-                       break;
-               if (dent->d_type != DT_DIR)
-                       continue;
+       strlist__for_each(nd, dirs) {
                scnprintf(kallsyms_filename, sizeof(kallsyms_filename),
-                         "%s/%s/kallsyms", dir, dent->d_name);
+                         "%s/%s/kallsyms", dir, nd->s);
                if (!validate_kcore_addresses(kallsyms_filename, map)) {
                        strlcpy(dir, kallsyms_filename, dir_sz);
                        ret = 0;
@@ -1622,7 +1636,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
                }
        }
 
-       closedir(d);
+       strlist__delete(dirs);
 
        return ret;
 }
@@ -1630,7 +1644,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
 static char *dso__find_kallsyms(struct dso *dso, struct map *map)
 {
        u8 host_build_id[BUILD_ID_SIZE];
-       char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+       char sbuild_id[SBUILD_ID_SIZE];
        bool is_host = false;
        char path[PATH_MAX];
 
index 07211c2f8456b409982532632726cb524c150ac1..2b5e4ed76fcb4b53c38ac74269e03317734bd699 100644 (file)
@@ -246,6 +246,9 @@ int __dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
 int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
                       symbol_filter_t filter);
 
+void dso__insert_symbol(struct dso *dso, enum map_type type,
+                       struct symbol *sym);
+
 struct symbol *dso__find_symbol(struct dso *dso, enum map_type type,
                                u64 addr);
 struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
index 01c9433de7ef5b53e1ce96c357e4f3d161d29af9..eab077ad6ca92f5fac2f570c3c96008203a980de 100644 (file)
@@ -139,7 +139,7 @@ struct strlist *lsdir(const char *name,
 
        list = strlist__new(NULL, NULL);
        if (!list) {
-               errno = -ENOMEM;
+               errno = ENOMEM;
                goto out;
        }