diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-06-13 11:39:23 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-13 11:51:00 -0400 |
commit | c17c2db1f3cea41c3543025905d3582c6937dd95 (patch) | |
tree | a795e310e24c7d07a6ea279c1b2332ee80b5b797 /tools | |
parent | ef281a196d66b8bc2d067a3704712e5b93691fbc (diff) |
perf annotate: Fixes for filename:line displays
- fix addr2line on userspace binary: don't only check kernel image.
- fix string allocation size for path: missing ending null char room
- fix overflow in symbol extra info
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1244907563-7820-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-annotate.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 7a5b27867a96..94cea678fd7e 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -1116,7 +1116,7 @@ parse_line(FILE *file, struct symbol *sym, __u64 start, __u64 len) | |||
1116 | if (offset < len) | 1116 | if (offset < len) |
1117 | hits = sym->hist[offset]; | 1117 | hits = sym->hist[offset]; |
1118 | 1118 | ||
1119 | if (sym_ext) { | 1119 | if (offset < len && sym_ext) { |
1120 | path = sym_ext[offset].path; | 1120 | path = sym_ext[offset].path; |
1121 | percent = sym_ext[offset].percent; | 1121 | percent = sym_ext[offset].percent; |
1122 | } else if (sym->hist_sum) | 1122 | } else if (sym->hist_sum) |
@@ -1190,7 +1190,8 @@ static void free_source_line(struct symbol *sym, int len) | |||
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | /* Get the filename:line for the colored entries */ | 1192 | /* Get the filename:line for the colored entries */ |
1193 | static void get_source_line(struct symbol *sym, __u64 start, int len) | 1193 | static void |
1194 | get_source_line(struct symbol *sym, __u64 start, int len, char *filename) | ||
1194 | { | 1195 | { |
1195 | int i; | 1196 | int i; |
1196 | char cmd[PATH_MAX * 2]; | 1197 | char cmd[PATH_MAX * 2]; |
@@ -1216,7 +1217,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len) | |||
1216 | continue; | 1217 | continue; |
1217 | 1218 | ||
1218 | offset = start + i; | 1219 | offset = start + i; |
1219 | sprintf(cmd, "addr2line -e %s %016llx", vmlinux, offset); | 1220 | sprintf(cmd, "addr2line -e %s %016llx", filename, offset); |
1220 | fp = popen(cmd, "r"); | 1221 | fp = popen(cmd, "r"); |
1221 | if (!fp) | 1222 | if (!fp) |
1222 | continue; | 1223 | continue; |
@@ -1224,7 +1225,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len) | |||
1224 | if (getline(&path, &line_len, fp) < 0 || !line_len) | 1225 | if (getline(&path, &line_len, fp) < 0 || !line_len) |
1225 | goto next; | 1226 | goto next; |
1226 | 1227 | ||
1227 | sym_ext[i].path = malloc(sizeof(char) * line_len); | 1228 | sym_ext[i].path = malloc(sizeof(char) * line_len + 1); |
1228 | if (!sym_ext[i].path) | 1229 | if (!sym_ext[i].path) |
1229 | goto next; | 1230 | goto next; |
1230 | 1231 | ||
@@ -1285,7 +1286,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym) | |||
1285 | len = sym->end - sym->start; | 1286 | len = sym->end - sym->start; |
1286 | 1287 | ||
1287 | if (print_line) { | 1288 | if (print_line) { |
1288 | get_source_line(sym, start, len); | 1289 | get_source_line(sym, start, len, filename); |
1289 | print_summary(filename); | 1290 | print_summary(filename); |
1290 | } | 1291 | } |
1291 | 1292 | ||