aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/util/symbol.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 5cc96c86861b..594f36a1da8f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -962,25 +962,6 @@ out:
962 return err; 962 return err;
963} 963}
964 964
965static char *dso__read_build_id(struct dso *self)
966{
967 int len;
968 char *build_id = NULL;
969 unsigned char rawbf[BUILD_ID_SIZE];
970
971 len = filename__read_build_id(self->long_name, rawbf, sizeof(rawbf));
972 if (len < 0)
973 goto out;
974
975 build_id = malloc(len * 2 + 1);
976 if (build_id == NULL)
977 goto out;
978
979 build_id__sprintf(rawbf, len, build_id);
980out:
981 return build_id;
982}
983
984char dso__symtab_origin(const struct dso *self) 965char dso__symtab_origin(const struct dso *self)
985{ 966{
986 static const char origin[] = { 967 static const char origin[] = {
@@ -1001,7 +982,8 @@ char dso__symtab_origin(const struct dso *self)
1001int dso__load(struct dso *self, struct map *map, symbol_filter_t filter) 982int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
1002{ 983{
1003 int size = PATH_MAX; 984 int size = PATH_MAX;
1004 char *name = malloc(size), *build_id = NULL; 985 char *name = malloc(size);
986 u8 build_id[BUILD_ID_SIZE];
1005 int ret = -1; 987 int ret = -1;
1006 int fd; 988 int fd;
1007 989
@@ -1023,8 +1005,6 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
1023 1005
1024more: 1006more:
1025 do { 1007 do {
1026 int berr = 0;
1027
1028 self->origin++; 1008 self->origin++;
1029 switch (self->origin) { 1009 switch (self->origin) {
1030 case DSO__ORIG_FEDORA: 1010 case DSO__ORIG_FEDORA:
@@ -1036,12 +1016,18 @@ more:
1036 self->long_name); 1016 self->long_name);
1037 break; 1017 break;
1038 case DSO__ORIG_BUILDID: 1018 case DSO__ORIG_BUILDID:
1039 build_id = dso__read_build_id(self); 1019 if (filename__read_build_id(self->long_name, build_id,
1040 if (build_id != NULL) { 1020 sizeof(build_id))) {
1021 char build_id_hex[BUILD_ID_SIZE * 2 + 1];
1022
1023 build_id__sprintf(build_id, sizeof(build_id),
1024 build_id_hex);
1041 snprintf(name, size, 1025 snprintf(name, size,
1042 "/usr/lib/debug/.build-id/%.2s/%s.debug", 1026 "/usr/lib/debug/.build-id/%.2s/%s.debug",
1043 build_id, build_id + 2); 1027 build_id_hex, build_id_hex + 2);
1044 goto compare_build_id; 1028 if (self->has_build_id)
1029 goto compare_build_id;
1030 break;
1045 } 1031 }
1046 self->origin++; 1032 self->origin++;
1047 /* Fall thru */ 1033 /* Fall thru */
@@ -1054,18 +1040,12 @@ more:
1054 } 1040 }
1055 1041
1056 if (self->has_build_id) { 1042 if (self->has_build_id) {
1057 bool match; 1043 if (filename__read_build_id(name, build_id,
1058 build_id = malloc(BUILD_ID_SIZE); 1044 sizeof(build_id)) < 0)
1059 if (build_id == NULL)
1060 goto more; 1045 goto more;
1061 berr = filename__read_build_id(name, build_id,
1062 BUILD_ID_SIZE);
1063compare_build_id: 1046compare_build_id:
1064 match = berr > 0 && memcmp(build_id, self->build_id, 1047 if (memcmp(build_id, self->build_id,
1065 sizeof(self->build_id)) == 0; 1048 sizeof(self->build_id)) != 0)
1066 free(build_id);
1067 build_id = NULL;
1068 if (!match)
1069 goto more; 1049 goto more;
1070 } 1050 }
1071 1051