linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 38/44] perf annotate: Pass function descriptor to its instruction parsing routines
Date: Sat, 24 Mar 2018 17:02:05 -0300	[thread overview]
Message-ID: <20180324200211.21326-39-acme@kernel.org> (raw)
In-Reply-To: <20180324200211.21326-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

We need that to figure out if jumps have targets in a different
function.

E.g. _cpp_lex_token(), in /usr/libexec/gcc/x86_64-redhat-linux/5.3.1/cc1
has a line like this:

  jne    c469be <cpp_named_operator2name@@Base+0xa72>

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-ris0ioziyp469pofpzix2atb@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/arch/s390/annotate/instructions.c |  5 +++--
 tools/perf/util/annotate.c                   | 30 ++++++++++++++++------------
 tools/perf/util/annotate.h                   |  2 +-
 3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c
index 46c21831f2ac..cee4e2f7c057 100644
--- a/tools/perf/arch/s390/annotate/instructions.c
+++ b/tools/perf/arch/s390/annotate/instructions.c
@@ -2,9 +2,10 @@
 #include <linux/compiler.h>
 
 static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
-			    struct map *map)
+			    struct map_symbol *ms)
 {
 	char *endptr, *tok, *name;
+	struct map *map = ms->map;
 	struct addr_map_symbol target = {
 		.map = map,
 	};
@@ -54,7 +55,7 @@ static struct ins_ops s390_call_ops = {
 
 static int s390_mov__parse(struct arch *arch __maybe_unused,
 			   struct ins_operands *ops,
-			   struct map *map __maybe_unused)
+			   struct map_symbol *ms __maybe_unused)
 {
 	char *s = strchr(ops->raw, ','), *target, *endptr;
 
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 666f62c58e1a..3ff829d89178 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -202,9 +202,10 @@ bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2)
 	return arch->ins_is_fused(arch, ins1, ins2);
 }
 
-static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *map)
+static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
 {
 	char *endptr, *tok, *name;
+	struct map *map = ms->map;
 	struct addr_map_symbol target = {
 		.map = map,
 	};
@@ -272,7 +273,7 @@ bool ins__is_call(const struct ins *ins)
 	return ins->ops == &call_ops || ins->ops == &s390_call_ops;
 }
 
-static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map *map __maybe_unused)
+static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms __maybe_unused)
 {
 	const char *s = strchr(ops->raw, '+');
 	const char *c = strchr(ops->raw, ',');
@@ -365,7 +366,7 @@ static int comment__symbol(char *raw, char *comment, u64 *addrp, char **namep)
 	return 0;
 }
 
-static int lock__parse(struct arch *arch, struct ins_operands *ops, struct map *map)
+static int lock__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
 {
 	ops->locked.ops = zalloc(sizeof(*ops->locked.ops));
 	if (ops->locked.ops == NULL)
@@ -380,7 +381,7 @@ static int lock__parse(struct arch *arch, struct ins_operands *ops, struct map *
 		goto out_free_ops;
 
 	if (ops->locked.ins.ops->parse &&
-	    ops->locked.ins.ops->parse(arch, ops->locked.ops, map) < 0)
+	    ops->locked.ins.ops->parse(arch, ops->locked.ops, ms) < 0)
 		goto out_free_ops;
 
 	return 0;
@@ -423,7 +424,7 @@ static struct ins_ops lock_ops = {
 	.scnprintf = lock__scnprintf,
 };
 
-static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map *map __maybe_unused)
+static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms __maybe_unused)
 {
 	char *s = strchr(ops->raw, ','), *target, *comment, prev;
 
@@ -484,7 +485,7 @@ static struct ins_ops mov_ops = {
 	.scnprintf = mov__scnprintf,
 };
 
-static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map *map __maybe_unused)
+static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms __maybe_unused)
 {
 	char *target, *comment, *s, prev;
 
@@ -923,14 +924,14 @@ int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *samp
 	return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip, sample);
 }
 
-static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map)
+static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map_symbol *ms)
 {
 	dl->ins.ops = ins__find(arch, dl->ins.name);
 
 	if (!dl->ins.ops)
 		return;
 
-	if (dl->ins.ops->parse && dl->ins.ops->parse(arch, &dl->ops, map) < 0)
+	if (dl->ins.ops->parse && dl->ins.ops->parse(arch, &dl->ops, ms) < 0)
 		dl->ins.ops = NULL;
 }
 
@@ -967,7 +968,7 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
 struct annotate_args {
 	size_t			 privsize;
 	struct arch		*arch;
-	struct map		*map;
+	struct map_symbol	 ms;
 	struct perf_evsel	*evsel;
 	s64			 offset;
 	char			*line;
@@ -1049,7 +1050,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, args->map);
+			disasm_line__init_ins(dl, args->arch, &args->ms);
 		}
 	}
 
