Commit c17c2db1 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar

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: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarFrederic 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: default avatarIngo Molnar <mingo@elte.hu>
parent ef281a19
...@@ -1116,7 +1116,7 @@ parse_line(FILE *file, struct symbol *sym, __u64 start, __u64 len) ...@@ -1116,7 +1116,7 @@ parse_line(FILE *file, struct symbol *sym, __u64 start, __u64 len)
if (offset < len) if (offset < len)
hits = sym->hist[offset]; hits = sym->hist[offset];
if (sym_ext) { if (offset < len && sym_ext) {
path = sym_ext[offset].path; path = sym_ext[offset].path;
percent = sym_ext[offset].percent; percent = sym_ext[offset].percent;
} else if (sym->hist_sum) } else if (sym->hist_sum)
...@@ -1190,7 +1190,8 @@ static void free_source_line(struct symbol *sym, int len) ...@@ -1190,7 +1190,8 @@ static void free_source_line(struct symbol *sym, int len)
} }
/* Get the filename:line for the colored entries */ /* Get the filename:line for the colored entries */
static void get_source_line(struct symbol *sym, __u64 start, int len) static void
get_source_line(struct symbol *sym, __u64 start, int len, char *filename)
{ {
int i; int i;
char cmd[PATH_MAX * 2]; char cmd[PATH_MAX * 2];
...@@ -1216,7 +1217,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len) ...@@ -1216,7 +1217,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len)
continue; continue;
offset = start + i; offset = start + i;
sprintf(cmd, "addr2line -e %s %016llx", vmlinux, offset); sprintf(cmd, "addr2line -e %s %016llx", filename, offset);
fp = popen(cmd, "r"); fp = popen(cmd, "r");
if (!fp) if (!fp)
continue; continue;
...@@ -1224,7 +1225,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len) ...@@ -1224,7 +1225,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len)
if (getline(&path, &line_len, fp) < 0 || !line_len) if (getline(&path, &line_len, fp) < 0 || !line_len)
goto next; goto next;
sym_ext[i].path = malloc(sizeof(char) * line_len); sym_ext[i].path = malloc(sizeof(char) * line_len + 1);
if (!sym_ext[i].path) if (!sym_ext[i].path)
goto next; goto next;
...@@ -1285,7 +1286,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym) ...@@ -1285,7 +1286,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
len = sym->end - sym->start; len = sym->end - sym->start;
if (print_line) { if (print_line) {
get_source_line(sym, start, len); get_source_line(sym, start, len, filename);
print_summary(filename); print_summary(filename);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment