diff options
author | Ingo Molnar <mingo@kernel.org> | 2016-08-24 05:08:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2016-08-24 05:08:10 -0400 |
commit | 36e674a05164cdbb9d4a5b1b0b279fabae6c13bd (patch) | |
tree | b00a7ae974277eaed48eebd8287ca32fcaae26fe /tools/perf/util/annotate.c | |
parent | b6a32f023fcc9cbd1602f78a467fd8d41bbc9457 (diff) | |
parent | 5e30d55c71de058e4156080fe32d426c22d094cb (diff) |
Merge tag 'perf-core-for-mingo-20160823' 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:
. Allow configuring the default 'perf report -s' sort order in ~/.perfconfig,
for instance, "sym,dso" may be more fitting for kernel developers. (Arnaldo Carvalho de Melo)
- Support x8/x16/x32/x64 hexadecimal "types" in ftrace and 'perf probe' (Masami Hiramatsu)
Infrastructure changes:
- Skip running the feature tests for 'make install-doc' (Rui Teng)
- Introduce tools/include/linux/time64.h with *SEC_PER_*SEC macros
to use in all of tools/ (Arnaldo Carvalho de Melo)
- Break down symbol__disassemble() into multiple functions, to ease
future work on better reporting the errors that may take place in
the various steps it performs (possibly decompressing kernel module
files, getting build-id keyed files, calling objdump, parsing its
output, etc) (Arnaldo Carvalho de Melo)
- Typo fixes in various places (Colin Ian King)
- Remove superfluous NULL check in the TUI code (Colin Ian King)
- Allow displaying multiple header lines in the TUI browser, prep
work for the 'perf c2c' browser (Jiri Olsa)
- Copy coresight-pmu.h header file needed by perf tools (Mathieu Poirier)
- Use __weak definition from linux/compiler.h (Rui Teng)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r-- | tools/perf/util/annotate.c | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 4024d309bb00..25a9259a6a6e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1162,53 +1162,60 @@ 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 = dso__build_id_filename(dso, NULL, 0); | 1168 | char *build_id_filename; |
1169 | bool free_filename = true; | ||
1170 | char command[PATH_MAX * 2]; | ||
1171 | FILE *file; | ||
1172 | int err = 0; | ||
1173 | char symfs_filename[PATH_MAX]; | ||
1174 | struct kcore_extract kce; | ||
1175 | bool delete_extract = false; | ||
1176 | int stdout_fd[2]; | ||
1177 | int lineno = 0; | ||
1178 | int nline; | ||
1179 | pid_t pid; | ||
1180 | 1169 | ||
1181 | if (filename) | 1170 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && |
1182 | symbol__join_symfs(symfs_filename, filename); | 1171 | !dso__is_kcore(dso)) |
1172 | return SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX; | ||
1183 | 1173 | ||
1184 | if (filename == NULL) { | 1174 | build_id_filename = dso__build_id_filename(dso, NULL, 0); |
1175 | if (build_id_filename) { | ||
1176 | __symbol__join_symfs(filename, filename_size, build_id_filename); | ||
1177 | free(build_id_filename); | ||
1178 | } else { | ||
1185 | if (dso->has_build_id) | 1179 | if (dso->has_build_id) |
1186 | return ENOMEM; | 1180 | return ENOMEM; |
1187 | goto fallback; | 1181 | goto fallback; |
1188 | } else if (dso__is_kcore(dso) || | 1182 | } |
1189 | readlink(symfs_filename, command, sizeof(command)) < 0 || | 1183 | |
1190 | strstr(command, DSO__NAME_KALLSYMS) || | 1184 | if (dso__is_kcore(dso) || |
1191 | access(symfs_filename, R_OK)) { | 1185 | readlink(filename, linkname, sizeof(linkname)) < 0 || |
1192 | free(filename); | 1186 | strstr(linkname, DSO__NAME_KALLSYMS) || |
1187 | access(filename, R_OK)) { | ||
1193 | fallback: | 1188 | fallback: |
1194 | /* | 1189 | /* |
1195 | * 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 |
1196 | * 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 |
1197 | * DSO is the same as when 'perf record' ran. | 1192 | * DSO is the same as when 'perf record' ran. |
1198 | */ | 1193 | */ |
1199 | filename = (char *)dso->long_name; | 1194 | __symbol__join_symfs(filename, filename_size, dso->long_name); |
1200 | symbol__join_symfs(symfs_filename, filename); | ||
1201 | free_filename = false; | ||
1202 | } | 1195 | } |
1203 | 1196 | ||
1204 | if (dso->symtab_type == DSO_BINARY_TYPE__KALLSYMS && | 1197 | return 0; |
1205 | !dso__is_kcore(dso)) { | 1198 | } |
1206 | err = SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX; | 1199 | |
1207 | goto out_free_filename; | 1200 | int symbol__disassemble(struct symbol *sym, struct map *map, size_t privsize) |
1208 | } | 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; | ||
1209 | 1216 | ||
1210 | 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__, |
1211 | filename, sym->name, map->unmap_ip(map, sym->start), | 1218 | symfs_filename, sym->name, map->unmap_ip(map, sym->start), |
1212 | map->unmap_ip(map, sym->end)); | 1219 | map->unmap_ip(map, sym->end)); |
1213 | 1220 | ||
1214 | pr_debug("annotating [%p] %30s : [%p] %30s\n", | 1221 | pr_debug("annotating [%p] %30s : [%p] %30s\n", |
@@ -1223,11 +1230,6 @@ fallback: | |||
1223 | delete_extract = true; | 1230 | delete_extract = true; |
1224 | strlcpy(symfs_filename, kce.extract_filename, | 1231 | strlcpy(symfs_filename, kce.extract_filename, |
1225 | sizeof(symfs_filename)); | 1232 | sizeof(symfs_filename)); |
1226 | if (free_filename) { | ||
1227 | free(filename); | ||
1228 | free_filename = false; | ||
1229 | } | ||
1230 | filename = symfs_filename; | ||
1231 | } | 1233 | } |
1232 | } else if (dso__needs_decompress(dso)) { | 1234 | } else if (dso__needs_decompress(dso)) { |
1233 | char tmp[PATH_MAX]; | 1235 | char tmp[PATH_MAX]; |
@@ -1236,14 +1238,14 @@ fallback: | |||
1236 | bool ret; | 1238 | bool ret; |
1237 | 1239 | ||
1238 | if (kmod_path__parse_ext(&m, symfs_filename)) | 1240 | if (kmod_path__parse_ext(&m, symfs_filename)) |
1239 | goto out_free_filename; | 1241 | goto out; |
1240 | 1242 | ||
1241 | snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX"); | 1243 | snprintf(tmp, PATH_MAX, "/tmp/perf-kmod-XXXXXX"); |
1242 | 1244 | ||
1243 | fd = mkstemp(tmp); | 1245 | fd = mkstemp(tmp); |
1244 | if (fd < 0) { | 1246 | if (fd < 0) { |
1245 | free(m.ext); | 1247 | free(m.ext); |
1246 | goto out_free_filename; | 1248 | goto out; |
1247 | } | 1249 | } |
1248 | 1250 | ||
1249 | ret = decompress_to_file(m.ext, symfs_filename, fd); | 1251 | ret = decompress_to_file(m.ext, symfs_filename, fd); |
@@ -1255,7 +1257,7 @@ fallback: | |||
1255 | close(fd); | 1257 | close(fd); |
1256 | 1258 | ||
1257 | if (!ret) | 1259 | if (!ret) |
1258 | goto out_free_filename; | 1260 | goto out; |
1259 | 1261 | ||
1260 | strcpy(symfs_filename, tmp); | 1262 | strcpy(symfs_filename, tmp); |
1261 | } | 1263 | } |
@@ -1271,7 +1273,7 @@ fallback: | |||
1271 | map__rip_2objdump(map, sym->end), | 1273 | map__rip_2objdump(map, sym->end), |
1272 | symbol_conf.annotate_asm_raw ? "" : "--no-show-raw", | 1274 | symbol_conf.annotate_asm_raw ? "" : "--no-show-raw", |
1273 | symbol_conf.annotate_src ? "-S" : "", | 1275 | symbol_conf.annotate_src ? "-S" : "", |
1274 | symfs_filename, filename); | 1276 | symfs_filename, symfs_filename); |
1275 | 1277 | ||
1276 | pr_debug("Executing: %s\n", command); | 1278 | pr_debug("Executing: %s\n", command); |
1277 | 1279 | ||
@@ -1333,11 +1335,10 @@ out_remove_tmp: | |||
1333 | 1335 | ||
1334 | if (dso__needs_decompress(dso)) | 1336 | if (dso__needs_decompress(dso)) |
1335 | unlink(symfs_filename); | 1337 | unlink(symfs_filename); |
1336 | out_free_filename: | 1338 | |
1337 | if (delete_extract) | 1339 | if (delete_extract) |
1338 | kcore_extract__delete(&kce); | 1340 | kcore_extract__delete(&kce); |
1339 | if (free_filename) | 1341 | out: |
1340 | free(filename); | ||
1341 | return err; | 1342 | return err; |
1342 | 1343 | ||
1343 | out_close_stdout: | 1344 | out_close_stdout: |