@@ -1307,7 +1308,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
 				      struct annotate_args *args,
 				      int *line_nr)
 {
-	struct map *map = args->map;
+	struct map *map = args->ms.map;
 	struct annotation *notes = symbol__annotation(sym);
 	struct disasm_line *dl;
 	char *line = NULL, *parsed_line, *tmp, *tmp2;
@@ -1354,6 +1355,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
 	args->offset  = offset;
 	args->line    = parsed_line;
 	args->line_nr = *line_nr;
+	args->ms.sym  = sym;
 
 	dl = disasm_line__new(args);
 	free(line);
@@ -1506,7 +1508,7 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
 
 static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
 {
-	struct map *map = args->map;
+	struct map *map = args->ms.map;
 	struct dso *dso = map->dso;
 	char *command;
 	FILE *file;
@@ -1705,7 +1707,6 @@ int symbol__annotate(struct symbol *sym, struct map *map,
 {
 	struct annotate_args args = {
 		.privsize	= privsize,
-		.map		= map,
 		.evsel		= evsel,
 	};
 	struct perf_env *env = perf_evsel__env(evsel);
@@ -1731,6 +1732,9 @@ int symbol__annotate(struct symbol *sym, struct map *map,
 		}
 	}
 
+	args.ms.map = map;
+	args.ms.sym = sym;
+
 	return symbol__disassemble(sym, &args);
 }
 
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 365e9df888cf..c0bf0554a9ea 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -46,7 +46,7 @@ struct arch;
 
 struct ins_ops {
 	void (*free)(struct ins_operands *ops);
-	int (*parse)(struct arch *arch, struct ins_operands *ops, struct map *map);
+	int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms);
 	int (*scnprintf)(struct ins *ins, char *bf, size_t size,
 			 struct ins_operands *ops);
 };
-- 
2.14.3

  parent reply	other threads:[~2018-03-24 20:02 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-24 20:01 [GIT PULL 00/44] perf/core improvements and fixes Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 01/44] perf unwind: Report error from dwfl_attach_state Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 02/44] perf annotate: Move annotation_options out of the TUI browser Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 03/44] perf annotate: Move cycles/IPC formatting width constants outside TUI Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 04/44] perf annotate tui: Use annotate_browser__cycles_width() mroe Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 05/44] perf annotate tui: Move have_cycles to struct annotation Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 06/44] perf annotate: Move annotation_line array from TUI to generic code Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 07/44] perf annotate: Move compute_ipc() to annotation library Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 08/44] perf annotate: Move nr_events from annotate_browser to annotation struct Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 09/44] perf annotate: Stop using a global config struct Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 10/44] perf annotate: Move pcnt_with() to the annotation library Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 11/44] perf annotate tui: Add browser__annotation() helper Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 12/44] perf annotate: Move max_jump_sources to struct annotation Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 13/44] perf annotate: Move jumps_percent_color to ui_browser Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 14/44] perf annotate: Move nr_jumps to struct annotation Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 15/44] perf annotate: Move mark_jump_targets from the TUI to the annotation library Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 16/44] perf annotate: Nuke struct browser_line Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 17/44] perf annotate: Move 'start' to struct annotation Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 18/44] perf annotate: Move nr_{asm_}entries " Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 19/44] perf annotate: Introduce set_offsets() method out of TUI code Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 20/44] perf annotate: Move the column widths from the TUI to generic lib Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 21/44] perf annotate: Move update_column_widths() to the " Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 22/44] perf annotate: Introduce init_column_widths() method out of TUI code Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 23/44] perf annotate: Introduce symbol__annotate2 method Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 24/44] perf annotate: Introduce annotation_line__max_percent() Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 25/44] perf ui browser: Add vprintf() method Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 26/44] perf annotate: Introduce annotation_line__print_start() out of TUI code Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 27/44] perf annotate: Finish the generalization of annotate_browser__write() Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 28/44] perf annotate: Use a ops table for annotation_line__write() Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 29/44] perf annotate: Introduce annotation_line__filter() Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 30/44] perf annotate: Introduce the --stdio2 output mode Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 31/44] perf annotate: Move the default annotate options to the library Arnaldo Carvalho de Melo
2018-03-24 20:01 ` [PATCH 32/44] perf annotate: Use the default annotation options for --stdio2 Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 33/44] perf annotate: Add function header to --stdio2 Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 34/44] perf annotate: Introduce --ignore-vmlinux command line option Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 35/44] perf report: " Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 36/44] perf annotate browser: Add 'P' hotkey to dump annotation to file Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 37/44] perf annotate: No need to calculate notes->start twice Arnaldo Carvalho de Melo
2018-03-24 20:02 ` Arnaldo Carvalho de Melo [this message]
2018-03-24 20:02 ` [PATCH 39/44] perf annotate: Mark jumps to outher functions with the call arrow Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 40/44] perf python: Reference Py_None before returning it Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 41/44] perf annotate: Add "_local" to jump/offset validation routines Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 42/44] perf annotate: Support jumping from one function to another Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 43/44] perf annotate: Defer searching for comma in raw line till it is needed Arnaldo Carvalho de Melo
2018-03-24 20:02 ` [PATCH 44/44] perf annotate: Use absolute addresses to calculate jump target offsets Arnaldo Carvalho de Melo
2018-03-25  8:40 ` [GIT PULL 00/44] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180324200211.21326-39-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).