diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-08-09 14:32:53 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-08-23 14:37:33 -0400 |
commit | 05ed3ac9417dac9be9dd63f3cf97416c80bad359 (patch) | |
tree | a16b0a037a6db880dcea62765a7b666e79e2cb4b /tools/perf/util/annotate.c | |
parent | 3caee094d160b0ef92988099105e9a173a3805b0 (diff) |
perf disassemble: Extract logic to find file to pass to objdump to a separate function
Disentangling this a bit further, more to come.
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: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-7bjv2xazuyzs0xw01mlwosn5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 8a9949399112..25a9259a6a6e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1162,29 +1162,19 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map * | |||
1162 | return 0; | 1162 | return 0; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) | 1165 | static int dso__disassemble_filename(struct dso *dso, char *filename, size_t filename_size) |
1166 | { | 1166 | { |
1167 | struct dso *dso = map->dso; | 1167 | char linkname[PATH_MAX]; |
1168 | char *filename; | 1168 | char *build_id_filename; |
1169 | char command[PATH_MAX * 2]; | ||
1170 | FILE *file; | ||
1171 | char symfs_filename[PATH_MAX]; | ||
1172 | struct kcore_extract kce; | ||
1173 | bool delete_extract = false; | ||
1174 | int stdout_fd[2]; | ||
1175 | int lineno = 0; | ||
1176 | int nline; | ||
1177 | pid_t pid; | ||
1178 | int err = SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX; | ||
1179 | 1169 | ||
1180 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && | 1170 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && |
1181 | !dso__is_kcore(dso)) | 1171 | !dso__is_kcore(dso)) |
1182 | goto out; | 1172 | return SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX; |
1183 | 1173 | ||
1184 | filename = dso__build_id_filename(dso, NULL, 0); | 1174 | build_id_filename = dso__build_id_filename(dso, NULL, 0); |
1185 | if (filename) { | 1175 | if (build_id_filename) { |
1186 | symbol__join_symfs(symfs_filename, filename); | 1176 | __symbol__join_symfs(filename, filename_size, build_id_filename); |
1187 | free(filename); | 1177 | free(build_id_filename); |
1188 | } else { | 1178 | } else { |
1189 | if (dso->has_build_id) | 1179 | if (dso->has_build_id) |
1190 | return ENOMEM; | 1180 | return ENOMEM; |
@@ -1192,18 +1182,38 @@ int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) | |||
1192 | } | 1182 | } |
1193 | 1183 | ||
1194 | if (dso__is_kcore(dso) || | 1184 | if (dso__is_kcore(dso) || |
1195 | readlink(symfs_filename, command, sizeof(command)) < 0 || | 1185 | readlink(filename, linkname, sizeof(linkname)) < 0 || |
1196 | strstr(command, DSO__NAME_KALLSYMS) || | 1186 | strstr(linkname, DSO__NAME_KALLSYMS) || |
1197 | access(symfs_filename, R_OK)) { | 1187 | access(filename, R_OK)) { |
1198 | fallback: | 1188 | fallback: |
1199 | /* | 1189 | /* |
1200 | * If we don't have build-ids or the build-id file isn't in the | 1190 | * If we don't have build-ids or the build-id file isn't in the |
1201 | * cache, or is just a kallsyms file, well, lets hope that this | 1191 | * cache, or is just a kallsyms file, well, lets hope that this |
1202 | * DSO is the same as when 'perf record' ran. | 1192 | * DSO is the same as when 'perf record' ran. |
1203 | */ | 1193 | */ |
1204 | symbol__join_symfs(symfs_filename, dso->long_name); | 1194 | __symbol__join_symfs(filename, filename_size, dso->long_name); |
1205 | } | 1195 | } |
1206 | 1196 | ||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) | ||
1201 | { | ||
1202 | struct dso *dso = map->dso; | ||
1203 | char command[PATH_MAX * 2]; | ||
1204 | FILE *file; | ||
1205 | char symfs_filename[PATH_MAX]; | ||
1206 | struct kcore_extract kce; | ||
1207 | bool delete_extract = false; | ||
1208 | int stdout_fd[2]; | ||
1209 | int lineno = 0; | ||
1210 | int nline; | ||
1211 | pid_t pid; | ||
1212 | int err = dso__disassemble_filename(dso, symfs_filename, sizeof(symfs_filename)); | ||
1213 | |||
1214 | if (err) | ||
1215 | return err; | ||
1216 | |||
1207 | pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, | 1217 | pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__, |
1208 | symfs_filename, sym->name, map->unmap_ip(map, sym->start), | 1218 | symfs_filename, sym->name, map->unmap_ip(map, sym->start), |
1209 | map->unmap_ip(map, sym->end)); | 1219 | map->unmap_ip(map, sym->end)); |