aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2017-10-11 11:01:29 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-11-13 07:39:58 -0500
commitea07c5aaed33d23875cd59da8b0892f76e882ccd (patch)
treeaf9d639cad713187af274c7636a2e0ec03b3b349
parentc34df25b40c20b478634b954a709749aebdc241a (diff)
perf annotate: Add struct annotate_args
Adding struct annotate_args to reduce the number of arguments, that need to travel all the way to line allocation. This makes the code easier to read and ease up the changes for following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20171011150158.11895-7-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/annotate.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index f0093918882d..f5bd6826fa66 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -878,12 +878,17 @@ out_free_name:
878 return -1; 878 return -1;
879} 879}
880 880
881static struct disasm_line *disasm_line__new(s64 offset, char *line, 881struct annotate_args {
882 size_t privsize, int line_nr, 882 size_t privsize;
883};
884
885static struct disasm_line *disasm_line__new(struct annotate_args *args,
886 s64 offset, char *line,
887 int line_nr,
883 struct arch *arch, 888 struct arch *arch,
884 struct map *map) 889 struct map *map)
885{ 890{
886 struct disasm_line *dl = zalloc(sizeof(*dl) + privsize); 891 struct disasm_line *dl = zalloc(sizeof(*dl) + args->privsize);
887 892
888 if (dl != NULL) { 893 if (dl != NULL) {
889 dl->al.offset = offset; 894 dl->al.offset = offset;
@@ -1217,8 +1222,8 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
1217 * The ops.raw part will be parsed further according to type of the instruction. 1222 * The ops.raw part will be parsed further according to type of the instruction.
1218 */ 1223 */
1219static int symbol__parse_objdump_line(struct symbol *sym, struct map *map, 1224static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
1220 struct arch *arch, 1225 struct arch *arch, FILE *file,
1221 FILE *file, size_t privsize, 1226 struct annotate_args *args,
1222 int *line_nr) 1227 int *line_nr)
1223{ 1228{
1224 struct annotation *notes = symbol__annotation(sym); 1229 struct annotation *notes = symbol__annotation(sym);
@@ -1264,7 +1269,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
1264 parsed_line = tmp2 + 1; 1269 parsed_line = tmp2 + 1;
1265 } 1270 }
1266 1271
1267 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr, arch, map); 1272 dl = disasm_line__new(args, offset, parsed_line, *line_nr, arch, map);
1268 free(line); 1273 free(line);
1269 (*line_nr)++; 1274 (*line_nr)++;
1270 1275
@@ -1426,7 +1431,8 @@ static const char *annotate__norm_arch(const char *arch_name)
1426} 1431}
1427 1432
1428static int symbol__disassemble(struct symbol *sym, struct map *map, 1433static int symbol__disassemble(struct symbol *sym, struct map *map,
1429 size_t privsize, struct arch *arch) 1434 struct annotate_args *args,
1435 struct arch *arch)
1430{ 1436{
1431 struct dso *dso = map->dso; 1437 struct dso *dso = map->dso;
1432 char command[PATH_MAX * 2]; 1438 char command[PATH_MAX * 2];
@@ -1526,7 +1532,7 @@ static int symbol__disassemble(struct symbol *sym, struct map *map,
1526 * can associate it with the instructions till the next one. 1532 * can associate it with the instructions till the next one.
1527 * See disasm_line__new() and struct disasm_line::line_nr. 1533 * See disasm_line__new() and struct disasm_line::line_nr.
1528 */ 1534 */
1529 if (symbol__parse_objdump_line(sym, map, arch, file, privsize, 1535 if (symbol__parse_objdump_line(sym, map, arch, file, args,
1530 &lineno) < 0) 1536 &lineno) < 0)
1531 break; 1537 break;
1532 nline++; 1538 nline++;
@@ -1564,6 +1570,9 @@ int symbol__annotate(struct symbol *sym, struct map *map,
1564 const char *arch_name, size_t privsize, 1570 const char *arch_name, size_t privsize,
1565 struct arch **parch, char *cpuid) 1571 struct arch **parch, char *cpuid)
1566{ 1572{
1573 struct annotate_args args = {
1574 .privsize = privsize,
1575 };
1567 struct arch *arch; 1576 struct arch *arch;
1568 int err; 1577 int err;
1569 1578
@@ -1586,7 +1595,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,
1586 } 1595 }
1587 } 1596 }
1588 1597
1589 return symbol__disassemble(sym, map, privsize, arch); 1598 return symbol__disassemble(sym, map, &args, arch);
1590} 1599}
1591 1600
1592static void insert_source_line(struct rb_root *root, struct source_line *src_line) 1601static void insert_source_line(struct rb_root *root, struct source_line *src_line)