linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, dsahern@gmail.com, andi@firstfloor.org,
	mingo@kernel.org, linux-kernel@vger.kernel.org,
	namhyung@kernel.org, jolsa@kernel.org, tglx@linutronix.de,
	hpa@zytor.com, peterz@infradead.org
Subject: [tip:perf/core] perf annotate: Factor annotation_line__print from disasm_line__print
Date: Sat, 18 Nov 2017 00:19:52 -0800	[thread overview]
Message-ID: <tip-29971f9a82a5d005b37d65fbb73edaf9073279b0@git.kernel.org> (raw)
In-Reply-To: <20171011150158.11895-25-jolsa@kernel.org>

Commit-ID:  29971f9a82a5d005b37d65fbb73edaf9073279b0
Gitweb:     https://git.kernel.org/tip/29971f9a82a5d005b37d65fbb73edaf9073279b0
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 11 Oct 2017 17:01:47 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 16 Nov 2017 14:49:44 -0300

perf annotate: Factor annotation_line__print from disasm_line__print

Move generic annotation line display code into annotation_line__print
function.

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-25-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c | 69 ++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 36 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5c6f739..cb065ca 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1093,24 +1093,36 @@ static void annotate__branch_printf(struct block_range *br, u64 addr)
 }
 
 
-static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 start,
-		      struct perf_evsel *evsel, u64 len, int min_pcnt, int printed,
-		      int max_lines, struct disasm_line *queue)
+static int disasm_line__print(struct disasm_line *dl, u64 start)
 {
+	s64 offset = dl->al.offset;
+	const u64 addr = start + offset;
+	struct block_range *br;
+
+	br = block_range__find(addr);
+	color_fprintf(stdout, annotate__address_color(br), "  %" PRIx64 ":", addr);
+	color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line);
+	annotate__branch_printf(br, addr);
+	return 0;
+}
+
+static int
+annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start,
+		       struct perf_evsel *evsel, u64 len, int min_pcnt, int printed,
+		       int max_lines, struct annotation_line *queue)
+{
+	struct disasm_line *dl = container_of(al, struct disasm_line, al);
 	static const char *prev_line;
 	static const char *prev_color;
 
-	if (dl->al.offset != -1) {
+	if (al->offset != -1) {
 		double max_percent = 0.0;
 		int i, nr_percent = 1;
 		const char *color;
 		struct annotation *notes = symbol__annotation(sym);
-		s64 offset = dl->al.offset;
-		const u64 addr = start + offset;
-		struct block_range *br;
 
-		for (i = 0; i < dl->al.samples_nr; i++) {
-			struct annotation_data *sample = &dl->al.samples[i];
+		for (i = 0; i < al->samples_nr; i++) {
+			struct annotation_data *sample = &al->samples[i];
 
 			if (sample->percent > max_percent)
 				max_percent = sample->percent;
@@ -1123,11 +1135,11 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
 			return 1;
 
 		if (queue != NULL) {
-			list_for_each_entry_from(queue, &notes->src->source, al.node) {
-				if (queue == dl)
+			list_for_each_entry_from(queue, &notes->src->source, node) {
+				if (queue == al)
 					break;
-				disasm_line__print(queue, sym, start, evsel, len,
-						    0, 0, 1, NULL);
+				annotation_line__print(queue, sym, start, evsel, len,
+						       0, 0, 1, NULL);
 			}
 		}
 
@@ -1138,17 +1150,17 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
 		 * the same color than the percentage. Don't print it
 		 * twice for close colored addr with the same filename:line
 		 */
-		if (dl->al.path) {
-			if (!prev_line || strcmp(prev_line, dl->al.path)
+		if (al->path) {
+			if (!prev_line || strcmp(prev_line, al->path)
 				       || color != prev_color) {
-				color_fprintf(stdout, color, " %s", dl->al.path);
-				prev_line = dl->al.path;
+				color_fprintf(stdout, color, " %s", al->path);
+				prev_line = al->path;
 				prev_color = color;
 			}
 		}
 
 		for (i = 0; i < nr_percent; i++) {
-			struct annotation_data *sample = &dl->al.samples[i];
+			struct annotation_data *sample = &al->samples[i];
 
 			color = get_percent_color(sample->percent);
 
@@ -1164,10 +1176,7 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
 
 		printf(" :	");
 
-		br = block_range__find(addr);
-		color_fprintf(stdout, annotate__address_color(br), "  %" PRIx64 ":", addr);
-		color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line);
-		annotate__branch_printf(br, addr);
+		disasm_line__print(dl, start);
 		printf("\n");
 	} else if (max_lines && printed >= max_lines)
 		return 1;
@@ -1180,27 +1189,15 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
 		if (perf_evsel__is_group_event(evsel))
 			width *= evsel->nr_members;
 
-		if (!*dl->al.line)
+		if (!*al->line)
 			printf(" %*s:\n", width, " ");
 		else
-			printf(" %*s:	%s\n", width, " ", dl->al.line);
+			printf(" %*s:	%s\n", width, " ", al->line);
 	}
 
 	return 0;
 }
 
-static int
-annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 start,
-		       struct perf_evsel *evsel, u64 len, int min_pcnt, int printed,
-		       int max_lines, struct annotation_line *aq)
-{
-	struct disasm_line *dl    = container_of(al, struct disasm_line, al);
-	struct disasm_line *queue = container_of(aq, struct disasm_line, al);
-
-	return disasm_line__print(dl, sym, start, evsel, len, min_pcnt, printed,
-				  max_lines, queue);
-}
-
 /*
  * symbol__parse_objdump_line() parses objdump output (with -d --no-show-raw)
  * which looks like following

  reply	other threads:[~2017-11-18  8:23 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 15:01 [PATCH 00/35] perf annotate: Use generic annotation line Jiri Olsa
2017-10-11 15:01 ` [PATCH 01/35] perf annotate: Remove arch::cpuid_parse callback Jiri Olsa
2017-10-24 10:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 02/35] perf annotate: Add annotation_line struct Jiri Olsa
2017-10-11 15:29   ` Arnaldo Carvalho de Melo
2017-10-11 19:12     ` Jiri Olsa
2017-11-18  8:10   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 03/35] perf annotate: Move line/offset into " Jiri Olsa
2017-11-18  8:11   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 04/35] perf annotate: Move ipc/cycles " Jiri Olsa
2017-11-18  8:11   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 05/35] perf annotate: Add symbol__annotate function Jiri Olsa
2017-11-18  8:12   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 06/35] perf annotate: Add struct annotate_args Jiri Olsa
2017-11-18  8:12   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 07/35] perf annotate: Add arch into " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 08/35] perf annotate: Add map " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 09/35] perf annotate: Add offset/line/line_nr " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 10/35] perf annotate: Add evsel into struct annotation_line_args Jiri Olsa
2017-11-18  8:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 11/35] perf annotate: Add annotation_line__next function Jiri Olsa
2017-11-18  8:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 12/35] perf annotate: Add annotation_line__add function Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 13/35] perf annotate: Move rb_node into struct annotation_line Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] perf annotate: Move rb_node to " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 14/35] perf annotate: Add annotation_line__(new|free) functions Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] perf annotate: Add annotation_line__(new|delete) functions tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 15/35] perf annotate: Add annotated_source__purge function Jiri Olsa
2017-11-18  8:16   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 16/35] perf annotate: Add samples into struct annotation_line Jiri Olsa
2017-11-13 15:46   ` Ravi Bangoria
2017-11-13 20:14     ` Jiri Olsa
2017-11-14  9:31       ` Jiri Olsa
2017-11-14 10:15         ` Ravi Bangoria
2017-11-14 10:29           ` Jiri Olsa
2017-11-15 14:04             ` Jiri Olsa
2017-11-16  4:27               ` Ravi Bangoria
2017-11-18  8:16   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 17/35] perf annotate: Add symbol__calc_percent function Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 18/35] perf annotate: Add symbol__calc_lines function Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 19/35] perf annotate: Remove disasm__calc_percent from disasm_line__print Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] perf annotate: Remove disasm__calc_percent() from disasm_line__print() tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 20/35] perf annotate: Remove disasm__calc_percent from annotate_browser__calc_percent Jiri Olsa
2017-11-18  8:18   ` [tip:perf/core] perf annotate: Remove disasm__calc_percent() from annotate_browser__calc_percent() tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 21/35] perf annotate: Remove disasm__calc_percent function Jiri Olsa
2017-11-18  8:18   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 22/35] perf annotate: Remove struct source_line Jiri Olsa
2017-11-18  8:19   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 23/35] perf annotate: Add annotation_line__print function Jiri Olsa
2017-11-18  8:19   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 24/35] perf annotate: Factor annotation_line__print from disasm_line__print Jiri Olsa
2017-11-18  8:19   ` tip-bot for Jiri Olsa [this message]
2017-10-11 15:01 ` [PATCH 25/35] perf annotate browser: Use samples data from struct annotation_line Jiri Olsa
2017-11-18  8:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 26/35] perf annotate browser: Do not pass nr_events in disasm_rb_tree__insert Jiri Olsa
2017-11-18  8:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 27/35] perf annotate browser: Rename struct browser_disasm_line to browser_line Jiri Olsa
2017-11-06 10:55   ` [PATCHv2 " Jiri Olsa
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 28/35] perf annotate browser: Rename disasm_line__browser " Jiri Olsa
2017-11-06 10:55   ` [PATCHv2 " Jiri Olsa
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 29/35] perf annotate browser: Change selection to struct annotation_line Jiri Olsa
2017-11-06 10:56   ` [PATCHv2 " Jiri Olsa
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 30/35] perf annotate browser: Change offsets " Jiri Olsa
2017-11-18  8:22   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 31/35] perf annotate browser: Use struct annotation_line in browser_line Jiri Olsa
2017-11-18  8:22   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 32/35] perf annotate browser: Use struct annotation_line in find functions Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 33/35] perf annotate browser: Use struct annotation_line in browser top Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 34/35] perf annotate browser: Add disasm_line__write function Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 35/35] perf annotate: Align source and offset lines Jiri Olsa
2017-11-07 14:10   ` Arnaldo Carvalho de Melo
2017-11-07 14:50     ` Jiri Olsa
2017-11-18  8:24   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:27 ` [PATCH 00/35] perf annotate: Use generic annotation line Arnaldo Carvalho de Melo
2017-10-11 19:10   ` Jiri Olsa
2017-10-11 19:18     ` Arnaldo Carvalho de Melo
2017-10-11 19:30       ` Jiri Olsa
2017-10-11 19:43         ` Arnaldo Carvalho de Melo
2017-11-02 12:16 ` Jiri Olsa
2017-11-03 16:59   ` Arnaldo Carvalho de Melo
2017-11-04 10:29     ` Jiri Olsa
2017-11-06 10:56       ` Jiri Olsa

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=tip-29971f9a82a5d005b37d65fbb73edaf9073279b0@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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).