[PATCH 08/35] perf annotate: Add map into struct annotate_args
From: Jiri Olsa
Date: Wed Oct 11 2017 - 11:02:22 EST
Adding map into struct annotate_args to reduce the number of
arguments that need to travel all the way to line allocation.
Link: http://lkml.kernel.org/n/tip-rq3z2ixworigen4vm2h3mdqo@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/annotate.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c814c33a987e..0f95a308db9b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -871,12 +871,12 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
struct annotate_args {
size_t privsize;
struct arch *arch;
+ struct map *map;
};
static struct disasm_line *disasm_line__new(struct annotate_args *args,
s64 offset, char *line,
- int line_nr,
- struct map *map)
+ int line_nr)
{
struct disasm_line *dl = zalloc(sizeof(*dl) + args->privsize);
@@ -892,7 +892,7 @@ static struct disasm_line *disasm_line__new(struct annotate_args *args,
if (disasm_line__parse(dl->al.line, &dl->ins.name, &dl->ops.raw) < 0)
goto out_free_line;
- disasm_line__init_ins(dl, args->arch, map);
+ disasm_line__init_ins(dl, args->arch, args->map);
}
}
@@ -1211,11 +1211,11 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
* means that it's not a disassembly line so should be treated differently.
* The ops.raw part will be parsed further according to type of the instruction.
*/
-static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
- FILE *file,
+static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
struct annotate_args *args,
int *line_nr)
{
+ struct map *map = args->map;
struct annotation *notes = symbol__annotation(sym);
struct disasm_line *dl;
char *line = NULL, *parsed_line, *tmp, *tmp2;
@@ -1259,7 +1259,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
parsed_line = tmp2 + 1;
}
- dl = disasm_line__new(args, offset, parsed_line, *line_nr, map);
+ dl = disasm_line__new(args, offset, parsed_line, *line_nr);
free(line);
(*line_nr)++;
@@ -1420,9 +1420,9 @@ static const char *annotate__norm_arch(const char *arch_name)
return normalize_arch((char *)arch_name);
}
-static int symbol__disassemble(struct symbol *sym, struct map *map,
- struct annotate_args *args)
+static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
{
+ struct map *map = args->map;
struct dso *dso = map->dso;
char command[PATH_MAX * 2];
FILE *file;
@@ -1521,8 +1521,7 @@ static int symbol__disassemble(struct symbol *sym, struct map *map,
* can associate it with the instructions till the next one.
* See disasm_line__new() and struct disasm_line::line_nr.
*/
- if (symbol__parse_objdump_line(sym, map, file, args,
- &lineno) < 0)
+ if (symbol__parse_objdump_line(sym, file, args, &lineno) < 0)
break;
nline++;
}
@@ -1561,6 +1560,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,
{
struct annotate_args args = {
.privsize = privsize,
+ .map = map,
};
struct arch *arch;
int err;
@@ -1584,7 +1584,7 @@ int symbol__annotate(struct symbol *sym, struct map *map,
}
}
- return symbol__disassemble(sym, map, &args);
+ return symbol__disassemble(sym, &args);
}
static void insert_source_line(struct rb_root *root, struct source_line *src_line)
--
2.13.6