* [PATCH] perfcounters: Fixes for filename:line displays
@ 2009-06-13 15:39 Frederic Weisbecker
2009-06-13 15:54 ` [tip:perfcounters/core] perf annotate: " tip-bot for Frederic Weisbecker
0 siblings, 1 reply; 2+ messages in thread
From: Frederic Weisbecker @ 2009-06-13 15:39 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Peter Zijlstra, Mike Galbraith, Paul Mackerras,
Frederic Weisbecker
- 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>
---
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 7a5b278..94cea67 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)
if (offset < len)
hits = sym->hist[offset];
- if (sym_ext) {
+ if (offset < len && sym_ext) {
path = sym_ext[offset].path;
percent = sym_ext[offset].percent;
} else if (sym->hist_sum)
@@ -1190,7 +1190,8 @@ static void free_source_line(struct symbol *sym, int len)
}
/* 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;
char cmd[PATH_MAX * 2];
@@ -1216,7 +1217,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len)
continue;
offset = start + i;
- sprintf(cmd, "addr2line -e %s %016llx", vmlinux, offset);
+ sprintf(cmd, "addr2line -e %s %016llx", filename, offset);
fp = popen(cmd, "r");
if (!fp)
continue;
@@ -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)
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)
goto next;
@@ -1285,7 +1286,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
len = sym->end - sym->start;
if (print_line) {
- get_source_line(sym, start, len);
+ get_source_line(sym, start, len, filename);
print_summary(filename);
}
--
1.6.2.3
^ permalink raw reply [flat|nested] 2+ messages in thread* [tip:perfcounters/core] perf annotate: Fixes for filename:line displays
2009-06-13 15:39 [PATCH] perfcounters: Fixes for filename:line displays Frederic Weisbecker
@ 2009-06-13 15:54 ` tip-bot for Frederic Weisbecker
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2009-06-13 15:54 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, paulus, hpa, mingo, a.p.zijlstra, efault, fweisbec,
tglx, mingo
Commit-ID: c17c2db1f3cea41c3543025905d3582c6937dd95
Gitweb: http://git.kernel.org/tip/c17c2db1f3cea41c3543025905d3582c6937dd95
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Sat, 13 Jun 2009 17:39:23 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sat, 13 Jun 2009 17:51:00 +0200
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>
---
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 7a5b278..94cea67 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)
if (offset < len)
hits = sym->hist[offset];
- if (sym_ext) {
+ if (offset < len && sym_ext) {
path = sym_ext[offset].path;
percent = sym_ext[offset].percent;
} else if (sym->hist_sum)
@@ -1190,7 +1190,8 @@ static void free_source_line(struct symbol *sym, int len)
}
/* 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;
char cmd[PATH_MAX * 2];
@@ -1216,7 +1217,7 @@ static void get_source_line(struct symbol *sym, __u64 start, int len)
continue;
offset = start + i;
- sprintf(cmd, "addr2line -e %s %016llx", vmlinux, offset);
+ sprintf(cmd, "addr2line -e %s %016llx", filename, offset);
fp = popen(cmd, "r");
if (!fp)
continue;
@@ -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)
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)
goto next;
@@ -1285,7 +1286,7 @@ static void annotate_sym(struct dso *dso, struct symbol *sym)
len = sym->end - sym->start;
if (print_line) {
- get_source_line(sym, start, len);
+ get_source_line(sym, start, len, filename);
print_summary(filename);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-13 15:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-13 15:39 [PATCH] perfcounters: Fixes for filename:line displays Frederic Weisbecker
2009-06-13 15:54 ` [tip:perfcounters/core] perf annotate: " tip-bot for Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome