Skip to contentSkip to conversation

perf annotate: Allow arches to have a init routine and a priv area

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Nov 25, 2016 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  0781ea923445405a45464842e9ee0e30f76cb84b
Gitweb:     http://git.kernel.org/tip/0781ea923445405a45464842e9ee0e30f76cb84b
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Fri, 18 Nov 2016 12:34:26 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 25 Nov 2016 10:38:55 -0300

perf annotate: Allow arches to have a init routine and a priv area

Arches like ARM will want to use regular expressions when deciding what instructions to associate with what ins_ops, provide infrastructure for that.

Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Chris Riyder <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kim Phillips <[email protected]>
Cc Markus Trippelsdorf <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Naveen N. Rao <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Russell King <[email protected]>
Cc Taeung Song <[email protected]>
Cc Wang Nan <[email protected]>
---
 tools/perf/util/annotate.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/perf/util/annotate.c +11 -0
index 026915a..1e96549 100644
@@ -39,6 +39,9 @@ struct arch {
 	size_t		nr_instructions_allocated;
 	struct ins_ops  *(*associate_instruction_ops)(struct arch *arch, const char *name);
 	bool		sorted_instructions;
+	bool		initialized;
+	void		*priv;
+	int		(*init)(struct arch *arch);
 	struct		{
 		char comment_char;
 		char skip_functions_char;
@@ -1356,6 +1359,14 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na
 	if (arch == NULL)
 		return -ENOTSUP;
 
+	if (arch->init) {
+		err = arch->init(arch);
+		if (err) {
+			pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name);
+			return err;
+		}
+	}
+
 	pr_debug("%s: filename=%s, sym=%s, start=%#" PRIx64 ", end=%#" PRIx64 "\n", __func__,
 		 symfs_filename, sym->name, map->unmap_ip(map, sym->start),
 		 map->unmap_ip(map, sym->end));