Skip to content

Commit

Permalink
perf annotate: Inform the user about objdump failures in --stdio
Browse files Browse the repository at this point in the history
When the browser fails to annotate it is difficult for users to find out
what went wrong.

Add some errors for objdump failures that are displayed in the UI.

Note it would be even better to handle these errors smarter, like
falling back to the binary when the debug info is somehow corrupted. But
for now just giving a better error is an improvement.

Committer note:

This works for --stdio, where errors just scroll by the screen:

  # perf annotate --stdio intel_idle
  Failure running objdump  --start-address=0xffffffff81418290 --stop-address=0xffffffff814183ae -l -d --no-show-raw -S -C /root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1 2>/dev/null|grep -v /root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1|expand
   Percent |      Source code & Disassembly of vmlinux for cycles:pp
  ------------------------------------------------------------------

And with that one can use that command line to try to find out more about what
happened instead of getting a blank screen, an improvement.

We need tho to improve this further to get it to work with other UIs, like
--tui and --gtk, where it continues showing a blank screen, no messages, as
the pr_err() used is enough just for --stdio.

Signed-off-by: Andi Kleen <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
Andi Kleen authored and acmel committed Nov 6, 2015
1 parent e054731 commit 62ec9b3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
@@ -1084,6 +1084,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
struct kcore_extract kce;
bool delete_extract = false;
int lineno = 0;
int nline;

if (filename)
symbol__join_symfs(symfs_filename, filename);
@@ -1179,6 +1180,9 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)

ret = decompress_to_file(m.ext, symfs_filename, fd);

if (ret)
pr_err("Cannot decompress %s %s\n", m.ext, symfs_filename);

free(m.ext);
close(fd);

@@ -1204,13 +1208,25 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
pr_debug("Executing: %s\n", command);

file = popen(command, "r");
if (!file)
if (!file) {
pr_err("Failure running %s\n", command);
/*
* If we were using debug info should retry with
* original binary.
*/
goto out_remove_tmp;
}

while (!feof(file))
nline = 0;
while (!feof(file)) {
if (symbol__parse_objdump_line(sym, map, file, privsize,
&lineno) < 0)
break;
nline++;
}

if (nline == 0)
pr_err("No output from %s\n", command);

/*
* kallsyms does not have symbol sizes so there may a nop at the end.

0 comments on commit 62ec9b3

Please sign in to comment.