aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r--tools/perf/builtin-annotate.c11
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 */
1193static void get_source_line(struct symbol *sym, __u64 start, int len) 1193static void
1194get_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